// 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`);