From 818f888fa2d244553e21431b948ef07db9814de8 Mon Sep 17 00:00:00 2001 From: PKief Date: Sun, 9 Sep 2018 17:10:18 +0200 Subject: [PATCH] Adapting the extension to the new Settings GUI --- package-lock.json | 24 +++++++++++------------ package.json | 29 +++++++++++++++++++++++----- package.nls.de.json | 10 +++++++++- package.nls.es.json | 8 ++++++++ package.nls.fr.json | 8 ++++++++ package.nls.json | 8 ++++++++ package.nls.pt-BR.json | 8 ++++++++ package.nls.pt-PT.json | 8 ++++++++ package.nls.ru.json | 8 ++++++++ package.nls.zh-CN.json | 10 +++++++++- src/helpers/changeDetection.ts | 4 ++-- src/icons/generator/iconOpacity.ts | 6 +----- src/icons/generator/jsonGenerator.ts | 8 +++++++- 13 files changed, 112 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 766ad914d4..bae1d2256d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,15 +17,15 @@ "dev": true }, "@types/node": { - "version": "10.7.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.1.tgz", - "integrity": "sha512-EGoI4ylB/lPOaqXqtzAyL8HcgOuCtH2hkEaLmkueOYufsTFWBn4VCvlCDC2HW8Q+9iF+QVC3sxjDKQYjHQeZ9w==", + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", + "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", "dev": true }, "@types/puppeteer": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-1.6.0.tgz", - "integrity": "sha512-I7M8S3bmgH4WozaPWMbe6MxTQ7P2jyWLVhsV5ZY/K3FkkG9Knei99783dlCtQS+rlkbhDBgBEjFhl7UoMr5/tw==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-1.6.3.tgz", + "integrity": "sha512-LckvRjv9yE47H3zg1w8zaA0sxtW7EAxVGz2RsPMIZkTtVfl8M8/8o1GvD6xXEH1H5JrbAUjL37EhRMFi4Oe+Zg==", "dev": true, "requires": { "@types/events": "*", @@ -1778,9 +1778,9 @@ "dev": true }, "puppeteer": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.7.0.tgz", - "integrity": "sha512-f+1DxKHPqce6CXUBz2eVO2WcATeVeQSOPG9GYaGObEZDCiCEUwG+gogjMsrvn7he2wHTqNVb5p6RUrwmr8XFBA==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.8.0.tgz", + "integrity": "sha512-wJ7Fxs03l4dy/ZXQACUKBBobIuJaS4NHq44q7/QinpAXFMwJMJFEIPjzoksVzUhZxQe+RXnjXH69mg13yMh0BA==", "dev": true, "requires": { "debug": "^3.1.0", @@ -2235,9 +2235,9 @@ "dev": true }, "typescript": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", - "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.3.tgz", + "integrity": "sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==", "dev": true }, "unique-stream": { diff --git a/package.json b/package.json index 2c4e125c59..ea90bf1cd7 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,21 @@ "material-icon-theme.activeIconPack": { "type": "string", "default": "angular", - "description": "%configuration.activeIconPack%" + "description": "%configuration.activeIconPack%", + "enumDescriptions": [ + "%configuration.activeIconPack.angular%", + "%configuration.activeIconPack.angular_ngrx%", + "%configuration.activeIconPack.react%", + "%configuration.activeIconPack.react_redux%", + "%configuration.activeIconPack.none%" + ], + "enum": [ + "angular", + "angular_ngrx", + "react", + "react_redux", + "none" + ] }, "material-icon-theme.files.associations": { "type": "object", @@ -115,6 +129,11 @@ "type": "string", "default": "specific", "description": "%configuration.folders.theme%", + "enumDescriptions": [ + "%configuration.folders.theme.specific%", + "%configuration.folders.theme.classic%", + "%configuration.folders.theme.none%" + ], "enum": [ "specific", "classic", @@ -164,14 +183,14 @@ }, "devDependencies": { "@types/mocha": "^5.2.5", - "@types/node": "^10.7.1", - "@types/puppeteer": "^1.6.0", + "@types/node": "^10.9.4", + "@types/puppeteer": "^1.6.3", "mocha": "^5.2.0", - "puppeteer": "^1.7.0", + "puppeteer": "^1.8.0", "rimraf": "^2.6.2", "ts-node": "^7.0.1", "tslint": "^5.11.0", - "typescript": "^3.0.1", + "typescript": "^3.0.3", "vscode": "^1.1.21" } } diff --git a/package.nls.de.json b/package.nls.de.json index 6c9987efc0..548ed4e1ef 100644 --- a/package.nls.de.json +++ b/package.nls.de.json @@ -13,8 +13,16 @@ "configuration.showWelcomeMessage": "Willkommensnachricht nach der ersten Installation anzeigen.", "configuration.showUpdateMessage": "Nachricht bei Aktualisierungen anzeigen.", "configuration.showReloadMessage": "Nachricht zum Neustarten anzeigen.", - "configuration.activeIconPack": "Icon Paket auswählen, die bestimme Icons aktivieren.", + "configuration.activeIconPack": "Icon-Pack auswählen, die bestimme Icons aktivieren.", + "configuration.activeIconPack.angular": "Icons für Angular", + "configuration.activeIconPack.angular_ngrx": "Icons für Angular und Ngrx", + "configuration.activeIconPack.react": "Icons für React", + "configuration.activeIconPack.react_redux": "Icons für React und Redux", + "configuration.activeIconPack.none": "Kein Icon-Pack aktiviert.", "configuration.folders.theme": "Art der Ordner Icons auswählen.", + "configuration.folders.theme.specific": "Spezifische Ordner Icons auswählen.", + "configuration.folders.theme.classic": "Klassische Ordner Icons auswählen.", + "configuration.folders.theme.none": "Keine Ordner Icons.", "configuration.folders.color": "Farbe der Ordner Icons verändern.", "configuration.hidesExplorerArrows": "Pfeile vor den Ordnern deaktivieren.", "configuration.opacity": "Deckkraft der Icons anpassen." diff --git a/package.nls.es.json b/package.nls.es.json index e8408fa0a5..56df845512 100644 --- a/package.nls.es.json +++ b/package.nls.es.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "Mostrar mensaje al actualizar.", "configuration.showReloadMessage": "Mostrar mensaje de reinicio.", "configuration.activeIconPack": "Seleccione un paquete de iconos que permita iconos específicos.", + "configuration.activeIconPack.angular": "Iconos de Angular.", + "configuration.activeIconPack.angular_ngrx": "Iconos de Angular y ngrx.", + "configuration.activeIconPack.react": "Iconos de React.", + "configuration.activeIconPack.react_redux": "Iconos de React y Redux.", + "configuration.activeIconPack.none": "No hay ningún paquete de iconos activo.", "configuration.folders.theme": "Seleccione el tipo de iconos de carpeta.", + "configuration.folders.theme.specific": "Seleccione iconos de carpeta específicos.", + "configuration.folders.theme.classic": "Seleccione iconos de carpetas clásicas.", + "configuration.folders.theme.none": "Sin iconos de carpeta.", "configuration.folders.color": "Cambia el color de las carpetas.", "configuration.hidesExplorerArrows": "Deshabilitar flechas delante de carpetas.", "configuration.opacity": "Cambia la opacidad de los iconos." diff --git a/package.nls.fr.json b/package.nls.fr.json index ee5eae485c..6f95723d16 100644 --- a/package.nls.fr.json +++ b/package.nls.fr.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "Afficher le message de mise à jour.", "configuration.showReloadMessage": "Afficher le message de redémarrage.", "configuration.activeIconPack": "Sélectionner un pack d'icônes qui active des icônes spécifiques.", + "configuration.activeIconPack.angular": "Icônes pour Angular.", + "configuration.activeIconPack.angular_ngrx": "Icônes pour Angular et ngrx.", + "configuration.activeIconPack.react": "Icônes pour React.", + "configuration.activeIconPack.react_redux": "Icônes pour React et Redux.", + "configuration.activeIconPack.none": "Aucun pack d'icônes n'est actif.", "configuration.folders.theme": "Sélectionner le type d'icônes de dossier.", + "configuration.folders.theme.specific": "Sélectionner des icônes de dossiers spécifiques.", + "configuration.folders.theme.classic": "Sélectionner les icônes des dossiers classiques.", + "configuration.folders.theme.none": "Pas d'icônes de dossier.", "configuration.folders.color": "Changer la couleur des icônes du dossier.", "configuration.hidesExplorerArrows": "Désactiver les flèches devant les dossiers.", "configuration.opacity": "Ajuster l'opacité des icônes." diff --git a/package.nls.json b/package.nls.json index ee55b0a32b..59f8abd611 100644 --- a/package.nls.json +++ b/package.nls.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "Show the update message after each update.", "configuration.showReloadMessage": "Show restart notification.", "configuration.activeIconPack": "Select an icon pack that enables specific icons.", + "configuration.activeIconPack.angular": "Icons for Angular.", + "configuration.activeIconPack.angular_ngrx": "Icons for Angular and ngrx.", + "configuration.activeIconPack.react": "Icons for React.", + "configuration.activeIconPack.react_redux": "Icons for React and Redux.", + "configuration.activeIconPack.none": "No icon pack enabled.", "configuration.folders.theme": "Set the type for the folder icons.", + "configuration.folders.theme.specific": "Select specific folder icons.", + "configuration.folders.theme.classic": "Select classic folder icons.", + "configuration.folders.theme.none": "No folder icons.", "configuration.folders.color": "Change the color of the folder icons.", "configuration.hidesExplorerArrows": "Hide explorer arrows before folder.", "configuration.opacity": "Change the opacity of the icons." diff --git a/package.nls.pt-BR.json b/package.nls.pt-BR.json index dfcda1d2b0..0f619cfec4 100644 --- a/package.nls.pt-BR.json +++ b/package.nls.pt-BR.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "Mostrar mensagem de atualização após cada atualização.", "configuration.showReloadMessage": "Mostrar mensagem da reinicialização.", "configuration.activeIconPack": "Selecione um pacote de ícones que habilitam ícones específicos.", + "configuration.activeIconPack.angular": "Ícones para Angular.", + "configuration.activeIconPack.angular_ngrx": "Ícones para Angular e ngrx.", + "configuration.activeIconPack.react": "Ícones para React.", + "configuration.activeIconPack.react_redux": "Ícones para React e ngrx.", + "configuration.activeIconPack.none": "Nenhum pacote de ícones ativado.", "configuration.folders.theme": "Definir o tipo dos ícones das pastas.", + "configuration.folders.theme.specific": "Selecione ícones de pastas específicas.", + "configuration.folders.theme.classic": "Selecione ícones de pastas clássicas.", + "configuration.folders.theme.none": "Nenhum ícone de pasta.", "configuration.folders.color": "Alterar a cor dos ícones das pastas.", "configuration.hidesExplorerArrows": "Ocultar as setas ao lado das pastas no explorador de arquivos.", "configuration.opacity": "Alterar a opacidade dos ícones." diff --git a/package.nls.pt-PT.json b/package.nls.pt-PT.json index 009dee0caf..be4f9979d5 100644 --- a/package.nls.pt-PT.json +++ b/package.nls.pt-PT.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "Exibir mensagem de actualização após cada actualização.", "configuration.showReloadMessage": "Exibir mensagem da reinicialização.", "configuration.activeIconPack": "Selecciona um pacote de ícones que habilitam ícones específicos.", + "configuration.activeIconPack.angular": "Ícones para Angular.", + "configuration.activeIconPack.angular_ngrx": "Ícones para Angular e ngrx.", + "configuration.activeIconPack.react": "Ícones para React.", + "configuration.activeIconPack.react_redux": "Ícones para React e ngrx.", + "configuration.activeIconPack.none": "Nenhum pacote de ícones ativado.", "configuration.folders.theme": "Definir o formato dos ícones dos directórios.", + "configuration.folders.theme.specific": "Selecciona ícones de pastas específicas.", + "configuration.folders.theme.classic": "Selecciona ícones de pastas clássicas.", + "configuration.folders.theme.none": "Nenhum ícone de pasta.", "configuration.folders.color": "Alterar a cor dos ícones dos directórios.", "configuration.hidesExplorerArrows": "Esconder as setas ao lado dos directórios no explorador de ficheiros.", "configuration.opacity": "Alterar a opacidade dos ícones." diff --git a/package.nls.ru.json b/package.nls.ru.json index fb1b8b671b..3c9374e2a4 100644 --- a/package.nls.ru.json +++ b/package.nls.ru.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "Показывать сообщение об обновлении после каждого обновления.", "configuration.showReloadMessage": "Показывать сообщение перезагрузки.", "configuration.activeIconPack": "Выберите набор значков, которые включают определенные значки.", + "configuration.activeIconPack.angular": "Иконки для Angular.", + "configuration.activeIconPack.angular_ngrx": "Иконки для Angular и ngrx.", + "configuration.activeIconPack.react": "Иконки для React.", + "configuration.activeIconPack.react_redux": "Иконки для React и Redux.", + "configuration.activeIconPack.none": "Папка с иконками не включена.", "configuration.folders.theme": "Установить тип иконок для папок.", + "configuration.folders.theme.specific": "Выберите конкретные значки папок.", + "configuration.folders.theme.classic": "Выберите классические значки папок.", + "configuration.folders.theme.none": "Нет значков папок.", "configuration.folders.color": "Изменение цвета иконок папок.", "configuration.hidesExplorerArrows": "Скрыть стрелки проводника перед папкой.", "configuration.opacity": "Измените прозрачность значков." diff --git a/package.nls.zh-CN.json b/package.nls.zh-CN.json index ff8a0d27f4..b0c988e5b6 100644 --- a/package.nls.zh-CN.json +++ b/package.nls.zh-CN.json @@ -14,7 +14,15 @@ "configuration.showUpdateMessage": "更新后显示升级信息。", "configuration.showReloadMessage": "显示重启消息。", "configuration.activeIconPack": "选择一个图标包。", - "configuration.folders.theme": "设置文件夹图标类型。\n接受的值为 \"specific\", \"classic\"和\"none\"。", + "configuration.activeIconPack.angular": "Angular的图标。", + "configuration.activeIconPack.angular_ngrx": "Angular和ngrx的图标。", + "configuration.activeIconPack.react": "React的图标。", + "configuration.activeIconPack.react_redux": "React和Redux的图标。", + "configuration.activeIconPack.none": "没有启用图标包。", + "configuration.folders.theme": "设置文件夹图标的类型。", + "configuration.folders.theme.specific": "选择特定文件夹图标。", + "configuration.folders.theme.classic": "选择经典文件夹图标。", + "configuration.folders.theme.none": "没有文件夹图标。", "configuration.folders.color": "更改文件夹图标的颜色。", "configuration.hidesExplorerArrows": "隐藏该文件夹旁边的箭头。", "configuration.opacity": "更改图标的透明度。" diff --git a/src/helpers/changeDetection.ts b/src/helpers/changeDetection.ts index 385f0db8fb..10f11b9908 100644 --- a/src/helpers/changeDetection.ts +++ b/src/helpers/changeDetection.ts @@ -33,10 +33,10 @@ const compareConfigs = (configs: string[]): Promise<{ updatedConfigs: IconJsonOp // no further actions (e.g. reload) required if (/show(Welcome|Update|Reload)Message/g.test(configName)) return result; - const configValue = getThemeConfig(configName).globalValue; + const configValue = getThemeConfig(configName).globalValue || getThemeConfig(configName).defaultValue; const currentState = getObjectPropertyValue(json.options, configName); - if (configValue !== undefined && JSON.stringify(configValue) !== JSON.stringify(currentState)) { + if (JSON.stringify(configValue) !== JSON.stringify(currentState)) { setObjectPropertyValue(json.options, configName, configValue); setObjectPropertyValue(result.updatedConfigs, configName, configValue); } diff --git a/src/icons/generator/iconOpacity.ts b/src/icons/generator/iconOpacity.ts index 214874a7b4..ed0f478ff3 100644 --- a/src/icons/generator/iconOpacity.ts +++ b/src/icons/generator/iconOpacity.ts @@ -7,10 +7,6 @@ import * as path from 'path'; * @param fileNames Only change the opacity of certain file names. */ export const setIconOpacity = (opacity: number, fileNames?: string[]) => { - if (!validateOpacityValue(opacity)) { - return console.error('Invalid opacity value! Opacity must be a decimal number between 0 and 1!'); - } - return new Promise((resolve, reject) => { let iconsPath = path.join(__dirname, '..', '..', '..'); const parentFolder = iconsPath.split(path.sep).pop(); @@ -57,7 +53,7 @@ export const setIconOpacity = (opacity: number, fileNames?: string[]) => { * @param opacity Opacity value */ export const validateOpacityValue = (opacity: number) => { - return opacity <= 1 && opacity >= 0; + return opacity !== null && opacity <= 1 && opacity >= 0; }; /** diff --git a/src/icons/generator/jsonGenerator.ts b/src/icons/generator/jsonGenerator.ts index 158a3c2fef..b1cd0cad7d 100644 --- a/src/icons/generator/jsonGenerator.ts +++ b/src/icons/generator/jsonGenerator.ts @@ -6,7 +6,7 @@ import { fileIcons } from '../fileIcons'; import { folderIcons } from '../folderIcons'; import { languageIcons } from '../languageIcons'; import { iconJsonName } from './constants'; -import { generateFolderIcons, getFileIconDefinitions, getFolderIconDefinitions, getLanguageIconDefinitions, setIconOpacity } from './index'; +import { generateFolderIcons, getFileIconDefinitions, getFolderIconDefinitions, getLanguageIconDefinitions, setIconOpacity, validateOpacityValue } from './index'; /** * Generate the complete icon configuration object that can be written as JSON file. @@ -32,11 +32,17 @@ export const createIconFile = async (updatedConfigs?: IconJsonOptions, updatedJS const iconJSONPath = path.join(__dirname, '../../../', 'src', iconJsonName); const json = generateIconConfigurationObject(options); + // make sure that the opacity value must be entered correctly to trigger a reload. + if (updatedConfigs && updatedConfigs.opacity && !validateOpacityValue(updatedConfigs.opacity)) { + return Promise.reject('Material Icons: Invalid opacity value!'); + } + try { await fs.writeFile(iconJSONPath, JSON.stringify(json, undefined, 2), async (err) => { if (err) { throw Error(err.message); } + // if updatedConfigs do not exist (because of initial setup) // or new config value was detected by the change detection if (!updatedConfigs || (updatedConfigs.folders || {}).color) {