2023-08-22 11:22:46 +00:00
|
|
|
#!/usr/bin/env -S deno run -A
|
2023-08-23 10:22:00 +00:00
|
|
|
|
2023-08-22 11:22:46 +00:00
|
|
|
import * as path from "std/path";
|
|
|
|
import * as sass from "sass";
|
2023-12-27 21:21:10 +00:00
|
|
|
import * as rp from "npm:@rose-pine/palette";
|
2023-08-22 11:22:46 +00:00
|
|
|
|
|
|
|
const builder = (flavor: string, accent: string) => `
|
2023-12-27 21:21:10 +00:00
|
|
|
@import "@rose-pine/palette/dist/css/rose-pine.css";
|
|
|
|
|
|
|
|
$base: var(--rp-${flavor}-base)
|
|
|
|
$surface: var(--rp-${flavor}-surface)
|
|
|
|
$overlay: var(--rp-${flavor}-overlay)
|
|
|
|
$muted: var(--rp-${flavor}-muted)
|
|
|
|
$subtle: var(--rp-${flavor}-subtle)
|
|
|
|
$text: var(--rp-${flavor}-text)
|
|
|
|
$love: var(--rp-${flavor}-love)
|
|
|
|
$gold: var(--rp-${flavor}-gold)
|
|
|
|
$rose: var(--rp-${flavor}-rose)
|
|
|
|
$pine: var(--rp-${flavor}-pine)
|
|
|
|
$foam: var(--rp-${flavor}-foam)
|
|
|
|
$iris: var(--rp-${flavor}-iris)
|
|
|
|
$highlight-low: var(--rp-${flavor}-highlight-low)
|
|
|
|
$highlight-med: var(--rp-${flavor}-highlight-med)
|
|
|
|
$highlight-high: var(--rp-${flavor}-highlight-high)
|
|
|
|
|
2023-08-22 11:22:46 +00:00
|
|
|
$accent: $${accent};
|
2023-12-27 21:21:10 +00:00
|
|
|
$isDark: ${flavor !== "dawn"};
|
|
|
|
|
2023-08-22 11:22:46 +00:00
|
|
|
@import "theme";
|
|
|
|
`;
|
|
|
|
|
|
|
|
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
|
|
|
|
|
2023-12-27 21:21:10 +00:00
|
|
|
const accents = ["love", "gold", "rose", "pine", "foam", "iris"];
|
2023-08-22 11:22:46 +00:00
|
|
|
|
|
|
|
Deno.mkdirSync(path.join(__dirname, "dist"), { recursive: true });
|
|
|
|
|
2023-12-27 21:21:10 +00:00
|
|
|
const flavors = Object.keys(rp.variantColors);
|
2023-08-22 11:22:46 +00:00
|
|
|
for (const flavor of flavors) {
|
|
|
|
for (const accent of accents) {
|
|
|
|
const input = builder(flavor, accent);
|
|
|
|
const result = sass.compileString(input, {
|
|
|
|
loadPaths: [
|
|
|
|
path.join(__dirname, "src"),
|
|
|
|
path.join(__dirname, "node_modules"),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.writeTextFileSync(
|
2023-12-27 21:21:10 +00:00
|
|
|
path.join(__dirname, "dist", `theme-rose-pine-${flavor}-${accent}.css`),
|
2023-08-22 11:22:46 +00:00
|
|
|
result.css,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-23 10:22:00 +00:00
|
|
|
// TODO:
|
|
|
|
// refactor this part out to a common import, since ctp/ctp & ctp/userstyles
|
|
|
|
// are both using the same base function
|
2023-08-22 11:22:46 +00:00
|
|
|
const updateReadme = ({
|
|
|
|
readme,
|
|
|
|
section,
|
|
|
|
newContent,
|
|
|
|
}: {
|
|
|
|
readme: string;
|
|
|
|
section: string;
|
|
|
|
newContent: string;
|
|
|
|
}): string => {
|
|
|
|
const preamble =
|
|
|
|
"<!-- the following section is auto-generated, do not edit -->";
|
|
|
|
const startMarker = `<!-- AUTOGEN:${section.toUpperCase()} START -->`;
|
|
|
|
const endMarker = `<!-- AUTOGEN:${section.toUpperCase()} END -->`;
|
|
|
|
const wrapped = `${startMarker}\n${preamble}\n${newContent}\n${endMarker}`;
|
|
|
|
|
|
|
|
if (!(readme.includes(startMarker) && readme.includes(endMarker))) {
|
|
|
|
throw new Error("Markers not found in README.md");
|
|
|
|
}
|
|
|
|
|
|
|
|
const pre = readme.split(startMarker)[0];
|
|
|
|
const end = readme.split(endMarker)[1];
|
|
|
|
return pre + wrapped + end;
|
|
|
|
};
|
|
|
|
|
|
|
|
const readme = Deno.readTextFileSync(path.join(__dirname, "README.md"));
|
|
|
|
const newcontent = updateReadme({
|
|
|
|
readme,
|
|
|
|
section: "ini",
|
|
|
|
newContent: `
|
|
|
|
\`\`\`
|
|
|
|
[ui]
|
2023-12-27 21:21:10 +00:00
|
|
|
THEMES = ${flavors
|
|
|
|
.map((f) => accents.map((a) => `rp-${f}-${a}`).join(","))
|
|
|
|
.join(",")}
|
2023-08-22 11:22:46 +00:00
|
|
|
\`\`\`
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.writeTextFileSync(path.join(__dirname, "README.md"), newcontent);
|