1// Folds src/console (markup, styles, script: three ordinary files) into2// src/gen/console.ts, the strings the relay serves as its page. A generated3// module rather than wrangler's text-module rules, since celld deploy4// refuses a config with "rules" (scripts/check/check-celld.mjs). `--check`5// rebuilds in memory and fails when the committed file is stale, so6// typecheck catches a forgotten rebuild.7import { readFileSync, writeFileSync } from "node:fs";89const OUT = new URL("../../src/gen/console.ts", import.meta.url);10const read = (name) => readFileSync(new URL("../../src/console/" + name, import.meta.url), "utf8");11const html = read("console.html");12const css = read("console.css");13const js = read("console.js");14const file = `// Generated by scripts/build/build-console.mjs from src/console. Do not edit; run npm run build:console.15export const CONSOLE_HTML = ${JSON.stringify(html)};16export const CONSOLE_CSS = ${JSON.stringify(css)};17export const CONSOLE_JS = ${JSON.stringify(js)};18`;19if (process.argv.includes("--check")) {20 let cur = "";21 try {22 cur = readFileSync(OUT, "utf8");23 } catch {24 /* missing */25 }26 if (cur !== file) {27 console.error("src/gen/console.ts is stale: run npm run build:console");28 process.exit(1);29 }30} else {31 writeFileSync(OUT, file);32 console.log(`src/gen/console.ts: ${((html.length + css.length + js.length) / 1024).toFixed(0)} KB`);33}