@geekmidas/cli 10.0.0-alpha.94 → 10.0.0-alpha.96
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/dist/{GoDaddyProvider-BRZUWD8z.mjs → GoDaddyProvider-BsUKjGcg.mjs} +3 -3
- package/dist/{GoDaddyProvider-BRZUWD8z.mjs.map → GoDaddyProvider-BsUKjGcg.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-DzguxU_a.cjs → GoDaddyProvider-DyHXHDHe.cjs} +3 -3
- package/dist/{GoDaddyProvider-DzguxU_a.cjs.map → GoDaddyProvider-DyHXHDHe.cjs.map} +1 -1
- package/dist/{HostingerProvider-Cjh_2Ml6.mjs → HostingerProvider-BNpS9aRJ.mjs} +2 -2
- package/dist/{HostingerProvider-Cjh_2Ml6.mjs.map → HostingerProvider-BNpS9aRJ.mjs.map} +1 -1
- package/dist/{HostingerProvider-OdQmKXE3.cjs → HostingerProvider-DR1iws1P.cjs} +2 -2
- package/dist/{HostingerProvider-OdQmKXE3.cjs.map → HostingerProvider-DR1iws1P.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BQZb6-j2.mjs → LegacyStateStore-B6SOqRFi.mjs} +3 -3
- package/dist/{LegacyStateStore-BQZb6-j2.mjs.map → LegacyStateStore-B6SOqRFi.mjs.map} +1 -1
- package/dist/{LegacyStateStore-D50dgUPc.cjs → LegacyStateStore-BnMcONE0.cjs} +3 -3
- package/dist/{LegacyStateStore-D50dgUPc.cjs.map → LegacyStateStore-BnMcONE0.cjs.map} +1 -1
- package/dist/{LocalStateStore-BSaS2535.mjs → LocalStateStore-6CrsZzqI.mjs} +2 -2
- package/dist/{LocalStateStore-BSaS2535.mjs.map → LocalStateStore-6CrsZzqI.mjs.map} +1 -1
- package/dist/{LocalStateStore-EFBUjuMX.cjs → LocalStateStore-pd4bbdJJ.cjs} +2 -2
- package/dist/{LocalStateStore-EFBUjuMX.cjs.map → LocalStateStore-pd4bbdJJ.cjs.map} +1 -1
- package/dist/{S3StateStore-C5mv8To3.cjs → S3StateStore-CoGk6ZKU.cjs} +2 -2
- package/dist/{S3StateStore-C5mv8To3.cjs.map → S3StateStore-CoGk6ZKU.cjs.map} +1 -1
- package/dist/{S3StateStore-CrFq4UZU.mjs → S3StateStore-DP_7Q4yb.mjs} +2 -2
- package/dist/{S3StateStore-CrFq4UZU.mjs.map → S3StateStore-DP_7Q4yb.mjs.map} +1 -1
- package/dist/{SSMStateStore-D3Z6mZnA.mjs → SSMStateStore-Bo6_KDYY.mjs} +2 -2
- package/dist/{SSMStateStore-D3Z6mZnA.mjs.map → SSMStateStore-Bo6_KDYY.mjs.map} +1 -1
- package/dist/{SSMStateStore-DuZCH7_v.cjs → SSMStateStore-D9s4_Do3.cjs} +2 -2
- package/dist/{SSMStateStore-DuZCH7_v.cjs.map → SSMStateStore-D9s4_Do3.cjs.map} +1 -1
- package/dist/{add-C85isXFl.mjs → add-BQS2QZHp.mjs} +22 -51
- package/dist/add-BQS2QZHp.mjs.map +1 -0
- package/dist/{add-DsVDdvon.cjs → add-CjURJ-vI.cjs} +23 -52
- package/dist/add-CjURJ-vI.cjs.map +1 -0
- package/dist/{bundler-BSHog8CH.mjs → bundler-BMM3UsGm.mjs} +5 -5
- package/dist/{bundler-BSHog8CH.mjs.map → bundler-BMM3UsGm.mjs.map} +1 -1
- package/dist/{bundler-BEgUKc4j.cjs → bundler-DmLJQ7AY.cjs} +5 -5
- package/dist/{bundler-BEgUKc4j.cjs.map → bundler-DmLJQ7AY.cjs.map} +1 -1
- package/dist/{cli-BvBdv660.cjs → cli-C2c-jOVK.cjs} +4 -4
- package/dist/{cli-BvBdv660.cjs.map → cli-C2c-jOVK.cjs.map} +1 -1
- package/dist/{cli-BsFenyaf.mjs → cli-Ce6NgaQF.mjs} +4 -4
- package/dist/{cli-BsFenyaf.mjs.map → cli-Ce6NgaQF.mjs.map} +1 -1
- package/dist/{compose-D2RFYd_f.mjs → compose-BJDPFBAN.mjs} +43 -47
- package/dist/compose-BJDPFBAN.mjs.map +1 -0
- package/dist/{compose-Cd09gW-n.cjs → compose-ETFKqkTu.cjs} +60 -64
- package/dist/compose-ETFKqkTu.cjs.map +1 -0
- package/dist/{config-Ngesg4O8.d.mts → config-4yirvxS8.d.cts} +4 -4
- package/dist/{config-DvHNMoOp.d.cts.map → config-4yirvxS8.d.cts.map} +1 -1
- package/dist/{config-DvHNMoOp.d.cts → config-C8NPCn1l.d.mts} +4 -4
- package/dist/{config-Ngesg4O8.d.mts.map → config-C8NPCn1l.d.mts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/{credentials-DpfnUvIR.mjs → credentials-B5N5yKk6.mjs} +4 -132
- package/dist/credentials-B5N5yKk6.mjs.map +1 -0
- package/dist/{credentials-D7XJypNd.cjs → credentials-Zqr3QQYB.cjs} +3 -173
- package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
- package/dist/deploy/public.cjs +16 -15
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts +5 -5
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +5 -5
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +11 -10
- package/dist/deploy/public.mjs.map +1 -1
- package/dist/deploy-BdN0ym2i.cjs +2057 -0
- package/dist/deploy-BdN0ym2i.cjs.map +1 -0
- package/dist/deploy-DktQl7ti.mjs +2008 -0
- package/dist/deploy-DktQl7ti.mjs.map +1 -0
- package/dist/{discover-CTzOSGUF.d.cts → discover-BtFofyQB.d.cts} +2 -2
- package/dist/{discover-CTzOSGUF.d.cts.map → discover-BtFofyQB.d.cts.map} +1 -1
- package/dist/{discover-CihAtaoj.d.mts → discover-D-MdXZgm.d.mts} +2 -2
- package/dist/{discover-CihAtaoj.d.mts.map → discover-D-MdXZgm.d.mts.map} +1 -1
- package/dist/dns-BjHECDO7.mjs +44 -0
- package/dist/dns-BjHECDO7.mjs.map +1 -0
- package/dist/dns-C-X6PLkV.cjs +663 -0
- package/dist/dns-C-X6PLkV.cjs.map +1 -0
- package/dist/dns-C2EeR6n2.mjs +610 -0
- package/dist/dns-C2EeR6n2.mjs.map +1 -0
- package/dist/dns-ClI7-d5g.cjs +55 -0
- package/dist/dns-ClI7-d5g.cjs.map +1 -0
- package/dist/{dokploy-CV7GcobZ.cjs → dokploy-CD_Bc4EV.cjs} +2 -2
- package/dist/{dokploy-CV7GcobZ.cjs.map → dokploy-CD_Bc4EV.cjs.map} +1 -1
- package/dist/{dokploy-D_aat2Xj.mjs → dokploy-CxtkS5hl.mjs} +2 -2
- package/dist/{dokploy-D_aat2Xj.mjs.map → dokploy-CxtkS5hl.mjs.map} +1 -1
- package/dist/{encryption-_4qKqtTx.mjs → encryption-BgQd4f2S.mjs} +3 -3
- package/dist/{encryption-_4qKqtTx.mjs.map → encryption-BgQd4f2S.mjs.map} +1 -1
- package/dist/{encryption-DFcivJaO.cjs → encryption-CqVfz-m7.cjs} +3 -3
- package/dist/{encryption-DFcivJaO.cjs.map → encryption-CqVfz-m7.cjs.map} +1 -1
- package/dist/{engine-Bv-LZpmj.cjs → engine-OVVKtPmW.cjs} +18 -36
- package/dist/engine-OVVKtPmW.cjs.map +1 -0
- package/dist/{engine-DPMHThkg.mjs → engine-YlXzlTUl.mjs} +14 -32
- package/dist/{engine-DPMHThkg.mjs.map → engine-YlXzlTUl.mjs.map} +1 -1
- package/dist/{github-Br42NMrW.cjs → github-CsMloeSL.cjs} +9 -7
- package/dist/{github-Br42NMrW.cjs.map → github-CsMloeSL.cjs.map} +1 -1
- package/dist/{github-xsDT19im.mjs → github-DuuvqI3Z.mjs} +5 -3
- package/dist/{github-xsDT19im.mjs.map → github-DuuvqI3Z.mjs.map} +1 -1
- package/dist/{index-CwLvFqtH.d.cts → index-5eL8rM6H.d.mts} +2 -2
- package/dist/{index-BlpcClwM.d.mts.map → index-5eL8rM6H.d.mts.map} +1 -1
- package/dist/{index-BlpcClwM.d.mts → index-Dz-gyjm_.d.cts} +2 -2
- package/dist/{index-CwLvFqtH.d.cts.map → index-Dz-gyjm_.d.cts.map} +1 -1
- package/dist/index.cjs +54 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +52 -51
- package/dist/index.mjs.map +1 -1
- package/dist/{local-B7Zv1NoA.mjs → local-BwC2v2Y8.mjs} +2 -2
- package/dist/{local-B7Zv1NoA.mjs.map → local-BwC2v2Y8.mjs.map} +1 -1
- package/dist/{local-OPC9BCZt.cjs → local-DNhnkugT.cjs} +3 -3
- package/dist/{local-OPC9BCZt.cjs.map → local-DNhnkugT.cjs.map} +1 -1
- package/dist/{migrate-D5jUz20_.cjs → migrate-BAmJeVq1.cjs} +3 -3
- package/dist/{migrate-D5jUz20_.cjs.map → migrate-BAmJeVq1.cjs.map} +1 -1
- package/dist/{migrate-SkWJotn5.cjs → migrate-BdkoNdIu.cjs} +3 -3
- package/dist/{migrate-SkWJotn5.cjs.map → migrate-BdkoNdIu.cjs.map} +1 -1
- package/dist/{migrate-DhvFPGLi.mjs → migrate-CB8B6W9y.mjs} +3 -3
- package/dist/{migrate-DhvFPGLi.mjs.map → migrate-CB8B6W9y.mjs.map} +1 -1
- package/dist/{migrate-B7evHv7O.mjs → migrate-CsPFHgTs.mjs} +3 -3
- package/dist/{migrate-B7evHv7O.mjs.map → migrate-CsPFHgTs.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/reconcile/public.d.cts +2 -2
- package/dist/reconcile/public.d.mts +2 -2
- package/dist/{resolve-CFEOtRsl.cjs → resolve-BDatNOoG.cjs} +4 -4
- package/dist/{resolve-CFEOtRsl.cjs.map → resolve-BDatNOoG.cjs.map} +1 -1
- package/dist/{resolve-Dyd1S2wn.mjs → resolve-CUne0qOm.mjs} +4 -4
- package/dist/{resolve-Dyd1S2wn.mjs.map → resolve-CUne0qOm.mjs.map} +1 -1
- package/dist/{rollback-NroNbGC0.mjs → rollback-CCdEEEcF.mjs} +7 -8
- package/dist/{rollback-NroNbGC0.mjs.map → rollback-CCdEEEcF.mjs.map} +1 -1
- package/dist/{rollback-D720SFhV.cjs → rollback-CuG3DkTY.cjs} +8 -9
- package/dist/{rollback-D720SFhV.cjs.map → rollback-CuG3DkTY.cjs.map} +1 -1
- 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-VktAo_8B.d.cts → runtime-DUQdM-mW.d.cts} +2 -2
- package/dist/{runtime-BRCq6dQ7.d.mts.map → runtime-DUQdM-mW.d.cts.map} +1 -1
- package/dist/{runtime-BRCq6dQ7.d.mts → runtime-Vr6mleo2.d.mts} +2 -2
- package/dist/{runtime-VktAo_8B.d.cts.map → runtime-Vr6mleo2.d.mts.map} +1 -1
- package/dist/{sandbox-D1gd0iDz.d.cts → sandbox-BbJmh2rI.d.cts} +2 -2
- package/dist/{sandbox-D1gd0iDz.d.cts.map → sandbox-BbJmh2rI.d.cts.map} +1 -1
- package/dist/{sandbox-zHnRLCj0.d.mts → sandbox-DGOsMPMf.d.mts} +2 -2
- package/dist/{sandbox-zHnRLCj0.d.mts.map → sandbox-DGOsMPMf.d.mts.map} +1 -1
- package/dist/{secrets-DAvi_O9g.cjs → secrets-C5qROlbp.cjs} +3 -3
- package/dist/{secrets-DAvi_O9g.cjs.map → secrets-C5qROlbp.cjs.map} +1 -1
- package/dist/{secrets-CwLauUB_.mjs → secrets-ZikTIxEm.mjs} +3 -3
- package/dist/{secrets-CwLauUB_.mjs.map → secrets-ZikTIxEm.mjs.map} +1 -1
- package/dist/{seeds-BCg8X36S.cjs → seeds-BjXW-Krf.cjs} +193 -946
- package/dist/seeds-BjXW-Krf.cjs.map +1 -0
- package/dist/{seeds-CTxTZa-R.mjs → seeds-CbJSne1A.mjs} +156 -825
- package/dist/seeds-CbJSne1A.mjs.map +1 -0
- package/dist/{sniffer-DCcuzHz_.mjs → sniffer-DQGBYY8i.mjs} +8 -8
- package/dist/{sniffer-DCcuzHz_.mjs.map → sniffer-DQGBYY8i.mjs.map} +1 -1
- package/dist/{sniffer-C0z3NB2A.cjs → sniffer-NPD1dyab.cjs} +8 -8
- package/dist/{sniffer-C0z3NB2A.cjs.map → sniffer-NPD1dyab.cjs.map} +1 -1
- package/dist/{sst-DRDSDwOk.mjs → sst-CGdjHn2A.mjs} +4 -3
- package/dist/{sst-DRDSDwOk.mjs.map → sst-CGdjHn2A.mjs.map} +1 -1
- package/dist/{sst-DKNH243z.cjs → sst-DGuHDxVU.cjs} +5 -4
- package/dist/{sst-DKNH243z.cjs.map → sst-DGuHDxVU.cjs.map} +1 -1
- package/dist/{stack-NrdH5ngX.mjs → stack-BFq3K-_z.mjs} +14 -52
- package/dist/stack-BFq3K-_z.mjs.map +1 -0
- package/dist/{stack-B3fPDTBg.cjs → stack-DOVvEd1T.cjs} +14 -52
- package/dist/stack-DOVvEd1T.cjs.map +1 -0
- package/dist/{stages-veC4TcQe.mjs → stages-BEn2ArJZ.mjs} +4 -3
- package/dist/{stages-veC4TcQe.mjs.map → stages-BEn2ArJZ.mjs.map} +1 -1
- package/dist/{stages-CkqP1N4S.cjs → stages-Cw6urZyJ.cjs} +5 -4
- package/dist/{stages-CkqP1N4S.cjs.map → stages-Cw6urZyJ.cjs.map} +1 -1
- 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-CkUYuAPd.cjs → terminal-CPHuH4S1.cjs} +2 -2
- package/dist/{terminal-CkUYuAPd.cjs.map → terminal-CPHuH4S1.cjs.map} +1 -1
- package/dist/{terminal-DAHs2Zko.mjs → terminal-iNmAXXjs.mjs} +2 -2
- package/dist/{terminal-DAHs2Zko.mjs.map → terminal-iNmAXXjs.mjs.map} +1 -1
- package/dist/{types-DMoaFrjg.d.mts → types-bkqVscdN.d.mts} +12 -3
- package/dist/types-bkqVscdN.d.mts.map +1 -0
- package/dist/{types-DXyaSmqu.d.cts → types-dipJRmKV.d.cts} +12 -3
- package/dist/types-dipJRmKV.d.cts.map +1 -0
- 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-DWK1PTXP.mjs → workspace-CqFUjObk.mjs} +54 -2
- package/dist/workspace-CqFUjObk.mjs.map +1 -0
- package/dist/{workspace-cSyi5nb1.cjs → workspace-DDkm4y6D.cjs} +71 -1
- package/dist/workspace-DDkm4y6D.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/add-C85isXFl.mjs.map +0 -1
- package/dist/add-DsVDdvon.cjs.map +0 -1
- package/dist/compose-Cd09gW-n.cjs.map +0 -1
- package/dist/compose-D2RFYd_f.mjs.map +0 -1
- package/dist/credentials-D7XJypNd.cjs.map +0 -1
- package/dist/credentials-DpfnUvIR.mjs.map +0 -1
- package/dist/deploy-C911Akkn.cjs +0 -670
- package/dist/deploy-C911Akkn.cjs.map +0 -1
- package/dist/deploy-CeJ5D0xn.mjs +0 -641
- package/dist/deploy-CeJ5D0xn.mjs.map +0 -1
- package/dist/engine-Bv-LZpmj.cjs.map +0 -1
- package/dist/providers-BFeP_mYw.cjs +0 -1098
- package/dist/providers-BFeP_mYw.cjs.map +0 -1
- package/dist/providers-sTj-BG0S.mjs +0 -1079
- package/dist/providers-sTj-BG0S.mjs.map +0 -1
- package/dist/seeds-BCg8X36S.cjs.map +0 -1
- package/dist/seeds-CTxTZa-R.mjs.map +0 -1
- package/dist/stack-B3fPDTBg.cjs.map +0 -1
- package/dist/stack-NrdH5ngX.mjs.map +0 -1
- package/dist/types-DMoaFrjg.d.mts.map +0 -1
- package/dist/types-DXyaSmqu.d.cts.map +0 -1
- package/dist/workspace-DWK1PTXP.mjs.map +0 -1
- package/dist/workspace-cSyi5nb1.cjs.map +0 -1
package/dist/deploy-C911Akkn.cjs
DELETED
|
@@ -1,670 +0,0 @@
|
|
|
1
|
-
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
2
|
-
const require_credentials = require("./credentials-D7XJypNd.cjs");
|
|
3
|
-
const require_discover = require("./discover-DPgu-ScS.cjs");
|
|
4
|
-
const require_sandbox = require("./sandbox-CHv3OYXg.cjs");
|
|
5
|
-
const require_derive = require("./derive-DAbo49sm.cjs");
|
|
6
|
-
const require_workspace = require("./workspace-cSyi5nb1.cjs");
|
|
7
|
-
const require_define = require("./define-crmMcXFS.cjs");
|
|
8
|
-
const require_config = require("./config.cjs");
|
|
9
|
-
const require_seeds = require("./seeds-BCg8X36S.cjs");
|
|
10
|
-
const require_resolve = require("./resolve-CFEOtRsl.cjs");
|
|
11
|
-
const require_local = require("./local-OPC9BCZt.cjs");
|
|
12
|
-
const require_sniffer = require("./sniffer-C0z3NB2A.cjs");
|
|
13
|
-
const require_providers = require("./providers-BFeP_mYw.cjs");
|
|
14
|
-
let node_path = require("node:path");
|
|
15
|
-
//#region src/target/secrets.ts
|
|
16
|
-
/**
|
|
17
|
-
* A stage's secrets as a target sees them: read and written through the
|
|
18
|
-
* stage's own store, and masked in everything the run prints once read.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Shorter values are left alone: what a progress line legitimately prints —
|
|
22
|
-
* a port, a stage, an app name — would otherwise come out as `***` wherever
|
|
23
|
-
* a secret happened to share it.
|
|
24
|
-
*/
|
|
25
|
-
const SHORTEST_MASKED = 6;
|
|
26
|
-
/** The values a run must never print, and the rewrite that keeps it so. */
|
|
27
|
-
var Redactor = class {
|
|
28
|
-
values = /* @__PURE__ */ new Set();
|
|
29
|
-
add(value) {
|
|
30
|
-
if (value && value.length >= SHORTEST_MASKED) this.values.add(value);
|
|
31
|
-
}
|
|
32
|
-
/** `text` with every masked value replaced by `***`, longest first. */
|
|
33
|
-
redact(text) {
|
|
34
|
-
if (this.values.size === 0) return text;
|
|
35
|
-
let out = text;
|
|
36
|
-
const longestFirst = [...this.values].sort((a, b) => b.length - a.length);
|
|
37
|
-
for (const value of longestFirst) out = out.replaceAll(value, "***");
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
/** Every value in `secrets` that is a secret rather than a label. */
|
|
42
|
-
function secretValues(secrets) {
|
|
43
|
-
return [
|
|
44
|
-
secrets.seed,
|
|
45
|
-
...Object.values(secrets.custom ?? {}),
|
|
46
|
-
...Object.values(secrets.urls ?? {}),
|
|
47
|
-
...Object.values(secrets.services ?? {}).map((service) => service?.password)
|
|
48
|
-
].filter((value) => typeof value === "string");
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* The stage's secrets through the store `secrets.store` names for it. Opening
|
|
52
|
-
* one builds a client and makes no request, so a target that never reads them
|
|
53
|
-
* costs nothing.
|
|
54
|
-
*/
|
|
55
|
-
async function deploySecrets(workspace, stage, redactor, options = {}) {
|
|
56
|
-
const store = await require_seeds.secretsStoreFor(workspace, stage, options);
|
|
57
|
-
const mask = (secrets) => {
|
|
58
|
-
for (const value of secretValues(secrets)) redactor.add(value);
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
store: store.name,
|
|
62
|
-
async read() {
|
|
63
|
-
const secrets = await store.read(stage);
|
|
64
|
-
if (secrets) mask(secrets);
|
|
65
|
-
return secrets;
|
|
66
|
-
},
|
|
67
|
-
async write(secrets) {
|
|
68
|
-
mask(secrets);
|
|
69
|
-
await store.write(stage, secrets);
|
|
70
|
-
},
|
|
71
|
-
mask: (value) => redactor.add(value)
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/deploy/orchestrate.ts
|
|
76
|
-
/**
|
|
77
|
-
* The run around a target: what every deploy does whatever it deploys
|
|
78
|
-
* through.
|
|
79
|
-
*
|
|
80
|
-
* It loads the workspace, resolves the target, works out the apps and the
|
|
81
|
-
* identity, takes the stage's lock, and calls the target's phases in order,
|
|
82
|
-
* reporting each as it starts, finishes or fails. Everything that is about
|
|
83
|
-
* *where* the stage goes is the target's.
|
|
84
|
-
*/
|
|
85
|
-
/** `--resources-only` with `--skip-resources`: the one asks for what the other skips. */
|
|
86
|
-
var ResourcesOnlyAndSkipped = class extends require_errors.GkmError {
|
|
87
|
-
constructor() {
|
|
88
|
-
super("--resources-only creates the stage's resources and nothing else, and --skip-resources deploys without creating them. Run the first where the cloud credentials are (a CI runner), then the second where the stack runs.");
|
|
89
|
-
this.name = "ResourcesOnlyAndSkipped";
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
/** Apps were asked for by name that the workspace does not have. */
|
|
93
|
-
var UnknownDeployApps = class extends require_errors.GkmError {
|
|
94
|
-
apps;
|
|
95
|
-
available;
|
|
96
|
-
constructor(apps, available) {
|
|
97
|
-
super(`Unknown apps: ${apps.join(", ")}\nAvailable apps: ${available.join(", ")}`);
|
|
98
|
-
this.apps = apps;
|
|
99
|
-
this.available = available;
|
|
100
|
-
this.name = "UnknownDeployApps";
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
/** Every app asked for deploys through some other target. */
|
|
104
|
-
var NoDeployableApps = class extends require_errors.GkmError {
|
|
105
|
-
stage;
|
|
106
|
-
target;
|
|
107
|
-
constructor(stage, target) {
|
|
108
|
-
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.`);
|
|
109
|
-
this.stage = stage;
|
|
110
|
-
this.target = target;
|
|
111
|
-
this.name = "NoDeployableApps";
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
/** A build-only run through a target with no build phase. */
|
|
115
|
-
var TargetBuildsNothing = class extends require_errors.GkmError {
|
|
116
|
-
target;
|
|
117
|
-
constructor(target) {
|
|
118
|
-
super(`"${target}" has no build phase, so a build-only run would do nothing. Deploy it in full, or build through a target that builds images (compose).`);
|
|
119
|
-
this.target = target;
|
|
120
|
-
this.name = "TargetBuildsNothing";
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
/** A failed rollback, after the failure that called for it. */
|
|
124
|
-
var RollbackFailed = class extends Error {
|
|
125
|
-
target;
|
|
126
|
-
failure;
|
|
127
|
-
constructor(target, failure, cause) {
|
|
128
|
-
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 });
|
|
129
|
-
this.target = target;
|
|
130
|
-
this.failure = failure;
|
|
131
|
-
this.name = "RollbackFailed";
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Generate image tag from stage and timestamp
|
|
136
|
-
*/
|
|
137
|
-
function generateTag(stage) {
|
|
138
|
-
return `${stage}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19)}`;
|
|
139
|
-
}
|
|
140
|
-
/** Why an app that deploys through another target is left out. */
|
|
141
|
-
function elsewhere(target, stage) {
|
|
142
|
-
const instead = require_define.builtinTarget(target)?.instead?.(stage);
|
|
143
|
-
if (instead) return `it deploys through "${target}" — ${instead}`;
|
|
144
|
-
return `it deploys through "${target}" — run \`gkm deploy --target ${target} --stage ${stage}\``;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Deploy a workspace's stage through its target.
|
|
148
|
-
*
|
|
149
|
-
* The engine under `deploy()` and `gkm deploy`. It never prompts and never
|
|
150
|
-
* exits: credentials come from `ctx.credentials`, progress goes to
|
|
151
|
-
* `ctx.emit` and to `output`, and every failure is thrown.
|
|
152
|
-
*
|
|
153
|
-
* @internal
|
|
154
|
-
*/
|
|
155
|
-
async function runDeploy(source, request, ctx) {
|
|
156
|
-
const { stage } = request;
|
|
157
|
-
const redactor = ctx.redactor ?? new Redactor();
|
|
158
|
-
const emit = (event) => ctx.emit(event.type === "log" ? {
|
|
159
|
-
...event,
|
|
160
|
-
message: redactor.redact(event.message)
|
|
161
|
-
} : event);
|
|
162
|
-
/** Run one phase between its events. */
|
|
163
|
-
const phase = async (name, body) => {
|
|
164
|
-
ctx.signal?.throwIfAborted();
|
|
165
|
-
emit({
|
|
166
|
-
type: "phase.started",
|
|
167
|
-
phase: name
|
|
168
|
-
});
|
|
169
|
-
try {
|
|
170
|
-
const value = await body();
|
|
171
|
-
emit({
|
|
172
|
-
type: "phase.finished",
|
|
173
|
-
phase: name
|
|
174
|
-
});
|
|
175
|
-
return value;
|
|
176
|
-
} catch (error) {
|
|
177
|
-
emit({
|
|
178
|
-
type: "phase.failed",
|
|
179
|
-
phase: name,
|
|
180
|
-
error: require_sniffer.eventError(error)
|
|
181
|
-
});
|
|
182
|
-
throw error;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
ctx.signal?.throwIfAborted();
|
|
186
|
-
emit({
|
|
187
|
-
type: "phase.started",
|
|
188
|
-
phase: "validate"
|
|
189
|
-
});
|
|
190
|
-
let prepared;
|
|
191
|
-
try {
|
|
192
|
-
prepared = await prepare(source, request, ctx, emit, redactor);
|
|
193
|
-
} catch (error) {
|
|
194
|
-
emit({
|
|
195
|
-
type: "phase.failed",
|
|
196
|
-
phase: "validate",
|
|
197
|
-
error: require_sniffer.eventError(error)
|
|
198
|
-
});
|
|
199
|
-
throw error;
|
|
200
|
-
}
|
|
201
|
-
const { resolved, phaseCtx, store } = prepared;
|
|
202
|
-
const { target } = resolved;
|
|
203
|
-
const resources = !ctx.buildOnly && !request.skipResources && phaseCtx.stage !== phaseCtx.workspace.stages.local;
|
|
204
|
-
const provision = async () => {
|
|
205
|
-
if (!request.skipDns && resolved.target.runtime === "server") try {
|
|
206
|
-
await require_seeds.dnsCredentials(phaseCtx.stage, require_seeds.stageDnsDomains(phaseCtx.stage, phaseCtx.workspace.domains, phaseCtx.workspace.dns), ctx.credentials);
|
|
207
|
-
} catch (error) {
|
|
208
|
-
emit({
|
|
209
|
-
type: "phase.failed",
|
|
210
|
-
phase: "validate",
|
|
211
|
-
error: require_sniffer.eventError(error)
|
|
212
|
-
});
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
await provisionResources(phaseCtx, request, ctx, store, emit);
|
|
216
|
-
};
|
|
217
|
-
if (ctx.dryRun) {
|
|
218
|
-
if (resources) await provision();
|
|
219
|
-
if (request.resourcesOnly) return resourcesOnly(target, phaseCtx, emit);
|
|
220
|
-
const run = await validate(target, phaseCtx, emit);
|
|
221
|
-
await phase("plan", () => target.plan(phaseCtx, run));
|
|
222
|
-
return target.result(phaseCtx, run);
|
|
223
|
-
}
|
|
224
|
-
if (ctx.buildOnly) {
|
|
225
|
-
if (!target.build) throw new TargetBuildsNothing(resolved.name);
|
|
226
|
-
const run = await validate(target, phaseCtx, emit);
|
|
227
|
-
await phase("build", () => target.build(phaseCtx, run));
|
|
228
|
-
return target.result(phaseCtx, run);
|
|
229
|
-
}
|
|
230
|
-
let lock;
|
|
231
|
-
try {
|
|
232
|
-
require_sniffer.assertStateOutlivesRun(phaseCtx.workspace, stage, "deploy");
|
|
233
|
-
lock = await store.lock(stage, { operation: "deploy" });
|
|
234
|
-
} catch (error) {
|
|
235
|
-
emit({
|
|
236
|
-
type: "phase.failed",
|
|
237
|
-
phase: "validate",
|
|
238
|
-
error: require_sniffer.eventError(error)
|
|
239
|
-
});
|
|
240
|
-
throw error;
|
|
241
|
-
}
|
|
242
|
-
try {
|
|
243
|
-
if (resources) await provision();
|
|
244
|
-
if (request.resourcesOnly) return resourcesOnly(target, phaseCtx, emit);
|
|
245
|
-
const run = await validate(target, phaseCtx, emit);
|
|
246
|
-
if (target.provision) await phase("provision", () => target.provision(phaseCtx, run));
|
|
247
|
-
if (target.build) await phase("build", () => target.build(phaseCtx, run));
|
|
248
|
-
let releasing = "release";
|
|
249
|
-
try {
|
|
250
|
-
await phase("release", () => target.release(phaseCtx, run));
|
|
251
|
-
releasing = "verify";
|
|
252
|
-
if (target.verify) await phase("verify", () => target.verify(phaseCtx, run));
|
|
253
|
-
} catch (error) {
|
|
254
|
-
if (ctx.signal?.aborted || !target.capabilities.rollback) throw error;
|
|
255
|
-
if (!target.rollback) throw error;
|
|
256
|
-
try {
|
|
257
|
-
await phase("rollback", () => target.rollback(phaseCtx, run, {
|
|
258
|
-
phase: releasing,
|
|
259
|
-
error
|
|
260
|
-
}));
|
|
261
|
-
} catch (rollbackError) {
|
|
262
|
-
throw new RollbackFailed(resolved.name, error, rollbackError);
|
|
263
|
-
}
|
|
264
|
-
throw error;
|
|
265
|
-
}
|
|
266
|
-
return await target.result(phaseCtx, run);
|
|
267
|
-
} finally {
|
|
268
|
-
await lock.release();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* The stage's providers, run inside the validate phase. A dry run plans them
|
|
273
|
-
* and, so the checks after it see the stage as the run would leave it, reads
|
|
274
|
-
* the keys they would write as placeholders.
|
|
275
|
-
*/
|
|
276
|
-
async function provisionResources(phaseCtx, request, ctx, store, emit) {
|
|
277
|
-
try {
|
|
278
|
-
const reports = await require_providers.provisionStage({
|
|
279
|
-
workspace: phaseCtx.workspace,
|
|
280
|
-
stage: phaseCtx.stage,
|
|
281
|
-
manifest: phaseCtx.manifest,
|
|
282
|
-
runnables: phaseCtx.runnables ?? {},
|
|
283
|
-
secrets: phaseCtx.secrets,
|
|
284
|
-
state: store,
|
|
285
|
-
dryRun: ctx.dryRun,
|
|
286
|
-
...request.rotateKeys ? { rotateKeys: true } : {},
|
|
287
|
-
...request.retireOldKeys ? { retireOldKeys: true } : {},
|
|
288
|
-
...ctx.home ? { home: ctx.home } : {},
|
|
289
|
-
log: (line) => phaseCtx.logger.info(line)
|
|
290
|
-
});
|
|
291
|
-
if (!ctx.dryRun) return;
|
|
292
|
-
const planned = reports.flatMap((r) => r.planned);
|
|
293
|
-
if (planned.length === 0) return;
|
|
294
|
-
const secrets = phaseCtx.secrets;
|
|
295
|
-
phaseCtx.secrets = {
|
|
296
|
-
...secrets,
|
|
297
|
-
async read() {
|
|
298
|
-
const stored = await secrets.read() ?? require_seeds.initStageSecrets(phaseCtx.stage);
|
|
299
|
-
const custom = { ...stored.custom };
|
|
300
|
-
for (const key of planned) custom[key] ??= PLANNED_BY_THE_DEPLOY;
|
|
301
|
-
return {
|
|
302
|
-
...stored,
|
|
303
|
-
custom
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
} catch (error) {
|
|
308
|
-
emit({
|
|
309
|
-
type: "phase.failed",
|
|
310
|
-
phase: "validate",
|
|
311
|
-
error: require_sniffer.eventError(error)
|
|
312
|
-
});
|
|
313
|
-
throw error;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/** What a dry run reads for a key its providers would write. */
|
|
317
|
-
const PLANNED_BY_THE_DEPLOY = "s3://planned-by-this-deploy";
|
|
318
|
-
/** `--resources-only`: the target's own resources, and nothing else. */
|
|
319
|
-
async function resourcesOnly(target, phaseCtx, emit) {
|
|
320
|
-
try {
|
|
321
|
-
if (target.resources) await target.resources(phaseCtx);
|
|
322
|
-
} catch (error) {
|
|
323
|
-
emit({
|
|
324
|
-
type: "phase.failed",
|
|
325
|
-
phase: "validate",
|
|
326
|
-
error: require_sniffer.eventError(error)
|
|
327
|
-
});
|
|
328
|
-
throw error;
|
|
329
|
-
}
|
|
330
|
-
emit({
|
|
331
|
-
type: "phase.finished",
|
|
332
|
-
phase: "validate"
|
|
333
|
-
});
|
|
334
|
-
return resourcesResult(phaseCtx);
|
|
335
|
-
}
|
|
336
|
-
/** A `--resources-only` run: no app was deployed. */
|
|
337
|
-
function resourcesResult(phaseCtx) {
|
|
338
|
-
return {
|
|
339
|
-
apps: [],
|
|
340
|
-
projectId: "",
|
|
341
|
-
successCount: 0,
|
|
342
|
-
failedCount: 0,
|
|
343
|
-
stage: phaseCtx.stage,
|
|
344
|
-
identity: phaseCtx.identity.key,
|
|
345
|
-
tag: phaseCtx.tag,
|
|
346
|
-
dryRun: phaseCtx.dryRun,
|
|
347
|
-
environmentId: "",
|
|
348
|
-
skipped: [...phaseCtx.skipped],
|
|
349
|
-
urls: {},
|
|
350
|
-
changes: []
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
/** `validate`, then the run's `deploy.started`, inside the validate phase. */
|
|
354
|
-
async function validate(target, phaseCtx, emit) {
|
|
355
|
-
try {
|
|
356
|
-
const run = await target.validate(phaseCtx);
|
|
357
|
-
const skipped = new Set(phaseCtx.skipped.map((s) => s.app));
|
|
358
|
-
emit({
|
|
359
|
-
type: "deploy.started",
|
|
360
|
-
stage: phaseCtx.stage,
|
|
361
|
-
target: phaseCtx.target,
|
|
362
|
-
identity: phaseCtx.identity.key,
|
|
363
|
-
tag: phaseCtx.tag,
|
|
364
|
-
apps: phaseCtx.apps.filter((app) => !skipped.has(app)),
|
|
365
|
-
dryRun: phaseCtx.dryRun
|
|
366
|
-
});
|
|
367
|
-
emit({
|
|
368
|
-
type: "phase.finished",
|
|
369
|
-
phase: "validate"
|
|
370
|
-
});
|
|
371
|
-
return run;
|
|
372
|
-
} catch (error) {
|
|
373
|
-
emit({
|
|
374
|
-
type: "phase.failed",
|
|
375
|
-
phase: "validate",
|
|
376
|
-
error: require_sniffer.eventError(error)
|
|
377
|
-
});
|
|
378
|
-
throw error;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
/** Everything the phases are handed, worked out before the first of them. */
|
|
382
|
-
async function prepare(source, request, ctx, emit, redactor) {
|
|
383
|
-
const { stage } = request;
|
|
384
|
-
if (request.resourcesOnly && request.skipResources) throw new ResourcesOnlyAndSkipped();
|
|
385
|
-
const configured = typeof source === "function" ? await source() : source;
|
|
386
|
-
const local = stage === configured.stages.local;
|
|
387
|
-
if (!local) require_workspace.assertDeployedStage(configured.stages, stage);
|
|
388
|
-
const targetName = request.target ?? configured.deploy?.default ?? "dokploy";
|
|
389
|
-
const resolved = await require_resolve.resolveTarget(targetName, {
|
|
390
|
-
workspace: configured,
|
|
391
|
-
stage,
|
|
392
|
-
...ctx.targets ? { host: ctx.targets } : {}
|
|
393
|
-
});
|
|
394
|
-
if (local && !resolved.target.capabilities.localStage) require_workspace.assertDeployedStage(configured.stages, stage);
|
|
395
|
-
const options = await require_resolve.parseTargetOptions(resolved);
|
|
396
|
-
const allowDevServices = request.allowDevServices === true;
|
|
397
|
-
if (allowDevServices && resolved.target.runtime === "aws") throw new require_seeds.DevServicesNeedServerTarget(targetName);
|
|
398
|
-
const runnables = {};
|
|
399
|
-
const background = {};
|
|
400
|
-
const manifest = await require_discover.discover({
|
|
401
|
-
patterns: require_seeds.constructGlobs(configured),
|
|
402
|
-
cwd: configured.root,
|
|
403
|
-
runnables,
|
|
404
|
-
background
|
|
405
|
-
});
|
|
406
|
-
require_workspace.resolveStageTelemetry({
|
|
407
|
-
...configured.deploy?.telemetry ? { telemetry: configured.deploy.telemetry } : {},
|
|
408
|
-
stage,
|
|
409
|
-
local,
|
|
410
|
-
target: targetName,
|
|
411
|
-
runtime: resolved.target.runtime,
|
|
412
|
-
selfHosted: resolved.target.capabilities.selfHostedTelemetry === true,
|
|
413
|
-
used: require_seeds.usesTelemetry(manifest)
|
|
414
|
-
});
|
|
415
|
-
const units = require_derive.derivedApps(manifest, configured);
|
|
416
|
-
const workspace = Object.keys(units).length > 0 ? {
|
|
417
|
-
...configured,
|
|
418
|
-
apps: units
|
|
419
|
-
} : configured;
|
|
420
|
-
const identity = require_seeds.deployIdentity(workspace, stage);
|
|
421
|
-
const tag = request.tag ?? (resolved.target.tag ? await resolved.target.tag({
|
|
422
|
-
cwd: workspace.root,
|
|
423
|
-
stage
|
|
424
|
-
}) : generateTag(stage));
|
|
425
|
-
const buildOrder = require_workspace.getAppBuildOrder(workspace);
|
|
426
|
-
let selected = buildOrder;
|
|
427
|
-
if (request.apps && request.apps.length > 0) {
|
|
428
|
-
const unknown = request.apps.filter((name) => !workspace.apps[name]);
|
|
429
|
-
if (unknown.length > 0) throw new UnknownDeployApps(unknown, Object.keys(workspace.apps));
|
|
430
|
-
selected = buildOrder.filter((name) => request.apps.includes(name));
|
|
431
|
-
}
|
|
432
|
-
const skipped = [];
|
|
433
|
-
const skip = (app, reason) => {
|
|
434
|
-
skipped.push({
|
|
435
|
-
app,
|
|
436
|
-
reason
|
|
437
|
-
});
|
|
438
|
-
emit({
|
|
439
|
-
type: "app.skipped",
|
|
440
|
-
app,
|
|
441
|
-
reason
|
|
442
|
-
});
|
|
443
|
-
};
|
|
444
|
-
const byDefault = configured.deploy?.default ?? "dokploy";
|
|
445
|
-
const apps = selected.filter((name) => {
|
|
446
|
-
const own = workspace.apps[name].resolvedDeployTarget;
|
|
447
|
-
const deploysThrough = own === byDefault ? targetName : own;
|
|
448
|
-
if (deploysThrough === targetName) return true;
|
|
449
|
-
skip(name, elsewhere(deploysThrough, stage));
|
|
450
|
-
return false;
|
|
451
|
-
});
|
|
452
|
-
if (apps.length === 0) throw new NoDeployableApps(stage, targetName);
|
|
453
|
-
const store = await require_sniffer.createStateStore({
|
|
454
|
-
config: workspace.state,
|
|
455
|
-
workspaceRoot: workspace.root,
|
|
456
|
-
workspaceName: workspace.name
|
|
457
|
-
});
|
|
458
|
-
const secrets = await deploySecrets(workspace, stage, redactor, { ...ctx.home ? { home: ctx.home } : {} });
|
|
459
|
-
const line = (level) => (message) => emit({
|
|
460
|
-
type: "log",
|
|
461
|
-
level,
|
|
462
|
-
message
|
|
463
|
-
});
|
|
464
|
-
const logger = {
|
|
465
|
-
info: line("info"),
|
|
466
|
-
warn: line("warn"),
|
|
467
|
-
error: line("error")
|
|
468
|
-
};
|
|
469
|
-
return {
|
|
470
|
-
resolved,
|
|
471
|
-
phaseCtx: {
|
|
472
|
-
target: targetName,
|
|
473
|
-
cwd: workspace.root,
|
|
474
|
-
stage,
|
|
475
|
-
tag,
|
|
476
|
-
tagGiven: request.tag !== void 0,
|
|
477
|
-
apps,
|
|
478
|
-
skipped,
|
|
479
|
-
identity,
|
|
480
|
-
workspace,
|
|
481
|
-
manifest,
|
|
482
|
-
runnables,
|
|
483
|
-
background,
|
|
484
|
-
options,
|
|
485
|
-
dryRun: ctx.dryRun,
|
|
486
|
-
atomic: request.atomic ?? false,
|
|
487
|
-
allowDevServices,
|
|
488
|
-
...request.skipDns ? { skipDns: true } : {},
|
|
489
|
-
...request.skipResources ? { skipResources: true } : {},
|
|
490
|
-
credentials: ctx.credentials,
|
|
491
|
-
state: store,
|
|
492
|
-
secrets,
|
|
493
|
-
logger,
|
|
494
|
-
signal: ctx.signal ?? new AbortController().signal,
|
|
495
|
-
childOutput: ctx.childOutput ?? "inherit",
|
|
496
|
-
emit,
|
|
497
|
-
skip,
|
|
498
|
-
name: (resource) => require_seeds.applicationName(identity, resource)
|
|
499
|
-
},
|
|
500
|
-
store
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
//#endregion
|
|
504
|
-
//#region src/deploy/deploy.ts
|
|
505
|
-
/**
|
|
506
|
-
* `deploy()`: a deploy as a library call.
|
|
507
|
-
*
|
|
508
|
-
* `gkm deploy` could only be driven from an interactive terminal: it prompted
|
|
509
|
-
* for what it lacked and exited the process on failure, worked out of
|
|
510
|
-
* `process.cwd()`, and reported progress by printing. Here the caller says
|
|
511
|
-
* where the project is, hands over the credentials and a signal, and gets back
|
|
512
|
-
* a run — events to iterate while it goes, and a structured result at the end.
|
|
513
|
-
* Nothing below this asks a person anything or ends the process; `gkm deploy`
|
|
514
|
-
* is a thin wrapper that does both.
|
|
515
|
-
*/
|
|
516
|
-
/**
|
|
517
|
-
* Every event a run emits, kept so that each iteration — however late it
|
|
518
|
-
* starts — sees the run from its first event to its last.
|
|
519
|
-
*/
|
|
520
|
-
var EventLog = class {
|
|
521
|
-
events = [];
|
|
522
|
-
closed = false;
|
|
523
|
-
waiting = [];
|
|
524
|
-
push(event) {
|
|
525
|
-
this.events.push(event);
|
|
526
|
-
this.wake();
|
|
527
|
-
}
|
|
528
|
-
close() {
|
|
529
|
-
this.closed = true;
|
|
530
|
-
this.wake();
|
|
531
|
-
}
|
|
532
|
-
wake() {
|
|
533
|
-
const waiting = this.waiting;
|
|
534
|
-
this.waiting = [];
|
|
535
|
-
for (const resume of waiting) resume();
|
|
536
|
-
}
|
|
537
|
-
async *iterate() {
|
|
538
|
-
let next = 0;
|
|
539
|
-
while (true) if (next < this.events.length) yield this.events[next++];
|
|
540
|
-
else if (this.closed) return;
|
|
541
|
-
else await new Promise((resume) => this.waiting.push(resume));
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
function forward(logger, level, message) {
|
|
545
|
-
if (!logger) return;
|
|
546
|
-
if (level === "info") logger.info(message);
|
|
547
|
-
else if (level === "error" && logger.error) logger.error(message);
|
|
548
|
-
else logger.warn(message);
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Deploy a project's stage.
|
|
552
|
-
*
|
|
553
|
-
* ```ts
|
|
554
|
-
* import { deploy } from '@geekmidas/cli/deploy';
|
|
555
|
-
*
|
|
556
|
-
* const run = deploy({ cwd: '/srv/checkouts/shop', stage: 'production' });
|
|
557
|
-
* for await (const event of run) {
|
|
558
|
-
* if (event.type === 'app.deployed') console.log(event.app, event.url);
|
|
559
|
-
* }
|
|
560
|
-
* const result = await run.result;
|
|
561
|
-
* ```
|
|
562
|
-
*
|
|
563
|
-
* The run starts at once; iterating it is optional, and an iteration started
|
|
564
|
-
* late still sees every event from the first.
|
|
565
|
-
*/
|
|
566
|
-
function deploy(input) {
|
|
567
|
-
const log = new EventLog();
|
|
568
|
-
const redactor = new Redactor();
|
|
569
|
-
const emit = (event) => {
|
|
570
|
-
const masked = event.type === "log" ? {
|
|
571
|
-
...event,
|
|
572
|
-
message: redactor.redact(event.message)
|
|
573
|
-
} : event;
|
|
574
|
-
log.push(masked);
|
|
575
|
-
if (masked.type === "log") forward(input.logger, masked.level, masked.message);
|
|
576
|
-
};
|
|
577
|
-
const ctx = {
|
|
578
|
-
emit,
|
|
579
|
-
credentials: input.credentials ?? require_credentials.storedCredentials({ home: input.home ?? require_credentials.gkmHome() }),
|
|
580
|
-
dryRun: input.dryRun ?? false,
|
|
581
|
-
...input.buildOnly ? { buildOnly: true } : {},
|
|
582
|
-
home: input.home ?? require_credentials.gkmHome(),
|
|
583
|
-
redactor,
|
|
584
|
-
...input.signal ? { signal: input.signal } : {},
|
|
585
|
-
...input.childOutput ? { childOutput: input.childOutput } : {},
|
|
586
|
-
...input.targets ? { targets: input.targets } : {}
|
|
587
|
-
};
|
|
588
|
-
const result = require_discover.withOutput((level, message) => emit({
|
|
589
|
-
type: "log",
|
|
590
|
-
level,
|
|
591
|
-
message
|
|
592
|
-
}), async () => {
|
|
593
|
-
try {
|
|
594
|
-
input.signal?.throwIfAborted();
|
|
595
|
-
const sandbox = input.sandbox ?? new require_local.LocalSandbox({ root: require_config.findWorkspaceRoot((0, node_path.resolve)(input.cwd)) });
|
|
596
|
-
const deployed = await require_sandbox.withSandbox(sandbox, () => runDeploy(() => load(input, sandbox), {
|
|
597
|
-
stage: input.stage,
|
|
598
|
-
...input.target ? { target: input.target } : {},
|
|
599
|
-
...input.tag ? { tag: input.tag } : {},
|
|
600
|
-
...input.apps ? { apps: input.apps } : {},
|
|
601
|
-
...input.atomic ? { atomic: true } : {},
|
|
602
|
-
...input.allowDevServices ? { allowDevServices: input.allowDevServices } : {},
|
|
603
|
-
...input.skipDns ? { skipDns: true } : {},
|
|
604
|
-
...input.resourcesOnly ? { resourcesOnly: true } : {},
|
|
605
|
-
...input.skipResources ? { skipResources: true } : {},
|
|
606
|
-
...input.rotateKeys ? { rotateKeys: true } : {},
|
|
607
|
-
...input.retireOldKeys ? { retireOldKeys: true } : {}
|
|
608
|
-
}, ctx));
|
|
609
|
-
emit({
|
|
610
|
-
type: "deploy.finished",
|
|
611
|
-
result: deployed
|
|
612
|
-
});
|
|
613
|
-
return deployed;
|
|
614
|
-
} catch (error) {
|
|
615
|
-
emit({
|
|
616
|
-
type: "deploy.failed",
|
|
617
|
-
error: require_sniffer.eventError(error)
|
|
618
|
-
});
|
|
619
|
-
throw error;
|
|
620
|
-
} finally {
|
|
621
|
-
log.close();
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
result.catch(() => {});
|
|
625
|
-
return {
|
|
626
|
-
result,
|
|
627
|
-
[Symbol.asyncIterator]: () => log.iterate()
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* The workspace at `input.cwd`. The stage is checked by the run, once it
|
|
632
|
-
* knows the target: one that runs on this machine may take the local stage.
|
|
633
|
-
*/
|
|
634
|
-
async function load(input, sandbox) {
|
|
635
|
-
const { workspace } = await require_config.loadWorkspaceConfig((0, node_path.resolve)(input.cwd), { sandbox });
|
|
636
|
-
return workspace;
|
|
637
|
-
}
|
|
638
|
-
//#endregion
|
|
639
|
-
Object.defineProperty(exports, "NoDeployableApps", {
|
|
640
|
-
enumerable: true,
|
|
641
|
-
get: function() {
|
|
642
|
-
return NoDeployableApps;
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
Object.defineProperty(exports, "RollbackFailed", {
|
|
646
|
-
enumerable: true,
|
|
647
|
-
get: function() {
|
|
648
|
-
return RollbackFailed;
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
Object.defineProperty(exports, "TargetBuildsNothing", {
|
|
652
|
-
enumerable: true,
|
|
653
|
-
get: function() {
|
|
654
|
-
return TargetBuildsNothing;
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
Object.defineProperty(exports, "UnknownDeployApps", {
|
|
658
|
-
enumerable: true,
|
|
659
|
-
get: function() {
|
|
660
|
-
return UnknownDeployApps;
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
Object.defineProperty(exports, "deploy", {
|
|
664
|
-
enumerable: true,
|
|
665
|
-
get: function() {
|
|
666
|
-
return deploy;
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
//# sourceMappingURL=deploy-C911Akkn.cjs.map
|