47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Manifest checker - validates presence of required artifact files."""
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
MANIFEST = {
|
|
"artifacts": [
|
|
"json_validator.py",
|
|
"manifest_check.py"
|
|
],
|
|
"version": "1.0"
|
|
}
|
|
|
|
|
|
def check_manifest(artifacts_dir: str) -> dict:
|
|
"""Check that all required artifacts exist."""
|
|
base = Path(artifacts_dir)
|
|
results = {
|
|
"valid": True,
|
|
"artifacts_dir": str(base),
|
|
"expected": MANIFEST["artifacts"],
|
|
"found": [],
|
|
"missing": []
|
|
}
|
|
|
|
for artifact in MANIFEST["artifacts"]:
|
|
path = base / artifact
|
|
if path.exists():
|
|
results["found"].append(artifact)
|
|
else:
|
|
results["missing"].append(artifact)
|
|
results["valid"] = False
|
|
|
|
return results
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: manifest_check.py <artifacts_dir>", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
result = check_manifest(sys.argv[1])
|
|
print(json.dumps(result, indent=2))
|
|
sys.exit(0 if result["valid"] else 1) |