home-hosted 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +319 -628
- package/dist/chunks/archive-DP-XQR8X.js +352 -0
- package/dist/chunks/archive-DP-XQR8X.js.map +1 -0
- package/dist/chunks/atomic-C1PfJpE7.js +26 -0
- package/dist/chunks/atomic-C1PfJpE7.js.map +1 -0
- package/dist/chunks/backup-CZcVca2a.js +822 -0
- package/dist/chunks/backup-CZcVca2a.js.map +1 -0
- package/dist/chunks/backups-CFRaWe_m.js +4691 -0
- package/dist/chunks/backups-CFRaWe_m.js.map +1 -0
- package/dist/chunks/config-text-DifCHhnz.js +50 -0
- package/dist/chunks/config-text-DifCHhnz.js.map +1 -0
- package/dist/chunks/contracts-CMBD1TF9.js +2230 -0
- package/dist/chunks/contracts-CMBD1TF9.js.map +1 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js +241 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +1 -0
- package/dist/chunks/daemon-qKVECISl.js +247 -0
- package/dist/chunks/daemon-qKVECISl.js.map +1 -0
- package/dist/chunks/docker-Cy9Lyvda.js +437 -0
- package/dist/chunks/docker-Cy9Lyvda.js.map +1 -0
- package/dist/chunks/down-pKbGCW9d.js +383 -0
- package/dist/chunks/down-pKbGCW9d.js.map +1 -0
- package/dist/chunks/init-BZ7hK9Vf.js +276 -0
- package/dist/chunks/init-BZ7hK9Vf.js.map +1 -0
- package/dist/chunks/last-stop-C-BXz_XI.js +53 -0
- package/dist/chunks/last-stop-C-BXz_XI.js.map +1 -0
- package/dist/chunks/layout-DwTtmund.js +24 -0
- package/dist/chunks/layout-DwTtmund.js.map +1 -0
- package/dist/chunks/lazy-Ce5zEAq1.js +66 -0
- package/dist/chunks/lazy-Ce5zEAq1.js.map +1 -0
- package/dist/chunks/log-buffer-Dy9HHDMD.js +414 -0
- package/dist/chunks/log-buffer-Dy9HHDMD.js.map +1 -0
- package/dist/chunks/logger-B5U4GD3j.js +13 -0
- package/dist/chunks/logger-B5U4GD3j.js.map +1 -0
- package/dist/chunks/logs---TI_bxM.js +267 -0
- package/dist/chunks/logs---TI_bxM.js.map +1 -0
- package/dist/chunks/migrate-Cfoq-Vgh.js +155 -0
- package/dist/chunks/migrate-Cfoq-Vgh.js.map +1 -0
- package/dist/chunks/nanny-B-Eu0sFW.js +132 -0
- package/dist/chunks/nanny-B-Eu0sFW.js.map +1 -0
- package/dist/chunks/nanny-BtWfy0QH.js +1167 -0
- package/dist/chunks/nanny-BtWfy0QH.js.map +1 -0
- package/dist/chunks/nanny-ChMtq1Zl.js +39 -0
- package/dist/chunks/nanny-ChMtq1Zl.js.map +1 -0
- package/dist/chunks/nanny-sweep-DErnlPY1.js +105 -0
- package/dist/chunks/nanny-sweep-DErnlPY1.js.map +1 -0
- package/dist/chunks/nearest-6KgQEDUe.js +41 -0
- package/dist/chunks/nearest-6KgQEDUe.js.map +1 -0
- package/dist/chunks/parse-DhmG26fI.js +383 -0
- package/dist/chunks/parse-DhmG26fI.js.map +1 -0
- package/dist/chunks/paths-CGlGDrOU.js +206 -0
- package/dist/chunks/paths-CGlGDrOU.js.map +1 -0
- package/dist/chunks/port-B8WBTRMk.js +333 -0
- package/dist/chunks/port-B8WBTRMk.js.map +1 -0
- package/dist/chunks/restart-Des4DrAN.js +92 -0
- package/dist/chunks/restart-Des4DrAN.js.map +1 -0
- package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/chunks/schema-B240VXcV.js +103 -0
- package/dist/chunks/schema-B240VXcV.js.map +1 -0
- package/dist/chunks/secrets-BieELnZh.js +562 -0
- package/dist/chunks/secrets-BieELnZh.js.map +1 -0
- package/dist/chunks/server-Bge2r2qQ.js +169 -0
- package/dist/chunks/server-Bge2r2qQ.js.map +1 -0
- package/dist/chunks/server-ids-DRuNLVCV.js +32 -0
- package/dist/chunks/server-ids-DRuNLVCV.js.map +1 -0
- package/dist/chunks/set-password-D5vZqqSX.js +43 -0
- package/dist/chunks/set-password-D5vZqqSX.js.map +1 -0
- package/dist/chunks/set-token-obPiEJYk.js +78 -0
- package/dist/chunks/set-token-obPiEJYk.js.map +1 -0
- package/dist/chunks/settings-xu-XTfWg.js +423 -0
- package/dist/chunks/settings-xu-XTfWg.js.map +1 -0
- package/dist/chunks/setup-temp-CAN4_bA-.js +150 -0
- package/dist/chunks/setup-temp-CAN4_bA-.js.map +1 -0
- package/dist/chunks/shape-DnTKzjQ2.js +24 -0
- package/dist/chunks/shape-DnTKzjQ2.js.map +1 -0
- package/dist/chunks/src-BtWMFmzZ.js +12338 -0
- package/dist/chunks/src-BtWMFmzZ.js.map +1 -0
- package/dist/chunks/status-DT1EsA-B.js +123 -0
- package/dist/chunks/status-DT1EsA-B.js.map +1 -0
- package/dist/chunks/ui-D562aqw5.js +325 -0
- package/dist/chunks/ui-D562aqw5.js.map +1 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js +39 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +1 -0
- package/dist/chunks/ui-release-DKzVvlLd.js +312 -0
- package/dist/chunks/ui-release-DKzVvlLd.js.map +1 -0
- package/dist/chunks/ui-revert-EkBBwRTt.js +27 -0
- package/dist/chunks/ui-revert-EkBBwRTt.js.map +1 -0
- package/dist/chunks/ui-switch-BnZTdMDd.js +150 -0
- package/dist/chunks/ui-switch-BnZTdMDd.js.map +1 -0
- package/dist/chunks/ui-update-_xryLYxw.js +272 -0
- package/dist/chunks/ui-update-_xryLYxw.js.map +1 -0
- package/dist/chunks/up-Pdz-l6IH.js +210 -0
- package/dist/chunks/up-Pdz-l6IH.js.map +1 -0
- package/dist/chunks/usage-DFrCVXpT.js +111 -0
- package/dist/chunks/usage-DFrCVXpT.js.map +1 -0
- package/dist/chunks/workspaces-DYcfvKV_.js +229 -0
- package/dist/chunks/workspaces-DYcfvKV_.js.map +1 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js +322 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +1 -0
- package/dist/cli.js +441 -25418
- package/dist/cli.js.map +1 -1
- package/dist/client.js +144 -0
- package/dist/client.js.map +1 -0
- package/dist/types/api/acme.d.ts +24 -0
- package/dist/types/api/auth/$.routes.d.ts +103 -0
- package/dist/types/api/backups.d.ts +184 -0
- package/dist/types/api/control.d.ts +470 -0
- package/dist/types/api/ddns.d.ts +432 -0
- package/dist/types/api/events.d.ts +22 -0
- package/dist/types/api/health.d.ts +28 -0
- package/dist/types/api/logs.d.ts +95 -0
- package/dist/types/api/metrics.d.ts +21 -0
- package/dist/types/api/notifications.d.ts +141 -0
- package/dist/types/api/proxy.d.ts +1128 -0
- package/dist/types/api/servers/$.routes.d.ts +1318 -0
- package/dist/types/api/settings.d.ts +642 -0
- package/dist/types/api/state.d.ts +498 -0
- package/dist/types/api/static.d.ts +11 -0
- package/dist/types/api/tls.d.ts +112 -0
- package/dist/types/api/workspaces/$.routes.d.ts +797 -0
- package/dist/types/api/wsl-temperature.d.ts +113 -0
- package/dist/types/app.d.ts +6095 -0
- package/dist/types/cli/args.d.ts +75 -0
- package/dist/types/cli/backup-offline.d.ts +23 -0
- package/dist/types/cli/backup.d.ts +86 -0
- package/dist/types/cli/down.d.ts +80 -0
- package/dist/types/cli/init.d.ts +60 -0
- package/dist/types/cli/io.d.ts +65 -0
- package/dist/types/cli/logs.d.ts +76 -0
- package/dist/types/cli/migrate.d.ts +33 -0
- package/dist/types/cli/nanny.d.ts +19 -0
- package/dist/types/cli/nearest.d.ts +10 -0
- package/dist/types/cli/restart.d.ts +41 -0
- package/dist/types/cli/server.d.ts +68 -0
- package/dist/types/cli/set-password.d.ts +14 -0
- package/dist/types/cli/set-token.d.ts +21 -0
- package/dist/types/cli/setup-temp.d.ts +65 -0
- package/dist/types/cli/status.d.ts +14 -0
- package/dist/types/cli/ui-revert.d.ts +3 -0
- package/dist/types/cli/ui-switch.d.ts +27 -0
- package/dist/types/cli/ui-update.d.ts +72 -0
- package/dist/types/cli/up.d.ts +96 -0
- package/dist/types/cli/usage.d.ts +23 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/client.d.ts +11891 -0
- package/dist/types/config/layout.d.ts +11 -0
- package/dist/types/config/migrations.d.ts +69 -0
- package/dist/types/config/parse.d.ts +54 -0
- package/dist/types/config/patch.d.ts +20 -0
- package/dist/types/config/schema.d.ts +318 -0
- package/dist/types/config/secret-parts.d.ts +48 -0
- package/dist/types/config/secrets.d.ts +208 -0
- package/dist/types/config/seed.d.ts +30 -0
- package/dist/types/config/server-ids.d.ts +14 -0
- package/dist/types/config/settings.d.ts +120 -0
- package/dist/types/config/store.d.ts +145 -0
- package/dist/types/config/workspaces.d.ts +99 -0
- package/dist/types/helpers/action-result.d.ts +46 -0
- package/dist/types/helpers/atomic.d.ts +9 -0
- package/dist/types/helpers/backoff.d.ts +7 -0
- package/dist/types/helpers/bind.d.ts +16 -0
- package/dist/types/helpers/config-text.d.ts +23 -0
- package/dist/types/helpers/cookies.d.ts +19 -0
- package/dist/types/helpers/copy-tree.d.ts +20 -0
- package/dist/types/helpers/daemon-log.d.ts +45 -0
- package/dist/types/helpers/daemon.d.ts +135 -0
- package/dist/types/helpers/deferred.d.ts +7 -0
- package/dist/types/helpers/env-file.d.ts +20 -0
- package/dist/types/helpers/error.d.ts +26 -0
- package/dist/types/helpers/event-stream.d.ts +21 -0
- package/dist/types/helpers/factory.d.ts +6 -0
- package/dist/types/helpers/last-stop.d.ts +20 -0
- package/dist/types/helpers/logger.d.ts +7 -0
- package/dist/types/helpers/open.d.ts +2 -0
- package/dist/types/helpers/openapi.d.ts +34 -0
- package/dist/types/helpers/paths.d.ts +112 -0
- package/dist/types/helpers/restore-lock.d.ts +32 -0
- package/dist/types/helpers/runtime.d.ts +18 -0
- package/dist/types/helpers/secret-compare.d.ts +13 -0
- package/dist/types/helpers/shell.d.ts +19 -0
- package/dist/types/helpers/sse.d.ts +23 -0
- package/dist/types/helpers/template.d.ts +8 -0
- package/dist/types/helpers/ui-dir.d.ts +11 -0
- package/dist/types/helpers/utf8-chunks.d.ts +15 -0
- package/dist/types/helpers/validate.d.ts +7 -0
- package/dist/types/helpers/validator.d.ts +12 -0
- package/dist/types/helpers/version.d.ts +10 -0
- package/dist/types/helpers/workspace.d.ts +25 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/middleware/auth.d.ts +53 -0
- package/dist/types/middleware/host.d.ts +29 -0
- package/dist/types/middleware/loopback.d.ts +18 -0
- package/dist/types/openapi-reference.d.ts +22 -0
- package/dist/types/openapi.d.ts +34 -0
- package/dist/types/providers/archive.d.ts +54 -0
- package/dist/types/providers/backup-hook.d.ts +34 -0
- package/dist/types/providers/ddns/cloudflare.d.ts +2 -0
- package/dist/types/providers/ddns/desec.d.ts +2 -0
- package/dist/types/providers/ddns/digitalocean.d.ts +2 -0
- package/dist/types/providers/ddns/duckdns.d.ts +2 -0
- package/dist/types/providers/ddns/dyndns2.d.ts +15 -0
- package/dist/types/providers/ddns/dynu.d.ts +2 -0
- package/dist/types/providers/ddns/freedns.d.ts +2 -0
- package/dist/types/providers/ddns/gandi.d.ts +2 -0
- package/dist/types/providers/ddns/godaddy.d.ts +2 -0
- package/dist/types/providers/ddns/henet.d.ts +3 -0
- package/dist/types/providers/ddns/index.d.ts +12 -0
- package/dist/types/providers/ddns/ip.d.ts +27 -0
- package/dist/types/providers/ddns/namecheap-api.d.ts +13 -0
- package/dist/types/providers/ddns/namecheap.d.ts +6 -0
- package/dist/types/providers/ddns/noip.d.ts +2 -0
- package/dist/types/providers/ddns/porkbun.d.ts +2 -0
- package/dist/types/providers/ddns/spaceship.d.ts +7 -0
- package/dist/types/providers/ddns/types.d.ts +98 -0
- package/dist/types/providers/ddns/zone.d.ts +11 -0
- package/dist/types/providers/docker.d.ts +117 -0
- package/dist/types/providers/entry-state.d.ts +15 -0
- package/dist/types/providers/health-check.d.ts +27 -0
- package/dist/types/providers/host.d.ts +147 -0
- package/dist/types/providers/identity.d.ts +54 -0
- package/dist/types/providers/log-tail.d.ts +56 -0
- package/dist/types/providers/nanny-sweep.d.ts +54 -0
- package/dist/types/providers/nanny.d.ts +104 -0
- package/dist/types/providers/port.d.ts +142 -0
- package/dist/types/providers/proc.d.ts +125 -0
- package/dist/types/providers/process.d.ts +78 -0
- package/dist/types/providers/proxy/caddy.d.ts +2 -0
- package/dist/types/providers/proxy/index.d.ts +7 -0
- package/dist/types/providers/proxy/types.d.ts +54 -0
- package/dist/types/providers/server-vars.d.ts +4 -0
- package/dist/types/providers/telegram.d.ts +74 -0
- package/dist/types/providers/ui-release.d.ts +113 -0
- package/dist/types/providers/webhook.d.ts +64 -0
- package/dist/types/providers/wsl-temperature.d.ts +65 -0
- package/dist/types/services/acme-challenge.d.ts +44 -0
- package/dist/types/services/auth.d.ts +177 -0
- package/dist/types/services/backups.d.ts +476 -0
- package/dist/types/services/config-watch.d.ts +40 -0
- package/dist/types/services/control-server.d.ts +58 -0
- package/dist/types/services/ddns.d.ts +72 -0
- package/dist/types/services/dependencies.d.ts +21 -0
- package/dist/types/services/events.d.ts +17 -0
- package/dist/types/services/exposure.d.ts +86 -0
- package/dist/types/services/history.d.ts +37 -0
- package/dist/types/services/host-monitor.d.ts +33 -0
- package/dist/types/services/init.d.ts +71 -0
- package/dist/types/services/log-buffer.d.ts +39 -0
- package/dist/types/services/log-files.d.ts +77 -0
- package/dist/types/services/log-relay.d.ts +35 -0
- package/dist/types/services/nanny.d.ts +14 -0
- package/dist/types/services/notifications.d.ts +124 -0
- package/dist/types/services/panel.d.ts +213 -0
- package/dist/types/services/proxy-certificates/certificates.d.ts +116 -0
- package/dist/types/services/proxy-config.d.ts +83 -0
- package/dist/types/services/proxy.d.ts +431 -0
- package/dist/types/services/state.d.ts +38 -0
- package/dist/types/services/supervisor/compose.d.ts +17 -0
- package/dist/types/services/supervisor/entry.d.ts +149 -0
- package/dist/types/services/supervisor/health.d.ts +56 -0
- package/dist/types/services/supervisor/output.d.ts +126 -0
- package/dist/types/services/supervisor/pending-load.d.ts +6 -0
- package/dist/types/services/supervisor/persistent.d.ts +58 -0
- package/dist/types/services/supervisor/port-preflight.d.ts +45 -0
- package/dist/types/services/supervisor/records.d.ts +118 -0
- package/dist/types/services/supervisor/spawn.d.ts +15 -0
- package/dist/types/services/supervisor/view.d.ts +4 -0
- package/dist/types/services/supervisor.d.ts +145 -0
- package/dist/types/services/tls.d.ts +48 -0
- package/dist/types/services/ui-update.d.ts +44 -0
- package/dist/types/services/ui.d.ts +50 -0
- package/dist/types/shared/action-outcome.d.ts +25 -0
- package/dist/types/shared/api-client.d.ts +351 -0
- package/dist/types/shared/backup-scope.d.ts +167 -0
- package/dist/types/shared/clone.d.ts +14 -0
- package/dist/types/shared/contracts.d.ts +4175 -0
- package/dist/types/shared/cpu-scale.d.ts +25 -0
- package/dist/types/shared/ddns-form.d.ts +75 -0
- package/dist/types/shared/endpoint.d.ts +8 -0
- package/dist/types/shared/error-message.d.ts +8 -0
- package/dist/types/shared/fields.d.ts +21 -0
- package/dist/types/shared/form-repair.d.ts +6 -0
- package/dist/types/shared/generated.d.ts +26 -0
- package/dist/types/shared/host-readings.d.ts +185 -0
- package/dist/types/shared/lazy.d.ts +4 -0
- package/dist/types/shared/live-frames.d.ts +22 -0
- package/dist/types/shared/live-series.d.ts +21 -0
- package/dist/types/shared/live-store.d.ts +72 -0
- package/dist/types/shared/patch-diff.d.ts +105 -0
- package/dist/types/shared/probe-latency.d.ts +25 -0
- package/dist/types/shared/proxy-form.d.ts +184 -0
- package/dist/types/shared/server-attention.d.ts +37 -0
- package/dist/types/shared/server-form.d.ts +121 -0
- package/dist/types/shared/server-key.d.ts +13 -0
- package/dist/types/shared/server-readings.d.ts +55 -0
- package/dist/types/shared/server-url.d.ts +43 -0
- package/dist/types/shared/shape.d.ts +17 -0
- package/dist/types/shared/stream-access.d.ts +20 -0
- package/dist/types/shared/ui-format.d.ts +89 -0
- package/docs/API.md +209 -0
- package/docs/BACKUPS.md +117 -0
- package/docs/CLI.md +95 -0
- package/docs/DDNS.md +11 -1
- package/docs/NOTIFICATIONS.md +7 -1
- package/docs/REVERSE_PROXY.md +9 -3
- package/docs/SECURITY.md +93 -0
- package/docs/SERVERS.md +141 -34
- package/docs/UI_CREATION.md +91 -291
- package/docs/demo/blank-host-restore.sh +4 -3
- package/package.json +22 -14
- package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +1 -0
- package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +1 -0
- package/uis/stock/dist/assets/LogViewer-DIliXy62.js +1 -0
- package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +1 -0
- package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +39 -0
- package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +1 -0
- package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +2 -0
- package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +1 -0
- package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +2 -0
- package/uis/stock/dist/assets/de-BRITeb0H.js +1 -0
- package/uis/stock/dist/assets/es-B2zIEssV.js +1 -0
- package/uis/stock/dist/assets/fr-s0ZOBEqh.js +1 -0
- package/uis/stock/dist/assets/index-C1MehbKy.css +2 -0
- package/uis/stock/dist/assets/index-CnBN54wF.js +15 -0
- package/uis/stock/dist/assets/ja-CU7MR85V.js +1 -0
- package/uis/stock/dist/assets/ko-tL5Me6d-.js +1 -0
- package/uis/stock/dist/assets/ru-92yrvkNJ.js +1 -0
- package/uis/stock/dist/assets/vi-CzvY16k2.js +1 -0
- package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +1 -0
- package/uis/stock/dist/index.html +3 -2
- package/uis/stock/dist/ui.json +3 -3
- package/docs/RESTORE_DEMO.md +0 -306
- package/uis/stock/dist/assets/de-0YLueNal.js +0 -1
- package/uis/stock/dist/assets/es-FCHhRmn2.js +0 -1
- package/uis/stock/dist/assets/fr-C69Z8o0z.js +0 -1
- package/uis/stock/dist/assets/index-Cok5msAO.css +0 -2
- package/uis/stock/dist/assets/index-KdyqrVv8.js +0 -53
- package/uis/stock/dist/assets/ja-Chz9YOqR.js +0 -1
- package/uis/stock/dist/assets/ko-CtXZ2x1l.js +0 -1
- package/uis/stock/dist/assets/ru-D_jE64xN.js +0 -1
- package/uis/stock/dist/assets/vi-sxSffss7.js +0 -1
- package/uis/stock/dist/assets/zh-CN-ChTpf29X.js +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { C as errorMessage } from "../cli.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
//#region src/providers/ui-release.ts
|
|
6
|
+
/**
|
|
7
|
+
* The GitHub-release side of installing a UI: which repo, which tag, which asset, how
|
|
8
|
+
* to read the release metadata and how to download one. `ui-switch` picks a release by
|
|
9
|
+
* hand and `ui-update` follows what an installed UI declared, but both go through this
|
|
10
|
+
* one implementation — the failure messages and the asset matching are the same problem.
|
|
11
|
+
*/
|
|
12
|
+
var DEFAULT_REPO = "NamesMT/home-hosted";
|
|
13
|
+
/** Mirrors the cap `UiService` enforces uncompressed — the same body, before it is parsed. */
|
|
14
|
+
var MAX_DOWNLOAD_BYTES = 536870912;
|
|
15
|
+
/** `owner/name`, the only slug GitHub releases are addressed by. */
|
|
16
|
+
function parseRepoSlug(value) {
|
|
17
|
+
const match = /^([\w.-]+)\/([\w.-]+)$/.exec(value.trim());
|
|
18
|
+
if (match === null) return null;
|
|
19
|
+
return {
|
|
20
|
+
owner: match[1],
|
|
21
|
+
name: match[2]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function repoSlug(repo) {
|
|
25
|
+
return `${repo.owner}/${repo.name}`;
|
|
26
|
+
}
|
|
27
|
+
/** The repo the default tag rule is about; `DEFAULT_REPO` is its only definition. */
|
|
28
|
+
function isOwnRepo(repo) {
|
|
29
|
+
return repoSlug(repo).toLowerCase() === DEFAULT_REPO.toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Our own release tag matches this CLI's version, so a UI is paired with the panel
|
|
33
|
+
* it was built for. Another repo has no such pairing, so its latest release is used.
|
|
34
|
+
* `null` means "latest".
|
|
35
|
+
*/
|
|
36
|
+
function defaultReleaseTag(repo, version) {
|
|
37
|
+
return isOwnRepo(repo) ? `v${version}` : null;
|
|
38
|
+
}
|
|
39
|
+
function releaseApiUrl(repo, tag) {
|
|
40
|
+
const base = `https://api.github.com/repos/${repo.owner}/${repo.name}/releases`;
|
|
41
|
+
if (tag === null || tag.length === 0 || tag === "latest") return `${base}/latest`;
|
|
42
|
+
return `${base}/tags/${encodeURIComponent(tag)}`;
|
|
43
|
+
}
|
|
44
|
+
/** Every published release, newest first, as GitHub orders them. */
|
|
45
|
+
function releasesApiUrl(repo, perPage = 30) {
|
|
46
|
+
return `https://api.github.com/repos/${repo.owner}/${repo.name}/releases?per_page=${perPage}`;
|
|
47
|
+
}
|
|
48
|
+
/** Generous and predictable: a UI bundle is an asset whose name ends in `.zip`. */
|
|
49
|
+
function isUiAsset(name) {
|
|
50
|
+
return /\.zip$/i.test(name.trim());
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a wanted asset: an exact name, a case-insensitive name, or a single
|
|
54
|
+
* unambiguous substring (`--asset stock` for `home-hosted-ui-stock.zip`).
|
|
55
|
+
*/
|
|
56
|
+
function matchAsset(names, query) {
|
|
57
|
+
const wanted = query.trim();
|
|
58
|
+
if (wanted.length === 0) return {
|
|
59
|
+
ok: false,
|
|
60
|
+
error: "no asset name was given"
|
|
61
|
+
};
|
|
62
|
+
const exact = names.find((name) => name === wanted);
|
|
63
|
+
if (exact !== void 0) return {
|
|
64
|
+
ok: true,
|
|
65
|
+
name: exact
|
|
66
|
+
};
|
|
67
|
+
const lower = wanted.toLowerCase();
|
|
68
|
+
const insensitive = names.filter((name) => name.toLowerCase() === lower);
|
|
69
|
+
if (insensitive.length === 1) return {
|
|
70
|
+
ok: true,
|
|
71
|
+
name: insensitive[0]
|
|
72
|
+
};
|
|
73
|
+
const partial = names.filter((name) => name.toLowerCase().includes(lower));
|
|
74
|
+
if (partial.length === 0) return {
|
|
75
|
+
ok: false,
|
|
76
|
+
error: `no asset matches "${wanted}" (available: ${names.join(", ") || "none"})`
|
|
77
|
+
};
|
|
78
|
+
if (partial.length > 1) return {
|
|
79
|
+
ok: false,
|
|
80
|
+
error: `"${wanted}" matches more than one asset: ${partial.join(", ")} — use the full name`
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
ok: true,
|
|
84
|
+
name: partial[0]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** `^https?://` means a URL; anything else is a filesystem path with `~` expanded. */
|
|
88
|
+
function parseFileSource(value) {
|
|
89
|
+
const trimmed = value.trim();
|
|
90
|
+
if (/^https?:\/\//i.test(trimmed)) return {
|
|
91
|
+
kind: "url",
|
|
92
|
+
url: trimmed
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
kind: "path",
|
|
96
|
+
path: expandHome(trimmed)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function expandHome(value) {
|
|
100
|
+
if (value === "~") return os.homedir();
|
|
101
|
+
if (value.startsWith("~/") || value.startsWith("~\\")) return path.join(os.homedir(), value.slice(2));
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A token is only ever sent to GitHub: `--file <url>` may point anywhere, and a
|
|
106
|
+
* credential must not leak to a host the user did not vouch for.
|
|
107
|
+
*/
|
|
108
|
+
function isGithubHost(url) {
|
|
109
|
+
try {
|
|
110
|
+
const parsed = new URL(url);
|
|
111
|
+
if (parsed.protocol !== "https:") return false;
|
|
112
|
+
const host = parsed.hostname.toLowerCase();
|
|
113
|
+
return host === "github.com" || host.endsWith(".github.com") || host === "githubusercontent.com" || host.endsWith(".githubusercontent.com");
|
|
114
|
+
} catch {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A hung connection must not become a hung command. `fetch` has no default timeout, and
|
|
120
|
+
* the startup hook is fire-and-forget: without this a stalled request would keep that
|
|
121
|
+
* promise (and its temp directory) pending for as long as the process lives.
|
|
122
|
+
*/
|
|
123
|
+
var REQUEST_TIMEOUT_MS = 3e4;
|
|
124
|
+
var DOWNLOAD_TIMEOUT_MS = 12e4;
|
|
125
|
+
function timeoutSignal(ms) {
|
|
126
|
+
return typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function" ? AbortSignal.timeout(ms) : void 0;
|
|
127
|
+
}
|
|
128
|
+
function isTimeout(error) {
|
|
129
|
+
return error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
|
|
130
|
+
}
|
|
131
|
+
/** What `UiService` names the install when the archive carries no `ui.json`. */
|
|
132
|
+
function fallbackUiName(source) {
|
|
133
|
+
const stripped = path.basename(source).replace(/\.zip$/i, "").replace(/^home-hosted-ui-/i, "");
|
|
134
|
+
return stripped.length > 0 ? stripped : "custom-ui";
|
|
135
|
+
}
|
|
136
|
+
/** One release's assets, or a message that says what was wrong with the answer. */
|
|
137
|
+
async function fetchRelease(repo, tag, context) {
|
|
138
|
+
const url = releaseApiUrl(repo, tag);
|
|
139
|
+
let response;
|
|
140
|
+
try {
|
|
141
|
+
response = await fetch(url, {
|
|
142
|
+
headers: apiHeaders(context),
|
|
143
|
+
signal: timeoutSignal(REQUEST_TIMEOUT_MS)
|
|
144
|
+
});
|
|
145
|
+
} catch (error) {
|
|
146
|
+
throw new Error(isTimeout(error) ? `GitHub did not answer within ${REQUEST_TIMEOUT_MS / 1e3}s` : `could not reach GitHub: ${describeError(error)}`);
|
|
147
|
+
}
|
|
148
|
+
if (!response.ok) throw new Error(describeReleaseFailure(response.status, repo, tag));
|
|
149
|
+
const body = await response.json();
|
|
150
|
+
return {
|
|
151
|
+
tag: body.tag_name ?? tag ?? "latest",
|
|
152
|
+
assets: Array.isArray(body.assets) ? body.assets : []
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/** Every published release, newest first. Drafts and unusable entries are dropped. */
|
|
156
|
+
async function fetchReleases(repo, context, perPage = 30) {
|
|
157
|
+
let response;
|
|
158
|
+
try {
|
|
159
|
+
response = await fetch(releasesApiUrl(repo, perPage), {
|
|
160
|
+
headers: apiHeaders(context),
|
|
161
|
+
signal: timeoutSignal(REQUEST_TIMEOUT_MS)
|
|
162
|
+
});
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw new Error(isTimeout(error) ? `GitHub did not answer within ${REQUEST_TIMEOUT_MS / 1e3}s` : `could not reach GitHub: ${describeError(error)}`);
|
|
165
|
+
}
|
|
166
|
+
if (!response.ok) throw new Error(describeReleaseFailure(response.status, repo, null));
|
|
167
|
+
const body = await response.json();
|
|
168
|
+
if (!Array.isArray(body)) return [];
|
|
169
|
+
return body.filter((release) => release.draft !== true && typeof release.tag_name === "string").map((release) => ({
|
|
170
|
+
tag: release.tag_name,
|
|
171
|
+
assets: Array.isArray(release.assets) ? release.assets : [],
|
|
172
|
+
publishedAt: typeof release.published_at === "string" ? release.published_at : null
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
function assetDownloadUrl(asset) {
|
|
176
|
+
const url = asset.url ?? asset.browser_download_url;
|
|
177
|
+
if (url === void 0 || url.length === 0) throw new Error(`the release metadata for "${asset.name ?? "an asset"}" carries no download URL`);
|
|
178
|
+
return url;
|
|
179
|
+
}
|
|
180
|
+
/** Streams to `os.tmpdir()` so a large body is never buffered in memory. */
|
|
181
|
+
async function downloadToTemp(url, headers, context) {
|
|
182
|
+
let response;
|
|
183
|
+
try {
|
|
184
|
+
response = await fetch(url, {
|
|
185
|
+
headers,
|
|
186
|
+
redirect: "follow",
|
|
187
|
+
signal: timeoutSignal(DOWNLOAD_TIMEOUT_MS)
|
|
188
|
+
});
|
|
189
|
+
} catch (error) {
|
|
190
|
+
throw new Error(isTimeout(error) ? `the download stalled for ${DOWNLOAD_TIMEOUT_MS / 1e3}s: ${url}` : `could not reach ${url}: ${describeError(error)}`);
|
|
191
|
+
}
|
|
192
|
+
if (!response.ok) throw new Error(describeDownloadFailure(response.status, url));
|
|
193
|
+
const declared = Number(response.headers.get("content-length") ?? "0");
|
|
194
|
+
if (!Number.isFinite(declared) || declared < 0) throw new Error(`the download from ${url} reported an unusable size`);
|
|
195
|
+
if (declared > 536870912) throw new Error(tooLargeMessage(declared));
|
|
196
|
+
if (response.body === null) throw new Error(`the download from ${url} had no body`);
|
|
197
|
+
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "hh-ui-"));
|
|
198
|
+
const file = path.join(dir, "ui.zip");
|
|
199
|
+
const handle = await fs.promises.open(file, "w");
|
|
200
|
+
let received = 0;
|
|
201
|
+
try {
|
|
202
|
+
for await (const chunk of response.body) {
|
|
203
|
+
received += chunk.length;
|
|
204
|
+
if (received > 536870912) throw new Error(tooLargeMessage(received));
|
|
205
|
+
await handle.write(chunk);
|
|
206
|
+
}
|
|
207
|
+
} catch (error) {
|
|
208
|
+
await handle.close();
|
|
209
|
+
fs.rmSync(dir, {
|
|
210
|
+
recursive: true,
|
|
211
|
+
force: true
|
|
212
|
+
});
|
|
213
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
214
|
+
}
|
|
215
|
+
await handle.close();
|
|
216
|
+
if (context.quiet !== true) context.io.write(`${context.io.style.dim(`downloaded ${formatBytes(received)}`)}\n`);
|
|
217
|
+
return {
|
|
218
|
+
dir,
|
|
219
|
+
file
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function apiHeaders(context) {
|
|
223
|
+
const headers = {
|
|
224
|
+
"accept": "application/vnd.github+json",
|
|
225
|
+
"user-agent": `home-hosted/${context.version}`,
|
|
226
|
+
"x-github-api-version": "2022-11-28"
|
|
227
|
+
};
|
|
228
|
+
if (context.token !== null && context.token.length > 0) headers.authorization = `Bearer ${context.token}`;
|
|
229
|
+
return headers;
|
|
230
|
+
}
|
|
231
|
+
function noAssetsMessage(where, skipped, tag) {
|
|
232
|
+
const lines = [`no usable UI assets in ${where} (expected a .zip)`];
|
|
233
|
+
lines.push(skipped.length > 0 ? ` skipped: ${skipped.join(", ")}` : " the release has no assets at all");
|
|
234
|
+
if (tag !== null && tag !== "latest") lines.push(" installing a different version silently is worse than failing: try the newest release with --tag latest");
|
|
235
|
+
return lines.join("\n");
|
|
236
|
+
}
|
|
237
|
+
function describeReleaseFailure(status, repo, tag) {
|
|
238
|
+
const slug = repoSlug(repo);
|
|
239
|
+
if (status === 404) {
|
|
240
|
+
if (tag !== null && tag !== "latest") return `no release tagged "${tag}" in ${slug}\n list what exists with: home-hosted ui-switch --repo ${slug} --tag latest --list`;
|
|
241
|
+
return `no repository or published release at ${slug}\n check the --repo slug (owner/name), and that the repository is public`;
|
|
242
|
+
}
|
|
243
|
+
if (status === 403 || status === 429) return `GitHub refused the request (HTTP ${status}) — the unauthenticated API rate limit is per address.\n set a token to raise it: --token <token>, or GITHUB_TOKEN / GH_TOKEN`;
|
|
244
|
+
if (status === 401) return "GitHub rejected the token (HTTP 401) — check --token, GITHUB_TOKEN or GH_TOKEN";
|
|
245
|
+
return `GitHub answered HTTP ${status} while reading the release of ${slug}`;
|
|
246
|
+
}
|
|
247
|
+
function describeDownloadFailure(status, url) {
|
|
248
|
+
const github = isGithubHost(url);
|
|
249
|
+
if (status === 404) return github ? `the asset is gone (HTTP 404) — ${url}\n the release may have been rebuilt since it was listed; run the command again` : `nothing is served at that URL (HTTP 404) — ${url}`;
|
|
250
|
+
if (status === 403 || status === 429) return github ? `GitHub refused the download (HTTP ${status}) — a token raises the rate limit: --token <token>, or GITHUB_TOKEN / GH_TOKEN` : `the host refused the download (HTTP ${status}) — ${url}`;
|
|
251
|
+
if (status === 401 && github) return "GitHub rejected the token on the download (HTTP 401) — check --token, GITHUB_TOKEN or GH_TOKEN";
|
|
252
|
+
return `the download failed (HTTP ${status}) — ${url}`;
|
|
253
|
+
}
|
|
254
|
+
function tooLargeMessage(bytes) {
|
|
255
|
+
return `the download is ${formatBytes(bytes)}, larger than the ${MAX_DOWNLOAD_BYTES / 1024 / 1024}MB a UI may be`;
|
|
256
|
+
}
|
|
257
|
+
function formatBytes(bytes) {
|
|
258
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
259
|
+
if (bytes < 1048576) return `${Math.round(bytes / 1024)} KB`;
|
|
260
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
261
|
+
}
|
|
262
|
+
function describeError(error) {
|
|
263
|
+
return errorMessage(error);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Tag ordering: `v1.2.3` beats `v1.2.2`, a prerelease loses to its release, and anything
|
|
267
|
+
* that is not a version sorts below every version that is. Enough to answer "is this
|
|
268
|
+
* release newer than the one the UI came from" without a semver dependency.
|
|
269
|
+
*/
|
|
270
|
+
function compareTags(a, b) {
|
|
271
|
+
const left = parseTag(a);
|
|
272
|
+
const right = parseTag(b);
|
|
273
|
+
if (left === null && right === null) return a.localeCompare(b);
|
|
274
|
+
if (left === null) return -1;
|
|
275
|
+
if (right === null) return 1;
|
|
276
|
+
for (let index = 0; index < 3; index++) {
|
|
277
|
+
const difference = (left.parts[index] ?? 0) - (right.parts[index] ?? 0);
|
|
278
|
+
if (difference !== 0) return difference;
|
|
279
|
+
}
|
|
280
|
+
if (left.prerelease.length === 0 && right.prerelease.length === 0) return 0;
|
|
281
|
+
if (left.prerelease.length === 0) return 1;
|
|
282
|
+
if (right.prerelease.length === 0) return -1;
|
|
283
|
+
for (let index = 0; index < Math.max(left.prerelease.length, right.prerelease.length); index++) {
|
|
284
|
+
const one = left.prerelease[index];
|
|
285
|
+
const two = right.prerelease[index];
|
|
286
|
+
if (one === void 0) return -1;
|
|
287
|
+
if (two === void 0) return 1;
|
|
288
|
+
if (one === two) continue;
|
|
289
|
+
const numeric = /^\d+$/;
|
|
290
|
+
if (numeric.test(one) && numeric.test(two)) return Number(one) - Number(two);
|
|
291
|
+
if (numeric.test(one)) return -1;
|
|
292
|
+
if (numeric.test(two)) return 1;
|
|
293
|
+
return one.localeCompare(two);
|
|
294
|
+
}
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
297
|
+
function parseTag(tag) {
|
|
298
|
+
const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+.*)?$/.exec(tag.trim());
|
|
299
|
+
if (match === null) return null;
|
|
300
|
+
return {
|
|
301
|
+
parts: [
|
|
302
|
+
Number(match[1]),
|
|
303
|
+
Number(match[2] ?? 0),
|
|
304
|
+
Number(match[3] ?? 0)
|
|
305
|
+
],
|
|
306
|
+
prerelease: match[4] === void 0 ? [] : match[4].split(".")
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
export { repoSlug as C, releasesApiUrl as S, matchAsset as _, compareTags as a, parseRepoSlug as b, describeReleaseFailure as c, fetchRelease as d, fetchReleases as f, isUiAsset as g, isOwnRepo as h, assetDownloadUrl as i, downloadToTemp as l, isGithubHost as m, MAX_DOWNLOAD_BYTES as n, defaultReleaseTag as o, formatBytes as p, apiHeaders as r, describeError as s, DEFAULT_REPO as t, fallbackUiName as u, noAssetsMessage as v, releaseApiUrl as x, parseFileSource as y };
|
|
311
|
+
|
|
312
|
+
//# sourceMappingURL=ui-release-DKzVvlLd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-release-DKzVvlLd.js","names":[],"sources":["../../src/providers/ui-release.ts"],"sourcesContent":["import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { errorMessage } from '#src/shared/error-message'\n/**\n * The GitHub-release side of installing a UI: which repo, which tag, which asset, how\n * to read the release metadata and how to download one. `ui-switch` picks a release by\n * hand and `ui-update` follows what an installed UI declared, but both go through this\n * one implementation — the failure messages and the asset matching are the same problem.\n */\n\nexport const DEFAULT_REPO = 'NamesMT/home-hosted'\n/** Mirrors the cap `UiService` enforces uncompressed — the same body, before it is parsed. */\nexport const MAX_DOWNLOAD_BYTES = 512 * 1024 * 1024\n\nexport interface RepoSlug {\n owner: string\n name: string\n}\n\nexport interface GithubAsset {\n name?: string\n url?: string\n browser_download_url?: string\n}\n\nexport interface GithubRelease {\n tag_name?: string\n name?: string\n draft?: boolean\n prerelease?: boolean\n published_at?: string\n assets?: GithubAsset[]\n}\n\n/** What both commands need from the CLI that owns the readline prompts and the colours. */\nexport interface UiSourceIo {\n write: (text: string) => void\n prompt?: (question: string) => Promise<string>\n style: {\n bold: (text: string) => string\n dim: (text: string) => string\n green: (text: string) => string\n }\n}\n\nexport interface UiSourceContext {\n io: UiSourceIo\n version: string\n token: string | null\n /** Suppress progress lines: the startup hook runs with nobody watching. */\n quiet?: boolean\n}\n\n/** `owner/name`, the only slug GitHub releases are addressed by. */\nexport function parseRepoSlug(value: string): RepoSlug | null {\n const match = /^([\\w.-]+)\\/([\\w.-]+)$/.exec(value.trim())\n if (match === null)\n return null\n return { owner: match[1]!, name: match[2]! }\n}\n\nexport function repoSlug(repo: RepoSlug): string {\n return `${repo.owner}/${repo.name}`\n}\n\n/** The repo the default tag rule is about; `DEFAULT_REPO` is its only definition. */\nexport function isOwnRepo(repo: RepoSlug): boolean {\n return repoSlug(repo).toLowerCase() === DEFAULT_REPO.toLowerCase()\n}\n\n/**\n * Our own release tag matches this CLI's version, so a UI is paired with the panel\n * it was built for. Another repo has no such pairing, so its latest release is used.\n * `null` means \"latest\".\n */\nexport function defaultReleaseTag(repo: RepoSlug, version: string): string | null {\n return isOwnRepo(repo) ? `v${version}` : null\n}\n\nexport function releaseApiUrl(repo: RepoSlug, tag: string | null): string {\n const base = `https://api.github.com/repos/${repo.owner}/${repo.name}/releases`\n if (tag === null || tag.length === 0 || tag === 'latest')\n return `${base}/latest`\n return `${base}/tags/${encodeURIComponent(tag)}`\n}\n\n/** Every published release, newest first, as GitHub orders them. */\nexport function releasesApiUrl(repo: RepoSlug, perPage = 30): string {\n return `https://api.github.com/repos/${repo.owner}/${repo.name}/releases?per_page=${perPage}`\n}\n\n/** Generous and predictable: a UI bundle is an asset whose name ends in `.zip`. */\nexport function isUiAsset(name: string): boolean {\n return /\\.zip$/i.test(name.trim())\n}\n\n/**\n * Resolves a wanted asset: an exact name, a case-insensitive name, or a single\n * unambiguous substring (`--asset stock` for `home-hosted-ui-stock.zip`).\n */\nexport function matchAsset(names: readonly string[], query: string): { ok: true, name: string } | { ok: false, error: string } {\n const wanted = query.trim()\n if (wanted.length === 0)\n return { ok: false, error: 'no asset name was given' }\n\n const exact = names.find(name => name === wanted)\n if (exact !== undefined)\n return { ok: true, name: exact }\n\n const lower = wanted.toLowerCase()\n const insensitive = names.filter(name => name.toLowerCase() === lower)\n if (insensitive.length === 1)\n return { ok: true, name: insensitive[0]! }\n\n const partial = names.filter(name => name.toLowerCase().includes(lower))\n if (partial.length === 0)\n return { ok: false, error: `no asset matches \"${wanted}\" (available: ${names.join(', ') || 'none'})` }\n if (partial.length > 1)\n return { ok: false, error: `\"${wanted}\" matches more than one asset: ${partial.join(', ')} — use the full name` }\n return { ok: true, name: partial[0]! }\n}\n\n/** `^https?://` means a URL; anything else is a filesystem path with `~` expanded. */\nexport function parseFileSource(value: string): { kind: 'url', url: string } | { kind: 'path', path: string } {\n const trimmed = value.trim()\n if (/^https?:\\/\\//i.test(trimmed))\n return { kind: 'url', url: trimmed }\n return { kind: 'path', path: expandHome(trimmed) }\n}\n\nfunction expandHome(value: string): string {\n if (value === '~')\n return os.homedir()\n if (value.startsWith('~/') || value.startsWith('~\\\\'))\n return path.join(os.homedir(), value.slice(2))\n return value\n}\n\n/**\n * A token is only ever sent to GitHub: `--file <url>` may point anywhere, and a\n * credential must not leak to a host the user did not vouch for.\n */\nexport function isGithubHost(url: string): boolean {\n try {\n const parsed = new URL(url)\n // A token is only ever sent over TLS, so a plain-http GitHub URL is not \"GitHub\" here.\n if (parsed.protocol !== 'https:')\n return false\n const host = parsed.hostname.toLowerCase()\n return host === 'github.com' || host.endsWith('.github.com')\n || host === 'githubusercontent.com' || host.endsWith('.githubusercontent.com')\n }\n catch {\n return false\n }\n}\n\n/**\n * A hung connection must not become a hung command. `fetch` has no default timeout, and\n * the startup hook is fire-and-forget: without this a stalled request would keep that\n * promise (and its temp directory) pending for as long as the process lives.\n */\nconst REQUEST_TIMEOUT_MS = 30_000\nconst DOWNLOAD_TIMEOUT_MS = 120_000\n\nfunction timeoutSignal(ms: number): AbortSignal | undefined {\n // `AbortSignal.timeout` exists from Node 17.3; the engines field requires 24.\n return typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function'\n ? AbortSignal.timeout(ms)\n : undefined\n}\n\nfunction isTimeout(error: unknown): boolean {\n return error instanceof Error && (error.name === 'TimeoutError' || error.name === 'AbortError')\n}\n\n/** What `UiService` names the install when the archive carries no `ui.json`. */\nexport function fallbackUiName(source: string): string {\n const base = path.basename(source).replace(/\\.zip$/i, '')\n const stripped = base.replace(/^home-hosted-ui-/i, '')\n return stripped.length > 0 ? stripped : 'custom-ui'\n}\n\n/** One release's assets, or a message that says what was wrong with the answer. */\nexport async function fetchRelease(repo: RepoSlug, tag: string | null, context: UiSourceContext): Promise<{ tag: string, assets: GithubAsset[] }> {\n const url = releaseApiUrl(repo, tag)\n let response: Response\n try {\n response = await fetch(url, { headers: apiHeaders(context), signal: timeoutSignal(REQUEST_TIMEOUT_MS) })\n }\n catch (error) {\n throw new Error(isTimeout(error) ? `GitHub did not answer within ${REQUEST_TIMEOUT_MS / 1000}s` : `could not reach GitHub: ${describeError(error)}`)\n }\n\n if (!response.ok)\n throw new Error(describeReleaseFailure(response.status, repo, tag))\n\n const body = await response.json() as GithubRelease\n return { tag: body.tag_name ?? tag ?? 'latest', assets: Array.isArray(body.assets) ? body.assets : [] }\n}\n\n/** Every published release, newest first. Drafts and unusable entries are dropped. */\nexport async function fetchReleases(repo: RepoSlug, context: UiSourceContext, perPage = 30): Promise<Array<{ tag: string, assets: GithubAsset[], publishedAt: string | null }>> {\n let response: Response\n try {\n response = await fetch(releasesApiUrl(repo, perPage), { headers: apiHeaders(context), signal: timeoutSignal(REQUEST_TIMEOUT_MS) })\n }\n catch (error) {\n throw new Error(isTimeout(error) ? `GitHub did not answer within ${REQUEST_TIMEOUT_MS / 1000}s` : `could not reach GitHub: ${describeError(error)}`)\n }\n\n if (!response.ok)\n throw new Error(describeReleaseFailure(response.status, repo, null))\n\n const body = await response.json()\n if (!Array.isArray(body))\n return []\n\n return (body as GithubRelease[])\n .filter(release => release.draft !== true && typeof release.tag_name === 'string')\n .map(release => ({\n tag: release.tag_name!,\n assets: Array.isArray(release.assets) ? release.assets : [],\n publishedAt: typeof release.published_at === 'string' ? release.published_at : null,\n }))\n}\n\nexport function assetDownloadUrl(asset: GithubAsset): string {\n const url = asset.url ?? asset.browser_download_url\n if (url === undefined || url.length === 0)\n throw new Error(`the release metadata for \"${asset.name ?? 'an asset'}\" carries no download URL`)\n return url\n}\n\n/** Streams to `os.tmpdir()` so a large body is never buffered in memory. */\nexport async function downloadToTemp(url: string, headers: Record<string, string>, context: UiSourceContext): Promise<{ dir: string, file: string }> {\n let response: Response\n try {\n response = await fetch(url, { headers, redirect: 'follow', signal: timeoutSignal(DOWNLOAD_TIMEOUT_MS) })\n }\n catch (error) {\n throw new Error(isTimeout(error) ? `the download stalled for ${DOWNLOAD_TIMEOUT_MS / 1000}s: ${url}` : `could not reach ${url}: ${describeError(error)}`)\n }\n\n if (!response.ok)\n throw new Error(describeDownloadFailure(response.status, url))\n\n const declared = Number(response.headers.get('content-length') ?? '0')\n if (!Number.isFinite(declared) || declared < 0)\n throw new Error(`the download from ${url} reported an unusable size`)\n if (declared > MAX_DOWNLOAD_BYTES)\n throw new Error(tooLargeMessage(declared))\n if (response.body === null)\n throw new Error(`the download from ${url} had no body`)\n\n const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'hh-ui-'))\n const file = path.join(dir, 'ui.zip')\n const handle = await fs.promises.open(file, 'w')\n let received = 0\n\n try {\n for await (const chunk of response.body) {\n received += chunk.length\n if (received > MAX_DOWNLOAD_BYTES)\n throw new Error(tooLargeMessage(received))\n await handle.write(chunk)\n }\n }\n catch (error) {\n await handle.close()\n fs.rmSync(dir, { recursive: true, force: true })\n throw error instanceof Error ? error : new Error(String(error))\n }\n await handle.close()\n\n if (context.quiet !== true)\n context.io.write(`${context.io.style.dim(`downloaded ${formatBytes(received)}`)}\\n`)\n return { dir, file }\n}\n\nexport function apiHeaders(context: UiSourceContext): Record<string, string> {\n const headers: Record<string, string> = {\n 'accept': 'application/vnd.github+json',\n 'user-agent': `home-hosted/${context.version}`,\n 'x-github-api-version': '2022-11-28',\n }\n if (context.token !== null && context.token.length > 0)\n headers.authorization = `Bearer ${context.token}`\n return headers\n}\n\nexport function noAssetsMessage(where: string, skipped: string[], tag: string | null): string {\n const lines = [`no usable UI assets in ${where} (expected a .zip)`]\n lines.push(skipped.length > 0 ? ` skipped: ${skipped.join(', ')}` : ' the release has no assets at all')\n if (tag !== null && tag !== 'latest')\n lines.push(' installing a different version silently is worse than failing: try the newest release with --tag latest')\n return lines.join('\\n')\n}\n\nexport function describeReleaseFailure(status: number, repo: RepoSlug, tag: string | null): string {\n const slug = repoSlug(repo)\n if (status === 404) {\n if (tag !== null && tag !== 'latest')\n return `no release tagged \"${tag}\" in ${slug}\\n list what exists with: home-hosted ui-switch --repo ${slug} --tag latest --list`\n return `no repository or published release at ${slug}\\n check the --repo slug (owner/name), and that the repository is public`\n }\n if (status === 403 || status === 429)\n return `GitHub refused the request (HTTP ${status}) — the unauthenticated API rate limit is per address.\\n set a token to raise it: --token <token>, or GITHUB_TOKEN / GH_TOKEN`\n if (status === 401)\n return 'GitHub rejected the token (HTTP 401) — check --token, GITHUB_TOKEN or GH_TOKEN'\n return `GitHub answered HTTP ${status} while reading the release of ${slug}`\n}\n\nfunction describeDownloadFailure(status: number, url: string): string {\n const github = isGithubHost(url)\n if (status === 404) {\n return github\n ? `the asset is gone (HTTP 404) — ${url}\\n the release may have been rebuilt since it was listed; run the command again`\n : `nothing is served at that URL (HTTP 404) — ${url}`\n }\n if (status === 403 || status === 429) {\n return github\n ? `GitHub refused the download (HTTP ${status}) — a token raises the rate limit: --token <token>, or GITHUB_TOKEN / GH_TOKEN`\n : `the host refused the download (HTTP ${status}) — ${url}`\n }\n if (status === 401 && github)\n return 'GitHub rejected the token on the download (HTTP 401) — check --token, GITHUB_TOKEN or GH_TOKEN'\n return `the download failed (HTTP ${status}) — ${url}`\n}\n\nfunction tooLargeMessage(bytes: number): string {\n return `the download is ${formatBytes(bytes)}, larger than the ${MAX_DOWNLOAD_BYTES / 1024 / 1024}MB a UI may be`\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes < 1024)\n return `${bytes} B`\n if (bytes < 1024 * 1024)\n return `${Math.round(bytes / 1024)} KB`\n return `${(bytes / 1024 / 1024).toFixed(1)} MB`\n}\n\nexport function describeError(error: unknown): string {\n return errorMessage(error)\n}\n\n/**\n * Tag ordering: `v1.2.3` beats `v1.2.2`, a prerelease loses to its release, and anything\n * that is not a version sorts below every version that is. Enough to answer \"is this\n * release newer than the one the UI came from\" without a semver dependency.\n */\nexport function compareTags(a: string, b: string): number {\n const left = parseTag(a)\n const right = parseTag(b)\n if (left === null && right === null)\n return a.localeCompare(b)\n if (left === null)\n return -1\n if (right === null)\n return 1\n\n for (let index = 0; index < 3; index++) {\n const difference = (left.parts[index] ?? 0) - (right.parts[index] ?? 0)\n if (difference !== 0)\n return difference\n }\n\n // A release outranks its own prereleases, and two prereleases are ordered by their\n // identifiers — `rc.2` after `rc.1`. Comparing only \"is it a prerelease\" made every\n // pair of them equal, so `ui-update` hid each one from the other.\n if (left.prerelease.length === 0 && right.prerelease.length === 0)\n return 0\n if (left.prerelease.length === 0)\n return 1\n if (right.prerelease.length === 0)\n return -1\n\n for (let index = 0; index < Math.max(left.prerelease.length, right.prerelease.length); index++) {\n const one = left.prerelease[index]\n const two = right.prerelease[index]\n if (one === undefined)\n return -1\n if (two === undefined)\n return 1\n if (one === two)\n continue\n const numeric = /^\\d+$/\n if (numeric.test(one) && numeric.test(two))\n return Number(one) - Number(two)\n // Numeric identifiers rank below alphanumeric ones, per semver.\n if (numeric.test(one))\n return -1\n if (numeric.test(two))\n return 1\n return one.localeCompare(two)\n }\n return 0\n}\n\nfunction parseTag(tag: string): { parts: number[], prerelease: string[] } | null {\n const match = /^v?(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:-([0-9A-Za-z.-]+))?(?:\\+.*)?$/.exec(tag.trim())\n if (match === null)\n return null\n return {\n parts: [Number(match[1]), Number(match[2] ?? 0), Number(match[3] ?? 0)],\n prerelease: match[4] === undefined ? [] : match[4].split('.'),\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,eAAe;;AAE5B,IAAa,qBAAqB;;AA0ClC,SAAgB,cAAc,OAAgC;CAC5D,MAAM,QAAQ,yBAAyB,KAAK,MAAM,KAAK,CAAC;CACxD,IAAI,UAAU,MACZ,OAAO;CACT,OAAO;EAAE,OAAO,MAAM;EAAK,MAAM,MAAM;CAAI;AAC7C;AAEA,SAAgB,SAAS,MAAwB;CAC/C,OAAO,GAAG,KAAK,MAAM,GAAG,KAAK;AAC/B;;AAGA,SAAgB,UAAU,MAAyB;CACjD,OAAO,SAAS,IAAI,CAAC,CAAC,YAAY,MAAM,aAAa,YAAY;AACnE;;;;;;AAOA,SAAgB,kBAAkB,MAAgB,SAAgC;CAChF,OAAO,UAAU,IAAI,IAAI,IAAI,YAAY;AAC3C;AAEA,SAAgB,cAAc,MAAgB,KAA4B;CACxE,MAAM,OAAO,gCAAgC,KAAK,MAAM,GAAG,KAAK,KAAK;CACrE,IAAI,QAAQ,QAAQ,IAAI,WAAW,KAAK,QAAQ,UAC9C,OAAO,GAAG,KAAK;CACjB,OAAO,GAAG,KAAK,QAAQ,mBAAmB,GAAG;AAC/C;;AAGA,SAAgB,eAAe,MAAgB,UAAU,IAAY;CACnE,OAAO,gCAAgC,KAAK,MAAM,GAAG,KAA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,SAAS,SAAS,KAA+D;CAC/E,MAAM,QAAQ,mEAAmE,KAAK,IAAI,KAAK,CAAC;CAChG,IAAI,UAAU,MACZ,OAAO;CACT,OAAO;EACL,OAAO;GAAC,OAAO,MAAM,EAAE;GAAG,OAAO,MAAM,MAAM,CAAC;GAAG,OAAO,MAAM,MAAM,CAAC;EAAC;EACtE,YAAY,MAAM,OAAO,KAAA,IAAY,CAAC,IAAI,MAAM,EAAE,CAAC,MAAM,GAAG;CAC9D;AACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { m as green } from "../cli.js";
|
|
2
|
+
import { c as hhDir } from "./paths-CGlGDrOU.js";
|
|
3
|
+
import { UiService } from "./ui-D562aqw5.js";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { defineCommand } from "citty";
|
|
6
|
+
//#region src/cli/ui-revert.ts
|
|
7
|
+
/** `ui-revert` drops a user-installed UI so the stock panel serves again. */
|
|
8
|
+
async function runUiRevert() {
|
|
9
|
+
const ui = new UiService({ dataRoot: hhDir });
|
|
10
|
+
if (!ui.custom) {
|
|
11
|
+
process.stdout.write("no custom UI is installed — the stock panel is already in use\n");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
ui.revert();
|
|
15
|
+
process.stdout.write(`${green("custom UI removed")} — the stock panel is back; refresh the browser\n`);
|
|
16
|
+
}
|
|
17
|
+
var uiRevertCommand = defineCommand({
|
|
18
|
+
meta: { name: "ui-revert" },
|
|
19
|
+
args: {},
|
|
20
|
+
run: async () => {
|
|
21
|
+
await runUiRevert();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { uiRevertCommand };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=ui-revert-EkBBwRTt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-revert-EkBBwRTt.js","names":[],"sources":["../../src/cli/ui-revert.ts"],"sourcesContent":["import process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { green } from '#src/cli/io'\nimport { hhDir as dataRoot } from '#src/helpers/paths'\nimport { UiService } from '#src/services/ui'\n\n/** `ui-revert` drops a user-installed UI so the stock panel serves again. */\n\nexport async function runUiRevert(): Promise<void> {\n const ui = new UiService({ dataRoot })\n\n if (!ui.custom) {\n process.stdout.write('no custom UI is installed — the stock panel is already in use\\n')\n return\n }\n ui.revert()\n process.stdout.write(`${green('custom UI removed')} — the stock panel is back; refresh the browser\\n`)\n}\n\nexport const uiRevertCommand = defineCommand({\n meta: { name: 'ui-revert' },\n // Declared **empty** on purpose. `rejectUnknownFlags` refuses every flag and bare word for a\n // command whose definition is empty, and that is the whole point here: this command used to\n // declare nothing at all, which reads as \"parses my own argv\" — and it parses nothing. So\n // `ui-revert --dry-run` printed \"custom UI removed\" and deleted the installed UI, exiting 0,\n // because nothing ever looked at the flag. A command that takes no options now says so.\n args: {},\n run: async () => {\n await runUiRevert()\n },\n})\n"],"mappings":";;;;;;;AAQA,eAAsB,cAA6B;CACjD,MAAM,KAAK,IAAI,UAAU,EAAE,UAAA,MAAS,CAAC;CAErC,IAAI,CAAC,GAAG,QAAQ;EACd,QAAQ,OAAO,MAAM,iEAAiE;EACtF;CACF;CACA,GAAG,OAAO;CACV,QAAQ,OAAO,MAAM,GAAG,MAAM,mBAAmB,EAAE,kDAAkD;AACvG;AAEA,IAAa,kBAAkB,cAAc;CAC3C,MAAM,EAAE,MAAM,YAAY;CAM1B,MAAM,CAAC;CACP,KAAK,YAAY;EACf,MAAM,YAAY;CACpB;AACF,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { _ as prompt, b as style } from "../cli.js";
|
|
2
|
+
import { _ as matchAsset, b as parseRepoSlug, d as fetchRelease, g as isUiAsset, i as assetDownloadUrl, l as downloadToTemp, m as isGithubHost, o as defaultReleaseTag, t as DEFAULT_REPO, u as fallbackUiName, v as noAssetsMessage, y as parseFileSource } from "./ui-release-DKzVvlLd.js";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
//#region src/cli/ui-switch.ts
|
|
8
|
+
async function uiSwitch(argv, io) {
|
|
9
|
+
const { values } = parseArgs({
|
|
10
|
+
args: argv,
|
|
11
|
+
options: {
|
|
12
|
+
repo: { type: "string" },
|
|
13
|
+
tag: { type: "string" },
|
|
14
|
+
asset: { type: "string" },
|
|
15
|
+
file: { type: "string" },
|
|
16
|
+
list: { type: "boolean" },
|
|
17
|
+
token: { type: "string" },
|
|
18
|
+
yes: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
short: "y"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
allowPositionals: false
|
|
24
|
+
});
|
|
25
|
+
const { appVersion } = await import("../cli.js").then((n) => n.i);
|
|
26
|
+
const context = {
|
|
27
|
+
io,
|
|
28
|
+
version: appVersion(),
|
|
29
|
+
token: values.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN ?? null
|
|
30
|
+
};
|
|
31
|
+
if (values.file !== void 0) {
|
|
32
|
+
if (values.repo !== void 0 || values.tag !== void 0 || values.asset !== void 0 || values.list === true) throw new Error("--file installs a zip directly; it cannot be combined with --repo, --tag, --asset or --list");
|
|
33
|
+
await installFromFile(values.file, context);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const repo = parseRepoSlug(values.repo ?? "NamesMT/home-hosted");
|
|
37
|
+
if (repo === null) throw new Error(`invalid --repo "${values.repo}" — expected an "owner/name" slug, e.g. ${DEFAULT_REPO}`);
|
|
38
|
+
const requestedTag = values.tag ?? defaultReleaseTag(repo, context.version);
|
|
39
|
+
const release = await fetchRelease(repo, requestedTag, context);
|
|
40
|
+
const skipped = release.assets.filter((asset) => !isUiAsset(asset.name ?? "")).map((asset) => asset.name ?? "?");
|
|
41
|
+
const usable = release.assets.filter((asset) => isUiAsset(asset.name ?? ""));
|
|
42
|
+
const where = `${repo.owner}/${repo.name}@${release.tag}`;
|
|
43
|
+
if (values.list === true) {
|
|
44
|
+
if (usable.length === 0) throw new Error(noAssetsMessage(where, skipped, requestedTag));
|
|
45
|
+
const lines = [`${io.style.bold(where)} — ${usable.length} usable UI asset(s)`];
|
|
46
|
+
for (const asset of usable) lines.push(` ${asset.name}`);
|
|
47
|
+
if (skipped.length > 0) lines.push(io.style.dim(` skipped (not a .zip): ${skipped.join(", ")}`));
|
|
48
|
+
io.write(`${lines.join("\n")}\n`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (usable.length === 0) throw new Error(noAssetsMessage(where, skipped, requestedTag));
|
|
52
|
+
const chosen = await chooseAsset(usable, values, context);
|
|
53
|
+
if (chosen === null) {
|
|
54
|
+
io.write("cancelled — nothing was installed\n");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
await installFromUrl(assetDownloadUrl(chosen), fallbackUiName(chosen.name ?? ""), context, release.tag);
|
|
58
|
+
}
|
|
59
|
+
async function chooseAsset(assets, values, context) {
|
|
60
|
+
const { io } = context;
|
|
61
|
+
if (values.asset !== void 0) {
|
|
62
|
+
const matched = matchAsset(assets.map((asset) => asset.name ?? ""), values.asset);
|
|
63
|
+
if (!matched.ok) throw new Error(matched.error);
|
|
64
|
+
return assets.find((asset) => asset.name === matched.name);
|
|
65
|
+
}
|
|
66
|
+
if (!(process.stdin.isTTY === true && values.yes !== true)) {
|
|
67
|
+
if (assets.length === 1) return assets[0];
|
|
68
|
+
throw new Error([
|
|
69
|
+
`${assets.length} UI assets are available and this session cannot ask which one:`,
|
|
70
|
+
...assets.map((asset) => ` ${asset.name}`),
|
|
71
|
+
" pick one with --asset <name>, or list them with --list"
|
|
72
|
+
].join("\n"));
|
|
73
|
+
}
|
|
74
|
+
io.write(`${[io.style.bold("Available UI assets"), ...assets.map((asset, index) => ` ${index + 1}) ${asset.name}`)].join("\n")}\n`);
|
|
75
|
+
for (;;) {
|
|
76
|
+
const answer = (await io.prompt(`Select an asset [1-${assets.length}] (empty to cancel) `)).trim();
|
|
77
|
+
if (answer.length === 0) return null;
|
|
78
|
+
if (/^\d+$/.test(answer)) {
|
|
79
|
+
const index = Number.parseInt(answer, 10);
|
|
80
|
+
if (index >= 1 && index <= assets.length) return assets[index - 1];
|
|
81
|
+
}
|
|
82
|
+
const matched = matchAsset(assets.map((asset) => asset.name ?? ""), answer);
|
|
83
|
+
if (matched.ok) return assets.find((asset) => asset.name === matched.name);
|
|
84
|
+
io.write(` ${io.style.dim(matched.error)}\n`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function installFromFile(value, context) {
|
|
88
|
+
const source = parseFileSource(value);
|
|
89
|
+
if (source.kind === "path") {
|
|
90
|
+
if (!fs.existsSync(source.path)) throw new Error(`no file at ${source.path}`);
|
|
91
|
+
if (!fs.statSync(source.path).isFile()) throw new Error(`${source.path} is not a file`);
|
|
92
|
+
await installArchive(source.path, fallbackUiName(source.path), context);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
await installFromUrl(source.url, fallbackUiName(new URL(source.url).pathname), context);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* `installedTag` is the release the asset came from, never the one inside the archive:
|
|
99
|
+
* a UI zip is built before its release is cut, so it carries the previous tag at best,
|
|
100
|
+
* and recording that makes the panel re-install the same UI on every boot. A local file
|
|
101
|
+
* or a bare URL names no release, so it has none to record.
|
|
102
|
+
*/
|
|
103
|
+
async function installFromUrl(url, fallbackName, context, installedTag) {
|
|
104
|
+
const headers = {
|
|
105
|
+
"accept": "application/octet-stream",
|
|
106
|
+
"user-agent": `home-hosted/${context.version}`
|
|
107
|
+
};
|
|
108
|
+
if (context.token !== null && context.token.length > 0 && isGithubHost(url)) headers.authorization = `Bearer ${context.token}`;
|
|
109
|
+
const download = await downloadToTemp(url, headers, context);
|
|
110
|
+
try {
|
|
111
|
+
await installArchive(download.file, fallbackName, context, installedTag);
|
|
112
|
+
} finally {
|
|
113
|
+
fs.rmSync(download.dir, {
|
|
114
|
+
recursive: true,
|
|
115
|
+
force: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function installArchive(archivePath, fallbackName, context, installedTag) {
|
|
120
|
+
const { UiService } = await import("./ui-D562aqw5.js");
|
|
121
|
+
const { hhDir: dataRoot } = await import("./paths-CGlGDrOU.js").then((n) => n.d);
|
|
122
|
+
const ui = new UiService({ dataRoot });
|
|
123
|
+
const result = await ui.install(archivePath, fallbackName, installedTag);
|
|
124
|
+
if (!result.ok) throw new Error(`nothing was installed: ${result.error}`);
|
|
125
|
+
const { meta } = result;
|
|
126
|
+
const label = meta.version === null ? meta.name : `${meta.name} ${meta.version}`;
|
|
127
|
+
context.io.write(`${context.io.style.green("UI installed")} — ${label}\n`);
|
|
128
|
+
context.io.write(` ${context.io.style.dim("state")} ${ui.directory}\n`);
|
|
129
|
+
context.io.write(` ${context.io.style.dim("files")} ${meta.files}\n`);
|
|
130
|
+
context.io.write(`refresh the browser to see it\n`);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The citty entry. `ui-switch` keeps parsing its own flags (and its own error
|
|
134
|
+
* messages) inside `uiSwitch`; citty dispatches with the argv it was handed, so
|
|
135
|
+
* the invocation changes and the helpers do not.
|
|
136
|
+
*/
|
|
137
|
+
var uiSwitchCommand = defineCommand({
|
|
138
|
+
meta: { name: "ui-switch" },
|
|
139
|
+
run: async ({ rawArgs }) => {
|
|
140
|
+
await uiSwitch(rawArgs, {
|
|
141
|
+
write: (text) => process.stdout.write(text),
|
|
142
|
+
prompt,
|
|
143
|
+
style
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
//#endregion
|
|
148
|
+
export { uiSwitchCommand };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=ui-switch-BnZTdMDd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-switch-BnZTdMDd.js","names":[],"sources":["../../src/cli/ui-switch.ts"],"sourcesContent":["import type { GithubAsset } from '#src/providers/ui-release'\nimport fs from 'node:fs'\nimport process from 'node:process'\nimport { parseArgs } from 'node:util'\nimport { defineCommand } from 'citty'\nimport { prompt, style } from '#src/cli/io'\nimport {\n assetDownloadUrl,\n DEFAULT_REPO,\n defaultReleaseTag,\n downloadToTemp,\n fallbackUiName,\n fetchRelease,\n isGithubHost,\n isUiAsset,\n matchAsset,\n noAssetsMessage,\n parseFileSource,\n parseRepoSlug,\n} from '#src/providers/ui-release'\n\n/**\n * `home-hosted ui-switch` installs the panel's frontend UI without the settings\n * page: a GitHub release asset (the default), a local zip, or an http(s) URL.\n *\n * This module is only ever imported dynamically, after `--home` has been applied,\n * so the modules that read the state directories are imported inside the command\n * rather than at the top. The release-side helpers it shares with `ui-update` are\n * in `#src/providers/ui-release`, and re-exported here so existing importers keep working.\n */\n\nexport * from '#src/providers/ui-release'\n\n/** What the command needs from the CLI that owns the readline prompts and the colours. */\nexport interface UiSwitchIo {\n write: (text: string) => void\n prompt: (question: string) => Promise<string>\n style: {\n bold: (text: string) => string\n dim: (text: string) => string\n green: (text: string) => string\n }\n}\n\ninterface SwitchContext {\n io: UiSwitchIo\n version: string\n token: string | null\n}\n\nexport async function uiSwitch(argv: string[], io: UiSwitchIo): Promise<void> {\n const { values } = parseArgs({\n args: argv,\n options: {\n repo: { type: 'string' },\n tag: { type: 'string' },\n asset: { type: 'string' },\n file: { type: 'string' },\n list: { type: 'boolean' },\n token: { type: 'string' },\n yes: { type: 'boolean', short: 'y' },\n },\n allowPositionals: false,\n })\n\n const { appVersion } = await import('#src/helpers/version')\n const context: SwitchContext = {\n io,\n version: appVersion(),\n token: values.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN ?? null,\n }\n\n if (values.file !== undefined) {\n if (values.repo !== undefined || values.tag !== undefined || values.asset !== undefined || values.list === true)\n throw new Error('--file installs a zip directly; it cannot be combined with --repo, --tag, --asset or --list')\n await installFromFile(values.file, context)\n return\n }\n\n const repo = parseRepoSlug(values.repo ?? DEFAULT_REPO)\n if (repo === null)\n throw new Error(`invalid --repo \"${values.repo}\" — expected an \"owner/name\" slug, e.g. ${DEFAULT_REPO}`)\n\n const requestedTag = values.tag ?? defaultReleaseTag(repo, context.version)\n const release = await fetchRelease(repo, requestedTag, context)\n const skipped = release.assets.filter(asset => !isUiAsset(asset.name ?? '')).map(asset => asset.name ?? '?')\n const usable = release.assets.filter(asset => isUiAsset(asset.name ?? ''))\n const where = `${repo.owner}/${repo.name}@${release.tag}`\n\n if (values.list === true) {\n if (usable.length === 0)\n throw new Error(noAssetsMessage(where, skipped, requestedTag))\n // One write, so `ui-switch --list | head` does not die on a broken pipe.\n const lines = [`${io.style.bold(where)} — ${usable.length} usable UI asset(s)`]\n for (const asset of usable)\n lines.push(` ${asset.name}`)\n if (skipped.length > 0)\n lines.push(io.style.dim(` skipped (not a .zip): ${skipped.join(', ')}`))\n io.write(`${lines.join('\\n')}\\n`)\n return\n }\n\n if (usable.length === 0)\n throw new Error(noAssetsMessage(where, skipped, requestedTag))\n\n const chosen = await chooseAsset(usable, values, context)\n if (chosen === null) {\n io.write('cancelled — nothing was installed\\n')\n return\n }\n\n await installFromUrl(assetDownloadUrl(chosen), fallbackUiName(chosen.name ?? ''), context, release.tag)\n}\n\nasync function chooseAsset(assets: GithubAsset[], values: { asset?: string, yes?: boolean }, context: SwitchContext): Promise<GithubAsset | null> {\n const { io } = context\n\n if (values.asset !== undefined) {\n const matched = matchAsset(assets.map(asset => asset.name ?? ''), values.asset)\n if (!matched.ok)\n throw new Error(matched.error)\n return assets.find(asset => asset.name === matched.name)!\n }\n\n const interactive = process.stdin.isTTY === true && values.yes !== true\n if (!interactive) {\n if (assets.length === 1)\n return assets[0]!\n throw new Error([\n `${assets.length} UI assets are available and this session cannot ask which one:`,\n ...assets.map(asset => ` ${asset.name}`),\n ' pick one with --asset <name>, or list them with --list',\n ].join('\\n'))\n }\n\n // One write, so the listing is complete before the prompt (and a piped stdout\n // cannot interleave with it).\n io.write(`${[io.style.bold('Available UI assets'), ...assets.map((asset, index) => ` ${index + 1}) ${asset.name}`)].join('\\n')}\\n`)\n\n for (;;) {\n const answer = (await io.prompt(`Select an asset [1-${assets.length}] (empty to cancel) `)).trim()\n if (answer.length === 0)\n return null\n\n if (/^\\d+$/.test(answer)) {\n const index = Number.parseInt(answer, 10)\n if (index >= 1 && index <= assets.length)\n return assets[index - 1]!\n }\n\n const matched = matchAsset(assets.map(asset => asset.name ?? ''), answer)\n if (matched.ok)\n return assets.find(asset => asset.name === matched.name)!\n io.write(` ${io.style.dim(matched.error)}\\n`)\n }\n}\n\nasync function installFromFile(value: string, context: SwitchContext): Promise<void> {\n const source = parseFileSource(value)\n if (source.kind === 'path') {\n if (!fs.existsSync(source.path))\n throw new Error(`no file at ${source.path}`)\n if (!fs.statSync(source.path).isFile())\n throw new Error(`${source.path} is not a file`)\n await installArchive(source.path, fallbackUiName(source.path), context)\n return\n }\n await installFromUrl(source.url, fallbackUiName(new URL(source.url).pathname), context)\n}\n\n/**\n * `installedTag` is the release the asset came from, never the one inside the archive:\n * a UI zip is built before its release is cut, so it carries the previous tag at best,\n * and recording that makes the panel re-install the same UI on every boot. A local file\n * or a bare URL names no release, so it has none to record.\n */\nasync function installFromUrl(url: string, fallbackName: string, context: SwitchContext, installedTag?: string): Promise<void> {\n const headers: Record<string, string> = {\n 'accept': 'application/octet-stream',\n 'user-agent': `home-hosted/${context.version}`,\n }\n if (context.token !== null && context.token.length > 0 && isGithubHost(url))\n headers.authorization = `Bearer ${context.token}`\n\n const download = await downloadToTemp(url, headers, context)\n try {\n await installArchive(download.file, fallbackName, context, installedTag)\n }\n finally {\n fs.rmSync(download.dir, { recursive: true, force: true })\n }\n}\n\nasync function installArchive(archivePath: string, fallbackName: string, context: SwitchContext, installedTag?: string): Promise<void> {\n const { UiService } = await import('#src/services/ui')\n const { hhDir: dataRoot } = await import('#src/helpers/paths')\n const ui = new UiService({ dataRoot })\n const result = await ui.install(archivePath, fallbackName, installedTag)\n\n if (!result.ok)\n throw new Error(`nothing was installed: ${result.error}`)\n\n const { meta } = result\n const label = meta.version === null ? meta.name : `${meta.name} ${meta.version}`\n context.io.write(`${context.io.style.green('UI installed')} — ${label}\\n`)\n context.io.write(` ${context.io.style.dim('state')} ${ui.directory}\\n`)\n context.io.write(` ${context.io.style.dim('files')} ${meta.files}\\n`)\n context.io.write(`refresh the browser to see it\\n`)\n}\n\n/**\n * The citty entry. `ui-switch` keeps parsing its own flags (and its own error\n * messages) inside `uiSwitch`; citty dispatches with the argv it was handed, so\n * the invocation changes and the helpers do not.\n */\nexport const uiSwitchCommand = defineCommand({\n meta: { name: 'ui-switch' },\n run: async ({ rawArgs }) => {\n await uiSwitch(rawArgs, {\n write: text => process.stdout.write(text),\n prompt,\n style,\n })\n },\n})\n"],"mappings":";;;;;;;AAkDA,eAAsB,SAAS,MAAgB,IAA+B;CAC5E,MAAM,EAAE,WAAW,UAAU;EAC3B,MAAM;EACN,SAAS;GACP,MAAM,EAAE,MAAM,SAAS;GACvB,KAAK,EAAE,MAAM,SAAS;GACtB,OAAO,EAAE,MAAM,SAAS;GACxB,MAAM,EAAE,MAAM,SAAS;GACvB,MAAM,EAAE,MAAM,UAAU;GACxB,OAAO,EAAE,MAAM,SAAS;GACxB,KAAK;IAAE,MAAM;IAAW,OAAO;GAAI;EACrC;EACA,kBAAkB;CACpB,CAAC;CAED,MAAM,EAAE,eAAe,MAAM,OAAO,YAAA,CAAA,MAAA,MAAA,EAAA,CAAA;CACpC,MAAM,UAAyB;EAC7B;EACA,SAAS,WAAW;EACpB,OAAO,OAAO,SAAS,QAAQ,IAAI,gBAAgB,QAAQ,IAAI,YAAY;CAC7E;CAEA,IAAI,OAAO,SAAS,KAAA,GAAW;EAC7B,IAAI,OAAO,SAAS,KAAA,KAAa,OAAO,QAAQ,KAAA,KAAa,OAAO,UAAU,KAAA,KAAa,OAAO,SAAS,MACzG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