home-hosted 0.13.0 → 0.20.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 +117 -322
- package/bin/home-hosted.mjs +41 -0
- package/dist/chunks/account-DiLrSyww.js +359 -0
- package/dist/chunks/account-DiLrSyww.js.map +1 -0
- package/dist/chunks/add-DEIYVkNK.js +183 -0
- package/dist/chunks/add-DEIYVkNK.js.map +1 -0
- package/dist/chunks/{archive-DP-XQR8X.js → archive-DFi3qK1c.js} +25 -73
- package/dist/chunks/archive-DFi3qK1c.js.map +1 -0
- package/dist/chunks/{atomic-C1PfJpE7.js → atomic-SZUwDtGD.js} +3 -6
- package/dist/chunks/atomic-SZUwDtGD.js.map +1 -0
- package/dist/chunks/{backup-CZcVca2a.js → backup-DnyxIzw0.js} +110 -190
- package/dist/chunks/backup-DnyxIzw0.js.map +1 -0
- package/dist/chunks/backups-BrrN6cwW.js +2203 -0
- package/dist/chunks/backups-BrrN6cwW.js.map +1 -0
- package/dist/chunks/bind-DIxrnUst.js +43 -0
- package/dist/chunks/bind-DIxrnUst.js.map +1 -0
- package/dist/chunks/config-text-DxMOQQnk.js +34 -0
- package/dist/chunks/config-text-DxMOQQnk.js.map +1 -0
- package/dist/chunks/{contracts-CMBD1TF9.js → contracts-CxZ7u1L3.js} +1239 -1454
- package/dist/chunks/contracts-CxZ7u1L3.js.map +1 -0
- package/dist/chunks/daemon-BAAYUYQC.js +211 -0
- package/dist/chunks/daemon-BAAYUYQC.js.map +1 -0
- package/dist/chunks/daemon-log-Ccu-69vB.js +179 -0
- package/dist/chunks/daemon-log-Ccu-69vB.js.map +1 -0
- package/dist/chunks/deploy-CggSOEkq.js +144 -0
- package/dist/chunks/deploy-CggSOEkq.js.map +1 -0
- package/dist/chunks/{docker-Cy9Lyvda.js → docker--Un0uLfF.js} +32 -68
- package/dist/chunks/docker--Un0uLfF.js.map +1 -0
- package/dist/chunks/{down-pKbGCW9d.js → down-CpIN7LEQ.js} +34 -94
- package/dist/chunks/down-CpIN7LEQ.js.map +1 -0
- package/dist/chunks/exposure-CDJNvOCK.js +229 -0
- package/dist/chunks/exposure-CDJNvOCK.js.map +1 -0
- package/dist/chunks/import-Bd4VZH0f.js +205 -0
- package/dist/chunks/import-Bd4VZH0f.js.map +1 -0
- package/dist/chunks/import-plan--fDS_l5r.js +147 -0
- package/dist/chunks/import-plan--fDS_l5r.js.map +1 -0
- package/dist/chunks/import-write-BTfbeV26.js +42 -0
- package/dist/chunks/import-write-BTfbeV26.js.map +1 -0
- package/dist/chunks/{init-BZ7hK9Vf.js → init-Bv3oH65x.js} +14 -50
- package/dist/chunks/init-Bv3oH65x.js.map +1 -0
- package/dist/chunks/job-CYOdN6Ub.js +341 -0
- package/dist/chunks/job-CYOdN6Ub.js.map +1 -0
- package/dist/chunks/jobs-BX4ahcfh.js +489 -0
- package/dist/chunks/jobs-BX4ahcfh.js.map +1 -0
- package/dist/chunks/last-stop-DD3lHwo_.js +42 -0
- package/dist/chunks/last-stop-DD3lHwo_.js.map +1 -0
- package/dist/chunks/layout-D0ysDNav.js +18 -0
- package/dist/chunks/layout-D0ysDNav.js.map +1 -0
- package/dist/chunks/lazy-kfcBNeqj.js +48 -0
- package/dist/chunks/lazy-kfcBNeqj.js.map +1 -0
- package/dist/chunks/log-buffer-B7jmn7ts.js +110 -0
- package/dist/chunks/log-buffer-B7jmn7ts.js.map +1 -0
- package/dist/chunks/log-files-CZL2UhuE.js +488 -0
- package/dist/chunks/log-files-CZL2UhuE.js.map +1 -0
- package/dist/chunks/{logger-B5U4GD3j.js → logger-BnrKTBHQ.js} +2 -6
- package/dist/chunks/logger-BnrKTBHQ.js.map +1 -0
- package/dist/chunks/{logs---TI_bxM.js → logs-DxKI6OW2.js} +23 -73
- package/dist/chunks/logs-DxKI6OW2.js.map +1 -0
- package/dist/chunks/ls-BseUHy_m.js +128 -0
- package/dist/chunks/ls-BseUHy_m.js.map +1 -0
- package/dist/chunks/migrate-D4w_dXDm.js +268 -0
- package/dist/chunks/migrate-D4w_dXDm.js.map +1 -0
- package/dist/chunks/{nanny-B-Eu0sFW.js → nanny-BWh7nuvv.js} +21 -14
- package/dist/chunks/nanny-BWh7nuvv.js.map +1 -0
- package/dist/chunks/{nanny-ChMtq1Zl.js → nanny-BjF2-1pv.js} +3 -3
- package/dist/chunks/{nanny-ChMtq1Zl.js.map → nanny-BjF2-1pv.js.map} +1 -1
- package/dist/chunks/nanny-DGTXVq5d.js +806 -0
- package/dist/chunks/nanny-DGTXVq5d.js.map +1 -0
- package/dist/chunks/{nanny-sweep-DErnlPY1.js → nanny-sweep-hjmZ_p7S.js} +14 -24
- package/dist/chunks/nanny-sweep-hjmZ_p7S.js.map +1 -0
- package/dist/chunks/{nearest-6KgQEDUe.js → nearest-DOx4jySJ.js} +2 -10
- package/dist/chunks/nearest-DOx4jySJ.js.map +1 -0
- package/dist/chunks/{parse-DhmG26fI.js → parse-DVMPLUDe.js} +47 -72
- package/dist/chunks/parse-DVMPLUDe.js.map +1 -0
- package/dist/chunks/password-policy-Clq6PGE-.js +9 -0
- package/dist/chunks/password-policy-Clq6PGE-.js.map +1 -0
- package/dist/chunks/{paths-CGlGDrOU.js → paths-C34-TJLh.js} +32 -56
- package/dist/chunks/paths-C34-TJLh.js.map +1 -0
- package/dist/chunks/{port-B8WBTRMk.js → port-CnsrxKNR.js} +27 -71
- package/dist/chunks/port-CnsrxKNR.js.map +1 -0
- package/dist/chunks/process-CboOFPU_.js +192 -0
- package/dist/chunks/process-CboOFPU_.js.map +1 -0
- package/dist/chunks/{restart-Des4DrAN.js → restart-C0J8dZ2L.js} +11 -29
- package/dist/chunks/restart-C0J8dZ2L.js.map +1 -0
- package/dist/chunks/run-deploy-DoNDvwT4.js +91 -0
- package/dist/chunks/run-deploy-DoNDvwT4.js.map +1 -0
- package/dist/chunks/{schema-B240VXcV.js → schema-CZ6f-PHD.js} +7 -20
- package/dist/chunks/schema-CZ6f-PHD.js.map +1 -0
- package/dist/chunks/secret-MY397r90.js +219 -0
- package/dist/chunks/secret-MY397r90.js.map +1 -0
- package/dist/chunks/secrets-CG5N4lwY.js +1061 -0
- package/dist/chunks/secrets-CG5N4lwY.js.map +1 -0
- package/dist/chunks/server-Dm_dXfTW.js +255 -0
- package/dist/chunks/server-Dm_dXfTW.js.map +1 -0
- package/dist/chunks/server-attention-UQwYXqKe.js +10 -0
- package/dist/chunks/server-attention-UQwYXqKe.js.map +1 -0
- package/dist/chunks/server-create-D7nvhgBd.js +96 -0
- package/dist/chunks/server-create-D7nvhgBd.js.map +1 -0
- package/dist/chunks/server-ids-BEQD2rFz.js +23 -0
- package/dist/chunks/server-ids-BEQD2rFz.js.map +1 -0
- package/dist/chunks/server-vars-DMYmHutL.js +27 -0
- package/dist/chunks/server-vars-DMYmHutL.js.map +1 -0
- package/dist/chunks/service-C8l-ewNA.js +585 -0
- package/dist/chunks/service-C8l-ewNA.js.map +1 -0
- package/dist/chunks/{settings-xu-XTfWg.js → settings-CtYDs5PX.js} +62 -78
- package/dist/chunks/settings-CtYDs5PX.js.map +1 -0
- package/dist/chunks/{setup-temp-CAN4_bA-.js → setup-temp-TAtDmMMU.js} +43 -37
- package/dist/chunks/setup-temp-TAtDmMMU.js.map +1 -0
- package/dist/chunks/shape-CDGeYl_J.js +9 -0
- package/dist/chunks/shape-CDGeYl_J.js.map +1 -0
- package/dist/chunks/{src-BtWMFmzZ.js → src-BnzkVy_M.js} +12548 -10576
- package/dist/chunks/src-BnzkVy_M.js.map +1 -0
- package/dist/chunks/{status-DT1EsA-B.js → status-efbbfYZQ.js} +53 -26
- package/dist/chunks/status-efbbfYZQ.js.map +1 -0
- package/dist/chunks/store-Bs_Lljjm.js +2082 -0
- package/dist/chunks/store-Bs_Lljjm.js.map +1 -0
- package/dist/chunks/template-xan58bJh.js +28 -0
- package/dist/chunks/template-xan58bJh.js.map +1 -0
- package/dist/chunks/token-DDeWfZA4.js +142 -0
- package/dist/chunks/token-DDeWfZA4.js.map +1 -0
- package/dist/chunks/{ui-D562aqw5.js → ui-BcIAtyxE.js} +68 -79
- package/dist/chunks/ui-BcIAtyxE.js.map +1 -0
- package/dist/chunks/{ui-dir-CsU3uLNV.js → ui-dir-ClCzVRc3.js} +3 -7
- package/dist/chunks/ui-dir-ClCzVRc3.js.map +1 -0
- package/dist/chunks/ui-format-CDvvqOoi.js +53 -0
- package/dist/chunks/ui-format-CDvvqOoi.js.map +1 -0
- package/dist/chunks/{ui-release-DKzVvlLd.js → ui-release-XbJ85pYI.js} +36 -38
- package/dist/chunks/ui-release-XbJ85pYI.js.map +1 -0
- package/dist/chunks/{ui-revert-EkBBwRTt.js → ui-revert-Dgawq7ze.js} +4 -4
- package/dist/chunks/ui-revert-Dgawq7ze.js.map +1 -0
- package/dist/chunks/{ui-switch-BnZTdMDd.js → ui-switch-CfQMbZ0g.js} +31 -38
- package/dist/chunks/ui-switch-CfQMbZ0g.js.map +1 -0
- package/dist/chunks/{ui-update-_xryLYxw.js → ui-update-B3PPivUm.js} +30 -48
- package/dist/chunks/ui-update-B3PPivUm.js.map +1 -0
- package/dist/chunks/ui-update-CAiH2tFb.js +109 -0
- package/dist/chunks/ui-update-CAiH2tFb.js.map +1 -0
- package/dist/chunks/{up-Pdz-l6IH.js → up-BQSnYxYd.js} +47 -53
- package/dist/chunks/up-BQSnYxYd.js.map +1 -0
- package/dist/chunks/{usage-DFrCVXpT.js → usage-KG8TeOio.js} +7 -20
- package/dist/chunks/usage-KG8TeOio.js.map +1 -0
- package/dist/chunks/{workspaces-DYcfvKV_.js → workspaces-D9akpzU8.js} +80 -68
- package/dist/chunks/workspaces-D9akpzU8.js.map +1 -0
- package/dist/chunks/{wsl-temperature-BiCI4iK6.js → wsl-temperature-D-_d4Yk1.js} +47 -42
- package/dist/chunks/wsl-temperature-D-_d4Yk1.js.map +1 -0
- package/dist/cli.js +306 -238
- package/dist/cli.js.map +1 -1
- package/dist/client.js +76 -29
- package/dist/client.js.map +1 -1
- package/dist/types/api/acme.d.ts +3 -7
- package/dist/types/api/auth/$.routes.d.ts +107 -16
- package/dist/types/api/backups.d.ts +5 -5
- package/dist/types/api/control.d.ts +747 -38
- package/dist/types/api/ddns.d.ts +13 -18
- package/dist/types/api/events.d.ts +9 -3
- package/dist/types/api/health.d.ts +2 -4
- package/dist/types/api/jobs.d.ts +438 -0
- package/dist/types/api/logs.d.ts +20 -0
- package/dist/types/api/metrics.d.ts +2 -5
- package/dist/types/api/notifications.d.ts +3 -6
- package/dist/types/api/proxy.d.ts +63 -23
- package/dist/types/api/server-ops.d.ts +17 -0
- package/dist/types/api/servers/$.routes.d.ts +418 -186
- package/dist/types/api/session-required.d.ts +16 -0
- package/dist/types/api/settings.d.ts +7 -7
- package/dist/types/api/state.d.ts +100 -10
- package/dist/types/api/static.d.ts +2 -2
- package/dist/types/api/tls.d.ts +2 -5
- package/dist/types/api/workspaces/$.routes.d.ts +186 -12
- package/dist/types/api/wsl-temperature.d.ts +4 -10
- package/dist/types/app.d.ts +4511 -2778
- package/dist/types/cli/account.d.ts +23 -0
- package/dist/types/cli/add.d.ts +96 -0
- package/dist/types/cli/args.d.ts +24 -35
- package/dist/types/cli/backup-offline.d.ts +2 -8
- package/dist/types/cli/backup.d.ts +12 -21
- package/dist/types/cli/down.d.ts +15 -41
- package/dist/types/cli/import-plan.d.ts +55 -0
- package/dist/types/cli/import-write.d.ts +5 -0
- package/dist/types/cli/import.d.ts +86 -0
- package/dist/types/cli/io.d.ts +26 -35
- package/dist/types/cli/job.d.ts +99 -0
- package/dist/types/cli/logs.d.ts +1 -10
- package/dist/types/cli/ls.d.ts +57 -0
- package/dist/types/cli/migrate.d.ts +31 -8
- package/dist/types/cli/nearest.d.ts +1 -9
- package/dist/types/cli/run-deploy.d.ts +36 -0
- package/dist/types/cli/secret.d.ts +90 -0
- package/dist/types/cli/server.d.ts +6 -15
- package/dist/types/cli/service.d.ts +135 -0
- package/dist/types/cli/setup-temp.d.ts +17 -13
- package/dist/types/cli/status.d.ts +7 -1
- package/dist/types/cli/token.d.ts +6 -0
- package/dist/types/cli/ui-switch.d.ts +3 -14
- package/dist/types/cli/ui-update.d.ts +3 -16
- package/dist/types/cli/up.d.ts +9 -22
- package/dist/types/cli/usage.d.ts +2 -6
- package/dist/types/cli.d.ts +1 -10
- package/dist/types/client.d.ts +4099 -1142
- package/dist/types/config/accounts.d.ts +16 -0
- package/dist/types/config/jobs.d.ts +68 -0
- package/dist/types/config/layout.d.ts +2 -8
- package/dist/types/config/migrations.d.ts +9 -41
- package/dist/types/config/parse.d.ts +8 -13
- package/dist/types/config/patch.d.ts +1 -6
- package/dist/types/config/schema.d.ts +16 -18
- package/dist/types/config/secret-parts.d.ts +6 -27
- package/dist/types/config/secrets.d.ts +167 -88
- package/dist/types/config/seed.d.ts +1 -6
- package/dist/types/config/server-ids.d.ts +2 -11
- package/dist/types/config/settings.d.ts +13 -49
- package/dist/types/config/store.d.ts +17 -54
- package/dist/types/config/workspaces.d.ts +24 -56
- package/dist/types/helpers/action-result.d.ts +18 -32
- package/dist/types/helpers/atomic.d.ts +1 -4
- package/dist/types/helpers/backoff.d.ts +0 -1
- package/dist/types/helpers/bind.d.ts +3 -11
- package/dist/types/helpers/config-text.d.ts +4 -19
- package/dist/types/helpers/cookies.d.ts +2 -7
- package/dist/types/helpers/copy-tree.d.ts +4 -12
- package/dist/types/helpers/daemon-log.d.ts +8 -33
- package/dist/types/helpers/daemon.d.ts +20 -70
- package/dist/types/helpers/deferred.d.ts +2 -4
- package/dist/types/helpers/env-file.d.ts +2 -7
- package/dist/types/helpers/error.d.ts +3 -14
- package/dist/types/helpers/event-stream.d.ts +18 -10
- package/dist/types/helpers/factory.d.ts +2 -3
- package/dist/types/helpers/last-stop.d.ts +5 -12
- package/dist/types/helpers/logger.d.ts +1 -5
- package/dist/types/helpers/open.d.ts +0 -1
- package/dist/types/helpers/openapi.d.ts +19 -5
- package/dist/types/helpers/paths.d.ts +18 -53
- package/dist/types/helpers/restore-lock.d.ts +2 -17
- package/dist/types/helpers/runtime.d.ts +3 -13
- package/dist/types/helpers/secret-compare.d.ts +2 -10
- package/dist/types/helpers/server-create.d.ts +15 -0
- package/dist/types/helpers/shell.d.ts +2 -16
- package/dist/types/helpers/sse.d.ts +8 -6
- package/dist/types/helpers/ui-dir.d.ts +1 -5
- package/dist/types/helpers/utf8-chunks.d.ts +2 -8
- package/dist/types/helpers/validate.d.ts +2 -4
- package/dist/types/helpers/validator.d.ts +8 -4
- package/dist/types/helpers/version.d.ts +1 -6
- package/dist/types/helpers/workspace.d.ts +24 -16
- package/dist/types/index.d.ts +2 -3
- package/dist/types/middleware/auth.d.ts +8 -27
- package/dist/types/middleware/body-limit.d.ts +10 -0
- package/dist/types/middleware/host.d.ts +4 -23
- package/dist/types/middleware/loopback.d.ts +1 -8
- package/dist/types/middleware/token-scope.d.ts +34 -0
- package/dist/types/node-compat.d.ts +43 -0
- package/dist/types/openapi-reference.d.ts +4 -19
- package/dist/types/openapi.d.ts +5 -8
- package/dist/types/providers/archive.d.ts +8 -25
- package/dist/types/providers/backup-hook.d.ts +4 -19
- package/dist/types/providers/ddns/dyndns2.d.ts +0 -3
- package/dist/types/providers/ddns/index.d.ts +2 -3
- package/dist/types/providers/ddns/ip.d.ts +2 -12
- package/dist/types/providers/ddns/namecheap-api.d.ts +3 -2
- package/dist/types/providers/ddns/types.d.ts +6 -32
- package/dist/types/providers/ddns/zone.d.ts +1 -4
- package/dist/types/providers/docker.d.ts +18 -45
- package/dist/types/providers/entry-state.d.ts +4 -9
- package/dist/types/providers/health-check.d.ts +1 -5
- package/dist/types/providers/host.d.ts +33 -108
- package/dist/types/providers/identity.d.ts +9 -34
- package/dist/types/providers/log-tail.d.ts +14 -24
- package/dist/types/providers/nanny-sweep.d.ts +8 -25
- package/dist/types/providers/nanny.d.ts +16 -58
- package/dist/types/providers/port.d.ts +28 -83
- package/dist/types/providers/proc.d.ts +22 -80
- package/dist/types/providers/process.d.ts +12 -36
- package/dist/types/providers/proxy/admin.d.ts +11 -0
- package/dist/types/providers/proxy/types.d.ts +4 -16
- package/dist/types/providers/telegram.d.ts +1 -17
- package/dist/types/providers/ui-release.d.ts +15 -25
- package/dist/types/providers/webhook.d.ts +8 -29
- package/dist/types/providers/wsl-temperature.d.ts +13 -22
- package/dist/types/services/acme-challenge.d.ts +2 -16
- package/dist/types/services/auth.d.ts +65 -80
- package/dist/types/services/backups/archive-safety.d.ts +30 -0
- package/dist/types/services/backups/paths.d.ts +31 -0
- package/dist/types/services/backups.d.ts +61 -271
- package/dist/types/services/config-watch.d.ts +3 -15
- package/dist/types/services/control-server.d.ts +6 -10
- package/dist/types/services/ddns.d.ts +12 -13
- package/dist/types/services/dependencies.d.ts +3 -14
- package/dist/types/services/deploy.d.ts +34 -0
- package/dist/types/services/events.d.ts +15 -9
- package/dist/types/services/exposure.d.ts +13 -63
- package/dist/types/services/history.d.ts +5 -14
- package/dist/types/services/host-monitor.d.ts +6 -11
- package/dist/types/services/init.d.ts +5 -35
- package/dist/types/services/job-ledger.d.ts +27 -0
- package/dist/types/services/jobs.d.ts +113 -0
- package/dist/types/services/log-buffer.d.ts +7 -8
- package/dist/types/services/log-files.d.ts +12 -42
- package/dist/types/services/log-relay.d.ts +3 -13
- package/dist/types/services/nanny.d.ts +3 -10
- package/dist/types/services/notifications.d.ts +31 -61
- package/dist/types/services/panel.d.ts +32 -78
- package/dist/types/services/proxy-certificates/certificates.d.ts +31 -69
- package/dist/types/services/proxy-config.d.ts +15 -36
- package/dist/types/services/proxy-dns01.d.ts +14 -0
- package/dist/types/services/proxy.d.ts +73 -254
- package/dist/types/services/scheduler.d.ts +46 -0
- package/dist/types/services/state.d.ts +17 -8
- package/dist/types/services/supervisor/compose.d.ts +2 -6
- package/dist/types/services/supervisor/entry.d.ts +29 -32
- package/dist/types/services/supervisor/health.d.ts +8 -31
- package/dist/types/services/supervisor/job-run.d.ts +36 -0
- package/dist/types/services/supervisor/output.d.ts +13 -77
- package/dist/types/services/supervisor/persistent.d.ts +5 -11
- package/dist/types/services/supervisor/port-preflight.d.ts +4 -10
- package/dist/types/services/supervisor/records.d.ts +27 -60
- package/dist/types/services/supervisor/restart-required.d.ts +13 -0
- package/dist/types/services/supervisor/spawn.d.ts +3 -5
- package/dist/types/services/supervisor/view.d.ts +3 -1
- package/dist/types/services/supervisor.d.ts +31 -43
- package/dist/types/services/tls.d.ts +6 -17
- package/dist/types/services/ui-update.d.ts +19 -17
- package/dist/types/services/ui.d.ts +10 -19
- package/dist/types/shared/action-outcome.d.ts +2 -7
- package/dist/types/shared/api-client.d.ts +133 -177
- package/dist/types/shared/api-scopes.d.ts +17 -0
- package/dist/types/shared/backup-scope.d.ts +16 -90
- package/dist/types/shared/clone.d.ts +2 -11
- package/dist/types/shared/contracts/accounts.d.ts +99 -0
- package/dist/types/shared/contracts/backups.d.ts +219 -0
- package/dist/types/shared/contracts/ddns.d.ts +208 -0
- package/dist/types/shared/contracts/frames.d.ts +1395 -0
- package/dist/types/shared/contracts/index.d.ts +3 -0
- package/dist/types/shared/contracts/logs.d.ts +107 -0
- package/dist/types/shared/contracts/proxy.d.ts +303 -0
- package/dist/types/shared/contracts.d.ts +852 -1982
- package/dist/types/shared/cpu-scale.d.ts +3 -19
- package/dist/types/shared/crash-cause.d.ts +8 -0
- package/dist/types/shared/cron.d.ts +70 -0
- package/dist/types/shared/ddns-form.d.ts +9 -43
- package/dist/types/shared/endpoint.d.ts +1 -7
- package/dist/types/shared/error-codes.d.ts +438 -0
- package/dist/types/shared/error-message.d.ts +1 -7
- package/dist/types/shared/fields.d.ts +7 -17
- package/dist/types/shared/form-repair.d.ts +1 -5
- package/dist/types/shared/generated.d.ts +3 -19
- package/dist/types/shared/host-readings.d.ts +25 -128
- package/dist/types/shared/lazy.d.ts +1 -1
- package/dist/types/shared/live-frames.d.ts +2 -8
- package/dist/types/shared/live-series.d.ts +2 -8
- package/dist/types/shared/live-store.d.ts +4 -8
- package/dist/types/shared/log-download.d.ts +6 -0
- package/dist/types/shared/meta.d.ts +6 -0
- package/dist/types/shared/password-policy.d.ts +10 -0
- package/dist/types/shared/patch-diff.d.ts +13 -72
- package/dist/types/shared/port-reading.d.ts +18 -0
- package/dist/types/shared/probe-latency.d.ts +3 -21
- package/dist/types/shared/proxy-form.d.ts +33 -74
- package/dist/types/shared/proxy-validate.d.ts +11 -0
- package/dist/types/shared/query-params.d.ts +8 -0
- package/dist/types/shared/server-attention.d.ts +2 -27
- package/dist/types/shared/server-form.d.ts +15 -54
- package/dist/types/shared/server-key.d.ts +1 -12
- package/dist/types/shared/server-readings.d.ts +7 -32
- package/dist/types/shared/server-url.d.ts +9 -31
- package/dist/types/shared/shape.d.ts +1 -16
- package/dist/types/shared/stream-access.d.ts +2 -8
- package/dist/types/shared/ui-format.d.ts +25 -65
- package/docs/API.md +315 -107
- package/docs/BACKUPS.md +61 -56
- package/docs/CLI.md +255 -49
- package/docs/DDNS.md +35 -49
- package/docs/JOBS.md +129 -0
- package/docs/NOTIFICATIONS.md +58 -90
- package/docs/REVERSE_PROXY.md +116 -188
- package/docs/SECURITY.md +126 -44
- package/docs/SERVERS.md +282 -409
- package/docs/UI_CREATION.md +90 -47
- package/docs/demo/blank-host-restore.sh +31 -7
- package/package.json +15 -6
- package/scripts/prepare.mjs +47 -0
- package/uis/stock/dist/assets/CopyButton-8mliL0xi.js +1 -0
- package/uis/stock/dist/assets/GlobalSettingsView-BINXY77E.js +1 -0
- package/uis/stock/dist/assets/LogViewer-kiSnTwdY.js +1 -0
- package/uis/stock/dist/assets/LogsView-DDXf_ONs.js +1 -0
- package/uis/stock/dist/assets/Modal-lrUuViF2.js +39 -0
- package/uis/stock/dist/assets/ProxyView-uXMaJdSQ.js +1 -0
- package/uis/stock/dist/assets/ServerDetailView-CW0Vb_c0.js +4 -0
- package/uis/stock/dist/assets/SettingsShell-B135xWjJ.js +1 -0
- package/uis/stock/dist/assets/SettingsView-BLtWxVkl.js +2 -0
- package/uis/stock/dist/assets/de-BIoTrHBQ.js +1 -0
- package/uis/stock/dist/assets/es-x4-ih8lH.js +1 -0
- package/uis/stock/dist/assets/fr-DatqBBkO.js +1 -0
- package/uis/stock/dist/assets/index-CnojaKcA.css +2 -0
- package/uis/stock/dist/assets/index-D-CiZReu.js +16 -0
- package/uis/stock/dist/assets/ja-CW1703Gw.js +1 -0
- package/uis/stock/dist/assets/ko-wFbT4XtK.js +1 -0
- package/uis/stock/dist/assets/ru-C1p5C4VN.js +1 -0
- package/uis/stock/dist/assets/useUnsavedGuard-BcsXsfCC.js +9 -0
- package/uis/stock/dist/assets/vi-CDqr0uie.js +1 -0
- package/uis/stock/dist/assets/zh-CN-BJ7iit-X.js +1 -0
- package/uis/stock/dist/index.html +4 -3
- package/uis/stock/dist/ui.json +3 -3
- package/dist/chunks/archive-DP-XQR8X.js.map +0 -1
- package/dist/chunks/atomic-C1PfJpE7.js.map +0 -1
- package/dist/chunks/backup-CZcVca2a.js.map +0 -1
- package/dist/chunks/backups-CFRaWe_m.js +0 -4691
- package/dist/chunks/backups-CFRaWe_m.js.map +0 -1
- package/dist/chunks/config-text-DifCHhnz.js +0 -50
- package/dist/chunks/config-text-DifCHhnz.js.map +0 -1
- package/dist/chunks/contracts-CMBD1TF9.js.map +0 -1
- package/dist/chunks/daemon-log-BVj8cDEo.js +0 -241
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +0 -1
- package/dist/chunks/daemon-qKVECISl.js +0 -247
- package/dist/chunks/daemon-qKVECISl.js.map +0 -1
- package/dist/chunks/docker-Cy9Lyvda.js.map +0 -1
- package/dist/chunks/down-pKbGCW9d.js.map +0 -1
- package/dist/chunks/init-BZ7hK9Vf.js.map +0 -1
- package/dist/chunks/last-stop-C-BXz_XI.js +0 -53
- package/dist/chunks/last-stop-C-BXz_XI.js.map +0 -1
- package/dist/chunks/layout-DwTtmund.js +0 -24
- package/dist/chunks/layout-DwTtmund.js.map +0 -1
- package/dist/chunks/lazy-Ce5zEAq1.js +0 -66
- package/dist/chunks/lazy-Ce5zEAq1.js.map +0 -1
- package/dist/chunks/log-buffer-Dy9HHDMD.js +0 -414
- package/dist/chunks/log-buffer-Dy9HHDMD.js.map +0 -1
- package/dist/chunks/logger-B5U4GD3j.js.map +0 -1
- package/dist/chunks/logs---TI_bxM.js.map +0 -1
- package/dist/chunks/migrate-Cfoq-Vgh.js +0 -155
- package/dist/chunks/migrate-Cfoq-Vgh.js.map +0 -1
- package/dist/chunks/nanny-B-Eu0sFW.js.map +0 -1
- package/dist/chunks/nanny-BtWfy0QH.js +0 -1167
- package/dist/chunks/nanny-BtWfy0QH.js.map +0 -1
- package/dist/chunks/nanny-sweep-DErnlPY1.js.map +0 -1
- package/dist/chunks/nearest-6KgQEDUe.js.map +0 -1
- package/dist/chunks/parse-DhmG26fI.js.map +0 -1
- package/dist/chunks/paths-CGlGDrOU.js.map +0 -1
- package/dist/chunks/port-B8WBTRMk.js.map +0 -1
- package/dist/chunks/restart-Des4DrAN.js.map +0 -1
- package/dist/chunks/schema-B240VXcV.js.map +0 -1
- package/dist/chunks/secrets-BieELnZh.js +0 -562
- package/dist/chunks/secrets-BieELnZh.js.map +0 -1
- package/dist/chunks/server-Bge2r2qQ.js +0 -169
- package/dist/chunks/server-Bge2r2qQ.js.map +0 -1
- package/dist/chunks/server-ids-DRuNLVCV.js +0 -32
- package/dist/chunks/server-ids-DRuNLVCV.js.map +0 -1
- package/dist/chunks/set-password-D5vZqqSX.js +0 -43
- package/dist/chunks/set-password-D5vZqqSX.js.map +0 -1
- package/dist/chunks/set-token-obPiEJYk.js +0 -78
- package/dist/chunks/set-token-obPiEJYk.js.map +0 -1
- package/dist/chunks/settings-xu-XTfWg.js.map +0 -1
- package/dist/chunks/setup-temp-CAN4_bA-.js.map +0 -1
- package/dist/chunks/shape-DnTKzjQ2.js +0 -24
- package/dist/chunks/shape-DnTKzjQ2.js.map +0 -1
- package/dist/chunks/src-BtWMFmzZ.js.map +0 -1
- package/dist/chunks/status-DT1EsA-B.js.map +0 -1
- package/dist/chunks/ui-D562aqw5.js.map +0 -1
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +0 -1
- package/dist/chunks/ui-release-DKzVvlLd.js.map +0 -1
- package/dist/chunks/ui-revert-EkBBwRTt.js.map +0 -1
- package/dist/chunks/ui-switch-BnZTdMDd.js.map +0 -1
- package/dist/chunks/ui-update-_xryLYxw.js.map +0 -1
- package/dist/chunks/up-Pdz-l6IH.js.map +0 -1
- package/dist/chunks/usage-DFrCVXpT.js.map +0 -1
- package/dist/chunks/workspaces-DYcfvKV_.js.map +0 -1
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +0 -1
- package/dist/types/cli/set-password.d.ts +0 -14
- package/dist/types/cli/set-token.d.ts +0 -21
- package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +0 -1
- package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +0 -1
- package/uis/stock/dist/assets/LogViewer-DIliXy62.js +0 -1
- package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +0 -1
- package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +0 -39
- package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +0 -1
- package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +0 -2
- package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +0 -1
- package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +0 -2
- package/uis/stock/dist/assets/de-BRITeb0H.js +0 -1
- package/uis/stock/dist/assets/es-B2zIEssV.js +0 -1
- package/uis/stock/dist/assets/fr-s0ZOBEqh.js +0 -1
- package/uis/stock/dist/assets/index-C1MehbKy.css +0 -2
- package/uis/stock/dist/assets/index-CnBN54wF.js +0 -15
- package/uis/stock/dist/assets/ja-CU7MR85V.js +0 -1
- package/uis/stock/dist/assets/ko-tL5Me6d-.js +0 -1
- package/uis/stock/dist/assets/ru-92yrvkNJ.js +0 -1
- package/uis/stock/dist/assets/vi-CzvY16k2.js +0 -1
- package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-release-XbJ85pYI.js","names":[],"sources":["../../src/providers/ui-release.ts"],"sourcesContent":["import type { Buffer } from 'node:buffer'\nimport { createHash } from 'node:crypto'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { invocation } from '#src/cli/io'\nimport { errorMessage } from '#src/shared/error-message'\n/**\n * The GitHub-release side of installing a UI (repo, tag, asset, metadata, download), shared by\n * `ui-switch` and `ui-update`.\n */\n\nexport const DEFAULT_REPO = 'NamesMT/home-hosted'\n/** Mirrors the cap `UiService` enforces uncompressed. */\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 /** `sha256:<hex>`, which GitHub publishes for every asset uploaded since mid-2025. */\n digest?: string | null\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\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\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\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, pairing a UI with its panel; another repo uses its\n * latest release. `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\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/** 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\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/** A token is only ever sent to GitHub, never to a `--file <url>` host the user did not vouch for. */\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/** `fetch` has no default timeout, and a stalled request in the startup hook would pend forever. */\nconst REQUEST_TIMEOUT_MS = 30_000\nconst DOWNLOAD_TIMEOUT_MS = 120_000\n\nfunction timeoutSignal(ms: number): AbortSignal | undefined {\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\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: ${errorMessage(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\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: ${errorMessage(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\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}: ${errorMessage(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\n/** Refuses a download whose sha256 differs from the release metadata; an asset with no digest is not checked. */\nexport async function verifyAssetDigest(file: string, digest: string | null | undefined): Promise<void> {\n if (typeof digest !== 'string')\n return\n const match = /^sha256:([0-9a-f]{64})$/i.exec(digest.trim())\n if (match === null)\n return\n const hash = createHash('sha256')\n for await (const chunk of fs.createReadStream(file))\n hash.update(chunk as Buffer)\n const actual = hash.digest('hex')\n if (actual !== match[1]!.toLowerCase())\n throw new Error(`the download does not match the release's sha256 digest (expected ${match[1]!.toLowerCase()}, got ${actual}) — nothing was installed`)\n}\n\n/** Headers for an asset download: the token goes only to GitHub, and only over https. */\nexport function downloadHeaders(url: string, context: UiSourceContext): Record<string, string> {\n return {\n 'accept': 'application/octet-stream',\n 'user-agent': `home-hosted/${context.version}`,\n ...(context.token !== null && context.token !== undefined && context.token.length > 0 && isGithubHost(url) ? { authorization: `Bearer ${context.token}` } : {}),\n }\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: ${invocation()} 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\n/**\n * Tag ordering without a semver dependency: `v1.2.3` beats `v1.2.2`, a prerelease loses to its\n * release, and a non-version sorts below every version.\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 prereleases; two prereleases are ordered by identifiers (`rc.2` after `rc.1`).\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":";;;;;;;;;;AAYA,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;AAEA,SAAgB,UAAU,MAAyB;CACjD,OAAO,SAAS,IAAI,CAAC,CAAC,YAAY,MAAM,a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AY,MAAM,OAAO,KAAA,IAAY,CAAC,IAAI,MAAM,EAAE,CAAC,MAAM,GAAG;CAC9D;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as hhDir } from "./paths-
|
|
3
|
-
import { UiService } from "./ui-
|
|
1
|
+
import { h as green } from "../cli.js";
|
|
2
|
+
import { c as hhDir } from "./paths-C34-TJLh.js";
|
|
3
|
+
import { UiService } from "./ui-BcIAtyxE.js";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
//#region src/cli/ui-revert.ts
|
|
@@ -24,4 +24,4 @@ var uiRevertCommand = defineCommand({
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { uiRevertCommand };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=ui-revert-
|
|
27
|
+
//# sourceMappingURL=ui-revert-Dgawq7ze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-revert-Dgawq7ze.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 so `rejectUnknownFlags` refuses every flag and word: this command takes no options.\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;CAE1B,MAAM,CAAC;CACP,KAAK,YAAY;EACf,MAAM,YAAY;CACpB;AACF,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { S as style, y as prompt } from "../cli.js";
|
|
2
|
+
import { c as fetchRelease, d as isUiAsset, f as matchAsset, h as parseRepoSlug, i as defaultReleaseTag, m as parseFileSource, n as assetDownloadUrl, p as noAssetsMessage, s as fallbackUiName, t as DEFAULT_REPO } from "./ui-release-XbJ85pYI.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import fs from "node:fs";
|
|
6
|
-
import { parseArgs } from "node:util";
|
|
6
|
+
import { parseArgs as parseArgs$1 } from "node:util";
|
|
7
7
|
//#region src/cli/ui-switch.ts
|
|
8
8
|
async function uiSwitch(argv, io) {
|
|
9
|
-
const { values } = parseArgs({
|
|
9
|
+
const { values } = parseArgs$1({
|
|
10
10
|
args: argv,
|
|
11
11
|
options: {
|
|
12
12
|
repo: { type: "string" },
|
|
@@ -18,7 +18,8 @@ async function uiSwitch(argv, io) {
|
|
|
18
18
|
yes: {
|
|
19
19
|
type: "boolean",
|
|
20
20
|
short: "y"
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
|
+
insecure: { type: "boolean" }
|
|
22
23
|
},
|
|
23
24
|
allowPositionals: false
|
|
24
25
|
});
|
|
@@ -30,9 +31,10 @@ async function uiSwitch(argv, io) {
|
|
|
30
31
|
};
|
|
31
32
|
if (values.file !== void 0) {
|
|
32
33
|
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
|
+
await installFromFile(values.file, context, values.insecure === true);
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
37
|
+
if (values.insecure === true) throw new Error("--insecure only applies to an http:// --file URL");
|
|
36
38
|
const repo = parseRepoSlug(values.repo ?? "NamesMT/home-hosted");
|
|
37
39
|
if (repo === null) throw new Error(`invalid --repo "${values.repo}" — expected an "owner/name" slug, e.g. ${DEFAULT_REPO}`);
|
|
38
40
|
const requestedTag = values.tag ?? defaultReleaseTag(repo, context.version);
|
|
@@ -54,7 +56,7 @@ async function uiSwitch(argv, io) {
|
|
|
54
56
|
io.write("cancelled — nothing was installed\n");
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
|
-
await installFromUrl(assetDownloadUrl(chosen), fallbackUiName(chosen.name ?? ""), context, release.tag);
|
|
59
|
+
await installFromUrl(assetDownloadUrl(chosen), fallbackUiName(chosen.name ?? ""), context, release.tag, chosen.digest);
|
|
58
60
|
}
|
|
59
61
|
async function chooseAsset(assets, values, context) {
|
|
60
62
|
const { io } = context;
|
|
@@ -84,7 +86,7 @@ async function chooseAsset(assets, values, context) {
|
|
|
84
86
|
io.write(` ${io.style.dim(matched.error)}\n`);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
async function installFromFile(value, context) {
|
|
89
|
+
async function installFromFile(value, context, insecure) {
|
|
88
90
|
const source = parseFileSource(value);
|
|
89
91
|
if (source.kind === "path") {
|
|
90
92
|
if (!fs.existsSync(source.path)) throw new Error(`no file at ${source.path}`);
|
|
@@ -92,35 +94,30 @@ async function installFromFile(value, context) {
|
|
|
92
94
|
await installArchive(source.path, fallbackUiName(source.path), context);
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
97
|
+
if (new URL(source.url).protocol !== "https:" && !insecure) throw new Error(`refusing to install a UI over plain http (${source.url}) — use https, or pass --insecure if you trust every network in between`);
|
|
95
98
|
await installFromUrl(source.url, fallbackUiName(new URL(source.url).pathname), context);
|
|
96
99
|
}
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
}
|
|
100
|
+
/** Records the release the asset came from, never the stale tag inside the archive; a file or bare URL has none. */
|
|
101
|
+
async function installFromUrl(url, fallbackName, context, installedTag, digest) {
|
|
102
|
+
const { UiService } = await import("./ui-BcIAtyxE.js");
|
|
103
|
+
const { installReleaseAsset } = await import("./ui-update-CAiH2tFb.js");
|
|
104
|
+
const { hhDir: dataRoot } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
105
|
+
const ui = new UiService({ dataRoot });
|
|
106
|
+
report(ui, await installReleaseAsset(ui, {
|
|
107
|
+
url,
|
|
108
|
+
fallbackName,
|
|
109
|
+
tag: installedTag,
|
|
110
|
+
digest,
|
|
111
|
+
context
|
|
112
|
+
}), context);
|
|
118
113
|
}
|
|
119
114
|
async function installArchive(archivePath, fallbackName, context, installedTag) {
|
|
120
|
-
const { UiService } = await import("./ui-
|
|
121
|
-
const { hhDir: dataRoot } = await import("./paths-
|
|
115
|
+
const { UiService } = await import("./ui-BcIAtyxE.js");
|
|
116
|
+
const { hhDir: dataRoot } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
122
117
|
const ui = new UiService({ dataRoot });
|
|
123
|
-
|
|
118
|
+
report(ui, await ui.install(archivePath, fallbackName, installedTag), context);
|
|
119
|
+
}
|
|
120
|
+
function report(ui, result, context) {
|
|
124
121
|
if (!result.ok) throw new Error(`nothing was installed: ${result.error}`);
|
|
125
122
|
const { meta } = result;
|
|
126
123
|
const label = meta.version === null ? meta.name : `${meta.name} ${meta.version}`;
|
|
@@ -129,11 +126,7 @@ async function installArchive(archivePath, fallbackName, context, installedTag)
|
|
|
129
126
|
context.io.write(` ${context.io.style.dim("files")} ${meta.files}\n`);
|
|
130
127
|
context.io.write(`refresh the browser to see it\n`);
|
|
131
128
|
}
|
|
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
|
-
*/
|
|
129
|
+
/** `ui-switch` parses its own flags inside `uiSwitch`. */
|
|
137
130
|
var uiSwitchCommand = defineCommand({
|
|
138
131
|
meta: { name: "ui-switch" },
|
|
139
132
|
run: async ({ rawArgs }) => {
|
|
@@ -147,4 +140,4 @@ var uiSwitchCommand = defineCommand({
|
|
|
147
140
|
//#endregion
|
|
148
141
|
export { uiSwitchCommand };
|
|
149
142
|
|
|
150
|
-
//# sourceMappingURL=ui-switch-
|
|
143
|
+
//# sourceMappingURL=ui-switch-CfQMbZ0g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-switch-CfQMbZ0g.js","names":["parseArgs"],"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 fallbackUiName,\n fetchRelease,\n isUiAsset,\n matchAsset,\n noAssetsMessage,\n parseFileSource,\n parseRepoSlug,\n} from '#src/providers/ui-release'\n\n/**\n * `home-hosted ui-switch` installs a UI from a GitHub release asset (the default), a local zip, or an\n * http(s) URL. Imported only after `--home` is applied; state-reading modules load inside the command.\n */\n\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 insecure: { type: 'boolean' },\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, values.insecure === true)\n return\n }\n if (values.insecure === true)\n throw new Error('--insecure only applies to an http:// --file URL')\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 a broken pipe (`| head`) does not kill it.\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, chosen.digest)\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 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, insecure: boolean): 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 // The archive becomes the page every admin session loads; over plain http anyone on the path can swap it.\n if (new URL(source.url).protocol !== 'https:' && !insecure)\n throw new Error(`refusing to install a UI over plain http (${source.url}) — use https, or pass --insecure if you trust every network in between`)\n await installFromUrl(source.url, fallbackUiName(new URL(source.url).pathname), context)\n}\n\n/** Records the release the asset came from, never the stale tag inside the archive; a file or bare URL has none. */\nasync function installFromUrl(url: string, fallbackName: string, context: SwitchContext, installedTag?: string, digest?: string | null): Promise<void> {\n const { UiService } = await import('#src/services/ui')\n const { installReleaseAsset } = await import('#src/services/ui-update')\n const { hhDir: dataRoot } = await import('#src/helpers/paths')\n const ui = new UiService({ dataRoot })\n report(ui, await installReleaseAsset(ui, { url, fallbackName, tag: installedTag, digest, context }), context)\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 report(ui, await ui.install(archivePath, fallbackName, installedTag), context)\n}\n\nfunction report(ui: import('#src/services/ui').UiService, result: import('#src/services/ui').UiInstallResult, context: SwitchContext): void {\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/** `ui-switch` parses its own flags inside `uiSwitch`. */\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":";;;;;;;AAwCA,eAAsB,SAAS,MAAgB,IAA+B;CA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AAG,MAAM,KAAK,QAAQ,GAAG,MAAM,IAAI,OAAO,EAAE,IAAI,KAAK,MAAM,GAAG;CACtE,QAAQ,GAAG,MAAM,iCAAiC;AACpD;;AAGA,IAAa,kBAAkB,cAAc;CAC3C,MAAM,EAAE,MAAM,YAAY;CAC1B,KAAK,OAAO,EAAE,cAAc;EAC1B,MAAM,SAAS,SAAS;GACtB,QAAO,SAAQ,QAAQ,OAAO,MAAM,IAAI;GACxC;GACA;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { S as style, g as invocation, y as prompt } from "../cli.js";
|
|
2
|
+
import { r as formatDateTimeIso } from "./ui-format-CDvvqOoi.js";
|
|
3
|
+
import { c as fetchRelease, d as isUiAsset, f as matchAsset, g as repoSlug, h as parseRepoSlug, l as fetchReleases, n as assetDownloadUrl, r as compareTags, t as DEFAULT_REPO, u as isOwnRepo } from "./ui-release-XbJ85pYI.js";
|
|
3
4
|
import process from "node:process";
|
|
4
5
|
import { defineCommand } from "citty";
|
|
5
|
-
import
|
|
6
|
-
import { parseArgs } from "node:util";
|
|
6
|
+
import { parseArgs as parseArgs$1 } from "node:util";
|
|
7
7
|
//#region src/cli/ui-update.ts
|
|
8
|
-
/**
|
|
9
|
-
* Which of a release list applies to what is installed. A candidate is only offered when
|
|
10
|
-
* its assets carry the asset the person is actually using, so a UI is never swapped for a
|
|
11
|
-
* different flavour by an update.
|
|
12
|
-
*/
|
|
8
|
+
/** A candidate is offered only when it carries the asset in use, so an update never swaps flavour. */
|
|
13
9
|
function usableCandidates(releases, asset, order, currentTag) {
|
|
14
10
|
const found = [];
|
|
15
11
|
for (const release of releases) {
|
|
@@ -28,16 +24,12 @@ function usableCandidates(releases, asset, order, currentTag) {
|
|
|
28
24
|
}
|
|
29
25
|
return found;
|
|
30
26
|
}
|
|
31
|
-
/** What the asset the UI is using is likely called, when it never declared one. */
|
|
32
27
|
function impliedAsset(identity) {
|
|
33
28
|
if (identity.asset !== null && identity.asset.length > 0) return identity.asset;
|
|
34
29
|
if (identity.name.length > 0) return `${identity.name}.zip`;
|
|
35
30
|
return null;
|
|
36
31
|
}
|
|
37
|
-
/**
|
|
38
|
-
* The decision, with no I/O in it: given what is installed and this panel's release,
|
|
39
|
-
* what should `ui-update` do? `releases` is only consulted for someone else's UI.
|
|
40
|
-
*/
|
|
32
|
+
/** The decision, with no I/O. `releases` is only consulted for someone else's UI. */
|
|
41
33
|
function planUiUpdate(installed, runningTag, releases = [], order = "newer") {
|
|
42
34
|
if (installed === null) return { kind: "stock" };
|
|
43
35
|
const repo = installed.repo === null ? null : parseRepoSlug(installed.repo);
|
|
@@ -62,9 +54,8 @@ function planUiUpdate(installed, runningTag, releases = [], order = "newer") {
|
|
|
62
54
|
candidates: usableCandidates(releases, asset, order, installed.tag)
|
|
63
55
|
};
|
|
64
56
|
}
|
|
65
|
-
/** `home-hosted ui-update` — see the module comment for the three cases. */
|
|
66
57
|
async function uiUpdate(argv, io) {
|
|
67
|
-
const { values } = parseArgs({
|
|
58
|
+
const { values } = parseArgs$1({
|
|
68
59
|
args: argv,
|
|
69
60
|
options: {
|
|
70
61
|
tag: { type: "string" },
|
|
@@ -81,8 +72,8 @@ async function uiUpdate(argv, io) {
|
|
|
81
72
|
allowPositionals: false
|
|
82
73
|
});
|
|
83
74
|
const { appVersion } = await import("../cli.js").then((n) => n.i);
|
|
84
|
-
const { hhDir: dataRoot } = await import("./paths-
|
|
85
|
-
const { UiService } = await import("./ui-
|
|
75
|
+
const { hhDir: dataRoot } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
76
|
+
const { UiService } = await import("./ui-BcIAtyxE.js");
|
|
86
77
|
const context = {
|
|
87
78
|
io: {
|
|
88
79
|
write: io.write,
|
|
@@ -111,7 +102,7 @@ async function uiUpdate(argv, io) {
|
|
|
111
102
|
const repo = installed.repo === null ? null : parseRepoSlug(installed.repo);
|
|
112
103
|
if ((values.tag !== void 0 || values.asset !== void 0) && repo === null) {
|
|
113
104
|
const flag = values.tag !== void 0 ? "--tag" : "--asset";
|
|
114
|
-
throw new Error([`${flag} needs a repository to fetch from, and this UI does not declare one`, ` pass it:
|
|
105
|
+
throw new Error([`${flag} needs a repository to fetch from, and this UI does not declare one`, ` pass it: ${invocation()} ui-update --repo ${DEFAULT_REPO} ${flag} ${values[values.tag !== void 0 ? "tag" : "asset"]}`].join("\n"));
|
|
115
106
|
}
|
|
116
107
|
if (values.check === true && repo !== null) {
|
|
117
108
|
if (isOwnRepo(repo)) {
|
|
@@ -133,7 +124,7 @@ async function uiUpdate(argv, io) {
|
|
|
133
124
|
if (plan.kind === "unidentifiable") {
|
|
134
125
|
io.write(`${io.style.bold("this UI does not say where it came from")} — nothing to follow automatically\n`);
|
|
135
126
|
printIdentity(io, plan.identity);
|
|
136
|
-
io.write(` ${io.style.dim(
|
|
127
|
+
io.write(` ${io.style.dim(`point it at a repo to make this work: ${invocation()} ui-update --repo owner/name`)}\n`);
|
|
137
128
|
return;
|
|
138
129
|
}
|
|
139
130
|
if (plan.kind === "official") {
|
|
@@ -151,7 +142,7 @@ async function uiUpdate(argv, io) {
|
|
|
151
142
|
if (plan.candidates.length === 0) {
|
|
152
143
|
const direction = order === "newer" ? "newer" : "older";
|
|
153
144
|
io.write(`no ${direction} releases carry ${plan.asset}\n`);
|
|
154
|
-
if (order === "newer") io.write(` ${io.style.dim(
|
|
145
|
+
if (order === "newer") io.write(` ${io.style.dim(`list older releases with: ${invocation()} ui-update --old`)}\n`);
|
|
155
146
|
return;
|
|
156
147
|
}
|
|
157
148
|
const chosen = await chooseCandidate(plan.candidates, context, order);
|
|
@@ -176,7 +167,7 @@ function printIdentity(io, identity) {
|
|
|
176
167
|
io.write(` name ${identity.name}\n`);
|
|
177
168
|
io.write(` version ${identity.version ?? "unspecified"}\n`);
|
|
178
169
|
io.write(` repo ${identity.repo ?? "unspecified"}${identity.tag === null ? "" : ` @ ${identity.tag}`}\n`);
|
|
179
|
-
if (identity.unix !== null) io.write(` built ${(
|
|
170
|
+
if (identity.unix !== null) io.write(` built ${formatDateTimeIso(identity.unix * 1e3)}\n`);
|
|
180
171
|
}
|
|
181
172
|
function printCheck(io, identity, target, candidates = []) {
|
|
182
173
|
if (target !== null) {
|
|
@@ -219,7 +210,6 @@ async function chooseCandidate(candidates, context, order) {
|
|
|
219
210
|
io.write(` ${io.style.dim(`no such choice — enter 1-${candidates.length} or a tag`)}\n`);
|
|
220
211
|
}
|
|
221
212
|
}
|
|
222
|
-
/** Fetches one release's asset and installs it, reporting what landed. */
|
|
223
213
|
async function installTag(repo, wantedAsset, tag, context) {
|
|
224
214
|
const release = await fetchRelease(repo, tag, context);
|
|
225
215
|
const names = release.assets.map((asset) => asset.name ?? "").filter(isUiAsset);
|
|
@@ -231,31 +221,23 @@ async function installTag(repo, wantedAsset, tag, context) {
|
|
|
231
221
|
} else if (names.length === 1) assetName = names[0];
|
|
232
222
|
else throw new Error(`${names.length} UI assets in ${repo.owner}/${repo.name}@${release.tag} — name one with --asset`);
|
|
233
223
|
const asset = release.assets.find((entry) => entry.name === assetName);
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
fs.rmSync(download.dir, {
|
|
250
|
-
recursive: true,
|
|
251
|
-
force: true
|
|
252
|
-
});
|
|
253
|
-
}
|
|
224
|
+
const { UiService } = await import("./ui-BcIAtyxE.js");
|
|
225
|
+
const { installReleaseAsset } = await import("./ui-update-CAiH2tFb.js");
|
|
226
|
+
const { hhDir: dataRoot } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
227
|
+
const result = await installReleaseAsset(new UiService({ dataRoot }), {
|
|
228
|
+
url: assetDownloadUrl(asset),
|
|
229
|
+
fallbackName: assetName,
|
|
230
|
+
tag: release.tag,
|
|
231
|
+
digest: asset.digest,
|
|
232
|
+
context
|
|
233
|
+
});
|
|
234
|
+
if (!result.ok) throw new Error(`nothing was installed: ${result.error}`);
|
|
235
|
+
const { meta } = result;
|
|
236
|
+
const { io } = context;
|
|
237
|
+
io.write(`${io.style.green("UI updated")} — ${meta.name} ${meta.version ?? ""} at ${release.tag}\n`);
|
|
238
|
+
io.write(` ${io.style.dim("refresh the browser to see it")}\n`);
|
|
254
239
|
}
|
|
255
|
-
/**
|
|
256
|
-
* The citty entry. Like `ui-switch`, the parsing and the messages stay in the plain
|
|
257
|
-
* function so they can be exercised without a terminal.
|
|
258
|
-
*/
|
|
240
|
+
/** Parsing and messages stay in the plain function so they can be exercised without a terminal. */
|
|
259
241
|
var uiUpdateCommand = defineCommand({
|
|
260
242
|
meta: { name: "ui-update" },
|
|
261
243
|
run: async ({ rawArgs }) => {
|
|
@@ -269,4 +251,4 @@ var uiUpdateCommand = defineCommand({
|
|
|
269
251
|
//#endregion
|
|
270
252
|
export { uiUpdateCommand };
|
|
271
253
|
|
|
272
|
-
//# sourceMappingURL=ui-update-
|
|
254
|
+
//# sourceMappingURL=ui-update-B3PPivUm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-update-B3PPivUm.js","names":["parseArgs"],"sources":["../../src/cli/ui-update.ts"],"sourcesContent":["import type { UiSourceContext } from '#src/providers/ui-release'\nimport type { UiMeta } from '#src/shared/contracts'\nimport process from 'node:process'\nimport { parseArgs } from 'node:util'\nimport { defineCommand } from 'citty'\nimport { invocation, prompt, style } from '#src/cli/io'\nimport {\n assetDownloadUrl,\n compareTags,\n DEFAULT_REPO,\n fetchRelease,\n fetchReleases,\n isOwnRepo,\n isUiAsset,\n matchAsset,\n parseRepoSlug,\n repoSlug,\n} from '#src/providers/ui-release'\nimport { formatDateTimeIso } from '#src/shared/ui-format'\n\n/**\n * `home-hosted ui-update` keeps an installed UI in step with the panel:\n * the stock UI is always current;\n * a UI from our own repo is paired with a release, so it follows the running panel's tag;\n * anyone else's UI declares its own `repo`, and the person picks from releases carrying its asset.\n */\n\ninterface UpdateContext extends UiSourceContext {\n /** null when the session cannot be asked (not a TTY, or `--yes`). */\n ask: ((question: string) => Promise<string>) | null\n}\n\nexport interface UiIdentity {\n name: string\n version: string | null\n repo: string | null\n tag: string | null\n asset: string | null\n unix: number | null\n}\n\nexport type UiUpdatePlan\n /** Nothing installed: the stock UI is served, and it is always current. */\n = { kind: 'stock' }\n /** Installed, but it never said where it came from, so there is nothing to follow. */\n | { kind: 'unidentifiable', identity: UiIdentity }\n /** Ours: paired with this panel's release. `target` already matches when current. */\n | { kind: 'official', identity: UiIdentity, target: string }\n /** Someone else's: the person chooses from `candidates`. */\n | { kind: 'choice', identity: UiIdentity, asset: string, candidates: UpdateCandidate[] }\n\nexport interface UpdateCandidate {\n tag: string\n asset: string\n}\n\n/** A candidate is offered only when it carries the asset in use, so an update never swaps flavour. */\nexport function usableCandidates(\n releases: Array<{ tag: string, assets: Array<{ name?: string }> }>,\n asset: string,\n order: 'newer' | 'older',\n currentTag: string | null,\n): UpdateCandidate[] {\n const found: UpdateCandidate[] = []\n\n for (const release of releases) {\n const names = release.assets.map(entry => entry.name ?? '').filter(isUiAsset)\n const matched = matchAsset(names, asset)\n if (!matched.ok)\n continue\n if (currentTag !== null) {\n const difference = compareTags(release.tag, currentTag)\n if (order === 'newer' && difference <= 0)\n continue\n if (order === 'older' && difference >= 0)\n continue\n }\n found.push({ tag: release.tag, asset: matched.name })\n }\n\n return found\n}\n\nexport function impliedAsset(identity: UiIdentity): string | null {\n if (identity.asset !== null && identity.asset.length > 0)\n return identity.asset\n if (identity.name.length > 0)\n return `${identity.name}.zip`\n return null\n}\n\n/** The decision, with no I/O. `releases` is only consulted for someone else's UI. */\nexport function planUiUpdate(\n installed: UiIdentity | null,\n runningTag: string,\n releases: Array<{ tag: string, assets: Array<{ name?: string }> }> = [],\n order: 'newer' | 'older' = 'newer',\n): UiUpdatePlan {\n if (installed === null)\n return { kind: 'stock' }\n\n const repo = installed.repo === null ? null : parseRepoSlug(installed.repo)\n if (repo === null)\n return { kind: 'unidentifiable', identity: installed }\n\n if (isOwnRepo(repo))\n return { kind: 'official', identity: installed, target: runningTag }\n\n const asset = impliedAsset(installed)\n if (asset === null)\n return { kind: 'unidentifiable', identity: installed }\n\n return { kind: 'choice', identity: installed, asset, candidates: usableCandidates(releases, asset, order, installed.tag) }\n}\n\nexport async function uiUpdate(argv: string[], io: { write: (text: string) => void, prompt: (question: string) => Promise<string>, style: { bold: (text: string) => string, dim: (text: string) => string, green: (text: string) => string } }): Promise<void> {\n const { values } = parseArgs({\n args: argv,\n options: {\n tag: { type: 'string' },\n asset: { type: 'string' },\n token: { type: 'string' },\n yes: { type: 'boolean', short: 'y' },\n old: { type: 'boolean' },\n check: { type: 'boolean' },\n repo: { type: 'string' },\n },\n allowPositionals: false,\n })\n\n const { appVersion } = await import('#src/helpers/version')\n const { hhDir: dataRoot } = await import('#src/helpers/paths')\n const { UiService } = await import('#src/services/ui')\n\n const context: UpdateContext = {\n io: { write: io.write, style: io.style },\n ask: process.stdin.isTTY === true && values.yes !== true ? io.prompt : null,\n version: appVersion(),\n token: values.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN ?? null,\n }\n\n const ui = new UiService({ dataRoot })\n const status = ui.status()\n const installed = identityOf(status.meta)\n\n if (installed === null) {\n io.write(`${io.style.dim('the stock UI is in use — it ships with the panel and is always current')}\\n`)\n return\n }\n\n if (values.repo !== undefined) {\n const repo = parseRepoSlug(values.repo)\n if (repo === null)\n throw new Error(`invalid --repo \"${values.repo}\" — expected an \"owner/name\" slug, e.g. ${DEFAULT_REPO}`)\n installed.repo = repoSlug(repo)\n }\n\n // `--asset` outranks the declared one: a release can carry more than one UI.\n if (values.asset !== undefined) {\n const named = values.asset.trim()\n if (named.length === 0)\n throw new Error('--asset is empty — name the release asset to install, or drop the flag')\n installed.asset = named\n }\n\n const order = values.old === true ? 'older' : 'newer'\n const repo = installed.repo === null ? null : parseRepoSlug(installed.repo)\n\n if ((values.tag !== undefined || values.asset !== undefined) && repo === null) {\n const flag = values.tag !== undefined ? '--tag' : '--asset'\n throw new Error([\n `${flag} needs a repository to fetch from, and this UI does not declare one`,\n ` pass it: ${invocation()} ui-update --repo ${DEFAULT_REPO} ${flag} ${values[values.tag !== undefined ? 'tag' : 'asset']}`,\n ].join('\\n'))\n }\n\n // `--check` first: it installs nothing, so `--check --tag x` must not install x.\n if (values.check === true && repo !== null) {\n if (isOwnRepo(repo)) {\n const target = values.tag ?? `v${context.version}`\n printCheck(io, installed, target)\n return\n }\n const releases = await fetchReleases(repo, context)\n const asset = impliedAsset(installed)\n printCheck(io, installed, null, asset === null ? [] : usableCandidates(releases, asset, order, installed.tag))\n return\n }\n\n if (values.tag !== undefined && repo !== null) {\n await installTag(repo, installed.asset, values.tag, context)\n return\n }\n\n let releases: Array<{ tag: string, assets: Array<{ name?: string }> }> = []\n if (repo !== null && !isOwnRepo(repo))\n releases = await fetchReleases(repo, context)\n\n const plan = planUiUpdate(installed, `v${context.version}`, releases, order)\n if (plan.kind === 'unidentifiable') {\n io.write(`${io.style.bold('this UI does not say where it came from')} — nothing to follow automatically\\n`)\n printIdentity(io, plan.identity)\n io.write(` ${io.style.dim(`point it at a repo to make this work: ${invocation()} ui-update --repo owner/name`)}\\n`)\n return\n }\n\n if (plan.kind === 'official') {\n if (plan.identity.tag === plan.target) {\n io.write(`${io.style.green('already current')} — ${io.style.bold(plan.identity.name)} is at ${plan.target}\\n`)\n return\n }\n\n io.write(`${io.style.bold(`${plan.identity.name} ${plan.identity.version ?? ''}`.trim())} is on ${plan.identity.tag ?? 'an unknown tag'}; this panel is ${plan.target} — updating\\n`)\n await installTag(repo!, installed.asset, plan.target, context)\n return\n }\n\n if (plan.kind !== 'choice')\n return\n\n io.write(`${io.style.bold(plan.identity.name)} ${plan.identity.version ?? ''} — ${repoSlug(repo!)}@${plan.identity.tag ?? 'unknown tag'}\\n`)\n io.write(` ${io.style.dim(`asset: ${plan.asset}`)}\\n`)\n\n if (plan.candidates.length === 0) {\n const direction = order === 'newer' ? 'newer' : 'older'\n io.write(`no ${direction} releases carry ${plan.asset}\\n`)\n if (order === 'newer')\n // `invocation()` carries `--home`.\n io.write(` ${io.style.dim(`list older releases with: ${invocation()} ui-update --old`)}\\n`)\n return\n }\n\n const chosen = await chooseCandidate(plan.candidates, context, order)\n if (chosen === null) {\n io.write('cancelled — nothing was installed\\n')\n return\n }\n\n await installTag(repo!, chosen.asset, chosen.tag, context)\n}\n\nfunction identityOf(meta: UiMeta | null): UiIdentity | null {\n if (meta === null)\n return null\n return {\n name: meta.name ?? 'custom-ui',\n version: meta.version ?? null,\n repo: meta.repo ?? null,\n tag: meta.tag ?? null,\n asset: meta.asset ?? null,\n unix: meta.unix ?? null,\n }\n}\n\nfunction printIdentity(io: { write: (text: string) => void }, identity: UiIdentity): void {\n io.write(` name ${identity.name}\\n`)\n io.write(` version ${identity.version ?? 'unspecified'}\\n`)\n io.write(` repo ${identity.repo ?? 'unspecified'}${identity.tag === null ? '' : ` @ ${identity.tag}`}\\n`)\n if (identity.unix !== null)\n io.write(` built ${formatDateTimeIso(identity.unix * 1000)}\\n`)\n}\n\nfunction printCheck(\n io: { write: (text: string) => void, style: { dim: (text: string) => string, green: (text: string) => string } },\n identity: UiIdentity,\n target: string | null,\n candidates: UpdateCandidate[] = [],\n): void {\n if (target !== null) {\n if (identity.tag === target) {\n io.write(`${io.style.green('up to date')} — ${identity.version ?? identity.name} at ${target}\\n`)\n return\n }\n io.write(`update available: ${identity.tag ?? 'unknown'} → ${target}\\n`)\n return\n }\n if (candidates.length === 0) {\n io.write(`up to date — no release carries ${identity.asset ?? identity.name}.zip\\n`)\n return\n }\n io.write(`${candidates.length} release(s) available:\\n`)\n for (const candidate of candidates)\n io.write(` ${candidate.tag} ${io.style.dim(candidate.asset)}\\n`)\n}\n\nasync function chooseCandidate(candidates: UpdateCandidate[], context: UpdateContext, order: 'newer' | 'older'): Promise<UpdateCandidate | null> {\n const headline = order === 'newer' ? 'Newer releases' : 'Older releases'\n const { io } = context\n io.write(`${io.style.bold(headline)}\\n`)\n for (const [index, candidate] of candidates.entries())\n io.write(` ${index + 1}) ${candidate.tag}\\n`)\n\n if (context.ask === null) {\n if (candidates.length === 1)\n return candidates[0]!\n throw new Error([\n `${candidates.length} releases are available and this session cannot ask which one:`,\n ...candidates.map(candidate => ` ${candidate.tag}`),\n ' run it in a terminal, or pass --tag <tag>',\n ].join('\\n'))\n }\n\n for (;;) {\n const answer = (await context.ask(`Select a release [1-${candidates.length}] (empty to cancel) `)).trim()\n if (answer.length === 0)\n return null\n if (/^\\d+$/.test(answer)) {\n const index = Number.parseInt(answer, 10)\n if (index >= 1 && index <= candidates.length)\n return candidates[index - 1]!\n }\n const byTag = candidates.find(candidate => candidate.tag === answer)\n if (byTag !== undefined)\n return byTag\n io.write(` ${io.style.dim(`no such choice — enter 1-${candidates.length} or a tag`)}\\n`)\n }\n}\n\nasync function installTag(\n repo: { owner: string, name: string },\n wantedAsset: string | null,\n tag: string,\n context: UpdateContext,\n): Promise<void> {\n const release = await fetchRelease(repo, tag, context)\n const names = release.assets.map(asset => asset.name ?? '').filter(isUiAsset)\n\n let assetName: string\n if (wantedAsset !== null && wantedAsset.length > 0) {\n const matched = matchAsset(names, wantedAsset)\n if (!matched.ok)\n throw new Error(`${matched.error}\\n in ${repo.owner}/${repo.name}@${release.tag}`)\n assetName = matched.name\n }\n else if (names.length === 1) {\n assetName = names[0]!\n }\n else {\n throw new Error(`${names.length} UI assets in ${repo.owner}/${repo.name}@${release.tag} — name one with --asset`)\n }\n\n const asset = release.assets.find(entry => entry.name === assetName)!\n const { UiService } = await import('#src/services/ui')\n const { installReleaseAsset } = await import('#src/services/ui-update')\n const { hhDir: dataRoot } = await import('#src/helpers/paths')\n // Record the fetched release's tag: a zip is built before its release is cut, so its own tag is stale.\n const result = await installReleaseAsset(new UiService({ dataRoot }), {\n url: assetDownloadUrl(asset),\n fallbackName: assetName,\n tag: release.tag,\n digest: asset.digest,\n context,\n })\n\n if (!result.ok)\n throw new Error(`nothing was installed: ${result.error}`)\n\n const { meta } = result\n const { io } = context\n io.write(`${io.style.green('UI updated')} — ${meta.name} ${meta.version ?? ''} at ${release.tag}\\n`)\n io.write(` ${io.style.dim('refresh the browser to see it')}\\n`)\n}\n\n/** Parsing and messages stay in the plain function so they can be exercised without a terminal. */\nexport const uiUpdateCommand = defineCommand({\n meta: { name: 'ui-update' },\n run: async ({ rawArgs }) => {\n await uiUpdate(rawArgs, {\n write: text => process.stdout.write(text),\n prompt,\n style,\n })\n },\n})\n"],"mappings":";;;;;;;;AAyDA,SAAgB,iBACd,UACA,OACA,OACA,YACmB;CACnB,MAAM,QAA2B,CAAC;CAElC,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,OAAO,KAAI,UAAS,MAAM,QAAQ,EAAE,CAAC,CAAC,OAAO,SAAS;EAC5E,MAAM,UAAU,WAAW,OAAO,KAAK;EACvC,IAAI,CAAC,QAAQ,IACX;EACF,IAAI,eAAe,MAAM;GACvB,MAAM,aAAa,YAAY,QAAQ,KAAK,UAAU;GACtD,IAAI,UAAU,WAAW,cAAc,GACrC;GACF,IAAI,UAAU,WAAW,cAAc,GACrC;EACJ;EACA,MAAM,KAAK;GAAE,KAAK,QAAQ;GAAK,OAAO,QAAQ;EAAK,CAAC;CACtD;CAEA,OAAO;AACT;AAEA,SAAgB,aAAa,UAAqC;CAChE,IAAI,SAAS,UAAU,QAAQ,SAAS,MAAM,SAAS,GACrD,OAAO,SAAS;CAClB,IAAI,SAAS,KAAK,SAAS,GACzB,OAAO,GAAG,SAAS,KAAK;CAC1B,OAAO;AACT;;AAGA,SAAgB,aACd,WACA,YACA,WAAqE,CAAC,GACtE,QAA2B,SACb;CACd,IAAI,cAAc,MAChB,OAAO,EAAE,MAAM,QAAQ;CAEzB,MAAM,OAAO,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EAAE,MAAM,YAAY;CAC1B,KAAK,OAAO,EAAE,cAAc;EAC1B,MAAM,SAAS,SAAS;GACtB,QAAO,SAAQ,QAAQ,OAAO,MAAM,IAAI;GACxC;GACA;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { E as errorMessage, t as appVersion } from "../cli.js";
|
|
2
|
+
import { t as logger } from "./logger-BnrKTBHQ.js";
|
|
3
|
+
import { _ as verifyAssetDigest, a as downloadHeaders, c as fetchRelease, d as isUiAsset, f as matchAsset, h as parseRepoSlug, n as assetDownloadUrl, o as downloadToTemp, t as DEFAULT_REPO, u as isOwnRepo } from "./ui-release-XbJ85pYI.js";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
//#region src/services/ui-update.ts
|
|
7
|
+
/** Only an official UI that declares its repo; anything else is left for `home-hosted ui-update`. */
|
|
8
|
+
function officialTagFor(meta, runningVersion) {
|
|
9
|
+
if (meta === null || typeof meta.repo !== "string") return null;
|
|
10
|
+
const repo = parseRepoSlug(meta.repo);
|
|
11
|
+
if (repo === null || !isOwnRepo(repo)) return null;
|
|
12
|
+
return {
|
|
13
|
+
tag: `v${runningVersion}`,
|
|
14
|
+
repo: `${repo.owner}/${repo.name}`
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** The one download-and-install path `ui-switch`, `ui-update` and the startup sync share. */
|
|
18
|
+
async function installReleaseAsset(ui, install) {
|
|
19
|
+
const download = await downloadToTemp(install.url, downloadHeaders(install.url, install.context), install.context);
|
|
20
|
+
try {
|
|
21
|
+
await verifyAssetDigest(download.file, install.digest);
|
|
22
|
+
return await ui.install(download.file, install.fallbackName, install.tag, { unlessChanged: install.unlessChanged });
|
|
23
|
+
} finally {
|
|
24
|
+
fs.rmSync(download.dir, {
|
|
25
|
+
recursive: true,
|
|
26
|
+
force: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function syncOfficialUi(ui, runningVersion = appVersion()) {
|
|
31
|
+
if (!ui.custom) return { kind: "not-custom" };
|
|
32
|
+
const meta = ui.readMeta();
|
|
33
|
+
if (meta === null) return { kind: "no-identity" };
|
|
34
|
+
const repo = meta.repo === void 0 ? null : parseRepoSlug(meta.repo);
|
|
35
|
+
if (repo === null) return { kind: "no-identity" };
|
|
36
|
+
if (!isOwnRepo(repo)) return { kind: "foreign" };
|
|
37
|
+
const target = `v${runningVersion}`;
|
|
38
|
+
if (meta.tag === target) return {
|
|
39
|
+
kind: "current",
|
|
40
|
+
tag: target
|
|
41
|
+
};
|
|
42
|
+
const context = {
|
|
43
|
+
io: {
|
|
44
|
+
write: () => {},
|
|
45
|
+
style: {
|
|
46
|
+
bold: (t) => t,
|
|
47
|
+
dim: (t) => t,
|
|
48
|
+
green: (t) => t
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
version: runningVersion,
|
|
52
|
+
token: process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN ?? null,
|
|
53
|
+
quiet: true
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
const release = await fetchRelease(repo, target, context);
|
|
57
|
+
const names = release.assets.map((asset) => asset.name ?? "").filter(isUiAsset);
|
|
58
|
+
const failure = (error) => ({
|
|
59
|
+
kind: "failed",
|
|
60
|
+
error
|
|
61
|
+
});
|
|
62
|
+
if (names.length === 0) return failure(`no UI asset in ${DEFAULT_REPO}@${release.tag}`);
|
|
63
|
+
const wanted = meta.asset ?? "";
|
|
64
|
+
const matched = wanted.length > 0 ? matchAsset(names, wanted) : {
|
|
65
|
+
ok: true,
|
|
66
|
+
name: names[0]
|
|
67
|
+
};
|
|
68
|
+
if (!matched.ok) return failure(matched.error);
|
|
69
|
+
const asset = release.assets.find((entry) => entry.name === matched.name);
|
|
70
|
+
if (asset === void 0) return failure(`no asset named ${matched.name} in ${release.tag}`);
|
|
71
|
+
const decidedOn = JSON.stringify(meta);
|
|
72
|
+
const result = await installReleaseAsset(ui, {
|
|
73
|
+
url: assetDownloadUrl(asset),
|
|
74
|
+
fallbackName: matched.name.replace(/\.zip$/i, ""),
|
|
75
|
+
tag: release.tag,
|
|
76
|
+
digest: asset.digest,
|
|
77
|
+
context,
|
|
78
|
+
unlessChanged: () => JSON.stringify(ui.readMeta()) === decidedOn ? null : "the installed UI changed while the update downloaded — it was kept"
|
|
79
|
+
});
|
|
80
|
+
if (!result.ok) return failure(result.error);
|
|
81
|
+
return {
|
|
82
|
+
kind: "updated",
|
|
83
|
+
tag: release.tag
|
|
84
|
+
};
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
kind: "failed",
|
|
88
|
+
error: errorMessage(error)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** The startup hook: never awaited, never throws; the next request picks up the new UI. */
|
|
93
|
+
function autoUpdateOfficialUi(ui, runningVersion = appVersion()) {
|
|
94
|
+
if (!ui.custom) return;
|
|
95
|
+
const meta = ui.readMeta();
|
|
96
|
+
const plan = officialTagFor(meta, runningVersion);
|
|
97
|
+
if (plan === null || meta?.tag === plan.tag) return;
|
|
98
|
+
logger.info(`ui: ${meta?.name ?? "custom UI"} ${meta?.version ?? ""} came from ${meta?.tag ?? "an unknown release"}; this panel is ${plan.tag} — updating`);
|
|
99
|
+
syncOfficialUi(ui, runningVersion).then((result) => {
|
|
100
|
+
if (result.kind === "updated") logger.info(`ui: updated to ${result.tag} — refresh the browser`);
|
|
101
|
+
else if (result.kind === "failed") logger.warn(`ui: could not update to ${plan.tag}: ${result.error}`);
|
|
102
|
+
}).catch((error) => {
|
|
103
|
+
logger.warn(`ui: could not update: ${errorMessage(error)}`);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { autoUpdateOfficialUi, installReleaseAsset };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=ui-update-CAiH2tFb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-update-CAiH2tFb.js","names":[],"sources":["../../src/services/ui-update.ts"],"sourcesContent":["import type { UiSourceContext } from '#src/providers/ui-release'\nimport type { UiInstallResult, UiService } from '#src/services/ui'\nimport fs from 'node:fs'\nimport process from 'node:process'\nimport { logger } from '#src/helpers/logger'\nimport { appVersion } from '#src/helpers/version'\nimport {\n assetDownloadUrl,\n DEFAULT_REPO,\n downloadHeaders,\n downloadToTemp,\n fetchRelease,\n isOwnRepo,\n isUiAsset,\n matchAsset,\n parseRepoSlug,\n verifyAssetDigest,\n} from '#src/providers/ui-release'\nimport { errorMessage } from '#src/shared/error-message'\n\n/**\n * Keeps an *official* UI on the panel's own release tag; someone else's UI is left alone. Installs by\n * tag only, and every failure is a log line: a UI problem must never stop the panel serving.\n */\n\nexport type UiSyncResult = { kind: 'not-custom' }\n | { kind: 'foreign' }\n | { kind: 'no-identity' }\n | { kind: 'current', tag: string }\n | { kind: 'updated', tag: string }\n | { kind: 'failed', error: string }\n\n/** Only an official UI that declares its repo; anything else is left for `home-hosted ui-update`. */\nexport function officialTagFor(\n meta: { repo?: string, tag?: string } | null,\n runningVersion: string,\n): { tag: string, repo: string } | null {\n if (meta === null || typeof meta.repo !== 'string')\n return null\n const repo = parseRepoSlug(meta.repo)\n if (repo === null || !isOwnRepo(repo))\n return null\n return { tag: `v${runningVersion}`, repo: `${repo.owner}/${repo.name}` }\n}\n\nexport interface ReleaseAssetInstall {\n url: string\n /** The install's name when the archive carries no `ui.json`. */\n fallbackName: string\n /** The release the asset came from, recorded instead of the one inside the archive. */\n tag?: string\n /** The asset's `digest` from the release metadata, verified when present. */\n digest?: string | null\n context: UiSourceContext\n unlessChanged?: () => string | null\n}\n\n/** The one download-and-install path `ui-switch`, `ui-update` and the startup sync share. */\nexport async function installReleaseAsset(ui: UiService, install: ReleaseAssetInstall): Promise<UiInstallResult> {\n const download = await downloadToTemp(install.url, downloadHeaders(install.url, install.context), install.context)\n try {\n await verifyAssetDigest(download.file, install.digest)\n return await ui.install(download.file, install.fallbackName, install.tag, { unlessChanged: install.unlessChanged })\n }\n finally {\n fs.rmSync(download.dir, { recursive: true, force: true })\n }\n}\n\nexport async function syncOfficialUi(ui: UiService, runningVersion = appVersion()): Promise<UiSyncResult> {\n if (!ui.custom)\n return { kind: 'not-custom' }\n\n const meta = ui.readMeta()\n if (meta === null)\n return { kind: 'no-identity' }\n\n const repo = meta.repo === undefined ? null : parseRepoSlug(meta.repo)\n if (repo === null)\n return { kind: 'no-identity' }\n if (!isOwnRepo(repo))\n return { kind: 'foreign' }\n\n const target = `v${runningVersion}`\n if (meta.tag === target)\n return { kind: 'current', tag: target }\n\n const context: UiSourceContext = {\n io: { write: () => {}, style: { bold: (t: string) => t, dim: (t: string) => t, green: (t: string) => t } },\n version: runningVersion,\n // Without a token, a shared or CI address hits GitHub's 60/hour unauthenticated limit.\n token: process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN ?? null,\n quiet: true,\n }\n\n try {\n const release = await fetchRelease(repo, target, context)\n const names = release.assets.map(asset => asset.name ?? '').filter(isUiAsset)\n\n const failure = (error: string): UiSyncResult => ({ kind: 'failed', error })\n\n if (names.length === 0)\n return failure(`no UI asset in ${DEFAULT_REPO}@${release.tag}`)\n\n // The asset this UI came from, or the only one on offer when it never said.\n const wanted = meta.asset ?? ''\n const matched = wanted.length > 0 ? matchAsset(names, wanted) : { ok: true as const, name: names[0]! }\n if (!matched.ok)\n return failure(matched.error)\n\n const asset = release.assets.find(entry => entry.name === matched.name)\n if (asset === undefined)\n return failure(`no asset named ${matched.name} in ${release.tag}`)\n\n // A UI a person installs while this downloads wins: the swap is refused if the meta changed.\n const decidedOn = JSON.stringify(meta)\n const result = await installReleaseAsset(ui, {\n url: assetDownloadUrl(asset),\n fallbackName: matched.name.replace(/\\.zip$/i, ''),\n // The tag is the release we just fetched, never what the archive claims.\n tag: release.tag,\n digest: asset.digest,\n context,\n unlessChanged: () => JSON.stringify(ui.readMeta()) === decidedOn ? null : 'the installed UI changed while the update downloaded — it was kept',\n })\n if (!result.ok)\n return failure(result.error)\n\n return { kind: 'updated', tag: release.tag }\n }\n catch (error) {\n return { kind: 'failed', error: errorMessage(error) }\n }\n}\n\n/** The startup hook: never awaited, never throws; the next request picks up the new UI. */\nexport function autoUpdateOfficialUi(ui: UiService, runningVersion = appVersion()): void {\n if (!ui.custom)\n return\n\n const meta = ui.readMeta()\n const plan = officialTagFor(meta, runningVersion)\n if (plan === null || meta?.tag === plan.tag)\n return\n\n logger.info(`ui: ${meta?.name ?? 'custom UI'} ${meta?.version ?? ''} came from ${meta?.tag ?? 'an unknown release'}; this panel is ${plan.tag} — updating`)\n\n void syncOfficialUi(ui, runningVersion).then((result) => {\n if (result.kind === 'updated')\n logger.info(`ui: updated to ${result.tag} — refresh the browser`)\n else if (result.kind === 'failed')\n logger.warn(`ui: could not update to ${plan.tag}: ${result.error}`)\n }).catch((error: unknown) => {\n logger.warn(`ui: could not update: ${errorMessage(error)}`)\n })\n}\n"],"mappings":";;;;;;;AAiCA,SAAgB,eACd,MACA,gBACsC;CACtC,IAAI,SAAS,QAAQ,OAAO,KAAK,SAAS,UACxC,OAAO;CACT,MAAM,OAAO,cAAc,KAAK,IAAI;CACpC,IAAI,SAAS,QAAQ,CAAC,UAAU,IAAI,GAClC,OAAO;CACT,OAAO;EAAE,KAAK,IAAI;EAAkB,MAAM,GAAG,KAAK,MAAM,GAAG,KAAK;CAAO;AACzE;;AAeA,eAAsB,oBAAoB,IAAe,SAAwD;CAC/G,MAAM,WAAW,MAAM,eAAe,QAAQ,KAAK,gBAAgB,QAAQ,KAAK,QAAQ,OAAO,GAAG,QAAQ,OAAO;CACjH,IAAI;EACF,MAAM,kBAAkB,SAAS,MAAM,QAAQ,MAAM;EACrD,OAAO,MAAM,GAAG,QAAQ,SAAS,MAAM,QAAQ,cAAc,QAAQ,KAAK,EAAE,eAAe,QAAQ,cAAc,CAAC;CACpH,UACQ;EACN,GAAG,OAAO,SAAS,KAAK;GAAE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