A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
dev_setup_commands: every scripts/ helper has a dev-setup row (#363)
agamrafaeli-instinct2f35f03add65
diff --git a/scripts/oss/dev_setup_commands.py b/scripts/oss/dev_setup_commands.pyindex 5ef7eb332..53ce20225 100644--- a/scripts/oss/dev_setup_commands.py+++ b/scripts/oss/dev_setup_commands.py@@ -2,14 +2,14 @@"""Every script named in the dev-setup table exists (#359): `uv run scripts/oss/dev_setup_commands.py [--root DIR]`.Reads docs/dev-setup.md, takes each backticked `scripts/...` or `tools/...` path ending in .py or .sh, and checks that-the file is there. One line per missing file (line number and path); exit 1 if any."""+the file is there. One line per missing file (line number and path). Also lists each top-level scripts/*.py or scripts/*.sh that no backticked path names. Exit 1 if any."""import argparseimport reimport sysfrom pathlib import PathROOT = Path(__file__).resolve().parents[2]-PATH = re.compile(r"(?<![\w/.-])((?:scripts|tools)/[\w./-]+\.(?:py|sh))")+PATH = re.compile(r"(?<![\w/.-])((?:scripts|tools)/[\w./-]+\.(?:py|sh))(?![\w.-])")def missing(root: Path) -> list[tuple[int, str]]:@@ -23,6 +23,19 @@ def missing(root: Path) -> list[tuple[int, str]]:return bad+def named(root: Path) -> set[str]:+ """Every `scripts/...` or `tools/...` path inside a backticked span of docs/dev-setup.md, as missing() reads them."""+ text = (root / "docs/dev-setup.md").read_text(encoding="utf-8")+ return {p for span in re.findall(r"`([^`]+)`", text) for p in PATH.findall(span)}+++def undocumented(root: Path) -> list[str]:+ """Top-level scripts/*.py and scripts/*.sh that no backticked path in docs/dev-setup.md names."""+ names = named(root)+ scripts = sorted(p for p in (root / "scripts").iterdir() if p.is_file() and p.suffix in (".py", ".sh"))+ return [f"scripts/{p.name}" for p in scripts if f"scripts/{p.name}" not in names]++def main(argv: list[str]) -> int:ap = argparse.ArgumentParser(description=__doc__)ap.add_argument("--root", type=Path, default=ROOT)@@ -30,7 +43,10 @@ def main(argv: list[str]) -> int:bad = missing(args.root)for n, p in bad:print(f"docs/dev-setup.md:{n}: {p} does not exist")- return 1 if bad else 0+ loose = undocumented(args.root)+ for p in loose:+ print(f"{p} is not named in docs/dev-setup.md")+ return 1 if bad or loose else 0if __name__ == "__main__":diff --git a/scripts/oss/tests/test_dev_setup_commands.py b/scripts/oss/tests/test_dev_setup_commands.pyindex 483bd2d74..f2ea19a29 100644--- a/scripts/oss/tests/test_dev_setup_commands.py+++ b/scripts/oss/tests/test_dev_setup_commands.py@@ -27,3 +27,26 @@ def test_clean_returns_zero(make_repo):def test_this_repo_is_clean():assert m.missing(ROOT) == []+++def test_a_script_with_no_row_is_reported(make_repo, capsys):+ root = make_repo({'docs/dev-setup.md': '`uv run scripts/a.py`\nSee scripts/c.sh for the rest.\n', # prose only: not a name+ 'scripts/a.py': 'x\n', 'scripts/b.sh': 'x\n', 'scripts/c.sh': 'x\n', 'scripts/notes.txt': 'x\n'})+ assert m.undocumented(root) == ['scripts/b.sh', 'scripts/c.sh']+ assert m.main(['--root', str(root)]) == 1+ assert 'scripts/b.sh is not named in docs/dev-setup.md' in capsys.readouterr().out+++def test_a_directory_named_like_a_script_is_not_a_script(make_repo):+ root = make_repo({'docs/dev-setup.md': '`uv run scripts/a.py`\n', 'scripts/a.py': 'x\n', 'scripts/d.py/inner.txt': 'x\n'})+ assert m.undocumented(root) == []+++def test_a_longer_name_does_not_name_the_script_inside_it(make_repo):+ root = make_repo({'docs/dev-setup.md': '`uv run scripts/a.py` and `scripts/e.py.old`\n', 'scripts/a.py': 'x\n',+ 'scripts/e.py': 'x\n'})+ assert m.undocumented(root) == ['scripts/e.py']+++def test_this_repo_documents_every_script():+ assert m.undocumented(ROOT) == []