From 5913e6a4ba5865c7375d453ca37204cf115f6872 Mon Sep 17 00:00:00 2001 From: OctoD Date: Mon, 12 Jun 2017 20:11:51 +0200 Subject: [PATCH] chore: Moves dirs consts out of .gulp directory. --- .gulp/tasks/icons-accents.ts | 31 ++++++------------- .gulp/tasks/icons.ts | 2 +- .gulp/tasks/themes.ts | 2 +- .gulp/tasks/watcher.ts | 2 +- .../accents-setter/accented-theme-name.ts | 7 +++++ {.gulp => extensions}/consts/paths.ts | 0 6 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 extensions/accents-setter/accented-theme-name.ts rename {.gulp => extensions}/consts/paths.ts (100%) diff --git a/.gulp/tasks/icons-accents.ts b/.gulp/tasks/icons-accents.ts index cc83304..c83f99c 100644 --- a/.gulp/tasks/icons-accents.ts +++ b/.gulp/tasks/icons-accents.ts @@ -9,7 +9,8 @@ import { MESSAGE_GENERATED, MESSAGE_ICON_ACCENTS_ERROR } from "../consts/log"; import { CHARSET } from "../consts/files"; import { IThemeConfigCommons } from '../../extensions/interfaces/icommons'; import { IThemeIconsAccents } from "../interfaces/itheme-icons-accents"; -import PATHS from '../consts/paths' +import PATHS from '../../extensions/consts/paths' +import accentedThemeName from "../../extensions/accents-setter/accented-theme-name"; const BASE_ICON_THEME_PATH: string = path.join(process.cwd(), PATHS.THEMES, './Material-Theme-Icons.json'); const THEME_COMMONS: IThemeConfigCommons = require('../../extensions/accents-setter/commons.json'); @@ -21,24 +22,6 @@ const PACKAGE_JSON_ICON_THEME: IPackageJSONThemeIcons = { path: "./themes/Material-Theme-Icons.json" } -/** - * Gets file path - * @param {string} filename - * @returns {string} - */ -function getFilepath(filename: string): string { - return path.join(PATHS.THEMES, filename); -} - -/** - * Icon theme name - * @param {string} accentName - * @returns {string} - */ -function makefileName(accentName: string): string { - return `./Material-Theme-Icons-${ accentName }.json`; -} - /** * Normalizes icon path * @param {string} iconPath @@ -104,7 +87,11 @@ export default gulp.task('build:icons.accents', cb => { Object.keys(THEME_COMMONS.accents).forEach(key => { let iconName = replaceWhiteSpaces(key); let themecopy: IThemeIconsAccents = JSON.parse(JSON.stringify(basetheme)); - let themePath: string = getFilepath(makefileName(key)); + let themePath: string = accentedThemeName(key); + + let id: string = `${ PACKAGE_JSON_ICON_THEME.id }-${ key.replace(/\s+/g, '-').toLowerCase() }`; + let label: string = `${ PACKAGE_JSON_ICON_THEME.label } - ${ key } accent`; + let path: string = `./${ themePath }`; themecopy.iconDefinitions._folder_open.iconPath = replaceNameWithAccent(basetheme.iconDefinitions._folder_open.iconPath, iconName); themecopy.iconDefinitions._folder_open_build.iconPath = replaceNameWithAccent(basetheme.iconDefinitions._folder_open_build.iconPath, iconName); @@ -114,12 +101,12 @@ export default gulp.task('build:icons.accents', cb => { fs.writeFileSync(themePath, JSON.stringify(themecopy)); - PACKAGE_JSON + PACKAGE_JSON.contributes.iconThemes.push({ id, label, path }); gutil.log(gutil.colors.green(MESSAGE_GENERATED, themePath)); }); - fs.writeFileSync(path.join(process.cwd(), './package.test.json'), JSON.stringify(PACKAGE_JSON, null, 2), CHARSET); + fs.writeFileSync(path.join(process.cwd(), './package.json'), JSON.stringify(PACKAGE_JSON, null, 2), CHARSET); } catch (error) { // http://ragefaces.memesoftware.com/faces/large/misc-le-fu-l.png diff --git a/.gulp/tasks/icons.ts b/.gulp/tasks/icons.ts index 6d486a4..63c6460 100644 --- a/.gulp/tasks/icons.ts +++ b/.gulp/tasks/icons.ts @@ -9,7 +9,7 @@ import { HR, MESSAGE_GENERATED, MESSAGE_ICON_ERROR } from './../consts/log'; import { CHARSET } from '../consts/files'; import { IIcon } from './../interfaces/iicon'; import { IPlainObject } from '../interfaces/iplain-object'; -import paths from '../consts/paths'; +import paths from '../../extensions/consts/paths'; /** * Returns an object implementing the IIcon interface diff --git a/.gulp/tasks/themes.ts b/.gulp/tasks/themes.ts index a934af9..d58c5e3 100644 --- a/.gulp/tasks/themes.ts +++ b/.gulp/tasks/themes.ts @@ -8,7 +8,7 @@ import { HR, MESSAGE_GENERATED, MESSAGE_THEME_VARIANT_PARSE_ERROR } from './../c import { CHARSET } from '../consts/files'; import { IThemeVariant } from './../interfaces/itheme-variant'; -import paths from '../consts/paths'; +import paths from '../../extensions/consts/paths'; let commons = require('../../extensions/accents-setter/commons.json'); diff --git a/.gulp/tasks/watcher.ts b/.gulp/tasks/watcher.ts index 0cd75e3..43d185b 100644 --- a/.gulp/tasks/watcher.ts +++ b/.gulp/tasks/watcher.ts @@ -1,7 +1,7 @@ import * as gulp from "gulp"; import * as path from "path"; -import Paths from "../consts/paths"; +import Paths from "../../extensions/consts/paths"; /* * > Watcher diff --git a/extensions/accents-setter/accented-theme-name.ts b/extensions/accents-setter/accented-theme-name.ts new file mode 100644 index 0000000..ffdb837 --- /dev/null +++ b/extensions/accents-setter/accented-theme-name.ts @@ -0,0 +1,7 @@ +import * as path from 'path'; + +import PATHS from '../consts/paths' + +export default function accentedThemeName(accentName: string): string { + return path.join(PATHS.THEMES, `./Material-Theme-Icons-${ accentName }.json`); +} \ No newline at end of file diff --git a/.gulp/consts/paths.ts b/extensions/consts/paths.ts similarity index 100% rename from .gulp/consts/paths.ts rename to extensions/consts/paths.ts