Browse Source

chore(build): Build/linting infrastructure updates. (#276)

* Move npm/linting config files to root directory
* Apply prettier/eslint autofixes
* Update CONTRIBUTING.md
pull/277/head
Josh Dick 3 years ago
committed by GitHub
parent
commit
d954737e00
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      .eslintrc.json
  2. 1
      .github/ISSUE_TEMPLATE.md
  3. 2
      .gitignore
  4. 0
      .husky/.gitignore
  5. 1
      .husky/pre-commit
  6. 0
      .npmrc
  7. 6
      .prettierrc
  8. 34
      CONTRIBUTING.md
  9. 84
      README.md
  10. 28
      build/.eslintrc.json
  11. 322
      build/build.js
  12. 2197
      build/package-lock.json
  13. 28
      build/package.json
  14. 4610
      package-lock.json
  15. 45
      package.json

10
.eslintrc.json

@ -0,0 +1,10 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"no-console": ["off"]
}
}

1
.github/ISSUE_TEMPLATE.md

@ -6,6 +6,7 @@
Thank you!
-->
- [ ] I have carefully read and followed the [Installation section of the README](https://github.com/joshdick/onedark.vim#installation)
- [ ] I have searched through the [closed issues](https://github.com/joshdick/onedark.vim/issues?q=is%3Aissue+is%3Aclosed) to see if there is an existing solution for my issue

2
.gitignore

@ -1 +1 @@
build/node_modules
node_modules

0
build/.husky/.gitignore → .husky/.gitignore

1
build/.husky/pre-commit → .husky/pre-commit

@ -1,2 +1 @@
cd build
npm test

0
build/.npmrc → .npmrc

6
.prettierrc

@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none"
}

34
CONTRIBUTING.md

@ -14,23 +14,22 @@ The basic idea is that these files are generated by a build tool that substitute
Here are the locations of the files that are generated by the build system, along with the locations of the corresponding templates they are generated from:
| Theme Location | Template Location |
|----------------------------------------------|------------------------------------------|
| `autoload/onedark.vim` | `build/templates/autoload.template.vim` |
| `term/One Dark.Xresources` | `build/templates/One Dark.Xresources` |
| `term/One Dark.itermcolors` | `build/templates/One Dark.itermcolors` |
| `term/One Dark.terminal` | `build/templates/One Dark.terminal` |
| `term/One Dark.alacritty` | `build/templates/One Dark.alacritty` |
| `term/One Dark.colorscheme` | `build/templates/One Dark.colorscheme` |
| Theme Location | Template Location |
| --------------------------- | --------------------------------------- |
| `autoload/onedark.vim` | `build/templates/autoload.template.vim` |
| `term/One Dark.Xresources` | `build/templates/One Dark.Xresources` |
| `term/One Dark.itermcolors` | `build/templates/One Dark.itermcolors` |
| `term/One Dark.terminal` | `build/templates/One Dark.terminal` |
| `term/One Dark.alacritty` | `build/templates/One Dark.alacritty` |
| `term/One Dark.colorscheme` | `build/templates/One Dark.colorscheme` |
### Configure It
1) Install [Node.js](https://nodejs.org/en/) (Installing via [nvm](https://github.com/creationix/nvm) or [homebrew](https://brew.sh) are both better options than the official Node.js installer.)
1. Install [Node.js](https://nodejs.org/en/) (Installing via [nvm](https://github.com/creationix/nvm) or [homebrew](https://brew.sh) are both better options than the official Node.js installer.)
2) Run the following from within the root of this repository. This will install the build system's dependencies and will automatically configure a Git pre-commit hook that runs `npm test` (see below).
2. Run the following from within the root of this repository. This will install the build system's dependencies and will automatically configure a Git pre-commit hook that runs `npm test` (see below).
```bash
> cd build
> npm install
```
@ -38,16 +37,17 @@ That's it!
### Use It
The build system consists of a single Node.js script, `build.js`, which supports two commands:
The build system consists of a single Node.js script, `build/build.js`, which supports two commands:
* Running `./build.js` or `npm run build` generates theme files from the templates, **overwriting changes to the theme files without confirmation.**
* Running `./build.js check` or `npm test` checks that the theme files match the template-generated output, **without modifying theme files**. This command ensures that the theme files perfectly match the templates they are generated from, which is useful for detecting changes that were made to generated theme files but that should have been made in the templates. (In addition to running `./build.js check`, `npm test` also runs [eslint](http://eslint.org) linting on the build system code to catch and prevent simple problems with changes to that code.)
- Running `./build/build.js` or `npm run build` generates theme files from the templates, **overwriting changes to the theme files without confirmation.**
- Running `./build/build.js check` or `npm test` checks that the theme files match the template-generated output, **without modifying theme files**. This command ensures that the theme files perfectly match the templates they are generated from, which is useful for detecting changes that were made to generated theme files but that should have been made in the templates.
- In addition to running `./build/build.js check`, `npm test` also runs linting and style checks on certain files to catch and prevent simple problems and stylistic inconsistency. If `npm test` reports any issues, many reported issues can be automatically fixed by running `npm run lint:fix`.)
The basic development workflow looks like this:
1. Make changes to the appropriate template files in `build/templates`, then run `npm run build` from inside the `build` directory.
1. Make changes to the appropriate template files in `build/templates`, then run `npm run build`.
2. Commit your change in Git. `npm test` will automatically run before your commit is finalized. If the test fails, fix any inconsistencies between the template files and theme files (or linting errors in `build.js` if applicable), then try committing again.
2. Commit your changes with Git. `npm test` will automatically run before your commit is finalized. If the test fails, fix any inconsistencies between the template files and theme files (or linting/style errors if applicable), then try committing again.
## Style Guidelines
@ -55,7 +55,7 @@ Please match the existing comment and whitespace style in all template files.
For the "Language-Specific Highlighting" portion of onedark.vim, blocks for each language should be organized alphabetically ("Markdown" comes before "PHP").
Any changes to the JavaScript code in the build system should pass against the included eslint rules; you can manually check for linting errors by running `npm test` from inside the `build` directory.
All code changes should pass against the included linting and style checks. These checks are run via [husky](https://www.npmjs.com/package/husky) and [lint-staged](https://www.npmjs.com/package/lint-staged) when you attempt to commit changes. You can manually check for linting and stylistic issues by running `npm test`, and many reported issues can be automatically fixed by running `npm run lint:fix`.
## Thanks!

84
README.md

@ -10,19 +10,19 @@ A dark Vim/Neovim color scheme for the GUI and 16/256/true-color terminals, base
onedark.vim includes support for the following Vim and Neovim plugins:
* [airblade/vim-gitgutter](https://github.com/airblade/vim-gitgutter)
* [dense-analysis/ale](https://github.com/dense-analysis/ale)
* [easymotion/vim-easymotion](https://github.com/easymotion/vim-easymotion)
* [itchyny/lightline.vim](https://github.com/itchyny/lightline.vim)
* [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
* [mhinz/vim-signify](https://github.com/mhinz/vim-signify)
* [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
* [neomake/neomake](https://github.com/neomake/neomake)
* [Neovim LSP](https://neovim.io/doc/user/lsp.html)
* [plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
* [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
* [tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)
* [vim-airline/vim-airline](https://github.com/vim-airline/vim-airline)
- [airblade/vim-gitgutter](https://github.com/airblade/vim-gitgutter)
- [dense-analysis/ale](https://github.com/dense-analysis/ale)
- [easymotion/vim-easymotion](https://github.com/easymotion/vim-easymotion)
- [itchyny/lightline.vim](https://github.com/itchyny/lightline.vim)
- [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
- [mhinz/vim-signify](https://github.com/mhinz/vim-signify)
- [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
- [neomake/neomake](https://github.com/neomake/neomake)
- [Neovim LSP](https://neovim.io/doc/user/lsp.html)
- [plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
- [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
- [tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)
- [vim-airline/vim-airline](https://github.com/vim-airline/vim-airline)
## Installation
@ -77,11 +77,11 @@ onedark.vim includes support for the following Vim and Neovim plugins:
**Note:** All options should be set **before** the `colorscheme onedark` line in your `~/.vimrc`.
* `g:onedark_hide_endofbuffer`: Set to `1` if you want to hide end-of-buffer filler lines (~) for a cleaner look; `0` otherwise (the default).
- `g:onedark_hide_endofbuffer`: Set to `1` if you want to hide end-of-buffer filler lines (~) for a cleaner look; `0` otherwise (the default).
* `g:onedark_termcolors` **(see [Troubleshooting](#troubleshooting) (below) for more information about this option)**: Set to `256` for 256-color terminals (the default), or set to `16` to use your terminal emulator's native 16 colors.
- `g:onedark_termcolors` **(see [Troubleshooting](#troubleshooting) (below) for more information about this option)**: Set to `256` for 256-color terminals (the default), or set to `16` to use your terminal emulator's native 16 colors.
* `g:onedark_terminal_italics`: Set to `1` if your terminal emulator supports italics; `0` otherwise (the default).
- `g:onedark_terminal_italics`: Set to `1` if your terminal emulator supports italics; `0` otherwise (the default).
## lightline.vim Colorscheme
@ -91,8 +91,8 @@ This repository includes a companion [lightline.vim](https://github.com/itchyny/
The lightline.vim colorscheme:
* Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
* Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
- Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
- Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
### Installation
@ -114,9 +114,9 @@ This repository includes a companion [vim-airline](https://github.com/vim-airlin
The vim-airline theme:
* Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
* Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
* Is based on vim-airline's ["tomorrow" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/tomorrow.vim).
- Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
- Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
- Is based on vim-airline's ["tomorrow" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/tomorrow.vim).
### Installation
@ -146,23 +146,23 @@ However, you can use the `g:onedark_termcolors` option to control onedark.vim's
**When Vim/Neovim are configured to use 24-bit color, the `g:onedark_termcolors` option is ignored. However, `g:onedark_termcolors` can still coexist with 24-bit color configuration.** For instance, when tmux 2.1 or earlier and/or older Vim/Neovim versions that don't support 24-bit color are used, the `g:onedark_termcolors` option will take effect.
* **256-color mode** is enabled by default with no additional configuration, but colors are less accurate since they are approximated using a 256-color palette. The background color will appear darker than in the preview image, and most other colors will appear brighter than in the preview image. If you don't want to change your terminal's color palette as described in the 16-color mode section below, and your terminal doesn't support 24-bit color, 256-color mode is your only option.
- **256-color mode** is enabled by default with no additional configuration, but colors are less accurate since they are approximated using a 256-color palette. The background color will appear darker than in the preview image, and most other colors will appear brighter than in the preview image. If you don't want to change your terminal's color palette as described in the 16-color mode section below, and your terminal doesn't support 24-bit color, 256-color mode is your only option.
Although 256-color mode is enabled by default (when not using 24-bit color as described above), you can explicitly enable it by adding the following line to your `~/.vimrc`:
Although 256-color mode is enabled by default (when not using 24-bit color as described above), you can explicitly enable it by adding the following line to your `~/.vimrc`:
```vim
let g:onedark_termcolors=256
```
```vim
let g:onedark_termcolors=256
```
* **16-color mode** is the preferred option, since its colors are more accurate than those of 256-color mode. However, you'll need to set your terminal emulator's color palette to this color scheme's custom 16-color palette, since 16-color mode will cause the color scheme to use your terminal emulator's native 16 colors. If you don't use the custom 16-color palette in your terminal emulator when 16-color mode is enabled, onedark.vim's colors will not display correctly in Vim.
- **16-color mode** is the preferred option, since its colors are more accurate than those of 256-color mode. However, you'll need to set your terminal emulator's color palette to this color scheme's custom 16-color palette, since 16-color mode will cause the color scheme to use your terminal emulator's native 16 colors. If you don't use the custom 16-color palette in your terminal emulator when 16-color mode is enabled, onedark.vim's colors will not display correctly in Vim.
The canonical version of the 16-color palette is an [Xresources](https://en.wikipedia.org/wiki/X_resources) file located in this repository at `term/One Dark.Xresources`. Color schemes for various terminal emulators are also provided in `term/`. (The [iTerm2](https://iterm2.com/) color scheme works with iTerm2 versions 2.9.x and later.) You should be able to easily convert the Xresources color scheme for use with your terminal emulator of choice either by hand, or automatically by using [termcolors](https://github.com/stayradiated/termcolors).
The canonical version of the 16-color palette is an [Xresources](https://en.wikipedia.org/wiki/X_resources) file located in this repository at `term/One Dark.Xresources`. Color schemes for various terminal emulators are also provided in `term/`. (The [iTerm2](https://iterm2.com/) color scheme works with iTerm2 versions 2.9.x and later.) You should be able to easily convert the Xresources color scheme for use with your terminal emulator of choice either by hand, or automatically by using [termcolors](https://github.com/stayradiated/termcolors).
Assuming your terminal emulator is configured to use the custom 16-color palette as described above, add the following line to your `~/.vimrc` to enable 16-color mode:
Assuming your terminal emulator is configured to use the custom 16-color palette as described above, add the following line to your `~/.vimrc` to enable 16-color mode:
```vim
let g:onedark_termcolors=16
```
```vim
let g:onedark_termcolors=16
```
### Why do all comments look like they're highlighted?
@ -254,18 +254,18 @@ Several other themes and projects have reused code and/or colors from this proje
If onedark.vim isn't meeting your needs, try one of its relatives!
* [drewtempelmeyer/palenight.vim](https://github.com/drewtempelmeyer/palenight.vim)
* [KeitaNakamura/neodark.vim](https://github.com/KeitaNakamura/neodark.vim)
* [base16-onedark.vim](https://github.com/chriskempson/base16-vim/blob/master/colors/base16-onedark.vim)
* Associated base16 scheme: [tilal6991/base16-onedark-scheme](https://github.com/tilal6991/base16-onedark-scheme)
* [rakr/vim-one](https://github.com/rakr/vim-one)
* For Neovim >= 0.5 with treesitter support: [navarasu/onedark.nvim](https://github.com/navarasu/onedark.nvim)
* Neovim-only Lua port: [ii14/onedark.nvim](https://github.com/ii14/onedark.nvim)
- [drewtempelmeyer/palenight.vim](https://github.com/drewtempelmeyer/palenight.vim)
- [KeitaNakamura/neodark.vim](https://github.com/KeitaNakamura/neodark.vim)
- [base16-onedark.vim](https://github.com/chriskempson/base16-vim/blob/master/colors/base16-onedark.vim)
- Associated base16 scheme: [tilal6991/base16-onedark-scheme](https://github.com/tilal6991/base16-onedark-scheme)
- [rakr/vim-one](https://github.com/rakr/vim-one)
- For Neovim >= 0.5 with treesitter support: [navarasu/onedark.nvim](https://github.com/navarasu/onedark.nvim)
- Neovim-only Lua port: [ii14/onedark.nvim](https://github.com/ii14/onedark.nvim)
### Preview images
Preview images were taken using:
* [iTerm2](https://iterm2.com) terminal emulator on macOS
* 13 pt. [PragmataPro Mono](http://www.fsd.it/fonts/pragmatapro.htm#.VlDa1q6rTOY) font
* [vim-polyglot](https://github.com/sheerun/vim-polyglot) plug-in
- [iTerm2](https://iterm2.com) terminal emulator on macOS
- 13 pt. [PragmataPro Mono](http://www.fsd.it/fonts/pragmatapro.htm#.VlDa1q6rTOY) font
- [vim-polyglot](https://github.com/sheerun/vim-polyglot) plug-in

28
build/.eslintrc.json

@ -1,28 +0,0 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"no-console": [
"off"
],
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
}
}

322
build/build.js

@ -1,179 +1,185 @@
#!/usr/bin/env node
const _ = require('lodash') // ships with termcolors; only used because of termcolors customization
const termcolors = require('termcolors')
const { readFileSync, writeFileSync } = require('fs')
const { resolve } = require('path')
const _ = require('lodash'); // ships with termcolors; only used because of termcolors customization
const termcolors = require('termcolors');
const { readFileSync, writeFileSync } = require('fs');
const { resolve } = require('path');
const baseColors = Object.freeze({
red: { gui: '#E06C75', cterm: '204', cterm16: '1' }, // alternate cterm: 168
dark_red: { gui: '#BE5046', cterm: '196', cterm16: '9' },
green: { gui: '#98C379', cterm: '114', cterm16: '2' },
yellow: { gui: '#E5C07B', cterm: '180', cterm16: '3' },
dark_yellow: { gui: '#D19A66', cterm: '173', cterm16: '11' },
blue: { gui: '#61AFEF', cterm: '39', cterm16: '4' }, // alternate cterm: 75
purple: { gui: '#C678DD', cterm: '170', cterm16: '5' }, // alternate cterm: 176
cyan: { gui: '#56B6C2', cterm: '38', cterm16: '6' }, // alternate cterm: 73
white: { gui: '#ABB2BF', cterm: '145', cterm16 : '7' },
black: { gui: '#282C34', cterm: '235', cterm16: '0' }
})
red: { gui: '#E06C75', cterm: '204', cterm16: '1' }, // alternate cterm: 168
dark_red: { gui: '#BE5046', cterm: '196', cterm16: '9' },
green: { gui: '#98C379', cterm: '114', cterm16: '2' },
yellow: { gui: '#E5C07B', cterm: '180', cterm16: '3' },
dark_yellow: { gui: '#D19A66', cterm: '173', cterm16: '11' },
blue: { gui: '#61AFEF', cterm: '39', cterm16: '4' }, // alternate cterm: 75
purple: { gui: '#C678DD', cterm: '170', cterm16: '5' }, // alternate cterm: 176
cyan: { gui: '#56B6C2', cterm: '38', cterm16: '6' }, // alternate cterm: 73
white: { gui: '#ABB2BF', cterm: '145', cterm16: '7' },
black: { gui: '#282C34', cterm: '235', cterm16: '0' }
});
const specialColors = Object.freeze({
comment_grey: { gui: '#5C6370', cterm: '59', cterm16: '15' },
gutter_fg_grey: { gui: '#4B5263', cterm: '238', cterm16: '15' },
cursor_grey: { gui: '#2C323C', cterm: '236', cterm16: '8' },
visual_grey: { gui: '#3E4452', cterm: '237', cterm16: '15' },
menu_grey: { cterm16: '8' }, // vim theme handles gui/cterm values
special_grey: { gui: '#3B4048', cterm: '238', cterm16: '15' },
vertsplit: { gui: '#181A1F', cterm: '59', cterm16: '15' },
})
comment_grey: { gui: '#5C6370', cterm: '59', cterm16: '15' },
gutter_fg_grey: { gui: '#4B5263', cterm: '238', cterm16: '15' },
cursor_grey: { gui: '#2C323C', cterm: '236', cterm16: '8' },
visual_grey: { gui: '#3E4452', cterm: '237', cterm16: '15' },
menu_grey: { cterm16: '8' }, // vim theme handles gui/cterm values
special_grey: { gui: '#3B4048', cterm: '238', cterm16: '15' },
vertsplit: { gui: '#181A1F', cterm: '59', cterm16: '15' }
});
const colors = Object.assign({}, baseColors, specialColors)
const colors = Object.assign({}, baseColors, specialColors);
const templateMap = Object.freeze({
'templates/autoload.template.vim': '../autoload/onedark.vim',
'templates/One Dark.Xresources': '../term/One Dark.Xresources'
})
'templates/autoload.template.vim': '../autoload/onedark.vim',
'templates/One Dark.Xresources': '../term/One Dark.Xresources'
});
const shouldCheck = String(process.argv[2]).toLowerCase() === 'check'
const shouldCheck = String(process.argv[2]).toLowerCase() === 'check';
const handleError = (message, cause) => {
console.error('Error:', message)
if (cause) console.error('Cause:', cause)
process.exit(-1)
}
console.error('Error:', message);
if (cause) console.error('Cause:', cause);
process.exit(-1);
};
console.log(
shouldCheck ?
'Checking for inconsistencies between templates and existing output files...'
:
'Generating output files from templates...'
)
shouldCheck
? 'Checking for inconsistencies between templates and existing output files...'
: 'Generating output files from templates...'
);
Object.keys(templateMap).forEach(templateFilename => {
// Read the template
const templatePath = resolve(__dirname, templateFilename)
let templateText
try {
templateText = readFileSync(templatePath, 'utf8')
} catch (e) {
handleError(`Error reading template ${templatePath}`, e)
}
// Compile the template
let template
try {
template = _.template(templateText)
} catch (e) {
handleError(`Error compiling template ${templatePath}`, e)
}
// Execute the template (generate the output)
let output
try {
output = template(colors)
} catch (e) {
handleError(`Error running template ${templatePath}`, e)
}
let outputPath = resolve(__dirname, templateMap[templateFilename])
try {
const existingOutput = readFileSync(outputPath, 'utf8')
// Only need to do something if the generated output differs from what's already on disk
if (output !== existingOutput) {
if (shouldCheck) { // Check generated output against existing output file
handleError(`Changes were made to ${templateMap[templateFilename]} that are inconsistent with its template (${templateFilename}).\nDo you need to [re]build?`)
} else { // Overwrite existing output file
try {
writeFileSync(outputPath, output, 'utf8')
} catch (e) {
handleError(`Error writing to output file ${outputPath}`, e)
}
}
}
} catch (e) {
handleError(`Error reading existing output file ${outputPath}`, e)
}
})
// Read the template
const templatePath = resolve(__dirname, templateFilename);
let templateText;
try {
templateText = readFileSync(templatePath, 'utf8');
} catch (e) {
handleError(`Error reading template ${templatePath}`, e);
}
// Compile the template
let template;
try {
template = _.template(templateText);
} catch (e) {
handleError(`Error compiling template ${templatePath}`, e);
}
// Execute the template (generate the output)
let output;
try {
output = template(colors);
} catch (e) {
handleError(`Error running template ${templatePath}`, e);
}
let outputPath = resolve(__dirname, templateMap[templateFilename]);
try {
const existingOutput = readFileSync(outputPath, 'utf8');
// Only need to do something if the generated output differs from what's already on disk
if (output !== existingOutput) {
if (shouldCheck) {
// Check generated output against existing output file
handleError(
`Changes were made to ${templateMap[templateFilename]} that are inconsistent with its template (${templateFilename}).\nDo you need to [re]build?`
);
} else {
// Overwrite existing output file
try {
writeFileSync(outputPath, output, 'utf8');
} catch (e) {
handleError(`Error writing to output file ${outputPath}`, e);
}
}
}
} catch (e) {
handleError(`Error reading existing output file ${outputPath}`, e);
}
});
try {
// Use the Xresources theme as a color source since it was generated above via templating
const xresources = readFileSync(resolve(__dirname, '../term/One Dark.Xresources'), 'utf8')
const terminalPalette = termcolors.xresources.import(xresources)
let alacrittyTemplate, itermTemplate, kittyTemplate, konsoleTemplate, terminalAppTemplate
// Compile custom terminal color templates based on ones that ship with termcolors
try {
alacrittyTemplate = termcolors.export(
readFileSync(resolve(__dirname, 'templates/One Dark.alacritty')),
_.partialRight(_.mapValues, function (color) {
return color.toHex().slice(1)
})
)
itermTemplate = termcolors.export(
// From termcolors/lib/formats/iterm.js
readFileSync(resolve(__dirname, 'templates/One Dark.itermcolors')),
_.partialRight(_.mapValues, function (color) {
return color.toAvgRgbArray()
})
)
kittyTemplate = termcolors.export(
readFileSync(resolve(__dirname, 'templates/One Dark.kitty')),
_.partialRight(_.mapValues, function (color) {
return color.toHex().slice(1)
})
)
konsoleTemplate = termcolors.export(
// From termcolors/lib/formats/konsole.js
readFileSync(resolve(__dirname, 'templates/One Dark.colorscheme')),
_.partialRight(_.mapValues, function (color) {
return color.toRgbArray().join()
})
)
// From termcolors/lib/formats/terminal-app.js
const code = [
Buffer.from('62706c6973743030d40102030405061516582476657273696f6e58246f626a65637473592461726368697665725424746f7012000186a0a307080f55246e756c6cd3090a0b0c0d0e554e535247425c4e53436f6c6f7253706163655624636c6173734f1027', 'hex'),
Buffer.from('0010018002d2101112135a24636c6173736e616d655824636c6173736573574e53436f6c6f72a21214584e534f626a6563745f100f4e534b657965644172636869766572d1171854726f6f74800108111a232d32373b41484e5b628c8e9095a0a9b1b4bdcfd2d700000000000001010000000000000019000000000000000000000000000000d9', 'hex')
]
terminalAppTemplate = termcolors.export(
readFileSync(resolve(__dirname, 'templates/One Dark.terminal')),
// From termcolors/lib/formats/terminal-app.js
_.partialRight(_.mapValues, function (color) {
var srgb = color.toAvgRgbArray()
srgb = srgb.map(function (n) {
return n.toFixed(10).toString()
}).join(' ')
var output = code[0].toString('binary') + srgb + code[1].toString('binary')
output = (Buffer.from(output, 'binary')).toString('base64')
return output.match(/.{1,68}/g).join('\n\t')
})
)
} catch (e) {
handleError('Error compiling terminal color template', e)
}
try {
writeFileSync(resolve(__dirname, '../term/One Dark.alacritty'), alacrittyTemplate(terminalPalette))
writeFileSync(resolve(__dirname, '../term/One Dark.itermcolors'), itermTemplate(terminalPalette))
writeFileSync(resolve(__dirname, '../term/One Dark.kitty'), kittyTemplate(terminalPalette))
writeFileSync(resolve(__dirname, '../term/One Dark.colorscheme'), konsoleTemplate(terminalPalette))
writeFileSync(resolve(__dirname, '../term/One Dark.terminal'), terminalAppTemplate(terminalPalette))
} catch (e) {
handleError('Error writing terminal color file', e)
}
// Use the Xresources theme as a color source since it was generated above via templating
const xresources = readFileSync(resolve(__dirname, '../term/One Dark.Xresources'), 'utf8');
const terminalPalette = termcolors.xresources.import(xresources);
let alacrittyTemplate, itermTemplate, kittyTemplate, konsoleTemplate, terminalAppTemplate;
// Compile custom terminal color templates based on ones that ship with termcolors
try {
alacrittyTemplate = termcolors.export(
readFileSync(resolve(__dirname, 'templates/One Dark.alacritty')),
_.partialRight(_.mapValues, function (color) {
return color.toHex().slice(1);
})
);
itermTemplate = termcolors.export(
// From termcolors/lib/formats/iterm.js
readFileSync(resolve(__dirname, 'templates/One Dark.itermcolors')),
_.partialRight(_.mapValues, function (color) {
return color.toAvgRgbArray();
})
);
kittyTemplate = termcolors.export(
readFileSync(resolve(__dirname, 'templates/One Dark.kitty')),
_.partialRight(_.mapValues, function (color) {
return color.toHex().slice(1);
})
);
konsoleTemplate = termcolors.export(
// From termcolors/lib/formats/konsole.js
readFileSync(resolve(__dirname, 'templates/One Dark.colorscheme')),
_.partialRight(_.mapValues, function (color) {
return color.toRgbArray().join();
})
);
// From termcolors/lib/formats/terminal-app.js
const code = [
Buffer.from(
'62706c6973743030d40102030405061516582476657273696f6e58246f626a65637473592461726368697665725424746f7012000186a0a307080f55246e756c6cd3090a0b0c0d0e554e535247425c4e53436f6c6f7253706163655624636c6173734f1027',
'hex'
),
Buffer.from(
'0010018002d2101112135a24636c6173736e616d655824636c6173736573574e53436f6c6f72a21214584e534f626a6563745f100f4e534b657965644172636869766572d1171854726f6f74800108111a232d32373b41484e5b628c8e9095a0a9b1b4bdcfd2d700000000000001010000000000000019000000000000000000000000000000d9',
'hex'
)
];
terminalAppTemplate = termcolors.export(
readFileSync(resolve(__dirname, 'templates/One Dark.terminal')),
// From termcolors/lib/formats/terminal-app.js
_.partialRight(_.mapValues, function (color) {
var srgb = color.toAvgRgbArray();
srgb = srgb
.map(function (n) {
return n.toFixed(10).toString();
})
.join(' ');
var output = code[0].toString('binary') + srgb + code[1].toString('binary');
output = Buffer.from(output, 'binary').toString('base64');
return output.match(/.{1,68}/g).join('\n\t');
})
);
} catch (e) {
handleError('Error compiling terminal color template', e);
}
try {
writeFileSync(resolve(__dirname, '../term/One Dark.alacritty'), alacrittyTemplate(terminalPalette));
writeFileSync(resolve(__dirname, '../term/One Dark.itermcolors'), itermTemplate(terminalPalette));
writeFileSync(resolve(__dirname, '../term/One Dark.kitty'), kittyTemplate(terminalPalette));
writeFileSync(resolve(__dirname, '../term/One Dark.colorscheme'), konsoleTemplate(terminalPalette));
writeFileSync(resolve(__dirname, '../term/One Dark.terminal'), terminalAppTemplate(terminalPalette));
} catch (e) {
handleError('Error writing terminal color file', e);
}
} catch (e) {
handleError('Error reading Xresources terminal color file', e)
handleError('Error reading Xresources terminal color file', e);
}
console.log('Success!')
console.log('Success!');

2197
build/package-lock.json

File diff suppressed because it is too large

28
build/package.json

@ -1,28 +0,0 @@
{
"name": "onedark.vim-builder",
"version": "1.0.0",
"description": "Builds the onedark.vim Vim colorscheme and associated files",
"main": "build.js",
"scripts": {
"build": "node build.js",
"test": "eslint build.js && node build.js check",
"prepare": "cd .. && husky install build/.husky"
},
"author": {
"name": "Josh Dick",
"email": "josh@joshdick.net",
"url": "http://joshdick.net"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/joshdick/onedark.vim.git"
},
"devDependencies": {
"eslint": "^7.29.0",
"husky": "^6.0.0"
},
"dependencies": {
"termcolors": "0.7.3"
}
}

4610
package-lock.json

File diff suppressed because it is too large

45
package.json

@ -0,0 +1,45 @@
{
"name": "onedark.vim-builder",
"version": "1.0.0",
"description": "Builds the onedark.vim Vim colorscheme and associated files",
"main": "build.js",
"scripts": {
"build": "node build/build.js",
"test": "npm run lint && node build/build.js check",
"prepare": "husky install",
"lint": "run-p eslint:check prettier:check",
"lint:fix": "run-s eslint:fix prettier:fix",
"eslint:check": "eslint '**/*.js'",
"eslint:fix": "eslint --fix '**/*.js'",
"prettier:check": "prettier --check '**/*.{js,json,md}'",
"prettier:fix": "prettier --write '**/*.{js,json,md}'"
},
"author": {
"name": "Josh Dick",
"email": "josh@joshdick.net",
"url": "http://joshdick.net"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/joshdick/onedark.vim.git"
},
"devDependencies": {
"eslint": "^7.30.0",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2"
},
"dependencies": {
"termcolors": "0.7.3"
},
"lint-staged": {
"*.{js,json,md}": [
"prettier --check"
],
"*.{js}": [
"eslint"
]
}
}
Loading…
Cancel
Save