#!/usr/bin/env python3 """Assemble release/ per minitool-zip-builder skill (flat + relative paths).""" from __future__ import annotations import shutil import sys from pathlib import Path from subprocess import check_call ROOT = Path(__file__).resolve().parents[1] SRC = ROOT / "tool" OUT = ROOT / "release" def main() -> int: check_call([sys.executable, str(ROOT / "scripts" / "build_book_data.py")]) if OUT.exists(): shutil.rmtree(OUT) OUT.mkdir(parents=True) book = (SRC / "book-data.js").read_text(encoding="utf-8") md = (SRC / "markdown.js").read_text(encoding="utf-8") bridge = (SRC / "xhs-bridge.js").read_text(encoding="utf-8") app = (SRC / "app.js").read_text(encoding="utf-8") bundle = ( "/* bundled classic script for xhs minitool */\n" + book + "\n" + md + "\n" + bridge + "\n" + app + "\n" ) shutil.copy2(SRC / "index.html", OUT / "index.html") shutil.copy2(SRC / "styles.css", OUT / "styles.css") (OUT / "app.js").write_text(bundle, encoding="utf-8") print(f"assembled {OUT}") for p in sorted(OUT.iterdir()): print(f" {p.name}\t{p.stat().st_size}") return 0 if __name__ == "__main__": raise SystemExit(main())