nomadro/apps/ebook/redmini/scripts/assemble.py
eric d93a355fd5 Migrate navmini/ebook/nomadweb into apps/ as same-origin portal subpaths.
Shield external portal jumps (keep EXTERNAL_* for later), serve /nav from static build, and proxy /book + /community to vertical Next apps with Caddy notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 03:30:34 -05:00

50 lines
1.3 KiB
Python

#!/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())