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

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 (213) hide show
  1. package/dist/{GoDaddyProvider-Mi3vptSR.mjs → GoDaddyProvider-BwW51hPm.mjs} +3 -3
  2. package/dist/{GoDaddyProvider-Mi3vptSR.mjs.map → GoDaddyProvider-BwW51hPm.mjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-BZb-V14e.cjs → GoDaddyProvider-C_DgIkMv.cjs} +3 -3
  4. package/dist/{GoDaddyProvider-BZb-V14e.cjs.map → GoDaddyProvider-C_DgIkMv.cjs.map} +1 -1
  5. package/dist/{HostingerProvider-1mqD6aG8.mjs → HostingerProvider-BNpS9aRJ.mjs} +9 -4
  6. package/dist/{HostingerProvider-1mqD6aG8.mjs.map → HostingerProvider-BNpS9aRJ.mjs.map} +1 -1
  7. package/dist/{HostingerProvider-C6t-PSNe.cjs → HostingerProvider-DR1iws1P.cjs} +9 -4
  8. package/dist/HostingerProvider-DR1iws1P.cjs.map +1 -0
  9. package/dist/{LegacyStateStore-BlYXQQSE.cjs → LegacyStateStore-BawjE_5n.cjs} +10 -9
  10. package/dist/{LegacyStateStore-BlYXQQSE.cjs.map → LegacyStateStore-BawjE_5n.cjs.map} +1 -1
  11. package/dist/{LegacyStateStore-CtwO7fwy.mjs → LegacyStateStore-D5DarNA2.mjs} +3 -2
  12. package/dist/{LegacyStateStore-CtwO7fwy.mjs.map → LegacyStateStore-D5DarNA2.mjs.map} +1 -1
  13. package/dist/{LocalStateStore-oX_zxj9V.cjs → LocalStateStore-D8fu5WiF.cjs} +8 -8
  14. package/dist/{LocalStateStore-oX_zxj9V.cjs.map → LocalStateStore-D8fu5WiF.cjs.map} +1 -1
  15. package/dist/{LocalStateStore-D40_SDmJ.mjs → LocalStateStore-YjIqlgAz.mjs} +2 -2
  16. package/dist/{LocalStateStore-D40_SDmJ.mjs.map → LocalStateStore-YjIqlgAz.mjs.map} +1 -1
  17. package/dist/{S3StateStore-BzS0IeSt.mjs → S3StateStore-CjTAVsWh.mjs} +2 -2
  18. package/dist/{S3StateStore-BzS0IeSt.mjs.map → S3StateStore-CjTAVsWh.mjs.map} +1 -1
  19. package/dist/{S3StateStore-DeI7jtvi.cjs → S3StateStore-Cm-v2IPI.cjs} +5 -5
  20. package/dist/{S3StateStore-DeI7jtvi.cjs.map → S3StateStore-Cm-v2IPI.cjs.map} +1 -1
  21. package/dist/{SSMStateStore-CaCtrzFL.cjs → SSMStateStore-BS4BiZCN.cjs} +9 -9
  22. package/dist/{SSMStateStore-CaCtrzFL.cjs.map → SSMStateStore-BS4BiZCN.cjs.map} +1 -1
  23. package/dist/{SSMStateStore-k_Ew7TWx.mjs → SSMStateStore-BhtM6jOh.mjs} +2 -2
  24. package/dist/{SSMStateStore-k_Ew7TWx.mjs.map → SSMStateStore-BhtM6jOh.mjs.map} +1 -1
  25. package/dist/{add-VcyJnsPX.cjs → add-D-3IKT7W.cjs} +24 -53
  26. package/dist/add-D-3IKT7W.cjs.map +1 -0
  27. package/dist/{add-CP1podDH.mjs → add-ylx8dejw.mjs} +23 -52
  28. package/dist/add-ylx8dejw.mjs.map +1 -0
  29. package/dist/{bundler-Dfsr6KXU.cjs → bundler-CI3elfZS.cjs} +5 -5
  30. package/dist/{bundler-Dfsr6KXU.cjs.map → bundler-CI3elfZS.cjs.map} +1 -1
  31. package/dist/{bundler-BWrh-AJH.mjs → bundler-ywR3C1B_.mjs} +5 -5
  32. package/dist/{bundler-BWrh-AJH.mjs.map → bundler-ywR3C1B_.mjs.map} +1 -1
  33. package/dist/{cli-B8otnZfX.mjs → cli-BCSuCfQk.mjs} +9 -5
  34. package/dist/cli-BCSuCfQk.mjs.map +1 -0
  35. package/dist/{cli-DL19w4OE.cjs → cli-Dewt2T21.cjs} +9 -5
  36. package/dist/cli-Dewt2T21.cjs.map +1 -0
  37. package/dist/{compose-DrEB_4F-.mjs → compose-C4js1JDv.mjs} +82 -47
  38. package/dist/compose-C4js1JDv.mjs.map +1 -0
  39. package/dist/{compose-BHVKLluX.cjs → compose-Dd0XphvF.cjs} +94 -59
  40. package/dist/compose-Dd0XphvF.cjs.map +1 -0
  41. package/dist/{config-DCCcrOSo.d.cts → config-4yirvxS8.d.cts} +4 -4
  42. package/dist/{config-CHX5GOo3.d.mts.map → config-4yirvxS8.d.cts.map} +1 -1
  43. package/dist/{config-CHX5GOo3.d.mts → config-C8NPCn1l.d.mts} +4 -4
  44. package/dist/{config-DCCcrOSo.d.cts.map → config-C8NPCn1l.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-C4KII3PD.mjs → credentials-B5N5yKk6.mjs} +12 -134
  50. package/dist/credentials-B5N5yKk6.mjs.map +1 -0
  51. package/dist/{credentials-QBu7VgaQ.cjs → credentials-Zqr3QQYB.cjs} +11 -175
  52. package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
  53. package/dist/deploy/public.cjs +19 -18
  54. package/dist/deploy/public.cjs.map +1 -1
  55. package/dist/deploy/public.d.cts +24 -9
  56. package/dist/deploy/public.d.cts.map +1 -1
  57. package/dist/deploy/public.d.mts +24 -9
  58. package/dist/deploy/public.d.mts.map +1 -1
  59. package/dist/deploy/public.mjs +11 -10
  60. package/dist/deploy/public.mjs.map +1 -1
  61. package/dist/deploy-B0drCD6s.mjs +1854 -0
  62. package/dist/deploy-B0drCD6s.mjs.map +1 -0
  63. package/dist/deploy-Bw1FjX_x.cjs +1903 -0
  64. package/dist/deploy-Bw1FjX_x.cjs.map +1 -0
  65. package/dist/{discover-vk2r5giK.d.cts → discover-BtFofyQB.d.cts} +2 -2
  66. package/dist/{discover-DqwlBVyY.d.mts.map → discover-BtFofyQB.d.cts.map} +1 -1
  67. package/dist/{discover-DqwlBVyY.d.mts → discover-D-MdXZgm.d.mts} +2 -2
  68. package/dist/{discover-vk2r5giK.d.cts.map → discover-D-MdXZgm.d.mts.map} +1 -1
  69. package/dist/dns-Bmk7P9c2.cjs +663 -0
  70. package/dist/dns-Bmk7P9c2.cjs.map +1 -0
  71. package/dist/dns-CyMIq6to.cjs +55 -0
  72. package/dist/dns-CyMIq6to.cjs.map +1 -0
  73. package/dist/dns-X3oqEV4C.mjs +44 -0
  74. package/dist/dns-X3oqEV4C.mjs.map +1 -0
  75. package/dist/dns-idXfyCay.mjs +610 -0
  76. package/dist/dns-idXfyCay.mjs.map +1 -0
  77. package/dist/{dokploy-o4I6vb9W.mjs → dokploy-CZYxXeMa.mjs} +2 -2
  78. package/dist/{dokploy-o4I6vb9W.mjs.map → dokploy-CZYxXeMa.mjs.map} +1 -1
  79. package/dist/{dokploy-rivb1RFt.cjs → dokploy-DaT0mgLU.cjs} +2 -2
  80. package/dist/{dokploy-rivb1RFt.cjs.map → dokploy-DaT0mgLU.cjs.map} +1 -1
  81. package/dist/{encryption-B6ilrT7p.mjs → encryption-D0ucY4O7.mjs} +3 -3
  82. package/dist/{encryption-B6ilrT7p.mjs.map → encryption-D0ucY4O7.mjs.map} +1 -1
  83. package/dist/{encryption-D7zmwzWz.cjs → encryption-Dp0IvLVX.cjs} +3 -3
  84. package/dist/{encryption-D7zmwzWz.cjs.map → encryption-Dp0IvLVX.cjs.map} +1 -1
  85. package/dist/{engine-DjEcovm-.mjs → engine-BcuhnyQO.mjs} +14 -31
  86. package/dist/{engine-DjEcovm-.mjs.map → engine-BcuhnyQO.mjs.map} +1 -1
  87. package/dist/{engine-Cfx8fEZU.cjs → engine-WY6j_kvA.cjs} +18 -35
  88. package/dist/engine-WY6j_kvA.cjs.map +1 -0
  89. package/dist/{github-CzBbs43W.mjs → github-DUGA57du.mjs} +96 -6
  90. package/dist/github-DUGA57du.mjs.map +1 -0
  91. package/dist/{github-zneTMvnO.cjs → github-DgmW83OP.cjs} +96 -6
  92. package/dist/github-DgmW83OP.cjs.map +1 -0
  93. package/dist/{index-BiYU7cUl.d.mts → index-5eL8rM6H.d.mts} +2 -2
  94. package/dist/{index-BiYU7cUl.d.mts.map → index-5eL8rM6H.d.mts.map} +1 -1
  95. package/dist/{index-Dm6V9bwh.d.cts → index-Dz-gyjm_.d.cts} +2 -2
  96. package/dist/{index-Dm6V9bwh.d.cts.map → index-Dz-gyjm_.d.cts.map} +1 -1
  97. package/dist/index.cjs +150 -118
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.mjs +144 -112
  100. package/dist/index.mjs.map +1 -1
  101. package/dist/{local-Otp74ak0.mjs → local-BwC2v2Y8.mjs} +2 -2
  102. package/dist/{local-Otp74ak0.mjs.map → local-BwC2v2Y8.mjs.map} +1 -1
  103. package/dist/{local-B61kUh0w.cjs → local-DNhnkugT.cjs} +3 -3
  104. package/dist/{local-B61kUh0w.cjs.map → local-DNhnkugT.cjs.map} +1 -1
  105. package/dist/{migrate-DFjbGnSr.cjs → migrate-BBcG1dhS.cjs} +3 -3
  106. package/dist/{migrate-DFjbGnSr.cjs.map → migrate-BBcG1dhS.cjs.map} +1 -1
  107. package/dist/{migrate-CsBZKALY.mjs → migrate-CZ-v5WV0.mjs} +3 -3
  108. package/dist/{migrate-CsBZKALY.mjs.map → migrate-CZ-v5WV0.mjs.map} +1 -1
  109. package/dist/{migrate-BaC4w0sb.mjs → migrate-D6PlNv2o.mjs} +3 -3
  110. package/dist/{migrate-BaC4w0sb.mjs.map → migrate-D6PlNv2o.mjs.map} +1 -1
  111. package/dist/{migrate-C8wTpakT.cjs → migrate-afgRL3Hg.cjs} +3 -3
  112. package/dist/{migrate-C8wTpakT.cjs.map → migrate-afgRL3Hg.cjs.map} +1 -1
  113. package/dist/openapi.cjs +1 -1
  114. package/dist/openapi.d.cts +1 -1
  115. package/dist/openapi.d.mts +1 -1
  116. package/dist/openapi.mjs +1 -1
  117. package/dist/reconcile/public.d.cts +2 -2
  118. package/dist/reconcile/public.d.mts +2 -2
  119. package/dist/{resolve-g8htuR80.cjs → resolve-CFb4Navi.cjs} +4 -4
  120. package/dist/{resolve-g8htuR80.cjs.map → resolve-CFb4Navi.cjs.map} +1 -1
  121. package/dist/{resolve-Ccjlpnd9.mjs → resolve-DakDhr6Z.mjs} +4 -4
  122. package/dist/{resolve-Ccjlpnd9.mjs.map → resolve-DakDhr6Z.mjs.map} +1 -1
  123. package/dist/{rollback--ympG9ss.cjs → rollback-B-1dPP0m.cjs} +9 -8
  124. package/dist/{rollback--ympG9ss.cjs.map → rollback-B-1dPP0m.cjs.map} +1 -1
  125. package/dist/{rollback-Drbg0OeR.mjs → rollback-B1TIpjdE.mjs} +7 -6
  126. package/dist/{rollback-Drbg0OeR.mjs.map → rollback-B1TIpjdE.mjs.map} +1 -1
  127. package/dist/run-BJLIerMM.mjs +133 -0
  128. package/dist/run-BJLIerMM.mjs.map +1 -0
  129. package/dist/run-fVZ-rLnc.cjs +174 -0
  130. package/dist/run-fVZ-rLnc.cjs.map +1 -0
  131. package/dist/{runtime-_wEVtshH.d.mts → runtime-DUQdM-mW.d.cts} +2 -2
  132. package/dist/{runtime-D_J3ExJn.d.cts.map → runtime-DUQdM-mW.d.cts.map} +1 -1
  133. package/dist/{runtime-D_J3ExJn.d.cts → runtime-Vr6mleo2.d.mts} +2 -2
  134. package/dist/{runtime-_wEVtshH.d.mts.map → runtime-Vr6mleo2.d.mts.map} +1 -1
  135. package/dist/{sandbox-CPJq1Kia.d.mts → sandbox-BbJmh2rI.d.cts} +2 -2
  136. package/dist/{sandbox-CPJq1Kia.d.mts.map → sandbox-BbJmh2rI.d.cts.map} +1 -1
  137. package/dist/{sandbox-JwuPAl7I.d.cts → sandbox-DGOsMPMf.d.mts} +2 -2
  138. package/dist/{sandbox-JwuPAl7I.d.cts.map → sandbox-DGOsMPMf.d.mts.map} +1 -1
  139. package/dist/{secrets-DJteijZo.cjs → secrets-CPM0Qffe.cjs} +3 -3
  140. package/dist/secrets-CPM0Qffe.cjs.map +1 -0
  141. package/dist/{secrets-DbPmAS4k.mjs → secrets-oI9ClAPR.mjs} +3 -3
  142. package/dist/secrets-oI9ClAPR.mjs.map +1 -0
  143. package/dist/{seeds-c-ByX9je.cjs → seeds-CnXkgKUv.cjs} +1339 -3594
  144. package/dist/seeds-CnXkgKUv.cjs.map +1 -0
  145. package/dist/{seeds-BSL55F6q.mjs → seeds-CoKkrSny.mjs} +1126 -3266
  146. package/dist/seeds-CoKkrSny.mjs.map +1 -0
  147. package/dist/{sniffer-BTtGAtm3.mjs → sniffer-CFRzIrby.mjs} +496 -5
  148. package/dist/sniffer-CFRzIrby.mjs.map +1 -0
  149. package/dist/{sniffer-Dq5BS98f.cjs → sniffer-vbiQ2Isn.cjs} +572 -3
  150. package/dist/sniffer-vbiQ2Isn.cjs.map +1 -0
  151. package/dist/{sst-BaRXp2Dd.mjs → sst-CGdjHn2A.mjs} +4 -3
  152. package/dist/{sst-BaRXp2Dd.mjs.map → sst-CGdjHn2A.mjs.map} +1 -1
  153. package/dist/{sst-CnKY-CSh.cjs → sst-DGuHDxVU.cjs} +5 -4
  154. package/dist/{sst-CnKY-CSh.cjs.map → sst-DGuHDxVU.cjs.map} +1 -1
  155. package/dist/{stack-1PeLJS2j.cjs → stack-1g57OfOw.cjs} +14 -52
  156. package/dist/stack-1g57OfOw.cjs.map +1 -0
  157. package/dist/{stack-Co4uZkAo.mjs → stack-B7O975TR.mjs} +14 -52
  158. package/dist/stack-B7O975TR.mjs.map +1 -0
  159. package/dist/{stages-DY-fQKmo.mjs → stages-Bt4OggMm.mjs} +17 -3
  160. package/dist/stages-Bt4OggMm.mjs.map +1 -0
  161. package/dist/{stages-BI8JvPzI.cjs → stages-BujUB4we.cjs} +17 -3
  162. package/dist/stages-BujUB4we.cjs.map +1 -0
  163. package/dist/target/public.cjs +1 -1
  164. package/dist/target/public.d.cts +2 -2
  165. package/dist/target/public.d.mts +2 -2
  166. package/dist/target/public.mjs +1 -1
  167. package/dist/{terminal-8XngdSTo.cjs → terminal-CPHuH4S1.cjs} +2 -2
  168. package/dist/{terminal-8XngdSTo.cjs.map → terminal-CPHuH4S1.cjs.map} +1 -1
  169. package/dist/{terminal-C4XRdwnU.mjs → terminal-iNmAXXjs.mjs} +2 -2
  170. package/dist/{terminal-C4XRdwnU.mjs.map → terminal-iNmAXXjs.mjs.map} +1 -1
  171. package/dist/{types-BibpiHKB.d.cts → types-bkqVscdN.d.mts} +43 -11
  172. package/dist/types-bkqVscdN.d.mts.map +1 -0
  173. package/dist/{types-B6lmD3en.d.mts → types-dipJRmKV.d.cts} +44 -10
  174. package/dist/types-dipJRmKV.d.cts.map +1 -0
  175. package/dist/workspace/index.cjs +1 -1
  176. package/dist/workspace/index.d.cts +2 -2
  177. package/dist/workspace/index.d.mts +2 -2
  178. package/dist/workspace/index.mjs +1 -1
  179. package/dist/{workspace-Bzw7Zs82.mjs → workspace-DWK1PTXP.mjs} +4 -4
  180. package/dist/workspace-DWK1PTXP.mjs.map +1 -0
  181. package/dist/{workspace-CHOB2Xg3.cjs → workspace-cSyi5nb1.cjs} +4 -4
  182. package/dist/workspace-cSyi5nb1.cjs.map +1 -0
  183. package/package.json +15 -15
  184. package/dist/HostingerProvider-C6t-PSNe.cjs.map +0 -1
  185. package/dist/add-CP1podDH.mjs.map +0 -1
  186. package/dist/add-VcyJnsPX.cjs.map +0 -1
  187. package/dist/cli-B8otnZfX.mjs.map +0 -1
  188. package/dist/cli-DL19w4OE.cjs.map +0 -1
  189. package/dist/compose-BHVKLluX.cjs.map +0 -1
  190. package/dist/compose-DrEB_4F-.mjs.map +0 -1
  191. package/dist/credentials-C4KII3PD.mjs.map +0 -1
  192. package/dist/credentials-QBu7VgaQ.cjs.map +0 -1
  193. package/dist/deploy-C3Mhnmus.cjs +0 -556
  194. package/dist/deploy-C3Mhnmus.cjs.map +0 -1
  195. package/dist/deploy-DYIyIUYd.mjs +0 -527
  196. package/dist/deploy-DYIyIUYd.mjs.map +0 -1
  197. package/dist/engine-Cfx8fEZU.cjs.map +0 -1
  198. package/dist/github-CzBbs43W.mjs.map +0 -1
  199. package/dist/github-zneTMvnO.cjs.map +0 -1
  200. package/dist/secrets-DJteijZo.cjs.map +0 -1
  201. package/dist/secrets-DbPmAS4k.mjs.map +0 -1
  202. package/dist/seeds-BSL55F6q.mjs.map +0 -1
  203. package/dist/seeds-c-ByX9je.cjs.map +0 -1
  204. package/dist/sniffer-BTtGAtm3.mjs.map +0 -1
  205. package/dist/sniffer-Dq5BS98f.cjs.map +0 -1
  206. package/dist/stack-1PeLJS2j.cjs.map +0 -1
  207. package/dist/stack-Co4uZkAo.mjs.map +0 -1
  208. package/dist/stages-BI8JvPzI.cjs.map +0 -1
  209. package/dist/stages-DY-fQKmo.mjs.map +0 -1
  210. package/dist/types-B6lmD3en.d.mts.map +0 -1
  211. package/dist/types-BibpiHKB.d.cts.map +0 -1
  212. package/dist/workspace-Bzw7Zs82.mjs.map +0 -1
  213. package/dist/workspace-CHOB2Xg3.cjs.map +0 -1
@@ -2,12 +2,14 @@ import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
3
3
  import { d as output, s as nodeWithTsx } from "./discover-qjFapetL.mjs";
4
4
  import { i as activeSandbox } from "./sandbox-CbVB7uOD.mjs";
5
- import { v as getPublicEnvPrefix } from "./workspace-Bzw7Zs82.mjs";
6
- import { t as LocalSandbox } from "./local-Otp74ak0.mjs";
5
+ import { v as getPublicEnvPrefix } from "./workspace-DWK1PTXP.mjs";
6
+ import { _ as isCi, f as dnsRecordResource, h as currentActor } from "./seeds-CoKkrSny.mjs";
7
+ import { t as LocalSandbox } from "./local-BwC2v2Y8.mjs";
7
8
  import { dirname, resolve } from "node:path";
8
9
  import { existsSync } from "node:fs";
10
+ import { hostname, userInfo } from "node:os";
9
11
  import { fileURLToPath } from "node:url";
10
- import { createCipheriv, createHash, randomBytes } from "node:crypto";
12
+ import { createCipheriv, createHash, randomBytes, randomUUID } from "node:crypto";
11
13
  //#region src/secrets/encryption.ts
12
14
  var encryption_exports = /* @__PURE__ */ __exportAll({
13
15
  encryptSecrets: () => encryptSecrets,
@@ -73,6 +75,495 @@ function eventError(error) {
73
75
  };
74
76
  }
75
77
  //#endregion
78
+ //#region src/deploy/StateProvider.ts
79
+ /**
80
+ * Check if value is a StateProvider implementation.
81
+ */
82
+ function isStateProvider(value) {
83
+ return typeof value === "object" && value !== null && typeof value.read === "function" && typeof value.write === "function";
84
+ }
85
+ var StateLocked = class extends GkmError {
86
+ stage;
87
+ holder;
88
+ location;
89
+ constructor(stage, holder, location) {
90
+ const by = holder ? `${holder.owner}@${holder.host} (pid ${holder.pid}) since ${holder.acquiredAt}${holder.operation ? ` for '${holder.operation}'` : ""}` : "a run that did not record who it was";
91
+ super(`Deploy state for stage '${stage}' is locked by ${by} (${location}). Wait for that run to finish; if it crashed, release the lock with \`gkm state:unlock --stage ${stage}\`.`);
92
+ this.stage = stage;
93
+ this.holder = holder;
94
+ this.location = location;
95
+ this.name = "StateLocked";
96
+ }
97
+ };
98
+ var StateVersionConflict = class extends GkmError {
99
+ stage;
100
+ expectedVersion;
101
+ actualVersion;
102
+ constructor(stage, expectedVersion, actualVersion) {
103
+ super(`Deploy state for stage '${stage}' changed since it was read (expected ${expectedVersion ? `version ${expectedVersion}` : "no state"}, found ${actualVersion ? `version ${actualVersion}` : "no state"}). Another run wrote it: read the state again and re-apply the change, and hold the stage's lock so runs take turns.`);
104
+ this.stage = stage;
105
+ this.expectedVersion = expectedVersion;
106
+ this.actualVersion = actualVersion;
107
+ this.name = "StateVersionConflict";
108
+ }
109
+ };
110
+ var StageStateMissing = class extends GkmError {
111
+ stage;
112
+ constructor(stage) {
113
+ super(`There is no deploy state for stage '${stage}' to record a resource in. Write the stage's state first (write with expectedVersion: null).`);
114
+ this.stage = stage;
115
+ this.name = "StageStateMissing";
116
+ }
117
+ };
118
+ var StateUnreadable = class extends GkmError {
119
+ stage;
120
+ location;
121
+ constructor(stage, location, cause) {
122
+ super(`Deploy state for stage '${stage}' at ${location} is not valid JSON. Restore it from a backup (or the provider's history) rather than deploying without it — a deploy without state recreates every resource.`, { cause });
123
+ this.stage = stage;
124
+ this.location = location;
125
+ this.name = "StateUnreadable";
126
+ }
127
+ };
128
+ var StateSchemaTooNew = class extends GkmError {
129
+ stage;
130
+ schemaVersion;
131
+ constructor(stage, schemaVersion) {
132
+ super(`Deploy state for stage '${stage}' has schema version ${String(schemaVersion)}, newer than this @geekmidas/cli understands (3). Upgrade @geekmidas/cli to the version that wrote it.`);
133
+ this.stage = stage;
134
+ this.schemaVersion = schemaVersion;
135
+ this.name = "StateSchemaTooNew";
136
+ }
137
+ };
138
+ /**
139
+ * Not thrown: emitted (once per store) when a custom `StateProvider` stands
140
+ * in for a store, so a deploy that cannot be protected from a concurrent one
141
+ * says so.
142
+ */
143
+ var StateStoreWithoutLocking = class extends GkmError {
144
+ provider;
145
+ constructor(provider) {
146
+ super(`The custom state provider '${provider}' has no lock and no versions, so two deploys of the same stage can still overwrite each other. Implement StateStore (lock, versioned read, conditional write) or use the 'local', 'ssm' or 's3' state provider.`);
147
+ this.provider = provider;
148
+ this.name = "StateStoreWithoutLocking";
149
+ }
150
+ };
151
+ var StateStoreNeedsWorkspaceName = class extends GkmError {
152
+ provider;
153
+ constructor(provider) {
154
+ super(`The '${provider}' state provider keys state by workspace name. Set "name" in gkm.config.ts.`);
155
+ this.provider = provider;
156
+ this.name = "StateStoreNeedsWorkspaceName";
157
+ }
158
+ };
159
+ var UnknownStateProvider = class extends GkmError {
160
+ config;
161
+ constructor(config) {
162
+ super(`Unknown state provider ${JSON.stringify(config)}. Use 'local', 'ssm', 's3', or an object implementing StateStore or StateProvider.`);
163
+ this.config = config;
164
+ this.name = "UnknownStateProvider";
165
+ }
166
+ };
167
+ /**
168
+ * A deploy, setup or rollback of a stage in CI, with the stage's state kept on
169
+ * the runner — which is discarded when the job ends.
170
+ */
171
+ var LocalStateInCi = class extends GkmError {
172
+ stage;
173
+ operation;
174
+ region;
175
+ constructor(stage, operation, region) {
176
+ super(`\`gkm ${operation}\` would keep stage '${stage}'s deploy state in .gkm/ on this CI runner, and the runner is discarded when the job ends: the next run would start without it — no releases to roll back to, no record of what was created. Keep the state in AWS — in gkm.config.ts:\n\n state: { provider: 'ssm', region: '${region}' },\n\nthen move the state you already have, from the machine that holds it:\n\n gkm state:push --stage ${stage}\n`);
177
+ this.stage = stage;
178
+ this.operation = operation;
179
+ this.region = region;
180
+ this.name = "LocalStateInCi";
181
+ }
182
+ };
183
+ /** A lock or write that could not get at the state backend in time. */
184
+ var StateStoreBusy = class extends GkmError {
185
+ stage;
186
+ location;
187
+ constructor(stage, location) {
188
+ super(`Timed out waiting to write deploy state for stage '${stage}' (${location}). If no other gkm process is running, remove ${location}.`);
189
+ this.stage = stage;
190
+ this.location = location;
191
+ this.name = "StateStoreBusy";
192
+ }
193
+ };
194
+ function decodeDocument(stage, body, location) {
195
+ let parsed;
196
+ try {
197
+ parsed = JSON.parse(body);
198
+ } catch (error) {
199
+ throw new StateUnreadable(stage, location, error);
200
+ }
201
+ if (typeof parsed !== "object" || parsed === null) throw new StateUnreadable(stage, location, parsed);
202
+ const schemaVersion = parsed.schemaVersion;
203
+ if (schemaVersion === void 0) return {
204
+ schemaVersion: 1,
205
+ state: parsed
206
+ };
207
+ if (schemaVersion === 2) return {
208
+ schemaVersion: 2,
209
+ document: parsed
210
+ };
211
+ if (schemaVersion === 3) return {
212
+ schemaVersion: 3,
213
+ document: parsed
214
+ };
215
+ throw new StateSchemaTooNew(stage, schemaVersion);
216
+ }
217
+ function encodeDocument(document) {
218
+ return JSON.stringify(document, null, 2);
219
+ }
220
+ /**
221
+ * v1 state as a v2 document. The ids v1 kept are seeded as `ready` records,
222
+ * so the first journaled deploy after an upgrade adopts them rather than
223
+ * treating them as unknown.
224
+ */
225
+ function migrateV1(stage, state) {
226
+ const now = (/* @__PURE__ */ new Date()).toISOString();
227
+ const resources = {};
228
+ const seed = (type, name, id) => {
229
+ if (!id) return;
230
+ const key = name ? `${type}:${name}` : type;
231
+ resources[key] = {
232
+ key,
233
+ type,
234
+ id,
235
+ status: "ready",
236
+ updatedAt: now
237
+ };
238
+ };
239
+ seed("project", null, state.projectId);
240
+ seed("environment", null, state.environmentId);
241
+ for (const [app, id] of Object.entries(state.applications ?? {})) seed("application", app, id);
242
+ seed("postgres", null, state.services?.postgresId);
243
+ seed("redis", null, state.services?.redisId);
244
+ seed("backup-destination", null, state.backups?.destinationId);
245
+ return {
246
+ schemaVersion: 2,
247
+ stage,
248
+ serial: 1,
249
+ state,
250
+ resources,
251
+ updatedAt: now
252
+ };
253
+ }
254
+ const isEmpty = (value) => !value || Object.keys(value).length === 0;
255
+ /**
256
+ * Whether a v2 state in the Dokploy shape was written by the compose target.
257
+ *
258
+ * Before v3 every target wrote the Dokploy shape, and compose filled none of
259
+ * its Dokploy fields. So the rule is the shape's content, not the target the
260
+ * workspace names now: a state whose every Dokploy-only field is empty — no
261
+ * project or environment id, no application or service ids, no credentials,
262
+ * generated secrets, backups or registry — holds nothing only Dokploy could
263
+ * use, and reading it as compose loses nothing. One with any of them was
264
+ * written by Dokploy and is kept exactly as it is.
265
+ *
266
+ * The configured target is not used: a document decodes the same wherever it
267
+ * is read (`state:show`, `state:push`) without a workspace, a stage can be
268
+ * moved between targets, and `--target` can override a run.
269
+ */
270
+ function writtenByCompose(state) {
271
+ return !state.projectId && !state.environmentId && isEmpty(state.applications) && !state.services?.postgresId && !state.services?.redisId && isEmpty(state.appCredentials) && isEmpty(state.generatedSecrets) && !state.backups && !state.registryId;
272
+ }
273
+ /**
274
+ * A v2 state and its records as v3 keeps them. A compose-written state
275
+ * becomes the compose shape: its `dnsRecords` become `dns-record` resources,
276
+ * and `dnsVerified` and the empty Dokploy fields go — the DNS check is made
277
+ * on every deploy. A Dokploy state is returned as it is.
278
+ */
279
+ function upgradeV2State(state, resources) {
280
+ if (!writtenByCompose(state)) return {
281
+ state,
282
+ resources
283
+ };
284
+ const compose = {
285
+ provider: "compose",
286
+ stage: state.stage,
287
+ lastDeployedAt: state.lastDeployedAt,
288
+ ...state.identity ? { identity: state.identity } : {},
289
+ ...state.releases ? { releases: state.releases } : {}
290
+ };
291
+ const upgraded = { ...resources };
292
+ for (const record of Object.values(state.dnsRecords ?? {})) {
293
+ const resource = migratedDnsResource(record);
294
+ upgraded[resource.key] = resource;
295
+ }
296
+ return {
297
+ state: compose,
298
+ resources: upgraded
299
+ };
300
+ }
301
+ /** A v2 `dnsRecords` entry as the `dns-record` resource v3 keeps. */
302
+ function migratedDnsResource(record) {
303
+ return {
304
+ ...dnsRecordResource({
305
+ domain: record.domain,
306
+ name: record.name,
307
+ type: record.type,
308
+ value: record.value,
309
+ ttl: record.ttl
310
+ }),
311
+ updatedAt: record.createdAt
312
+ };
313
+ }
314
+ /** A v2 document as v3 — not written until the next write. */
315
+ function migrateV2(document) {
316
+ const { state, resources } = upgradeV2State(document.state, document.resources);
317
+ return {
318
+ schemaVersion: 3,
319
+ stage: document.stage,
320
+ serial: document.serial,
321
+ state,
322
+ resources,
323
+ updatedAt: document.updatedAt,
324
+ history: []
325
+ };
326
+ }
327
+ function newLockHolder(options) {
328
+ let owner = "unknown";
329
+ try {
330
+ owner = userInfo().username;
331
+ } catch {}
332
+ return {
333
+ id: randomUUID(),
334
+ owner,
335
+ host: hostname(),
336
+ pid: process.pid,
337
+ acquiredAt: (/* @__PURE__ */ new Date()).toISOString(),
338
+ operation: options?.operation
339
+ };
340
+ }
341
+ function contentVersion(body) {
342
+ return createHash("sha256").update(body).digest("hex").slice(0, 16);
343
+ }
344
+ /**
345
+ * `history` with this write at its head. A run makes many writes — one per
346
+ * resource it journals — so a run is one entry: a write by the run that
347
+ * wrote the newest entry (the same lock) replaces it, and any other is
348
+ * added. Without a lock, each write is its own entry.
349
+ */
350
+ function appendHistory(history, entry, sameRun) {
351
+ return [entry, ...sameRun ? history.slice(1) : history].slice(0, 20);
352
+ }
353
+ /**
354
+ * A store over a backend that can read and conditionally write one blob per
355
+ * stage, and create a lock object only if it does not exist. Migration,
356
+ * resource records and history are the same for every such backend, so they
357
+ * live here.
358
+ */
359
+ var DocumentStateStore = class {
360
+ /** The lock this store holds for each stage — what its writes are for. */
361
+ held = /* @__PURE__ */ new Map();
362
+ /** Per stage, the lock whose run wrote the newest history entry. */
363
+ logged = /* @__PURE__ */ new Map();
364
+ /** Who this store writes as. */
365
+ actor() {
366
+ return currentActor();
367
+ }
368
+ async lock(stage, options) {
369
+ const holder = newLockHolder(options);
370
+ await this.createLock(stage, holder);
371
+ this.held.set(stage, holder);
372
+ let released = false;
373
+ return {
374
+ stage,
375
+ holder,
376
+ release: async () => {
377
+ if (released) return;
378
+ released = true;
379
+ if (this.held.get(stage)?.id === holder.id) this.held.delete(stage);
380
+ await this.removeLock(stage, holder);
381
+ }
382
+ };
383
+ }
384
+ async forceUnlock(stage) {
385
+ const holder = await this.readLock(stage);
386
+ await this.removeLock(stage, null);
387
+ return holder;
388
+ }
389
+ async read(stage) {
390
+ const current = await this.readDocument(stage);
391
+ if (!current) return null;
392
+ return {
393
+ state: current.document.state,
394
+ resources: current.document.resources,
395
+ history: current.document.history,
396
+ version: current.version
397
+ };
398
+ }
399
+ async write(stage, state, options) {
400
+ if (options.expectedVersion === null) {
401
+ const document = this.stamp(stage, {
402
+ schemaVersion: 3,
403
+ stage,
404
+ serial: 1,
405
+ state,
406
+ resources: {},
407
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
408
+ history: []
409
+ });
410
+ return this.writeRaw(stage, encodeDocument(document), null);
411
+ }
412
+ return this.mutate(stage, options.expectedVersion, (document) => ({
413
+ ...document,
414
+ state
415
+ }));
416
+ }
417
+ async putResource(stage, record, options) {
418
+ return this.mutate(stage, options?.expectedVersion, (document) => ({
419
+ ...document,
420
+ resources: {
421
+ ...document.resources,
422
+ [record.key]: {
423
+ ...record,
424
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
425
+ updatedBy: this.actor()
426
+ }
427
+ }
428
+ }));
429
+ }
430
+ async deleteResource(stage, key, options) {
431
+ return this.mutate(stage, options?.expectedVersion, (document) => {
432
+ const { [key]: _removed, ...resources } = document.resources;
433
+ return {
434
+ ...document,
435
+ resources
436
+ };
437
+ });
438
+ }
439
+ /** `document` as this write leaves it: who wrote it, in its history. */
440
+ stamp(stage, document) {
441
+ const by = this.actor();
442
+ const holder = this.held.get(stage);
443
+ const operation = holder?.operation ?? "write";
444
+ const history = document.history ?? [];
445
+ const sameRun = holder !== void 0 && this.logged.get(stage) === holder.id && history[0]?.operation === operation;
446
+ if (holder) this.logged.set(stage, holder.id);
447
+ return {
448
+ ...document,
449
+ updatedBy: by,
450
+ history: appendHistory(history, {
451
+ serial: document.serial,
452
+ at: document.updatedAt,
453
+ by,
454
+ operation
455
+ }, sameRun)
456
+ };
457
+ }
458
+ async mutate(stage, expectedVersion, change) {
459
+ const current = await this.readDocument(stage);
460
+ if (!current) {
461
+ if (expectedVersion !== void 0) throw new StateVersionConflict(stage, expectedVersion, null);
462
+ throw new StageStateMissing(stage);
463
+ }
464
+ if (expectedVersion !== void 0 && current.version !== expectedVersion) throw new StateVersionConflict(stage, expectedVersion, current.version);
465
+ const next = change(current.document);
466
+ next.schemaVersion = 3;
467
+ next.serial = current.document.serial + 1;
468
+ next.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
469
+ return this.writeRaw(stage, encodeDocument(this.stamp(stage, next)), current.version);
470
+ }
471
+ /**
472
+ * Reads the stage's document as v3. A v1 document is migrated in place on
473
+ * the way — itself a conditional write: if another run migrated (or wrote)
474
+ * first, its result is read instead. A v2 document is upgraded in memory
475
+ * and written as v3 by the next write.
476
+ */
477
+ async readDocument(stage, attempt = 0) {
478
+ const raw = await this.readRaw(stage);
479
+ if (!raw) return null;
480
+ const decoded = decodeDocument(stage, raw.body, this.location(stage));
481
+ if (decoded.schemaVersion === 3) return {
482
+ document: decoded.document,
483
+ version: raw.version
484
+ };
485
+ if (decoded.schemaVersion === 2) return {
486
+ document: migrateV2(decoded.document),
487
+ version: raw.version
488
+ };
489
+ await this.writeV1Backup(stage, raw.body);
490
+ const document = this.stamp(stage, migrateV2(migrateV1(stage, decoded.state)));
491
+ try {
492
+ return {
493
+ document,
494
+ version: await this.writeRaw(stage, encodeDocument(document), raw.version)
495
+ };
496
+ } catch (error) {
497
+ if (error instanceof StateVersionConflict && attempt < 2) return this.readDocument(stage, attempt + 1);
498
+ throw error;
499
+ }
500
+ }
501
+ };
502
+ /** Whether `config` keeps state on this machine — `local`, or none given. */
503
+ function isLocalState(config) {
504
+ return !config || config.provider === "local";
505
+ }
506
+ /**
507
+ * Refuses, with `LocalStateInCi`, a run that would write a deployed stage's
508
+ * state to a CI runner's disk — the local stage, which runs on the runner
509
+ * itself, is exempt. Local use is untouched. The region the message
510
+ * suggests is the secrets store's, when the workspace keeps them in AWS.
511
+ */
512
+ function assertStateOutlivesRun(workspace, stage, operation, env = process.env) {
513
+ if (stage === workspace.stages?.local) return;
514
+ if (!isCi(env) || !isLocalState(workspace.state)) return;
515
+ const store = workspace.secrets?.store;
516
+ throw new LocalStateInCi(stage, operation, typeof store === "object" && store && typeof store.region === "string" ? store.region : "<region>");
517
+ }
518
+ function isStateStore(value) {
519
+ return typeof value === "object" && value !== null && typeof value.lock === "function" && typeof value.read === "function" && typeof value.write === "function" && typeof value.putResource === "function";
520
+ }
521
+ /**
522
+ * The store for a workspace's `state` config:
523
+ *
524
+ * - none / `'local'`: `LocalStateStore` under `.gkm/`
525
+ * - `'ssm'`: `SSMStateStore`, with no local cache — SSM is read directly, so
526
+ * a stale local copy can never win over it
527
+ * - `'s3'`: `S3StateStore`
528
+ * - a `StateStore` object: used as is
529
+ * - a `StateProvider` object: wrapped by `LegacyStateStore`
530
+ */
531
+ async function createStateStore(options) {
532
+ const { config, workspaceRoot, workspaceName } = options;
533
+ if (!config || config.provider === "local") {
534
+ const { LocalStateStore } = await import("./LocalStateStore-YjIqlgAz.mjs").then((n) => n.n);
535
+ return new LocalStateStore(workspaceRoot);
536
+ }
537
+ if (isStateStore(config.provider)) return config.provider;
538
+ if (isStateProvider(config.provider)) {
539
+ const { LegacyStateStore } = await import("./LegacyStateStore-D5DarNA2.mjs");
540
+ return new LegacyStateStore(config.provider, { warn: options.warn });
541
+ }
542
+ if (config.provider === "ssm") {
543
+ if (!workspaceName) throw new StateStoreNeedsWorkspaceName("ssm");
544
+ const { SSMStateStore } = await import("./SSMStateStore-BhtM6jOh.mjs");
545
+ const ssm = config;
546
+ return SSMStateStore.create({
547
+ workspaceName,
548
+ region: ssm.region,
549
+ profile: ssm.profile
550
+ });
551
+ }
552
+ if (config.provider === "s3") {
553
+ if (!workspaceName) throw new StateStoreNeedsWorkspaceName("s3");
554
+ const { S3StateStore } = await import("./S3StateStore-CjTAVsWh.mjs");
555
+ const s3 = config;
556
+ return S3StateStore.create({
557
+ workspaceName,
558
+ bucket: s3.bucket,
559
+ prefix: s3.prefix,
560
+ region: s3.region,
561
+ profile: s3.profile
562
+ });
563
+ }
564
+ throw new UnknownStateProvider(config);
565
+ }
566
+ //#endregion
76
567
  //#region src/target/dokploy/dokploy-api.ts
77
568
  /**
78
569
  * Centralized Dokploy API client
@@ -1263,6 +1754,6 @@ async function sniffAllApps(apps, workspacePath, options = {}) {
1263
1754
  return results;
1264
1755
  }
1265
1756
  //#endregion
1266
- export { DeploymentTimedOut as a, dokploy_api_exports as c, encryption_exports as d, keyFingerprint as f, DeploymentFailed as i, eventError as l, sniffAppEnvironment as n, DokployApi as o, DEFAULT_DEPLOYMENT_TIMEOUT_MS as r, DokployApiError as s, sniffAllApps as t, encryptSecrets as u };
1757
+ export { encryptSecrets as C, eventError as S, keyFingerprint as T, assertStateOutlivesRun as _, DeploymentTimedOut as a, newLockHolder as b, dokploy_api_exports as c, StageStateMissing as d, StateLocked as f, appendHistory as g, StateVersionConflict as h, DeploymentFailed as i, DocumentStateStore as l, StateStoreWithoutLocking as m, sniffAppEnvironment as n, DokployApi as o, StateStoreBusy as p, DEFAULT_DEPLOYMENT_TIMEOUT_MS as r, DokployApiError as s, sniffAllApps as t, LocalStateInCi as u, contentVersion as v, encryption_exports as w, upgradeV2State as x, createStateStore as y };
1267
1758
 
1268
- //# sourceMappingURL=sniffer-BTtGAtm3.mjs.map
1759
+ //# sourceMappingURL=sniffer-CFRzIrby.mjs.map