34 lines
1.7 KiB
Python
Executable File
34 lines
1.7 KiB
Python
Executable File
from pathlib import Path
|
|
|
|
APP_PARTS = ("core.js", "session-resume.js", "refresh.js", "rate-sampling.js", "preferences.js", "dashboard-layout-editor.js", "dashboard-inline-layout.js", "stream-dashboard.js", "backend-dashboard.js", "config-history.js", "runtime.js", "settings.js")
|
|
PANEL_PARTS = (
|
|
"management.js", "drafts.js", "integrations.js", "vhosts.js",
|
|
"web-server-profiles.js", "web-server.js", "docker.js", "streams.js",
|
|
"redirects.js", "host404.js", "traffic-panel.js", "cache-panel.js",
|
|
"transform-panel.js", "acme.js", "settings.js", "certificate-api.js", "file-logs.js",
|
|
)
|
|
VHOST_PARTS = ("core.js", "protocol.js", "health.js", "rates.js", "editor.js", "render.js")
|
|
|
|
def _read(root: Path, folder: str, parts: tuple[str, ...]) -> str:
|
|
return "\n".join((root / "src/admin/web" / folder / part).read_text(encoding="utf-8") for part in parts)
|
|
|
|
def read_vhosts_js(root: Path) -> str:
|
|
body = _read(root, "vhosts", VHOST_PARTS)
|
|
return "(() => {\n" + body + "\n})();"
|
|
|
|
def read_app_js(root: Path) -> str:
|
|
# Mirror the Rust include_str! assembly including the server-validated
|
|
# widget registry, so QA parses the same core used by the real panel.
|
|
parts = []
|
|
for part in APP_PARTS:
|
|
if part == "preferences.js":
|
|
registry = (root / "src/admin/web/dashboard-widgets.json").read_text(encoding="utf-8")
|
|
parts.append(f"const ADMIN_DASHBOARD_WIDGET_REGISTRY = Object.freeze({registry});")
|
|
parts.append((root / "src/admin/web/app" / part).read_text(encoding="utf-8"))
|
|
primary = "\n".join(parts)
|
|
panel = "\n".join(
|
|
read_vhosts_js(root) if name == "vhosts.js" else (root / "src/admin/web" / name).read_text(encoding="utf-8")
|
|
for name in PANEL_PARTS
|
|
)
|
|
return primary + "\n" + panel
|