theme / scripts / build-cdn.mjs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
// build the cdn layout: dist/theme/v<major>/theme.css
// the major version comes from package.json — a breaking token change bumps
// the major, so the cdn grows a new /v2/ dir instead of shifting /v1/.
import { readFileSync, mkdirSync, copyFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
const major = pkg.version.split(".")[0];
if (!/^\d+$/.test(major)) {
  console.error(`unexpected version "${pkg.version}" in package.json`);
  process.exit(1);
}

const out = join(root, "dist", "theme", `v${major}`);
mkdirSync(out, { recursive: true });
copyFileSync(join(root, "theme.css"), join(out, "theme.css"));
console.log(`dist/theme/v${major}/theme.css`);

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/theme.git