mirror of
https://github.com/bitbaum/solon.git
synced 2026-12-03 19:27:06 +01:00
* fix(law): a recut keeps the mark of a text read by OCR The weekly recut wrote every cantonal version it examined back with the plain importer version, so a text read from a scan by OCR (`…+ocr`) lost the mark that says how it was read, and an older version so marked was examined again at the head of every run. Any version carrying this reader's version with a mark (+archive, +ocr, or both) is now current, and a version brought up to date keeps every mark it had. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmuJdjaMYdbLjujoC3k * feat(places): a pack of its own takes a country over from the world pack Adding a pack is how a country gets places in depth, and the path had never run: a new pack's root resolved to the world pack's row, which kept its pack and path; the new pack's places hung under world/...; and a world file still stating the country would set the root's level back and give it a parent. - A pack may `yield` (the world pack does): it holds a place only until a pack of the place's own names it. - Then the place moves: same row (its figures and records stay), new pack and path, the new path canonical in place_paths and the old one redirecting, and the parents other sources stated for it superseded. - What the world pack held under a moved place that the batch does not restate ends that day; restated later, it moves and is current again. - A batch of a yielding pack leaves alone a place another pack holds and every place it states under one, so a world file not yet regenerated, the countries' or the subdivisions', cannot take a country back. - An integration test adds Quuxland, a made-up country the world pack holds first, and checks all of it, rerun-safe on one database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmuJdjaMYdbLjujoC3k * feat(data): one command refreshes every generated dataset, and a monthly workflow opens the PR The world's profiles, its countries, every country's subdivisions, the world list's photographs and the law plan were refreshed only when someone ran three to five commands on a laptop, in an order nobody wrote down; all were last read on 2026-11-10. - `pnpm run data:refresh [--only a,b] [--list]` (scripts/data-refresh.ts) runs the generators in the order they build on each other. One that fails keeps its old files and is reported; the rest still run. A new generator is one entry. - .github/workflows/data-refresh.yml runs it on the 4th of each month (or on dispatch, for some), and opens a pull request when anything changed, as bitbaum/substrata's recheck-data.yml does; the sweep merges it on green CI and the deploy's places-data job imports it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmuJdjaMYdbLjujoC3k --------- Co-authored-by: Claude <noreply@anthropic.com>
90 lines
3.1 KiB
TypeScript
90 lines
3.1 KiB
TypeScript
/**
|
|
* Every generated dataset, refreshed in the order they build on each other:
|
|
* one command instead of five run in an order nobody wrote down. Each
|
|
* generator is a package script. One that fails keeps its old files (they are
|
|
* restored from git) and is reported, and the rest still run.
|
|
*
|
|
* pnpm run data:refresh [--only world-profiles,photos] [--list]
|
|
*
|
|
* `.github/workflows/data-refresh.yml` runs it every month and opens a pull
|
|
* request when anything changed; the fleet's sweep merges it when CI is green,
|
|
* and the deploy's places-data job imports what changed. A new generator is
|
|
* one entry below.
|
|
*/
|
|
import { spawnSync } from "node:child_process";
|
|
|
|
interface Generator {
|
|
key: string;
|
|
/** The package script that writes it. */
|
|
script: string;
|
|
args?: string[];
|
|
/** The files it writes, restored when it fails. */
|
|
writes: string[];
|
|
/** Why it is where it is in the order. */
|
|
why: string;
|
|
}
|
|
|
|
export const GENERATORS: readonly Generator[] = [
|
|
{
|
|
key: "world-profiles",
|
|
script: "world:profiles",
|
|
writes: ["data/world/profiles.json", "src/lib/config/world/extras.json"],
|
|
why: "every place's Wikidata facts and the UN's list; the world list reads extras.json, so it is first",
|
|
},
|
|
{
|
|
key: "world-countries",
|
|
script: "places:world-countries",
|
|
writes: ["data/places/world/countries.json"],
|
|
why: "the world pack's countries, from the registry and the packs (offline)",
|
|
},
|
|
{
|
|
key: "world-subdivisions",
|
|
script: "places:world-subdivisions",
|
|
writes: ["data/places/world/subdivisions.json"],
|
|
why: "every country's ISO 3166-2 subdivisions, from Wikidata",
|
|
},
|
|
{
|
|
key: "photos",
|
|
script: "places:photos",
|
|
writes: ["data/world/photos.json"],
|
|
why: "the world list's photographs and their licences; after the profiles it reads",
|
|
},
|
|
{
|
|
key: "law-plan",
|
|
script: "law:plan",
|
|
args: ["seed"],
|
|
writes: ["data/law/plan.json"],
|
|
why: "the plan for every country's law, keeping every choice a person made; after the world list",
|
|
},
|
|
];
|
|
|
|
const args = process.argv.slice(2);
|
|
const only = args.includes("--only") ? args[args.indexOf("--only") + 1]?.split(",") : undefined;
|
|
|
|
function main(): number {
|
|
if (args.includes("--list")) {
|
|
for (const g of GENERATORS) console.log(`${g.key}: pnpm run ${g.script} — ${g.why}`);
|
|
return 0;
|
|
}
|
|
const unknown = (only ?? []).filter((key) => !GENERATORS.some((g) => g.key === key));
|
|
if (unknown.length > 0) {
|
|
console.error(`no generator ${unknown.join(", ")}; pnpm run data:refresh --list`);
|
|
return 2;
|
|
}
|
|
const failed: string[] = [];
|
|
for (const g of GENERATORS) {
|
|
if (only && !only.includes(g.key)) continue;
|
|
console.log(`\n== ${g.key}: pnpm run ${g.script} ${(g.args ?? []).join(" ")}`);
|
|
const run = spawnSync("pnpm", ["run", g.script, ...(g.args ?? [])], { stdio: "inherit" });
|
|
if (run.status !== 0) {
|
|
failed.push(g.key);
|
|
spawnSync("git", ["checkout", "--", ...g.writes], { stdio: "inherit" });
|
|
console.log(`${g.key} failed: its files are as they were`);
|
|
}
|
|
}
|
|
console.log(failed.length > 0 ? `\nFAILED: ${failed.join(", ")}` : "\nevery generator ran");
|
|
return failed.length > 0 ? 1 : 0;
|
|
}
|
|
|
|
process.exit(main());
|