@geekmidas/cli 10.0.0-alpha.65 → 10.0.0-alpha.67
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 +123 -177
- package/dist/{HostingerProvider-x9gQTAGZ.mjs → HostingerProvider-D85ayzTi.mjs} +4 -4
- package/dist/HostingerProvider-D85ayzTi.mjs.map +1 -0
- package/dist/{HostingerProvider-Dlmbfass.cjs → HostingerProvider-dxkwynSs.cjs} +4 -4
- package/dist/HostingerProvider-dxkwynSs.cjs.map +1 -0
- package/dist/{LegacyStateStore-BGoo__sO.cjs → LegacyStateStore-BZiO9-Lw.cjs} +2 -2
- package/dist/{LegacyStateStore-BGoo__sO.cjs.map → LegacyStateStore-BZiO9-Lw.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BUu1nQ5u.mjs → LegacyStateStore-C39UKwmf.mjs} +2 -2
- package/dist/{LegacyStateStore-BUu1nQ5u.mjs.map → LegacyStateStore-C39UKwmf.mjs.map} +1 -1
- package/dist/{LocalStateStore-93urXyQe.cjs → LocalStateStore-DHVsZLyF.cjs} +2 -2
- package/dist/{LocalStateStore-93urXyQe.cjs.map → LocalStateStore-DHVsZLyF.cjs.map} +1 -1
- package/dist/{LocalStateStore-BRhMQRuy.mjs → LocalStateStore-Dk3Wbvzk.mjs} +2 -2
- package/dist/{LocalStateStore-BRhMQRuy.mjs.map → LocalStateStore-Dk3Wbvzk.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BWuDRHe9.cjs → OpenApiTsGenerator-B2zrdyP4.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-BWuDRHe9.cjs.map → OpenApiTsGenerator-B2zrdyP4.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-C6v-IeHt.mjs → OpenApiTsGenerator-BmUAcR7d.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-C6v-IeHt.mjs.map → OpenApiTsGenerator-BmUAcR7d.mjs.map} +1 -1
- package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-Bllus2NR.cjs} +2 -2
- package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
- package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-QXxjkZO1.mjs} +2 -2
- package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
- package/dist/{S3StateStore-F4dxw6kS.cjs → S3StateStore--4tYVMAL.cjs} +2 -2
- package/dist/{S3StateStore-F4dxw6kS.cjs.map → S3StateStore--4tYVMAL.cjs.map} +1 -1
- package/dist/{S3StateStore-pw1GhWwt.mjs → S3StateStore-B_ZF9eHt.mjs} +2 -2
- package/dist/{S3StateStore-pw1GhWwt.mjs.map → S3StateStore-B_ZF9eHt.mjs.map} +1 -1
- package/dist/{SSMStateStore-Bt9acuAF.cjs → SSMStateStore-ACZ8hRvZ.cjs} +2 -2
- package/dist/{SSMStateStore-Bt9acuAF.cjs.map → SSMStateStore-ACZ8hRvZ.cjs.map} +1 -1
- package/dist/{SSMStateStore-Dmj7zzFO.mjs → SSMStateStore-DjPuKqrm.mjs} +2 -2
- package/dist/{SSMStateStore-Dmj7zzFO.mjs.map → SSMStateStore-DjPuKqrm.mjs.map} +1 -1
- package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
- package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
- package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
- package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
- package/dist/{bundler-D_14JLZF.mjs → bundler-Bq3HaLOZ.mjs} +20 -5
- package/dist/bundler-Bq3HaLOZ.mjs.map +1 -0
- package/dist/{bundler-D6MlIfBT.cjs → bundler-pyLj-gS0.cjs} +20 -5
- package/dist/bundler-pyLj-gS0.cjs.map +1 -0
- package/dist/{cli-P56vvrDQ.mjs → cli-C2Tjbn27.mjs} +6 -5
- package/dist/cli-C2Tjbn27.mjs.map +1 -0
- package/dist/{cli-BfH1deAT.cjs → cli-DR7B2_fX.cjs} +6 -5
- package/dist/cli-DR7B2_fX.cjs.map +1 -0
- package/dist/{compose-391oEKj1.cjs → compose-5oNHAKNT.cjs} +137 -667
- package/dist/compose-5oNHAKNT.cjs.map +1 -0
- package/dist/{compose-DprE3ASm.mjs → compose-BjToENzG.mjs} +130 -569
- package/dist/compose-BjToENzG.mjs.map +1 -0
- package/dist/{config-V_X_BMpm.d.cts → config-4XFxX1al.d.cts} +3 -3
- package/dist/{config-BonvTW8p.d.mts.map → config-4XFxX1al.d.cts.map} +1 -1
- package/dist/{config-BonvTW8p.d.mts → config-UtKzhpFb.d.mts} +3 -3
- package/dist/{config-V_X_BMpm.d.cts.map → config-UtKzhpFb.d.mts.map} +1 -1
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +3 -3
- package/dist/{credentials-Bzbg23n8.cjs → credentials-BVs7mrtw.cjs} +239 -3
- package/dist/credentials-BVs7mrtw.cjs.map +1 -0
- package/dist/{credentials-Dq1MnWQf.mjs → credentials-pAtB70k3.mjs} +223 -5
- package/dist/credentials-pAtB70k3.mjs.map +1 -0
- package/dist/databases-C2p5LGAp.cjs +419 -0
- package/dist/databases-C2p5LGAp.cjs.map +1 -0
- package/dist/databases-hUHTuwhx.mjs +346 -0
- package/dist/databases-hUHTuwhx.mjs.map +1 -0
- package/dist/deploy/public.cjs +37 -28
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts +136 -19
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +136 -19
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +11 -11
- package/dist/deploy-BucRfbvX.cjs +511 -0
- package/dist/deploy-BucRfbvX.cjs.map +1 -0
- package/dist/deploy-DRAwTG72.mjs +488 -0
- package/dist/deploy-DRAwTG72.mjs.map +1 -0
- package/dist/{discover-LMrqsWSU.mjs → discover-BFoJWKGD.mjs} +4 -2
- package/dist/discover-BFoJWKGD.mjs.map +1 -0
- package/dist/{discover-DHdECueV.cjs → discover-OEfZ9OkA.cjs} +4 -2
- package/dist/discover-OEfZ9OkA.cjs.map +1 -0
- package/dist/dokploy-DIt1IZl1.mjs +38 -0
- package/dist/dokploy-DIt1IZl1.mjs.map +1 -0
- package/dist/dokploy-m345Zx02.cjs +38 -0
- package/dist/dokploy-m345Zx02.cjs.map +1 -0
- package/dist/{encryption-DF_hgIpl.mjs → encryption-Ccbahik7.mjs} +3 -5
- package/dist/{encryption-DF_hgIpl.mjs.map → encryption-Ccbahik7.mjs.map} +1 -1
- package/dist/{encryption-B1wJwgae.cjs → encryption-rZ3BghXy.cjs} +5 -7
- package/dist/{encryption-B1wJwgae.cjs.map → encryption-rZ3BghXy.cjs.map} +1 -1
- package/dist/{deploy-Cy8igpQF.cjs → engine-Cx_dvx9q.cjs} +1491 -1260
- package/dist/engine-Cx_dvx9q.cjs.map +1 -0
- package/dist/{deploy-CZ5nlpsu.mjs → engine-Gs0abjuj.mjs} +1450 -1261
- package/dist/engine-Gs0abjuj.mjs.map +1 -0
- package/dist/{github-B0YYE98x.mjs → github-CJANTYqi.mjs} +3 -3
- package/dist/{github-B0YYE98x.mjs.map → github-CJANTYqi.mjs.map} +1 -1
- package/dist/{github-CYcmTdFs.cjs → github-CrcGFkfD.cjs} +7 -7
- package/dist/{github-CYcmTdFs.cjs.map → github-CrcGFkfD.cjs.map} +1 -1
- package/dist/{index-DPUAGJaK.d.cts → index-CyApaHVe.d.cts} +2 -2
- package/dist/{index-DPUAGJaK.d.cts.map → index-CyApaHVe.d.cts.map} +1 -1
- package/dist/{index-DwKD_8lt.d.mts → index-DD1FfUHh.d.mts} +2 -2
- package/dist/{index-DwKD_8lt.d.mts.map → index-DD1FfUHh.d.mts.map} +1 -1
- package/dist/index.cjs +285 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +258 -68
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-q4pPAXtO.cjs → migrate-CQdSpttI.cjs} +16 -16
- package/dist/{migrate-q4pPAXtO.cjs.map → migrate-CQdSpttI.cjs.map} +1 -1
- package/dist/{migrate-B2qL5wj4.mjs → migrate-DCVo5gLS.mjs} +6 -6
- package/dist/{migrate-B2qL5wj4.mjs.map → migrate-DCVo5gLS.mjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/provider-B3Sv_a74.cjs +173 -0
- package/dist/provider-B3Sv_a74.cjs.map +1 -0
- package/dist/provider-D7rQzzzf.mjs +138 -0
- package/dist/provider-D7rQzzzf.mjs.map +1 -0
- package/dist/{ready-bQfu9GES.mjs → ready-2s3-CndS.mjs} +3 -3
- package/dist/{ready-bQfu9GES.mjs.map → ready-2s3-CndS.mjs.map} +1 -1
- package/dist/{ready-brEhh68f.cjs → ready-B6uHr4sm.cjs} +3 -3
- package/dist/{ready-brEhh68f.cjs.map → ready-B6uHr4sm.cjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-N_i4XNd-.cjs → resolve-BexmDcsN.cjs} +4 -4
- package/dist/{resolve-N_i4XNd-.cjs.map → resolve-BexmDcsN.cjs.map} +1 -1
- package/dist/{resolve-DLkIXTct.mjs → resolve-DhZgtvZe.mjs} +4 -4
- package/dist/{resolve-DLkIXTct.mjs.map → resolve-DhZgtvZe.mjs.map} +1 -1
- package/dist/rollback-BnY7KuG_.cjs +161 -0
- package/dist/rollback-BnY7KuG_.cjs.map +1 -0
- package/dist/rollback-m4Yeym5x.mjs +132 -0
- package/dist/rollback-m4Yeym5x.mjs.map +1 -0
- package/dist/run-BJLIerMM.mjs +133 -0
- package/dist/run-BJLIerMM.mjs.map +1 -0
- package/dist/run-fVZ-rLnc.cjs +174 -0
- package/dist/run-fVZ-rLnc.cjs.map +1 -0
- package/dist/{runtime-BnD7Nn96.d.cts → runtime-BRqFOvPM.d.cts} +2 -2
- package/dist/{runtime-BnD7Nn96.d.cts.map → runtime-BRqFOvPM.d.cts.map} +1 -1
- package/dist/{runtime-j-tmFL65.d.mts → runtime-CEk5n4VH.d.mts} +2 -2
- package/dist/{runtime-j-tmFL65.d.mts.map → runtime-CEk5n4VH.d.mts.map} +1 -1
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox/migrate-worker.cjs +61 -0
- package/dist/sandbox/migrate-worker.cjs.map +1 -0
- package/dist/sandbox/migrate-worker.d.cts +1 -0
- package/dist/sandbox/migrate-worker.d.mts +1 -0
- package/dist/sandbox/migrate-worker.mjs +62 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/{schemas-D2LCF689.mjs → schemas-Cfhtpdo0.mjs} +10 -2
- package/dist/{schemas-Ckm_aBnF.cjs.map → schemas-Cfhtpdo0.mjs.map} +1 -1
- package/dist/{schemas-Ckm_aBnF.cjs → schemas-RUlKHu27.cjs} +15 -1
- package/dist/{schemas-D2LCF689.mjs.map → schemas-RUlKHu27.cjs.map} +1 -1
- package/dist/{sniffer-BZ-OJO4Y.mjs → sniffer-BdFeLSmA.mjs} +97 -600
- package/dist/sniffer-BdFeLSmA.mjs.map +1 -0
- package/dist/{sniffer-BSwaL-dX.cjs → sniffer-D66HIvi9.cjs} +110 -674
- package/dist/sniffer-D66HIvi9.cjs.map +1 -0
- package/dist/{sst-B2HbrDR3.mjs → sst-DRi3H5TB.mjs} +3 -3
- package/dist/{sst-B2HbrDR3.mjs.map → sst-DRi3H5TB.mjs.map} +1 -1
- package/dist/{sst-DcfsVH6x.cjs → sst-hBrKouBy.cjs} +5 -5
- package/dist/{sst-DcfsVH6x.cjs.map → sst-hBrKouBy.cjs.map} +1 -1
- package/dist/{state-DF26e_lo.cjs → state-DgmM4EKq.cjs} +2787 -1890
- package/dist/state-DgmM4EKq.cjs.map +1 -0
- package/dist/{state-B8YwmUZU.mjs → state-DkUStoqJ.mjs} +2813 -2084
- package/dist/state-DkUStoqJ.mjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-CfbiYUbZ.mjs → terminal-C3cv-OQu.mjs} +5 -5
- package/dist/{terminal-CfbiYUbZ.mjs.map → terminal-C3cv-OQu.mjs.map} +1 -1
- package/dist/{terminal-Bs5E1oxm.cjs → terminal-DjzgLu6m.cjs} +12 -16
- package/dist/{terminal-Bs5E1oxm.cjs.map → terminal-DjzgLu6m.cjs.map} +1 -1
- package/dist/{types-ByMWkXKP.d.cts → types-CSw2w69a.d.mts} +68 -10
- package/dist/types-CSw2w69a.d.mts.map +1 -0
- package/dist/{types-BCzMWBb6.d.mts → types-D5WIxRDP.d.cts} +69 -9
- package/dist/types-D5WIxRDP.d.cts.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-C06_pW4g.mjs → workspace-Be6uBhlF.mjs} +10 -3
- package/dist/workspace-Be6uBhlF.mjs.map +1 -0
- package/dist/{workspace-BewAHZIo.cjs → workspace-ON-bqiJz.cjs} +10 -3
- package/dist/workspace-ON-bqiJz.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/HostingerProvider-Dlmbfass.cjs.map +0 -1
- package/dist/HostingerProvider-x9gQTAGZ.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
- package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
- package/dist/bundler-D6MlIfBT.cjs.map +0 -1
- package/dist/bundler-D_14JLZF.mjs.map +0 -1
- package/dist/cli-BfH1deAT.cjs.map +0 -1
- package/dist/cli-P56vvrDQ.mjs.map +0 -1
- package/dist/compose-391oEKj1.cjs.map +0 -1
- package/dist/compose-DprE3ASm.mjs.map +0 -1
- package/dist/credentials-Bzbg23n8.cjs.map +0 -1
- package/dist/credentials-Dq1MnWQf.mjs.map +0 -1
- package/dist/deploy-9MBG_QLd.mjs +0 -137
- package/dist/deploy-9MBG_QLd.mjs.map +0 -1
- package/dist/deploy-B80idPUZ.cjs +0 -142
- package/dist/deploy-B80idPUZ.cjs.map +0 -1
- package/dist/deploy-CZ5nlpsu.mjs.map +0 -1
- package/dist/deploy-Cy8igpQF.cjs.map +0 -1
- package/dist/discover-DHdECueV.cjs.map +0 -1
- package/dist/discover-LMrqsWSU.mjs.map +0 -1
- package/dist/dokploy-BdtBePjp.mjs +0 -32
- package/dist/dokploy-BdtBePjp.mjs.map +0 -1
- package/dist/dokploy-iFY8MY-L.cjs +0 -32
- package/dist/dokploy-iFY8MY-L.cjs.map +0 -1
- package/dist/local-BdH4XN0E.cjs +0 -409
- package/dist/local-BdH4XN0E.cjs.map +0 -1
- package/dist/local-CWR4Y_kW.mjs +0 -350
- package/dist/local-CWR4Y_kW.mjs.map +0 -1
- package/dist/sniffer-BSwaL-dX.cjs.map +0 -1
- package/dist/sniffer-BZ-OJO4Y.mjs.map +0 -1
- package/dist/state-B8YwmUZU.mjs.map +0 -1
- package/dist/state-DF26e_lo.cjs.map +0 -1
- package/dist/storage-BzaUxmqe.mjs +0 -124
- package/dist/storage-BzaUxmqe.mjs.map +0 -1
- package/dist/storage-CSGoC3bK.cjs +0 -152
- package/dist/storage-CSGoC3bK.cjs.map +0 -1
- package/dist/store-CJF1Tqkq.cjs +0 -510
- package/dist/store-CJF1Tqkq.cjs.map +0 -1
- package/dist/store-CLiHnqOY.mjs +0 -415
- package/dist/store-CLiHnqOY.mjs.map +0 -1
- package/dist/types-BCzMWBb6.d.mts.map +0 -1
- package/dist/types-ByMWkXKP.d.cts.map +0 -1
- package/dist/workspace-BewAHZIo.cjs.map +0 -1
- package/dist/workspace-C06_pW4g.mjs.map +0 -1
|
@@ -1,206 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { d as output, r as discover, s as nodeWithTsx } from "./discover-LMrqsWSU.mjs";
|
|
2
|
+
import { i as LocalSandbox } from "./credentials-pAtB70k3.mjs";
|
|
3
|
+
import { d as output, s as nodeWithTsx } from "./discover-BFoJWKGD.mjs";
|
|
5
4
|
import { i as activeSandbox } from "./sandbox-Dm247NGx.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { o as builtinTarget } from "./define-DR8xGYfL.mjs";
|
|
8
|
-
import { h as getPublicEnvPrefix, k as assertDeployedStage, s as getAppBuildOrder } from "./workspace-C06_pW4g.mjs";
|
|
9
|
-
import { l as applicationName, n as secretsStoreFor, u as deployIdentity } from "./store-CLiHnqOY.mjs";
|
|
10
|
-
import { D as constructGlobs } from "./state-B8YwmUZU.mjs";
|
|
11
|
-
import { a as parseTargetOptions, o as resolveTarget } from "./resolve-DLkIXTct.mjs";
|
|
5
|
+
import { h as getPublicEnvPrefix } from "./workspace-Be6uBhlF.mjs";
|
|
12
6
|
import { dirname, resolve } from "node:path";
|
|
13
|
-
import { stdin, stdout } from "node:process";
|
|
14
|
-
import * as readline from "node:readline/promises";
|
|
15
7
|
import { existsSync } from "node:fs";
|
|
16
8
|
import { hostname, userInfo } from "node:os";
|
|
17
9
|
import { fileURLToPath } from "node:url";
|
|
18
|
-
import {
|
|
19
|
-
//#region src/prompt.ts
|
|
20
|
-
/**
|
|
21
|
-
* Asking the person at the terminal.
|
|
22
|
-
*
|
|
23
|
-
* CLI layer only: a command's action may prompt, nothing it calls may. A
|
|
24
|
-
* library call (`deploy()`) that needs something it was not given raises a
|
|
25
|
-
* named error instead, and the command decides whether to ask.
|
|
26
|
-
*/
|
|
27
|
-
/** A prompt was needed with no terminal to ask at. */
|
|
28
|
-
var PromptNeedsTerminal = class extends Error {
|
|
29
|
-
question;
|
|
30
|
-
instead;
|
|
31
|
-
constructor(question, instead) {
|
|
32
|
-
super(`Interactive input required. ${instead}`);
|
|
33
|
-
this.question = question;
|
|
34
|
-
this.instead = instead;
|
|
35
|
-
this.name = "PromptNeedsTerminal";
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
/** Whether there is a person at a terminal to ask. */
|
|
39
|
-
function canPrompt() {
|
|
40
|
-
return process.stdin.isTTY === true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Ask `message` and resolve with the line typed — without echoing it when
|
|
44
|
-
* `hidden`. Ctrl+C at a hidden prompt exits, as it would anywhere else in a
|
|
45
|
-
* terminal program: raw mode has taken the signal away from the shell.
|
|
46
|
-
*/
|
|
47
|
-
async function prompt(message, options) {
|
|
48
|
-
if (!canPrompt()) throw new PromptNeedsTerminal(message, options.instead);
|
|
49
|
-
if (options.hidden) {
|
|
50
|
-
process.stdout.write(message);
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
let value = "";
|
|
53
|
-
const cleanup = () => {
|
|
54
|
-
process.stdin.setRawMode(false);
|
|
55
|
-
process.stdin.pause();
|
|
56
|
-
process.stdin.removeListener("data", onData);
|
|
57
|
-
process.stdin.removeListener("error", onError);
|
|
58
|
-
};
|
|
59
|
-
const onError = (err) => {
|
|
60
|
-
cleanup();
|
|
61
|
-
reject(err);
|
|
62
|
-
};
|
|
63
|
-
const onData = (char) => {
|
|
64
|
-
const c = char.toString();
|
|
65
|
-
if (c === "\n" || c === "\r") {
|
|
66
|
-
cleanup();
|
|
67
|
-
process.stdout.write("\n");
|
|
68
|
-
resolve(value);
|
|
69
|
-
} else if (c === "") {
|
|
70
|
-
cleanup();
|
|
71
|
-
process.stdout.write("\n");
|
|
72
|
-
process.exit(1);
|
|
73
|
-
} else if (c === "" || c === "\b") {
|
|
74
|
-
if (value.length > 0) value = value.slice(0, -1);
|
|
75
|
-
} else value += c;
|
|
76
|
-
};
|
|
77
|
-
process.stdin.setRawMode(true);
|
|
78
|
-
process.stdin.resume();
|
|
79
|
-
process.stdin.on("data", onData);
|
|
80
|
-
process.stdin.on("error", onError);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
const rl = readline.createInterface({
|
|
84
|
-
input: stdin,
|
|
85
|
-
output: stdout
|
|
86
|
-
});
|
|
87
|
-
try {
|
|
88
|
-
return await rl.question(message);
|
|
89
|
-
} finally {
|
|
90
|
-
rl.close();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/auth/index.ts
|
|
95
|
-
const logger = console;
|
|
96
|
-
/**
|
|
97
|
-
* Validate Dokploy token by making a test API call
|
|
98
|
-
*/
|
|
99
|
-
async function validateDokployToken(endpoint, token) {
|
|
100
|
-
const { DokployApi } = await Promise.resolve().then(() => dokploy_api_exports);
|
|
101
|
-
return new DokployApi({
|
|
102
|
-
baseUrl: endpoint,
|
|
103
|
-
token
|
|
104
|
-
}).validateToken();
|
|
105
|
-
}
|
|
106
|
-
/** What answers a login prompt without a terminal. */
|
|
107
|
-
const LOGIN_INSTEAD = "Please provide --token option.";
|
|
108
|
-
/**
|
|
109
|
-
* Login to a service
|
|
110
|
-
*/
|
|
111
|
-
async function loginCommand(options) {
|
|
112
|
-
const { provider, token: providedToken, endpoint: providedEndpoint } = options;
|
|
113
|
-
if (provider === "dokploy") {
|
|
114
|
-
logger.log("\n🔐 Logging in to Dokploy...\n");
|
|
115
|
-
let endpoint = providedEndpoint;
|
|
116
|
-
if (!endpoint) endpoint = await prompt("Dokploy URL (e.g., https://dokploy.example.com): ", { instead: LOGIN_INSTEAD });
|
|
117
|
-
endpoint = endpoint.replace(/\/$/, "");
|
|
118
|
-
try {
|
|
119
|
-
new URL(endpoint);
|
|
120
|
-
} catch {
|
|
121
|
-
logger.error("Invalid URL format");
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
let token = providedToken;
|
|
125
|
-
if (!token) {
|
|
126
|
-
logger.log(`\nGenerate a token at: ${endpoint}/settings/profile\n`);
|
|
127
|
-
token = await prompt("API Token: ", {
|
|
128
|
-
hidden: true,
|
|
129
|
-
instead: LOGIN_INSTEAD
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (!token) {
|
|
133
|
-
logger.error("Token is required");
|
|
134
|
-
process.exit(1);
|
|
135
|
-
}
|
|
136
|
-
logger.log("\nValidating credentials...");
|
|
137
|
-
if (!await validateDokployToken(endpoint, token)) {
|
|
138
|
-
logger.error("\n✗ Invalid credentials. Please check your token and try again.");
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
await storeDokployCredentials(token, endpoint);
|
|
142
|
-
logger.log("\n✓ Successfully logged in to Dokploy!");
|
|
143
|
-
logger.log(` Endpoint: ${endpoint}`);
|
|
144
|
-
logger.log(` Credentials stored in: ${getCredentialsPath()}`);
|
|
145
|
-
logger.log("\nYou can now use deploy commands without setting DOKPLOY_API_TOKEN.");
|
|
146
|
-
}
|
|
147
|
-
if (provider === "hostinger") {
|
|
148
|
-
logger.log("\n🔐 Logging in to Hostinger...\n");
|
|
149
|
-
let token = providedToken;
|
|
150
|
-
if (!token) {
|
|
151
|
-
logger.log("\nGenerate a token at: https://hpanel.hostinger.com/profile/api\n");
|
|
152
|
-
token = await prompt("API Token: ", {
|
|
153
|
-
hidden: true,
|
|
154
|
-
instead: LOGIN_INSTEAD
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
if (!token) {
|
|
158
|
-
logger.error("Token is required");
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
await storeHostingerToken(token);
|
|
162
|
-
logger.log("\n✓ Hostinger token stored.");
|
|
163
|
-
logger.log(` Credentials stored in: ${getCredentialsPath()}`);
|
|
164
|
-
logger.log(" Not validated here: every DNS endpoint is scoped to a domain, so the\n first deploy that touches DNS is where a bad token reports itself.");
|
|
165
|
-
logger.log("\nYou can now use it as a DNS provider without setting HOSTINGER_API_TOKEN.");
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Logout from a service
|
|
170
|
-
*/
|
|
171
|
-
async function logoutCommand(options) {
|
|
172
|
-
const { provider = "dokploy" } = options;
|
|
173
|
-
if (provider === "all") {
|
|
174
|
-
if (await removeDokployCredentials()) logger.log("\n✓ Logged out from all services");
|
|
175
|
-
else logger.log("\nNo stored credentials found");
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (provider === "dokploy") {
|
|
179
|
-
if (await removeDokployCredentials()) logger.log("\n✓ Logged out from Dokploy");
|
|
180
|
-
else logger.log("\nNo Dokploy credentials found");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Show current login status
|
|
185
|
-
*/
|
|
186
|
-
async function whoamiCommand() {
|
|
187
|
-
logger.log("\n📋 Current credentials:\n");
|
|
188
|
-
const dokploy = await getDokployCredentials();
|
|
189
|
-
if (dokploy) {
|
|
190
|
-
logger.log(" Dokploy:");
|
|
191
|
-
logger.log(` Endpoint: ${dokploy.endpoint}`);
|
|
192
|
-
logger.log(` Token: ${maskToken(dokploy.token)}`);
|
|
193
|
-
} else logger.log(" Dokploy: Not logged in");
|
|
194
|
-
logger.log(`\n Credentials file: ${getCredentialsPath()}`);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Mask a token for display
|
|
198
|
-
*/
|
|
199
|
-
function maskToken(token) {
|
|
200
|
-
if (token.length <= 8) return "****";
|
|
201
|
-
return `${token.slice(0, 4)}...${token.slice(-4)}`;
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
10
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
204
11
|
//#region src/workspace/client-generator.ts
|
|
205
12
|
/**
|
|
206
13
|
* Normalize routes to an array of patterns.
|
|
@@ -212,118 +19,6 @@ function normalizeRoutes(routes) {
|
|
|
212
19
|
return Array.isArray(routes) ? routes : [routes];
|
|
213
20
|
}
|
|
214
21
|
//#endregion
|
|
215
|
-
//#region src/secrets/encryption.ts
|
|
216
|
-
var encryption_exports = /* @__PURE__ */ __exportAll({
|
|
217
|
-
encryptSecrets: () => encryptSecrets,
|
|
218
|
-
generateDefineOptions: () => generateDefineOptions,
|
|
219
|
-
keyFingerprint: () => keyFingerprint
|
|
220
|
-
});
|
|
221
|
-
/** AES-256-GCM configuration */
|
|
222
|
-
const ALGORITHM = "aes-256-gcm";
|
|
223
|
-
const KEY_LENGTH = 32;
|
|
224
|
-
const IV_LENGTH = 12;
|
|
225
|
-
/**
|
|
226
|
-
* Encrypt secrets for embedding in a bundle.
|
|
227
|
-
* Uses AES-256-GCM with a randomly generated ephemeral key.
|
|
228
|
-
*
|
|
229
|
-
* @param secrets - Key-value pairs to encrypt
|
|
230
|
-
* @returns Encrypted payload with ephemeral master key
|
|
231
|
-
*/
|
|
232
|
-
function encryptSecrets(secrets) {
|
|
233
|
-
const masterKey = randomBytes(KEY_LENGTH);
|
|
234
|
-
const iv = randomBytes(IV_LENGTH);
|
|
235
|
-
const plaintext = JSON.stringify(secrets);
|
|
236
|
-
const cipher = createCipheriv(ALGORITHM, masterKey, iv);
|
|
237
|
-
const ciphertext = Buffer.concat([cipher.update(plaintext, "utf-8"), cipher.final()]);
|
|
238
|
-
const authTag = cipher.getAuthTag();
|
|
239
|
-
return {
|
|
240
|
-
encrypted: Buffer.concat([ciphertext, authTag]).toString("base64"),
|
|
241
|
-
iv: iv.toString("hex"),
|
|
242
|
-
masterKey: masterKey.toString("hex")
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Generate the define options for tsdown/esbuild.
|
|
247
|
-
* These will be injected at build time.
|
|
248
|
-
*/
|
|
249
|
-
function generateDefineOptions(payload) {
|
|
250
|
-
return {
|
|
251
|
-
__GKM_ENCRYPTED_CREDENTIALS__: JSON.stringify(payload.encrypted),
|
|
252
|
-
__GKM_CREDENTIALS_IV__: JSON.stringify(payload.iv)
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* A short, one-way name for a master key: the first 8 hex characters of its
|
|
257
|
-
* SHA-256.
|
|
258
|
-
*
|
|
259
|
-
* Printed where the key itself used to be, so a person can tell which key a
|
|
260
|
-
* build used — and match it against the one they hold — without the output
|
|
261
|
-
* carrying a value that decrypts every secret of the stage.
|
|
262
|
-
*/
|
|
263
|
-
function keyFingerprint(masterKey) {
|
|
264
|
-
return createHash("sha256").update(masterKey).digest("hex").slice(0, 8);
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/target/secrets.ts
|
|
268
|
-
/**
|
|
269
|
-
* A stage's secrets as a target sees them: read and written through the
|
|
270
|
-
* stage's own store, and masked in everything the run prints once read.
|
|
271
|
-
*/
|
|
272
|
-
/**
|
|
273
|
-
* Shorter values are left alone: what a progress line legitimately prints —
|
|
274
|
-
* a port, a stage, an app name — would otherwise come out as `***` wherever
|
|
275
|
-
* a secret happened to share it.
|
|
276
|
-
*/
|
|
277
|
-
const SHORTEST_MASKED = 6;
|
|
278
|
-
/** The values a run must never print, and the rewrite that keeps it so. */
|
|
279
|
-
var Redactor = class {
|
|
280
|
-
values = /* @__PURE__ */ new Set();
|
|
281
|
-
add(value) {
|
|
282
|
-
if (value && value.length >= SHORTEST_MASKED) this.values.add(value);
|
|
283
|
-
}
|
|
284
|
-
/** `text` with every masked value replaced by `***`, longest first. */
|
|
285
|
-
redact(text) {
|
|
286
|
-
if (this.values.size === 0) return text;
|
|
287
|
-
let out = text;
|
|
288
|
-
const longestFirst = [...this.values].sort((a, b) => b.length - a.length);
|
|
289
|
-
for (const value of longestFirst) out = out.replaceAll(value, "***");
|
|
290
|
-
return out;
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
/** Every value in `secrets` that is a secret rather than a label. */
|
|
294
|
-
function secretValues(secrets) {
|
|
295
|
-
return [
|
|
296
|
-
secrets.seed,
|
|
297
|
-
...Object.values(secrets.custom ?? {}),
|
|
298
|
-
...Object.values(secrets.urls ?? {}),
|
|
299
|
-
...Object.values(secrets.services ?? {}).map((service) => service?.password)
|
|
300
|
-
].filter((value) => typeof value === "string");
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* The stage's secrets through the store `secrets.store` names for it. Opening
|
|
304
|
-
* one builds a client and makes no request, so a target that never reads them
|
|
305
|
-
* costs nothing.
|
|
306
|
-
*/
|
|
307
|
-
async function deploySecrets(workspace, stage, redactor, options = {}) {
|
|
308
|
-
const store = await secretsStoreFor(workspace, stage, options);
|
|
309
|
-
const mask = (secrets) => {
|
|
310
|
-
for (const value of secretValues(secrets)) redactor.add(value);
|
|
311
|
-
};
|
|
312
|
-
return {
|
|
313
|
-
store: store.name,
|
|
314
|
-
async read() {
|
|
315
|
-
const secrets = await store.read(stage);
|
|
316
|
-
if (secrets) mask(secrets);
|
|
317
|
-
return secrets;
|
|
318
|
-
},
|
|
319
|
-
async write(secrets) {
|
|
320
|
-
mask(secrets);
|
|
321
|
-
await store.write(stage, secrets);
|
|
322
|
-
},
|
|
323
|
-
mask: (value) => redactor.add(value)
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
//#endregion
|
|
327
22
|
//#region src/deploy/events.ts
|
|
328
23
|
/** An error as an event carries it: its name and message, nothing else. */
|
|
329
24
|
function eventError(error) {
|
|
@@ -658,17 +353,17 @@ function isStateStore(value) {
|
|
|
658
353
|
async function createStateStore(options) {
|
|
659
354
|
const { config, workspaceRoot, workspaceName } = options;
|
|
660
355
|
if (!config || config.provider === "local") {
|
|
661
|
-
const { LocalStateStore } = await import("./LocalStateStore-
|
|
356
|
+
const { LocalStateStore } = await import("./LocalStateStore-Dk3Wbvzk.mjs").then((n) => n.n);
|
|
662
357
|
return new LocalStateStore(workspaceRoot);
|
|
663
358
|
}
|
|
664
359
|
if (isStateStore(config.provider)) return config.provider;
|
|
665
360
|
if (isStateProvider(config.provider)) {
|
|
666
|
-
const { LegacyStateStore } = await import("./LegacyStateStore-
|
|
361
|
+
const { LegacyStateStore } = await import("./LegacyStateStore-C39UKwmf.mjs");
|
|
667
362
|
return new LegacyStateStore(config.provider, { warn: options.warn });
|
|
668
363
|
}
|
|
669
364
|
if (config.provider === "ssm") {
|
|
670
365
|
if (!workspaceName) throw new StateStoreNeedsWorkspaceName("ssm");
|
|
671
|
-
const { SSMStateStore } = await import("./SSMStateStore-
|
|
366
|
+
const { SSMStateStore } = await import("./SSMStateStore-DjPuKqrm.mjs");
|
|
672
367
|
const ssm = config;
|
|
673
368
|
return SSMStateStore.create({
|
|
674
369
|
workspaceName,
|
|
@@ -678,7 +373,7 @@ async function createStateStore(options) {
|
|
|
678
373
|
}
|
|
679
374
|
if (config.provider === "s3") {
|
|
680
375
|
if (!workspaceName) throw new StateStoreNeedsWorkspaceName("s3");
|
|
681
|
-
const { S3StateStore } = await import("./S3StateStore-
|
|
376
|
+
const { S3StateStore } = await import("./S3StateStore-B_ZF9eHt.mjs");
|
|
682
377
|
const s3 = config;
|
|
683
378
|
return S3StateStore.create({
|
|
684
379
|
workspaceName,
|
|
@@ -691,293 +386,12 @@ async function createStateStore(options) {
|
|
|
691
386
|
throw new UnknownStateProvider(config);
|
|
692
387
|
}
|
|
693
388
|
//#endregion
|
|
694
|
-
//#region src/
|
|
695
|
-
/**
|
|
696
|
-
* The run around a target: what every deploy does whatever it deploys
|
|
697
|
-
* through.
|
|
698
|
-
*
|
|
699
|
-
* It loads the workspace, resolves the target, works out the apps and the
|
|
700
|
-
* identity, takes the stage's lock, and calls the target's phases in order,
|
|
701
|
-
* reporting each as it starts, finishes or fails. Everything that is about
|
|
702
|
-
* *where* the stage goes is the target's.
|
|
703
|
-
*/
|
|
704
|
-
/** Apps were asked for by name that the workspace does not have. */
|
|
705
|
-
var UnknownDeployApps = class extends Error {
|
|
706
|
-
apps;
|
|
707
|
-
available;
|
|
708
|
-
constructor(apps, available) {
|
|
709
|
-
super(`Unknown apps: ${apps.join(", ")}\nAvailable apps: ${available.join(", ")}`);
|
|
710
|
-
this.apps = apps;
|
|
711
|
-
this.available = available;
|
|
712
|
-
this.name = "UnknownDeployApps";
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
/** Every app asked for deploys through some other target. */
|
|
716
|
-
var NoDeployableApps = class extends Error {
|
|
717
|
-
stage;
|
|
718
|
-
target;
|
|
719
|
-
constructor(stage, target) {
|
|
720
|
-
super(`No apps to deploy through "${target}": every selected app deploys somewhere else. Pick the target with --target, or set each app's deploy in gkm.config.ts.`);
|
|
721
|
-
this.stage = stage;
|
|
722
|
-
this.target = target;
|
|
723
|
-
this.name = "NoDeployableApps";
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
/** A failed rollback, after the failure that called for it. */
|
|
727
|
-
var RollbackFailed = class extends Error {
|
|
728
|
-
target;
|
|
729
|
-
failure;
|
|
730
|
-
constructor(target, failure, cause) {
|
|
731
|
-
super(`Deploying through "${target}" failed, and so did rolling it back: ${cause instanceof Error ? cause.message : String(cause)}. The stage may be part-released; deploy again, or roll it back by hand. The first failure: ${failure instanceof Error ? failure.message : String(failure)}`, { cause });
|
|
732
|
-
this.target = target;
|
|
733
|
-
this.failure = failure;
|
|
734
|
-
this.name = "RollbackFailed";
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
/**
|
|
738
|
-
* Generate image tag from stage and timestamp
|
|
739
|
-
*/
|
|
740
|
-
function generateTag(stage) {
|
|
741
|
-
return `${stage}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19)}`;
|
|
742
|
-
}
|
|
743
|
-
/** Why an app that deploys through another target is left out. */
|
|
744
|
-
function elsewhere(target, stage) {
|
|
745
|
-
const instead = builtinTarget(target)?.instead?.(stage);
|
|
746
|
-
if (instead) return `it deploys through "${target}" — ${instead}`;
|
|
747
|
-
return `it deploys through "${target}" — run \`gkm deploy --target ${target} --stage ${stage}\``;
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Deploy a workspace's stage through its target.
|
|
751
|
-
*
|
|
752
|
-
* The engine under `deploy()` and `gkm deploy`. It never prompts and never
|
|
753
|
-
* exits: credentials come from `ctx.credentials`, progress goes to
|
|
754
|
-
* `ctx.emit` and to `output`, and every failure is thrown.
|
|
755
|
-
*
|
|
756
|
-
* @internal
|
|
757
|
-
*/
|
|
758
|
-
async function runDeploy(source, request, ctx) {
|
|
759
|
-
const { stage } = request;
|
|
760
|
-
const redactor = ctx.redactor ?? new Redactor();
|
|
761
|
-
const emit = (event) => ctx.emit(event.type === "log" ? {
|
|
762
|
-
...event,
|
|
763
|
-
message: redactor.redact(event.message)
|
|
764
|
-
} : event);
|
|
765
|
-
/** Run one phase between its events. */
|
|
766
|
-
const phase = async (name, body) => {
|
|
767
|
-
ctx.signal?.throwIfAborted();
|
|
768
|
-
emit({
|
|
769
|
-
type: "phase.started",
|
|
770
|
-
phase: name
|
|
771
|
-
});
|
|
772
|
-
try {
|
|
773
|
-
const value = await body();
|
|
774
|
-
emit({
|
|
775
|
-
type: "phase.finished",
|
|
776
|
-
phase: name
|
|
777
|
-
});
|
|
778
|
-
return value;
|
|
779
|
-
} catch (error) {
|
|
780
|
-
emit({
|
|
781
|
-
type: "phase.failed",
|
|
782
|
-
phase: name,
|
|
783
|
-
error: eventError(error)
|
|
784
|
-
});
|
|
785
|
-
throw error;
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
ctx.signal?.throwIfAborted();
|
|
789
|
-
emit({
|
|
790
|
-
type: "phase.started",
|
|
791
|
-
phase: "validate"
|
|
792
|
-
});
|
|
793
|
-
let prepared;
|
|
794
|
-
try {
|
|
795
|
-
prepared = await prepare(source, request, ctx, emit, redactor);
|
|
796
|
-
} catch (error) {
|
|
797
|
-
emit({
|
|
798
|
-
type: "phase.failed",
|
|
799
|
-
phase: "validate",
|
|
800
|
-
error: eventError(error)
|
|
801
|
-
});
|
|
802
|
-
throw error;
|
|
803
|
-
}
|
|
804
|
-
const { resolved, phaseCtx, store } = prepared;
|
|
805
|
-
const { target } = resolved;
|
|
806
|
-
if (ctx.dryRun) {
|
|
807
|
-
const run = await validate(target, phaseCtx, emit);
|
|
808
|
-
await phase("plan", () => target.plan(phaseCtx, run));
|
|
809
|
-
return target.result(phaseCtx, run);
|
|
810
|
-
}
|
|
811
|
-
let lock;
|
|
812
|
-
try {
|
|
813
|
-
lock = await store.lock(stage, { operation: "deploy" });
|
|
814
|
-
} catch (error) {
|
|
815
|
-
emit({
|
|
816
|
-
type: "phase.failed",
|
|
817
|
-
phase: "validate",
|
|
818
|
-
error: eventError(error)
|
|
819
|
-
});
|
|
820
|
-
throw error;
|
|
821
|
-
}
|
|
822
|
-
try {
|
|
823
|
-
const run = await validate(target, phaseCtx, emit);
|
|
824
|
-
if (target.provision) await phase("provision", () => target.provision(phaseCtx, run));
|
|
825
|
-
if (target.build) await phase("build", () => target.build(phaseCtx, run));
|
|
826
|
-
let releasing = "release";
|
|
827
|
-
try {
|
|
828
|
-
await phase("release", () => target.release(phaseCtx, run));
|
|
829
|
-
releasing = "verify";
|
|
830
|
-
if (target.verify) await phase("verify", () => target.verify(phaseCtx, run));
|
|
831
|
-
} catch (error) {
|
|
832
|
-
if (ctx.signal?.aborted || !target.capabilities.rollback) throw error;
|
|
833
|
-
if (!target.rollback) throw error;
|
|
834
|
-
try {
|
|
835
|
-
await phase("rollback", () => target.rollback(phaseCtx, run, {
|
|
836
|
-
phase: releasing,
|
|
837
|
-
error
|
|
838
|
-
}));
|
|
839
|
-
} catch (rollbackError) {
|
|
840
|
-
throw new RollbackFailed(resolved.name, error, rollbackError);
|
|
841
|
-
}
|
|
842
|
-
throw error;
|
|
843
|
-
}
|
|
844
|
-
return await target.result(phaseCtx, run);
|
|
845
|
-
} finally {
|
|
846
|
-
await lock.release();
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
/** `validate`, then the run's `deploy.started`, inside the validate phase. */
|
|
850
|
-
async function validate(target, phaseCtx, emit) {
|
|
851
|
-
try {
|
|
852
|
-
const run = await target.validate(phaseCtx);
|
|
853
|
-
const skipped = new Set(phaseCtx.skipped.map((s) => s.app));
|
|
854
|
-
emit({
|
|
855
|
-
type: "deploy.started",
|
|
856
|
-
stage: phaseCtx.stage,
|
|
857
|
-
target: phaseCtx.target,
|
|
858
|
-
identity: phaseCtx.identity.key,
|
|
859
|
-
tag: phaseCtx.tag,
|
|
860
|
-
apps: phaseCtx.apps.filter((app) => !skipped.has(app)),
|
|
861
|
-
dryRun: phaseCtx.dryRun
|
|
862
|
-
});
|
|
863
|
-
emit({
|
|
864
|
-
type: "phase.finished",
|
|
865
|
-
phase: "validate"
|
|
866
|
-
});
|
|
867
|
-
return run;
|
|
868
|
-
} catch (error) {
|
|
869
|
-
emit({
|
|
870
|
-
type: "phase.failed",
|
|
871
|
-
phase: "validate",
|
|
872
|
-
error: eventError(error)
|
|
873
|
-
});
|
|
874
|
-
throw error;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
/** Everything the phases are handed, worked out before the first of them. */
|
|
878
|
-
async function prepare(source, request, ctx, emit, redactor) {
|
|
879
|
-
const { stage } = request;
|
|
880
|
-
const configured = typeof source === "function" ? await source() : source;
|
|
881
|
-
const local = stage === configured.stages.local;
|
|
882
|
-
if (!local) assertDeployedStage(configured.stages, stage);
|
|
883
|
-
const targetName = request.target ?? configured.deploy?.default ?? "dokploy";
|
|
884
|
-
const resolved = await resolveTarget(targetName, {
|
|
885
|
-
workspace: configured,
|
|
886
|
-
stage,
|
|
887
|
-
...ctx.targets ? { host: ctx.targets } : {}
|
|
888
|
-
});
|
|
889
|
-
if (local && !resolved.target.capabilities.localStage) assertDeployedStage(configured.stages, stage);
|
|
890
|
-
const options = await parseTargetOptions(resolved);
|
|
891
|
-
const manifest = await discover({
|
|
892
|
-
patterns: constructGlobs(configured),
|
|
893
|
-
cwd: configured.root
|
|
894
|
-
});
|
|
895
|
-
const units = derivedApps(manifest, configured);
|
|
896
|
-
const workspace = Object.keys(units).length > 0 ? {
|
|
897
|
-
...configured,
|
|
898
|
-
apps: units
|
|
899
|
-
} : configured;
|
|
900
|
-
const identity = deployIdentity(workspace, stage);
|
|
901
|
-
const tag = request.tag ?? (resolved.target.tag ? await resolved.target.tag({
|
|
902
|
-
cwd: workspace.root,
|
|
903
|
-
stage
|
|
904
|
-
}) : generateTag(stage));
|
|
905
|
-
const buildOrder = getAppBuildOrder(workspace);
|
|
906
|
-
let selected = buildOrder;
|
|
907
|
-
if (request.apps && request.apps.length > 0) {
|
|
908
|
-
const unknown = request.apps.filter((name) => !workspace.apps[name]);
|
|
909
|
-
if (unknown.length > 0) throw new UnknownDeployApps(unknown, Object.keys(workspace.apps));
|
|
910
|
-
selected = buildOrder.filter((name) => request.apps.includes(name));
|
|
911
|
-
}
|
|
912
|
-
const skipped = [];
|
|
913
|
-
const skip = (app, reason) => {
|
|
914
|
-
skipped.push({
|
|
915
|
-
app,
|
|
916
|
-
reason
|
|
917
|
-
});
|
|
918
|
-
emit({
|
|
919
|
-
type: "app.skipped",
|
|
920
|
-
app,
|
|
921
|
-
reason
|
|
922
|
-
});
|
|
923
|
-
};
|
|
924
|
-
const byDefault = configured.deploy?.default ?? "dokploy";
|
|
925
|
-
const apps = selected.filter((name) => {
|
|
926
|
-
const own = workspace.apps[name].resolvedDeployTarget;
|
|
927
|
-
const deploysThrough = own === byDefault ? targetName : own;
|
|
928
|
-
if (deploysThrough === targetName) return true;
|
|
929
|
-
skip(name, elsewhere(deploysThrough, stage));
|
|
930
|
-
return false;
|
|
931
|
-
});
|
|
932
|
-
if (apps.length === 0) throw new NoDeployableApps(stage, targetName);
|
|
933
|
-
const store = await createStateStore({
|
|
934
|
-
config: workspace.state,
|
|
935
|
-
workspaceRoot: workspace.root,
|
|
936
|
-
workspaceName: workspace.name
|
|
937
|
-
});
|
|
938
|
-
const secrets = await deploySecrets(workspace, stage, redactor, { ...ctx.home ? { home: ctx.home } : {} });
|
|
939
|
-
const line = (level) => (message) => emit({
|
|
940
|
-
type: "log",
|
|
941
|
-
level,
|
|
942
|
-
message
|
|
943
|
-
});
|
|
944
|
-
const logger = {
|
|
945
|
-
info: line("info"),
|
|
946
|
-
warn: line("warn"),
|
|
947
|
-
error: line("error")
|
|
948
|
-
};
|
|
949
|
-
return {
|
|
950
|
-
resolved,
|
|
951
|
-
phaseCtx: {
|
|
952
|
-
target: targetName,
|
|
953
|
-
cwd: workspace.root,
|
|
954
|
-
stage,
|
|
955
|
-
tag,
|
|
956
|
-
tagGiven: request.tag !== void 0,
|
|
957
|
-
apps,
|
|
958
|
-
skipped,
|
|
959
|
-
identity,
|
|
960
|
-
workspace,
|
|
961
|
-
manifest,
|
|
962
|
-
options,
|
|
963
|
-
dryRun: ctx.dryRun,
|
|
964
|
-
credentials: ctx.credentials,
|
|
965
|
-
state: store,
|
|
966
|
-
secrets,
|
|
967
|
-
logger,
|
|
968
|
-
signal: ctx.signal ?? new AbortController().signal,
|
|
969
|
-
childOutput: ctx.childOutput ?? "inherit",
|
|
970
|
-
emit,
|
|
971
|
-
skip,
|
|
972
|
-
name: (resource) => applicationName(identity, resource)
|
|
973
|
-
},
|
|
974
|
-
store
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
//#endregion
|
|
978
|
-
//#region src/deploy/dokploy-api.ts
|
|
389
|
+
//#region src/target/dokploy/dokploy-api.ts
|
|
979
390
|
var dokploy_api_exports = /* @__PURE__ */ __exportAll({
|
|
391
|
+
DEFAULT_DEPLOYMENT_TIMEOUT_MS: () => DEFAULT_DEPLOYMENT_TIMEOUT_MS,
|
|
980
392
|
DEFAULT_DOKPLOY_TIMEOUT_MS: () => DEFAULT_DOKPLOY_TIMEOUT_MS,
|
|
393
|
+
DeploymentFailed: () => DeploymentFailed,
|
|
394
|
+
DeploymentTimedOut: () => DeploymentTimedOut,
|
|
981
395
|
DokployApi: () => DokployApi,
|
|
982
396
|
DokployApiError: () => DokployApiError,
|
|
983
397
|
DokployRequestTimedOut: () => DokployRequestTimedOut
|
|
@@ -1024,6 +438,32 @@ function pause(ms, signal) {
|
|
|
1024
438
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1025
439
|
});
|
|
1026
440
|
}
|
|
441
|
+
/** How long a deployment may take to finish before a deploy gives up on it. */
|
|
442
|
+
const DEFAULT_DEPLOYMENT_TIMEOUT_MS = 6e5;
|
|
443
|
+
/** A deployment Dokploy ran and reported as failed. */
|
|
444
|
+
var DeploymentFailed = class extends Error {
|
|
445
|
+
applicationId;
|
|
446
|
+
deployment;
|
|
447
|
+
constructor(applicationId, deployment) {
|
|
448
|
+
super(`Dokploy's deployment ${deployment.deploymentId} of application ${applicationId} ended in "${deployment.status}"${deployment.errorMessage ? `: ${deployment.errorMessage}` : ""}. Its log in Dokploy says why — usually an image the server could not pull, or a container that exited on start.`);
|
|
449
|
+
this.applicationId = applicationId;
|
|
450
|
+
this.deployment = deployment;
|
|
451
|
+
this.name = "DeploymentFailed";
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
/** A deployment that had not finished when the deploy stopped waiting. */
|
|
455
|
+
var DeploymentTimedOut = class extends Error {
|
|
456
|
+
applicationId;
|
|
457
|
+
timeoutMs;
|
|
458
|
+
lastStatus;
|
|
459
|
+
constructor(applicationId, timeoutMs, lastStatus) {
|
|
460
|
+
super(`Application ${applicationId} did not finish deploying within ${Math.round(timeoutMs / 1e3)}s (${lastStatus ? `last status "${lastStatus}"` : "no deployment started"}). Check its deployment log in Dokploy, or raise deploy.dokploy.verify.deploymentTimeoutMs for an image that is slow to pull.`);
|
|
461
|
+
this.applicationId = applicationId;
|
|
462
|
+
this.timeoutMs = timeoutMs;
|
|
463
|
+
this.lastStatus = lastStatus;
|
|
464
|
+
this.name = "DeploymentTimedOut";
|
|
465
|
+
}
|
|
466
|
+
};
|
|
1027
467
|
var DokployApiError = class extends Error {
|
|
1028
468
|
status;
|
|
1029
469
|
statusText;
|
|
@@ -1331,6 +771,63 @@ var DokployApi = class {
|
|
|
1331
771
|
await this.post("application.deploy", { applicationId });
|
|
1332
772
|
}
|
|
1333
773
|
/**
|
|
774
|
+
* An application's deployments, newest first.
|
|
775
|
+
*
|
|
776
|
+
* Sorted here rather than trusted to arrive sorted: which deployment is
|
|
777
|
+
* the latest is the whole question `waitForDeployment` asks.
|
|
778
|
+
*/
|
|
779
|
+
async listDeployments(applicationId) {
|
|
780
|
+
return [...await this.get(`deployment.all?applicationId=${encodeURIComponent(applicationId)}`)].sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt));
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* When the application's latest deployment was created, by Dokploy's own
|
|
784
|
+
* clock — what `waitForDeployment`'s `since` is measured against. Epoch
|
|
785
|
+
* when it has none.
|
|
786
|
+
*/
|
|
787
|
+
async latestDeploymentAt(applicationId) {
|
|
788
|
+
const [latest] = await this.listDeployments(applicationId);
|
|
789
|
+
return new Date(latest ? Date.parse(latest.createdAt) : 0);
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Wait for the deployment `application.deploy` queued to finish.
|
|
793
|
+
*
|
|
794
|
+
* `application.deploy` only queues one: it answers before the image is
|
|
795
|
+
* pulled, let alone running, so a deploy that stopped there reported
|
|
796
|
+
* success for containers that had not started. This polls the latest
|
|
797
|
+
* deployment created after `since` — Dokploy's clock, from
|
|
798
|
+
* `latestDeploymentAt` before deploying, so a laptop's skew cannot pick an
|
|
799
|
+
* older one — and the application's own status, backing off from
|
|
800
|
+
* `intervalMs` to `maxIntervalMs`.
|
|
801
|
+
*
|
|
802
|
+
* @throws {DeploymentFailed} when the deployment ends in `error` or is
|
|
803
|
+
* cancelled, or the application reports `error` once it has finished.
|
|
804
|
+
* @throws {DeploymentTimedOut} when it has not finished within `timeoutMs`.
|
|
805
|
+
*/
|
|
806
|
+
async waitForDeployment(applicationId, options) {
|
|
807
|
+
const { since, timeoutMs = DEFAULT_DEPLOYMENT_TIMEOUT_MS, signal, intervalMs = 2e3, maxIntervalMs = 15e3 } = options;
|
|
808
|
+
const after = since.getTime();
|
|
809
|
+
const deadline = Date.now() + timeoutMs;
|
|
810
|
+
let interval = intervalMs;
|
|
811
|
+
let last;
|
|
812
|
+
while (true) {
|
|
813
|
+
signal?.throwIfAborted();
|
|
814
|
+
const deployment = (await this.listDeployments(applicationId)).find((d) => Date.parse(d.createdAt) > after);
|
|
815
|
+
last = deployment ?? last;
|
|
816
|
+
if (deployment) {
|
|
817
|
+
if (deployment.status === "error" || deployment.status === "cancelled") throw new DeploymentFailed(applicationId, deployment);
|
|
818
|
+
if (deployment.status === "done") {
|
|
819
|
+
const { applicationStatus } = await this.get(`application.one?applicationId=${encodeURIComponent(applicationId)}`);
|
|
820
|
+
if (applicationStatus === "error") throw new DeploymentFailed(applicationId, deployment);
|
|
821
|
+
if (applicationStatus !== "running") return deployment;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
const left = deadline - Date.now();
|
|
825
|
+
if (left <= 0) throw new DeploymentTimedOut(applicationId, timeoutMs, last?.status);
|
|
826
|
+
await pause(Math.min(interval, left), signal);
|
|
827
|
+
interval = Math.min(interval * 2, maxIntervalMs);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
1334
831
|
* Delete an application
|
|
1335
832
|
*/
|
|
1336
833
|
async deleteApplication(applicationId) {
|
|
@@ -2063,6 +1560,6 @@ async function sniffAllApps(apps, workspacePath, options = {}) {
|
|
|
2063
1560
|
return results;
|
|
2064
1561
|
}
|
|
2065
1562
|
//#endregion
|
|
2066
|
-
export {
|
|
1563
|
+
export { newLockHolder as _, DeploymentTimedOut as a, dokploy_api_exports as c, StateLocked as d, StateStoreBusy as f, createStateStore as g, contentVersion as h, DeploymentFailed as i, DocumentStateStore as l, StateVersionConflict as m, sniffAppEnvironment as n, DokployApi as o, StateStoreWithoutLocking as p, DEFAULT_DEPLOYMENT_TIMEOUT_MS as r, DokployApiError as s, sniffAllApps as t, StageStateMissing as u, eventError as v };
|
|
2067
1564
|
|
|
2068
|
-
//# sourceMappingURL=sniffer-
|
|
1565
|
+
//# sourceMappingURL=sniffer-BdFeLSmA.mjs.map
|