#!/usr/bin/env node
// Writes every text copy of the brand geometry from packages/ui/lib/multica-brand.ts:
// favicons, the PWA icon source, the README wordmark SVGs, the mobile wordmark and
// the inline SVG on the `multica login` callback page.
//
// node scripts/brand/sync.mjs rewrite the copies
// node scripts/brand/sync.mjs --check exit 1 if any copy drifted (CI)
//
// Dependency-free on purpose: CI runs it without installing node_modules.
import { readFileSync, realpathSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
export const INK = "#0b0b0c";
export const PAPER = "#ffffff";
const CLI_WORDMARK_HEIGHT = 19.5;
export async function loadBrand(root) {
return import(pathToFileURL(join(root, "packages/ui/lib/multica-brand.ts")).href);
}
export function svgs(brand) {
const { WORDMARK, WORDMARK_STROKE, ICON_TILE_RADIUS, starPath, iconStar, iconStarTransform } = brand;
const star = (px, attrs) => {
const { scale, stroke } = iconStar(px);
return ``;
};
const wordmark = (color, extra = "") =>
``;
const tile = (px, { bleed = false, bg = INK, fg = PAPER } = {}) =>
``;
const [, , vbW, vbH] = WORDMARK.viewBox.split(" ").map(Number);
return {
tile,
wordmark,
favicon: `\n`,
pwaIcon: `\n`,
cliWordmark: wordmark("currentColor", ` height="${CLI_WORDMARK_HEIGHT}" width="${Math.round((CLI_WORDMARK_HEIGHT * vbW) / vbH)}"`),
};
}
function mobileBlock({ WORDMARK, WORDMARK_STROKE }) {
const [x, y, w, h] = WORDMARK.viewBox.split(" ").map(Number);
const star = WORDMARK.letters.find((l) => l.star).star;
return [
`const VIEW_BOX = { x: ${x}, y: ${y}, w: ${w}, h: ${h} };`,
`const STROKE = ${WORDMARK_STROKE};`,
"const LETTERS = [",
...WORDMARK.letters.map((l) => ` "${l.d}",`),
"];",
"/** The star on the i, filled. */",
"const STAR =",
` "${star}";`,
].join("\n");
}
const MOBILE_BEGIN = "// BEGIN GENERATED by scripts/brand/sync.mjs from WORDMARK in packages/ui/lib/multica-brand.ts\n";
const MOBILE_END = "\n// END GENERATED";
const CLI_SVG = /(
)