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>
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Sync links.json + icons into xhs/tool for offline packaging.
|
|
Aligned with apps/navmini/xhs/scripts/sync_data.py — paths adapted for apps/miniprogram.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1] # xhs/
|
|
MINI = ROOT.parent # apps/miniprogram
|
|
NAVMINI = MINI.parent / "navmini"
|
|
|
|
SRC_JSON = MINI / "src" / "data" / "links.json"
|
|
if not SRC_JSON.is_file():
|
|
SRC_JSON = NAVMINI / "src" / "data" / "links.json"
|
|
|
|
SRC_ICONS = MINI / "src" / "assets" / "icons"
|
|
if not SRC_ICONS.is_dir():
|
|
SRC_ICONS = NAVMINI / "public" / "icons"
|
|
|
|
TOOL = ROOT / "tool"
|
|
OUT_ICONS = TOOL / "icons"
|
|
OUT_DATA = TOOL / "nav-data.js"
|
|
|
|
|
|
def main() -> int:
|
|
if not SRC_JSON.is_file():
|
|
print(f"missing {SRC_JSON}", file=sys.stderr)
|
|
return 1
|
|
|
|
data = json.loads(SRC_JSON.read_text(encoding="utf-8"))
|
|
OUT_ICONS.mkdir(parents=True, exist_ok=True)
|
|
|
|
for old in OUT_ICONS.glob("*"):
|
|
if old.is_file():
|
|
old.unlink()
|
|
|
|
if SRC_ICONS.is_dir():
|
|
for icon in SRC_ICONS.glob("*"):
|
|
if icon.is_file():
|
|
shutil.copy2(icon, OUT_ICONS / icon.name)
|
|
|
|
payload = json.dumps(data, ensure_ascii=False, indent=2)
|
|
OUT_DATA.write_text(
|
|
f"/* auto-generated — do not edit */\nwindow.__NAV_DATA__ = {payload};\n",
|
|
encoding="utf-8",
|
|
)
|
|
print(f"wrote {OUT_DATA} categories={len(data.get('categories') or [])}")
|
|
print(f"icons from {SRC_ICONS} -> {OUT_ICONS}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|