Switch miniprogram H5 to Vite for fast local compile; align portal pages and static icons for cross-machine continue. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
||
"""Pack release-book/ → dist/yidu-xingqiu-xhs-tool.zip(电子书独立上传)。"""
|
||
from __future__ import annotations
|
||
|
||
import sys
|
||
import zipfile
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
TOOL = ROOT / "release-book"
|
||
OUT = ROOT / "dist" / "yidu-xingqiu-xhs-tool.zip"
|
||
|
||
|
||
def main() -> int:
|
||
out = Path(sys.argv[1]) if len(sys.argv) > 1 else OUT
|
||
out.parent.mkdir(parents=True, exist_ok=True)
|
||
if out.exists():
|
||
out.unlink()
|
||
|
||
root_index = TOOL / "index.html"
|
||
if not root_index.is_file():
|
||
print("run: python scripts/assemble_book.py", file=sys.stderr)
|
||
return 1
|
||
nested = [p for p in TOOL.rglob("index.html") if p != root_index]
|
||
if nested:
|
||
print("FATAL nested index.html", nested, file=sys.stderr)
|
||
return 1
|
||
|
||
files = sorted(p for p in TOOL.rglob("*") if p.is_file())
|
||
with zipfile.ZipFile(out, "w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||
zf.write(root_index, "index.html")
|
||
for p in files:
|
||
rel = p.relative_to(TOOL).as_posix()
|
||
if rel == "index.html":
|
||
continue
|
||
zf.write(p, rel)
|
||
|
||
names = zipfile.ZipFile(out).namelist()
|
||
print(f"packed {out} ({out.stat().st_size / 1024:.1f} KB) entries={names}")
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|