@geekmidas/cli 10.0.0-alpha.65 → 10.0.0-alpha.66
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 +14 -0
- package/dist/{HostingerProvider-Dlmbfass.cjs → HostingerProvider-BznqRC2S.cjs} +3 -3
- package/dist/HostingerProvider-BznqRC2S.cjs.map +1 -0
- package/dist/{HostingerProvider-x9gQTAGZ.mjs → HostingerProvider-CY_VpVud.mjs} +3 -3
- package/dist/HostingerProvider-CY_VpVud.mjs.map +1 -0
- package/dist/{LegacyStateStore-BGoo__sO.cjs → LegacyStateStore-BFcTT2QL.cjs} +2 -2
- package/dist/{LegacyStateStore-BGoo__sO.cjs.map → LegacyStateStore-BFcTT2QL.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BUu1nQ5u.mjs → LegacyStateStore-CFheFo62.mjs} +2 -2
- package/dist/{LegacyStateStore-BUu1nQ5u.mjs.map → LegacyStateStore-CFheFo62.mjs.map} +1 -1
- package/dist/{LocalStateStore-93urXyQe.cjs → LocalStateStore-BVUexSvu.cjs} +2 -2
- package/dist/{LocalStateStore-93urXyQe.cjs.map → LocalStateStore-BVUexSvu.cjs.map} +1 -1
- package/dist/{LocalStateStore-BRhMQRuy.mjs → LocalStateStore-Bm3x9oOg.mjs} +2 -2
- package/dist/{LocalStateStore-BRhMQRuy.mjs.map → LocalStateStore-Bm3x9oOg.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-pw1GhWwt.mjs → S3StateStore-BFHuctWM.mjs} +2 -2
- package/dist/{S3StateStore-pw1GhWwt.mjs.map → S3StateStore-BFHuctWM.mjs.map} +1 -1
- package/dist/{S3StateStore-F4dxw6kS.cjs → S3StateStore-CoXBhILd.cjs} +2 -2
- package/dist/{S3StateStore-F4dxw6kS.cjs.map → S3StateStore-CoXBhILd.cjs.map} +1 -1
- package/dist/{SSMStateStore-Bt9acuAF.cjs → SSMStateStore-BqCA9TP2.cjs} +2 -2
- package/dist/{SSMStateStore-Bt9acuAF.cjs.map → SSMStateStore-BqCA9TP2.cjs.map} +1 -1
- package/dist/{SSMStateStore-Dmj7zzFO.mjs → SSMStateStore-C1kvHScY.mjs} +2 -2
- package/dist/{SSMStateStore-Dmj7zzFO.mjs.map → SSMStateStore-C1kvHScY.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-Dvaiud0h.mjs} +4 -4
- package/dist/{bundler-D_14JLZF.mjs.map → bundler-Dvaiud0h.mjs.map} +1 -1
- package/dist/{bundler-D6MlIfBT.cjs → bundler-orRqUJNZ.cjs} +4 -4
- package/dist/{bundler-D6MlIfBT.cjs.map → bundler-orRqUJNZ.cjs.map} +1 -1
- package/dist/{cli-P56vvrDQ.mjs → cli-CfHm0AO7.mjs} +5 -4
- package/dist/cli-CfHm0AO7.mjs.map +1 -0
- package/dist/{cli-BfH1deAT.cjs → cli-D1JkkOwg.cjs} +5 -4
- package/dist/cli-D1JkkOwg.cjs.map +1 -0
- package/dist/{compose-DprE3ASm.mjs → compose-CNQL8BnO.mjs} +18 -482
- package/dist/compose-CNQL8BnO.mjs.map +1 -0
- package/dist/{compose-391oEKj1.cjs → compose-jrLy7KGO.cjs} +16 -571
- package/dist/compose-jrLy7KGO.cjs.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/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 +26 -17
- 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 +8 -8
- package/dist/deploy-B7aJi_Ah.cjs +511 -0
- package/dist/deploy-B7aJi_Ah.cjs.map +1 -0
- package/dist/deploy-DWn7YfIc.mjs +488 -0
- package/dist/deploy-DWn7YfIc.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-B4LcYG1E.cjs +38 -0
- package/dist/dokploy-B4LcYG1E.cjs.map +1 -0
- package/dist/dokploy-DalwLML5.mjs +38 -0
- package/dist/dokploy-DalwLML5.mjs.map +1 -0
- package/dist/{encryption-B1wJwgae.cjs → encryption-3KlGS1sl.cjs} +5 -7
- package/dist/{encryption-B1wJwgae.cjs.map → encryption-3KlGS1sl.cjs.map} +1 -1
- package/dist/{encryption-DF_hgIpl.mjs → encryption-CPfENwWO.mjs} +3 -5
- package/dist/{encryption-DF_hgIpl.mjs.map → encryption-CPfENwWO.mjs.map} +1 -1
- package/dist/{deploy-CZ5nlpsu.mjs → engine-CunvOG3s.mjs} +2100 -1733
- package/dist/engine-CunvOG3s.mjs.map +1 -0
- package/dist/{deploy-Cy8igpQF.cjs → engine-DR6KurWX.cjs} +2136 -1727
- package/dist/engine-DR6KurWX.cjs.map +1 -0
- package/dist/{github-CYcmTdFs.cjs → github-BJ5gh9bw.cjs} +7 -7
- package/dist/{github-CYcmTdFs.cjs.map → github-BJ5gh9bw.cjs.map} +1 -1
- package/dist/{github-B0YYE98x.mjs → github-MXA9v7Ge.mjs} +3 -3
- package/dist/{github-B0YYE98x.mjs.map → github-MXA9v7Ge.mjs.map} +1 -1
- package/dist/{index-DwKD_8lt.d.mts → index-CyApaHVe.d.cts} +2 -2
- package/dist/{index-DPUAGJaK.d.cts.map → index-CyApaHVe.d.cts.map} +1 -1
- package/dist/{index-DPUAGJaK.d.cts → 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 +276 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +254 -50
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-B2qL5wj4.mjs → migrate-BJBcm4sG.mjs} +6 -6
- package/dist/{migrate-B2qL5wj4.mjs.map → migrate-BJBcm4sG.mjs.map} +1 -1
- package/dist/{migrate-q4pPAXtO.cjs → migrate-CF4J4GQS.cjs} +16 -16
- package/dist/{migrate-q4pPAXtO.cjs.map → migrate-CF4J4GQS.cjs.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-CVmch0wI.cjs} +3 -3
- package/dist/{resolve-N_i4XNd-.cjs.map → resolve-CVmch0wI.cjs.map} +1 -1
- package/dist/{resolve-DLkIXTct.mjs → resolve-Db0tNlrW.mjs} +3 -3
- package/dist/{resolve-DLkIXTct.mjs.map → resolve-Db0tNlrW.mjs.map} +1 -1
- package/dist/rollback-DvAo4OKS.mjs +133 -0
- package/dist/rollback-DvAo4OKS.mjs.map +1 -0
- package/dist/rollback-DxJK84hy.cjs +162 -0
- package/dist/rollback-DxJK84hy.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-BSwaL-dX.cjs → sniffer-5xmrkh2a.cjs} +112 -606
- package/dist/sniffer-5xmrkh2a.cjs.map +1 -0
- package/dist/{sniffer-BZ-OJO4Y.mjs → sniffer-BAQhLEsI.mjs} +95 -546
- package/dist/sniffer-BAQhLEsI.mjs.map +1 -0
- package/dist/{state-DF26e_lo.cjs → state-Y6ATakMX.cjs} +744 -20
- package/dist/state-Y6ATakMX.cjs.map +1 -0
- package/dist/{state-B8YwmUZU.mjs → state-uuYqnRVO.mjs} +605 -19
- package/dist/state-uuYqnRVO.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-Bs5E1oxm.cjs → terminal-CHy_MdjG.cjs} +11 -15
- package/dist/{terminal-Bs5E1oxm.cjs.map → terminal-CHy_MdjG.cjs.map} +1 -1
- package/dist/{terminal-CfbiYUbZ.mjs → terminal-DUhcZ1ND.mjs} +4 -4
- package/dist/{terminal-CfbiYUbZ.mjs.map → terminal-DUhcZ1ND.mjs.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/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/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/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
2
|
import { t as LocalSandbox } from "./local-CWR4Y_kW.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { d as output, r as discover, s as nodeWithTsx } from "./discover-LMrqsWSU.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
10
|
import { createCipheriv, createHash, randomBytes, randomUUID } from "node:crypto";
|
|
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
|
|
204
11
|
//#region src/workspace/client-generator.ts
|
|
205
12
|
/**
|
|
206
13
|
* Normalize routes to an array of patterns.
|
|
@@ -264,66 +71,6 @@ function keyFingerprint(masterKey) {
|
|
|
264
71
|
return createHash("sha256").update(masterKey).digest("hex").slice(0, 8);
|
|
265
72
|
}
|
|
266
73
|
//#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
74
|
//#region src/deploy/events.ts
|
|
328
75
|
/** An error as an event carries it: its name and message, nothing else. */
|
|
329
76
|
function eventError(error) {
|
|
@@ -658,17 +405,17 @@ function isStateStore(value) {
|
|
|
658
405
|
async function createStateStore(options) {
|
|
659
406
|
const { config, workspaceRoot, workspaceName } = options;
|
|
660
407
|
if (!config || config.provider === "local") {
|
|
661
|
-
const { LocalStateStore } = await import("./LocalStateStore-
|
|
408
|
+
const { LocalStateStore } = await import("./LocalStateStore-Bm3x9oOg.mjs").then((n) => n.n);
|
|
662
409
|
return new LocalStateStore(workspaceRoot);
|
|
663
410
|
}
|
|
664
411
|
if (isStateStore(config.provider)) return config.provider;
|
|
665
412
|
if (isStateProvider(config.provider)) {
|
|
666
|
-
const { LegacyStateStore } = await import("./LegacyStateStore-
|
|
413
|
+
const { LegacyStateStore } = await import("./LegacyStateStore-CFheFo62.mjs");
|
|
667
414
|
return new LegacyStateStore(config.provider, { warn: options.warn });
|
|
668
415
|
}
|
|
669
416
|
if (config.provider === "ssm") {
|
|
670
417
|
if (!workspaceName) throw new StateStoreNeedsWorkspaceName("ssm");
|
|
671
|
-
const { SSMStateStore } = await import("./SSMStateStore-
|
|
418
|
+
const { SSMStateStore } = await import("./SSMStateStore-C1kvHScY.mjs");
|
|
672
419
|
const ssm = config;
|
|
673
420
|
return SSMStateStore.create({
|
|
674
421
|
workspaceName,
|
|
@@ -678,7 +425,7 @@ async function createStateStore(options) {
|
|
|
678
425
|
}
|
|
679
426
|
if (config.provider === "s3") {
|
|
680
427
|
if (!workspaceName) throw new StateStoreNeedsWorkspaceName("s3");
|
|
681
|
-
const { S3StateStore } = await import("./S3StateStore-
|
|
428
|
+
const { S3StateStore } = await import("./S3StateStore-BFHuctWM.mjs");
|
|
682
429
|
const s3 = config;
|
|
683
430
|
return S3StateStore.create({
|
|
684
431
|
workspaceName,
|
|
@@ -691,293 +438,12 @@ async function createStateStore(options) {
|
|
|
691
438
|
throw new UnknownStateProvider(config);
|
|
692
439
|
}
|
|
693
440
|
//#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
|
|
441
|
+
//#region src/target/dokploy/dokploy-api.ts
|
|
979
442
|
var dokploy_api_exports = /* @__PURE__ */ __exportAll({
|
|
443
|
+
DEFAULT_DEPLOYMENT_TIMEOUT_MS: () => DEFAULT_DEPLOYMENT_TIMEOUT_MS,
|
|
980
444
|
DEFAULT_DOKPLOY_TIMEOUT_MS: () => DEFAULT_DOKPLOY_TIMEOUT_MS,
|
|
445
|
+
DeploymentFailed: () => DeploymentFailed,
|
|
446
|
+
DeploymentTimedOut: () => DeploymentTimedOut,
|
|
981
447
|
DokployApi: () => DokployApi,
|
|
982
448
|
DokployApiError: () => DokployApiError,
|
|
983
449
|
DokployRequestTimedOut: () => DokployRequestTimedOut
|
|
@@ -1024,6 +490,32 @@ function pause(ms, signal) {
|
|
|
1024
490
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1025
491
|
});
|
|
1026
492
|
}
|
|
493
|
+
/** How long a deployment may take to finish before a deploy gives up on it. */
|
|
494
|
+
const DEFAULT_DEPLOYMENT_TIMEOUT_MS = 6e5;
|
|
495
|
+
/** A deployment Dokploy ran and reported as failed. */
|
|
496
|
+
var DeploymentFailed = class extends Error {
|
|
497
|
+
applicationId;
|
|
498
|
+
deployment;
|
|
499
|
+
constructor(applicationId, deployment) {
|
|
500
|
+
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.`);
|
|
501
|
+
this.applicationId = applicationId;
|
|
502
|
+
this.deployment = deployment;
|
|
503
|
+
this.name = "DeploymentFailed";
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
/** A deployment that had not finished when the deploy stopped waiting. */
|
|
507
|
+
var DeploymentTimedOut = class extends Error {
|
|
508
|
+
applicationId;
|
|
509
|
+
timeoutMs;
|
|
510
|
+
lastStatus;
|
|
511
|
+
constructor(applicationId, timeoutMs, lastStatus) {
|
|
512
|
+
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.`);
|
|
513
|
+
this.applicationId = applicationId;
|
|
514
|
+
this.timeoutMs = timeoutMs;
|
|
515
|
+
this.lastStatus = lastStatus;
|
|
516
|
+
this.name = "DeploymentTimedOut";
|
|
517
|
+
}
|
|
518
|
+
};
|
|
1027
519
|
var DokployApiError = class extends Error {
|
|
1028
520
|
status;
|
|
1029
521
|
statusText;
|
|
@@ -1331,6 +823,63 @@ var DokployApi = class {
|
|
|
1331
823
|
await this.post("application.deploy", { applicationId });
|
|
1332
824
|
}
|
|
1333
825
|
/**
|
|
826
|
+
* An application's deployments, newest first.
|
|
827
|
+
*
|
|
828
|
+
* Sorted here rather than trusted to arrive sorted: which deployment is
|
|
829
|
+
* the latest is the whole question `waitForDeployment` asks.
|
|
830
|
+
*/
|
|
831
|
+
async listDeployments(applicationId) {
|
|
832
|
+
return [...await this.get(`deployment.all?applicationId=${encodeURIComponent(applicationId)}`)].sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt));
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* When the application's latest deployment was created, by Dokploy's own
|
|
836
|
+
* clock — what `waitForDeployment`'s `since` is measured against. Epoch
|
|
837
|
+
* when it has none.
|
|
838
|
+
*/
|
|
839
|
+
async latestDeploymentAt(applicationId) {
|
|
840
|
+
const [latest] = await this.listDeployments(applicationId);
|
|
841
|
+
return new Date(latest ? Date.parse(latest.createdAt) : 0);
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Wait for the deployment `application.deploy` queued to finish.
|
|
845
|
+
*
|
|
846
|
+
* `application.deploy` only queues one: it answers before the image is
|
|
847
|
+
* pulled, let alone running, so a deploy that stopped there reported
|
|
848
|
+
* success for containers that had not started. This polls the latest
|
|
849
|
+
* deployment created after `since` — Dokploy's clock, from
|
|
850
|
+
* `latestDeploymentAt` before deploying, so a laptop's skew cannot pick an
|
|
851
|
+
* older one — and the application's own status, backing off from
|
|
852
|
+
* `intervalMs` to `maxIntervalMs`.
|
|
853
|
+
*
|
|
854
|
+
* @throws {DeploymentFailed} when the deployment ends in `error` or is
|
|
855
|
+
* cancelled, or the application reports `error` once it has finished.
|
|
856
|
+
* @throws {DeploymentTimedOut} when it has not finished within `timeoutMs`.
|
|
857
|
+
*/
|
|
858
|
+
async waitForDeployment(applicationId, options) {
|
|
859
|
+
const { since, timeoutMs = DEFAULT_DEPLOYMENT_TIMEOUT_MS, signal, intervalMs = 2e3, maxIntervalMs = 15e3 } = options;
|
|
860
|
+
const after = since.getTime();
|
|
861
|
+
const deadline = Date.now() + timeoutMs;
|
|
862
|
+
let interval = intervalMs;
|
|
863
|
+
let last;
|
|
864
|
+
while (true) {
|
|
865
|
+
signal?.throwIfAborted();
|
|
866
|
+
const deployment = (await this.listDeployments(applicationId)).find((d) => Date.parse(d.createdAt) > after);
|
|
867
|
+
last = deployment ?? last;
|
|
868
|
+
if (deployment) {
|
|
869
|
+
if (deployment.status === "error" || deployment.status === "cancelled") throw new DeploymentFailed(applicationId, deployment);
|
|
870
|
+
if (deployment.status === "done") {
|
|
871
|
+
const { applicationStatus } = await this.get(`application.one?applicationId=${encodeURIComponent(applicationId)}`);
|
|
872
|
+
if (applicationStatus === "error") throw new DeploymentFailed(applicationId, deployment);
|
|
873
|
+
if (applicationStatus !== "running") return deployment;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
const left = deadline - Date.now();
|
|
877
|
+
if (left <= 0) throw new DeploymentTimedOut(applicationId, timeoutMs, last?.status);
|
|
878
|
+
await pause(Math.min(interval, left), signal);
|
|
879
|
+
interval = Math.min(interval * 2, maxIntervalMs);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
1334
883
|
* Delete an application
|
|
1335
884
|
*/
|
|
1336
885
|
async deleteApplication(applicationId) {
|
|
@@ -2063,6 +1612,6 @@ async function sniffAllApps(apps, workspacePath, options = {}) {
|
|
|
2063
1612
|
return results;
|
|
2064
1613
|
}
|
|
2065
1614
|
//#endregion
|
|
2066
|
-
export {
|
|
1615
|
+
export { newLockHolder as _, DeploymentTimedOut as a, encryption_exports as b, 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, keyFingerprint as x, encryptSecrets as y };
|
|
2067
1616
|
|
|
2068
|
-
//# sourceMappingURL=sniffer-
|
|
1617
|
+
//# sourceMappingURL=sniffer-BAQhLEsI.mjs.map
|