@geekmidas/cli 10.0.0-alpha.140 → 10.0.0-alpha.142

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 (262) hide show
  1. package/dist/{EndpointGenerator-BMRL04ic.mjs → EndpointGenerator-CusLH-9S.mjs} +2 -2
  2. package/dist/{EndpointGenerator-BMRL04ic.mjs.map → EndpointGenerator-CusLH-9S.mjs.map} +1 -1
  3. package/dist/{EndpointGenerator-ePscnbwB.cjs → EndpointGenerator-DyLMYClE.cjs} +2 -2
  4. package/dist/{EndpointGenerator-ePscnbwB.cjs.map → EndpointGenerator-DyLMYClE.cjs.map} +1 -1
  5. package/dist/{GoDaddyProvider-BgY6mqoH.mjs → GoDaddyProvider-BIibcRG4.mjs} +2 -3
  6. package/dist/{GoDaddyProvider-BgY6mqoH.mjs.map → GoDaddyProvider-BIibcRG4.mjs.map} +1 -1
  7. package/dist/{GoDaddyProvider-C-rs22Zv.cjs → GoDaddyProvider-C7Zt4dVy.cjs} +5 -6
  8. package/dist/{GoDaddyProvider-C-rs22Zv.cjs.map → GoDaddyProvider-C7Zt4dVy.cjs.map} +1 -1
  9. package/dist/{HostingerProvider-DEqpvoiD.cjs → HostingerProvider-BVhFhzCW.cjs} +2 -2
  10. package/dist/{HostingerProvider-DEqpvoiD.cjs.map → HostingerProvider-BVhFhzCW.cjs.map} +1 -1
  11. package/dist/{HostingerProvider-CgMuKgO_.mjs → HostingerProvider-DSHpNBim.mjs} +2 -2
  12. package/dist/{HostingerProvider-CgMuKgO_.mjs.map → HostingerProvider-DSHpNBim.mjs.map} +1 -1
  13. package/dist/{LegacyStateStore-Dx65SWE9.mjs → LegacyStateStore-Bd2I3zz7.mjs} +3 -3
  14. package/dist/{LegacyStateStore-Dx65SWE9.mjs.map → LegacyStateStore-Bd2I3zz7.mjs.map} +1 -1
  15. package/dist/{LegacyStateStore-6xskEtld.cjs → LegacyStateStore-DzRGMFhs.cjs} +3 -3
  16. package/dist/{LegacyStateStore-6xskEtld.cjs.map → LegacyStateStore-DzRGMFhs.cjs.map} +1 -1
  17. package/dist/{LocalStateStore-DFtTtHty.cjs → LocalStateStore-Ci_tzIfp.cjs} +2 -2
  18. package/dist/{LocalStateStore-DFtTtHty.cjs.map → LocalStateStore-Ci_tzIfp.cjs.map} +1 -1
  19. package/dist/{LocalStateStore-Dto39TCx.mjs → LocalStateStore-CzNrVQd2.mjs} +2 -2
  20. package/dist/{LocalStateStore-Dto39TCx.mjs.map → LocalStateStore-CzNrVQd2.mjs.map} +1 -1
  21. package/dist/{OpenApiTsGenerator-B-PQLx8X.mjs → OpenApiTsGenerator-BTMuu1WS.mjs} +2 -2
  22. package/dist/{OpenApiTsGenerator-B-PQLx8X.mjs.map → OpenApiTsGenerator-BTMuu1WS.mjs.map} +1 -1
  23. package/dist/{OpenApiTsGenerator-BvacdbiG.cjs → OpenApiTsGenerator-CI-tceXV.cjs} +2 -2
  24. package/dist/{OpenApiTsGenerator-BvacdbiG.cjs.map → OpenApiTsGenerator-CI-tceXV.cjs.map} +1 -1
  25. package/dist/{S3StateStore-C01zMOYm.mjs → S3StateStore-DVtcCMEc.mjs} +4 -4
  26. package/dist/{S3StateStore-C01zMOYm.mjs.map → S3StateStore-DVtcCMEc.mjs.map} +1 -1
  27. package/dist/{S3StateStore-B-9ea-sX.cjs → S3StateStore-LrKb9lH7.cjs} +5 -5
  28. package/dist/{S3StateStore-B-9ea-sX.cjs.map → S3StateStore-LrKb9lH7.cjs.map} +1 -1
  29. package/dist/{SSMStateStore-k-4XM7mb.mjs → SSMStateStore-CNHYH6g7.mjs} +2 -2
  30. package/dist/{SSMStateStore-k-4XM7mb.mjs.map → SSMStateStore-CNHYH6g7.mjs.map} +1 -1
  31. package/dist/{SSMStateStore-CKArcPUh.cjs → SSMStateStore-CpkvL95K.cjs} +2 -2
  32. package/dist/{SSMStateStore-CKArcPUh.cjs.map → SSMStateStore-CpkvL95K.cjs.map} +1 -1
  33. package/dist/{SubscriberGenerator-DR4Y7ihK.cjs → SubscriberGenerator-BNJyPmXJ.cjs} +3 -3
  34. package/dist/{SubscriberGenerator-DR4Y7ihK.cjs.map → SubscriberGenerator-BNJyPmXJ.cjs.map} +1 -1
  35. package/dist/{SubscriberGenerator-DLPH-ynS.mjs → SubscriberGenerator-CzPrixYu.mjs} +3 -3
  36. package/dist/{SubscriberGenerator-DLPH-ynS.mjs.map → SubscriberGenerator-CzPrixYu.mjs.map} +1 -1
  37. package/dist/{add-BgzsYxUq.cjs → add-AlV6_ljM.cjs} +18 -17
  38. package/dist/{add-BgzsYxUq.cjs.map → add-AlV6_ljM.cjs.map} +1 -1
  39. package/dist/{add-CiIrpOb9.mjs → add-B51nMuUd.mjs} +8 -7
  40. package/dist/{add-CiIrpOb9.mjs.map → add-B51nMuUd.mjs.map} +1 -1
  41. package/dist/apps-C1KiJqth.mjs +4593 -0
  42. package/dist/apps-C1KiJqth.mjs.map +1 -0
  43. package/dist/apps-CPdR2pYw.cjs +5002 -0
  44. package/dist/apps-CPdR2pYw.cjs.map +1 -0
  45. package/dist/{bundler-DKxuDoVL.cjs → bundler-B-hw8rJi.cjs} +33 -9
  46. package/dist/bundler-B-hw8rJi.cjs.map +1 -0
  47. package/dist/{bundler-C4uMSy8e.mjs → bundler-DbIt3a6I.mjs} +34 -10
  48. package/dist/bundler-DbIt3a6I.mjs.map +1 -0
  49. package/dist/{cli-na0npMhC.cjs → cli-6eYxU_Q2.cjs} +4 -4
  50. package/dist/{cli-na0npMhC.cjs.map → cli-6eYxU_Q2.cjs.map} +1 -1
  51. package/dist/{cli-Bm2is6R_.mjs → cli-CmmrPCM_.mjs} +4 -4
  52. package/dist/{cli-Bm2is6R_.mjs.map → cli-CmmrPCM_.mjs.map} +1 -1
  53. package/dist/compose-B2dCLbrc.cjs +1895 -0
  54. package/dist/compose-B2dCLbrc.cjs.map +1 -0
  55. package/dist/{compose-CVatM7Cl.mjs → compose-DVARqEeR.mjs} +16 -1830
  56. package/dist/compose-DVARqEeR.mjs.map +1 -0
  57. package/dist/{compose-D8U9ygdm.cjs → compose-D_fNsrkx.cjs} +101 -1969
  58. package/dist/compose-D_fNsrkx.cjs.map +1 -0
  59. package/dist/compose-kOpW9Pa1.mjs +1554 -0
  60. package/dist/compose-kOpW9Pa1.mjs.map +1 -0
  61. package/dist/config-BKpzKP6W.mjs +659 -0
  62. package/dist/config-BKpzKP6W.mjs.map +1 -0
  63. package/dist/config-QAqAEgb0.cjs +772 -0
  64. package/dist/config-QAqAEgb0.cjs.map +1 -0
  65. package/dist/config.cjs +16 -419
  66. package/dist/config.mjs +2 -405
  67. package/dist/{credentialSchemas-DZ2Nh5li.cjs → credentialSchemas-BAklWDna.cjs} +4 -5
  68. package/dist/{credentialSchemas-DZ2Nh5li.cjs.map → credentialSchemas-BAklWDna.cjs.map} +1 -1
  69. package/dist/{credentialSchemas-DUCSYl9a.mjs → credentialSchemas-mz9QZTYh.mjs} +2 -3
  70. package/dist/{credentialSchemas-DUCSYl9a.mjs.map → credentialSchemas-mz9QZTYh.mjs.map} +1 -1
  71. package/dist/credentials-CIpa4Hgs.cjs +2336 -0
  72. package/dist/credentials-CIpa4Hgs.cjs.map +1 -0
  73. package/dist/credentials-CWa7hRXd.mjs +1851 -0
  74. package/dist/credentials-CWa7hRXd.mjs.map +1 -0
  75. package/dist/{databases-P824RTnx.cjs → databases-DawSdqBI.cjs} +2 -2
  76. package/dist/{databases-P824RTnx.cjs.map → databases-DawSdqBI.cjs.map} +1 -1
  77. package/dist/{databases-Db48ZIXL.mjs → databases-mzSUFBTw.mjs} +2 -2
  78. package/dist/{databases-Db48ZIXL.mjs.map → databases-mzSUFBTw.mjs.map} +1 -1
  79. package/dist/deploy/public.cjs +24 -24
  80. package/dist/deploy/public.cjs.map +1 -1
  81. package/dist/deploy/public.d.cts.map +1 -1
  82. package/dist/deploy/public.d.mts.map +1 -1
  83. package/dist/deploy/public.mjs +13 -13
  84. package/dist/{deploy-DrQB7ytj.cjs → deploy-CjJ447kd.cjs} +73 -72
  85. package/dist/{deploy-DrQB7ytj.cjs.map → deploy-CjJ447kd.cjs.map} +1 -1
  86. package/dist/{deploy-CDcO08Xz.mjs → deploy-DqJiCwI9.mjs} +16 -15
  87. package/dist/{deploy-CDcO08Xz.mjs.map → deploy-DqJiCwI9.mjs.map} +1 -1
  88. package/dist/{discover-yqeJ2Bx7.cjs → discover-CRywE7yc.cjs} +157 -6
  89. package/dist/discover-CRywE7yc.cjs.map +1 -0
  90. package/dist/{discover-B2m8ytyq.mjs → discover-DbDrCQ8h.mjs} +117 -8
  91. package/dist/discover-DbDrCQ8h.mjs.map +1 -0
  92. package/dist/docker-CCzFCus7.mjs +1407 -0
  93. package/dist/docker-CCzFCus7.mjs.map +1 -0
  94. package/dist/docker-DK4rmb0u.cjs +1514 -0
  95. package/dist/docker-DK4rmb0u.cjs.map +1 -0
  96. package/dist/{dokploy-k4_ZN8zN.mjs → dokploy-B5_Y5wf0.mjs} +2 -2
  97. package/dist/{dokploy-k4_ZN8zN.mjs.map → dokploy-B5_Y5wf0.mjs.map} +1 -1
  98. package/dist/{dokploy-BKjPDvSN.cjs → dokploy-EJKX2T7M.cjs} +2 -2
  99. package/dist/{dokploy-BKjPDvSN.cjs.map → dokploy-EJKX2T7M.cjs.map} +1 -1
  100. package/dist/{drivers-C47nm-wB.cjs → drivers-aM87NQJi.cjs} +4 -91
  101. package/dist/drivers-aM87NQJi.cjs.map +1 -0
  102. package/dist/{drivers-CDjpjakg.mjs → drivers-uxLBq3e3.mjs} +3 -60
  103. package/dist/drivers-uxLBq3e3.mjs.map +1 -0
  104. package/dist/{eas-Bg4dI6n2.cjs → eas-AqSay-vE.cjs} +6 -6
  105. package/dist/{eas-Bg4dI6n2.cjs.map → eas-AqSay-vE.cjs.map} +1 -1
  106. package/dist/{eas-B1wBvwPH.mjs → eas-BQlD6Z-u.mjs} +3 -3
  107. package/dist/{eas-B1wBvwPH.mjs.map → eas-BQlD6Z-u.mjs.map} +1 -1
  108. package/dist/{encryption-DL_y8t6V.cjs → encryption-B6_aL5d-.cjs} +6 -6
  109. package/dist/{encryption-DL_y8t6V.cjs.map → encryption-B6_aL5d-.cjs.map} +1 -1
  110. package/dist/{encryption-Bve0PVOo.mjs → encryption-Dlh5mcE1.mjs} +3 -3
  111. package/dist/{encryption-Bve0PVOo.mjs.map → encryption-Dlh5mcE1.mjs.map} +1 -1
  112. package/dist/{engine-BhR5lt_V.cjs → engine-BAkmPI2z.cjs} +99 -97
  113. package/dist/{engine-BhR5lt_V.cjs.map → engine-BAkmPI2z.cjs.map} +1 -1
  114. package/dist/{engine-HMLf20iZ.mjs → engine-D3P2P6RK.mjs} +12 -10
  115. package/dist/{engine-HMLf20iZ.mjs.map → engine-D3P2P6RK.mjs.map} +1 -1
  116. package/dist/{github-B2hJVl-n.cjs → github-DokGIXT-.cjs} +18 -17
  117. package/dist/{github-B2hJVl-n.cjs.map → github-DokGIXT-.cjs.map} +1 -1
  118. package/dist/{github-DKn9ACi2.mjs → github-STWxD6cu.mjs} +9 -8
  119. package/dist/{github-DKn9ACi2.mjs.map → github-STWxD6cu.mjs.map} +1 -1
  120. package/dist/{googlePlay-DtuN0-7D.cjs → googlePlay-DL0htRJD.cjs} +5 -5
  121. package/dist/{googlePlay-DtuN0-7D.cjs.map → googlePlay-DL0htRJD.cjs.map} +1 -1
  122. package/dist/{googlePlay-CWq7ND_X.mjs → googlePlay-uAyXzxlu.mjs} +5 -5
  123. package/dist/{googlePlay-CWq7ND_X.mjs.map → googlePlay-uAyXzxlu.mjs.map} +1 -1
  124. package/dist/index.cjs +196 -192
  125. package/dist/index.cjs.map +1 -1
  126. package/dist/index.mjs +70 -66
  127. package/dist/index.mjs.map +1 -1
  128. package/dist/{local-OPC9BCZt.cjs → local-C6ndR_Wx.cjs} +6 -6
  129. package/dist/{local-OPC9BCZt.cjs.map → local-C6ndR_Wx.cjs.map} +1 -1
  130. package/dist/{local-B7Zv1NoA.mjs → local-CC7rdmgg.mjs} +3 -3
  131. package/dist/{local-B7Zv1NoA.mjs.map → local-CC7rdmgg.mjs.map} +1 -1
  132. package/dist/{migrate-BLVZqHtN.cjs → migrate-BbJUJ4CY.cjs} +6 -6
  133. package/dist/{migrate-BLVZqHtN.cjs.map → migrate-BbJUJ4CY.cjs.map} +1 -1
  134. package/dist/{migrate-iUui7B4q.cjs → migrate-CMurhHuj.cjs} +15 -13
  135. package/dist/{migrate-iUui7B4q.cjs.map → migrate-CMurhHuj.cjs.map} +1 -1
  136. package/dist/{migrate-W0ruUNb9.mjs → migrate-D079sADO.mjs} +3 -3
  137. package/dist/{migrate-W0ruUNb9.mjs.map → migrate-D079sADO.mjs.map} +1 -1
  138. package/dist/{migrate-DCvD4RJW.mjs → migrate-D27h4H79.mjs} +7 -5
  139. package/dist/{migrate-DCvD4RJW.mjs.map → migrate-D27h4H79.mjs.map} +1 -1
  140. package/dist/notes-B655tUny.cjs +500 -0
  141. package/dist/notes-B655tUny.cjs.map +1 -0
  142. package/dist/notes-wPJlNUj7.mjs +399 -0
  143. package/dist/notes-wPJlNUj7.mjs.map +1 -0
  144. package/dist/openapi.cjs +4 -5
  145. package/dist/openapi.cjs.map +1 -1
  146. package/dist/openapi.mjs +3 -4
  147. package/dist/openapi.mjs.map +1 -1
  148. package/dist/{projectBucket-BBbQ1lHF.cjs → projectBucket-Bs8ftcgB.cjs} +2 -2
  149. package/dist/{projectBucket-BBbQ1lHF.cjs.map → projectBucket-Bs8ftcgB.cjs.map} +1 -1
  150. package/dist/{projectBucket-C_DN4WzF.mjs → projectBucket-XVxyvW1y.mjs} +2 -2
  151. package/dist/{projectBucket-C_DN4WzF.mjs.map → projectBucket-XVxyvW1y.mjs.map} +1 -1
  152. package/dist/{publish-CxIBBD3b.mjs → publish-B9BNIaf2.mjs} +2 -2
  153. package/dist/{publish-CxIBBD3b.mjs.map → publish-B9BNIaf2.mjs.map} +1 -1
  154. package/dist/{publish-CqvDA5ry.cjs → publish-Bwgb-1JN.cjs} +2 -2
  155. package/dist/{publish-CqvDA5ry.cjs.map → publish-Bwgb-1JN.cjs.map} +1 -1
  156. package/dist/{ready-DuU0FXSj.cjs → ready-BNh3zsSn.cjs} +6 -6
  157. package/dist/{ready-DuU0FXSj.cjs.map → ready-BNh3zsSn.cjs.map} +1 -1
  158. package/dist/{ready-CGqJ74Kt.mjs → ready-g25dcGzK.mjs} +6 -6
  159. package/dist/{ready-CGqJ74Kt.mjs.map → ready-g25dcGzK.mjs.map} +1 -1
  160. package/dist/reconcile/public.cjs +1 -1
  161. package/dist/reconcile/public.mjs +1 -1
  162. package/dist/{resolve-CMC0MI0Z.mjs → resolve-DheFxtmy.mjs} +4 -4
  163. package/dist/{resolve-CMC0MI0Z.mjs.map → resolve-DheFxtmy.mjs.map} +1 -1
  164. package/dist/{resolve-BEVVvi13.cjs → resolve-Dir9EjMu.cjs} +4 -4
  165. package/dist/{resolve-BEVVvi13.cjs.map → resolve-Dir9EjMu.cjs.map} +1 -1
  166. package/dist/{rollback-CZiQkukY.mjs → rollback-BWAB77F9.mjs} +8 -8
  167. package/dist/{rollback-CZiQkukY.mjs.map → rollback-BWAB77F9.mjs.map} +1 -1
  168. package/dist/{rollback-e0zGkaBx.cjs → rollback-CrtuUKqe.cjs} +11 -11
  169. package/dist/{rollback-e0zGkaBx.cjs.map → rollback-CrtuUKqe.cjs.map} +1 -1
  170. package/dist/{s3-BKnL6YGQ.cjs → s3-DKJfDHUQ.cjs} +2 -2
  171. package/dist/{s3-BKnL6YGQ.cjs.map → s3-DKJfDHUQ.cjs.map} +1 -1
  172. package/dist/{s3-DW7SLsb8.mjs → s3-DNp8U0Ea.mjs} +2 -2
  173. package/dist/{s3-DW7SLsb8.mjs.map → s3-DNp8U0Ea.mjs.map} +1 -1
  174. package/dist/sandbox/credentials-worker.cjs +3 -4
  175. package/dist/sandbox/credentials-worker.cjs.map +1 -1
  176. package/dist/sandbox/credentials-worker.mjs +2 -3
  177. package/dist/sandbox/credentials-worker.mjs.map +1 -1
  178. package/dist/sandbox/discover-worker.cjs +1 -1
  179. package/dist/sandbox/discover-worker.mjs +1 -1
  180. package/dist/sandbox/migrate-worker.cjs +3 -4
  181. package/dist/sandbox/migrate-worker.cjs.map +1 -1
  182. package/dist/sandbox/migrate-worker.mjs +2 -3
  183. package/dist/sandbox/migrate-worker.mjs.map +1 -1
  184. package/dist/seeds-B3xvUAQf.cjs +363 -0
  185. package/dist/seeds-B3xvUAQf.cjs.map +1 -0
  186. package/dist/seeds-BCC8vAXR.mjs +298 -0
  187. package/dist/seeds-BCC8vAXR.mjs.map +1 -0
  188. package/dist/{serverSetup-D2Xzsp2t.cjs → serverSetup-BVL9HhNE.cjs} +9 -8
  189. package/dist/{serverSetup-D2Xzsp2t.cjs.map → serverSetup-BVL9HhNE.cjs.map} +1 -1
  190. package/dist/{serverSetup-C3Tt9X1R.mjs → serverSetup-D---hcyW.mjs} +7 -6
  191. package/dist/{serverSetup-C3Tt9X1R.mjs.map → serverSetup-D---hcyW.mjs.map} +1 -1
  192. package/dist/{sniffer-BWgXPFAt.cjs → sniffer-BjHnOaCe.cjs} +9 -10
  193. package/dist/{sniffer-BWgXPFAt.cjs.map → sniffer-BjHnOaCe.cjs.map} +1 -1
  194. package/dist/{sniffer-eEF_fIId.mjs → sniffer-DOyzfgPF.mjs} +8 -9
  195. package/dist/{sniffer-eEF_fIId.mjs.map → sniffer-DOyzfgPF.mjs.map} +1 -1
  196. package/dist/{snsSubscriptions-BSoqUgsq.mjs → snsSubscriptions-Cf5DZfO5.mjs} +4 -453
  197. package/dist/snsSubscriptions-Cf5DZfO5.mjs.map +1 -0
  198. package/dist/{snsSubscriptions-Y9declDd.cjs → snsSubscriptions-DB0iRByH.cjs} +12 -559
  199. package/dist/snsSubscriptions-DB0iRByH.cjs.map +1 -0
  200. package/dist/{sst-Bz2HJlqc.mjs → sst-3V-rcKcw.mjs} +27 -5
  201. package/dist/sst-3V-rcKcw.mjs.map +1 -0
  202. package/dist/{sst-lvCHdYsY.cjs → sst-DuU7Ju0c.cjs} +29 -7
  203. package/dist/sst-DuU7Ju0c.cjs.map +1 -0
  204. package/dist/stack-BRKZ69bf.mjs +2307 -0
  205. package/dist/stack-BRKZ69bf.mjs.map +1 -0
  206. package/dist/stack-CmHjkg7D.cjs +2536 -0
  207. package/dist/stack-CmHjkg7D.cjs.map +1 -0
  208. package/dist/{stage-DhcbcAar.mjs → stage-CTq3Gjsx.mjs} +7 -7
  209. package/dist/{stage-DhcbcAar.mjs.map → stage-CTq3Gjsx.mjs.map} +1 -1
  210. package/dist/{stage-BEcxppsu.cjs → stage-s_8HOsH0.cjs} +13 -13
  211. package/dist/{stage-BEcxppsu.cjs.map → stage-s_8HOsH0.cjs.map} +1 -1
  212. package/dist/{stages--icWbhPy.cjs → stages-CFI0OiLj.cjs} +2 -2
  213. package/dist/{stages--icWbhPy.cjs.map → stages-CFI0OiLj.cjs.map} +1 -1
  214. package/dist/{stages-CUwSy39f.mjs → stages-DoYa81kN.mjs} +2 -2
  215. package/dist/{stages-CUwSy39f.mjs.map → stages-DoYa81kN.mjs.map} +1 -1
  216. package/dist/target/public.cjs +1 -1
  217. package/dist/target/public.mjs +1 -1
  218. package/dist/{terminal-DURcYlVX.cjs → terminal-ChxtuTYJ.cjs} +3 -3
  219. package/dist/{terminal-DURcYlVX.cjs.map → terminal-ChxtuTYJ.cjs.map} +1 -1
  220. package/dist/{terminal-yOZ7kKF9.mjs → terminal-oHKnZHkT.mjs} +3 -3
  221. package/dist/{terminal-yOZ7kKF9.mjs.map → terminal-oHKnZHkT.mjs.map} +1 -1
  222. package/dist/types-Bl_CwZC9.cjs +90 -0
  223. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  224. package/dist/types-Y1NfWlyG.mjs +61 -0
  225. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  226. package/dist/vitest.cjs +1 -1
  227. package/dist/vitest.mjs +1 -1
  228. package/package.json +15 -15
  229. package/dist/bundler-C4uMSy8e.mjs.map +0 -1
  230. package/dist/bundler-DKxuDoVL.cjs.map +0 -1
  231. package/dist/compose-CVatM7Cl.mjs.map +0 -1
  232. package/dist/compose-D8U9ygdm.cjs.map +0 -1
  233. package/dist/config.cjs.map +0 -1
  234. package/dist/config.mjs.map +0 -1
  235. package/dist/credentials-D7XJypNd.cjs +0 -520
  236. package/dist/credentials-D7XJypNd.cjs.map +0 -1
  237. package/dist/credentials-DpfnUvIR.mjs +0 -395
  238. package/dist/credentials-DpfnUvIR.mjs.map +0 -1
  239. package/dist/derive-Cd7Hl3r2.mjs +0 -259
  240. package/dist/derive-Cd7Hl3r2.mjs.map +0 -1
  241. package/dist/derive-CgZfoBU2.cjs +0 -282
  242. package/dist/derive-CgZfoBU2.cjs.map +0 -1
  243. package/dist/discover-B2m8ytyq.mjs.map +0 -1
  244. package/dist/discover-yqeJ2Bx7.cjs.map +0 -1
  245. package/dist/drivers-C47nm-wB.cjs.map +0 -1
  246. package/dist/drivers-CDjpjakg.mjs.map +0 -1
  247. package/dist/identity-CBXr4wNi.mjs +0 -129
  248. package/dist/identity-CBXr4wNi.mjs.map +0 -1
  249. package/dist/identity-CbLfgQNT.cjs +0 -182
  250. package/dist/identity-CbLfgQNT.cjs.map +0 -1
  251. package/dist/sandbox-CHv3OYXg.cjs +0 -165
  252. package/dist/sandbox-CHv3OYXg.cjs.map +0 -1
  253. package/dist/sandbox-CbVB7uOD.mjs +0 -118
  254. package/dist/sandbox-CbVB7uOD.mjs.map +0 -1
  255. package/dist/seeds-BR_7hJTw.cjs +0 -10541
  256. package/dist/seeds-BR_7hJTw.cjs.map +0 -1
  257. package/dist/seeds-nCxxlP5h.mjs +0 -9418
  258. package/dist/seeds-nCxxlP5h.mjs.map +0 -1
  259. package/dist/snsSubscriptions-BSoqUgsq.mjs.map +0 -1
  260. package/dist/snsSubscriptions-Y9declDd.cjs.map +0 -1
  261. package/dist/sst-Bz2HJlqc.mjs.map +0 -1
  262. package/dist/sst-lvCHdYsY.cjs.map +0 -1
@@ -0,0 +1,1851 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
3
+ import { ft as UnknownSecretsStoreProvider, mt as s3SecretsLocation, yt as isReservedStageKey } from "./workspace-BbfBFtjn.mjs";
4
+ import { g as appKey } from "./config-BKpzKP6W.mjs";
5
+ import { n as DEFAULT_EVENTS, r as DEFAULT_STORAGE, t as DEFAULT_CACHE } from "./types-Y1NfWlyG.mjs";
6
+ import { y as output } from "./discover-DbDrCQ8h.mjs";
7
+ import { c as runtimeOf } from "./resolve-DheFxtmy.mjs";
8
+ import { basename, dirname, join, resolve, sep } from "node:path";
9
+ import { constants, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync } from "node:fs";
10
+ import { chmod, copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
11
+ import { homedir } from "node:os";
12
+ import { spawn } from "node:child_process";
13
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
14
+ import { kebabCase, provideKey, scopedName } from "@geekmidas/manifest";
15
+ import { lookup } from "node:dns/promises";
16
+ //#region src/home.ts
17
+ /**
18
+ * Where the CLI keeps what belongs to a person rather than a project: stage
19
+ * keys and stored provider credentials.
20
+ *
21
+ * `GKM_HOME` names it, so a CI job, a shared build runner or a test can give
22
+ * every run its own instead of reaching into whoever's home directory the
23
+ * process happens to have. Unset, it is `~/.gkm`, where it has always been.
24
+ */
25
+ /** The environment variable that moves the CLI's home. */
26
+ const GKM_HOME_ENV = "GKM_HOME";
27
+ /** The CLI's home: `GKM_HOME` if set, else `~/.gkm`. */
28
+ function gkmHome(env = process.env) {
29
+ const configured = env[GKM_HOME_ENV];
30
+ return configured ? resolve(configured) : join(homedir(), ".gkm");
31
+ }
32
+ //#endregion
33
+ //#region src/auth/credentials.ts
34
+ /**
35
+ * Get the path to the credentials directory
36
+ */
37
+ function getCredentialsDir(options) {
38
+ if (options?.home) return options.home;
39
+ return options?.root ? join(options.root, ".gkm") : gkmHome();
40
+ }
41
+ /**
42
+ * Get the path to the credentials file
43
+ */
44
+ function getCredentialsPath(options) {
45
+ return join(getCredentialsDir(options), "credentials.json");
46
+ }
47
+ /**
48
+ * Ensure the credentials directory exists
49
+ */
50
+ function ensureCredentialsDir(options) {
51
+ const dir = getCredentialsDir(options);
52
+ if (!existsSync(dir)) mkdirSync(dir, {
53
+ recursive: true,
54
+ mode: 448
55
+ });
56
+ }
57
+ /**
58
+ * Read stored credentials from disk
59
+ */
60
+ async function readCredentials(options) {
61
+ const path = getCredentialsPath(options);
62
+ if (!existsSync(path)) return {};
63
+ try {
64
+ const content = await readFile(path, "utf-8");
65
+ return JSON.parse(content);
66
+ } catch {
67
+ return {};
68
+ }
69
+ }
70
+ /**
71
+ * Write credentials to disk
72
+ */
73
+ async function writeCredentials(credentials, options) {
74
+ ensureCredentialsDir(options);
75
+ const path = getCredentialsPath(options);
76
+ await writeFile(path, JSON.stringify(credentials, null, 2), { mode: 384 });
77
+ }
78
+ /**
79
+ * Store Dokploy credentials
80
+ */
81
+ async function storeDokployCredentials(token, endpoint, options) {
82
+ const credentials = await readCredentials(options);
83
+ credentials.dokploy = {
84
+ token,
85
+ endpoint,
86
+ storedAt: (/* @__PURE__ */ new Date()).toISOString()
87
+ };
88
+ await writeCredentials(credentials, options);
89
+ }
90
+ /**
91
+ * Get stored Dokploy credentials
92
+ */
93
+ async function getDokployCredentials(options) {
94
+ const credentials = await readCredentials(options);
95
+ const token = process.env.DOKPLOY_API_TOKEN ?? credentials.dokploy?.token;
96
+ const endpoint = process.env.DOKPLOY_ENDPOINT ?? credentials.dokploy?.endpoint;
97
+ if (!token || !endpoint) return null;
98
+ return {
99
+ token,
100
+ endpoint: endpoint.replace(/\/$/, ""),
101
+ ...credentials.dokploy?.registryId ? { registryId: credentials.dokploy.registryId } : {}
102
+ };
103
+ }
104
+ /**
105
+ * Remove Dokploy credentials
106
+ */
107
+ async function removeDokployCredentials(options) {
108
+ const credentials = await readCredentials(options);
109
+ if (!credentials.dokploy) return false;
110
+ delete credentials.dokploy;
111
+ await writeCredentials(credentials, options);
112
+ return true;
113
+ }
114
+ /**
115
+ * Get Dokploy API token, checking stored credentials first, then environment
116
+ */
117
+ async function getDokployToken(options) {
118
+ const envToken = process.env.DOKPLOY_API_TOKEN;
119
+ if (envToken) return envToken;
120
+ const stored = await getDokployCredentials(options);
121
+ if (stored) return stored.token;
122
+ return null;
123
+ }
124
+ /**
125
+ * Get Dokploy registry ID from stored credentials
126
+ */
127
+ async function getDokployRegistryId(options) {
128
+ return (await getDokployCredentials(options))?.registryId ?? void 0;
129
+ }
130
+ /**
131
+ * Store Hostinger API token
132
+ *
133
+ * @param token - API token from hpanel.hostinger.com/profile/api
134
+ */
135
+ async function storeHostingerToken(token, options) {
136
+ const credentials = await readCredentials(options);
137
+ credentials.hostinger = {
138
+ token,
139
+ storedAt: (/* @__PURE__ */ new Date()).toISOString()
140
+ };
141
+ await writeCredentials(credentials, options);
142
+ }
143
+ /**
144
+ * Get stored Hostinger API token
145
+ *
146
+ * Checks environment variable first (HOSTINGER_API_TOKEN),
147
+ * then falls back to stored credentials.
148
+ */
149
+ async function getHostingerToken(options) {
150
+ const envToken = process.env.HOSTINGER_API_TOKEN;
151
+ if (envToken) return envToken;
152
+ return (await readCredentials(options)).hostinger?.token ?? null;
153
+ }
154
+ /**
155
+ * Store a GoDaddy Personal Access Token.
156
+ */
157
+ async function storeGoDaddyToken(token, options) {
158
+ const credentials = await readCredentials(options);
159
+ credentials.godaddy = {
160
+ token,
161
+ storedAt: (/* @__PURE__ */ new Date()).toISOString()
162
+ };
163
+ await writeCredentials(credentials, options);
164
+ }
165
+ /**
166
+ * Remove GoDaddy credentials
167
+ */
168
+ async function removeGoDaddyCredentials(options) {
169
+ const credentials = await readCredentials(options);
170
+ if (!credentials.godaddy) return false;
171
+ delete credentials.godaddy;
172
+ await writeCredentials(credentials, options);
173
+ return true;
174
+ }
175
+ //#endregion
176
+ //#region src/run.ts
177
+ /**
178
+ * Start a program with an argument array, never a shell string.
179
+ *
180
+ * `gkm build`, `gkm docker` and `gkm deploy` pass values that come from the
181
+ * workspace — image refs, tags, build args, package names — to `docker` and
182
+ * `turbo`. Joined into a string and handed to a shell, a package named
183
+ * `x;curl …|sh` or a tag holding `$(…)` became part of the command line, which
184
+ * matters most where the CLI builds a repository it didn't write: a CI job for a
185
+ * fork, a shared build runner. Here every value reaches the program as one
186
+ * `argv` element, whatever it contains.
187
+ */
188
+ /** Long enough for a cold image build; short enough that a hung one ends. */
189
+ const DEFAULT_TIMEOUT_MS = 18e5;
190
+ /** How long a timed-out child has to exit on SIGTERM before it is killed. */
191
+ const KILL_GRACE_MS = 5e3;
192
+ /** The command line as a person would read it — for messages, never to run. */
193
+ function display(command, args) {
194
+ return [command, ...args].join(" ");
195
+ }
196
+ /** The program ran and exited unsuccessfully; its own output said why. */
197
+ var CommandFailed = class extends Error {
198
+ command;
199
+ args;
200
+ exitCode;
201
+ signal;
202
+ constructor(command, args, exitCode, signal) {
203
+ super(`\`${display(command, args)}\` ${exitCode === null ? `was stopped by ${signal ?? "a signal"}` : `exited with code ${exitCode}`}. Its output above says why; run it by hand to see it again.`);
204
+ this.command = command;
205
+ this.args = args;
206
+ this.exitCode = exitCode;
207
+ this.signal = signal;
208
+ this.name = "CommandFailed";
209
+ }
210
+ };
211
+ /** The program ran past its timeout and was killed. */
212
+ var CommandTimedOut = class extends Error {
213
+ command;
214
+ args;
215
+ timeoutMs;
216
+ constructor(command, args, timeoutMs) {
217
+ super(`\`${display(command, args)}\` was still running after ${Math.round(timeoutMs / 1e3)}s and was stopped. Check what it was waiting on — a registry, the Docker daemon, a prompt — and run it again.`);
218
+ this.command = command;
219
+ this.args = args;
220
+ this.timeoutMs = timeoutMs;
221
+ this.name = "CommandTimedOut";
222
+ }
223
+ };
224
+ /**
225
+ * Run `command` with `args`, resolving when it exits 0.
226
+ *
227
+ * Rejects with {@link CommandFailed} on any other exit, {@link CommandTimedOut}
228
+ * once `timeoutMs` passes (after the child is gone), and with the spawn error
229
+ * itself when the program cannot be started at all — `ENOENT` already names it.
230
+ */
231
+ async function run(command, args, options = {}) {
232
+ await spawnChild(command, args, options, false);
233
+ }
234
+ /**
235
+ * {@link run}, resolving with what the program wrote to stdout — for a value
236
+ * the CLI reads back, such as the digest `docker inspect` reports. stderr still
237
+ * reaches the terminal, so a failure explains itself the same way.
238
+ */
239
+ function runOutput(command, args, options = {}) {
240
+ return spawnChild(command, args, options, true);
241
+ }
242
+ function spawnChild(command, args, options, capture) {
243
+ const { timeoutMs = DEFAULT_TIMEOUT_MS, ...spawnOptions } = options;
244
+ return new Promise((resolve, reject) => {
245
+ const child = spawn(command, [...args], {
246
+ stdio: "inherit",
247
+ ...spawnOptions,
248
+ ...capture ? { stdio: [
249
+ "ignore",
250
+ "pipe",
251
+ "inherit"
252
+ ] } : {},
253
+ shell: false
254
+ });
255
+ let stdout = "";
256
+ child.stdout?.on("data", (chunk) => {
257
+ stdout += chunk.toString();
258
+ });
259
+ let timedOut = false;
260
+ let killer;
261
+ const timer = setTimeout(() => {
262
+ timedOut = true;
263
+ child.kill("SIGTERM");
264
+ killer = setTimeout(() => child.kill("SIGKILL"), KILL_GRACE_MS);
265
+ killer.unref?.();
266
+ }, timeoutMs);
267
+ timer.unref?.();
268
+ const settle = () => {
269
+ clearTimeout(timer);
270
+ if (killer) clearTimeout(killer);
271
+ };
272
+ child.on("error", (error) => {
273
+ settle();
274
+ reject(spawnOptions.signal?.aborted ? spawnOptions.signal.reason : error);
275
+ });
276
+ child.on("close", (code, signal) => {
277
+ settle();
278
+ if (spawnOptions.signal?.aborted) reject(spawnOptions.signal.reason);
279
+ else if (timedOut) reject(new CommandTimedOut(command, args, timeoutMs));
280
+ else if (code === 0) resolve(stdout);
281
+ else reject(new CommandFailed(command, args, code, signal));
282
+ });
283
+ });
284
+ }
285
+ //#endregion
286
+ //#region src/deploy/identity.ts
287
+ /**
288
+ * Who a deploy is, on a target it shares with other workspaces.
289
+ *
290
+ * A Dokploy server is one flat namespace of projects, images and Docker
291
+ * service names. Deploys used to identify everything they made by the
292
+ * workspace name alone, so two workspaces called `shop` — or `Shop` and
293
+ * `shop` — deploying to one server landed in the same project, pushed over
294
+ * each other's images and redeployed each other's applications. A
295
+ * `DeployIdentity` is what a deploy names and claims its resources by instead.
296
+ */
297
+ var identity_exports = /* @__PURE__ */ __exportAll({
298
+ DeployNamespaceInvalid: () => DeployNamespaceInvalid,
299
+ DeployProjectNameInvalid: () => DeployProjectNameInvalid,
300
+ applicationName: () => applicationName,
301
+ defaultNamespace: () => defaultNamespace,
302
+ deployIdentity: () => deployIdentity,
303
+ imageName: () => imageName,
304
+ imageRef: () => imageRef,
305
+ isOwnedBy: () => isOwnedBy,
306
+ markerOf: () => markerOf,
307
+ ownershipMarker: () => ownershipMarker,
308
+ projectName: () => projectName
309
+ });
310
+ /** A namespace that cannot be part of a Dokploy name or an image path. */
311
+ var DeployNamespaceInvalid = class extends GkmError {
312
+ namespace;
313
+ constructor(namespace) {
314
+ super(`deploy.namespace '${namespace}' is not usable as a name: use lowercase letters, digits and single '-' between them (e.g. 'acme' or 'acme-platform') in gkm.config.ts.`);
315
+ this.namespace = namespace;
316
+ this.name = "DeployNamespaceInvalid";
317
+ }
318
+ };
319
+ /** A workspace name with nothing a target can name a resource by. */
320
+ var DeployProjectNameInvalid = class extends GkmError {
321
+ workspaceName;
322
+ constructor(workspaceName) {
323
+ super(`The workspace name '${workspaceName}' has no letters or digits to name deployed resources by. Set "name" in gkm.config.ts.`);
324
+ this.workspaceName = workspaceName;
325
+ this.name = "DeployProjectNameInvalid";
326
+ }
327
+ };
328
+ const NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
329
+ /**
330
+ * Lowercase `[a-z0-9-]`, runs of anything else collapsed to one `-`: valid as
331
+ * a Docker image path component, a Docker service name and a Dokploy name.
332
+ */
333
+ function slug(value) {
334
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
335
+ }
336
+ /** The namespace a workspace is in when it does not name one. */
337
+ function defaultNamespace(workspaceName) {
338
+ return slug(kebabCase(workspaceName));
339
+ }
340
+ function deployIdentity(workspace, stage) {
341
+ const project = slug(workspace.name);
342
+ if (!project) throw new DeployProjectNameInvalid(workspace.name);
343
+ const fallback = defaultNamespace(workspace.name);
344
+ const namespace = workspace.deploy?.namespace ?? fallback;
345
+ if (!NAME.test(namespace)) throw new DeployNamespaceInvalid(namespace);
346
+ return {
347
+ namespace,
348
+ project,
349
+ stage,
350
+ key: `${namespace}/${project}`,
351
+ scope: namespace === fallback ? project : `${namespace}-${project}`
352
+ };
353
+ }
354
+ /**
355
+ * The token a Dokploy project's description carries to say which identity
356
+ * created it. A project with the right name and no marker belongs to someone
357
+ * else, and a deploy never adopts it.
358
+ */
359
+ function ownershipMarker(identity) {
360
+ return `gkm:${identity.key}`;
361
+ }
362
+ /** Whether a project description carries `identity`'s marker. */
363
+ function isOwnedBy(description, identity) {
364
+ const marker = ownershipMarker(identity);
365
+ return (description ?? "").split(/\s+/).includes(marker);
366
+ }
367
+ /** Any `gkm:` marker a description carries — whoever's it is. */
368
+ function markerOf(description) {
369
+ return (description ?? "").split(/\s+/).find((t) => t.startsWith("gkm:"));
370
+ }
371
+ /** What the Dokploy project is called. */
372
+ function projectName(identity) {
373
+ return identity.scope;
374
+ }
375
+ /**
376
+ * The repository an app's image is pushed to, below the registry:
377
+ * `<namespace>/<project>-<app>`.
378
+ *
379
+ * The namespace is a path segment of its own so that a registry that maps
380
+ * paths to owners (an organisation's packages, a Harbor project) can grant it
381
+ * as one; the app is joined to the project so the two read as one name.
382
+ */
383
+ function imageName(identity, app) {
384
+ return `${identity.namespace}/${identity.project}-${slug(kebabCase(app))}`;
385
+ }
386
+ /** The full image ref an app is built, pushed and deployed as. */
387
+ function imageRef(identity, app, registry, tag) {
388
+ const name = imageName(identity, app);
389
+ return registry ? `${registry.replace(/\/+$/, "")}/${name}:${tag}` : `${name}:${tag}`;
390
+ }
391
+ /**
392
+ * What one application is called on the target.
393
+ *
394
+ * The same rule the constructs use, through the same `scopedName`, scoped by
395
+ * the stage and the identity: the application beside
396
+ * `production-kitchen-sink-database` is `production-kitchen-sink-api`. A
397
+ * Dokploy application's name is also its Docker service name, which is unique
398
+ * on the whole server, so the namespace has to be in it too — `acme`'s and
399
+ * `globex`'s `shop` would otherwise both run `production-shop-api`.
400
+ *
401
+ * The app id is dropped when it repeats the project, so a project named for its
402
+ * one application is `production-kitchen-sink` rather than
403
+ * `production-kitchen-sink-kitchen-sink`.
404
+ */
405
+ function applicationName(identity, app) {
406
+ return slug(app) === identity.project ? `${identity.stage}-${identity.scope}` : scopedName([identity.stage, identity.scope], app);
407
+ }
408
+ //#endregion
409
+ //#region src/secrets/keystore.ts
410
+ /**
411
+ * The keys that open each stage's encrypted secrets file, kept outside the
412
+ * project in the CLI's home.
413
+ *
414
+ * Keys were kept at `~/.gkm/<folder>/<stage>.key`, named after the project
415
+ * directory — so two checkouts in folders with the same name (`~/work/api`
416
+ * and `~/oss/api`) shared one key, and the second `gkm secrets:init`
417
+ * overwrote the first project's. They are now kept under the project's
418
+ * identity, `<home>/keys/<namespace>/<project>/<stage>.key`, the same
419
+ * `<namespace>/<project>` a deploy claims its Dokploy project by. A key still
420
+ * at the old place is copied to the new one the first time it is read; the
421
+ * old file stays, so an older CLI on the same machine keeps working.
422
+ */
423
+ /** Key length for AES-256 encryption */
424
+ const KEY_LENGTH = 32;
425
+ /** A keystore project key that is not `<namespace>/<project>`. */
426
+ var KeystoreProjectInvalid = class extends GkmError {
427
+ key;
428
+ constructor(key) {
429
+ super(`'${key}' is not a keystore project: expected '<namespace>/<project>' in lowercase letters, digits and '-', as deployIdentity() produces. Pass the workspace's identity key.`);
430
+ this.key = key;
431
+ this.name = "KeystoreProjectInvalid";
432
+ }
433
+ };
434
+ /** A stage has no key, here or at the place keys used to be kept. */
435
+ var KeyNotFound = class extends GkmError {
436
+ stage;
437
+ project;
438
+ path;
439
+ constructor(stage, project, path) {
440
+ super(`Encryption key not found for stage "${stage}" in project "${project}". Expected key at: ${path}. Run \`gkm secrets:init --stage ${stage}\` to create one, or copy the stage's key there.`);
441
+ this.stage = stage;
442
+ this.project = project;
443
+ this.path = path;
444
+ this.name = "KeyNotFound";
445
+ }
446
+ };
447
+ const PROJECT_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
448
+ /**
449
+ * The keystore key of a workspace: its deploy identity without the stage, so
450
+ * a project's keys and its Dokploy project are named by the same thing.
451
+ */
452
+ function projectKey(workspace) {
453
+ return deployIdentity(workspace, "").key;
454
+ }
455
+ /** The keystore project of a loaded workspace. */
456
+ function keystoreProject(workspace, home) {
457
+ const key = projectKey(workspace);
458
+ const unscoped = projectKey({ name: workspace.name });
459
+ return {
460
+ key,
461
+ legacy: [.../* @__PURE__ */ new Set([folderName(workspace.root), workspace.name])].filter((name) => !!name),
462
+ ...unscoped !== key ? { aliases: [unscoped] } : {},
463
+ ...home ? { home } : {}
464
+ };
465
+ }
466
+ /**
467
+ * Whether `name` stays inside the home it is joined to. A workspace name was
468
+ * joined as is — `@acme/shop` is `~/.gkm/@acme/shop` — but never upwards.
469
+ */
470
+ function isLegacyName(name) {
471
+ return name.split(/[\\/]/).every((part) => part !== ".." && part !== "");
472
+ }
473
+ /** The last segment of a path, as the old keystore named projects. */
474
+ function folderName(path) {
475
+ const name = path.split(/[\\/]/).filter(Boolean).at(-1);
476
+ return name && name !== "." && name !== ".." ? name : void 0;
477
+ }
478
+ /**
479
+ * Get the keystore directory for a project:
480
+ * `<home>/keys/<namespace>/<project>`.
481
+ */
482
+ function getKeystoreDir(project) {
483
+ if (!PROJECT_KEY.test(project.key)) throw new KeystoreProjectInvalid(project.key);
484
+ const [namespace, name] = project.key.split("/");
485
+ return join(project.home ?? gkmHome(), "keys", namespace, name);
486
+ }
487
+ /** Get the path to a stage's encryption key. */
488
+ function getKeyPath(stage, project) {
489
+ return join(getKeystoreDir(project), `${stage}.key`);
490
+ }
491
+ /**
492
+ * Where else a stage's key may be, most likely first: under an alias of the
493
+ * project, then where keys were kept before they were keyed by identity —
494
+ * under the configured home, then under `~/.gkm`, which is where every CLI
495
+ * before `GKM_HOME` wrote.
496
+ */
497
+ function legacyKeyPaths(stage, project) {
498
+ const aliases = (project.aliases ?? []).map((key) => getKeyPath(stage, {
499
+ key,
500
+ home: project.home
501
+ }));
502
+ const homes = [.../* @__PURE__ */ new Set([project.home ?? gkmHome(), join(homedir(), ".gkm")])];
503
+ const names = (project.legacy ?? []).filter(isLegacyName);
504
+ return [...aliases, ...names.flatMap((name) => homes.map((home) => join(home, name, `${stage}.key`)))];
505
+ }
506
+ /**
507
+ * Generate a new encryption key for a stage, stored owner-only at
508
+ * `<home>/keys/<namespace>/<project>/<stage>.key`.
509
+ */
510
+ async function generateKey(stage, project, flag = "w") {
511
+ const keyDir = getKeystoreDir(project);
512
+ const keyPath = getKeyPath(stage, project);
513
+ await mkdir(keyDir, {
514
+ recursive: true,
515
+ mode: 448
516
+ });
517
+ const key = randomBytes(KEY_LENGTH).toString("hex");
518
+ await writeFile(keyPath, key, {
519
+ mode: 384,
520
+ encoding: "utf-8",
521
+ flag
522
+ });
523
+ await chmod(keyPath, 384);
524
+ return key;
525
+ }
526
+ /**
527
+ * Copy a key from where it used to be kept to where it is kept now.
528
+ *
529
+ * Copied, not moved: an older CLI on the same machine still reads the old
530
+ * place. Exclusive, so two processes migrating at once cannot overwrite a key
531
+ * one of them already put there.
532
+ */
533
+ async function migrateLegacyKey(stage, project) {
534
+ const legacy = legacyKeyPaths(stage, project).find((path) => existsSync(path));
535
+ if (!legacy) return false;
536
+ const keyPath = getKeyPath(stage, project);
537
+ await mkdir(getKeystoreDir(project), {
538
+ recursive: true,
539
+ mode: 448
540
+ });
541
+ try {
542
+ await copyFile(legacy, keyPath, constants.COPYFILE_EXCL);
543
+ } catch (error) {
544
+ if (error.code !== "EEXIST") throw error;
545
+ }
546
+ await chmod(keyPath, 384);
547
+ return true;
548
+ }
549
+ /**
550
+ * Read an encryption key for a stage, or `null` when there is none — after
551
+ * copying it over from where keys used to be kept, if it is still there.
552
+ */
553
+ async function readKey(stage, project) {
554
+ const keyPath = getKeyPath(stage, project);
555
+ if (!existsSync(keyPath) && !await migrateLegacyKey(stage, project)) return null;
556
+ return (await readFile(keyPath, "utf-8")).trim();
557
+ }
558
+ /**
559
+ * Read an encryption key for a stage, throwing {@link KeyNotFound} if there
560
+ * is none.
561
+ */
562
+ async function requireKey(stage, project) {
563
+ const key = await readKey(stage, project);
564
+ if (!key) throw new KeyNotFound(stage, project.key, getKeyPath(stage, project));
565
+ return key;
566
+ }
567
+ /**
568
+ * Get or create a key for a stage.
569
+ * If the key already exists, it is returned. Otherwise, a new key is generated.
570
+ */
571
+ async function getOrCreateKey(stage, project) {
572
+ const existingKey = await readKey(stage, project);
573
+ if (existingKey) return existingKey;
574
+ try {
575
+ return await generateKey(stage, project, "wx");
576
+ } catch (error) {
577
+ if (error.code !== "EEXIST") throw error;
578
+ return requireKey(stage, project);
579
+ }
580
+ }
581
+ //#endregion
582
+ //#region src/secrets/file.ts
583
+ /** Where the files live, relative to the project root. */
584
+ const SECRETS_DIR = ".gkm/secrets";
585
+ /** AES-256-GCM configuration */
586
+ const ALGORITHM = "aes-256-gcm";
587
+ const IV_LENGTH = 12;
588
+ /**
589
+ * A stage's secrets as an encrypted file on this machine:
590
+ * `.gkm/secrets/<stage>.json`, with its key in the CLI's home at
591
+ * `keys/<namespace>/<project>/<stage>.key`.
592
+ *
593
+ * The local stage's store, always — its secrets belong to the machine running
594
+ * `gkm dev` — and a deployed stage's when `secrets.store` is `'file'`.
595
+ */
596
+ var FileSecretsStore = class {
597
+ root;
598
+ name = "file";
599
+ project;
600
+ /**
601
+ * @param project - Whose keys: a workspace's `keystoreProject()`. Outside a
602
+ * workspace there is no config to name the project, so it is named the
603
+ * way a workspace without `name` is — its package name, else its folder.
604
+ */
605
+ constructor(root, project) {
606
+ this.root = root;
607
+ this.project = project ?? {
608
+ key: projectKey({ name: packageName(root) ?? basename(root) }),
609
+ legacy: [basename(root)]
610
+ };
611
+ }
612
+ /** The file a stage's secrets are kept in. */
613
+ path(stage) {
614
+ return join(this.root, SECRETS_DIR, `${stage}.json`);
615
+ }
616
+ async read(stage) {
617
+ const path = this.path(stage);
618
+ if (!existsSync(path)) return null;
619
+ const data = JSON.parse(await readFile(path, "utf-8"));
620
+ if (!(data.version === 1 && data.encrypted && data.iv)) return data;
621
+ const key = await readKey(stage, this.project);
622
+ if (!key) throw new MissingSecretsKey(stage, this.project.key, getKeyPath(stage, this.project));
623
+ return decrypt(data, key);
624
+ }
625
+ async write(stage, secrets) {
626
+ await mkdir(join(this.root, SECRETS_DIR), { recursive: true });
627
+ const key = await getOrCreateKey(stage, this.project);
628
+ await writeFile(this.path(stage), JSON.stringify(encrypt(secrets, key), null, 2), "utf-8");
629
+ }
630
+ };
631
+ /** A stage's secrets file exists, and the key that opens it does not. */
632
+ var MissingSecretsKey = class extends GkmError {
633
+ stage;
634
+ project;
635
+ path;
636
+ constructor(stage, project, path) {
637
+ super(`Decryption key not found for stage "${stage}". Expected key at: ${path}. Copy the stage's key there from whoever created it, or set secrets.store to a store this machine can reach.`);
638
+ this.stage = stage;
639
+ this.project = project;
640
+ this.path = path;
641
+ this.name = "MissingSecretsKey";
642
+ }
643
+ };
644
+ /** A project's package name without its scope, as a workspace name reads it. */
645
+ function packageName(root) {
646
+ try {
647
+ const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf-8"));
648
+ return typeof pkg.name === "string" ? pkg.name.replace(/^@[^/]+\//, "") : void 0;
649
+ } catch {
650
+ return;
651
+ }
652
+ }
653
+ /**
654
+ * Encrypt a JSON value with a stage key: AES-256-GCM, the file format every
655
+ * stage's secrets are kept in.
656
+ */
657
+ function encrypt(secrets, keyHex) {
658
+ const key = Buffer.from(keyHex, "hex");
659
+ const iv = randomBytes(IV_LENGTH);
660
+ const cipher = createCipheriv(ALGORITHM, key, iv);
661
+ const ciphertext = Buffer.concat([cipher.update(JSON.stringify(secrets), "utf-8"), cipher.final()]);
662
+ return {
663
+ version: 1,
664
+ encrypted: Buffer.concat([ciphertext, cipher.getAuthTag()]).toString("base64"),
665
+ iv: iv.toString("hex")
666
+ };
667
+ }
668
+ /** Decrypt what {@link encrypt} wrote. */
669
+ function decrypt(data, keyHex) {
670
+ const key = Buffer.from(keyHex, "hex");
671
+ const combined = Buffer.from(data.encrypted, "base64");
672
+ const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(data.iv, "hex"));
673
+ decipher.setAuthTag(combined.subarray(-16));
674
+ const plaintext = Buffer.concat([decipher.update(combined.subarray(0, -16)), decipher.final()]);
675
+ return JSON.parse(plaintext.toString("utf-8"));
676
+ }
677
+ //#endregion
678
+ //#region src/build/native.ts
679
+ /**
680
+ * The file beside a bundle naming the packages it left out, each at the
681
+ * version the build resolved: a `package.json` an image installs, for its own
682
+ * platform, next to the bundle. `server.mjs` → `server.externals.json`.
683
+ */
684
+ function externalsManifestName(outfile) {
685
+ return `${outfile.replace(/\.mjs$/, "")}.externals.json`;
686
+ }
687
+ /**
688
+ * Asked to leave a package out of the bundle, and nothing the app depends on
689
+ * provides it: there is no version to install in the image.
690
+ */
691
+ var ExternalNotInstalled = class extends Error {
692
+ packageName;
693
+ root;
694
+ constructor(packageName, root) {
695
+ super(`'${packageName}' is left out of the bundle, to be installed beside it, but it is not installed for the app at ${root}: add it to the app's dependencies.`);
696
+ this.packageName = packageName;
697
+ this.root = root;
698
+ this.name = "ExternalNotInstalled";
699
+ }
700
+ };
701
+ /** Packages whose job is loading a compiled addon. */
702
+ const NATIVE_LOADERS = /* @__PURE__ */ new Set([
703
+ "bindings",
704
+ "node-gyp-build",
705
+ "node-gyp-build-optional-packages",
706
+ "node-pre-gyp",
707
+ "@mapbox/node-pre-gyp",
708
+ "prebuild-install",
709
+ "@neon-rs/load"
710
+ ]);
711
+ /** A per-platform binary package: `@node-rs/argon2-linux-x64-gnu`, `@img/sharp-darwin-arm64`. */
712
+ const PLATFORM_PACKAGE = /(?:^|[-/])(?:linux|darwin|win32|freebsd|android)-(?:x64|arm64|arm|ia32)\b/;
713
+ function readPackage(dir) {
714
+ try {
715
+ return JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
716
+ } catch {
717
+ return;
718
+ }
719
+ }
720
+ /**
721
+ * Where `name` resolves from `from`, the way Node finds it: the nearest
722
+ * `node_modules/<name>` walking up. Followed through symlinks, so a pnpm
723
+ * store package resolves its own dependencies beside it.
724
+ */
725
+ function locate(name, from) {
726
+ let dir = from;
727
+ for (;;) {
728
+ const candidate = join(dir, "node_modules", name);
729
+ if (existsSync(join(candidate, "package.json"))) return realpathSync(candidate);
730
+ const parent = dirname(dir);
731
+ if (parent === dir) return void 0;
732
+ dir = parent;
733
+ }
734
+ }
735
+ /**
736
+ * Whether a package carries compiled code: a `binding.gyp` or prebuilt
737
+ * binaries of its own, a loader for them, or a binary package per platform.
738
+ * Such a package cannot be inlined into a bundle — it loads a `.node` file
739
+ * from beside its own source, for the platform it was installed on.
740
+ */
741
+ function isNativePackage(dir, pkg) {
742
+ if (pkg.gypfile || pkg.binary || pkg.napi) return true;
743
+ if (Object.keys({
744
+ ...pkg.dependencies,
745
+ ...pkg.optionalDependencies
746
+ }).some((dep) => NATIVE_LOADERS.has(dep))) return true;
747
+ if (Object.keys(pkg.optionalDependencies ?? {}).some((dep) => PLATFORM_PACKAGE.test(dep))) return true;
748
+ if (existsSync(join(dir, "binding.gyp"))) return true;
749
+ if (existsSync(join(dir, "prebuilds"))) return true;
750
+ try {
751
+ return readdirSync(dir).some((file) => file.endsWith(".node"));
752
+ } catch {
753
+ return false;
754
+ }
755
+ }
756
+ /**
757
+ * The packages with native code an app's bundle would otherwise inline, each
758
+ * at the version installed for it.
759
+ *
760
+ * Walks what the app depends on at runtime — `dependencies`, never
761
+ * `devDependencies` — through workspace packages and installed ones alike,
762
+ * since anything reached is bundled. A native package is where the walk
763
+ * stops: installing it brings what it depends on.
764
+ */
765
+ function nativeDependencies(root) {
766
+ const found = {};
767
+ const seen = /* @__PURE__ */ new Set();
768
+ const queue = [realpathSync(root)];
769
+ while (queue.length > 0) {
770
+ const dir = queue.shift();
771
+ if (seen.has(dir)) continue;
772
+ seen.add(dir);
773
+ const pkg = readPackage(dir);
774
+ if (!pkg) continue;
775
+ const isRoot = seen.size === 1;
776
+ const installed = dir.split(sep).includes("node_modules");
777
+ if (!isRoot && installed && isNativePackage(dir, pkg)) {
778
+ if ((!pkg.os || pkg.os.includes("linux") || pkg.os.every((os) => os.startsWith("!")) && !pkg.os.includes("!linux")) && pkg.name && pkg.version && !(pkg.name in found)) found[pkg.name] = pkg.version;
779
+ continue;
780
+ }
781
+ for (const dep of Object.keys({
782
+ ...pkg.dependencies,
783
+ ...pkg.optionalDependencies
784
+ })) {
785
+ const location = locate(dep, dir);
786
+ if (location && !seen.has(location)) queue.push(location);
787
+ }
788
+ }
789
+ return Object.fromEntries(Object.entries(found).sort(([a], [b]) => a.localeCompare(b)));
790
+ }
791
+ /**
792
+ * What a bundle leaves out, with the version of each to install: the native
793
+ * packages found under `root`, and any it was asked to leave out besides,
794
+ * at the version installed for the app.
795
+ */
796
+ function bundleExternals(root, declared) {
797
+ const externals = nativeDependencies(root);
798
+ for (const name of declared) {
799
+ if (name in externals) continue;
800
+ const location = locate(name, root);
801
+ const version = location ? readPackage(location)?.version : void 0;
802
+ if (!version) throw new ExternalNotInstalled(name, root);
803
+ externals[name] = version;
804
+ }
805
+ return Object.fromEntries(Object.entries(externals).sort(([a], [b]) => a.localeCompare(b)));
806
+ }
807
+ /** The package a bare specifier names: `argon2/lib` → `argon2`, `@a/b/c` → `@a/b`. */
808
+ function packageOf(specifier) {
809
+ const parts = specifier.split("/");
810
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
811
+ }
812
+ /**
813
+ * The packages a bundle imports at runtime rather than inlining, read from
814
+ * esbuild's metafile. Nothing when there is no metafile.
815
+ */
816
+ function importedPackages(metafile) {
817
+ let meta;
818
+ try {
819
+ meta = JSON.parse(readFileSync(metafile, "utf-8"));
820
+ } catch {
821
+ return /* @__PURE__ */ new Set();
822
+ }
823
+ const imported = /* @__PURE__ */ new Set();
824
+ for (const output of Object.values(meta.outputs ?? {})) for (const { path, external } of output.imports ?? []) if (external && !path.startsWith(".") && !path.startsWith("node:")) imported.add(packageOf(path));
825
+ return imported;
826
+ }
827
+ //#endregion
828
+ //#region src/secrets/storage.ts
829
+ /**
830
+ * What a stage's secrets are, independent of where they are kept: building
831
+ * them, changing them, and handing them to a process. Where they are kept is a
832
+ * {@link SecretsStore}'s business — see `secretsStoreFor`.
833
+ */
834
+ var storage_exports = /* @__PURE__ */ __exportAll({
835
+ initStageSecrets: () => initStageSecrets,
836
+ maskPassword: () => maskPassword,
837
+ toEmbeddableSecrets: () => toEmbeddableSecrets,
838
+ validateEnvironmentVariables: () => validateEnvironmentVariables,
839
+ withCustomSecret: () => withCustomSecret
840
+ });
841
+ /**
842
+ * Initialize an empty StageSecrets object for a stage.
843
+ */
844
+ function initStageSecrets(stage) {
845
+ const now = (/* @__PURE__ */ new Date()).toISOString();
846
+ return {
847
+ stage,
848
+ createdAt: now,
849
+ updatedAt: now,
850
+ services: {},
851
+ urls: {},
852
+ custom: {}
853
+ };
854
+ }
855
+ /**
856
+ * Convert StageSecrets to embeddable format (flat key-value pairs).
857
+ * This is what gets encrypted and embedded in the bundle.
858
+ */
859
+ function toEmbeddableSecrets(secrets) {
860
+ return {
861
+ ...secrets.urls,
862
+ ...Object.fromEntries(Object.entries(secrets.custom).filter(([key]) => !isReservedStageKey(key))),
863
+ ...secrets.services.postgres && {
864
+ POSTGRES_USER: secrets.services.postgres.username,
865
+ POSTGRES_PASSWORD: secrets.services.postgres.password,
866
+ POSTGRES_DB: secrets.services.postgres.database ?? "app",
867
+ POSTGRES_HOST: secrets.services.postgres.host,
868
+ POSTGRES_PORT: String(secrets.services.postgres.port)
869
+ },
870
+ ...secrets.services.redis && {
871
+ REDIS_PASSWORD: secrets.services.redis.password,
872
+ REDIS_HOST: secrets.services.redis.host,
873
+ REDIS_PORT: String(secrets.services.redis.port)
874
+ },
875
+ ...secrets.services.minio && {
876
+ STORAGE_ACCESS_KEY_ID: secrets.services.minio.username,
877
+ STORAGE_SECRET_ACCESS_KEY: secrets.services.minio.password,
878
+ STORAGE_BUCKET: secrets.services.minio.bucket ?? "app",
879
+ STORAGE_REGION: "eu-west-1",
880
+ STORAGE_FORCE_PATH_STYLE: "true"
881
+ },
882
+ ...secrets.services.mailpit && {
883
+ SMTP_HOST: secrets.services.mailpit.host,
884
+ SMTP_PORT: String(secrets.services.mailpit.port),
885
+ SMTP_USER: secrets.services.mailpit.username,
886
+ SMTP_PASS: secrets.services.mailpit.password,
887
+ SMTP_SECURE: "false",
888
+ MAIL_FROM: "noreply@localhost"
889
+ },
890
+ ...secrets.services.localstack && {
891
+ AWS_ACCESS_KEY_ID: secrets.services.localstack.accessKeyId ?? secrets.services.localstack.username,
892
+ AWS_SECRET_ACCESS_KEY: secrets.services.localstack.password,
893
+ AWS_REGION: secrets.services.localstack.region ?? "us-east-1",
894
+ AWS_ENDPOINT_URL: `http://${secrets.services.localstack.host}:${secrets.services.localstack.port}`
895
+ }
896
+ };
897
+ }
898
+ /** The same secrets with one custom value set, and `updatedAt` moved on. */
899
+ function withCustomSecret(secrets, key, value) {
900
+ return {
901
+ ...secrets,
902
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
903
+ custom: {
904
+ ...secrets.custom,
905
+ [key]: value
906
+ }
907
+ };
908
+ }
909
+ /**
910
+ * Mask a password for display (show first 4 and last 2 chars).
911
+ */
912
+ function maskPassword(password) {
913
+ if (password.length <= 8) return "********";
914
+ return `${password.slice(0, 4)}${"*".repeat(password.length - 6)}${password.slice(-2)}`;
915
+ }
916
+ /**
917
+ * Validate that all required environment variables are present in secrets.
918
+ *
919
+ * @param requiredVars - Array of environment variable names required by the application
920
+ * @param secrets - Stage secrets to validate against
921
+ * @returns Validation result with missing and provided variables
922
+ *
923
+ * @example
924
+ * ```typescript
925
+ * const required = ['DATABASE_URL', 'API_KEY', 'JWT_SECRET'];
926
+ * const secrets = await secretsStoreFor(workspace, 'production').then((s) => s.read('production'));
927
+ * const result = validateEnvironmentVariables(required, secrets);
928
+ *
929
+ * if (!result.valid) {
930
+ * console.error(`Missing environment variables: ${result.missing.join(', ')}`);
931
+ * }
932
+ * ```
933
+ */
934
+ function validateEnvironmentVariables(requiredVars, secrets) {
935
+ const embeddable = toEmbeddableSecrets(secrets);
936
+ const availableVars = new Set(Object.keys(embeddable));
937
+ const missing = [];
938
+ const provided = [];
939
+ for (const varName of requiredVars) if (availableVars.has(varName)) provided.push(varName);
940
+ else missing.push(varName);
941
+ return {
942
+ valid: missing.length === 0,
943
+ missing: missing.sort(),
944
+ provided: provided.sort(),
945
+ required: [...requiredVars].sort()
946
+ };
947
+ }
948
+ //#endregion
949
+ //#region src/secrets/store.ts
950
+ var store_exports = /* @__PURE__ */ __exportAll({
951
+ FileSecretsStore: () => FileSecretsStore,
952
+ isRemoteStore: () => isRemoteStore,
953
+ secretsStoreFor: () => secretsStoreFor,
954
+ storeFromConfig: () => storeFromConfig
955
+ });
956
+ /**
957
+ * The store a stage's secrets are kept in — what every command reads and
958
+ * writes, for the stage it acts on.
959
+ *
960
+ * The local stage is always the file: its secrets belong to the machine
961
+ * running `gkm dev`. A deployed stage uses `secrets.store`.
962
+ */
963
+ async function secretsStoreFor(workspace, stage, options = {}) {
964
+ const configured = workspace.secrets.store ?? "file";
965
+ if (stage === workspace.stages.local || configured === "file") return new FileSecretsStore(workspace.root, keystoreProject(workspace, options.home));
966
+ return storeFromConfig(workspace, configured, options);
967
+ }
968
+ /**
969
+ * The store a `secrets.store` value describes, for any stage — what
970
+ * {@link secretsStoreFor} answers for a deployed stage, and what
971
+ * `gkm secrets:migrate` builds for the store it copies to.
972
+ */
973
+ async function storeFromConfig(workspace, config, options = {}) {
974
+ if (config === "file") return new FileSecretsStore(workspace.root, keystoreProject(workspace, options.home));
975
+ const profile = options.profile ? { profile: options.profile } : {};
976
+ switch (config.provider) {
977
+ case "s3": {
978
+ const { S3SecretsStore } = await import("./s3-DNp8U0Ea.mjs");
979
+ const { deployIdentity } = await Promise.resolve().then(() => identity_exports);
980
+ const location = s3SecretsLocation(config, workspace.state);
981
+ return new S3SecretsStore({
982
+ project: workspace.name,
983
+ identity: deployIdentity(workspace, ""),
984
+ region: location.region,
985
+ prefix: location.prefix,
986
+ ...location.bucket ? { bucket: location.bucket } : {},
987
+ ...profile
988
+ });
989
+ }
990
+ case "ssm": {
991
+ const { AwsSecretsStore } = await import("./aws-8QQ8n-t6.mjs").then((n) => n.t);
992
+ return new AwsSecretsStore({
993
+ project: workspace.name,
994
+ region: config.region,
995
+ ...profile
996
+ });
997
+ }
998
+ case "secrets-manager": {
999
+ const { kmsKeyId } = config;
1000
+ const { SecretsManagerSecretsStore } = await import("./secretsManager-CQORubp9.mjs").then((n) => n.n);
1001
+ return new SecretsManagerSecretsStore({
1002
+ project: workspace.name,
1003
+ region: config.region,
1004
+ ...kmsKeyId ? { kmsKeyId } : {},
1005
+ ...profile
1006
+ });
1007
+ }
1008
+ default: {
1009
+ const provider = config.provider;
1010
+ if (typeof provider === "object" && provider !== null) return provider;
1011
+ throw new UnknownSecretsStoreProvider(provider);
1012
+ }
1013
+ }
1014
+ }
1015
+ /** Whether a stage's secrets live somewhere other than this machine. */
1016
+ function isRemoteStore(workspace, stage) {
1017
+ const configured = workspace.secrets.store ?? "file";
1018
+ return stage !== workspace.stages.local && configured !== "file";
1019
+ }
1020
+ //#endregion
1021
+ //#region src/workspace/backends.ts
1022
+ /**
1023
+ * Which backend each declared kind resolves to — decided by where the project
1024
+ * deploys, and by nothing else.
1025
+ *
1026
+ * These used to be read out of a `services:` block, where one key answered two
1027
+ * questions: *does this exist* and *what backs it*. The first is the manifest's
1028
+ * — a declared `Cache` is why there is a cache — and the second is the deploy
1029
+ * target's, because the right cache for a Lambda is not the right cache for a
1030
+ * box already running Postgres. With both answered elsewhere there was nothing
1031
+ * left for the block to say, so it is gone and these read the target.
1032
+ *
1033
+ * Mail has no answer here at all: every provider speaks SMTP, so the provider
1034
+ * is whichever one the stage's mail URL points at.
1035
+ */
1036
+ /**
1037
+ * Which family of defaults a workspace's deploy target belongs to.
1038
+ *
1039
+ * One question, asked once: **does this target run containers the project
1040
+ * controls?** Dokploy does, so a bucket or a cache can live beside the app;
1041
+ * AWS, Vercel and Cloudflare do not, so the default has to be something
1042
+ * managed. That is the whole of the distinction, and it is why `MainProvider`
1043
+ * is the right axis rather than the deploy target's own name — targets share
1044
+ * answers.
1045
+ *
1046
+ * Each target declares its answer as its `runtime` — a target package in its
1047
+ * `package.json`, so this never loads one. A workspace that names no target
1048
+ * is on AWS: an SST project predates `deploy.default: 'sst'`.
1049
+ */
1050
+ function providerOf(workspace) {
1051
+ const target = workspace.deploy?.default;
1052
+ return target ? runtimeOf(target, workspace) : "aws";
1053
+ }
1054
+ /**
1055
+ * The cache backend a target implies.
1056
+ *
1057
+ * The same answer locally and deployed: a local `gkm dev` for an AWS app still
1058
+ * uses the Upstash protocol, because a backend that differed between the two
1059
+ * would be worse than a slower one.
1060
+ */
1061
+ function cacheBackendFor(on) {
1062
+ return DEFAULT_CACHE[on];
1063
+ }
1064
+ /** Where a declared bucket lives on a target. */
1065
+ function storageBackendFor(on) {
1066
+ return DEFAULT_STORAGE[on];
1067
+ }
1068
+ /**
1069
+ * Which broker carries declared queues and topics on a target.
1070
+ *
1071
+ * Only consulted when something declares one; a project with no `Topic` or
1072
+ * `Queue` has no events at all, whatever the target.
1073
+ */
1074
+ function eventsBackendFor(on) {
1075
+ return DEFAULT_EVENTS[on];
1076
+ }
1077
+ //#endregion
1078
+ //#region src/providers/processorOrigin.ts
1079
+ /**
1080
+ * A file server's processors as a CDN origin: the names both sides agree on.
1081
+ *
1082
+ * On a compose stage whose bucket is on S3, the CDN serves the bucket and
1083
+ * sends each processor pattern to the stack's processor unit, at a host of
1084
+ * its own. That host is public — a CDN reaches its origin over the internet —
1085
+ * so the CDN adds a secret header and the edge refuses any request without
1086
+ * it. One definition, read by the CDN that sends the header and by the stack
1087
+ * whose edge checks it, so the two cannot drift.
1088
+ */
1089
+ /** The header the CDN adds to every request it sends a processor. */
1090
+ const ORIGIN_VERIFY_HEADER = "X-Gkm-Origin-Verify";
1091
+ /** Where a file server's processors answer the CDN: `<fileserver>-processors.<domain>`. */
1092
+ function processorOriginHost(serverId, domain) {
1093
+ return `${appKey(serverId)}-processors.${domain}`.toLowerCase();
1094
+ }
1095
+ /** The stage secret holding the header's value: `ASSETS_SERVER_ORIGIN_SECRET`. */
1096
+ function originSecretKey(serverId) {
1097
+ return provideKey(serverId, "originSecret");
1098
+ }
1099
+ /**
1100
+ * What the processor unit reads that secret from. Set wherever the CDN fronts
1101
+ * it, so the unit refuses a request without the header itself — on Dokploy,
1102
+ * whose edge cannot match a header, the only check; behind the stack's own
1103
+ * edge, a second one.
1104
+ */
1105
+ const PROCESSOR_ORIGIN_SECRET_ENV = "GKM_PROCESSOR_ORIGIN_SECRET";
1106
+ /** A new value for that secret: random, generated once, kept in the stage. */
1107
+ function newOriginSecret() {
1108
+ return randomBytes(32).toString("base64url");
1109
+ }
1110
+ //#endregion
1111
+ //#region src/deploy/state.ts
1112
+ /**
1113
+ * Create a new empty state for a stage
1114
+ */
1115
+ function createEmptyState(stage, projectId, environmentId) {
1116
+ return {
1117
+ provider: "dokploy",
1118
+ stage,
1119
+ projectId,
1120
+ environmentId,
1121
+ applications: {},
1122
+ services: {},
1123
+ lastDeployedAt: (/* @__PURE__ */ new Date()).toISOString()
1124
+ };
1125
+ }
1126
+ /** A new compose stage's state. */
1127
+ function createComposeState(stage) {
1128
+ return {
1129
+ provider: "compose",
1130
+ stage,
1131
+ lastDeployedAt: (/* @__PURE__ */ new Date()).toISOString()
1132
+ };
1133
+ }
1134
+ /**
1135
+ * `state` as the Dokploy target keeps it. A stage whose state another target
1136
+ * wrote — one moved from compose to Dokploy — keeps its core (releases,
1137
+ * identity) and starts with no Dokploy ids, as a first deploy would.
1138
+ */
1139
+ function asDokployState(state) {
1140
+ if (state.provider === "dokploy") return state;
1141
+ const { provider: _provider, ...core } = state;
1142
+ return {
1143
+ ...core,
1144
+ provider: "dokploy",
1145
+ projectId: "",
1146
+ environmentId: "",
1147
+ applications: {},
1148
+ services: {}
1149
+ };
1150
+ }
1151
+ /**
1152
+ * Set application ID in state (mutates state)
1153
+ */
1154
+ function setApplicationId(state, appName, applicationId) {
1155
+ state.applications[appName] = applicationId;
1156
+ }
1157
+ /** Two records naming the same image: by digest when both have one. */
1158
+ function sameImage(a, b) {
1159
+ return a.digest && b.digest ? a.digest === b.digest : a.ref === b.ref;
1160
+ }
1161
+ /** The newest release in `history` after `index` that a rollback may restore. */
1162
+ function restorable(history, index, current) {
1163
+ return history.slice(index + 1).find((entry) => !entry.rolledBack && !sameImage(entry, current));
1164
+ }
1165
+ /**
1166
+ * Record that `image` went live for `appName` (mutates state): it becomes
1167
+ * `current`, and what was current becomes `previous`. Releasing what already
1168
+ * runs — a redeploy of the same digest — changes nothing.
1169
+ */
1170
+ function recordRelease(state, appName, image, by, releasedAt = /* @__PURE__ */ new Date()) {
1171
+ const releases = state.releases?.[appName];
1172
+ if (releases && sameImage(releases.current, image)) return;
1173
+ const entry = {
1174
+ ...image,
1175
+ releasedAt: releasedAt.toISOString(),
1176
+ releasedBy: by
1177
+ };
1178
+ const history = [entry, ...releases?.history ?? []].slice(0, 10);
1179
+ const previous = releases?.current;
1180
+ state.releases = {
1181
+ ...state.releases,
1182
+ [appName]: {
1183
+ current: entry,
1184
+ ...previous ? { previous } : {},
1185
+ history
1186
+ }
1187
+ };
1188
+ }
1189
+ /**
1190
+ * Record that `appName` was rolled back to `to` (mutates state): every
1191
+ * release newer than it is marked rolled back, so neither this rollback nor
1192
+ * a later one restores it, and `previous` moves to the release before `to`.
1193
+ */
1194
+ function recordRollback(state, appName, to) {
1195
+ const releases = state.releases?.[appName];
1196
+ if (!releases) return;
1197
+ const index = releases.history.findIndex((entry) => !entry.rolledBack && sameImage(entry, to));
1198
+ if (index === -1) return;
1199
+ const history = releases.history.map((entry, i) => i < index ? {
1200
+ ...entry,
1201
+ rolledBack: true
1202
+ } : entry);
1203
+ const current = history[index];
1204
+ const previous = restorable(history, index, current);
1205
+ state.releases = {
1206
+ ...state.releases,
1207
+ [appName]: {
1208
+ current,
1209
+ ...previous ? { previous } : {},
1210
+ history
1211
+ }
1212
+ };
1213
+ }
1214
+ /**
1215
+ * Get a generated secret for an app
1216
+ */
1217
+ function getGeneratedSecret(state, appName, secretName) {
1218
+ return state?.generatedSecrets?.[appName]?.[secretName];
1219
+ }
1220
+ /**
1221
+ * Set a generated secret for an app (mutates state)
1222
+ */
1223
+ function setGeneratedSecret(state, appName, secretName, value) {
1224
+ if (!state.generatedSecrets) state.generatedSecrets = {};
1225
+ if (!state.generatedSecrets[appName]) state.generatedSecrets[appName] = {};
1226
+ state.generatedSecrets[appName][secretName] = value;
1227
+ }
1228
+ /**
1229
+ * Set DNS verification record for a hostname (mutates state)
1230
+ */
1231
+ function setDnsVerification(state, hostname, serverIp) {
1232
+ if (!state.dnsVerified) state.dnsVerified = {};
1233
+ state.dnsVerified[hostname] = {
1234
+ serverIp,
1235
+ verifiedAt: (/* @__PURE__ */ new Date()).toISOString()
1236
+ };
1237
+ }
1238
+ /**
1239
+ * Check if a hostname is already verified with the given IP
1240
+ */
1241
+ function isDnsVerified(state, hostname, serverIp) {
1242
+ return (state?.dnsVerified?.[hostname])?.serverIp === serverIp;
1243
+ }
1244
+ /**
1245
+ * Get the key for a DNS record in state
1246
+ */
1247
+ function getDnsRecordKey(name, type) {
1248
+ return `${name}:${type}`;
1249
+ }
1250
+ /**
1251
+ * Set a created DNS record in state (mutates state)
1252
+ */
1253
+ function setDnsRecord(state, record) {
1254
+ if (!state.dnsRecords) state.dnsRecords = {};
1255
+ const key = getDnsRecordKey(record.name, record.type);
1256
+ state.dnsRecords[key] = {
1257
+ ...record,
1258
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
1259
+ };
1260
+ }
1261
+ /**
1262
+ * Get backup state from state
1263
+ */
1264
+ function getBackupState(state) {
1265
+ return state?.backups;
1266
+ }
1267
+ /**
1268
+ * Set backup state (mutates state)
1269
+ */
1270
+ function setBackupState(state, backupState) {
1271
+ state.backups = backupState;
1272
+ }
1273
+ /**
1274
+ * Set postgres backup ID in state (mutates state)
1275
+ */
1276
+ function setPostgresBackupId(state, backupId) {
1277
+ if (state.backups) state.backups.postgresBackupId = backupId;
1278
+ }
1279
+ //#endregion
1280
+ //#region src/target/dokploy/dns/DnsProvider.ts
1281
+ /**
1282
+ * An MX record's value as every provider here reads and writes it — the zone
1283
+ * file's `<priority> <host>`, which is what Route53 and Hostinger take as is.
1284
+ * A provider whose API keeps the priority apart (GoDaddy) splits it with
1285
+ * {@link parseMxValue}.
1286
+ */
1287
+ function mxValue(priority, host) {
1288
+ return `${priority} ${host.trim().replace(/\.$/, "")}`;
1289
+ }
1290
+ /** An MX value that is not `<priority> <host>`. */
1291
+ var MxValueInvalid = class extends GkmError {
1292
+ value;
1293
+ constructor(value) {
1294
+ super(`'${value}' is not an MX record's value: it is written '<priority> <host>', like '10 inbound-smtp.eu-west-1.amazonaws.com'. Build it with mxValue(priority, host).`);
1295
+ this.value = value;
1296
+ this.name = "MxValueInvalid";
1297
+ }
1298
+ };
1299
+ /**
1300
+ * The priority and host of an MX value.
1301
+ *
1302
+ * @throws {MxValueInvalid} for a value that is not `<priority> <host>`
1303
+ */
1304
+ function parseMxValue(value) {
1305
+ const match = value.trim().match(/^(\d{1,5})\s+(\S+)$/);
1306
+ const priority = match ? Number(match[1]) : NaN;
1307
+ if (!match || priority > 65535) throw new MxValueInvalid(value);
1308
+ return {
1309
+ priority,
1310
+ host: match[2].replace(/\.$/, "")
1311
+ };
1312
+ }
1313
+ /**
1314
+ * Check if value is a DnsProvider implementation.
1315
+ */
1316
+ function isDnsProvider(value) {
1317
+ return typeof value === "object" && value !== null && typeof value.name === "string" && typeof value.getRecords === "function" && typeof value.upsertRecords === "function" && typeof value.deleteRecords === "function";
1318
+ }
1319
+ /**
1320
+ * Create a DNS provider based on configuration.
1321
+ *
1322
+ * - 'hostinger': HostingerProvider
1323
+ * - 'route53': Route53Provider
1324
+ * - 'godaddy': GoDaddyProvider
1325
+ * - 'manual': Returns null (user handles DNS)
1326
+ * - Custom: Use provided DnsProvider implementation
1327
+ */
1328
+ async function createDnsProvider(options) {
1329
+ const { config } = options;
1330
+ if (config.provider === "manual") return null;
1331
+ if (isDnsProvider(config.provider)) return config.provider;
1332
+ const provider = config.provider;
1333
+ if (provider === "hostinger") {
1334
+ const { HostingerProvider } = await import("./HostingerProvider-DSHpNBim.mjs");
1335
+ return new HostingerProvider(options.hostinger);
1336
+ }
1337
+ if (provider === "route53") {
1338
+ const { Route53Provider } = await import("./Route53Provider-Di_SD9CF.mjs");
1339
+ const route53Config = config;
1340
+ return new Route53Provider({
1341
+ region: route53Config.region,
1342
+ profile: route53Config.profile,
1343
+ hostedZoneId: route53Config.hostedZoneId
1344
+ });
1345
+ }
1346
+ if (provider === "godaddy") {
1347
+ const { GoDaddyProvider } = await import("./GoDaddyProvider-BIibcRG4.mjs");
1348
+ return new GoDaddyProvider(options.godaddy ?? {});
1349
+ }
1350
+ if (provider === "cloudflare") throw new DnsProviderNotImplemented("cloudflare");
1351
+ throw new DnsProviderUnknown(config);
1352
+ }
1353
+ /**
1354
+ * The provider's credentials can write records and not read them — a key
1355
+ * scoped to updates only. What reads them falls back to writing every record,
1356
+ * which is idempotent, without a diff.
1357
+ */
1358
+ var DnsRecordsUnreadable = class extends GkmError {
1359
+ provider;
1360
+ domain;
1361
+ reason;
1362
+ constructor(provider, domain, reason) {
1363
+ super(`The ${provider} key cannot read ${domain}'s DNS records (${reason}), so changes cannot be compared with what is there: every record is written, which leaves one that already has its value as it was.`);
1364
+ this.provider = provider;
1365
+ this.domain = domain;
1366
+ this.reason = reason;
1367
+ this.name = "DnsRecordsUnreadable";
1368
+ }
1369
+ };
1370
+ /** A DNS provider gkm names and does not have yet. */
1371
+ var DnsProviderNotImplemented = class extends Error {
1372
+ provider;
1373
+ constructor(provider) {
1374
+ super(`The ${provider} DNS provider is not implemented yet. Use 'route53', 'godaddy', 'hostinger' or 'manual' for this domain in dns, or pass your own DnsProvider object.`);
1375
+ this.provider = provider;
1376
+ this.name = "DnsProviderNotImplemented";
1377
+ }
1378
+ };
1379
+ /** A `provider:` that is none of the built-ins, nor a DnsProvider object. */
1380
+ var DnsProviderUnknown = class extends GkmError {
1381
+ config;
1382
+ constructor(config) {
1383
+ super(`Unknown DNS provider: ${JSON.stringify(config)}. dns takes 'route53', 'godaddy', 'hostinger', 'manual', or an object implementing DnsProvider.`);
1384
+ this.config = config;
1385
+ this.name = "DnsProviderUnknown";
1386
+ }
1387
+ };
1388
+ //#endregion
1389
+ //#region src/target/dokploy/dns/index.ts
1390
+ /**
1391
+ * DNS orchestration for deployments
1392
+ *
1393
+ * Handles automatic DNS record creation for deployed applications.
1394
+ */
1395
+ const logger = output;
1396
+ /**
1397
+ * Check if DNS config is legacy format (single domain with `domain` property)
1398
+ */
1399
+ function isLegacyDnsConfig(config) {
1400
+ return typeof config === "object" && config !== null && "provider" in config && "domain" in config;
1401
+ }
1402
+ /**
1403
+ * Normalize DNS config to new multi-domain format
1404
+ */
1405
+ function normalizeDnsConfig(config) {
1406
+ if (isLegacyDnsConfig(config)) {
1407
+ const { domain, ...providerConfig } = config;
1408
+ return { [domain]: providerConfig };
1409
+ }
1410
+ return config;
1411
+ }
1412
+ /**
1413
+ * Find the root domain for a hostname from available DNS configs
1414
+ *
1415
+ * @example
1416
+ * findRootDomain('api.geekmidas.com', { 'geekmidas.com': {...}, 'geekmidas.dev': {...} })
1417
+ * // Returns 'geekmidas.com'
1418
+ */
1419
+ function findRootDomain(hostname, dnsConfig) {
1420
+ const domains = Object.keys(dnsConfig).sort((a, b) => b.length - a.length);
1421
+ for (const domain of domains) if (hostname === domain || hostname.endsWith(`.${domain}`)) return domain;
1422
+ return null;
1423
+ }
1424
+ /**
1425
+ * Group hostnames by their root domain
1426
+ */
1427
+ function groupHostnamesByDomain(appHostnames, dnsConfig) {
1428
+ const grouped = /* @__PURE__ */ new Map();
1429
+ for (const [appName, hostname] of appHostnames) {
1430
+ const rootDomain = findRootDomain(hostname, dnsConfig);
1431
+ if (!rootDomain) {
1432
+ logger.log(` ⚠ No DNS config found for hostname: ${hostname}`);
1433
+ continue;
1434
+ }
1435
+ if (!grouped.has(rootDomain)) grouped.set(rootDomain, /* @__PURE__ */ new Map());
1436
+ grouped.get(rootDomain).set(appName, hostname);
1437
+ }
1438
+ return grouped;
1439
+ }
1440
+ /**
1441
+ * Resolve IP address from a hostname
1442
+ */
1443
+ async function resolveHostnameToIp(hostname) {
1444
+ try {
1445
+ return (await lookup(hostname, { family: 4 })).address;
1446
+ } catch (error) {
1447
+ throw new Error(`Failed to resolve IP for ${hostname}: ${error instanceof Error ? error.message : "Unknown error"}`);
1448
+ }
1449
+ }
1450
+ /**
1451
+ * Extract subdomain from full hostname relative to root domain
1452
+ *
1453
+ * @example
1454
+ * extractSubdomain('api.joemoer.traflabs.io', 'traflabs.io') => 'api.joemoer'
1455
+ * extractSubdomain('joemoer.traflabs.io', 'traflabs.io') => 'joemoer'
1456
+ */
1457
+ function extractSubdomain(hostname, rootDomain) {
1458
+ if (!hostname.endsWith(rootDomain)) throw new Error(`Hostname ${hostname} is not under root domain ${rootDomain}`);
1459
+ return hostname.slice(0, -(rootDomain.length + 1)) || "@";
1460
+ }
1461
+ /**
1462
+ * Generate required DNS records for a deployment
1463
+ */
1464
+ function generateRequiredRecords(appHostnames, rootDomain, serverIp) {
1465
+ const records = [];
1466
+ for (const [appName, hostname] of appHostnames) {
1467
+ const subdomain = extractSubdomain(hostname, rootDomain);
1468
+ records.push({
1469
+ hostname,
1470
+ subdomain,
1471
+ type: "A",
1472
+ value: serverIp,
1473
+ appName
1474
+ });
1475
+ }
1476
+ return records;
1477
+ }
1478
+ /**
1479
+ * Print DNS records table
1480
+ */
1481
+ function printDnsRecordsTable(records, rootDomain) {
1482
+ logger.log(`\n 📋 DNS Records for ${rootDomain}:`);
1483
+ logger.log(" ┌─────────────────────────────────────┬──────┬─────────────────┬────────┐");
1484
+ logger.log(" │ Subdomain │ Type │ Value │ Status │");
1485
+ logger.log(" ├─────────────────────────────────────┼──────┼─────────────────┼────────┤");
1486
+ for (const record of records) {
1487
+ const subdomain = record.subdomain.padEnd(35);
1488
+ const type = record.type.padEnd(4);
1489
+ const value = record.value.padEnd(15);
1490
+ let status;
1491
+ if (record.error) status = "✗";
1492
+ else if (record.created) status = "✓ new";
1493
+ else if (record.existed) status = "✓";
1494
+ else status = "?";
1495
+ logger.log(` │ ${subdomain} │ ${type} │ ${value} │ ${status.padEnd(6)} │`);
1496
+ }
1497
+ logger.log(" └─────────────────────────────────────┴──────┴─────────────────┴────────┘");
1498
+ }
1499
+ /**
1500
+ * Print DNS records in a simple format for manual setup
1501
+ */
1502
+ function printDnsRecordsSimple(records, rootDomain) {
1503
+ logger.log("\n 📋 Required DNS Records:");
1504
+ logger.log(` Add these A records to your DNS provider (${rootDomain}):\n`);
1505
+ for (const record of records) logger.log(` ${record.subdomain} → ${record.value} (A record)`);
1506
+ logger.log("");
1507
+ }
1508
+ /**
1509
+ * Create DNS records for a single domain using its configured provider
1510
+ */
1511
+ async function createDnsRecordsForDomain(records, rootDomain, providerConfig) {
1512
+ const ttl = "ttl" in providerConfig && providerConfig.ttl ? providerConfig.ttl : 300;
1513
+ let provider;
1514
+ try {
1515
+ provider = await createDnsProvider({ config: providerConfig });
1516
+ } catch (error) {
1517
+ const message = error instanceof Error ? error.message : "Unknown error";
1518
+ logger.log(` ⚠ Failed to create DNS provider for ${rootDomain}: ${message}`);
1519
+ return records.map((r) => ({
1520
+ ...r,
1521
+ error: message
1522
+ }));
1523
+ }
1524
+ if (!provider) return records.map((r) => ({
1525
+ ...r,
1526
+ created: false,
1527
+ existed: false
1528
+ }));
1529
+ const results = [];
1530
+ const upsertRecords = records.map((r) => ({
1531
+ name: r.subdomain,
1532
+ type: r.type,
1533
+ ttl,
1534
+ value: r.value
1535
+ }));
1536
+ try {
1537
+ const upsertResults = await provider.upsertRecords(rootDomain, upsertRecords);
1538
+ for (const [i, record] of records.entries()) {
1539
+ const result = upsertResults[i];
1540
+ if (!result) {
1541
+ results.push({
1542
+ hostname: record.hostname,
1543
+ subdomain: record.subdomain,
1544
+ type: record.type,
1545
+ value: record.value,
1546
+ appName: record.appName,
1547
+ error: "No result returned from provider"
1548
+ });
1549
+ continue;
1550
+ }
1551
+ if (result.unchanged) results.push({
1552
+ hostname: record.hostname,
1553
+ subdomain: record.subdomain,
1554
+ type: record.type,
1555
+ value: record.value,
1556
+ appName: record.appName,
1557
+ existed: true,
1558
+ created: false
1559
+ });
1560
+ else results.push({
1561
+ hostname: record.hostname,
1562
+ subdomain: record.subdomain,
1563
+ type: record.type,
1564
+ value: record.value,
1565
+ appName: record.appName,
1566
+ created: result.created,
1567
+ existed: !result.created
1568
+ });
1569
+ }
1570
+ } catch (error) {
1571
+ const message = error instanceof Error ? error.message : "Unknown error";
1572
+ logger.log(` ⚠ Failed to create DNS records for ${rootDomain}: ${message}`);
1573
+ return records.map((r) => ({
1574
+ hostname: r.hostname,
1575
+ subdomain: r.subdomain,
1576
+ type: r.type,
1577
+ value: r.value,
1578
+ appName: r.appName,
1579
+ error: message
1580
+ }));
1581
+ }
1582
+ return results;
1583
+ }
1584
+ /**
1585
+ * Main DNS orchestration function for deployments
1586
+ *
1587
+ * Supports both legacy single-domain format and new multi-domain format:
1588
+ * - Legacy: { provider: 'hostinger', domain: 'example.com' }
1589
+ * - Multi: { 'example.com': { provider: 'hostinger' }, 'example.dev': { provider: 'route53' } }
1590
+ *
1591
+ * @param appHostnames - Map of app names to hostnames
1592
+ * @param dnsConfig - DNS configuration (legacy or multi-domain)
1593
+ * @param dokployEndpoint - Dokploy server endpoint to resolve IP from
1594
+ * @param state - Optional state to save created records for later deletion
1595
+ */
1596
+ async function orchestrateDns(appHostnames, dnsConfig, dokployEndpoint, state) {
1597
+ if (!dnsConfig) return null;
1598
+ const normalizedConfig = normalizeDnsConfig(dnsConfig);
1599
+ logger.log("\n🌐 Setting up DNS records...");
1600
+ let serverIp;
1601
+ try {
1602
+ const endpointUrl = new URL(dokployEndpoint);
1603
+ serverIp = await resolveHostnameToIp(endpointUrl.hostname);
1604
+ logger.log(` Server IP: ${serverIp} (from ${endpointUrl.hostname})`);
1605
+ } catch (error) {
1606
+ const message = error instanceof Error ? error.message : "Unknown error";
1607
+ logger.log(` ⚠ Failed to resolve server IP: ${message}`);
1608
+ return null;
1609
+ }
1610
+ const groupedHostnames = groupHostnamesByDomain(appHostnames, normalizedConfig);
1611
+ if (groupedHostnames.size === 0) {
1612
+ logger.log(" No DNS records needed (no hostnames match configured domains)");
1613
+ return {
1614
+ records: [],
1615
+ success: true,
1616
+ serverIp
1617
+ };
1618
+ }
1619
+ const allRecords = [];
1620
+ let hasFailures = false;
1621
+ for (const [rootDomain, domainHostnames] of groupedHostnames) {
1622
+ const providerConfig = normalizedConfig[rootDomain];
1623
+ if (!providerConfig) {
1624
+ logger.log(` ⚠ No provider config for ${rootDomain}`);
1625
+ continue;
1626
+ }
1627
+ const providerName = typeof providerConfig.provider === "string" ? providerConfig.provider : "custom";
1628
+ const requiredRecords = generateRequiredRecords(domainHostnames, rootDomain, serverIp);
1629
+ if (requiredRecords.length === 0) continue;
1630
+ logger.log(` Creating DNS records for ${rootDomain} (${providerName})...`);
1631
+ const domainRecords = await createDnsRecordsForDomain(requiredRecords, rootDomain, providerConfig);
1632
+ allRecords.push(...domainRecords);
1633
+ const created = domainRecords.filter((r) => r.created).length;
1634
+ const existed = domainRecords.filter((r) => r.existed).length;
1635
+ const failed = domainRecords.filter((r) => r.error).length;
1636
+ if (created > 0) logger.log(` ✓ Created ${created} DNS record(s) for ${rootDomain}`);
1637
+ if (existed > 0) logger.log(` ✓ ${existed} record(s) already exist for ${rootDomain}`);
1638
+ if (failed > 0) {
1639
+ logger.log(` ⚠ ${failed} record(s) failed for ${rootDomain}`);
1640
+ hasFailures = true;
1641
+ }
1642
+ if (state) {
1643
+ for (const record of domainRecords) if (record.created || record.existed) setDnsRecord(state, {
1644
+ domain: rootDomain,
1645
+ name: record.subdomain,
1646
+ type: record.type,
1647
+ value: record.value,
1648
+ ttl: "ttl" in providerConfig && providerConfig.ttl ? providerConfig.ttl : 300
1649
+ });
1650
+ }
1651
+ printDnsRecordsTable(domainRecords, rootDomain);
1652
+ if (providerConfig.provider === "manual" || failed > 0) printDnsRecordsSimple(domainRecords.filter((r) => !r.created && !r.existed), rootDomain);
1653
+ }
1654
+ return {
1655
+ records: allRecords,
1656
+ success: !hasFailures,
1657
+ serverIp
1658
+ };
1659
+ }
1660
+ /**
1661
+ * Verify DNS records resolve correctly after deployment.
1662
+ *
1663
+ * This function:
1664
+ * 1. Checks state for previously verified hostnames (skips if already verified with same IP)
1665
+ * 2. Attempts to resolve each hostname to an IP
1666
+ * 3. Compares resolved IP with expected server IP
1667
+ * 4. Updates state with verification results
1668
+ *
1669
+ * @param appHostnames - Map of app names to hostnames
1670
+ * @param serverIp - Expected IP address the hostnames should resolve to
1671
+ * @param state - Deploy state for caching verification results
1672
+ * @returns Array of verification results
1673
+ */
1674
+ async function verifyDnsRecords(appHostnames, serverIp, state) {
1675
+ const results = [];
1676
+ logger.log("\n🔍 Verifying DNS records...");
1677
+ for (const [appName, hostname] of appHostnames) {
1678
+ if (isDnsVerified(state, hostname, serverIp)) {
1679
+ logger.log(` ✓ ${hostname} (previously verified)`);
1680
+ results.push({
1681
+ hostname,
1682
+ appName,
1683
+ verified: true,
1684
+ expectedIp: serverIp,
1685
+ skipped: true
1686
+ });
1687
+ continue;
1688
+ }
1689
+ try {
1690
+ const resolvedIp = await resolveHostnameToIp(hostname);
1691
+ if (resolvedIp === serverIp) {
1692
+ setDnsVerification(state, hostname, serverIp);
1693
+ logger.log(` ✓ ${hostname} → ${resolvedIp}`);
1694
+ results.push({
1695
+ hostname,
1696
+ appName,
1697
+ verified: true,
1698
+ resolvedIp,
1699
+ expectedIp: serverIp
1700
+ });
1701
+ } else {
1702
+ logger.log(` ⚠ ${hostname} resolves to ${resolvedIp}, expected ${serverIp}`);
1703
+ results.push({
1704
+ hostname,
1705
+ appName,
1706
+ verified: false,
1707
+ resolvedIp,
1708
+ expectedIp: serverIp
1709
+ });
1710
+ }
1711
+ } catch (error) {
1712
+ const message = error instanceof Error ? error.message : "Unknown error";
1713
+ logger.log(` ⚠ ${hostname} DNS not propagated (${message})`);
1714
+ results.push({
1715
+ hostname,
1716
+ appName,
1717
+ verified: false,
1718
+ expectedIp: serverIp,
1719
+ error: message
1720
+ });
1721
+ }
1722
+ }
1723
+ const verified = results.filter((r) => r.verified).length;
1724
+ const skipped = results.filter((r) => r.skipped).length;
1725
+ const pending = results.filter((r) => !r.verified).length;
1726
+ if (pending > 0) {
1727
+ logger.log(`\n ${verified} verified, ${pending} pending propagation`);
1728
+ logger.log(" DNS changes may take 5-30 minutes to propagate");
1729
+ } else if (skipped > 0) logger.log(` ${verified} verified (${skipped} from cache)`);
1730
+ return results;
1731
+ }
1732
+ //#endregion
1733
+ //#region src/deploy/credentials.ts
1734
+ /**
1735
+ * How a deploy gets the credentials it acts with.
1736
+ *
1737
+ * `deploy()` never prompts and never reads a terminal: it asks a
1738
+ * `CredentialProvider` and, when the provider has nothing, stops with
1739
+ * `MissingCredential` naming what it needed and how to supply it. Whether to
1740
+ * ask a person, read a vault or fail is the caller's decision — `gkm deploy`
1741
+ * prompts at a terminal and stores what was typed; a CI job sets the
1742
+ * environment; a host passes its own provider.
1743
+ */
1744
+ /**
1745
+ * How to supply each kind the CLI knows, for the error that says it is
1746
+ * missing. A target's own kinds are its to explain.
1747
+ */
1748
+ const HOW_TO_PROVIDE = {
1749
+ dokploy: "Set DOKPLOY_API_TOKEN (and DOKPLOY_ENDPOINT, or deploy.dokploy.endpoint in gkm.config.ts), run `gkm login --provider dokploy`, or pass them through the deploy's CredentialProvider.",
1750
+ registry: "Add the registry in Dokploy (Settings → Docker Registry) and set deploy.dokploy.registryId, set DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD, or run `gkm deploy` at a terminal to be asked for them.",
1751
+ godaddy: "Set GODADDY_API_TOKEN to a Personal Access Token scoped to domains.dns:update (create one in the GoDaddy developer dashboard), or run `gkm login --provider godaddy`.",
1752
+ hostinger: "Set HOSTINGER_API_TOKEN to a token from hpanel.hostinger.com/profile/api, or run `gkm login --provider hostinger`.",
1753
+ aws: "Set AWS_PROFILE to the stage account's profile, or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (and AWS_SESSION_TOKEN) — in CI, the keys aws-actions/configure-aws-credentials exports — or pass them through the deploy's CredentialProvider."
1754
+ };
1755
+ /** A deploy needed a credential, and its provider had none. */
1756
+ var MissingCredential = class extends GkmError {
1757
+ kind;
1758
+ target;
1759
+ howToProvide;
1760
+ constructor(kind, target, howToProvide = HOW_TO_PROVIDE[kind] ?? "Pass it through the deploy's CredentialProvider.") {
1761
+ const what = kind === "dokploy" ? `No Dokploy credentials${target ? ` for ${target}` : ""}.` : kind === "registry" ? `Dokploy has no registry for ${target ?? "the configured registry"}, and there are no credentials to create one with.` : kind === "aws" ? `No AWS credentials${target ? ` for the "${target}" stage` : ""}.` : kind === "godaddy" ? `No GoDaddy API token${target ? ` for ${target}` : ""}.` : kind === "hostinger" ? `No Hostinger API token${target ? ` for ${target}` : ""}.` : `No "${String(kind)}" credentials${target ? ` for ${target}` : ""}.`;
1762
+ super(`${what} ${howToProvide}`);
1763
+ this.kind = kind;
1764
+ this.target = target;
1765
+ this.howToProvide = howToProvide;
1766
+ this.name = "MissingCredential";
1767
+ }
1768
+ };
1769
+ /** Whatever was asked for, from the first provider that has it. */
1770
+ function chainCredentials(...providers) {
1771
+ return { async get(request, options) {
1772
+ for (const provider of providers) {
1773
+ const found = await provider.get(request, options);
1774
+ if (found) return found;
1775
+ }
1776
+ } };
1777
+ }
1778
+ /**
1779
+ * Credentials from the environment, then from what `gkm login` stored. What
1780
+ * `deploy()` uses when it is handed no provider.
1781
+ *
1782
+ * - Dokploy: `DOKPLOY_API_TOKEN` / `DOKPLOY_ENDPOINT`, each falling back to
1783
+ * the stored login, and the endpoint finally to `deploy.dokploy.endpoint`.
1784
+ * Each half is read on its own: a token is a secret and belongs in the
1785
+ * environment, an endpoint is configuration and belongs in the config.
1786
+ * - Registry: `DOCKER_REGISTRY_USERNAME` / `DOCKER_REGISTRY_PASSWORD`.
1787
+ * - AWS: `AWS_PROFILE` when it is set, and then nothing else; otherwise
1788
+ * `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`. The
1789
+ * profile winning is `secretsStoreFor`'s rule: a profile is a choice of
1790
+ * account someone made, exported keys may be left over from another.
1791
+ * Read here, by name, and handed only to the command that deploys — the
1792
+ * sandbox every other step runs in passes no `AWS_*` on.
1793
+ */
1794
+ function storedCredentials(options = {}) {
1795
+ const env = options.env ?? process.env;
1796
+ return { async get(asked) {
1797
+ const request = asked;
1798
+ switch (request.kind) {
1799
+ case "dokploy": {
1800
+ const stored = (await readCredentials(options.home ? { home: options.home } : void 0)).dokploy;
1801
+ const token = env.DOKPLOY_API_TOKEN ?? stored?.token;
1802
+ const endpoint = env.DOKPLOY_ENDPOINT ?? stored?.endpoint ?? request.endpoint;
1803
+ if (!token || !endpoint) return void 0;
1804
+ return {
1805
+ endpoint: endpoint.replace(/\/$/, ""),
1806
+ token
1807
+ };
1808
+ }
1809
+ case "registry": {
1810
+ const username = env.DOCKER_REGISTRY_USERNAME;
1811
+ const password = env.DOCKER_REGISTRY_PASSWORD;
1812
+ if (!username || !password) return void 0;
1813
+ return {
1814
+ username,
1815
+ password
1816
+ };
1817
+ }
1818
+ case "godaddy": {
1819
+ const token = env.GODADDY_API_TOKEN || (await readCredentials(options.home ? { home: options.home } : void 0)).godaddy?.token;
1820
+ if (!token) return void 0;
1821
+ return { token };
1822
+ }
1823
+ case "hostinger": {
1824
+ const token = env.HOSTINGER_API_TOKEN || (await readCredentials(options.home ? { home: options.home } : void 0)).hostinger?.token;
1825
+ if (!token) return void 0;
1826
+ return { token };
1827
+ }
1828
+ case "aws": {
1829
+ const region = env.AWS_REGION ?? env.AWS_DEFAULT_REGION;
1830
+ const where = region ? { region } : {};
1831
+ if (env.AWS_PROFILE) return {
1832
+ profile: env.AWS_PROFILE,
1833
+ ...where
1834
+ };
1835
+ const accessKeyId = env.AWS_ACCESS_KEY_ID;
1836
+ const secretAccessKey = env.AWS_SECRET_ACCESS_KEY;
1837
+ if (!accessKeyId || !secretAccessKey) return void 0;
1838
+ return {
1839
+ accessKeyId,
1840
+ secretAccessKey,
1841
+ ...env.AWS_SESSION_TOKEN ? { sessionToken: env.AWS_SESSION_TOKEN } : {},
1842
+ ...where
1843
+ };
1844
+ }
1845
+ }
1846
+ } };
1847
+ }
1848
+ //#endregion
1849
+ export { readKey as $, eventsBackendFor as A, toEmbeddableSecrets as B, setPostgresBackupId as C, storeHostingerToken as Ct, originSecretKey as D, newOriginSecret as E, storeFromConfig as F, FileSecretsStore as G, bundleExternals as H, store_exports as I, getKeyPath as J, decrypt as K, initStageSecrets as L, storageBackendFor as M, isRemoteStore as N, processorOriginHost as O, secretsStoreFor as P, projectKey as Q, maskPassword as R, setGeneratedSecret as S, storeGoDaddyToken as St, PROCESSOR_ORIGIN_SECRET_ENV as T, gkmHome as Tt, externalsManifestName as U, withCustomSecret as V, importedPackages as W, getOrCreateKey as X, getKeystoreDir as Y, keystoreProject as Z, getGeneratedSecret as _, getHostingerToken as _t, findRootDomain as a, markerOf as at, setApplicationId as b, removeGoDaddyCredentials as bt, verifyDnsRecords as c, CommandFailed as ct, mxValue as d, run as dt, applicationName as et, parseMxValue as f, runOutput as ft, getBackupState as g, getDokployToken as gt, createEmptyState as h, getDokployRegistryId as ht, extractSubdomain as i, isOwnedBy as it, providerOf as j, cacheBackendFor as k, DnsRecordsUnreadable as l, CommandTimedOut as lt, createComposeState as m, getDokployCredentials as mt, chainCredentials as n, imageName as nt, normalizeDnsConfig as o, ownershipMarker as ot, asDokployState as p, getCredentialsPath as pt, encrypt as q, storedCredentials as r, imageRef as rt, orchestrateDns as s, projectName as st, MissingCredential as t, deployIdentity as tt, createDnsProvider as u, DEFAULT_TIMEOUT_MS as ut, recordRelease as v, readCredentials as vt, ORIGIN_VERIFY_HEADER as w, GKM_HOME_ENV as wt, setBackupState as x, storeDokployCredentials as xt, recordRollback as y, removeDokployCredentials as yt, storage_exports as z };
1850
+
1851
+ //# sourceMappingURL=credentials-CWa7hRXd.mjs.map