=chore-finalize-stitch-verification
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import zipfile
|
||||
@@ -41,7 +42,17 @@ def is_included(path: Path) -> bool:
|
||||
|
||||
|
||||
def iter_files() -> Iterable[Path]:
|
||||
return sorted(path for path in ROOT.rglob("*") if is_included(path))
|
||||
files: list[Path] = []
|
||||
for directory, dirnames, filenames in os.walk(ROOT):
|
||||
dirnames[:] = sorted(name for name in dirnames if name not in EXCLUDED_DIRS)
|
||||
base = Path(directory)
|
||||
if base == ROOT / "local":
|
||||
dirnames.clear()
|
||||
for filename in sorted(filenames):
|
||||
path = base / filename
|
||||
if is_included(path):
|
||||
files.append(path)
|
||||
return sorted(files)
|
||||
|
||||
|
||||
def sha256(path: Path) -> str:
|
||||
@@ -52,9 +63,10 @@ def sha256(path: Path) -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def write_manifest(staging_root: Path) -> None:
|
||||
def write_manifest(staging_root: Path, paths: Iterable[Path] | None = None) -> None:
|
||||
entries = []
|
||||
for path in sorted(staging_root.rglob("*")):
|
||||
candidates = sorted(paths) if paths is not None else sorted(staging_root.rglob("*"))
|
||||
for path in candidates:
|
||||
if not path.is_file() or path.name == "PROJECT_MANIFEST.json":
|
||||
continue
|
||||
entries.append(
|
||||
@@ -103,6 +115,11 @@ def package(output: Path) -> tuple[int, str]:
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Maak een schone VacatureRadar-project-ZIP")
|
||||
parser.add_argument(
|
||||
"--manifest-only",
|
||||
action="store_true",
|
||||
help="Werk alleen PROJECT_MANIFEST.json in de repository bij.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"output",
|
||||
nargs="?",
|
||||
@@ -110,6 +127,10 @@ def main() -> int:
|
||||
default=ROOT.parent / "VacatureRadar_Project.zip",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if args.manifest_only:
|
||||
write_manifest(ROOT, iter_files())
|
||||
print(f"Manifest: {(ROOT / 'PROJECT_MANIFEST.json').resolve()}")
|
||||
return 0
|
||||
size, checksum = package(args.output)
|
||||
print(f"ZIP: {args.output.resolve()}")
|
||||
print(f"Bytes: {size}")
|
||||
|
||||
Reference in New Issue
Block a user