#!/usr/bin/env -S deno run -A import * as path from "std/path"; import * as sass from "sass"; import * as rp from "npm:@rose-pine/palette"; const builder = (flavor: string, accent: string) => ` @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) $accent: $${accent}; $isDark: ${flavor !== "dawn"}; @import "theme"; `; const __dirname = path.dirname(path.fromFileUrl(import.meta.url)); const accents = ["love", "gold", "rose", "pine", "foam", "iris"]; Deno.mkdirSync(path.join(__dirname, "dist"), { recursive: true }); const flavors = Object.keys(rp.variantColors); 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( path.join(__dirname, "dist", `theme-rose-pine-${flavor}-${accent}.css`), result.css, ); } } // TODO: // refactor this part out to a common import, since ctp/ctp & ctp/userstyles // are both using the same base function const updateReadme = ({ readme, section, newContent, }: { readme: string; section: string; newContent: string; }): string => { const preamble = ""; const startMarker = ``; const endMarker = ``; 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] THEMES = ${flavors .map((f) => accents.map((a) => `rp-${f}-${a}`).join(",")) .join(",")} \`\`\` `, }); Deno.writeTextFileSync(path.join(__dirname, "README.md"), newcontent);