#!/usr/bin/env python3 """Delete one channel's web// tree; leave shared sync/ and lab_seeds.json intact.""" from __future__ import annotations import argparse import json import shutil import sys from pathlib import Path from _channel_patch import validate_channel_id from _common import ARTIFACTS_ROOT RESULT_MARKER = "CORUNA_BUILD_RESULT " def main() -> int: parser = argparse.ArgumentParser(description="Remove web// from artifact root") parser.add_argument("--channel-id", required=True) parser.add_argument( "--artifact-root", type=Path, default=ARTIFACTS_ROOT, help=f"shared artifact root (default: {ARTIFACTS_ROOT})", ) args = parser.parse_args() channel = validate_channel_id(args.channel_id) artifact_root = args.artifact_root.resolve() web_dir = artifact_root / "web" / channel removed = False if web_dir.is_dir(): shutil.rmtree(web_dir) removed = True print(f"removed {web_dir}") else: print(f"missing {web_dir} (noop)") result = { "status": "deleted" if removed else "absent", "channel_id": channel, "artifact_root": str(artifact_root), "removed": removed, } print(RESULT_MARKER + json.dumps(result, separators=(",", ":")), flush=True) return 0 if __name__ == "__main__": raise SystemExit(main())