Files
Codewhale/web/vitest.global-setup.ts
CodeWhale BotandClaude Opus 5.5 b90c7d3c69 fix(web): derive the changelog and install-guide modules at build time
web/lib/changelog.generated.ts and web/lib/install-guide.generated.ts were
committed copies of CHANGELOG.md and docs/INSTALL.md. Two PRs that each
added a CHANGELOG line regenerated the copy against their own base; git
merged both hunks cleanly but kept one "itemCount" bump, so main's parity
test went red (ae08853fc and ede108041 on 2026-09-26) and every PR that
merged main inherited it.

Both files are now untracked (web/.gitignore). prebuild and dev already
derived them; a vitest globalSetup now derives them before any test
imports them, so `npm test`, `npx vitest` and the root `npm --prefix web
test` work on a fresh checkout. OpenNext's deploy build runs `npm run
build`, which triggers prebuild. check:docs renders the guide instead of
diffing a tracked copy (rendering still throws on broken links).
prepare-release.sh no longer regenerates or snapshots the changelog module.

facts.generated.ts stays committed: facts-drift.ts fetches it from the exact
revision at runtime for toolCount and models, and check-facts gates it.
crates/tui/CHANGELOG.md stays committed: /change include_str!s it from
inside the published codewhale-tui crate, and as a byte prefix of the root
changelog it merges consistently.

Verified: web vitest 55 files / 498 tests passed with both files deleted
first; npm run check exit 0 (check-facts OK, check-docs PASS, lint, tsc,
next build 839 pages; /en/changelog renders the Unreleased entries);
sync-changelog.sh --check up to date; check-versions.sh
--range-audit-advisory exit 0; check-contributor-credit.py v0.10.0 exit 0;
prepare-release.test.sh passed.

No-Issue: derived changelog artifacts raced between merges and reddened main twice on 2026-09-26

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-26 18:59:08 -07:00

19 lines
804 B
TypeScript

import { execFileSync } from "node:child_process";
import { fileURLToPath } from "node:url";
/**
* Derive the untracked build inputs before any test file imports them.
* `lib/changelog.generated.ts` and `lib/install-guide.generated.ts` are not
* committed (see web/.gitignore), so a bare `vitest run` on a fresh checkout
* must write them from CHANGELOG.md and docs/INSTALL.md first. Facts stay out
* of this list on purpose: `facts.generated.ts` is committed, and rewriting it
* here would hide the drift `npm run check:facts` exists to catch.
*/
export default function setup() {
for (const script of ["derive-changelog.mjs", "derive-install.mjs"]) {
execFileSync(process.execPath, [fileURLToPath(new URL(`./scripts/${script}`, import.meta.url))], {
stdio: "inherit",
});
}
}