@geekmidas/cli 10.0.0-alpha.93 → 10.0.0-alpha.94

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.
Files changed (196) hide show
  1. package/dist/{GoDaddyProvider-Mi3vptSR.mjs → GoDaddyProvider-BRZUWD8z.mjs} +3 -3
  2. package/dist/{GoDaddyProvider-Mi3vptSR.mjs.map → GoDaddyProvider-BRZUWD8z.mjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-BZb-V14e.cjs → GoDaddyProvider-DzguxU_a.cjs} +3 -3
  4. package/dist/{GoDaddyProvider-BZb-V14e.cjs.map → GoDaddyProvider-DzguxU_a.cjs.map} +1 -1
  5. package/dist/{HostingerProvider-1mqD6aG8.mjs → HostingerProvider-Cjh_2Ml6.mjs} +9 -4
  6. package/dist/{HostingerProvider-1mqD6aG8.mjs.map → HostingerProvider-Cjh_2Ml6.mjs.map} +1 -1
  7. package/dist/{HostingerProvider-C6t-PSNe.cjs → HostingerProvider-OdQmKXE3.cjs} +9 -4
  8. package/dist/HostingerProvider-OdQmKXE3.cjs.map +1 -0
  9. package/dist/{LegacyStateStore-CtwO7fwy.mjs → LegacyStateStore-BQZb6-j2.mjs} +3 -2
  10. package/dist/{LegacyStateStore-CtwO7fwy.mjs.map → LegacyStateStore-BQZb6-j2.mjs.map} +1 -1
  11. package/dist/{LegacyStateStore-BlYXQQSE.cjs → LegacyStateStore-D50dgUPc.cjs} +10 -9
  12. package/dist/{LegacyStateStore-BlYXQQSE.cjs.map → LegacyStateStore-D50dgUPc.cjs.map} +1 -1
  13. package/dist/{LocalStateStore-D40_SDmJ.mjs → LocalStateStore-BSaS2535.mjs} +2 -2
  14. package/dist/{LocalStateStore-D40_SDmJ.mjs.map → LocalStateStore-BSaS2535.mjs.map} +1 -1
  15. package/dist/{LocalStateStore-oX_zxj9V.cjs → LocalStateStore-EFBUjuMX.cjs} +8 -8
  16. package/dist/{LocalStateStore-oX_zxj9V.cjs.map → LocalStateStore-EFBUjuMX.cjs.map} +1 -1
  17. package/dist/{S3StateStore-DeI7jtvi.cjs → S3StateStore-C5mv8To3.cjs} +5 -5
  18. package/dist/{S3StateStore-DeI7jtvi.cjs.map → S3StateStore-C5mv8To3.cjs.map} +1 -1
  19. package/dist/{S3StateStore-BzS0IeSt.mjs → S3StateStore-CrFq4UZU.mjs} +2 -2
  20. package/dist/{S3StateStore-BzS0IeSt.mjs.map → S3StateStore-CrFq4UZU.mjs.map} +1 -1
  21. package/dist/{SSMStateStore-k_Ew7TWx.mjs → SSMStateStore-D3Z6mZnA.mjs} +2 -2
  22. package/dist/{SSMStateStore-k_Ew7TWx.mjs.map → SSMStateStore-D3Z6mZnA.mjs.map} +1 -1
  23. package/dist/{SSMStateStore-CaCtrzFL.cjs → SSMStateStore-DuZCH7_v.cjs} +9 -9
  24. package/dist/{SSMStateStore-CaCtrzFL.cjs.map → SSMStateStore-DuZCH7_v.cjs.map} +1 -1
  25. package/dist/{add-CP1podDH.mjs → add-C85isXFl.mjs} +4 -4
  26. package/dist/add-C85isXFl.mjs.map +1 -0
  27. package/dist/{add-VcyJnsPX.cjs → add-DsVDdvon.cjs} +4 -4
  28. package/dist/add-DsVDdvon.cjs.map +1 -0
  29. package/dist/{bundler-Dfsr6KXU.cjs → bundler-BEgUKc4j.cjs} +5 -5
  30. package/dist/{bundler-Dfsr6KXU.cjs.map → bundler-BEgUKc4j.cjs.map} +1 -1
  31. package/dist/{bundler-BWrh-AJH.mjs → bundler-BSHog8CH.mjs} +5 -5
  32. package/dist/{bundler-BWrh-AJH.mjs.map → bundler-BSHog8CH.mjs.map} +1 -1
  33. package/dist/{cli-B8otnZfX.mjs → cli-BsFenyaf.mjs} +9 -5
  34. package/dist/cli-BsFenyaf.mjs.map +1 -0
  35. package/dist/{cli-DL19w4OE.cjs → cli-BvBdv660.cjs} +9 -5
  36. package/dist/cli-BvBdv660.cjs.map +1 -0
  37. package/dist/{compose-BHVKLluX.cjs → compose-Cd09gW-n.cjs} +58 -19
  38. package/dist/compose-Cd09gW-n.cjs.map +1 -0
  39. package/dist/{compose-DrEB_4F-.mjs → compose-D2RFYd_f.mjs} +56 -17
  40. package/dist/compose-D2RFYd_f.mjs.map +1 -0
  41. package/dist/{config-DCCcrOSo.d.cts → config-DvHNMoOp.d.cts} +4 -4
  42. package/dist/{config-CHX5GOo3.d.mts.map → config-DvHNMoOp.d.cts.map} +1 -1
  43. package/dist/{config-CHX5GOo3.d.mts → config-Ngesg4O8.d.mts} +4 -4
  44. package/dist/{config-DCCcrOSo.d.cts.map → config-Ngesg4O8.d.mts.map} +1 -1
  45. package/dist/config.cjs +1 -1
  46. package/dist/config.d.cts +3 -3
  47. package/dist/config.d.mts +3 -3
  48. package/dist/config.mjs +1 -1
  49. package/dist/{credentials-QBu7VgaQ.cjs → credentials-D7XJypNd.cjs} +9 -3
  50. package/dist/{credentials-QBu7VgaQ.cjs.map → credentials-D7XJypNd.cjs.map} +1 -1
  51. package/dist/{credentials-C4KII3PD.mjs → credentials-DpfnUvIR.mjs} +9 -3
  52. package/dist/{credentials-C4KII3PD.mjs.map → credentials-DpfnUvIR.mjs.map} +1 -1
  53. package/dist/deploy/public.cjs +13 -13
  54. package/dist/deploy/public.d.cts +24 -9
  55. package/dist/deploy/public.d.cts.map +1 -1
  56. package/dist/deploy/public.d.mts +24 -9
  57. package/dist/deploy/public.d.mts.map +1 -1
  58. package/dist/deploy/public.mjs +10 -10
  59. package/dist/{deploy-C3Mhnmus.cjs → deploy-C911Akkn.cjs} +125 -11
  60. package/dist/deploy-C911Akkn.cjs.map +1 -0
  61. package/dist/{deploy-DYIyIUYd.mjs → deploy-CeJ5D0xn.mjs} +123 -9
  62. package/dist/deploy-CeJ5D0xn.mjs.map +1 -0
  63. package/dist/{discover-vk2r5giK.d.cts → discover-CTzOSGUF.d.cts} +2 -2
  64. package/dist/{discover-DqwlBVyY.d.mts.map → discover-CTzOSGUF.d.cts.map} +1 -1
  65. package/dist/{discover-DqwlBVyY.d.mts → discover-CihAtaoj.d.mts} +2 -2
  66. package/dist/{discover-vk2r5giK.d.cts.map → discover-CihAtaoj.d.mts.map} +1 -1
  67. package/dist/{dokploy-rivb1RFt.cjs → dokploy-CV7GcobZ.cjs} +2 -2
  68. package/dist/{dokploy-rivb1RFt.cjs.map → dokploy-CV7GcobZ.cjs.map} +1 -1
  69. package/dist/{dokploy-o4I6vb9W.mjs → dokploy-D_aat2Xj.mjs} +2 -2
  70. package/dist/{dokploy-o4I6vb9W.mjs.map → dokploy-D_aat2Xj.mjs.map} +1 -1
  71. package/dist/{encryption-D7zmwzWz.cjs → encryption-DFcivJaO.cjs} +3 -3
  72. package/dist/{encryption-D7zmwzWz.cjs.map → encryption-DFcivJaO.cjs.map} +1 -1
  73. package/dist/{encryption-B6ilrT7p.mjs → encryption-_4qKqtTx.mjs} +3 -3
  74. package/dist/{encryption-B6ilrT7p.mjs.map → encryption-_4qKqtTx.mjs.map} +1 -1
  75. package/dist/{engine-Cfx8fEZU.cjs → engine-Bv-LZpmj.cjs} +10 -9
  76. package/dist/{engine-Cfx8fEZU.cjs.map → engine-Bv-LZpmj.cjs.map} +1 -1
  77. package/dist/{engine-DjEcovm-.mjs → engine-DPMHThkg.mjs} +7 -6
  78. package/dist/{engine-DjEcovm-.mjs.map → engine-DPMHThkg.mjs.map} +1 -1
  79. package/dist/{github-zneTMvnO.cjs → github-Br42NMrW.cjs} +94 -6
  80. package/dist/github-Br42NMrW.cjs.map +1 -0
  81. package/dist/{github-CzBbs43W.mjs → github-xsDT19im.mjs} +94 -6
  82. package/dist/github-xsDT19im.mjs.map +1 -0
  83. package/dist/{index-BiYU7cUl.d.mts → index-BlpcClwM.d.mts} +2 -2
  84. package/dist/{index-BiYU7cUl.d.mts.map → index-BlpcClwM.d.mts.map} +1 -1
  85. package/dist/{index-Dm6V9bwh.d.cts → index-CwLvFqtH.d.cts} +2 -2
  86. package/dist/{index-Dm6V9bwh.d.cts.map → index-CwLvFqtH.d.cts.map} +1 -1
  87. package/dist/index.cjs +147 -116
  88. package/dist/index.cjs.map +1 -1
  89. package/dist/index.mjs +143 -112
  90. package/dist/index.mjs.map +1 -1
  91. package/dist/{local-Otp74ak0.mjs → local-B7Zv1NoA.mjs} +2 -2
  92. package/dist/{local-Otp74ak0.mjs.map → local-B7Zv1NoA.mjs.map} +1 -1
  93. package/dist/{local-B61kUh0w.cjs → local-OPC9BCZt.cjs} +2 -2
  94. package/dist/{local-B61kUh0w.cjs.map → local-OPC9BCZt.cjs.map} +1 -1
  95. package/dist/{migrate-BaC4w0sb.mjs → migrate-B7evHv7O.mjs} +3 -3
  96. package/dist/{migrate-BaC4w0sb.mjs.map → migrate-B7evHv7O.mjs.map} +1 -1
  97. package/dist/{migrate-C8wTpakT.cjs → migrate-D5jUz20_.cjs} +3 -3
  98. package/dist/{migrate-C8wTpakT.cjs.map → migrate-D5jUz20_.cjs.map} +1 -1
  99. package/dist/{migrate-CsBZKALY.mjs → migrate-DhvFPGLi.mjs} +3 -3
  100. package/dist/{migrate-CsBZKALY.mjs.map → migrate-DhvFPGLi.mjs.map} +1 -1
  101. package/dist/{migrate-DFjbGnSr.cjs → migrate-SkWJotn5.cjs} +3 -3
  102. package/dist/{migrate-DFjbGnSr.cjs.map → migrate-SkWJotn5.cjs.map} +1 -1
  103. package/dist/openapi.cjs +1 -1
  104. package/dist/openapi.d.cts +1 -1
  105. package/dist/openapi.d.mts +1 -1
  106. package/dist/openapi.mjs +1 -1
  107. package/dist/providers-BFeP_mYw.cjs +1098 -0
  108. package/dist/providers-BFeP_mYw.cjs.map +1 -0
  109. package/dist/providers-sTj-BG0S.mjs +1079 -0
  110. package/dist/providers-sTj-BG0S.mjs.map +1 -0
  111. package/dist/reconcile/public.d.cts +2 -2
  112. package/dist/reconcile/public.d.mts +2 -2
  113. package/dist/{resolve-g8htuR80.cjs → resolve-CFEOtRsl.cjs} +4 -4
  114. package/dist/{resolve-g8htuR80.cjs.map → resolve-CFEOtRsl.cjs.map} +1 -1
  115. package/dist/{resolve-Ccjlpnd9.mjs → resolve-Dyd1S2wn.mjs} +4 -4
  116. package/dist/{resolve-Ccjlpnd9.mjs.map → resolve-Dyd1S2wn.mjs.map} +1 -1
  117. package/dist/{rollback--ympG9ss.cjs → rollback-D720SFhV.cjs} +11 -9
  118. package/dist/{rollback--ympG9ss.cjs.map → rollback-D720SFhV.cjs.map} +1 -1
  119. package/dist/{rollback-Drbg0OeR.mjs → rollback-NroNbGC0.mjs} +8 -6
  120. package/dist/{rollback-Drbg0OeR.mjs.map → rollback-NroNbGC0.mjs.map} +1 -1
  121. package/dist/{runtime-_wEVtshH.d.mts → runtime-BRCq6dQ7.d.mts} +2 -2
  122. package/dist/{runtime-D_J3ExJn.d.cts.map → runtime-BRCq6dQ7.d.mts.map} +1 -1
  123. package/dist/{runtime-D_J3ExJn.d.cts → runtime-VktAo_8B.d.cts} +2 -2
  124. package/dist/{runtime-_wEVtshH.d.mts.map → runtime-VktAo_8B.d.cts.map} +1 -1
  125. package/dist/{sandbox-CPJq1Kia.d.mts → sandbox-D1gd0iDz.d.cts} +2 -2
  126. package/dist/{sandbox-CPJq1Kia.d.mts.map → sandbox-D1gd0iDz.d.cts.map} +1 -1
  127. package/dist/{sandbox-JwuPAl7I.d.cts → sandbox-zHnRLCj0.d.mts} +2 -2
  128. package/dist/{sandbox-JwuPAl7I.d.cts.map → sandbox-zHnRLCj0.d.mts.map} +1 -1
  129. package/dist/{secrets-DbPmAS4k.mjs → secrets-CwLauUB_.mjs} +3 -3
  130. package/dist/secrets-CwLauUB_.mjs.map +1 -0
  131. package/dist/{secrets-DJteijZo.cjs → secrets-DAvi_O9g.cjs} +3 -3
  132. package/dist/secrets-DAvi_O9g.cjs.map +1 -0
  133. package/dist/{seeds-c-ByX9je.cjs → seeds-BCg8X36S.cjs} +1143 -2645
  134. package/dist/seeds-BCg8X36S.cjs.map +1 -0
  135. package/dist/{seeds-BSL55F6q.mjs → seeds-CTxTZa-R.mjs} +1289 -2760
  136. package/dist/seeds-CTxTZa-R.mjs.map +1 -0
  137. package/dist/{sniffer-Dq5BS98f.cjs → sniffer-C0z3NB2A.cjs} +572 -3
  138. package/dist/sniffer-C0z3NB2A.cjs.map +1 -0
  139. package/dist/{sniffer-BTtGAtm3.mjs → sniffer-DCcuzHz_.mjs} +496 -5
  140. package/dist/sniffer-DCcuzHz_.mjs.map +1 -0
  141. package/dist/{sst-CnKY-CSh.cjs → sst-DKNH243z.cjs} +3 -3
  142. package/dist/{sst-CnKY-CSh.cjs.map → sst-DKNH243z.cjs.map} +1 -1
  143. package/dist/{sst-BaRXp2Dd.mjs → sst-DRDSDwOk.mjs} +3 -3
  144. package/dist/{sst-BaRXp2Dd.mjs.map → sst-DRDSDwOk.mjs.map} +1 -1
  145. package/dist/{stack-1PeLJS2j.cjs → stack-B3fPDTBg.cjs} +3 -3
  146. package/dist/{stack-1PeLJS2j.cjs.map → stack-B3fPDTBg.cjs.map} +1 -1
  147. package/dist/{stack-Co4uZkAo.mjs → stack-NrdH5ngX.mjs} +3 -3
  148. package/dist/{stack-Co4uZkAo.mjs.map → stack-NrdH5ngX.mjs.map} +1 -1
  149. package/dist/{stages-BI8JvPzI.cjs → stages-CkqP1N4S.cjs} +16 -3
  150. package/dist/stages-CkqP1N4S.cjs.map +1 -0
  151. package/dist/{stages-DY-fQKmo.mjs → stages-veC4TcQe.mjs} +16 -3
  152. package/dist/stages-veC4TcQe.mjs.map +1 -0
  153. package/dist/target/public.cjs +1 -1
  154. package/dist/target/public.d.cts +2 -2
  155. package/dist/target/public.d.mts +2 -2
  156. package/dist/target/public.mjs +1 -1
  157. package/dist/{terminal-8XngdSTo.cjs → terminal-CkUYuAPd.cjs} +2 -2
  158. package/dist/{terminal-8XngdSTo.cjs.map → terminal-CkUYuAPd.cjs.map} +1 -1
  159. package/dist/{terminal-C4XRdwnU.mjs → terminal-DAHs2Zko.mjs} +2 -2
  160. package/dist/{terminal-C4XRdwnU.mjs.map → terminal-DAHs2Zko.mjs.map} +1 -1
  161. package/dist/{types-BibpiHKB.d.cts → types-DMoaFrjg.d.mts} +32 -9
  162. package/dist/types-DMoaFrjg.d.mts.map +1 -0
  163. package/dist/{types-B6lmD3en.d.mts → types-DXyaSmqu.d.cts} +33 -8
  164. package/dist/types-DXyaSmqu.d.cts.map +1 -0
  165. package/dist/workspace/index.cjs +1 -1
  166. package/dist/workspace/index.d.cts +2 -2
  167. package/dist/workspace/index.d.mts +2 -2
  168. package/dist/workspace/index.mjs +1 -1
  169. package/dist/{workspace-Bzw7Zs82.mjs → workspace-DWK1PTXP.mjs} +4 -4
  170. package/dist/workspace-DWK1PTXP.mjs.map +1 -0
  171. package/dist/{workspace-CHOB2Xg3.cjs → workspace-cSyi5nb1.cjs} +4 -4
  172. package/dist/workspace-cSyi5nb1.cjs.map +1 -0
  173. package/package.json +15 -15
  174. package/dist/HostingerProvider-C6t-PSNe.cjs.map +0 -1
  175. package/dist/add-CP1podDH.mjs.map +0 -1
  176. package/dist/add-VcyJnsPX.cjs.map +0 -1
  177. package/dist/cli-B8otnZfX.mjs.map +0 -1
  178. package/dist/cli-DL19w4OE.cjs.map +0 -1
  179. package/dist/compose-BHVKLluX.cjs.map +0 -1
  180. package/dist/compose-DrEB_4F-.mjs.map +0 -1
  181. package/dist/deploy-C3Mhnmus.cjs.map +0 -1
  182. package/dist/deploy-DYIyIUYd.mjs.map +0 -1
  183. package/dist/github-CzBbs43W.mjs.map +0 -1
  184. package/dist/github-zneTMvnO.cjs.map +0 -1
  185. package/dist/secrets-DJteijZo.cjs.map +0 -1
  186. package/dist/secrets-DbPmAS4k.mjs.map +0 -1
  187. package/dist/seeds-BSL55F6q.mjs.map +0 -1
  188. package/dist/seeds-c-ByX9je.cjs.map +0 -1
  189. package/dist/sniffer-BTtGAtm3.mjs.map +0 -1
  190. package/dist/sniffer-Dq5BS98f.cjs.map +0 -1
  191. package/dist/stages-BI8JvPzI.cjs.map +0 -1
  192. package/dist/stages-DY-fQKmo.mjs.map +0 -1
  193. package/dist/types-B6lmD3en.d.mts.map +0 -1
  194. package/dist/types-BibpiHKB.d.cts.map +0 -1
  195. package/dist/workspace-Bzw7Zs82.mjs.map +0 -1
  196. package/dist/workspace-CHOB2Xg3.cjs.map +0 -1
@@ -1,15 +1,16 @@
1
1
  const require_errors = require("./errors-DMC4Umsb.cjs");
2
- const require_credentials = require("./credentials-QBu7VgaQ.cjs");
2
+ const require_credentials = require("./credentials-D7XJypNd.cjs");
3
3
  const require_discover = require("./discover-DPgu-ScS.cjs");
4
4
  const require_sandbox = require("./sandbox-CHv3OYXg.cjs");
5
5
  const require_derive = require("./derive-DAbo49sm.cjs");
6
- const require_workspace = require("./workspace-CHOB2Xg3.cjs");
6
+ const require_workspace = require("./workspace-cSyi5nb1.cjs");
7
7
  const require_define = require("./define-crmMcXFS.cjs");
8
8
  const require_config = require("./config.cjs");
9
- const require_seeds = require("./seeds-c-ByX9je.cjs");
10
- const require_resolve = require("./resolve-g8htuR80.cjs");
11
- const require_local = require("./local-B61kUh0w.cjs");
12
- const require_sniffer = require("./sniffer-Dq5BS98f.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");
13
14
  let node_path = require("node:path");
14
15
  //#region src/target/secrets.ts
15
16
  /**
@@ -81,6 +82,13 @@ async function deploySecrets(workspace, stage, redactor, options = {}) {
81
82
  * reporting each as it starts, finishes or fails. Everything that is about
82
83
  * *where* the stage goes is the target's.
83
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
+ };
84
92
  /** Apps were asked for by name that the workspace does not have. */
85
93
  var UnknownDeployApps = class extends require_errors.GkmError {
86
94
  apps;
@@ -192,7 +200,23 @@ async function runDeploy(source, request, ctx) {
192
200
  }
193
201
  const { resolved, phaseCtx, store } = prepared;
194
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
+ };
195
217
  if (ctx.dryRun) {
218
+ if (resources) await provision();
219
+ if (request.resourcesOnly) return resourcesOnly(target, phaseCtx, emit);
196
220
  const run = await validate(target, phaseCtx, emit);
197
221
  await phase("plan", () => target.plan(phaseCtx, run));
198
222
  return target.result(phaseCtx, run);
@@ -205,7 +229,7 @@ async function runDeploy(source, request, ctx) {
205
229
  }
206
230
  let lock;
207
231
  try {
208
- require_seeds.assertStateOutlivesRun(phaseCtx.workspace, stage, "deploy");
232
+ require_sniffer.assertStateOutlivesRun(phaseCtx.workspace, stage, "deploy");
209
233
  lock = await store.lock(stage, { operation: "deploy" });
210
234
  } catch (error) {
211
235
  emit({
@@ -216,6 +240,8 @@ async function runDeploy(source, request, ctx) {
216
240
  throw error;
217
241
  }
218
242
  try {
243
+ if (resources) await provision();
244
+ if (request.resourcesOnly) return resourcesOnly(target, phaseCtx, emit);
219
245
  const run = await validate(target, phaseCtx, emit);
220
246
  if (target.provision) await phase("provision", () => target.provision(phaseCtx, run));
221
247
  if (target.build) await phase("build", () => target.build(phaseCtx, run));
@@ -242,6 +268,88 @@ async function runDeploy(source, request, ctx) {
242
268
  await lock.release();
243
269
  }
244
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
+ }
245
353
  /** `validate`, then the run's `deploy.started`, inside the validate phase. */
246
354
  async function validate(target, phaseCtx, emit) {
247
355
  try {
@@ -273,6 +381,7 @@ async function validate(target, phaseCtx, emit) {
273
381
  /** Everything the phases are handed, worked out before the first of them. */
274
382
  async function prepare(source, request, ctx, emit, redactor) {
275
383
  const { stage } = request;
384
+ if (request.resourcesOnly && request.skipResources) throw new ResourcesOnlyAndSkipped();
276
385
  const configured = typeof source === "function" ? await source() : source;
277
386
  const local = stage === configured.stages.local;
278
387
  if (!local) require_workspace.assertDeployedStage(configured.stages, stage);
@@ -341,7 +450,7 @@ async function prepare(source, request, ctx, emit, redactor) {
341
450
  return false;
342
451
  });
343
452
  if (apps.length === 0) throw new NoDeployableApps(stage, targetName);
344
- const store = await require_seeds.createStateStore({
453
+ const store = await require_sniffer.createStateStore({
345
454
  config: workspace.state,
346
455
  workspaceRoot: workspace.root,
347
456
  workspaceName: workspace.name
@@ -376,7 +485,8 @@ async function prepare(source, request, ctx, emit, redactor) {
376
485
  dryRun: ctx.dryRun,
377
486
  atomic: request.atomic ?? false,
378
487
  allowDevServices,
379
- ...request.skipDnsCheck ? { skipDnsCheck: true } : {},
488
+ ...request.skipDns ? { skipDns: true } : {},
489
+ ...request.skipResources ? { skipResources: true } : {},
380
490
  credentials: ctx.credentials,
381
491
  state: store,
382
492
  secrets,
@@ -490,7 +600,11 @@ function deploy(input) {
490
600
  ...input.apps ? { apps: input.apps } : {},
491
601
  ...input.atomic ? { atomic: true } : {},
492
602
  ...input.allowDevServices ? { allowDevServices: input.allowDevServices } : {},
493
- ...input.skipDnsCheck ? { skipDnsCheck: true } : {}
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 } : {}
494
608
  }, ctx));
495
609
  emit({
496
610
  type: "deploy.finished",
@@ -553,4 +667,4 @@ Object.defineProperty(exports, "deploy", {
553
667
  }
554
668
  });
555
669
 
556
- //# sourceMappingURL=deploy-C3Mhnmus.cjs.map
670
+ //# sourceMappingURL=deploy-C911Akkn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-C911Akkn.cjs","names":["secretsStoreFor","GkmError","builtinTarget","eventError","dnsCredentials","stageDnsDomains","provisionStage","initStageSecrets","resolveTarget","parseTargetOptions","DevServicesNeedServerTarget","discover","constructGlobs","usesTelemetry","derivedApps","deployIdentity","getAppBuildOrder","createStateStore","applicationName","storedCredentials","gkmHome","withOutput","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","eventError","loadWorkspaceConfig"],"sources":["../src/target/secrets.ts","../src/deploy/orchestrate.ts","../src/deploy/deploy.ts"],"sourcesContent":["/**\n * A stage's secrets as a target sees them: read and written through the\n * stage's own store, and masked in everything the run prints once read.\n */\n\nimport { secretsStoreFor } from '../secrets/store';\nimport type { StageSecrets } from '../secrets/types';\nimport type { NormalizedWorkspace } from '../workspace/types';\nimport type { DeploySecrets } from './types';\n\n/**\n * Shorter values are left alone: what a progress line legitimately prints —\n * a port, a stage, an app name — would otherwise come out as `***` wherever\n * a secret happened to share it.\n */\nconst SHORTEST_MASKED = 6;\n\n/** The values a run must never print, and the rewrite that keeps it so. */\nexport class Redactor {\n\tprivate readonly values = new Set<string>();\n\n\tadd(value: string | undefined): void {\n\t\tif (value && value.length >= SHORTEST_MASKED) this.values.add(value);\n\t}\n\n\t/** `text` with every masked value replaced by `***`, longest first. */\n\tredact(text: string): string {\n\t\tif (this.values.size === 0) return text;\n\t\tlet out = text;\n\t\tconst longestFirst = [...this.values].sort((a, b) => b.length - a.length);\n\t\tfor (const value of longestFirst) out = out.replaceAll(value, '***');\n\t\treturn out;\n\t}\n}\n\n/** Every value in `secrets` that is a secret rather than a label. */\nfunction secretValues(secrets: StageSecrets): string[] {\n\treturn [\n\t\tsecrets.seed,\n\t\t...Object.values(secrets.custom ?? {}),\n\t\t...Object.values(secrets.urls ?? {}),\n\t\t...Object.values(secrets.services ?? {}).map(\n\t\t\t(service) => service?.password,\n\t\t),\n\t].filter((value): value is string => typeof value === 'string');\n}\n\n/**\n * The stage's secrets through the store `secrets.store` names for it. Opening\n * one builds a client and makes no request, so a target that never reads them\n * costs nothing.\n */\nexport async function deploySecrets(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n\tredactor: Redactor,\n\toptions: { home?: string } = {},\n): Promise<DeploySecrets> {\n\tconst store = await secretsStoreFor(workspace, stage, options);\n\tconst mask = (secrets: StageSecrets) => {\n\t\tfor (const value of secretValues(secrets)) redactor.add(value);\n\t};\n\n\treturn {\n\t\tstore: store.name,\n\t\tasync read() {\n\t\t\tconst secrets = await store.read(stage);\n\t\t\tif (secrets) mask(secrets);\n\t\t\treturn secrets;\n\t\t},\n\t\tasync write(secrets) {\n\t\t\tmask(secrets);\n\t\t\tawait store.write(stage, secrets);\n\t\t},\n\t\tmask: (value) => redactor.add(value),\n\t};\n}\n","/**\n * The run around a target: what every deploy does whatever it deploys\n * through.\n *\n * It loads the workspace, resolves the target, works out the apps and the\n * identity, takes the stage's lock, and calls the target's phases in order,\n * reporting each as it starts, finishes or fails. Everything that is about\n * *where* the stage goes is the target's.\n */\n\nimport { dnsCredentials, stageDnsDomains } from '../compose/dns.js';\nimport { GkmError } from '../errors';\nimport { provisionStage } from '../providers/index.js';\nimport { discover } from '../reconcile/discover.js';\nimport { constructGlobs } from '../reconcile/workspace.js';\nimport { initStageSecrets } from '../secrets/storage.js';\nimport { builtinTarget } from '../target/builtins';\nimport {\n\tparseTargetOptions,\n\ttype ResolvedTarget,\n\tresolveTarget,\n} from '../target/resolve';\nimport { deploySecrets, Redactor } from '../target/secrets';\nimport type {\n\tAnyDeployTarget,\n\tDeployPhaseContext,\n\tDeployTargetLogger,\n} from '../target/types';\nimport { resolveStageTelemetry } from '../telemetry/config';\nimport { usesTelemetry } from '../telemetry/edges';\nimport { derivedApps } from '../workspace/derive.js';\nimport { getAppBuildOrder } from '../workspace/index.js';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport type { CredentialProvider } from './credentials';\nimport { DevServicesNeedServerTarget } from './devServices';\nimport { type DeployEvent, type DeployPhase, eventError } from './events';\nimport { applicationName, deployIdentity } from './identity.js';\nimport { assertStateOutlivesRun, createStateStore } from './StateStore.js';\nimport type { DeployResult } from './types';\n\n/** What a run deploys, once the workspace is loaded. */\nexport interface DeployRequest {\n\t/** Deployment stage (e.g., 'production', 'staging') */\n\tstage: string;\n\t/** Image tag (default: stage-timestamp) */\n\ttag?: string;\n\t/** Specific apps to deploy (default: all) */\n\tapps?: string[];\n\t/** The target to deploy through. Defaults to `deploy.default`. */\n\ttarget?: string;\n\t/** On a failed release, roll back every app rather than the failed ones. */\n\tatomic?: boolean;\n\t/**\n\t * `--allow-dev-services`: a deployed stage runs the dev service for every\n\t * bucket and mail it does not account for. Server targets only.\n\t */\n\tallowDevServices?: boolean;\n\t/** `--skip-dns`: a server target writes and checks no host's DNS. */\n\tskipDns?: boolean;\n\t/**\n\t * `--resources-only`: create what the stage needs — its providers'\n\t * resources and keys, and its DNS records — and nothing else: no image\n\t * built, nothing started. What a CI runner runs with the stage's cloud\n\t * credentials and DNS token before the server deploys.\n\t */\n\tresourcesOnly?: boolean;\n\t/**\n\t * `--skip-resources`: an earlier `--resources-only` run created them, so\n\t * no provider runs and no DNS record is written or checked.\n\t */\n\tskipResources?: boolean;\n\t/** `--rotate-keys`: each provider issues its runtime keys a successor. */\n\trotateKeys?: boolean;\n\t/** `--retire-old-keys`: delete a rotated-out key now. */\n\tretireOldKeys?: boolean;\n}\n\n/** `--resources-only` with `--skip-resources`: the one asks for what the other skips. */\nexport class ResourcesOnlyAndSkipped extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"--resources-only creates the stage's resources and nothing else, and \" +\n\t\t\t\t'--skip-resources deploys without creating them. Run the first where ' +\n\t\t\t\t'the cloud credentials are (a CI runner), then the second where the ' +\n\t\t\t\t'stack runs.',\n\t\t);\n\t\tthis.name = 'ResourcesOnlyAndSkipped';\n\t}\n}\n\n/**\n * What a run is handed by whoever started it: where its events go, where it\n * gets credentials, and whether it may change anything. Nothing in a run\n * reads a terminal or exits the process — that is its caller's business.\n */\nexport interface DeployContext {\n\temit: (event: DeployEvent) => void;\n\tcredentials: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Look everything up, create, build and push nothing. */\n\tdryRun: boolean;\n\t/**\n\t * Validate and build — the target's images built, and pushed where it\n\t * pushes them — and nothing else: no lock, nothing provisioned, released,\n\t * verified or recorded. What a CI job runs before a server pulls.\n\t */\n\tbuildOnly?: boolean;\n\t/** The CLI's home, for the stage's keys. Defaults to `GKM_HOME`. */\n\thome?: string;\n\t/** Where spawned processes' output goes. Defaults to the terminal. */\n\tchildOutput?: 'inherit' | 'stderr' | 'ignore';\n\t/** The host's own targets, which win over every other by the same name. */\n\ttargets?: Record<string, AnyDeployTarget>;\n\t/**\n\t * What the run masks in what it prints. `deploy()` passes the one its\n\t * progress lines go through; a run without one masks only its events.\n\t */\n\tredactor?: Redactor;\n}\n\n/** Apps were asked for by name that the workspace does not have. */\nexport class UnknownDeployApps extends GkmError {\n\tconstructor(\n\t\treadonly apps: readonly string[],\n\t\treadonly available: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Unknown apps: ${apps.join(', ')}\\n` +\n\t\t\t\t`Available apps: ${available.join(', ')}`,\n\t\t);\n\t\tthis.name = 'UnknownDeployApps';\n\t}\n}\n\n/** Every app asked for deploys through some other target. */\nexport class NoDeployableApps extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly target: string,\n\t) {\n\t\tsuper(\n\t\t\t`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.`,\n\t\t);\n\t\tthis.name = 'NoDeployableApps';\n\t}\n}\n\n/** A build-only run through a target with no build phase. */\nexport class TargetBuildsNothing extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`\"${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).`,\n\t\t);\n\t\tthis.name = 'TargetBuildsNothing';\n\t}\n}\n\n/** A failed rollback, after the failure that called for it. */\nexport class RollbackFailed extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\t/** What failed first, and was being rolled back. */\n\t\treadonly failure: unknown,\n\t\tcause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`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)}`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'RollbackFailed';\n\t}\n}\n\n/**\n * Generate image tag from stage and timestamp\n */\nexport function generateTag(stage: string): string {\n\tconst timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);\n\treturn `${stage}-${timestamp}`;\n}\n\n/** Why an app that deploys through another target is left out. */\nfunction elsewhere(target: string, stage: string): string {\n\tconst instead = builtinTarget(target)?.instead?.(stage);\n\tif (instead) return `it deploys through \"${target}\" — ${instead}`;\n\treturn `it deploys through \"${target}\" — run \\`gkm deploy --target ${target} --stage ${stage}\\``;\n}\n\n/**\n * Deploy a workspace's stage through its target.\n *\n * The engine under `deploy()` and `gkm deploy`. It never prompts and never\n * exits: credentials come from `ctx.credentials`, progress goes to\n * `ctx.emit` and to `output`, and every failure is thrown.\n *\n * @internal\n */\nexport async function runDeploy(\n\tsource: NormalizedWorkspace | (() => Promise<NormalizedWorkspace>),\n\trequest: DeployRequest,\n\tctx: DeployContext,\n): Promise<DeployResult> {\n\tconst { stage } = request;\n\tconst redactor = ctx.redactor ?? new Redactor();\n\tconst emit = (event: DeployEvent) =>\n\t\tctx.emit(\n\t\t\tevent.type === 'log'\n\t\t\t\t? { ...event, message: redactor.redact(event.message) }\n\t\t\t\t: event,\n\t\t);\n\n\t/** Run one phase between its events. */\n\tconst phase = async <T>(name: DeployPhase, body: () => Promise<T>) => {\n\t\tctx.signal?.throwIfAborted();\n\t\temit({ type: 'phase.started', phase: name });\n\t\ttry {\n\t\t\tconst value = await body();\n\t\t\temit({ type: 'phase.finished', phase: name });\n\t\t\treturn value;\n\t\t} catch (error) {\n\t\t\temit({ type: 'phase.failed', phase: name, error: eventError(error) });\n\t\t\tthrow error;\n\t\t}\n\t};\n\n\tctx.signal?.throwIfAborted();\n\temit({ type: 'phase.started', phase: 'validate' });\n\n\tlet prepared: Prepared;\n\ttry {\n\t\tprepared = await prepare(source, request, ctx, emit, redactor);\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n\tconst { resolved, phaseCtx, store } = prepared;\n\tconst { target } = resolved;\n\n\t// The stage's resources — what its providers create, and the keys they\n\t// write into its secrets — before any check reads those secrets, so a key\n\t// the deploy creates is never reported missing. A build-only run creates\n\t// nothing, and neither does the local stage.\n\tconst resources =\n\t\t!ctx.buildOnly &&\n\t\t!request.skipResources &&\n\t\tphaseCtx.stage !== phaseCtx.workspace.stages.local;\n\tconst provision = async () => {\n\t\t// The token the stage's DNS records are written with, asked for first:\n\t\t// a deploy without it fails before anything is created or started.\n\t\tif (!request.skipDns && resolved.target.runtime === 'server') {\n\t\t\ttry {\n\t\t\t\tawait dnsCredentials(\n\t\t\t\t\tphaseCtx.stage,\n\t\t\t\t\tstageDnsDomains(\n\t\t\t\t\t\tphaseCtx.stage,\n\t\t\t\t\t\tphaseCtx.workspace.domains,\n\t\t\t\t\t\tphaseCtx.workspace.dns,\n\t\t\t\t\t),\n\t\t\t\t\tctx.credentials,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\temit({\n\t\t\t\t\ttype: 'phase.failed',\n\t\t\t\t\tphase: 'validate',\n\t\t\t\t\terror: eventError(error),\n\t\t\t\t});\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait provisionResources(phaseCtx, request, ctx, store, emit);\n\t};\n\n\t// A dry run takes no lock: it writes nothing a lock would protect, and it\n\t// should not stop a real deploy that starts while it is looking.\n\tif (ctx.dryRun) {\n\t\tif (resources) await provision();\n\t\tif (request.resourcesOnly) {\n\t\t\treturn resourcesOnly(target, phaseCtx, emit);\n\t\t}\n\t\tconst run = await validate(target, phaseCtx, emit);\n\t\tawait phase('plan', () => target.plan(phaseCtx, run));\n\t\treturn target.result(phaseCtx, run);\n\t}\n\n\t// Building changes no stage — nothing is provisioned, released or\n\t// recorded — so it takes no lock: a CI job building the next release must\n\t// not fail because a server is deploying the last one.\n\tif (ctx.buildOnly) {\n\t\tif (!target.build) throw new TargetBuildsNothing(resolved.name);\n\t\tconst run = await validate(target, phaseCtx, emit);\n\t\tawait phase('build', () => target.build!(phaseCtx, run));\n\t\treturn target.result(phaseCtx, run);\n\t}\n\n\t// One deploy of a stage at a time. Taken before the target generates,\n\t// provisions or records anything, and held until the run ends however it\n\t// ends. A second run of the stage — another CI job, a laptop — gets\n\t// `StateLocked` naming this one instead of racing it; a run killed with\n\t// the lock held is released with `gkm state:unlock`.\n\tlet lock: Awaited<ReturnType<typeof store.lock>>;\n\ttry {\n\t\t// A CI runner's disk is gone when the job ends; state kept on it is\n\t\t// lost with it, and the next run recreates every resource.\n\t\tassertStateOutlivesRun(phaseCtx.workspace, stage, 'deploy');\n\t\tlock = await store.lock(stage, { operation: 'deploy' });\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n\n\ttry {\n\t\tif (resources) await provision();\n\t\tif (request.resourcesOnly) {\n\t\t\treturn resourcesOnly(target, phaseCtx, emit);\n\t\t}\n\t\tconst run = await validate(target, phaseCtx, emit);\n\t\tif (target.provision) {\n\t\t\tawait phase('provision', () => target.provision!(phaseCtx, run));\n\t\t}\n\t\tif (target.build) {\n\t\t\tawait phase('build', () => target.build!(phaseCtx, run));\n\t\t}\n\n\t\tlet releasing: 'release' | 'verify' = 'release';\n\t\ttry {\n\t\t\tawait phase('release', () => target.release(phaseCtx, run));\n\t\t\treleasing = 'verify';\n\t\t\tif (target.verify) {\n\t\t\t\tawait phase('verify', () => target.verify!(phaseCtx, run));\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The caller stopping the run is not a release to undo.\n\t\t\tif (ctx.signal?.aborted || !target.capabilities.rollback) throw error;\n\t\t\tif (!target.rollback) throw error;\n\t\t\ttry {\n\t\t\t\tawait phase('rollback', () =>\n\t\t\t\t\ttarget.rollback!(phaseCtx, run, { phase: releasing, error }),\n\t\t\t\t);\n\t\t\t} catch (rollbackError) {\n\t\t\t\tthrow new RollbackFailed(resolved.name, error, rollbackError);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn await target.result(phaseCtx, run);\n\t} finally {\n\t\tawait lock.release();\n\t}\n}\n\n/**\n * The stage's providers, run inside the validate phase. A dry run plans them\n * and, so the checks after it see the stage as the run would leave it, reads\n * the keys they would write as placeholders.\n */\nasync function provisionResources(\n\tphaseCtx: DeployPhaseContext<unknown>,\n\trequest: DeployRequest,\n\tctx: DeployContext,\n\tstore: Awaited<ReturnType<typeof createStateStore>>,\n\temit: (event: DeployEvent) => void,\n): Promise<void> {\n\ttry {\n\t\tconst reports = await provisionStage({\n\t\t\tworkspace: phaseCtx.workspace,\n\t\t\tstage: phaseCtx.stage,\n\t\t\tmanifest: phaseCtx.manifest,\n\t\t\trunnables: (phaseCtx.runnables ?? {}) as Record<string, string[]>,\n\t\t\tsecrets: phaseCtx.secrets,\n\t\t\tstate: store,\n\t\t\tdryRun: ctx.dryRun,\n\t\t\t...(request.rotateKeys ? { rotateKeys: true } : {}),\n\t\t\t...(request.retireOldKeys ? { retireOldKeys: true } : {}),\n\t\t\t...(ctx.home ? { home: ctx.home } : {}),\n\t\t\tlog: (line) => phaseCtx.logger.info(line),\n\t\t});\n\t\tif (!ctx.dryRun) return;\n\t\tconst planned = reports.flatMap((r) => r.planned);\n\t\tif (planned.length === 0) return;\n\t\tconst secrets = phaseCtx.secrets;\n\t\t(phaseCtx as { secrets: typeof secrets }).secrets = {\n\t\t\t...secrets,\n\t\t\tasync read() {\n\t\t\t\tconst stored =\n\t\t\t\t\t(await secrets.read()) ?? initStageSecrets(phaseCtx.stage);\n\t\t\t\tconst custom = { ...stored.custom };\n\t\t\t\tfor (const key of planned) custom[key] ??= PLANNED_BY_THE_DEPLOY;\n\t\t\t\treturn { ...stored, custom };\n\t\t\t},\n\t\t};\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n}\n\n/** What a dry run reads for a key its providers would write. */\nexport const PLANNED_BY_THE_DEPLOY = 's3://planned-by-this-deploy';\n\n/** `--resources-only`: the target's own resources, and nothing else. */\nasync function resourcesOnly(\n\ttarget: AnyDeployTarget,\n\tphaseCtx: DeployPhaseContext<unknown>,\n\temit: (event: DeployEvent) => void,\n): Promise<DeployResult> {\n\ttry {\n\t\tif (target.resources) await target.resources(phaseCtx);\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n\temit({ type: 'phase.finished', phase: 'validate' });\n\treturn resourcesResult(phaseCtx);\n}\n\n/** A `--resources-only` run: no app was deployed. */\nfunction resourcesResult(phaseCtx: DeployPhaseContext<unknown>): DeployResult {\n\treturn {\n\t\tapps: [],\n\t\tprojectId: '',\n\t\tsuccessCount: 0,\n\t\tfailedCount: 0,\n\t\tstage: phaseCtx.stage,\n\t\tidentity: phaseCtx.identity.key,\n\t\ttag: phaseCtx.tag,\n\t\tdryRun: phaseCtx.dryRun,\n\t\tenvironmentId: '',\n\t\tskipped: [...phaseCtx.skipped],\n\t\turls: {},\n\t\tchanges: [],\n\t};\n}\n\n/** `validate`, then the run's `deploy.started`, inside the validate phase. */\nasync function validate(\n\ttarget: AnyDeployTarget,\n\tphaseCtx: DeployPhaseContext<unknown>,\n\temit: (event: DeployEvent) => void,\n): Promise<unknown> {\n\ttry {\n\t\tconst run = await target.validate(phaseCtx);\n\t\tconst skipped = new Set(phaseCtx.skipped.map((s) => s.app));\n\t\temit({\n\t\t\ttype: 'deploy.started',\n\t\t\tstage: phaseCtx.stage,\n\t\t\ttarget: phaseCtx.target,\n\t\t\tidentity: phaseCtx.identity.key,\n\t\t\ttag: phaseCtx.tag,\n\t\t\tapps: phaseCtx.apps.filter((app) => !skipped.has(app)),\n\t\t\tdryRun: phaseCtx.dryRun,\n\t\t});\n\t\temit({ type: 'phase.finished', phase: 'validate' });\n\t\treturn run;\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n}\n\ninterface Prepared {\n\tresolved: ResolvedTarget;\n\tphaseCtx: DeployPhaseContext<unknown>;\n\tstore: Awaited<ReturnType<typeof createStateStore>>;\n}\n\n/** Everything the phases are handed, worked out before the first of them. */\nasync function prepare(\n\tsource: NormalizedWorkspace | (() => Promise<NormalizedWorkspace>),\n\trequest: DeployRequest,\n\tctx: DeployContext,\n\temit: (event: DeployEvent) => void,\n\tredactor: Redactor,\n): Promise<Prepared> {\n\tconst { stage } = request;\n\tif (request.resourcesOnly && request.skipResources) {\n\t\tthrow new ResourcesOnlyAndSkipped();\n\t}\n\tconst configured = typeof source === 'function' ? await source() : source;\n\n\t// Before anything is provisioned: a typo'd stage would otherwise create a\n\t// whole second environment under the wrong name. The local stage is left\n\t// to the target, which says whether it can run it.\n\tconst local = stage === configured.stages.local;\n\tif (!local) assertDeployedStage(configured.stages, stage);\n\n\t// Before anything is discovered or derived: a target that cannot be found\n\t// — or a package that would not load — fails a deploy that has done\n\t// nothing yet.\n\tconst targetName = request.target ?? configured.deploy?.default ?? 'dokploy';\n\tconst resolved = await resolveTarget(targetName, {\n\t\tworkspace: configured,\n\t\tstage,\n\t\t...(ctx.targets ? { host: ctx.targets } : {}),\n\t});\n\tif (local && !resolved.target.capabilities.localStage) {\n\t\tassertDeployedStage(configured.stages, stage);\n\t}\n\tconst options = await parseTargetOptions(resolved);\n\n\t// Before anything is discovered: dev services asked of a target that runs\n\t// no containers fail a deploy that has done nothing.\n\tconst allowDevServices = request.allowDevServices === true;\n\tif (allowDevServices && resolved.target.runtime === 'aws') {\n\t\tthrow new DevServicesNeedServerTarget(targetName);\n\t}\n\n\t// What to deploy comes from the manifest.\n\t//\n\t// Discovered here rather than by the target, because the list of things\n\t// to deploy is the *declarations* — one `rest-api` is one server, one\n\t// `site` is one site — and the config only says how to run each. A project\n\t// that declares no surfaces keeps its configured apps, so adopting\n\t// constructs stays something you do a piece at a time.\n\tconst runnables: Record<string, string[]> = {};\n\tconst background: Record<string, string[]> = {};\n\tconst manifest = await discover({\n\t\tpatterns: constructGlobs(configured),\n\t\tcwd: configured.root,\n\t\trunnables,\n\t\tbackground,\n\t});\n\t// Where the stage's telemetry goes, settled before anything is built: a\n\t// stage that uses a `Telemetry` node on a target that cannot choose for it\n\t// — AWS has no self-hosted provider — fails here, naming the config.\n\tresolveStageTelemetry({\n\t\t...(configured.deploy?.telemetry\n\t\t\t? { telemetry: configured.deploy.telemetry }\n\t\t\t: {}),\n\t\tstage,\n\t\tlocal,\n\t\ttarget: targetName,\n\t\truntime: resolved.target.runtime,\n\t\tselfHosted: resolved.target.capabilities.selfHostedTelemetry === true,\n\t\tused: usesTelemetry(manifest),\n\t});\n\n\tconst units = derivedApps(manifest, configured);\n\tconst workspace: NormalizedWorkspace =\n\t\tObject.keys(units).length > 0 ? { ...configured, apps: units } : configured;\n\n\t// What every resource this deploy touches is named and claimed by —\n\t// resolved first, so a namespace that cannot be a name fails before\n\t// anything is built.\n\tconst identity = deployIdentity(workspace, stage);\n\tconst tag =\n\t\trequest.tag ??\n\t\t(resolved.target.tag\n\t\t\t? await resolved.target.tag({ cwd: workspace.root, stage })\n\t\t\t: generateTag(stage));\n\n\t// The apps asked for, in dependency order.\n\tconst buildOrder = getAppBuildOrder(workspace);\n\tlet selected = buildOrder;\n\tif (request.apps && request.apps.length > 0) {\n\t\tconst unknown = request.apps.filter((name) => !workspace.apps[name]);\n\t\tif (unknown.length > 0) {\n\t\t\tthrow new UnknownDeployApps(unknown, Object.keys(workspace.apps));\n\t\t}\n\t\tselected = buildOrder.filter((name) => request.apps!.includes(name));\n\t}\n\n\tconst skipped: { app: string; reason: string }[] = [];\n\tconst skip = (app: string, reason: string) => {\n\t\tskipped.push({ app, reason });\n\t\temit({ type: 'app.skipped', app, reason });\n\t};\n\n\t// An app that names another target deploys there, in a run of its own.\n\t// One on the default follows the run, so `--target` moves the stage\n\t// without every app having to be told.\n\tconst byDefault = configured.deploy?.default ?? 'dokploy';\n\tconst apps = selected.filter((name) => {\n\t\tconst own = workspace.apps[name]!.resolvedDeployTarget;\n\t\tconst deploysThrough = own === byDefault ? targetName : own;\n\t\tif (deploysThrough === targetName) return true;\n\t\tskip(name, elsewhere(deploysThrough, stage));\n\t\treturn false;\n\t});\n\tif (apps.length === 0) throw new NoDeployableApps(stage, targetName);\n\n\tconst store = await createStateStore({\n\t\tconfig: workspace.state,\n\t\tworkspaceRoot: workspace.root,\n\t\tworkspaceName: workspace.name,\n\t});\n\tconst secrets = await deploySecrets(workspace, stage, redactor, {\n\t\t...(ctx.home ? { home: ctx.home } : {}),\n\t});\n\n\tconst line =\n\t\t(level: 'info' | 'warn' | 'error') =>\n\t\t(message: string): void =>\n\t\t\temit({ type: 'log', level, message });\n\tconst logger: DeployTargetLogger = {\n\t\tinfo: line('info'),\n\t\twarn: line('warn'),\n\t\terror: line('error'),\n\t};\n\n\tconst phaseCtx: DeployPhaseContext<unknown> = {\n\t\ttarget: targetName,\n\t\tcwd: workspace.root,\n\t\tstage,\n\t\ttag,\n\t\ttagGiven: request.tag !== undefined,\n\t\tapps,\n\t\tskipped,\n\t\tidentity,\n\t\tworkspace,\n\t\tmanifest,\n\t\trunnables,\n\t\tbackground,\n\t\toptions,\n\t\tdryRun: ctx.dryRun,\n\t\tatomic: request.atomic ?? false,\n\t\tallowDevServices,\n\t\t...(request.skipDns ? { skipDns: true } : {}),\n\t\t...(request.skipResources ? { skipResources: true } : {}),\n\t\tcredentials: ctx.credentials,\n\t\tstate: store,\n\t\tsecrets,\n\t\tlogger,\n\t\tsignal: ctx.signal ?? new AbortController().signal,\n\t\tchildOutput: ctx.childOutput ?? 'inherit',\n\t\temit,\n\t\tskip,\n\t\tname: (resource) => applicationName(identity, resource),\n\t};\n\n\treturn { resolved, phaseCtx, store };\n}\n","/**\n * `deploy()`: a deploy as a library call.\n *\n * `gkm deploy` could only be driven from an interactive terminal: it prompted\n * for what it lacked and exited the process on failure, worked out of\n * `process.cwd()`, and reported progress by printing. Here the caller says\n * where the project is, hands over the credentials and a signal, and gets back\n * a run — events to iterate while it goes, and a structured result at the end.\n * Nothing below this asks a person anything or ends the process; `gkm deploy`\n * is a thin wrapper that does both.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../config';\nimport { gkmHome } from '../home';\nimport { type OutputLevel, withOutput } from '../output';\nimport { LocalSandbox } from '../sandbox/local';\nimport { type Sandbox, withSandbox } from '../sandbox/sandbox';\nimport { Redactor } from '../target/secrets';\nimport type { AnyDeployTarget } from '../target/types';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { type CredentialProvider, storedCredentials } from './credentials';\nimport { type DeployEvent, eventError } from './events';\nimport { type DeployContext, runDeploy } from './orchestrate';\nimport type { DeployResult } from './types';\n\n/**\n * Where a run's progress lines go, besides its events. `@geekmidas/logger`'s\n * `Logger` is one.\n */\nexport interface DeployLogger {\n\tinfo(message: string): void;\n\twarn(message: string): void;\n\terror?(message: string): void;\n}\n\nexport interface DeployInput {\n\t/**\n\t * The project to deploy: the directory holding `gkm.config.ts`, or any\n\t * directory inside it. Never assumed to be `process.cwd()`.\n\t */\n\tcwd: string;\n\t/**\n\t * The stage to deploy — one of the config's deployed stages, or its local\n\t * stage through a target that runs one (`compose`).\n\t */\n\tstage: string;\n\t/**\n\t * The target to deploy through, by name. Defaults to `deploy.default`,\n\t * else `dokploy`.\n\t */\n\ttarget?: string;\n\t/**\n\t * The host's own targets, by name. Consulted before the built-ins and the\n\t * config's `deploy.targets`, so a host can deploy through an\n\t * implementation of its own — `{ dokploy: myDokploy }` included.\n\t */\n\ttargets?: Record<string, AnyDeployTarget>;\n\t/** The image tag. Defaults to `<stage>-<timestamp>`. */\n\ttag?: string;\n\t/** Deploy only these apps (in dependency order). Defaults to all. */\n\tapps?: string[];\n\t/**\n\t * Look everything up and report what would happen — as `resource.planned`\n\t * events — without taking the lock, writing state, generating secrets,\n\t * changing Dokploy or building and pushing images.\n\t */\n\tdryRun?: boolean;\n\t/**\n\t * Validate and build only: the target's images built — and pushed, where\n\t * it pushes them — with no lock taken and nothing provisioned, released,\n\t * verified or recorded. `gkm compose --build --push` runs this way.\n\t */\n\tbuildOnly?: boolean;\n\t/**\n\t * When a release or its verification fails, roll back every app the run\n\t * released rather than only the ones that failed — on a target that can\n\t * roll back. For apps that must move together.\n\t */\n\tatomic?: boolean;\n\t/**\n\t * Where credentials come from. Defaults to the environment, then the\n\t * logins `gkm login` stored. A credential no provider has stops the run\n\t * with `MissingCredential`; nothing prompts.\n\t */\n\tcredentials?: CredentialProvider;\n\t/**\n\t * On a server target, run a dev service for every construct a deployed\n\t * stage does not account for — no key in its secrets, and no provider\n\t * (`deploy.objects`) backing its kind: MinIO for a bucket, Mailpit for\n\t * mail. Neither is production-grade — Mailpit delivers no mail — and every\n\t * run that uses one emits `dev-service.used`. Without it, a deployed stage\n\t * missing a mail or storage key fails with `ExternalServicesNotConfigured`;\n\t * on an AWS target it fails with `DevServicesNeedServerTarget`.\n\t */\n\tallowDevServices?: boolean;\n\t/**\n\t * On a server target, neither write the public hosts' DNS records nor\n\t * check that they point at the stage's server (`GKM_SERVER_IPV4`) — for a\n\t * CDN or proxy in front of the server, or records written by another step.\n\t */\n\tskipDns?: boolean;\n\t/**\n\t * Create the stage's resources — its providers' (deploy.<kind>.<stage>)\n\t * and its DNS records — and nothing else: what a CI runner runs with the\n\t * cloud credentials and DNS token before the server deploys.\n\t */\n\tresourcesOnly?: boolean;\n\t/**\n\t * An earlier `resourcesOnly` run created the stage's resources: run no\n\t * provider, and write or check no DNS record.\n\t */\n\tskipResources?: boolean;\n\t/** Each provider issues its runtime keys a successor. */\n\trotateKeys?: boolean;\n\t/** Delete a rotated-out key now, not after the next deploy. */\n\tretireOldKeys?: boolean;\n\t/** Receives each progress line as it is written. Defaults to none. */\n\tlogger?: DeployLogger;\n\t/**\n\t * Stops the run: in-flight Dokploy requests and docker children are\n\t * cancelled, the stage's lock is released, and `result` rejects with the\n\t * signal's reason.\n\t */\n\tsignal?: AbortSignal;\n\t/**\n\t * The CLI's home: stage keys and stored logins. Defaults to `GKM_HOME`,\n\t * else `~/.gkm`.\n\t */\n\thome?: string;\n\t/**\n\t * Where docker's own output goes: the host's terminal (`inherit`, the\n\t * default), its stderr, or nowhere.\n\t */\n\tchildOutput?: 'inherit' | 'stderr' | 'ignore';\n\t/**\n\t * Where the project's own code runs: loading `gkm.config.ts`, discovering\n\t * its constructs, sniffing each app's environment. Defaults to a\n\t * `LocalSandbox` on the project — a child process here with an\n\t * allowlisted environment, for a project the host trusts.\n\t *\n\t * A host deploying repositories it does not trust passes one that\n\t * isolates — a container per build — and the config then reaches the\n\t * deploy only as data. Credentials never enter a sandbox: they go from\n\t * `credentials` to the steps that provision, push and release.\n\t */\n\tsandbox?: Sandbox;\n}\n\n/** A deploy in progress. */\nexport interface DeployRun extends AsyncIterable<DeployEvent> {\n\t/**\n\t * What the deploy did, once it is done. Rejects with the error that\n\t * stopped it — `MissingCredential`, `StateLocked`, `ProjectNotOwned`, … —\n\t * after a `deploy.failed` event carrying the same.\n\t */\n\treadonly result: Promise<DeployResult>;\n}\n\n/**\n * Every event a run emits, kept so that each iteration — however late it\n * starts — sees the run from its first event to its last.\n */\nclass EventLog {\n\tprivate readonly events: DeployEvent[] = [];\n\tprivate closed = false;\n\tprivate waiting: (() => void)[] = [];\n\n\tpush(event: DeployEvent): void {\n\t\tthis.events.push(event);\n\t\tthis.wake();\n\t}\n\n\tclose(): void {\n\t\tthis.closed = true;\n\t\tthis.wake();\n\t}\n\n\tprivate wake(): void {\n\t\tconst waiting = this.waiting;\n\t\tthis.waiting = [];\n\t\tfor (const resume of waiting) resume();\n\t}\n\n\tasync *iterate(): AsyncGenerator<DeployEvent> {\n\t\tlet next = 0;\n\t\twhile (true) {\n\t\t\tif (next < this.events.length) {\n\t\t\t\tyield this.events[next++]!;\n\t\t\t} else if (this.closed) {\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tawait new Promise<void>((resume) => this.waiting.push(resume));\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction forward(\n\tlogger: DeployLogger | undefined,\n\tlevel: OutputLevel,\n\tmessage: string,\n): void {\n\tif (!logger) return;\n\tif (level === 'info') logger.info(message);\n\telse if (level === 'error' && logger.error) logger.error(message);\n\telse logger.warn(message);\n}\n\n/**\n * Deploy a project's stage.\n *\n * ```ts\n * import { deploy } from '@geekmidas/cli/deploy';\n *\n * const run = deploy({ cwd: '/srv/checkouts/shop', stage: 'production' });\n * for await (const event of run) {\n * if (event.type === 'app.deployed') console.log(event.app, event.url);\n * }\n * const result = await run.result;\n * ```\n *\n * The run starts at once; iterating it is optional, and an iteration started\n * late still sees every event from the first.\n */\nexport function deploy(input: DeployInput): DeployRun {\n\tconst log = new EventLog();\n\t// Every secret the run reads is masked in every line it reports — in the\n\t// events and in what the logger is handed.\n\tconst redactor = new Redactor();\n\tconst emit = (event: DeployEvent) => {\n\t\tconst masked =\n\t\t\tevent.type === 'log'\n\t\t\t\t? { ...event, message: redactor.redact(event.message) }\n\t\t\t\t: event;\n\t\tlog.push(masked);\n\t\tif (masked.type === 'log') {\n\t\t\tforward(input.logger, masked.level, masked.message);\n\t\t}\n\t};\n\n\tconst ctx: DeployContext = {\n\t\temit,\n\t\tcredentials:\n\t\t\tinput.credentials ?? storedCredentials({ home: input.home ?? gkmHome() }),\n\t\tdryRun: input.dryRun ?? false,\n\t\t...(input.buildOnly ? { buildOnly: true } : {}),\n\t\thome: input.home ?? gkmHome(),\n\t\tredactor,\n\t\t...(input.signal ? { signal: input.signal } : {}),\n\t\t...(input.childOutput ? { childOutput: input.childOutput } : {}),\n\t\t...(input.targets ? { targets: input.targets } : {}),\n\t};\n\n\t// Every line anything in the run writes through `output` — the deploy's\n\t// own, the Dockerfile generator's, discovery's warnings — becomes an event\n\t// of this run, and of no other.\n\tconst result = withOutput(\n\t\t(level, message) => emit({ type: 'log', level, message }),\n\t\tasync () => {\n\t\t\ttry {\n\t\t\t\tinput.signal?.throwIfAborted();\n\t\t\t\tconst sandbox =\n\t\t\t\t\tinput.sandbox ??\n\t\t\t\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\t\t\t\t// Every step of the run that executes the project's code — the\n\t\t\t\t// engine's own discoveries and sniffs included — runs in it.\n\t\t\t\tconst deployed = await withSandbox(sandbox, () =>\n\t\t\t\t\trunDeploy(\n\t\t\t\t\t\t() => load(input, sandbox),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstage: input.stage,\n\t\t\t\t\t\t\t...(input.target ? { target: input.target } : {}),\n\t\t\t\t\t\t\t...(input.tag ? { tag: input.tag } : {}),\n\t\t\t\t\t\t\t...(input.apps ? { apps: input.apps } : {}),\n\t\t\t\t\t\t\t...(input.atomic ? { atomic: true } : {}),\n\t\t\t\t\t\t\t...(input.allowDevServices\n\t\t\t\t\t\t\t\t? { allowDevServices: input.allowDevServices }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t...(input.skipDns ? { skipDns: true } : {}),\n\t\t\t\t\t\t\t...(input.resourcesOnly ? { resourcesOnly: true } : {}),\n\t\t\t\t\t\t\t...(input.skipResources ? { skipResources: true } : {}),\n\t\t\t\t\t\t\t...(input.rotateKeys ? { rotateKeys: true } : {}),\n\t\t\t\t\t\t\t...(input.retireOldKeys ? { retireOldKeys: true } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tctx,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\temit({ type: 'deploy.finished', result: deployed });\n\t\t\t\treturn deployed;\n\t\t\t} catch (error) {\n\t\t\t\temit({ type: 'deploy.failed', error: eventError(error) });\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tlog.close();\n\t\t\t}\n\t\t},\n\t);\n\n\t// A caller that only iterates still learns of the failure from the\n\t// `deploy.failed` event; the rejection must not also crash its process as\n\t// unhandled. Awaiting `result` still rejects.\n\tresult.catch(() => {});\n\n\treturn {\n\t\tresult,\n\t\t[Symbol.asyncIterator]: () => log.iterate(),\n\t};\n}\n\n/**\n * The workspace at `input.cwd`. The stage is checked by the run, once it\n * knows the target: one that runs on this machine may take the local stage.\n */\nasync function load(\n\tinput: DeployInput,\n\tsandbox: Sandbox,\n): Promise<NormalizedWorkspace> {\n\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\tsandbox,\n\t});\n\treturn workspace;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,kBAAkB;;AAGxB,IAAa,WAAb,MAAsB;CACrB,yBAA0B,IA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
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
- import { r as storedCredentials, x as gkmHome } from "./credentials-C4KII3PD.mjs";
2
+ import { r as storedCredentials, x as gkmHome } from "./credentials-DpfnUvIR.mjs";
3
3
  import { f as withOutput, r as discover } from "./discover-qjFapetL.mjs";
4
4
  import { c as withSandbox } from "./sandbox-CbVB7uOD.mjs";
5
5
  import { n as derivedApps } from "./derive-B4vDpzgP.mjs";
6
- import { L as resolveStageTelemetry, N as assertDeployedStage, u as getAppBuildOrder } from "./workspace-Bzw7Zs82.mjs";
6
+ import { L as resolveStageTelemetry, N as assertDeployedStage, u as getAppBuildOrder } from "./workspace-DWK1PTXP.mjs";
7
7
  import { o as builtinTarget } from "./define-6poNqm5O.mjs";
8
8
  import { findWorkspaceRoot, loadWorkspaceConfig } from "./config.mjs";
9
- import { Dt as constructGlobs, Q as assertStateOutlivesRun, ct as DevServicesNeedServerTarget, et as createStateStore, jn as usesTelemetry, nr as deployIdentity, qn as secretsStoreFor, tr as applicationName } from "./seeds-BSL55F6q.mjs";
10
- import { a as parseTargetOptions, o as resolveTarget } from "./resolve-Ccjlpnd9.mjs";
11
- import { t as LocalSandbox } from "./local-Otp74ak0.mjs";
12
- import { l as eventError } from "./sniffer-BTtGAtm3.mjs";
9
+ import { En as usesTelemetry, Hn as secretsStoreFor, K as dnsCredentials, Q as stageDnsDomains, St as constructGlobs, Xn as applicationName, Zn as deployIdentity, ir as initStageSecrets, x as DevServicesNeedServerTarget } from "./seeds-CTxTZa-R.mjs";
10
+ import { a as parseTargetOptions, o as resolveTarget } from "./resolve-Dyd1S2wn.mjs";
11
+ import { t as LocalSandbox } from "./local-B7Zv1NoA.mjs";
12
+ import { S as eventError, _ as assertStateOutlivesRun, y as createStateStore } from "./sniffer-DCcuzHz_.mjs";
13
+ import { t as provisionStage } from "./providers-sTj-BG0S.mjs";
13
14
  import { resolve } from "node:path";
14
15
  //#region src/target/secrets.ts
15
16
  /**
@@ -81,6 +82,13 @@ async function deploySecrets(workspace, stage, redactor, options = {}) {
81
82
  * reporting each as it starts, finishes or fails. Everything that is about
82
83
  * *where* the stage goes is the target's.
83
84
  */
85
+ /** `--resources-only` with `--skip-resources`: the one asks for what the other skips. */
86
+ var ResourcesOnlyAndSkipped = class extends 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
+ };
84
92
  /** Apps were asked for by name that the workspace does not have. */
85
93
  var UnknownDeployApps = class extends GkmError {
86
94
  apps;
@@ -192,7 +200,23 @@ async function runDeploy(source, request, ctx) {
192
200
  }
193
201
  const { resolved, phaseCtx, store } = prepared;
194
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 dnsCredentials(phaseCtx.stage, 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: eventError(error)
212
+ });
213
+ throw error;
214
+ }
215
+ await provisionResources(phaseCtx, request, ctx, store, emit);
216
+ };
195
217
  if (ctx.dryRun) {
218
+ if (resources) await provision();
219
+ if (request.resourcesOnly) return resourcesOnly(target, phaseCtx, emit);
196
220
  const run = await validate(target, phaseCtx, emit);
197
221
  await phase("plan", () => target.plan(phaseCtx, run));
198
222
  return target.result(phaseCtx, run);
@@ -216,6 +240,8 @@ async function runDeploy(source, request, ctx) {
216
240
  throw error;
217
241
  }
218
242
  try {
243
+ if (resources) await provision();
244
+ if (request.resourcesOnly) return resourcesOnly(target, phaseCtx, emit);
219
245
  const run = await validate(target, phaseCtx, emit);
220
246
  if (target.provision) await phase("provision", () => target.provision(phaseCtx, run));
221
247
  if (target.build) await phase("build", () => target.build(phaseCtx, run));
@@ -242,6 +268,88 @@ async function runDeploy(source, request, ctx) {
242
268
  await lock.release();
243
269
  }
244
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 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() ?? 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: 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: 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
+ }
245
353
  /** `validate`, then the run's `deploy.started`, inside the validate phase. */
246
354
  async function validate(target, phaseCtx, emit) {
247
355
  try {
@@ -273,6 +381,7 @@ async function validate(target, phaseCtx, emit) {
273
381
  /** Everything the phases are handed, worked out before the first of them. */
274
382
  async function prepare(source, request, ctx, emit, redactor) {
275
383
  const { stage } = request;
384
+ if (request.resourcesOnly && request.skipResources) throw new ResourcesOnlyAndSkipped();
276
385
  const configured = typeof source === "function" ? await source() : source;
277
386
  const local = stage === configured.stages.local;
278
387
  if (!local) assertDeployedStage(configured.stages, stage);
@@ -376,7 +485,8 @@ async function prepare(source, request, ctx, emit, redactor) {
376
485
  dryRun: ctx.dryRun,
377
486
  atomic: request.atomic ?? false,
378
487
  allowDevServices,
379
- ...request.skipDnsCheck ? { skipDnsCheck: true } : {},
488
+ ...request.skipDns ? { skipDns: true } : {},
489
+ ...request.skipResources ? { skipResources: true } : {},
380
490
  credentials: ctx.credentials,
381
491
  state: store,
382
492
  secrets,
@@ -490,7 +600,11 @@ function deploy(input) {
490
600
  ...input.apps ? { apps: input.apps } : {},
491
601
  ...input.atomic ? { atomic: true } : {},
492
602
  ...input.allowDevServices ? { allowDevServices: input.allowDevServices } : {},
493
- ...input.skipDnsCheck ? { skipDnsCheck: true } : {}
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 } : {}
494
608
  }, ctx));
495
609
  emit({
496
610
  type: "deploy.finished",
@@ -524,4 +638,4 @@ async function load(input, sandbox) {
524
638
  //#endregion
525
639
  export { UnknownDeployApps as a, TargetBuildsNothing as i, NoDeployableApps as n, RollbackFailed as r, deploy as t };
526
640
 
527
- //# sourceMappingURL=deploy-DYIyIUYd.mjs.map
641
+ //# sourceMappingURL=deploy-CeJ5D0xn.mjs.map