Files
games/scripts/audit_distribution_layout.py

73 lines
2.5 KiB
Python

#!/usr/bin/env python3
# file: scripts/audit_distribution_layout.py
# version: 1
"""Audit the static distribution layout expected by the 0.1.0 beta."""
from __future__ import annotations
import argparse
import pathlib
import sys
FORBIDDEN_PATHS = (
"builds",
)
REQUIRED_PATHS = (
"crates/apps/game-reflex-poc-desktop/Cargo.toml",
"crates/apps/game-snake-poc-desktop/Cargo.toml",
"crates/apps/game-reflex-poc-tauri/Cargo.toml",
"crates/apps/game-reflex-poc-tauri/package.json",
"crates/apps/game-reflex-poc-tauri/tsconfig.json",
"crates/apps/game-reflex-poc-tauri/vite.config.ts",
"crates/apps/game-reflex-poc-tauri/tauri.conf.json",
"crates/apps/game-reflex-poc-tauri/capabilities/default.json",
"crates/apps/game-reflex-poc-tauri/icons/icon.png",
"crates/apps/game-reflex-poc-tauri/frontend/index.html",
"crates/apps/game-reflex-poc-tauri/frontend/ts/main.ts",
"crates/apps/game-reflex-poc-wasm/Cargo.toml",
"Android/game-reflex-poc/build.gradle",
"Android/game-snake-poc/build.gradle",
"scripts/build_android_rust.py",
"scripts/build_reflex_tauri_wasm.py",
"assets/common",
"assets/game-reflex-poc",
"assets/game-snake-poc",
)
def main() -> int:
"""Validate that every static distribution boundary exists."""
parser = argparse.ArgumentParser()
parser.add_argument("--root", default=".", help="workspace root")
arguments = parser.parse_args()
root = pathlib.Path(arguments.root).resolve()
missing: list[str] = []
forbidden_present: list[str] = []
for relative in REQUIRED_PATHS:
if not (root / relative).exists():
missing.append(relative)
for relative in FORBIDDEN_PATHS:
if (root / relative).exists():
forbidden_present.append(relative)
if missing:
for relative in missing:
print(f"DIST-LAYOUT-001: missing required path: {relative}", file=sys.stderr)
print(f"Distribution layout audit: {len(missing)} violation(s)", file=sys.stderr)
return 1
if forbidden_present:
for relative in forbidden_present:
print(f"DIST-LAYOUT-002: generated path must stay outside repository: {relative}", file=sys.stderr)
print(f"Distribution layout audit: {len(forbidden_present)} violation(s)", file=sys.stderr)
return 1
print(f"Distribution layout audit: clean ({len(REQUIRED_PATHS)} required path(s), {len(FORBIDDEN_PATHS)} forbidden path(s) absent)")
return 0
if __name__ == "__main__":
raise SystemExit(main())