-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathhyper.ts
96 lines (90 loc) · 3.29 KB
/
hyper.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import Color from 'color';
import { source } from 'common-tags';
import { AnnotatedVariant, colorSetToVariants } from '../color-set/index.js';
import { dirname, join, Template, version } from './index.js';
function packageName(variant: AnnotatedVariant): string {
return `hyper-${variant.title.kebab}`;
}
const template: Template = {
name: 'Hyper',
render: async function* (colorSet) {
const variants = colorSetToVariants(colorSet);
for (const variant of variants) {
const indexFileName = 'index.js';
yield {
path: join(packageName(variant), 'package.json'),
content: JSON.stringify(
{
name: packageName(variant),
version,
description: `${variant.title.human} theme for Hyper.app, generated by themer`,
keywords: ['themer', colorSet.name, variant.name, 'hyper'],
main: indexFileName,
},
null,
2,
),
};
yield {
path: join(packageName(variant), indexFileName),
content: source`
module.exports.decorateConfig = config => {
return Object.assign({}, config, {
cursorColor: '${Color(variant.colors.accent6)
.fade(0.5)
.rgb()
.string()}',
cursorAccentColor: '${variant.colors.shade0}',
foregroundColor: '${variant.colors.shade6}',
backgroundColor: '${variant.colors.shade0}',
selectionColor: '${Color(variant.colors.accent5)
.fade(0.9)
.rgb()
.string()}',
borderColor: '${variant.colors.accent4}',
colors: {
black: '${variant.colors.shade0}',
red: '${variant.colors.accent0}',
green: '${variant.colors.accent3}',
yellow: '${variant.colors.accent2}',
blue: '${variant.colors.accent5}',
magenta: '${variant.colors.accent7}',
cyan: '${variant.colors.accent4}',
white: '${variant.colors.shade6}',
lightBlack: '${variant.colors.shade1}',
lightRed: '${variant.colors.accent1}',
lightGreen: '${variant.colors.accent3}',
lightYellow: '${variant.colors.accent2}',
lightBlue: '${variant.colors.accent5}',
lightMagenta: '${variant.colors.accent7}',
lightCyan: '${variant.colors.accent4}',
lightWhite: '${variant.colors.shade7}',
},
});
};
`,
};
}
},
renderInstructions: (paths, colorSet) => {
const directories = [...new Set(paths.map(dirname))];
const packageNames = colorSetToVariants(colorSet).map(packageName);
return source`
First, copy (or symlink) the outputted package ${
directories.length > 1 ? 'directories' : 'directory'
} to the Hyper local plugins directory:
\`\`\`
${directories.map((dir) => `cp -R '${dir}' ~/.hyper_plugins/local/`)}
\`\`\`
Then edit \`~/.hyper.js\` and ad the package to the \`localPlugins\` array:
\`\`\`
...
localPlugins: [
${packageNames.map((name) => `'${name}'`).join(' // or ')}
],
...
\`\`\`
`;
},
};
export default template;