Appearance
catalog-check.mjs
Renders src/catalog/catalog.json from the data modules under src/catalog and checks it for drift.
Contributor tooling › catalog-check.mjs
What it does
Calls renderCatalog() from src/catalog/index.mjs, which collects the rosters and stat tables the individual catalog modules (roster.mjs, buildings.mjs, units.mjs, research.mjs, lifeforms.mjs) export, and renders the result as formatted JSON. Compares that text byte for byte against src/catalog/catalog.json on disk, or, with --write, overwrites the file with it.
Usage
Run through its npm run alias:
bash
npm run catalog:checkOr directly:
bash
node tools/catalog-check.mjsOptions
| Flag | Value | What it does | Default |
|---|---|---|---|
--write | no value | Writes the rendered catalog to src/catalog/catalog.json, overwriting the file on disk. | Off. The bare invocation only compares and reports. |
Inputs and outputs
Reads the catalog data modules under src/catalog (through renderCatalog()). Passing --write writes src/catalog/catalog.json; the bare invocation writes nothing.
On success (exit 0), --write prints how many bytes it wrote; the bare invocation prints catalog-check: catalog.json matches the data modules.
On failure (exit 1), src/catalog/catalog.json is either missing or drifted. A missing file gets an error naming the --write command that creates it. A drifted file gets the first line where the on-disk text and the freshly rendered text disagree.
Examples
npm run check runs this bare, so confirm it passes before pushing a change to a catalog module:
bash
npm run catalog:checkAfter editing a file under src/catalog (a building's stats, a research prerequisite, a ship's roster entry), regenerate the committed JSON:
bash
node tools/catalog-check.mjs --writeNotes
None.
Source
tools/catalog-check.mjs — part of Contributor tooling