-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.ts
executable file
·69 lines (59 loc) · 1.86 KB
/
build.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
#!/usr/bin/env -S deno run -A
import * as path from "std/path";
import * as sass from "sass";
import ctp from "npm:@catppuccin/palette";
import { updateReadme } from "@catppuccin/deno-lib";
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
const flavors = Object.keys(ctp.variants);
const accents = Object.keys(ctp.labels).slice(0, 14);
Deno.mkdirSync(path.join(__dirname, "dist"), { recursive: true });
const sassBuilder = (flavor: string, accent: string) => `
@import "@catppuccin/palette/scss/${flavor}";
$accent: $${accent};
$isDark: ${flavor !== "latte"};
@import "theme";
`;
for (const flavor of flavors) {
for (const accent of accents) {
const input = sassBuilder(flavor, accent);
const result = sass.compileString(input, {
loadPaths: [
path.join(__dirname, "src"),
path.join(__dirname, "node_modules"),
],
});
Deno.writeTextFileSync(
path.join(__dirname, "dist", `theme-catppuccin-${flavor}-${accent}.css`),
result.css,
);
}
}
for (const accent of accents) {
Deno.writeTextFileSync(
path.join(__dirname, "dist", `theme-catppuccin-${accent}-auto.css`),
`@import "./theme-catppuccin-latte-${accent}.css" (prefers-color-scheme: light);
@import "./theme-catppuccin-mocha-${accent}.css" (prefers-color-scheme: dark);`,
);
}
const flavorAccentIni = `
\`\`\`ini
[ui]
THEMES = ${flavors
.map((f) => accents.map((a) => `catppuccin-${f}-${a}`).join(","))
.join(",")}
\`\`\`
`;
const themeAutoIni = `
\`\`\`ini
[ui]
THEMES = ${accents.map((a) => `catppuccin-${a}-auto`).join(",")}
\`\`\`
`;
const oldReadme = Deno.readTextFileSync(path.join(__dirname, "README.md"));
let newReadme = updateReadme(oldReadme, flavorAccentIni, {
section: "ini",
});
newReadme = updateReadme(newReadme, themeAutoIni, {
section: "ini-auto",
});
Deno.writeTextFileSync(path.join(__dirname, "README.md"), newReadme);