Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
||
"""Assemble xhs/release/ (flat + relative paths, classic script only)."""
|
||
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" / "sync_data.py")])
|
||
|
||
OUT.mkdir(parents=True, exist_ok=True)
|
||
|
||
data_js = (SRC / "nav-data.js").read_text(encoding="utf-8")
|
||
app_js = (SRC / "app.js").read_text(encoding="utf-8")
|
||
bundle = (
|
||
"/* bundled classic script for xhs minitool */\n"
|
||
+ data_js
|
||
+ "\n"
|
||
+ app_js
|
||
+ "\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")
|
||
|
||
icons_src = SRC / "icons"
|
||
icons_dst = OUT / "icons"
|
||
if icons_dst.exists():
|
||
shutil.rmtree(icons_dst, ignore_errors=True)
|
||
if icons_src.is_dir():
|
||
shutil.copytree(icons_src, icons_dst)
|
||
|
||
# 电子书离线包(对齐 ebook/redmini)
|
||
book_out = OUT / "book"
|
||
if book_out.exists():
|
||
shutil.rmtree(book_out, ignore_errors=True)
|
||
book_out.mkdir(parents=True, exist_ok=True)
|
||
for name, dest in [
|
||
("book.html", "index.html"),
|
||
("book-styles.css", "styles.css"),
|
||
("book-app.js", "app.js"),
|
||
]:
|
||
src_f = SRC / name
|
||
if src_f.is_file():
|
||
shutil.copy2(src_f, book_out / dest)
|
||
book_data_dir = SRC / "book"
|
||
if book_data_dir.is_dir():
|
||
for f in book_data_dir.iterdir():
|
||
if f.is_file():
|
||
shutil.copy2(f, book_out / f.name)
|
||
|
||
print(f"assembled {OUT}")
|
||
total = 0
|
||
for p in sorted(OUT.rglob("*")):
|
||
if p.is_file():
|
||
total += p.stat().st_size
|
||
print(f" {p.relative_to(OUT).as_posix()}\t{p.stat().st_size}")
|
||
print(f"total {total / 1024:.1f} KB")
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|