Feat/generator 3 iteration (#399)

* fix: vscode tasks and removed gulp files

* chore: cleanup deps and remove babel references

* chore: switch from cp to ncp
This commit is contained in:
Alessio Occhipinti 2019-12-24 11:28:38 +01:00 committed by Mattia Astorino
parent f11a9cda4c
commit 1ddcebf4c0
11 changed files with 28 additions and 1212 deletions

View file

@ -1,5 +0,0 @@
{
"presets": [
"env"
]
}

View file

@ -1,5 +0,0 @@
export const HR: string = '\n———————————————————————————————————————————————————————————————\n';
export const MESSAGE_BUMP_ERROR: string = ' There was an issue bumping version:\n';
export const MESSAGE_BUMP_SUCCESS: string = ' Finished successfully\n';
export const MESSAGE_GENERATED: string = 'Generated';
export const MESSAGE_THEME_VARIANT_PARSE_ERROR: string = 'Error when parsing json for theme variants';

View file

@ -1,8 +0,0 @@
// export the tasks
// export * from './tasks/themes';
export * from './tasks/watcher';
export * from './tasks/changelog-title';
export * from './tasks/copy-ui';
// export default script
export default ['build:copy-ui'];

View file

@ -1,42 +0,0 @@
export interface IThemeVariant {
id: string;
name: string;
scheme: {
background: string;
base: {
black: string;
blue: string;
brown: string;
cyan: string;
green: string;
orange: string;
paleblue: string;
pink: string;
purple: string;
red: string;
violet: string;
white: string;
yellow: string;
}
caret: string;
comments: string;
findHighlight: string;
focusBorder: string;
foreground: string;
guides: string;
inputBackground: string;
inputBorder: string;
inputForeground: string;
invisibles: string;
lineHighlight: string;
lineNumbers: string;
listHoverForeground: string;
scrollbars: string;
scrollbarsHover: string;
selection: string;
shadow: string;
sidebarForeground: string;
statusbarForeground: string;
}
type: string;
}

View file

@ -1,10 +0,0 @@
import * as fs from 'fs';
import * as gulp from 'gulp';
import {CHARSET} from '../../src/consts/files';
export default gulp.task('changelog-title', () => {
fs.writeFileSync(
'./CHANGELOG.md',
fs.readFileSync('CHANGELOG.md', CHARSET).replace('# Change Log', '# Material Theme Changelog'),
{encoding: CHARSET});
});

View file

@ -1,24 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
import * as gulp from 'gulp';
import {PATHS} from '../../src/consts/paths';
import {ensureDir} from '../../src/helpers/fs';
export default gulp.task('build:copy-ui', callback => {
try {
ensureDir(path.resolve(PATHS.UI));
fs.copyFileSync(
path.join(PATHS.SRC, 'webviews', 'ui', 'release-notes', 'release-notes.html'),
path.join(PATHS.UI, 'release-notes.html')
);
fs.copyFileSync(
path.join(PATHS.SRC, 'webviews', 'ui', 'release-notes', 'style.css'),
path.join(PATHS.UI, 'release-notes.css')
);
} catch (error) {
return callback(error);
}
callback();
});

View file

@ -1,59 +0,0 @@
import * as fs from 'fs';
import * as gulp from 'gulp';
import * as gulpUtil from 'gulp-util';
import * as mustache from 'mustache';
import * as path from 'path';
import {HR, MESSAGE_GENERATED, MESSAGE_THEME_VARIANT_PARSE_ERROR} from './../consts/log';
import {CHARSET} from './../../src/consts/files';
import {IThemeVariant} from './../interfaces/itheme-variant';
import paths from './../../src/consts/paths';
import {ensureDir, getDefaultValues} from './../../src/helpers/fs';
const commons = getDefaultValues();
const themeTemplateFileContent: string = fs.readFileSync(path.join(paths.SRC, '/themes/theme-template-color-theme.json'), CHARSET);
const themeVariants: IThemeVariant[] = [];
const fileNames: string[] = fs.readdirSync(path.join(paths.SRC, './themes/settings/specific'));
// build theme variants for later use in templating
fileNames.forEach(fileName => {
const filePath: string = path.join(paths.SRC, './themes/settings/specific', `./${fileName}`);
const contents: string = fs.readFileSync(filePath, CHARSET);
try {
themeVariants.push(JSON.parse(contents));
} catch (error) {
gulpUtil.log(MESSAGE_THEME_VARIANT_PARSE_ERROR, error);
}
});
/**
* Themes task
* Builds Themes
*/
export default gulp.task('build:themes', cb => {
gulpUtil.log(gulpUtil.colors.gray(HR));
ensureDir(path.join(paths.THEMES));
try {
themeVariants.forEach(variant => {
const filePath = path.join(paths.THEMES, `./${variant.name}.json`);
const templateData = {commons, variant};
const templateJSON: any = JSON.parse(mustache.render(themeTemplateFileContent, templateData));
const templateJSONStringified: string = JSON.stringify(templateJSON, null, 2);
fs.writeFileSync(filePath, templateJSONStringified, {encoding: CHARSET});
gulpUtil.log(MESSAGE_GENERATED, gulpUtil.colors.green(filePath));
});
} catch (exception) {
gulpUtil.log(exception);
cb(exception);
}
gulpUtil.log(gulpUtil.colors.gray(HR));
});

View file

@ -1,14 +0,0 @@
import * as gulp from 'gulp';
import * as path from 'path';
import Paths from './../../src/consts/paths';
/*
* > Watcher
* Watches files and build the themes
*/
export default gulp.task('watch', () => {
// Commented due
// gulp.watch(path.join(Paths.SRC, `./themes/**/*.json`), ['build:themes']);
gulp.watch(path.join(Paths.SRC, './themes/**/*.json'));
});

75
.vscode/tasks.json vendored
View file

@ -6,16 +6,15 @@
// ${fileExtname}: the current opened file's extension // ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process // ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension. // A task runner that calls a custom npm script that compiles the extension.
{ {
"version": "2.0.0", "version": "2.0.0",
// tasks list (build, build-theme, semver etc)
"tasks": [ "tasks": [
{ {
"args": [ "args": [
"run",
"build" "build"
], ],
"command": "npm", "command": "yarn",
"dependsOn": "tsc", "dependsOn": "tsc",
"label": "build", "label": "build",
"group": { "group": {
@ -23,76 +22,6 @@
"isDefault": true "isDefault": true
}, },
"problemMatcher": [] "problemMatcher": []
},
{
"linux": {
"args": [
".",
"-name",
"\"*.js\"",
"-not",
"-path",
"\"./node_modules/*\"",
"-not",
"-path",
"\"./src/*\"",
"-not",
"-path",
"\"./test/*\"",
"-type",
"f",
"-delete"
],
"command": "find"
},
"osx": {
"args": [
".",
"-name",
"\"*.js\"",
"-not",
"-path",
"\"./node_modules/*\"",
"-not",
"-path",
"\"./src/*\"",
"-not",
"-path",
"\"./test/*\"",
"-type",
"f",
"-delete"
],
"command": "find"
},
"command": "",
"label": "clean project"
},
{
"args": [
"run",
"changelog"
],
"command": "npm",
"label": "changelog"
},
{
"args": [
"run",
"build:ts"
],
"command": "npm",
"dependsOn": "clean project",
"label": "tsc"
},
{
"args": [
"run",
"build-ui-only"
],
"command": "npm",
"label": "UI: build UI only",
"problemMatcher": []
} }
] ]
} }

View file

@ -29,7 +29,7 @@
"lint": "eslint .", "lint": "eslint .",
"build:ui": "node dist/scripts/ui/index.js", "build:ui": "node dist/scripts/ui/index.js",
"build:generate-themes": "node dist/scripts/generator/index.js", "build:generate-themes": "node dist/scripts/generator/index.js",
"build:ts": "tsc -p ./tsconfig.json && cp -r dist/src/ build", "build:ts": "tsc -p ./tsconfig.json && ncp dist/src/ build",
"postinstall": "node ./node_modules/vscode/bin/install && opencollective postinstall && tsc -p tsconfig.json" "postinstall": "node ./node_modules/vscode/bin/install && opencollective postinstall && tsc -p tsconfig.json"
}, },
"categories": [ "categories": [
@ -157,26 +157,19 @@
} }
], ],
"devDependencies": { "devDependencies": {
"@babel/register": "7.4.4",
"@moxer/vscode-theme-generator": "1.1.0", "@moxer/vscode-theme-generator": "1.1.0",
"@types/browserify": "12.0.36", "@types/browserify": "12.0.36",
"@types/gulp-if": "0.0.33",
"@types/gulp-util": "3.0.34",
"@types/mustache": "0.8.32",
"@types/rimraf": "2.0.2", "@types/rimraf": "2.0.2",
"@typescript-eslint/eslint-plugin": "2.12.0", "@typescript-eslint/eslint-plugin": "2.12.0",
"@typescript-eslint/parser": "2.12.0", "@typescript-eslint/parser": "2.12.0",
"babel-core": "6.26.3",
"babel-preset-env": "1.7.0",
"browserify": "16.2.2", "browserify": "16.2.2",
"eslint": "6.7.2", "eslint": "6.7.2",
"eslint-config-xo-space": "0.22.0", "eslint-config-xo-space": "0.22.0",
"eslint-config-xo-typescript": "0.23.0", "eslint-config-xo-typescript": "0.23.0",
"fs-extra": "8.1.0", "fs-extra": "8.1.0",
"mustache": "3.0.1", "ncp": "2.0.0",
"typescript": "3.7.4", "typescript": "3.7.4",
"vscode": "1.1.36", "vscode": "1.1.36"
"yargs": "15.0.2"
}, },
"__metadata": { "__metadata": {
"id": "dffaf5a1-2219-434b-9d87-cb586fd59260", "id": "dffaf5a1-2219-434b-9d87-cb586fd59260",

985
yarn.lock

File diff suppressed because it is too large Load diff