// The two closure-defines every build of the hub needs, in one place so dev,
// build and test cannot drift apart.
//
// home.config/APP-VERSION <- client/version.json (the update banner
// compares it against the live one)
// home.config/CATALOG-SNAPSHOT-JSON <- client/catalog.json, MINIFIED
//
// The snapshot rides in as a define STRING rather than a generated source file:
// Vite had resolveJsonModule, shadow does not, and committing a generated copy
// of catalog.json would let the two drift. client/catalog.json stays the single
// source of truth (house rule 8). JSON.stringify's escapes are all valid EDN
// string escapes, so the value survives --config-merge verbatim.
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
export const CLIENT = dirname(dirname(fileURLToPath(import.meta.url)));
export function appVersion() {
return JSON.parse(readFileSync(join(CLIENT, "version.json"), "utf8")).version;
}
/** The minified catalog — the same bytes scripts/build.mjs writes to dist. */
export function catalogJson() {
return JSON.stringify(JSON.parse(readFileSync(join(CLIENT, "catalog.json"), "utf8")));
}
/** `--config-merge` args for the :app build (the :bridge build needs none). */
export function appDefines() {
return [
"--config-merge",
`{:closure-defines {home.config/APP-VERSION ${appVersion()}` +
` home.config/CATALOG-SNAPSHOT-JSON ${JSON.stringify(catalogJson())}}}`,
];
}