"""Build only the files served by the public demo.""" from pathlib import Path import json import re import shutil import sys root = Path(__file__).resolve().parents[1] out = Path(sys.argv[1]) out.mkdir(parents=True, exist_ok=True) static = root / "game/static" for name in ("app.js", "airfield.js", "cards.js", "demo-client.js", "style.css"): shutil.copy(static / name, out) index = (static / "index.html").read_text().replace('','') index = re.sub(r'', '', index, flags=re.S) index = re.sub(r'', '', index) index = re.sub(r'', '', index) (out / "index.html").write_text(index) shutil.copy(root / "game/catalog.json", out) for name in ("worker.js","cookie-worker.js","cookie-bridge.js"): shutil.copy(root / "demo" / name, out) shutil.copytree(root / "demo/vendor", out / "vendor", dirs_exist_ok=True) for license_file in (root / "demo").glob("LICENSE-*"): shutil.copy(license_file, out / (license_file.name + ".txt")) files = {name:(root / "game" / name).read_text() for name in ("catalog.json","engine.py","strategy.py")} files["local_game.py"] = (root / "demo/local_game.py").read_text() (out / "rules.json").write_text(json.dumps(files, ensure_ascii=False))