// Safety net for moving texts into the language files: saves what the // prerendered pages say (their text, links, labels, meta tags and structured // data) and later checks that a new build says exactly the same. Styling, // scripts, asset hashes and generated class names are left out, so only a // change of wording or content shows up. // // Usage (after `pnpm build`): // node config/htmlBaseline.ts save writes .baseline/.html (ignored by git) // node config/htmlBaseline.ts check compares dist/client with .baseline import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs'; import { join, relative } from 'node:path'; const DIST = 'dist/client'; const BASELINE = '.baseline'; // What stays: text, links, labels, meta, structured data and the data block const KEEP_SCRIPT = /type="application\/(?:ld\+json|json)"/; export function normalizeHtml(html: string): string { return ( html .replace(//g, '') .replace(//g, '') .replace( /]*)>([\s\S]*?)<\/script>/g, (all, attrs: string) => (KEEP_SCRIPT.test(attrs) ? all : ''), ) .replace(/