This repository has been archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
83 lines (79 loc) · 2 KB
/
index.js
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
#!/usr/bin/env node
// @ts-check
const fs = require("fs");
const colorMap = {
dark: {
"#d4d4d4": "#D4D4D4",
"#000080": "#0000A6",
"#6a9955": "#62AD41",
"#569cd6": "#30A0FC",
"#b5cea8": "#B1D99D",
"#646695": "#5559A4",
"#d7ba7d": "#F2C462",
"#9cdcfe": "#7FE5FF",
"#f44747": "#FF1313",
"#ce9178": "#E8865E",
"#6796e6": "#418CFF",
"#808080": "#808080",
"#d16969": "#F04A4A",
"#dcdcaa": "#EBEB9B",
"#4ec9b0": "#29EEC6",
"#c586c0": "#D873D0"
},
light: {
"#000000ff": "#000000",
"#000080": "#0A0A76",
"#008000": "#0A760A",
"#0000ff": "#1313EC",
"#09885a": "#137E57",
"#811f3f": "#7A2642",
"#800000": "#760A0A",
"#ff0000": "#EC1313",
"#cd3131": "#C13D3D",
"#a31515": "#982020",
"#0451a5": "#105299",
"#000000": "#000000",
"#795e26": "#735C2C",
"#267f99": "#2F7A90",
"#af00db": "#A510CB",
"#001080": "#0A1776",
"#d16969": "#C97171"
}
};
function mapTokenColors(theme) {
const themeVS = JSON.parse(
fs.readFileSync(`./templates/${theme}_vs.json`, "utf8")
);
const themePlus = JSON.parse(
fs.readFileSync(`./templates/${theme}_plus.json`, "utf8")
);
const tokenColors = [...themeVS.tokenColors, ...themePlus.tokenColors].map(
tokenColor => {
const mappedColor = {
...tokenColor
};
if (
tokenColor.settings &&
tokenColor.settings.foreground &&
tokenColor.settings.foreground.toLowerCase() in colorMap[theme]
) {
mappedColor.settings.foreground =
colorMap[theme][tokenColor.settings.foreground.toLowerCase()];
}
return mappedColor;
}
);
return tokenColors;
}
function writeTokenColors(theme) {
const template = JSON.parse(
fs.readFileSync(`./templates/xcode-${theme}.json`, "utf8")
);
template.tokenColors = mapTokenColors(theme);
fs.writeFileSync(
`./xcode-partial-${theme}-theme.json`,
JSON.stringify(template, null, 2)
);
}
writeTokenColors("dark");
writeTokenColors("light");