From 29712195710fe83f5c9b99dc45f4f207d8703fa0 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:04:43 +0100 Subject: [PATCH] fix: publish the manifests the pages link --- scripts/sitegen/publish.py | 11 +++++++---- tests/test_site_inputs.py | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/sitegen/publish.py b/scripts/sitegen/publish.py index 61f4397e1..2e450c7c3 100644 --- a/scripts/sitegen/publish.py +++ b/scripts/sitegen/publish.py @@ -6,7 +6,7 @@ import json import shutil from pathlib import Path -from model import releaserecord +from model import releaserecord, siteinputs from core.paths import REPO_ROOT from sitegen.write import record_written, write_if_changed @@ -33,12 +33,15 @@ def publish_manifests(api: Path) -> list[tuple]: pack installs: Batocera's list holds 353 files, its pack 14,508. The only copy was install/.json on the repository's main branch, which no page named. Copied byte for byte: the SHA256 the catalog gives - is the repository file's. + is the repository file's. Read from the folder the pages link from + (siteinputs.manifests_dir), so a run on another collection serves the + manifests its pages and DATs describe. """ + manifests = siteinputs.manifests_dir() folder = api / "manifests" folder.mkdir(parents=True, exist_ok=True) assets: list[tuple] = [] - for source in sorted((REPO_ROOT / "install").glob("*.json")): + for source in sorted(manifests.glob("*.json")): target = folder / source.name shutil.copy2(source, target) record_written(target) @@ -48,7 +51,7 @@ def publish_manifests(api: Path) -> list[tuple]: # api/v1/targets/ answered 404. targets = api / "targets" targets.mkdir(parents=True, exist_ok=True) - for source in sorted((REPO_ROOT / "install" / "targets").glob("*.json")): + for source in sorted((manifests / "targets").glob("*.json")): shutil.copy2(source, targets / source.name) record_written(targets / source.name) assets.append((targets / source.name, f"Target list: {source.stem}", diff --git a/tests/test_site_inputs.py b/tests/test_site_inputs.py index 08f6b6be0..206e8e94f 100644 --- a/tests/test_site_inputs.py +++ b/tests/test_site_inputs.py @@ -70,6 +70,20 @@ class TheGivenDatabase(_Inputs): (self.db.parent / "install" / "retroarch.json").write_text("{}") self.assertIn("install manifest", platformfiles.platform_data_links("retroarch")) + def test_the_published_manifests_are_the_ones_the_pages_link(self) -> None: + from sitegen.publish import publish_manifests + + given = self.db.parent / "install" + (given / "targets").mkdir(parents=True) + (given / "onlyhere.json").write_text('{"given": 1}') + (given / "targets" / "onlyhere.json").write_text('{"given": 2}') + api = self.db.parent / "api" + self.use(db=self.db) + publish_manifests(api) + self.assertEqual(sorted(p.name for p in (api / "manifests").iterdir()), ["onlyhere.json"]) + self.assertEqual((api / "manifests" / "onlyhere.json").read_text(), '{"given": 1}') + self.assertEqual(sorted(p.name for p in (api / "targets").iterdir()), ["onlyhere.json"]) + def test_board_election_opens_the_given_collection_archive(self) -> None: import zipfile @@ -227,7 +241,7 @@ class NoPageModuleReadsTheRepositoryInputs(unittest.TestCase): def test_no_page_module_reads_the_repository_manifests(self) -> None: modules = [SCRIPTS / "sitegen" / f"{name}.py" for name in ("render", "platformfiles", "whichpack", "structured", "install", - "lookup", "build", "guidepage", "diagrams")] + "lookup", "build", "guidepage", "diagrams", "publish")] found = [ f"{module.name}:{node.lineno}" for module in modules