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
|
@@ -1,41 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as tlsDir,
|
|
3
|
-
import { n as GlobalSettingsStore } from "./settings-
|
|
4
|
-
import {
|
|
5
|
-
import { n as WorkspaceRegistry } from "./workspaces-
|
|
6
|
-
import {
|
|
1
|
+
import { E as errorMessage, _ as paint, b as promptHidden, f as dim, g as invocation, h as green, l as bold, p as fail, v as printJson, y as prompt } from "../cli.js";
|
|
2
|
+
import { C as tlsDir, F as workspacesPath, a as globalSecretsPath, c as hhDir, i as ensureStateDir, o as globalSettingsPath, x as resolveUserPath } from "./paths-C34-TJLh.js";
|
|
3
|
+
import { n as GlobalSettingsStore } from "./settings-CtYDs5PX.js";
|
|
4
|
+
import { t as WorkspaceStore } from "./store-Bs_Lljjm.js";
|
|
5
|
+
import { n as WorkspaceRegistry } from "./workspaces-D9akpzU8.js";
|
|
6
|
+
import { a as unknownBackupIds, d as writeEntryState, l as entryStatePath, n as buildBackupSources, t as BackupService, u as readEntryState } from "./backups-BrrN6cwW.js";
|
|
7
|
+
import { _ as readNannyState } from "./nanny-DGTXVq5d.js";
|
|
8
|
+
import { r as formatDateTimeIso } from "./ui-format-CDvvqOoi.js";
|
|
7
9
|
import process from "node:process";
|
|
8
10
|
import { defineCommand } from "citty";
|
|
9
11
|
import path from "node:path";
|
|
10
12
|
import fs from "node:fs";
|
|
11
13
|
//#region src/cli/backup-offline.ts
|
|
12
14
|
/**
|
|
13
|
-
* A backup service for a host whose panel is
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* restoring meant leaving the panel up — the opposite of what someone migrating a machine wants.
|
|
17
|
-
* Nothing in the service needs the daemon: every source is a file, and the one live fact it wants
|
|
18
|
-
* (which entries are running) is on disk as the nanny state each entry writes.
|
|
19
|
-
*
|
|
20
|
-
* This builds the same sources the panel does, through the same `buildBackupSources`, so an offline
|
|
21
|
-
* archive cannot differ from an online one. `runningServers` is answered from `.state/*.json` rather
|
|
22
|
-
* than from supervisor views: a *persistent* entry keeps running when the panel stops, so "no panel"
|
|
23
|
-
* does not mean "nothing is running", and the restore warning has to keep telling the truth.
|
|
15
|
+
* A backup service for a host whose panel is not running, built through the same
|
|
16
|
+
* `buildBackupSources` so an offline archive cannot differ from an online one. Running entries come
|
|
17
|
+
* from `.state/*.json`: a persistent entry keeps running when the panel stops.
|
|
24
18
|
*/
|
|
25
|
-
/** The workspace ids this host knows, from the registry on disk. */
|
|
26
19
|
function workspaceIds(registry) {
|
|
27
20
|
return registry.all().map((workspace) => ({
|
|
28
21
|
id: workspace.id,
|
|
29
22
|
label: workspace.label
|
|
30
23
|
}));
|
|
31
24
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Entries whose nanny is alive right now, read from the state files they rewrite.
|
|
34
|
-
*
|
|
35
|
-
* Every path comes from `hhDir`, never from the module-level helpers: those resolve from this
|
|
36
|
-
* process's own `HHOSTED_HOME`, so a caller passing `--home` elsewhere would read a different host's
|
|
37
|
-
* state — which is exactly how a test came to depend on the developer's real `~/.home-hosted`.
|
|
38
|
-
*/
|
|
25
|
+
/** Entries whose nanny is alive, from the state files. Every path comes from `hhDir`, never the module-level helpers. */
|
|
39
26
|
function runningFromDisk(hhDir, ids) {
|
|
40
27
|
const running = [];
|
|
41
28
|
for (const workspaceId of ids) {
|
|
@@ -61,12 +48,8 @@ function runningFromDisk(hhDir, ids) {
|
|
|
61
48
|
return running;
|
|
62
49
|
}
|
|
63
50
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `ensureWorkspace` and `onRestored` are the two panel hooks, and both are deliberately absent: with
|
|
67
|
-
* no daemon there is nothing to reload, and a restore that brings a workspace this host lacks leaves
|
|
68
|
-
* it on disk for the next `up` to pick up. The registry is written by the service itself, which is
|
|
69
|
-
* what makes that work.
|
|
51
|
+
* `onRestored` is absent (nothing to reload); `ensureWorkspace` writes the registry
|
|
52
|
+
* itself, so the next `up` picks up a restored workspace.
|
|
70
53
|
*/
|
|
71
54
|
function createOfflineBackup(options = {}) {
|
|
72
55
|
const hhDir$1 = options.hhDir ?? hhDir;
|
|
@@ -82,6 +65,7 @@ function createOfflineBackup(options = {}) {
|
|
|
82
65
|
const dir = path.join(hhDir$1, workspace.id);
|
|
83
66
|
const settingsPath = path.join(dir, "settings.json");
|
|
84
67
|
const serversPath = path.join(dir, "servers.config.json");
|
|
68
|
+
const jobsPath = path.join(dir, "jobs.config.json");
|
|
85
69
|
const secretsPath = path.join(dir, ".secrets.json");
|
|
86
70
|
const store = new WorkspaceStore(workspace.id, settingsPath, serversPath);
|
|
87
71
|
store.load({ write: false });
|
|
@@ -90,6 +74,7 @@ function createOfflineBackup(options = {}) {
|
|
|
90
74
|
label: workspace.label,
|
|
91
75
|
settingsPath,
|
|
92
76
|
serversPath,
|
|
77
|
+
jobsPath,
|
|
93
78
|
secretsPath,
|
|
94
79
|
servers: store.servers
|
|
95
80
|
};
|
|
@@ -98,19 +83,6 @@ function createOfflineBackup(options = {}) {
|
|
|
98
83
|
service: new BackupService({
|
|
99
84
|
dataRoot: hhDir$1,
|
|
100
85
|
getConfig: () => settings.backups,
|
|
101
|
-
/**
|
|
102
|
-
* Register a workspace the archive brought.
|
|
103
|
-
*
|
|
104
|
-
* A panel-only hook in the running case, because the panel creates the runtime itself. With no
|
|
105
|
-
* panel there is nobody to do it, so the registry is written here — otherwise a restored
|
|
106
|
-
* workspace's files land on disk unreachable, and the next `up` never looks at them.
|
|
107
|
-
*/
|
|
108
|
-
/**
|
|
109
|
-
* Record the staged dump so the entry's next `up` loads it.
|
|
110
|
-
*
|
|
111
|
-
* Nothing is running to hold it in memory, so this is the only path that matters offline: the
|
|
112
|
-
* panel is started afterwards, reads the entry state, and runs the hook.
|
|
113
|
-
*/
|
|
114
86
|
onLoadPending: (workspaceId, serverId, dumpDir) => {
|
|
115
87
|
const dir = path.join(hhDir$1, workspaceId, ".state");
|
|
116
88
|
ensureStateDir(dir);
|
|
@@ -144,17 +116,9 @@ function createOfflineBackup(options = {}) {
|
|
|
144
116
|
}
|
|
145
117
|
//#endregion
|
|
146
118
|
//#region src/cli/backup.ts
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
* Every id is a colon-separated path, so the hierarchy is in the data and the renderer's only job is
|
|
151
|
-
* to show it: one row per prefix, each one level deeper than its parent. Depth is whatever the id
|
|
152
|
-
* says, not a fixed number of columns — `workspace:default:secrets:telegram` sits three deep, and a
|
|
153
|
-
* renderer that assumed two printed it beside its own parent.
|
|
154
|
-
*
|
|
155
|
-
* Both directions print through this, and so does the "what could I act on" list, so the three read
|
|
156
|
-
* alike. A row's note is the panel's own wording, passed through untouched.
|
|
157
|
-
*/
|
|
119
|
+
/** Pre-0.14 single-credential slots: listed by the service while empty, noise to anyone on accounts. */
|
|
120
|
+
var LEGACY_UNSET = /^global:secrets:(?:password|apiToken)$/;
|
|
121
|
+
/** Render plan ids (colon-separated paths) as a tree, one row per prefix. */
|
|
158
122
|
function printPlanTree(rows, out = (text) => process.stdout.write(text)) {
|
|
159
123
|
const known = new Set(rows.map((row) => row.id));
|
|
160
124
|
const nodes = /* @__PURE__ */ new Map();
|
|
@@ -163,6 +127,7 @@ function printPlanTree(rows, out = (text) => process.stdout.write(text)) {
|
|
|
163
127
|
if (existing !== void 0) return existing;
|
|
164
128
|
const created = {
|
|
165
129
|
note: null,
|
|
130
|
+
label: null,
|
|
166
131
|
children: /* @__PURE__ */ new Set()
|
|
167
132
|
};
|
|
168
133
|
nodes.set(id, created);
|
|
@@ -174,14 +139,19 @@ function printPlanTree(rows, out = (text) => process.stdout.write(text)) {
|
|
|
174
139
|
const id = segments.slice(0, depth).join(":");
|
|
175
140
|
const node = ensure(id);
|
|
176
141
|
if (depth > 1) ensure(segments.slice(0, depth - 1).join(":")).children.add(id);
|
|
177
|
-
if (depth === segments.length && known.has(row.id))
|
|
142
|
+
if (depth === segments.length && known.has(row.id)) {
|
|
143
|
+
node.note = row.note ?? null;
|
|
144
|
+
node.label = row.label ?? null;
|
|
145
|
+
}
|
|
178
146
|
}
|
|
179
147
|
}
|
|
180
148
|
const roots = [...nodes.keys()].filter((id) => !id.includes(":"));
|
|
181
149
|
const write = (id, depth) => {
|
|
182
150
|
const node = nodes.get(id);
|
|
183
151
|
if (node === void 0) return;
|
|
184
|
-
|
|
152
|
+
const padding = " ".repeat(depth);
|
|
153
|
+
const label = node.label === null || node.label === id.split(":").at(-1) ? "" : ` ${dim(node.label)}`;
|
|
154
|
+
out(`${padding}${depth === 1 ? "" : "- "}${id}${label}${node.note === null ? "" : ` ${dim(`(${node.note})`)}`}\n`);
|
|
185
155
|
for (const child of node.children) write(child, depth + 1);
|
|
186
156
|
};
|
|
187
157
|
for (const root of roots) write(root, 1);
|
|
@@ -191,9 +161,8 @@ function human(bytes) {
|
|
|
191
161
|
if (bytes < 1048576) return `${Math.round(bytes / 1024)} KB`;
|
|
192
162
|
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
193
163
|
}
|
|
194
|
-
/** The running panel's record, or a message saying what to do instead. */
|
|
195
164
|
async function livePanel() {
|
|
196
|
-
const daemon = await import("./daemon-
|
|
165
|
+
const daemon = await import("./daemon-BAAYUYQC.js");
|
|
197
166
|
const runtime = daemon.readRuntime();
|
|
198
167
|
if (runtime === null || !await daemon.runtimeIsAlive(runtime)) {
|
|
199
168
|
if (runtime !== null && await daemon.runtimeIsGone(runtime)) daemon.clearRuntime();
|
|
@@ -201,31 +170,18 @@ async function livePanel() {
|
|
|
201
170
|
}
|
|
202
171
|
return Object.assign(runtime, { request: daemon.requestControl });
|
|
203
172
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Whether to talk to a panel or work on the files directly.
|
|
206
|
-
*
|
|
207
|
-
* Both paths run the same service, so the only question is who owns the state: a live panel is the
|
|
208
|
-
* authority on what is running, and a stopped one has no opinion to disagree with.
|
|
209
|
-
*/
|
|
210
173
|
async function usesPanel() {
|
|
211
|
-
const daemon = await import("./daemon-
|
|
174
|
+
const daemon = await import("./daemon-BAAYUYQC.js");
|
|
212
175
|
const runtime = daemon.readRuntime();
|
|
213
176
|
if (runtime === null || !await daemon.runtimeIsAlive(runtime)) return false;
|
|
214
177
|
return (await daemon.probeRuntime(runtime)).reachable;
|
|
215
178
|
}
|
|
216
|
-
/** Exit on a non-200 control answer with the panel's own message, or the status. */
|
|
217
179
|
function failWithAnswer(answer) {
|
|
218
180
|
const body = answer.body;
|
|
219
181
|
if (body?.message !== void 0) fail(body.message);
|
|
220
182
|
fail(`the panel answered ${answer.status}`);
|
|
221
183
|
}
|
|
222
|
-
/**
|
|
223
|
-
* The flag combination, as far as it can be judged without asking the panel.
|
|
224
|
-
*
|
|
225
|
-
* `null` means "neither flag", which only the caller can resolve — it lists the available ids, and
|
|
226
|
-
* that needs a panel. Every other case is decided here, before any lookup, so a typo is refused
|
|
227
|
-
* whether or not anything is running.
|
|
228
|
-
*/
|
|
184
|
+
/** `null` means "neither flag"; every other combination is decided here, before any panel lookup. */
|
|
229
185
|
function parseScope(all, raw) {
|
|
230
186
|
if (all && raw !== void 0) fail("--include and --all are exclusive — pass one or the other");
|
|
231
187
|
if (all) return { kind: "all" };
|
|
@@ -237,19 +193,14 @@ function parseScope(all, raw) {
|
|
|
237
193
|
ids
|
|
238
194
|
};
|
|
239
195
|
}
|
|
240
|
-
/**
|
|
241
|
-
* The plan rows a scope selects, and an exclusion drops.
|
|
242
|
-
*
|
|
243
|
-
* `kind` is deliberately not part of this: it is the panel's label for a row, not an id, and every id
|
|
244
|
-
* the plan prints is already prefixed with it (`global:settings`, `workspace:default:servers`).
|
|
245
|
-
*/
|
|
246
|
-
/** Flatten a nested plan into the rows the tree renders. */
|
|
247
196
|
function flattenRows(rows) {
|
|
248
197
|
return rows.flatMap((row) => [{
|
|
249
198
|
id: row.id,
|
|
199
|
+
label: row.label,
|
|
250
200
|
note: row.note ?? null
|
|
251
|
-
}, ...(row.items ?? []).map((leaf) => ({
|
|
201
|
+
}, ...(row.items ?? []).filter((leaf) => !(leaf.included === false && LEGACY_UNSET.test(leaf.id))).map((leaf) => ({
|
|
252
202
|
id: leaf.id,
|
|
203
|
+
label: leaf.label,
|
|
253
204
|
note: leaf.note ?? null
|
|
254
205
|
}))]);
|
|
255
206
|
}
|
|
@@ -262,17 +213,7 @@ function filterEntries(entries, scope, exclude) {
|
|
|
262
213
|
items: entry.items.filter((leaf) => named(leaf.id) && !excluded(leaf.id))
|
|
263
214
|
});
|
|
264
215
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Refuse an id the plan does not have.
|
|
267
|
-
*
|
|
268
|
-
* An id that matches nothing is silently ignored by the service, which is right for an archive that
|
|
269
|
-
* simply does not carry something — and wrong for a typo: `--exclude global:secret` excludes nothing
|
|
270
|
-
* and says nothing, so the archive carries the credentials the person believed they had dropped.
|
|
271
|
-
*
|
|
272
|
-
* `action` decides the hint, because the two directions list their ids from different places: a
|
|
273
|
-
* create plan lists what this host declares, a restore plan lists what the archive holds — and the
|
|
274
|
-
* command that prints that one is a restore, not a create.
|
|
275
|
-
*/
|
|
216
|
+
/** Refuse an id the plan does not have: the service silently ignores it, so a typo would exclude nothing. */
|
|
276
217
|
function assertKnown(ids, entries, flag, action) {
|
|
277
218
|
if (ids === void 0) return;
|
|
278
219
|
const unknown = unknownBackupIds(ids, entries);
|
|
@@ -281,19 +222,13 @@ function assertKnown(ids, entries, flag, action) {
|
|
|
281
222
|
fail(`${flag} names ${unknown.map((id) => `"${id}"`).join(", ")}, which ${unknown.length === 1 ? "is" : "are"} not in this plan — ${hint}`);
|
|
282
223
|
}
|
|
283
224
|
}
|
|
284
|
-
/** `--exclude` parsed. An empty value is a mistake, not "exclude nothing". */
|
|
285
225
|
function parseExclude(raw) {
|
|
286
226
|
if (raw === void 0) return void 0;
|
|
287
227
|
const ids = raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
288
228
|
if (ids.length === 0) fail("--exclude is empty — name the ids to leave out, or drop the flag");
|
|
289
229
|
return ids;
|
|
290
230
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Neither flag given. Refused outright — the ids are a *bonus*, not the reason.
|
|
293
|
-
*
|
|
294
|
-
* The refusal must not depend on a panel being up: a mistyped command deserves the flag error, not
|
|
295
|
-
* "home-hosted is not running". So the list is best-effort, and a failure to produce it is silent.
|
|
296
|
-
*/
|
|
231
|
+
/** Neither flag given. The id list is best-effort, so the refusal does not depend on a panel being up. */
|
|
297
232
|
async function refuseWithoutScope(action, suffix) {
|
|
298
233
|
const rows = await availableRows(action, suffix).catch(() => []);
|
|
299
234
|
if (rows.length === 0) fail("name what to act on — pass --include <ids> or --all");
|
|
@@ -303,12 +238,6 @@ async function refuseWithoutScope(action, suffix) {
|
|
|
303
238
|
process.stderr.write("\n--exclude <ids> leaves those out: --all --exclude global:secrets\n");
|
|
304
239
|
process.exit(1);
|
|
305
240
|
}
|
|
306
|
-
/**
|
|
307
|
-
* The ids an offline run could act on, read from the state files.
|
|
308
|
-
*
|
|
309
|
-
* The refusal has to name real ids whether or not a panel is up — an empty list is the one answer
|
|
310
|
-
* worse than no list, because it reads as "there is nothing to back up".
|
|
311
|
-
*/
|
|
312
241
|
async function availableRowsFromDisk(action, suffix) {
|
|
313
242
|
try {
|
|
314
243
|
const { service } = createOfflineBackup();
|
|
@@ -324,15 +253,8 @@ async function availableRowsFromDisk(action, suffix) {
|
|
|
324
253
|
return [];
|
|
325
254
|
}
|
|
326
255
|
}
|
|
327
|
-
/**
|
|
328
|
-
* The ids this action could be scoped to.
|
|
329
|
-
*
|
|
330
|
-
* `create` asks what the entries declare; `restore` asks what the archive holds. Both come from the
|
|
331
|
-
* panel, so the list in a refusal is the real one rather than a hardcoded guess. A panel that cannot
|
|
332
|
-
* be reached yields no ids — the refusal still fires, it just cannot enumerate.
|
|
333
|
-
*/
|
|
334
256
|
async function availableRows(action, suffix) {
|
|
335
|
-
const daemon = await import("./daemon-
|
|
257
|
+
const daemon = await import("./daemon-BAAYUYQC.js");
|
|
336
258
|
const runtime = daemon.readRuntime();
|
|
337
259
|
if (runtime === null || !await daemon.runtimeIsAlive(runtime)) return await availableRowsFromDisk(action, suffix);
|
|
338
260
|
const path = action === "create" ? "/_hh/backups" : "/_hh/backups/restore";
|
|
@@ -341,21 +263,15 @@ async function availableRows(action, suffix) {
|
|
|
341
263
|
const body = answer.body;
|
|
342
264
|
return action === "create" ? body?.entries ?? [] : body?.items ?? [];
|
|
343
265
|
}
|
|
344
|
-
/** `?a=b`, or `''`. */
|
|
345
266
|
function suffixOf(query) {
|
|
346
267
|
return query.size === 0 ? "" : `?${query.toString()}`;
|
|
347
268
|
}
|
|
348
|
-
/** Appends one query parameter, keeping the `?`/`&` right. */
|
|
349
269
|
function withParam(suffix, key, value) {
|
|
350
270
|
return `${suffix}${suffix === "" ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
|
|
351
271
|
}
|
|
352
272
|
/**
|
|
353
|
-
* Ask before writing.
|
|
354
|
-
*
|
|
355
|
-
* A session that cannot be asked is refused, exit 1, after the plan: not a silent write, and not a
|
|
356
|
-
* success. Exiting 0 here meant a cron job's `backup create --all` printed a plan every night and
|
|
357
|
-
* never took a backup, with nothing in its exit status to say so. (`--json` without `--confirm` is
|
|
358
|
-
* the explicit "show me the plan" request and still exits 0; it never reaches this.)
|
|
273
|
+
* Ask before writing. A session that cannot be asked is refused (exit 1), not a silent write or a
|
|
274
|
+
* success, so a cron job without `--confirm` does not look like it took a backup.
|
|
359
275
|
*/
|
|
360
276
|
async function consent(question) {
|
|
361
277
|
if (process.stdin.isTTY !== true) fail("not applied — this session cannot ask for consent; re-run with --confirm to apply (or --json to only read the plan)");
|
|
@@ -367,13 +283,6 @@ async function consent(question) {
|
|
|
367
283
|
process.stdout.write("cancelled — nothing was written\n");
|
|
368
284
|
return false;
|
|
369
285
|
}
|
|
370
|
-
/**
|
|
371
|
-
* Run against the panel when one is up, and against the files when it is not.
|
|
372
|
-
*
|
|
373
|
-
* Both run the same `BackupService`, so the archive cannot differ; only the authority on what is
|
|
374
|
-
* running changes. A stopped panel is exactly when someone wants to back up or restore — the services
|
|
375
|
-
* are down because they stopped them on purpose.
|
|
376
|
-
*/
|
|
377
286
|
async function runBackupList(json) {
|
|
378
287
|
if (await usesPanel()) {
|
|
379
288
|
const runtime = await livePanel();
|
|
@@ -392,7 +301,7 @@ async function runBackupList(json) {
|
|
|
392
301
|
function printList(view, json) {
|
|
393
302
|
const files = view?.files ?? [];
|
|
394
303
|
if (json) {
|
|
395
|
-
|
|
304
|
+
printJson(view);
|
|
396
305
|
return;
|
|
397
306
|
}
|
|
398
307
|
if (files.length === 0) {
|
|
@@ -402,23 +311,21 @@ function printList(view, json) {
|
|
|
402
311
|
const noun = files.length === 1 ? "archive" : "archives";
|
|
403
312
|
process.stdout.write(`${bold(String(files.length))} ${noun}${view?.dir === void 0 ? "" : ` in ${dim(view.dir)}`}\n`);
|
|
404
313
|
for (const file of files) {
|
|
405
|
-
const when = file.createdAt == null ? "" :
|
|
314
|
+
const when = file.createdAt == null ? "" : formatDateTimeIso(file.createdAt);
|
|
406
315
|
process.stdout.write(` ${file.name.padEnd(36)} ${human(file.sizeBytes).padStart(8)} ${dim(when)}${file.automatic ? dim(" auto") : ""}\n`);
|
|
407
316
|
}
|
|
408
317
|
}
|
|
409
|
-
/**
|
|
410
|
-
* Name the entries still running, without blocking.
|
|
411
|
-
*
|
|
412
|
-
* A **persistent** entry keeps running while the panel is stopped, so "panel off" is not "services
|
|
413
|
-
* off" — and its data being captured mid-write is worth knowing before it is relied on. Warned rather
|
|
414
|
-
* than refused: the user may know, and the panel's own backup has always proceeded here.
|
|
415
|
-
*/
|
|
318
|
+
/** Name the entries still running: a persistent entry outlives the panel. Warned, not refused. */
|
|
416
319
|
function warnRunning(entries) {
|
|
417
320
|
if (entries.length === 0) return;
|
|
418
321
|
const named = entries.map((entry) => entry.serverId ?? entry.id ?? "").filter((name) => name.length > 0);
|
|
419
322
|
const isOne = named.length === 1;
|
|
420
323
|
process.stdout.write(`${dim(`! ${named.length} entr${isOne ? "y is" : "ies are"} still running (${named.join(", ")}) — its data may be captured mid-write`)}\n`);
|
|
421
324
|
}
|
|
325
|
+
/** One line per running entry whose declared data a restore replaces, grouped by entry. */
|
|
326
|
+
function replacedUnderRunningLines(list, applied) {
|
|
327
|
+
return [...new Set(list.map((entry) => entry.workspaceId === "default" ? entry.serverId : `${entry.workspaceId}/${entry.serverId}`))].map((label) => applied ? `! ${label} is running — its data was replaced under it; restart it` : `! ${label} is running — restoring replaces its data under it; restart it afterwards`);
|
|
328
|
+
}
|
|
422
329
|
async function runBackupCreate(options) {
|
|
423
330
|
const scope = options.scope;
|
|
424
331
|
const online = await usesPanel();
|
|
@@ -441,11 +348,11 @@ async function runBackupCreate(options) {
|
|
|
441
348
|
const wanted = filterEntries(entries, scope, options.exclude);
|
|
442
349
|
if (!options.confirm) {
|
|
443
350
|
if (options.json) {
|
|
444
|
-
|
|
351
|
+
printJson({
|
|
445
352
|
action: "create",
|
|
446
353
|
apply: false,
|
|
447
354
|
entries: wanted
|
|
448
|
-
}
|
|
355
|
+
});
|
|
449
356
|
return;
|
|
450
357
|
}
|
|
451
358
|
process.stdout.write(`${bold("Plan")} — what a backup would capture; nothing has been written yet\n`);
|
|
@@ -464,10 +371,9 @@ async function runBackupCreate(options) {
|
|
|
464
371
|
const runtime = await livePanel();
|
|
465
372
|
if (runtime !== null) {
|
|
466
373
|
const query = new URLSearchParams();
|
|
467
|
-
if (options.password !== void 0 && options.password.length > 0) query.set("password", options.password);
|
|
468
374
|
if (include !== void 0) query.set("include", include.join(","));
|
|
469
375
|
if (exclude !== void 0) query.set("exclude", exclude.join(","));
|
|
470
|
-
const answer = await runtime.request(runtime, `/_hh/backups${withParam(suffixOf(query), "confirm", "true")}`, 6e5);
|
|
376
|
+
const answer = await runtime.request(runtime, `/_hh/backups${withParam(suffixOf(query), "confirm", "true")}`, 6e5, "POST", void 0, passwordHeader(options.password));
|
|
471
377
|
if (answer === null) fail(`the control panel is not answering on ${runtime.probeUrl}`);
|
|
472
378
|
if (answer.status !== 200) failWithAnswer(answer);
|
|
473
379
|
return answer.body;
|
|
@@ -490,30 +396,24 @@ async function runBackupCreate(options) {
|
|
|
490
396
|
if (file === void 0) fail("the backup reported success but named no archive");
|
|
491
397
|
const warnings = created?.warnings ?? [];
|
|
492
398
|
if (options.json) {
|
|
493
|
-
|
|
399
|
+
printJson({
|
|
494
400
|
action: "create",
|
|
495
401
|
apply: true,
|
|
496
402
|
file,
|
|
497
403
|
...warnings.length === 0 ? {} : { warnings }
|
|
498
|
-
}
|
|
404
|
+
});
|
|
499
405
|
return;
|
|
500
406
|
}
|
|
501
407
|
process.stdout.write(`${green("backup created")} ${file.name} ${dim(`(${human(file.sizeBytes)})`)}\n`);
|
|
502
408
|
for (const warning of warnings) process.stderr.write(`warning: ${warning}\n`);
|
|
503
409
|
}
|
|
504
410
|
/**
|
|
505
|
-
* Why a restore plan is not something to apply, or `null`.
|
|
506
|
-
*
|
|
507
|
-
* The service answers a plan for every archive, including ones it refuses to read: `error` carries
|
|
508
|
-
* the refusal and `items` is empty. A caller that reads only `items` sees a tidy empty restore — and
|
|
509
|
-
* on a blank host, `restored 0 items` printed with exit 0 is the worst possible answer, because
|
|
510
|
-
* nothing distinguishes "this archive was empty" from "this archive could not be opened".
|
|
511
|
-
*
|
|
512
|
-
* `needsPassword` is its own case: it is the one refusal the person can fix from the same command.
|
|
411
|
+
* Why a restore plan is not something to apply, or `null`. A refused archive answers an empty plan,
|
|
412
|
+
* which must not read as "restored 0 items".
|
|
513
413
|
*/
|
|
514
414
|
function planRefusal(plan) {
|
|
515
415
|
if (plan === null) return null;
|
|
516
|
-
if (plan.needsPassword === true) return `${plan.error ?? "this backup is password-protected"} —
|
|
416
|
+
if (plan.needsPassword === true) return `${plan.error ?? "this backup is password-protected"} — set HHOSTED_BACKUP_PASSWORD, or run it at a terminal to be asked`;
|
|
517
417
|
if (plan.error !== void 0 && plan.error.length > 0) return plan.error;
|
|
518
418
|
return null;
|
|
519
419
|
}
|
|
@@ -521,15 +421,8 @@ async function runBackupRestore(options) {
|
|
|
521
421
|
const scope = options.scope;
|
|
522
422
|
const online = await usesPanel();
|
|
523
423
|
/**
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
* A name is an allowlist entry, which is why it is the default. `--from` is for the blank host
|
|
527
|
-
* where the archive is on a USB stick: it names the file to read, not a directory to write in.
|
|
528
|
-
* The two are refused together rather than one quietly winning — on the one command that
|
|
529
|
-
* overwrites live data, a guess about which archive was meant is the wrong default.
|
|
530
|
-
*
|
|
531
|
-
* The path is resolved against *this* process's directory; the panel would resolve a relative
|
|
532
|
-
* one against its own cwd, which is a different directory and so a different file.
|
|
424
|
+
* A name (an allowlist entry) or a `--from` path, never both. The path is resolved against this
|
|
425
|
+
* process's cwd, not the panel's.
|
|
533
426
|
*/
|
|
534
427
|
const source = options.from !== void 0 ? {
|
|
535
428
|
kind: "from",
|
|
@@ -538,12 +431,11 @@ async function runBackupRestore(options) {
|
|
|
538
431
|
kind: "name",
|
|
539
432
|
name: options.name ?? ""
|
|
540
433
|
};
|
|
541
|
-
/** What to call it in the plan and the result: the file it read, name or path. */
|
|
542
434
|
const label = source.kind === "from" ? path.basename(source.path) : source.name;
|
|
543
435
|
if (source.kind === "from" && (!fs.existsSync(source.path) || !fs.statSync(source.path).isFile())) fail(`no file at ${source.path} — \`--from\` takes the path to an archive on this machine`);
|
|
544
436
|
const service = online ? null : createOfflineBackup().service;
|
|
545
437
|
if (service !== null) await service.warm();
|
|
546
|
-
const
|
|
438
|
+
const readPlan = async () => {
|
|
547
439
|
if (service !== null) {
|
|
548
440
|
if (source.kind === "from") return await service.restore(source.path, {
|
|
549
441
|
confirm: false,
|
|
@@ -563,19 +455,24 @@ async function runBackupRestore(options) {
|
|
|
563
455
|
const runtime = await livePanel();
|
|
564
456
|
if (runtime === null) fail(`the control panel is not answering — try again once it is up`);
|
|
565
457
|
const base = restoreQuery(source, options, scope);
|
|
566
|
-
const answer = await runtime.request(runtime, `/_hh/backups/restore${suffixOf(base)}`, 12e4);
|
|
458
|
+
const answer = await runtime.request(runtime, `/_hh/backups/restore${suffixOf(base)}`, 12e4, "POST", void 0, passwordHeader(options.password));
|
|
567
459
|
if (answer === null) fail(`the control panel is not answering at ${runtime.probeUrl}`);
|
|
568
460
|
if (answer.status !== 200) failWithAnswer(answer);
|
|
569
461
|
return answer.body;
|
|
570
|
-
}
|
|
462
|
+
};
|
|
463
|
+
let plan = await readPlan();
|
|
464
|
+
if (plan?.needsPassword === true && options.password === void 0 && !options.json && process.stdin.isTTY === true) {
|
|
465
|
+
options.password = await promptHidden(`Password for ${label}: `);
|
|
466
|
+
plan = await readPlan();
|
|
467
|
+
}
|
|
571
468
|
const refused = planRefusal(plan);
|
|
572
469
|
if (refused !== null) {
|
|
573
|
-
if (options.json)
|
|
470
|
+
if (options.json) printJson({
|
|
574
471
|
action: "restore",
|
|
575
472
|
apply: false,
|
|
576
473
|
name: label,
|
|
577
474
|
error: refused
|
|
578
|
-
}
|
|
475
|
+
});
|
|
579
476
|
fail(refused);
|
|
580
477
|
}
|
|
581
478
|
const items = (plan?.items ?? []).filter((item) => item.selected !== false);
|
|
@@ -583,22 +480,26 @@ async function runBackupRestore(options) {
|
|
|
583
480
|
if (options.exclude !== void 0) assertKnown(options.exclude, archiveItems, "--exclude", "restore");
|
|
584
481
|
if (scope.kind === "include") assertKnown(scope.ids, archiveItems, "--include", "restore");
|
|
585
482
|
if (options.json && !options.confirm) {
|
|
586
|
-
|
|
483
|
+
printJson({
|
|
587
484
|
action: "restore",
|
|
588
485
|
apply: false,
|
|
589
486
|
name: label,
|
|
590
487
|
items,
|
|
591
488
|
skipped: plan?.skipped ?? []
|
|
592
|
-
}
|
|
489
|
+
});
|
|
593
490
|
return;
|
|
594
491
|
}
|
|
595
492
|
if (!options.json) {
|
|
596
493
|
process.stdout.write(options.confirm ? `${bold("Plan")} for ${label} — applying it now\n` : `${bold("Plan")} for ${label} — nothing has been written yet\n`);
|
|
597
494
|
printPlanTree(items.map((item) => ({
|
|
598
495
|
id: item.id,
|
|
496
|
+
label: item.label,
|
|
599
497
|
note: item.note ?? null
|
|
600
498
|
})));
|
|
601
|
-
if (!options.confirm)
|
|
499
|
+
if (!options.confirm) {
|
|
500
|
+
for (const note of plan?.skipped ?? []) process.stdout.write(` ${dim("!")} ${note}\n`);
|
|
501
|
+
for (const line of replacedUnderRunningLines(plan?.replacedUnderRunning ?? [], false)) process.stdout.write(` ${paint("33", line)}\n`);
|
|
502
|
+
}
|
|
602
503
|
if (items.length === 0) {
|
|
603
504
|
process.stdout.write(" (nothing to restore — check --include, or what this host declares)\n");
|
|
604
505
|
return;
|
|
@@ -623,7 +524,7 @@ async function runBackupRestore(options) {
|
|
|
623
524
|
const runtime = await livePanel();
|
|
624
525
|
if (runtime === null) fail("the control panel stopped answering — nothing further was written");
|
|
625
526
|
const base = restoreQuery(source, options, scope);
|
|
626
|
-
const answer = await runtime.request(runtime, `/_hh/backups/restore${withParam(suffixOf(base), "confirm", "true")}`, 6e5);
|
|
527
|
+
const answer = await runtime.request(runtime, `/_hh/backups/restore${withParam(suffixOf(base), "confirm", "true")}`, 6e5, "POST", void 0, passwordHeader(options.password));
|
|
627
528
|
if (answer === null) fail(`the control panel is not answering at ${runtime.probeUrl}`);
|
|
628
529
|
if (answer.status !== 200) failWithAnswer(answer);
|
|
629
530
|
const result = answer.body;
|
|
@@ -635,19 +536,19 @@ async function runBackupRestore(options) {
|
|
|
635
536
|
})();
|
|
636
537
|
const applyRefused = planRefusal(outcome);
|
|
637
538
|
if (applyRefused !== null) {
|
|
638
|
-
if (options.json)
|
|
539
|
+
if (options.json) printJson({
|
|
639
540
|
action: "restore",
|
|
640
541
|
apply: true,
|
|
641
542
|
name: label,
|
|
642
543
|
error: applyRefused
|
|
643
|
-
}
|
|
544
|
+
});
|
|
644
545
|
fail(applyRefused);
|
|
645
546
|
}
|
|
646
547
|
const applied = (outcome.items ?? []).filter((item) => item.selected !== false);
|
|
647
548
|
const hooks = (outcome.hooks ?? []).filter((hook) => hook.action === "load");
|
|
648
549
|
const notes = outcome.skipped ?? [];
|
|
649
550
|
if (options.json) {
|
|
650
|
-
|
|
551
|
+
printJson({
|
|
651
552
|
action: "restore",
|
|
652
553
|
apply: true,
|
|
653
554
|
name: label,
|
|
@@ -657,7 +558,7 @@ async function runBackupRestore(options) {
|
|
|
657
558
|
...outcome.restartRequired === true ? { restartRequired: true } : {},
|
|
658
559
|
...(outcome.createdWorkspaces ?? []).length === 0 ? {} : { createdWorkspaces: outcome.createdWorkspaces },
|
|
659
560
|
...(outcome.replacedUnderRunning ?? []).length === 0 ? {} : { replacedUnderRunning: outcome.replacedUnderRunning }
|
|
660
|
-
}
|
|
561
|
+
});
|
|
661
562
|
return;
|
|
662
563
|
}
|
|
663
564
|
if (applied.length === 0) process.stdout.write(`${green("restored")} nothing — the archive carried no item this host can take\n`);
|
|
@@ -665,28 +566,46 @@ async function runBackupRestore(options) {
|
|
|
665
566
|
for (const hook of hooks) process.stdout.write(` ${dim(`load ${hook.serverId}: ${hook.output ?? "staged"}`)}\n`);
|
|
666
567
|
for (const note of notes) process.stdout.write(` ${dim("!")} ${note}\n`);
|
|
667
568
|
if (outcome.restartRequired === true) process.stdout.write(` ${dim(`! the panel's listener changed — restart it so it binds where the archive says (\`${invocation()} restart\`)`)}\n`);
|
|
569
|
+
for (const line of replacedUnderRunningLines(outcome.replacedUnderRunning ?? [], true)) process.stdout.write(` ${paint("33", line)}\n`);
|
|
668
570
|
if ((outcome.createdWorkspaces ?? []).length > 0) process.stdout.write(` ${dim(`! created ${outcome.createdWorkspaces.join(", ")}, which this host did not have`)}\n`);
|
|
669
571
|
if (service !== null) process.stdout.write(dim(`the panel is not running, so nothing was reloaded — the next \`${invocation()} up\` reads what was restored\n`));
|
|
670
572
|
}
|
|
671
573
|
}
|
|
574
|
+
var BACKUP_PASSWORD_ENV = "HHOSTED_BACKUP_PASSWORD";
|
|
575
|
+
/** The password rides in a header: a query string is logged and visible to anything that reads URLs. */
|
|
576
|
+
function passwordHeader(password) {
|
|
577
|
+
return password === void 0 || password.length === 0 ? {} : { "x-home-hosted-backup-password": password };
|
|
578
|
+
}
|
|
672
579
|
/**
|
|
673
|
-
* The
|
|
674
|
-
*
|
|
675
|
-
* One builder, because the two requests must agree: a password or a selection on the plan and not on
|
|
676
|
-
* the apply made the apply answer about different items than the person approved.
|
|
580
|
+
* The archive password, kept out of shell history and `ps`: `HHOSTED_BACKUP_PASSWORD`, or a no-echo
|
|
581
|
+
* prompt for `--encrypt`. `--password <text>` still works, with a warning.
|
|
677
582
|
*/
|
|
583
|
+
async function backupPassword(flag, encrypt) {
|
|
584
|
+
if (flag !== void 0 && flag.length > 0) {
|
|
585
|
+
process.stderr.write(`${paint("33", "note")} --password is visible in shell history and the process list — set ${BACKUP_PASSWORD_ENV}, or use --encrypt to be asked\n`);
|
|
586
|
+
return flag;
|
|
587
|
+
}
|
|
588
|
+
const fromEnv = process.env[BACKUP_PASSWORD_ENV];
|
|
589
|
+
if (fromEnv !== void 0 && fromEnv.length > 0) return fromEnv;
|
|
590
|
+
if (!encrypt) return void 0;
|
|
591
|
+
if (process.stdin.isTTY !== true) fail(`--encrypt asks for the password at a terminal — set ${BACKUP_PASSWORD_ENV} for a script`);
|
|
592
|
+
const first = await promptHidden("Archive password: ");
|
|
593
|
+
if (first.length === 0) fail("an empty password encrypts nothing");
|
|
594
|
+
if (await promptHidden("Repeat it: ") !== first) fail("the passwords do not match");
|
|
595
|
+
return first;
|
|
596
|
+
}
|
|
597
|
+
/** One builder, so the plan and the apply ask about the same items. */
|
|
678
598
|
function restoreQuery(source, options, scope) {
|
|
679
599
|
const base = source.kind === "from" ? new URLSearchParams({ from: source.path }) : new URLSearchParams({ name: source.name });
|
|
680
|
-
if (options.password !== void 0 && options.password.length > 0) base.set("password", options.password);
|
|
681
600
|
if (scope.kind === "include") base.set("include", scope.ids.join(","));
|
|
682
601
|
if (options.exclude !== void 0) base.set("exclude", options.exclude.join(","));
|
|
683
602
|
return base;
|
|
684
603
|
}
|
|
685
|
-
/** What each action reads. Anything else given is refused, never parsed and dropped. */
|
|
686
604
|
var HONOURED = {
|
|
687
605
|
list: /* @__PURE__ */ new Set(["json"]),
|
|
688
606
|
create: /* @__PURE__ */ new Set([
|
|
689
607
|
"password",
|
|
608
|
+
"encrypt",
|
|
690
609
|
"include",
|
|
691
610
|
"exclude",
|
|
692
611
|
"all",
|
|
@@ -704,10 +623,6 @@ var HONOURED = {
|
|
|
704
623
|
"json"
|
|
705
624
|
])
|
|
706
625
|
};
|
|
707
|
-
/**
|
|
708
|
-
* A flag the action cannot honour is refused, not ignored: `backup list --all --include x` listed
|
|
709
|
-
* every archive, and `backup create foo --all` dropped `foo` without a word.
|
|
710
|
-
*/
|
|
711
626
|
function unhonouredBackupFlag(action, given) {
|
|
712
627
|
for (const flag of Object.keys(given)) {
|
|
713
628
|
if (given[flag] === void 0 || HONOURED[action].has(flag)) continue;
|
|
@@ -722,6 +637,7 @@ function refuseUnhonouredFlags(action, args) {
|
|
|
722
637
|
"target",
|
|
723
638
|
"from",
|
|
724
639
|
"password",
|
|
640
|
+
"encrypt",
|
|
725
641
|
"include",
|
|
726
642
|
"exclude",
|
|
727
643
|
"all",
|
|
@@ -753,7 +669,11 @@ var backupCommand = defineCommand({
|
|
|
753
669
|
},
|
|
754
670
|
password: {
|
|
755
671
|
type: "string",
|
|
756
|
-
description: "
|
|
672
|
+
description: "deprecated: visible in shell history and `ps` — use HHOSTED_BACKUP_PASSWORD or --encrypt"
|
|
673
|
+
},
|
|
674
|
+
encrypt: {
|
|
675
|
+
type: "boolean",
|
|
676
|
+
description: "create: encrypt the archive with a password asked for without echo"
|
|
757
677
|
},
|
|
758
678
|
include: {
|
|
759
679
|
type: "string",
|
|
@@ -787,7 +707,7 @@ var backupCommand = defineCommand({
|
|
|
787
707
|
else if (action === "create") {
|
|
788
708
|
const scope = parsed ?? await refuseWithoutScope("create", "");
|
|
789
709
|
await runBackupCreate({
|
|
790
|
-
password: args.password,
|
|
710
|
+
password: await backupPassword(args.password, args.encrypt === true),
|
|
791
711
|
scope,
|
|
792
712
|
exclude,
|
|
793
713
|
confirm: args.confirm === true,
|
|
@@ -804,7 +724,7 @@ var backupCommand = defineCommand({
|
|
|
804
724
|
await runBackupRestore({
|
|
805
725
|
...name === void 0 ? {} : { name },
|
|
806
726
|
...from === void 0 ? {} : { from },
|
|
807
|
-
password: args.password,
|
|
727
|
+
password: await backupPassword(args.password, false),
|
|
808
728
|
scope,
|
|
809
729
|
exclude,
|
|
810
730
|
confirm: args.confirm === true,
|
|
@@ -819,4 +739,4 @@ var backupCommand = defineCommand({
|
|
|
819
739
|
//#endregion
|
|
820
740
|
export { backupCommand };
|
|
821
741
|
|
|
822
|
-
//# sourceMappingURL=backup-
|
|
742
|
+
//# sourceMappingURL=backup-DnyxIzw0.js.map
|