Release v0.1.15
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Synchronize duplicated publish and development WebUI package contracts."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SYNCHRONIZED_KEYS = ("peerDependencies", "peerDependenciesMeta")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--repo", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
root_path = args.repo / "package.json"
|
||||
webui_path = args.repo / "webui" / "package.json"
|
||||
if not root_path.exists() or not webui_path.exists():
|
||||
return 0
|
||||
|
||||
root = _load(root_path)
|
||||
webui = _load(webui_path)
|
||||
root_name = root.get("name")
|
||||
webui_name = webui.get("name")
|
||||
if not isinstance(root_name, str) or root_name != webui_name:
|
||||
return 0
|
||||
|
||||
changed = False
|
||||
for key in SYNCHRONIZED_KEYS:
|
||||
if key in webui:
|
||||
value = webui[key]
|
||||
if root.get(key) != value:
|
||||
root[key] = value
|
||||
changed = True
|
||||
elif key in root:
|
||||
del root[key]
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
root_path.write_text(json.dumps(root, indent=2) + "\n")
|
||||
print(f"Synchronized WebUI peer metadata in {root_path}")
|
||||
return 0
|
||||
|
||||
|
||||
def _load(path: Path) -> dict[str, object]:
|
||||
payload = json.loads(path.read_text())
|
||||
if not isinstance(payload, dict):
|
||||
raise SystemExit(f"package metadata must be an object: {path}")
|
||||
return payload
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user