From c2a3cb7ee517babc29c8f5d393bb99e67e293817 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 1 Oct 2016 13:07:15 -0700 Subject: [PATCH] Initial commit --- .editorconfig | 9 +++++ .gitignore | 5 +++ README.md | 3 ++ out/.vscode/launch.json | 13 +++++++ out/package.json | 18 ++++++++++ package.json | 19 ++++++++++ src/index.ts | 78 +++++++++++++++++++++++++++++++++++++++++ theme.json | 1 + tsconfig.json | 12 +++++++ typings.json | 6 ++++ 10 files changed, 164 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 README.md create mode 100644 out/.vscode/launch.json create mode 100644 out/package.json create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 theme.json create mode 100644 tsconfig.json create mode 100644 typings.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..86a63dc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3fcc2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +dist/ +node_modules/ +typings/ + +out/theme.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..c4718ec --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +```bash +npm run build +``` \ No newline at end of file diff --git a/out/.vscode/launch.json b/out/.vscode/launch.json new file mode 100644 index 0000000..ecf1110 --- /dev/null +++ b/out/.vscode/launch.json @@ -0,0 +1,13 @@ +// A launch configuration that launches the extension inside a new window +{ + "version": "0.1.0", + "configurations": [ + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": ["--extensionDevelopmentPath=${workspaceRoot}" ] + } + ] +} diff --git a/out/package.json b/out/package.json new file mode 100644 index 0000000..b125baa --- /dev/null +++ b/out/package.json @@ -0,0 +1,18 @@ +{ + "name": "generated-theme", + "displayName": "Generated THeme", + "description": "...", + "categories": [ "Themes" ], + "version": "0.0.1", + "publisher": "vscode", + "engines": { "vscode": "*" }, + "contributes": { + "themes": [ + { + "label": "Generated theme", + "uiTheme": "vs-dark", + "path": "./theme.json" + } + ] + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..8ba1f3c --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "theme-generator", + "version": "0.0.1", + "description": "Generates editor/terminal themes using a set of colors", + "main": "dist/index.js", + "scripts": { + "build": "typings install && tsc" + }, + "author": "Tyriar", + "license": "MIT", + "typescript": { + "definition": "index.d.ts" + }, + "devDependencies": { + "@types/node": "^6.0.41", + "typescript": "^2.0.3", + "typings": "^1.4.0" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..83b3f38 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,78 @@ +/// + +import * as fs from 'fs'; +import * as path from 'path'; + +console.log('test'); + +interface IColorSet { + ansiGroups?: { + ansiNormal?: IAnsiColorSet; + ansiBright?: IAnsiColorSet; + } + syntaxGroups?: { + constant?: string; + identifier?: string; + statement?: string; + type?: string; + global?: string; + emphasis?: string; + special?: string; + trivial?: string; + } + uiGroups?: { + userActionNeeded?: string; + userCurrentState?: string; + backgroundState?: string; + background?: string; + foreground?: string; + } +} + +interface IAnsiColorSet { + black?: string; + red?: string; + green?: string; + yellow?: string; + blue?: string; + magenta?: string; + cyan?: string; + white?: string; +} + +interface IThemeGenerator { + generateTheme(colorSet: IColorSet): string; +} + +interface IVscodeJsonTheme { + name?: string; + include?: string; + settings?: any[]; +} + +class VscodeThemeGenerator implements IThemeGenerator { + public generateTheme(colorSet: IColorSet): string { + let theme: IVscodeJsonTheme = {}; + theme.name = 'Generated theme'; + theme.settings = []; + if (colorSet.syntaxGroups.identifier) { + theme.settings.push({ + 'name': 'Function declarations', + 'scope': 'entity.name.function', + 'settings': { + 'foreground': colorSet.syntaxGroups.identifier + } + }); + } + return JSON.stringify(theme); + } +} + +const colorSet: IColorSet = { + syntaxGroups: { + identifier: '#F00' + } +}; +const themeJson = new VscodeThemeGenerator().generateTheme(colorSet); +const outputFile = path.join(__dirname, '..', 'out', 'theme.json') +fs.writeFileSync(outputFile, themeJson); \ No newline at end of file diff --git a/theme.json b/theme.json new file mode 100644 index 0000000..bfe24d0 --- /dev/null +++ b/theme.json @@ -0,0 +1 @@ +{"name":"Generated theme","settings":[{"name":"Function declarations","scope":"entity.name.function","settings":{"foreground":"#F00"}}]} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c846234 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "declaration": true, + "module": "commonjs", + "target": "es5", + "noImplicitAny": true, + "outDir": "dist" + }, + "files": [ + "src/index.ts" + ] +} \ No newline at end of file diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..69ef9f8 --- /dev/null +++ b/typings.json @@ -0,0 +1,6 @@ +{ + "name": "theme-generator", + "globalDependencies": { + "node": "registry:env/node#6.0.0+20160918225031" + } +}