@geekmidas/cli 10.0.0-alpha.16 → 10.0.0-alpha.161

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