Coverage for plugin/scripts/check_version_parity.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-15 14:46 +0000

1#!/usr/bin/env python3 

2"""Assert plugin.json and marketplace.json declare the same plugin version. 

3 

4Used as a pre-commit hook so the two manifests can never drift (the mistake 

5that produced a 0.1.0 / v0.2.0 mismatch). Exits non-zero on mismatch. 

6""" 

7 

8import json 

9import sys 

10from pathlib import Path 

11 

12from _rhiza_layout import MARKETPLACE_MANIFEST, PLUGIN_MANIFEST 

13 

14 

15def main() -> None: 

16 """Entry point: assert both manifests share a version; exit 1 on mismatch.""" 

17 plugin = json.loads(Path(PLUGIN_MANIFEST).read_text(encoding="utf-8"))["version"] 

18 entries = json.loads(Path(MARKETPLACE_MANIFEST).read_text(encoding="utf-8"))["plugins"] 

19 mismatches = [e["name"] for e in entries if e.get("version") != plugin] 

20 if mismatches: 

21 market = {e["name"]: e.get("version") for e in entries} 

22 print( 

23 f"Version mismatch: plugin.json={plugin} but marketplace.json entries={market}", 

24 file=sys.stderr, 

25 ) 

26 sys.exit(1) 

27 print(f"manifest versions match: {plugin}") 

28 

29 

30if __name__ == "__main__": 

31 main()