43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Copy tool/ + src/data.js into release/ for XHS zip (H5 mirror)."""
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
TOOL = ROOT / "tool"
|
|
SRC_DATA = ROOT / "src" / "data.js"
|
|
RELEASE = ROOT / "release"
|
|
|
|
FILES = (
|
|
"index.html",
|
|
"app.js",
|
|
"nomadro.css",
|
|
"xhs-bridge.js",
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
if RELEASE.exists():
|
|
shutil.rmtree(RELEASE)
|
|
RELEASE.mkdir(parents=True)
|
|
for name in FILES:
|
|
src = TOOL / name
|
|
if not src.exists():
|
|
print(f"missing {src}")
|
|
return 1
|
|
shutil.copy2(src, RELEASE / name)
|
|
if not SRC_DATA.exists():
|
|
print(f"missing {SRC_DATA} — run: python scripts/build_data.py")
|
|
return 1
|
|
shutil.copy2(SRC_DATA, RELEASE / "data.js")
|
|
# keep a copy in tool/ for local preview
|
|
shutil.copy2(SRC_DATA, TOOL / "data.js")
|
|
print(f"assembled {RELEASE}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|