videogen/scripts/gen_web_tokens.mjs
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

51 lines
2.1 KiB
JavaScript

/**
* Build `@reelforge/ui-kit`'s `tokens.json` into CSS custom properties for
* `apps/web` (`app/reelforge-tokens.css`), so the Next.js app consumes the SAME
* palette as mobile / desktop / electron. Import it once in `app/globals.css`
* (`@import "./reelforge-tokens.css";`) and use `var(--rf-primary)` etc.
*
* Run: `node scripts/gen_web_tokens.mjs` (repo root). `--check` fails on drift.
*/
import { readFileSync, writeFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const here = dirname(fileURLToPath(import.meta.url));
const root = join(here, "..");
const t = JSON.parse(
readFileSync(join(root, "packages", "ui-kit", "src", "tokens", "tokens.json"), "utf8"),
);
const outPath = join(root, "apps", "web", "app", "reelforge-tokens.css");
const kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_ ]/g, "-").toLowerCase();
const lines = ["/* @generated by scripts/gen_web_tokens.mjs from packages/ui-kit/src/tokens/tokens.json */"];
lines.push("/* One ReelForge palette shared with mobile / desktop / electron. Do not edit by hand. */");
lines.push(":root {");
for (const [name, hex] of Object.entries(t.colors)) lines.push(` --rf-${kebab(name)}: ${hex};`);
for (const [name, hex] of Object.entries(t.platformColors)) lines.push(` --rf-platform-${kebab(name)}: ${hex};`);
for (const [name, v] of Object.entries(t.spacing)) lines.push(` --rf-space-${kebab(name)}: ${v}px;`);
for (const [name, v] of Object.entries(t.radii)) lines.push(` --rf-radius-${kebab(name)}: ${v}px;`);
for (const [name, v] of Object.entries(t.fontSizes)) lines.push(` --rf-text-${kebab(name)}: ${v}px;`);
lines.push("}");
lines.push("");
const out = lines.join("\n");
if (process.argv.includes("--check")) {
let cur = "";
try {
cur = readFileSync(outPath, "utf8");
} catch {
/* missing */
}
if (cur !== out) {
console.error(`STALE: ${outPath} — re-run scripts/gen_web_tokens.mjs`);
process.exit(1);
}
console.log("web tokens css is current.");
} else {
writeFileSync(outPath, out);
console.log(`wrote ${outPath}`);
}