@geekmidas/cli 10.0.0-alpha.184 → 10.0.0-alpha.185

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 (245) hide show
  1. package/dist/{LegacyStateStore-BtDLNkIH.cjs → LegacyStateStore-BtN83gfS.cjs} +2 -2
  2. package/dist/{LegacyStateStore-BtDLNkIH.cjs.map → LegacyStateStore-BtN83gfS.cjs.map} +1 -1
  3. package/dist/{LegacyStateStore-CTfoMtC2.mjs → LegacyStateStore-DKyEAWGI.mjs} +2 -2
  4. package/dist/{LegacyStateStore-CTfoMtC2.mjs.map → LegacyStateStore-DKyEAWGI.mjs.map} +1 -1
  5. package/dist/{LocalStateStore-BKp45OoB.cjs → LocalStateStore-BFh6rPhX.cjs} +2 -2
  6. package/dist/{LocalStateStore-BKp45OoB.cjs.map → LocalStateStore-BFh6rPhX.cjs.map} +1 -1
  7. package/dist/{LocalStateStore-C4zDHVM-.mjs → LocalStateStore-Dc3aGvQi.mjs} +2 -2
  8. package/dist/{LocalStateStore-C4zDHVM-.mjs.map → LocalStateStore-Dc3aGvQi.mjs.map} +1 -1
  9. package/dist/{S3StateStore-B6SjbLxh.cjs → S3StateStore-DZMpqbvD.cjs} +5 -5
  10. package/dist/{S3StateStore-B6SjbLxh.cjs.map → S3StateStore-DZMpqbvD.cjs.map} +1 -1
  11. package/dist/{S3StateStore-S0TXLlMW.mjs → S3StateStore-p6DyuAFZ.mjs} +4 -4
  12. package/dist/{S3StateStore-S0TXLlMW.mjs.map → S3StateStore-p6DyuAFZ.mjs.map} +1 -1
  13. package/dist/{SSMStateStore-ClPHFhRQ.mjs → SSMStateStore-BvH8XX4O.mjs} +2 -2
  14. package/dist/{SSMStateStore-ClPHFhRQ.mjs.map → SSMStateStore-BvH8XX4O.mjs.map} +1 -1
  15. package/dist/{SSMStateStore-6Di_zxwC.cjs → SSMStateStore-sbaLlCmj.cjs} +2 -2
  16. package/dist/{SSMStateStore-6Di_zxwC.cjs.map → SSMStateStore-sbaLlCmj.cjs.map} +1 -1
  17. package/dist/{add-Bd9MDHuU.cjs → add-CdVGxiKW.cjs} +13 -14
  18. package/dist/{add-Bd9MDHuU.cjs.map → add-CdVGxiKW.cjs.map} +1 -1
  19. package/dist/{add-BR8XW4IH.mjs → add-dOvgsAU6.mjs} +4 -5
  20. package/dist/{add-BR8XW4IH.mjs.map → add-dOvgsAU6.mjs.map} +1 -1
  21. package/dist/backups/runner.cjs +501 -13
  22. package/dist/backups/runner.cjs.map +1 -1
  23. package/dist/backups/runner.d.cts +87 -2
  24. package/dist/backups/runner.d.cts.map +1 -1
  25. package/dist/backups/runner.d.mts +87 -2
  26. package/dist/backups/runner.d.mts.map +1 -1
  27. package/dist/backups/runner.mjs +493 -15
  28. package/dist/backups/runner.mjs.map +1 -1
  29. package/dist/{bundler-4E-CGdL3.cjs → bundler-B5ioF-1Q.cjs} +9 -9
  30. package/dist/{bundler-4E-CGdL3.cjs.map → bundler-B5ioF-1Q.cjs.map} +1 -1
  31. package/dist/{bundler-Cwr4YSpp.mjs → bundler-Cvx6Bt3e.mjs} +6 -6
  32. package/dist/{bundler-Cwr4YSpp.mjs.map → bundler-Cvx6Bt3e.mjs.map} +1 -1
  33. package/dist/{cli-C3mHXsAE.mjs → cli-BjapgcXG.mjs} +4 -4
  34. package/dist/{cli-C3mHXsAE.mjs.map → cli-BjapgcXG.mjs.map} +1 -1
  35. package/dist/{cli-CrPJr29x.cjs → cli-PLhqvPOC.cjs} +6 -6
  36. package/dist/{cli-CrPJr29x.cjs.map → cli-PLhqvPOC.cjs.map} +1 -1
  37. package/dist/{clientTelemetry-Ej1tf1VE.d.cts → clientTelemetry-Bzc4KXz5.d.mts} +2 -2
  38. package/dist/clientTelemetry-Bzc4KXz5.d.mts.map +1 -0
  39. package/dist/{clientTelemetry-crdjgehZ.d.mts → clientTelemetry-N8NAguGI.d.cts} +2 -2
  40. package/dist/clientTelemetry-N8NAguGI.d.cts.map +1 -0
  41. package/dist/{compose-CKBieltT.cjs → compose-BEVBxf4w.cjs} +87 -948
  42. package/dist/compose-BEVBxf4w.cjs.map +1 -0
  43. package/dist/{compose-DPXoarGI.mjs → compose-Dx_nSZYU.mjs} +23 -842
  44. package/dist/compose-Dx_nSZYU.mjs.map +1 -0
  45. package/dist/{config-q4ewzIA_.d.mts → config-CTrfNKYd.d.mts} +3 -3
  46. package/dist/{config-lSOwPbUy.d.cts.map → config-CTrfNKYd.d.mts.map} +1 -1
  47. package/dist/{config-lSOwPbUy.d.cts → config-D9g_nYIu.d.cts} +3 -3
  48. package/dist/{config-q4ewzIA_.d.mts.map → config-D9g_nYIu.d.cts.map} +1 -1
  49. package/dist/config.cjs +1 -1
  50. package/dist/config.d.cts +3 -3
  51. package/dist/config.d.mts +3 -3
  52. package/dist/config.mjs +1 -1
  53. package/dist/{compose-CJznzQc7.mjs → credentials-DW5MvS4A.mjs} +1148 -1261
  54. package/dist/credentials-DW5MvS4A.mjs.map +1 -0
  55. package/dist/{compose-CvNyjqwL.cjs → credentials-Eyx2tM7B.cjs} +1175 -1288
  56. package/dist/credentials-Eyx2tM7B.cjs.map +1 -0
  57. package/dist/{dns-BzYrbB2Y.cjs → credentials-n2abUWwJ.cjs} +6 -847
  58. package/dist/credentials-n2abUWwJ.cjs.map +1 -0
  59. package/dist/{dns-C0wbTjVX.mjs → credentials-ztezRtR4.mjs} +5 -708
  60. package/dist/credentials-ztezRtR4.mjs.map +1 -0
  61. package/dist/{dbTunnel-DSzAG_wy.cjs → dbTunnel-DVohSZJQ.cjs} +8 -9
  62. package/dist/{dbTunnel-DSzAG_wy.cjs.map → dbTunnel-DVohSZJQ.cjs.map} +1 -1
  63. package/dist/{dbTunnel-CphoKGyk.mjs → dbTunnel-bV1CPWUv.mjs} +5 -6
  64. package/dist/{dbTunnel-CphoKGyk.mjs.map → dbTunnel-bV1CPWUv.mjs.map} +1 -1
  65. package/dist/deploy/public.cjs +25 -26
  66. package/dist/deploy/public.cjs.map +1 -1
  67. package/dist/deploy/public.d.cts +5 -5
  68. package/dist/deploy/public.d.mts +5 -5
  69. package/dist/deploy/public.mjs +10 -11
  70. package/dist/deploy/public.mjs.map +1 -1
  71. package/dist/{deploy-BaSYxpny.cjs → deploy-CDUWcl58.cjs} +72 -62
  72. package/dist/deploy-CDUWcl58.cjs.map +1 -0
  73. package/dist/{deploy-C_uZBzvS.mjs → deploy-Cpz5sKbh.mjs} +25 -15
  74. package/dist/deploy-Cpz5sKbh.mjs.map +1 -0
  75. package/dist/{destroy-yTBmL1jf.mjs → destroy-DRlcWJwm.mjs} +9 -9
  76. package/dist/{destroy-yTBmL1jf.mjs.map → destroy-DRlcWJwm.mjs.map} +1 -1
  77. package/dist/{destroy-PvrHxZDu.cjs → destroy-DzeV0EdY.cjs} +21 -21
  78. package/dist/{destroy-PvrHxZDu.cjs.map → destroy-DzeV0EdY.cjs.map} +1 -1
  79. package/dist/{dokploy-DYUMx2MY.cjs → dokploy-BTNfj3Zt.cjs} +2 -2
  80. package/dist/{dokploy-DYUMx2MY.cjs.map → dokploy-BTNfj3Zt.cjs.map} +1 -1
  81. package/dist/{dokploy-DqL3jeDu.mjs → dokploy-BveqiW2h.mjs} +2 -2
  82. package/dist/{dokploy-DqL3jeDu.mjs.map → dokploy-BveqiW2h.mjs.map} +1 -1
  83. package/dist/{eas-DHDU86PL.mjs → eas-BmYTfjY6.mjs} +3 -3
  84. package/dist/{eas-DHDU86PL.mjs.map → eas-BmYTfjY6.mjs.map} +1 -1
  85. package/dist/{eas-DEM-iWg6.cjs → eas-Dt_vRzb4.cjs} +3 -3
  86. package/dist/{eas-DEM-iWg6.cjs.map → eas-Dt_vRzb4.cjs.map} +1 -1
  87. package/dist/{encryption-BKWmbKkN.cjs → encryption-BE2wxfyH.cjs} +6 -6
  88. package/dist/{encryption-BKWmbKkN.cjs.map → encryption-BE2wxfyH.cjs.map} +1 -1
  89. package/dist/{encryption-CbMprdAb.mjs → encryption-DqoQltP8.mjs} +3 -3
  90. package/dist/{encryption-CbMprdAb.mjs.map → encryption-DqoQltP8.mjs.map} +1 -1
  91. package/dist/{engine-DaI4iScI.mjs → engine-B72vyrO8.mjs} +7 -9
  92. package/dist/{engine-DaI4iScI.mjs.map → engine-B72vyrO8.mjs.map} +1 -1
  93. package/dist/{engine-3imTFxdN.cjs → engine-BevpkNZe.cjs} +100 -102
  94. package/dist/{engine-3imTFxdN.cjs.map → engine-BevpkNZe.cjs.map} +1 -1
  95. package/dist/{github-Y6NAwHG1.cjs → github-DoHdtsDX.cjs} +18 -18
  96. package/dist/{github-Y6NAwHG1.cjs.map → github-DoHdtsDX.cjs.map} +1 -1
  97. package/dist/{github-Dijjr__H.mjs → github-hxvid6J3.mjs} +7 -7
  98. package/dist/{github-Dijjr__H.mjs.map → github-hxvid6J3.mjs.map} +1 -1
  99. package/dist/{googlePlay-Dcp3Yycu.cjs → googlePlay-CYney-Of.cjs} +5 -5
  100. package/dist/{googlePlay-Dcp3Yycu.cjs.map → googlePlay-CYney-Of.cjs.map} +1 -1
  101. package/dist/{googlePlay-SDT3j9Kf.mjs → googlePlay-DsvZTWgP.mjs} +4 -4
  102. package/dist/{googlePlay-SDT3j9Kf.mjs.map → googlePlay-DsvZTWgP.mjs.map} +1 -1
  103. package/dist/{iam-CqW9hsd2.mjs → iam-DloEBLXZ.mjs} +2 -2
  104. package/dist/{iam-CqW9hsd2.mjs.map → iam-DloEBLXZ.mjs.map} +1 -1
  105. package/dist/{iam-DeBQcSvw.cjs → iam-SxPKYCI_.cjs} +2 -2
  106. package/dist/{iam-DeBQcSvw.cjs.map → iam-SxPKYCI_.cjs.map} +1 -1
  107. package/dist/{index-DJzVO6Ht.d.cts → index-BThTZV8T.d.mts} +2 -2
  108. package/dist/{index-Ccsgoq3_.d.mts.map → index-BThTZV8T.d.mts.map} +1 -1
  109. package/dist/{index-Ccsgoq3_.d.mts → index-Cgd-ouyI.d.cts} +2 -2
  110. package/dist/{index-DJzVO6Ht.d.cts.map → index-Cgd-ouyI.d.cts.map} +1 -1
  111. package/dist/index.cjs +590 -246
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.mjs +443 -99
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/{local-DjaAcHZb.cjs → local-BuR4fIW6.cjs} +3 -3
  116. package/dist/{local-DjaAcHZb.cjs.map → local-BuR4fIW6.cjs.map} +1 -1
  117. package/dist/{local-4gzM52HT.mjs → local-Cmq75U_o.mjs} +2 -2
  118. package/dist/{local-4gzM52HT.mjs.map → local-Cmq75U_o.mjs.map} +1 -1
  119. package/dist/{migrate-0Rfhftef.mjs → migrate-Bf-EG8Fj.mjs} +5 -5
  120. package/dist/{migrate-0Rfhftef.mjs.map → migrate-Bf-EG8Fj.mjs.map} +1 -1
  121. package/dist/{migrate-DDIc3twm.cjs → migrate-CDMdrniJ.cjs} +13 -13
  122. package/dist/{migrate-DDIc3twm.cjs.map → migrate-CDMdrniJ.cjs.map} +1 -1
  123. package/dist/{migrate-CuHGYJL9.cjs → migrate-CuTQha4s.cjs} +6 -6
  124. package/dist/{migrate-CuHGYJL9.cjs.map → migrate-CuTQha4s.cjs.map} +1 -1
  125. package/dist/{migrate-BLW4BwLd.mjs → migrate-DYJffHOm.mjs} +3 -3
  126. package/dist/{migrate-BLW4BwLd.mjs.map → migrate-DYJffHOm.mjs.map} +1 -1
  127. package/dist/openapi.cjs +1 -1
  128. package/dist/openapi.d.cts +2 -2
  129. package/dist/openapi.d.mts +2 -2
  130. package/dist/openapi.mjs +1 -1
  131. package/dist/{projectBucket-BhEOVVch.mjs → projectBucket-B5YkuSVr.mjs} +2 -2
  132. package/dist/{projectBucket-BhEOVVch.mjs.map → projectBucket-B5YkuSVr.mjs.map} +1 -1
  133. package/dist/{projectBucket-C5Ap5kGw.cjs → projectBucket-NcgqleyH.cjs} +2 -2
  134. package/dist/{projectBucket-C5Ap5kGw.cjs.map → projectBucket-NcgqleyH.cjs.map} +1 -1
  135. package/dist/{publish-BELe2FO2.cjs → publish--EQ4Tw3F.cjs} +2 -2
  136. package/dist/{publish-BELe2FO2.cjs.map → publish--EQ4Tw3F.cjs.map} +1 -1
  137. package/dist/{publish-DiDv40hA.mjs → publish-YL8WZHSo.mjs} +2 -2
  138. package/dist/{publish-DiDv40hA.mjs.map → publish-YL8WZHSo.mjs.map} +1 -1
  139. package/dist/{ready--_hMxbUX.cjs → ready-DCvnFZnJ.cjs} +2 -2
  140. package/dist/{ready--_hMxbUX.cjs.map → ready-DCvnFZnJ.cjs.map} +1 -1
  141. package/dist/{ready-CjIqXFXe.mjs → ready-sSPuiZ7N.mjs} +2 -2
  142. package/dist/{ready-CjIqXFXe.mjs.map → ready-sSPuiZ7N.mjs.map} +1 -1
  143. package/dist/reconcile/public.d.cts +1 -1
  144. package/dist/reconcile/public.d.mts +1 -1
  145. package/dist/{resolve-DIPHwLan.cjs → resolve-Ced8-gj4.cjs} +4 -4
  146. package/dist/{resolve-DIPHwLan.cjs.map → resolve-Ced8-gj4.cjs.map} +1 -1
  147. package/dist/{resolve-N8EZzWqJ.mjs → resolve-DcG10_JV.mjs} +4 -4
  148. package/dist/{resolve-N8EZzWqJ.mjs.map → resolve-DcG10_JV.mjs.map} +1 -1
  149. package/dist/{rollback-DIeA6dba.mjs → rollback-BxI2p53H.mjs} +7 -6
  150. package/dist/{rollback-DIeA6dba.mjs.map → rollback-BxI2p53H.mjs.map} +1 -1
  151. package/dist/{rollback-Bp6hepUh.cjs → rollback-C6bCANv7.cjs} +10 -9
  152. package/dist/{rollback-Bp6hepUh.cjs.map → rollback-C6bCANv7.cjs.map} +1 -1
  153. package/dist/{runtime-D_UphAAH.d.cts → runtime-BtoiRP5G.d.cts} +2 -2
  154. package/dist/{runtime-BZlClwy2.d.mts.map → runtime-BtoiRP5G.d.cts.map} +1 -1
  155. package/dist/{runtime-BZlClwy2.d.mts → runtime-Ct41f0tN.d.mts} +2 -2
  156. package/dist/{runtime-D_UphAAH.d.cts.map → runtime-Ct41f0tN.d.mts.map} +1 -1
  157. package/dist/{s3-CIEf4puu.mjs → s3-BAI0ELtE.mjs} +3 -3
  158. package/dist/{s3-CIEf4puu.mjs.map → s3-BAI0ELtE.mjs.map} +1 -1
  159. package/dist/{s3-Bwd6lhTU.cjs → s3-DucPHZAn.cjs} +3 -3
  160. package/dist/{s3-Bwd6lhTU.cjs.map → s3-DucPHZAn.cjs.map} +1 -1
  161. package/dist/{serverSetup-C9DP30J4.cjs → serverSetup-D3-FE7Dj.cjs} +9 -8
  162. package/dist/{serverSetup-C9DP30J4.cjs.map → serverSetup-D3-FE7Dj.cjs.map} +1 -1
  163. package/dist/{serverSetup-mRCLdZQW.mjs → serverSetup-DS9tW50_.mjs} +7 -6
  164. package/dist/{serverSetup-mRCLdZQW.mjs.map → serverSetup-DS9tW50_.mjs.map} +1 -1
  165. package/dist/{sniffer-01tbQFmg.mjs → sniffer-CX8sI8Cu.mjs} +7 -7
  166. package/dist/{sniffer-01tbQFmg.mjs.map → sniffer-CX8sI8Cu.mjs.map} +1 -1
  167. package/dist/{sniffer-CkPIytPI.cjs → sniffer-XlvJLrhZ.cjs} +7 -7
  168. package/dist/{sniffer-CkPIytPI.cjs.map → sniffer-XlvJLrhZ.cjs.map} +1 -1
  169. package/dist/{snsSubscriptions-DmKrw7AF.cjs → snsSubscriptions-CJAOhWq9.cjs} +11 -12
  170. package/dist/{snsSubscriptions-DmKrw7AF.cjs.map → snsSubscriptions-CJAOhWq9.cjs.map} +1 -1
  171. package/dist/{snsSubscriptions-k61hsIRw.mjs → snsSubscriptions-DDrra9rN.mjs} +3 -4
  172. package/dist/{snsSubscriptions-k61hsIRw.mjs.map → snsSubscriptions-DDrra9rN.mjs.map} +1 -1
  173. package/dist/{sst-CvOnXAel.mjs → sst-CdHflajE.mjs} +6 -6
  174. package/dist/{sst-CvOnXAel.mjs.map → sst-CdHflajE.mjs.map} +1 -1
  175. package/dist/{sst-DGsteg5j.cjs → sst-CsEjVFtz.cjs} +8 -8
  176. package/dist/{sst-DGsteg5j.cjs.map → sst-CsEjVFtz.cjs.map} +1 -1
  177. package/dist/stack-BYhtz-bE.cjs +11449 -0
  178. package/dist/stack-BYhtz-bE.cjs.map +1 -0
  179. package/dist/stack-CLHY-_2m.mjs +10474 -0
  180. package/dist/stack-CLHY-_2m.mjs.map +1 -0
  181. package/dist/{stage-8KJCtYtl.cjs → stage-Bc_BtQeG.cjs} +11 -12
  182. package/dist/stage-Bc_BtQeG.cjs.map +1 -0
  183. package/dist/{stage-CXIdtjY2.mjs → stage-C7aYyDMr.mjs} +5 -6
  184. package/dist/stage-C7aYyDMr.mjs.map +1 -0
  185. package/dist/{stages-BNoiMXfL.mjs → stages-DFvE7iEO.mjs} +2 -2
  186. package/dist/{stages-BNoiMXfL.mjs.map → stages-DFvE7iEO.mjs.map} +1 -1
  187. package/dist/{stages-tdJKM9qp.cjs → stages-Dk6Lv7DY.cjs} +2 -2
  188. package/dist/{stages-tdJKM9qp.cjs.map → stages-Dk6Lv7DY.cjs.map} +1 -1
  189. package/dist/target/public.cjs +1 -1
  190. package/dist/target/public.d.cts +2 -2
  191. package/dist/target/public.d.mts +2 -2
  192. package/dist/target/public.mjs +1 -1
  193. package/dist/{terminal-GzAW5lzO.mjs → terminal-BZzK69T9.mjs} +2 -2
  194. package/dist/{terminal-GzAW5lzO.mjs.map → terminal-BZzK69T9.mjs.map} +1 -1
  195. package/dist/{terminal-DSQgidon.cjs → terminal-DXUXlqrO.cjs} +5 -5
  196. package/dist/{terminal-DSQgidon.cjs.map → terminal-DXUXlqrO.cjs.map} +1 -1
  197. package/dist/{types-BRnmoWCt.d.cts → types-BVDaaLas.d.cts} +22 -4
  198. package/dist/{types-BRnmoWCt.d.cts.map → types-BVDaaLas.d.cts.map} +1 -1
  199. package/dist/{types-Bg7LSAD2.d.mts → types-CJTKWLkK.d.mts} +22 -4
  200. package/dist/{types-Bg7LSAD2.d.mts.map → types-CJTKWLkK.d.mts.map} +1 -1
  201. package/dist/{utils-D_fxUqvU.mjs → utils-CdKxD8Lt.mjs} +2 -2
  202. package/dist/{utils-D_fxUqvU.mjs.map → utils-CdKxD8Lt.mjs.map} +1 -1
  203. package/dist/{utils-D2Nk1Nv2.cjs → utils-DBqXbB8P.cjs} +2 -2
  204. package/dist/{utils-D2Nk1Nv2.cjs.map → utils-DBqXbB8P.cjs.map} +1 -1
  205. package/dist/vitest.cjs +1 -1
  206. package/dist/vitest.mjs +1 -1
  207. package/dist/workspace/index.cjs +1 -1
  208. package/dist/workspace/index.d.cts +2 -2
  209. package/dist/workspace/index.d.mts +2 -2
  210. package/dist/workspace/index.mjs +1 -1
  211. package/dist/{workspace-fGwzXa5l.cjs → workspace-CTspddnJ.cjs} +55 -16
  212. package/dist/workspace-CTspddnJ.cjs.map +1 -0
  213. package/dist/{workspace-DTX6CJi2.mjs → workspace-CdiCMRap.mjs} +55 -16
  214. package/dist/workspace-CdiCMRap.mjs.map +1 -0
  215. package/package.json +16 -16
  216. package/dist/apps-CXzjaPWR.mjs +0 -4650
  217. package/dist/apps-CXzjaPWR.mjs.map +0 -1
  218. package/dist/apps-vLzb0ZSA.cjs +0 -5174
  219. package/dist/apps-vLzb0ZSA.cjs.map +0 -1
  220. package/dist/clientTelemetry-Ej1tf1VE.d.cts.map +0 -1
  221. package/dist/clientTelemetry-crdjgehZ.d.mts.map +0 -1
  222. package/dist/compose-CJznzQc7.mjs.map +0 -1
  223. package/dist/compose-CKBieltT.cjs.map +0 -1
  224. package/dist/compose-CvNyjqwL.cjs.map +0 -1
  225. package/dist/compose-DPXoarGI.mjs.map +0 -1
  226. package/dist/deploy-BaSYxpny.cjs.map +0 -1
  227. package/dist/deploy-C_uZBzvS.mjs.map +0 -1
  228. package/dist/dns-BzYrbB2Y.cjs.map +0 -1
  229. package/dist/dns-C0wbTjVX.mjs.map +0 -1
  230. package/dist/docker-CPoUMg5X.mjs +0 -1649
  231. package/dist/docker-CPoUMg5X.mjs.map +0 -1
  232. package/dist/docker-CrhpQWnL.cjs +0 -1798
  233. package/dist/docker-CrhpQWnL.cjs.map +0 -1
  234. package/dist/notes-6F8YXU8m.mjs +0 -409
  235. package/dist/notes-6F8YXU8m.mjs.map +0 -1
  236. package/dist/notes-DMOLnNJI.cjs +0 -510
  237. package/dist/notes-DMOLnNJI.cjs.map +0 -1
  238. package/dist/stack-Dd-egttk.mjs +0 -1777
  239. package/dist/stack-Dd-egttk.mjs.map +0 -1
  240. package/dist/stack-vBnc84e8.cjs +0 -1887
  241. package/dist/stack-vBnc84e8.cjs.map +0 -1
  242. package/dist/stage-8KJCtYtl.cjs.map +0 -1
  243. package/dist/stage-CXIdtjY2.mjs.map +0 -1
  244. package/dist/workspace-DTX6CJi2.mjs.map +0 -1
  245. package/dist/workspace-fGwzXa5l.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-ztezRtR4.mjs","names":[],"sources":["../src/home.ts","../src/auth/credentials.ts","../src/deploy/identity.ts","../src/secrets/keystore.ts","../src/secrets/file.ts","../src/build/native.ts","../src/secrets/storage.ts","../src/secrets/store.ts","../src/workspace/backends.ts","../src/deploy/credentials.ts"],"sourcesContent":["/**\n * Where the CLI keeps what belongs to a person rather than a project: stage\n * keys and stored provider credentials.\n *\n * `GKM_HOME` names it, so a CI job, a shared build runner or a test can give\n * every run its own instead of reaching into whoever's home directory the\n * process happens to have. Unset, it is `~/.gkm`, where it has always been.\n */\n\nimport { homedir } from 'node:os';\nimport { join, resolve } from 'node:path';\n\n/** The environment variable that moves the CLI's home. */\nexport const GKM_HOME_ENV = 'GKM_HOME';\n\n/** The CLI's home: `GKM_HOME` if set, else `~/.gkm`. */\nexport function gkmHome(env: NodeJS.ProcessEnv = process.env): string {\n\tconst configured = env[GKM_HOME_ENV];\n\treturn configured ? resolve(configured) : join(homedir(), '.gkm');\n}\n","import { existsSync, mkdirSync } from 'node:fs';\nimport { readFile, unlink, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { gkmHome } from '../home';\n\n/**\n * Stored credentials for various services\n */\nexport interface StoredCredentials {\n\tdokploy?: {\n\t\t/** API token */\n\t\ttoken: string;\n\t\t/** Dokploy endpoint URL */\n\t\tendpoint: string;\n\t\t/** Registry ID in Dokploy (for Docker image pulls) */\n\t\tregistryId?: string;\n\t\t/** When the credentials were stored */\n\t\tstoredAt: string;\n\t};\n\thostinger?: {\n\t\t/** API token from hpanel.hostinger.com/profile/api */\n\t\ttoken: string;\n\t\t/** When the credentials were stored */\n\t\tstoredAt: string;\n\t};\n\tgodaddy?: {\n\t\t/** A Personal Access Token, scoped to domains.dns:update */\n\t\ttoken: string;\n\t\t/** When the credentials were stored */\n\t\tstoredAt: string;\n\t};\n}\n\n/**\n * Options for credential operations\n */\nexport interface CredentialOptions {\n\t/**\n\t * A directory whose `.gkm` holds the credentials. Default: the CLI's home\n\t * (`GKM_HOME`, else `~/.gkm`).\n\t */\n\troot?: string;\n\t/** The CLI's home itself, holding `credentials.json`. Wins over `root`. */\n\thome?: string;\n}\n\n/**\n * Get the path to the credentials directory\n */\nexport function getCredentialsDir(options?: CredentialOptions): string {\n\tif (options?.home) return options.home;\n\treturn options?.root ? join(options.root, '.gkm') : gkmHome();\n}\n\n/**\n * Get the path to the credentials file\n */\nexport function getCredentialsPath(options?: CredentialOptions): string {\n\treturn join(getCredentialsDir(options), 'credentials.json');\n}\n\n/**\n * Ensure the credentials directory exists\n */\nfunction ensureCredentialsDir(options?: CredentialOptions): void {\n\tconst dir = getCredentialsDir(options);\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t}\n}\n\n/**\n * Read stored credentials from disk\n */\nexport async function readCredentials(\n\toptions?: CredentialOptions,\n): Promise<StoredCredentials> {\n\tconst path = getCredentialsPath(options);\n\n\tif (!existsSync(path)) {\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst content = await readFile(path, 'utf-8');\n\t\treturn JSON.parse(content) as StoredCredentials;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/**\n * Write credentials to disk\n */\nexport async function writeCredentials(\n\tcredentials: StoredCredentials,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tensureCredentialsDir(options);\n\tconst path = getCredentialsPath(options);\n\n\tawait writeFile(path, JSON.stringify(credentials, null, 2), {\n\t\tmode: 0o600, // Owner read/write only\n\t});\n}\n\n/**\n * Store Dokploy credentials\n */\nexport async function storeDokployCredentials(\n\ttoken: string,\n\tendpoint: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tcredentials.dokploy = {\n\t\ttoken,\n\t\tendpoint,\n\t\tstoredAt: new Date().toISOString(),\n\t};\n\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Get stored Dokploy credentials\n */\nexport async function getDokployCredentials(\n\toptions?: CredentialOptions,\n): Promise<{\n\ttoken: string;\n\tendpoint: string;\n\tregistryId?: string;\n} | null> {\n\tconst credentials = await readCredentials(options);\n\n\t// The environment first, and each half independently.\n\t//\n\t// `getDokployToken` has always read `DOKPLOY_API_TOKEN` while this — the\n\t// function the deploy path actually calls — read only the file. So a CI job\n\t// given the token as a secret had a token and nowhere to send it, and the\n\t// only way through was committing a credentials file or running an\n\t// interactive login on the runner.\n\t//\n\t// Read separately rather than as a pair because they arrive separately: a\n\t// token is a secret and belongs in the environment, while an endpoint is\n\t// configuration and usually belongs in `deploy.dokploy.endpoint`. Requiring\n\t// both from the same place is what made either one useless alone.\n\tconst token = process.env.DOKPLOY_API_TOKEN ?? credentials.dokploy?.token;\n\tconst endpoint =\n\t\tprocess.env.DOKPLOY_ENDPOINT ?? credentials.dokploy?.endpoint;\n\n\tif (!token || !endpoint) return null;\n\n\treturn {\n\t\ttoken,\n\t\tendpoint: endpoint.replace(/\\/$/, ''),\n\t\t...(credentials.dokploy?.registryId\n\t\t\t? { registryId: credentials.dokploy.registryId }\n\t\t\t: {}),\n\t};\n}\n\n/**\n * Remove Dokploy credentials\n */\nexport async function removeDokployCredentials(\n\toptions?: CredentialOptions,\n): Promise<boolean> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.dokploy) {\n\t\treturn false;\n\t}\n\n\tdelete credentials.dokploy;\n\tawait writeCredentials(credentials, options);\n\treturn true;\n}\n\n/**\n * Remove all stored credentials\n */\nexport async function removeAllCredentials(\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst path = getCredentialsPath(options);\n\n\tif (existsSync(path)) {\n\t\tawait unlink(path);\n\t}\n}\n\n/**\n * Get Dokploy API token, checking stored credentials first, then environment\n */\nexport async function getDokployToken(\n\toptions?: CredentialOptions,\n): Promise<string | null> {\n\t// First check environment variable (takes precedence)\n\tconst envToken = process.env.DOKPLOY_API_TOKEN;\n\tif (envToken) {\n\t\treturn envToken;\n\t}\n\n\t// Then check stored credentials\n\tconst stored = await getDokployCredentials(options);\n\tif (stored) {\n\t\treturn stored.token;\n\t}\n\n\treturn null;\n}\n\n/**\n * Get Dokploy endpoint from stored credentials\n */\nexport async function getDokployEndpoint(\n\toptions?: CredentialOptions,\n): Promise<string | null> {\n\tconst stored = await getDokployCredentials(options);\n\treturn stored?.endpoint ?? null;\n}\n\n/**\n * Store Dokploy registry ID\n */\nexport async function storeDokployRegistryId(\n\tregistryId: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.dokploy) {\n\t\tthrow new Error(\n\t\t\t'Dokploy credentials not found. Run \"gkm login --service dokploy\" first.',\n\t\t);\n\t}\n\n\tcredentials.dokploy.registryId = registryId;\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Get Dokploy registry ID from stored credentials\n */\nexport async function getDokployRegistryId(\n\toptions?: CredentialOptions,\n): Promise<string | undefined> {\n\tconst stored = await getDokployCredentials(options);\n\treturn stored?.registryId ?? undefined;\n}\n\n// ============================================\n// Hostinger credentials\n// ============================================\n\n/**\n * Store Hostinger API token\n *\n * @param token - API token from hpanel.hostinger.com/profile/api\n */\nexport async function storeHostingerToken(\n\ttoken: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tcredentials.hostinger = {\n\t\ttoken,\n\t\tstoredAt: new Date().toISOString(),\n\t};\n\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Get stored Hostinger API token\n *\n * Checks environment variable first (HOSTINGER_API_TOKEN),\n * then falls back to stored credentials.\n */\nexport async function getHostingerToken(\n\toptions?: CredentialOptions,\n): Promise<string | null> {\n\t// First check environment variable (takes precedence)\n\tconst envToken = process.env.HOSTINGER_API_TOKEN;\n\tif (envToken) {\n\t\treturn envToken;\n\t}\n\n\t// Then check stored credentials\n\tconst credentials = await readCredentials(options);\n\treturn credentials.hostinger?.token ?? null;\n}\n\n/**\n * Remove Hostinger credentials\n */\nexport async function removeHostingerCredentials(\n\toptions?: CredentialOptions,\n): Promise<boolean> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.hostinger) {\n\t\treturn false;\n\t}\n\n\tdelete credentials.hostinger;\n\tawait writeCredentials(credentials, options);\n\treturn true;\n}\n\n// ============================================\n// GoDaddy credentials\n// ============================================\n\n/**\n * Store a GoDaddy Personal Access Token.\n */\nexport async function storeGoDaddyToken(\n\ttoken: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tcredentials.godaddy = {\n\t\ttoken,\n\t\tstoredAt: new Date().toISOString(),\n\t};\n\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Remove GoDaddy credentials\n */\nexport async function removeGoDaddyCredentials(\n\toptions?: CredentialOptions,\n): Promise<boolean> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.godaddy) {\n\t\treturn false;\n\t}\n\n\tdelete credentials.godaddy;\n\tawait writeCredentials(credentials, options);\n\treturn true;\n}\n","/**\n * Who a deploy is, on a target it shares with other workspaces.\n *\n * A Dokploy server is one flat namespace of projects, images and Docker\n * service names. Deploys used to identify everything they made by the\n * workspace name alone, so two workspaces called `shop` — or `Shop` and\n * `shop` — deploying to one server landed in the same project, pushed over\n * each other's images and redeployed each other's applications. A\n * `DeployIdentity` is what a deploy names and claims its resources by instead.\n */\n\nimport { kebabCase, scopedName } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\n\nexport interface DeployIdentity {\n\t/**\n\t * Whose deploy this is — an organisation, a team, a repository. Two\n\t * workspaces with the same name are told apart by it. Defaults to the\n\t * kebab-cased workspace name; set `deploy.namespace` to choose one.\n\t */\n\treadonly namespace: string;\n\t/** The workspace name as the target spells it: lowercase, `[a-z0-9-]`. */\n\treadonly project: string;\n\treadonly stage: string;\n\t/**\n\t * `<namespace>/<project>`: what a Dokploy project is claimed by.\n\t *\n\t * The stage is not part of it because one Dokploy project holds every stage\n\t * of a workspace, each as an environment — the key has to be the same from\n\t * every stage that deploys into it.\n\t */\n\treadonly key: string;\n\t/**\n\t * The prefix every name on the target carries: the project alone in the\n\t * default namespace, `<namespace>-<project>` in any other.\n\t *\n\t * The default adds nothing so that a workspace that never set a namespace\n\t * keeps the names it was already deployed under — a Postgres is found by\n\t * its name, and a new name would be a new, empty database.\n\t */\n\treadonly scope: string;\n}\n\n/** A namespace that cannot be part of a Dokploy name or an image path. */\nexport class DeployNamespaceInvalid extends GkmError {\n\tconstructor(readonly namespace: string) {\n\t\tsuper(\n\t\t\t`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.`,\n\t\t);\n\t\tthis.name = 'DeployNamespaceInvalid';\n\t}\n}\n\n/** A workspace name with nothing a target can name a resource by. */\nexport class DeployProjectNameInvalid extends GkmError {\n\tconstructor(readonly workspaceName: string) {\n\t\tsuper(\n\t\t\t`The workspace name '${workspaceName}' has no letters or digits to name deployed resources by. Set \"name\" in gkm.config.ts.`,\n\t\t);\n\t\tthis.name = 'DeployProjectNameInvalid';\n\t}\n}\n\nconst NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * Lowercase `[a-z0-9-]`, runs of anything else collapsed to one `-`: valid as\n * a Docker image path component, a Docker service name and a Dokploy name.\n */\nfunction slug(value: string): string {\n\treturn value\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '-')\n\t\t.replace(/^-+|-+$/g, '');\n}\n\n/** The namespace a workspace is in when it does not name one. */\nexport function defaultNamespace(workspaceName: string): string {\n\treturn slug(kebabCase(workspaceName));\n}\n\n/** What an identity is derived from: a workspace's name and namespace. */\nexport interface IdentitySource {\n\tname: string;\n\tdeploy?: { namespace?: string };\n}\n\nexport function deployIdentity(\n\tworkspace: IdentitySource,\n\tstage: string,\n): DeployIdentity {\n\t// Lowercased rather than kebab-cased: the names a workspace was already\n\t// deployed under were `${stage}-${name}`.toLowerCase(), and this has to\n\t// reproduce them for the databases it finds by name.\n\tconst project = slug(workspace.name);\n\tif (!project) throw new DeployProjectNameInvalid(workspace.name);\n\n\tconst fallback = defaultNamespace(workspace.name);\n\tconst namespace = workspace.deploy?.namespace ?? fallback;\n\tif (!NAME.test(namespace)) throw new DeployNamespaceInvalid(namespace);\n\n\treturn {\n\t\tnamespace,\n\t\tproject,\n\t\tstage,\n\t\tkey: `${namespace}/${project}`,\n\t\tscope: namespace === fallback ? project : `${namespace}-${project}`,\n\t};\n}\n\n/**\n * The token a Dokploy project's description carries to say which identity\n * created it. A project with the right name and no marker belongs to someone\n * else, and a deploy never adopts it.\n */\nexport function ownershipMarker(identity: DeployIdentity): string {\n\treturn `gkm:${identity.key}`;\n}\n\n/** Whether a project description carries `identity`'s marker. */\nexport function isOwnedBy(\n\tdescription: string | null | undefined,\n\tidentity: DeployIdentity,\n): boolean {\n\tconst marker = ownershipMarker(identity);\n\treturn (description ?? '').split(/\\s+/).includes(marker);\n}\n\n/** Any `gkm:` marker a description carries — whoever's it is. */\nexport function markerOf(\n\tdescription: string | null | undefined,\n): string | undefined {\n\treturn (description ?? '').split(/\\s+/).find((t) => t.startsWith('gkm:'));\n}\n\n/** What the Dokploy project is called. */\nexport function projectName(identity: DeployIdentity): string {\n\treturn identity.scope;\n}\n\n/**\n * The repository an app's image is pushed to, below the registry:\n * `<namespace>/<project>-<app>`.\n *\n * The namespace is a path segment of its own so that a registry that maps\n * paths to owners (an organisation's packages, a Harbor project) can grant it\n * as one; the app is joined to the project so the two read as one name.\n */\nexport function imageName(identity: DeployIdentity, app: string): string {\n\treturn `${identity.namespace}/${identity.project}-${slug(kebabCase(app))}`;\n}\n\n/**\n * The tag every image a stage runs carries for a release: `v1.4.0-production`\n * and `v1.4.0-staging` are two images of the same commit.\n *\n * Each stage builds its own: a site inlines its stage's public URLs, and two\n * builds of one commit are never byte-for-byte the same image anyway. So a\n * tag shared by two stages would be owned by whichever push finished last,\n * and the other stage would deploy, or fail to find, an image it never built.\n * Every target names every image it builds, pushes and pulls through this.\n */\nexport function stageTag(tag: string, stage: string): string {\n\treturn `${tag}-${stage}`;\n}\n\n/** The full image ref an app is built, pushed and deployed as. */\nexport function imageRef(\n\tidentity: DeployIdentity,\n\tapp: string,\n\tregistry: string | undefined,\n\ttag: string,\n): string {\n\tconst name = imageName(identity, app);\n\treturn registry\n\t\t? `${registry.replace(/\\/+$/, '')}/${name}:${tag}`\n\t\t: `${name}:${tag}`;\n}\n\n/**\n * What one application is called on the target.\n *\n * The same rule the constructs use, through the same `scopedName`, scoped by\n * the stage and the identity: the application beside\n * `production-kitchen-sink-database` is `production-kitchen-sink-api`. A\n * Dokploy application's name is also its Docker service name, which is unique\n * on the whole server, so the namespace has to be in it too — `acme`'s and\n * `globex`'s `shop` would otherwise both run `production-shop-api`.\n *\n * The app id is dropped when it repeats the project, so a project named for its\n * one application is `production-kitchen-sink` rather than\n * `production-kitchen-sink-kitchen-sink`.\n */\nexport function applicationName(identity: DeployIdentity, app: string): string {\n\treturn slug(app) === identity.project\n\t\t? `${identity.stage}-${identity.scope}`\n\t\t: scopedName([identity.stage, identity.scope], app);\n}\n","/**\n * The keys that open each stage's encrypted secrets file, kept outside the\n * project in the CLI's home.\n *\n * Keys were kept at `~/.gkm/<folder>/<stage>.key`, named after the project\n * directory — so two checkouts in folders with the same name (`~/work/api`\n * and `~/oss/api`) shared one key, and the second `gkm secrets:init`\n * overwrote the first project's. They are now kept under the project's\n * identity, `<home>/keys/<namespace>/<project>/<stage>.key`, the same\n * `<namespace>/<project>` a deploy claims its Dokploy project by. A key still\n * at the old place is copied to the new one the first time it is read; the\n * old file stays, so an older CLI on the same machine keeps working.\n */\n\nimport { randomBytes } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport {\n\tchmod,\n\tlink,\n\tmkdir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile,\n} from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { deployIdentity, type IdentitySource } from '../deploy/identity';\nimport { GkmError } from '../errors';\nimport { gkmHome } from '../home';\n\n/** Key length for AES-256 encryption */\nconst KEY_LENGTH = 32; // 256 bits\n\n/** Whose keys, and where the CLI's home is. */\nexport interface KeystoreProject {\n\t/** `<namespace>/<project>`, as `DeployIdentity.key` spells it. */\n\tkey: string;\n\t/**\n\t * The names the project's keys were kept under, `~/.gkm/<name>/`, before\n\t * they were keyed by identity: its directory's basename, which the secrets\n\t * file used, and its workspace name, which `gkm init` and the generated CI\n\t * workflow wrote to. Looked in, and copied from, when the project has no\n\t * key of its own yet.\n\t */\n\tlegacy?: readonly string[];\n\t/**\n\t * Other project keys this project's keys may be copied from when it has\n\t * none: the default namespace's, for a workspace that has just set\n\t * `deploy.namespace` — the secrets file in the checkout is the same one.\n\t */\n\taliases?: string[];\n\t/** The CLI's home. Defaults to `GKM_HOME`, else `~/.gkm`. */\n\thome?: string;\n}\n\n/** A keystore project key that is not `<namespace>/<project>`. */\nexport class KeystoreProjectInvalid extends GkmError {\n\tconstructor(readonly key: string) {\n\t\tsuper(\n\t\t\t`'${key}' is not a keystore project: expected '<namespace>/<project>' in lowercase letters, digits and '-', as deployIdentity() produces. Pass the workspace's identity key.`,\n\t\t);\n\t\tthis.name = 'KeystoreProjectInvalid';\n\t}\n}\n\n/** A stage has no key, here or at the place keys used to be kept. */\nexport class KeyNotFound extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t\treadonly path: string,\n\t) {\n\t\tsuper(\n\t\t\t`Encryption key not found for stage \"${stage}\" in project \"${project}\". ` +\n\t\t\t\t`Expected key at: ${path}. Run \\`gkm secrets:init --stage ${stage}\\` to create one, or copy the stage's key there.`,\n\t\t);\n\t\tthis.name = 'KeyNotFound';\n\t}\n}\n\nconst PROJECT_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * The keystore key of a workspace: its deploy identity without the stage, so\n * a project's keys and its Dokploy project are named by the same thing.\n */\nexport function projectKey(workspace: IdentitySource): string {\n\treturn deployIdentity(workspace, '').key;\n}\n\n/** The keystore project of a loaded workspace. */\nexport function keystoreProject(\n\tworkspace: IdentitySource & { root: string },\n\thome?: string,\n): KeystoreProject {\n\tconst key = projectKey(workspace);\n\tconst unscoped = projectKey({ name: workspace.name });\n\tconst legacy = [\n\t\t...new Set([folderName(workspace.root), workspace.name]),\n\t].filter((name): name is string => !!name);\n\treturn {\n\t\tkey,\n\t\tlegacy,\n\t\t...(unscoped !== key ? { aliases: [unscoped] } : {}),\n\t\t...(home ? { home } : {}),\n\t};\n}\n\n/**\n * Whether `name` stays inside the home it is joined to. A workspace name was\n * joined as is — `@acme/shop` is `~/.gkm/@acme/shop` — but never upwards.\n */\nfunction isLegacyName(name: string): boolean {\n\treturn name.split(/[\\\\/]/).every((part) => part !== '..' && part !== '');\n}\n\n/** The last segment of a path, as the old keystore named projects. */\nfunction folderName(path: string): string | undefined {\n\tconst name = path.split(/[\\\\/]/).filter(Boolean).at(-1);\n\treturn name && name !== '.' && name !== '..' ? name : undefined;\n}\n\n/**\n * Get the keystore directory for a project:\n * `<home>/keys/<namespace>/<project>`.\n */\nexport function getKeystoreDir(project: KeystoreProject): string {\n\tif (!PROJECT_KEY.test(project.key)) {\n\t\tthrow new KeystoreProjectInvalid(project.key);\n\t}\n\tconst [namespace, name] = project.key.split('/') as [string, string];\n\treturn join(project.home ?? gkmHome(), 'keys', namespace, name);\n}\n\n/** Get the path to a stage's encryption key. */\nexport function getKeyPath(stage: string, project: KeystoreProject): string {\n\treturn join(getKeystoreDir(project), `${stage}.key`);\n}\n\n/**\n * Where else a stage's key may be, most likely first: under an alias of the\n * project, then where keys were kept before they were keyed by identity —\n * under the configured home, then under `~/.gkm`, which is where every CLI\n * before `GKM_HOME` wrote.\n */\nfunction legacyKeyPaths(stage: string, project: KeystoreProject): string[] {\n\tconst aliases = (project.aliases ?? []).map((key) =>\n\t\tgetKeyPath(stage, { key, home: project.home }),\n\t);\n\tconst homes = [\n\t\t...new Set([project.home ?? gkmHome(), join(homedir(), '.gkm')]),\n\t];\n\tconst names = (project.legacy ?? []).filter(isLegacyName);\n\treturn [\n\t\t...aliases,\n\t\t...names.flatMap((name) =>\n\t\t\thomes.map((home) => join(home, name, `${stage}.key`)),\n\t\t),\n\t];\n}\n\n/** Check if a key exists for a stage, here or where it used to be kept. */\nexport function keyExists(stage: string, project: KeystoreProject): boolean {\n\treturn (\n\t\texistsSync(getKeyPath(stage, project)) ||\n\t\tlegacyKeyPaths(stage, project).some((path) => existsSync(path))\n\t);\n}\n\n/**\n * Generate a new encryption key for a stage, stored owner-only at\n * `<home>/keys/<namespace>/<project>/<stage>.key`.\n */\nexport async function generateKey(\n\tstage: string,\n\tproject: KeystoreProject,\n\t/** `wx` to refuse replacing a key that is already there. */\n\tflag: 'w' | 'wx' = 'w',\n): Promise<string> {\n\tconst keyDir = getKeystoreDir(project);\n\tconst keyPath = getKeyPath(stage, project);\n\n\t// Ensure keystore directory exists with restricted permissions\n\tawait mkdir(keyDir, { recursive: true, mode: 0o700 });\n\n\t// Generate random key\n\tconst key = randomBytes(KEY_LENGTH).toString('hex');\n\n\tawait placeKey(keyPath, key, flag === 'wx');\n\n\treturn key;\n}\n\n/**\n * Put a key at `keyPath` whole, or not at all.\n *\n * Written beside it first, then linked (exclusive) or renamed into place.\n * Writing the path directly — even with `wx` — creates it empty and fills it\n * after, and another process reading in between found an empty key and\n * failed with `KeyNotFound`: two commands, or two test files, creating one\n * project's key at once.\n */\nasync function placeKey(\n\tkeyPath: string,\n\tkey: string,\n\texclusive: boolean,\n): Promise<void> {\n\tconst staged = `${keyPath}.${process.pid}.${randomBytes(4).toString('hex')}`;\n\t// Owner read/write only.\n\tawait writeFile(staged, key, { mode: 0o600, encoding: 'utf-8' });\n\ttry {\n\t\t// `link` refuses an existing path with EEXIST, as `wx` does.\n\t\tif (exclusive) await link(staged, keyPath);\n\t\telse await rename(staged, keyPath);\n\t} finally {\n\t\tawait rm(staged, { force: true });\n\t}\n\t// Ensure permissions are set correctly (in case the file existed)\n\tawait chmod(keyPath, 0o600);\n}\n\n/**\n * Copy a key from where it used to be kept to where it is kept now.\n *\n * Copied, not moved: an older CLI on the same machine still reads the old\n * place. Exclusive, so two processes migrating at once cannot overwrite a key\n * one of them already put there.\n */\nasync function migrateLegacyKey(\n\tstage: string,\n\tproject: KeystoreProject,\n): Promise<boolean> {\n\tconst legacy = legacyKeyPaths(stage, project).find((path) =>\n\t\texistsSync(path),\n\t);\n\tif (!legacy) return false;\n\n\tconst keyPath = getKeyPath(stage, project);\n\tawait mkdir(getKeystoreDir(project), { recursive: true, mode: 0o700 });\n\ttry {\n\t\tawait placeKey(keyPath, await readFile(legacy, 'utf-8'), true);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n\t}\n\treturn true;\n}\n\n/**\n * Read an encryption key for a stage, or `null` when there is none — after\n * copying it over from where keys used to be kept, if it is still there.\n */\nexport async function readKey(\n\tstage: string,\n\tproject: KeystoreProject,\n): Promise<string | null> {\n\tconst keyPath = getKeyPath(stage, project);\n\n\tif (!existsSync(keyPath) && !(await migrateLegacyKey(stage, project))) {\n\t\treturn null;\n\t}\n\n\tconst key = await readFile(keyPath, 'utf-8');\n\treturn key.trim();\n}\n\n/**\n * Read an encryption key for a stage, throwing {@link KeyNotFound} if there\n * is none.\n */\nexport async function requireKey(\n\tstage: string,\n\tproject: KeystoreProject,\n): Promise<string> {\n\tconst key = await readKey(stage, project);\n\n\tif (!key) {\n\t\tthrow new KeyNotFound(stage, project.key, getKeyPath(stage, project));\n\t}\n\n\treturn key;\n}\n\n/**\n * Delete a key for a stage. Only the current one: a key left at the old place\n * belongs to whichever older CLI still reads it.\n */\nexport async function deleteKey(\n\tstage: string,\n\tproject: KeystoreProject,\n): Promise<void> {\n\tawait rm(getKeyPath(stage, project), { force: true });\n}\n\n/**\n * Get or create a key for a stage.\n * If the key already exists, it is returned. Otherwise, a new key is generated.\n */\nexport async function getOrCreateKey(\n\tstage: string,\n\tproject: KeystoreProject,\n): Promise<string> {\n\tconst existingKey = await readKey(stage, project);\n\n\tif (existingKey) {\n\t\treturn existingKey;\n\t}\n\n\t// Exclusively: a key is now shared by every checkout of one project, and\n\t// two commands creating it at once must not each keep a different one.\n\ttry {\n\t\treturn await generateKey(stage, project, 'wx');\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n\t\treturn requireKey(stage, project);\n\t}\n}\n","import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { basename, join } from 'node:path';\nimport { GkmError } from '../errors';\nimport {\n\tgetKeyPath,\n\tgetOrCreateKey,\n\ttype KeystoreProject,\n\tprojectKey,\n\treadKey,\n} from './keystore';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types';\n\n/** Where the files live, relative to the project root. */\nconst SECRETS_DIR = '.gkm/secrets';\n\n/** AES-256-GCM configuration */\nconst ALGORITHM = 'aes-256-gcm';\nconst IV_LENGTH = 12; // 96 bits for GCM\nconst AUTH_TAG_LENGTH = 16; // 128 bits\n\n/** Encrypted secrets file structure */\nexport interface EncryptedSecretsFile {\n\t/** Version for future format changes */\n\tversion: 1;\n\t/** Base64 encoded encrypted data (ciphertext + auth tag) */\n\tencrypted: string;\n\t/** Hex encoded IV */\n\tiv: string;\n}\n\n/**\n * A stage's secrets as an encrypted file on this machine:\n * `.gkm/secrets/<stage>.json`, with its key in the CLI's home at\n * `keys/<namespace>/<project>/<stage>.key`.\n *\n * The local stage's store, always — its secrets belong to the machine running\n * `gkm dev` — and a deployed stage's when `secrets.store` is `'file'`.\n */\nexport class FileSecretsStore implements SecretsStore {\n\treadonly name = 'file';\n\tprivate readonly project: KeystoreProject;\n\n\t/**\n\t * @param project - Whose keys: a workspace's `keystoreProject()`. Outside a\n\t * workspace there is no config to name the project, so it is named the\n\t * way a workspace without `name` is — its package name, else its folder.\n\t */\n\tconstructor(\n\t\tprivate readonly root: string,\n\t\tproject?: KeystoreProject,\n\t) {\n\t\tthis.project = project ?? {\n\t\t\tkey: projectKey({ name: packageName(root) ?? basename(root) }),\n\t\t\tlegacy: [basename(root)],\n\t\t};\n\t}\n\n\t/** The file a stage's secrets are kept in. */\n\tpath(stage: string): string {\n\t\treturn join(this.root, SECRETS_DIR, `${stage}.json`);\n\t}\n\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst path = this.path(stage);\n\t\tif (!existsSync(path)) return null;\n\n\t\tconst data = JSON.parse(await readFile(path, 'utf-8'));\n\n\t\t// Legacy: unencrypted format (for backwards compatibility)\n\t\tif (!(data.version === 1 && data.encrypted && data.iv)) {\n\t\t\treturn data as StageSecrets;\n\t\t}\n\n\t\tconst key = await readKey(stage, this.project);\n\t\tif (!key) {\n\t\t\tthrow new MissingSecretsKey(\n\t\t\t\tstage,\n\t\t\t\tthis.project.key,\n\t\t\t\tgetKeyPath(stage, this.project),\n\t\t\t);\n\t\t}\n\n\t\treturn decrypt(data as EncryptedSecretsFile, key);\n\t}\n\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tawait mkdir(join(this.root, SECRETS_DIR), { recursive: true });\n\n\t\tconst key = await getOrCreateKey(stage, this.project);\n\t\tawait writeFile(\n\t\t\tthis.path(stage),\n\t\t\tJSON.stringify(encrypt(secrets, key), null, 2),\n\t\t\t'utf-8',\n\t\t);\n\t}\n\n\t/** The stage's file. Its key is kept: it opens nothing once this is gone. */\n\tasync delete(stage: string): Promise<void> {\n\t\tawait rm(this.path(stage), { force: true });\n\t}\n}\n\n/** A stage's secrets file exists, and the key that opens it does not. */\nexport class MissingSecretsKey extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t\treadonly path: string,\n\t) {\n\t\tsuper(\n\t\t\t`Decryption key not found for stage \"${stage}\". ` +\n\t\t\t\t`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.`,\n\t\t);\n\t\tthis.name = 'MissingSecretsKey';\n\t}\n}\n\n/** A project's package name without its scope, as a workspace name reads it. */\nfunction packageName(root: string): string | undefined {\n\ttry {\n\t\tconst pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));\n\t\treturn typeof pkg.name === 'string'\n\t\t\t? pkg.name.replace(/^@[^/]+\\//, '')\n\t\t\t: undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Encrypt a JSON value with a stage key: AES-256-GCM, the file format every\n * stage's secrets are kept in.\n */\nexport function encrypt(\n\tsecrets: unknown,\n\tkeyHex: string,\n): EncryptedSecretsFile {\n\tconst key = Buffer.from(keyHex, 'hex');\n\tconst iv = randomBytes(IV_LENGTH);\n\n\tconst cipher = createCipheriv(ALGORITHM, key, iv);\n\tconst ciphertext = Buffer.concat([\n\t\tcipher.update(JSON.stringify(secrets), 'utf-8'),\n\t\tcipher.final(),\n\t]);\n\n\t// Ciphertext and auth tag, together\n\tconst combined = Buffer.concat([ciphertext, cipher.getAuthTag()]);\n\n\treturn {\n\t\tversion: 1,\n\t\tencrypted: combined.toString('base64'),\n\t\tiv: iv.toString('hex'),\n\t};\n}\n\n/** Decrypt what {@link encrypt} wrote. */\nexport function decrypt<T = StageSecrets>(\n\tdata: EncryptedSecretsFile,\n\tkeyHex: string,\n): T {\n\tconst key = Buffer.from(keyHex, 'hex');\n\tconst combined = Buffer.from(data.encrypted, 'base64');\n\n\tconst decipher = createDecipheriv(\n\t\tALGORITHM,\n\t\tkey,\n\t\tBuffer.from(data.iv, 'hex'),\n\t);\n\tdecipher.setAuthTag(combined.subarray(-AUTH_TAG_LENGTH));\n\n\tconst plaintext = Buffer.concat([\n\t\tdecipher.update(combined.subarray(0, -AUTH_TAG_LENGTH)),\n\t\tdecipher.final(),\n\t]);\n\n\treturn JSON.parse(plaintext.toString('utf-8')) as T;\n}\n","import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, sep } from 'node:path';\n\n/**\n * A package left out of a bundle, at the version the build resolved — what\n * an image installs beside the bundle, for its own platform.\n */\nexport type ExternalPackages = Record<string, string>;\n\n/**\n * The file beside a bundle naming the packages it left out, each at the\n * version the build resolved: a `package.json` an image installs, for its own\n * platform, next to the bundle. `server.mjs` → `server.externals.json`.\n */\nexport function externalsManifestName(outfile: string): string {\n\treturn `${outfile.replace(/\\.mjs$/, '')}.externals.json`;\n}\n\n/**\n * Asked to leave a package out of the bundle, and nothing the app depends on\n * provides it: there is no version to install in the image.\n */\nexport class ExternalNotInstalled extends Error {\n\tconstructor(\n\t\treadonly packageName: string,\n\t\treadonly root: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${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.`,\n\t\t);\n\t\tthis.name = 'ExternalNotInstalled';\n\t}\n}\n\ninterface PackageJson {\n\tname?: string;\n\tversion?: string;\n\tdependencies?: Record<string, string>;\n\toptionalDependencies?: Record<string, string>;\n\tgypfile?: boolean;\n\tbinary?: unknown;\n\tnapi?: unknown;\n\tos?: string[];\n}\n\n/** Packages whose job is loading a compiled addon. */\nconst NATIVE_LOADERS = new Set([\n\t'bindings',\n\t'node-gyp-build',\n\t'node-gyp-build-optional-packages',\n\t'node-pre-gyp',\n\t'@mapbox/node-pre-gyp',\n\t'prebuild-install',\n\t'@neon-rs/load',\n]);\n\n/** A per-platform binary package: `@node-rs/argon2-linux-x64-gnu`, `@img/sharp-darwin-arm64`. */\nconst PLATFORM_PACKAGE =\n\t/(?:^|[-/])(?:linux|darwin|win32|freebsd|android)-(?:x64|arm64|arm|ia32)\\b/;\n\nfunction readPackage(dir: string): PackageJson | undefined {\n\ttry {\n\t\treturn JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Where `name` resolves from `from`, the way Node finds it: the nearest\n * `node_modules/<name>` walking up. Followed through symlinks, so a pnpm\n * store package resolves its own dependencies beside it.\n */\nfunction locate(name: string, from: string): string | undefined {\n\tlet dir = from;\n\tfor (;;) {\n\t\tconst candidate = join(dir, 'node_modules', name);\n\t\tif (existsSync(join(candidate, 'package.json'))) {\n\t\t\treturn realpathSync(candidate);\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n}\n\n/**\n * Whether a package carries compiled code: a `binding.gyp` or prebuilt\n * binaries of its own, a loader for them, or a binary package per platform.\n * Such a package cannot be inlined into a bundle — it loads a `.node` file\n * from beside its own source, for the platform it was installed on.\n */\nexport function isNativePackage(dir: string, pkg: PackageJson): boolean {\n\tif (pkg.gypfile || pkg.binary || pkg.napi) return true;\n\tconst deps = Object.keys({\n\t\t...pkg.dependencies,\n\t\t...pkg.optionalDependencies,\n\t});\n\tif (deps.some((dep) => NATIVE_LOADERS.has(dep))) return true;\n\tif (\n\t\tObject.keys(pkg.optionalDependencies ?? {}).some((dep) =>\n\t\t\tPLATFORM_PACKAGE.test(dep),\n\t\t)\n\t) {\n\t\treturn true;\n\t}\n\tif (existsSync(join(dir, 'binding.gyp'))) return true;\n\tif (existsSync(join(dir, 'prebuilds'))) return true;\n\ttry {\n\t\treturn readdirSync(dir).some((file) => file.endsWith('.node'));\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * The packages with native code an app's bundle would otherwise inline, each\n * at the version installed for it.\n *\n * Walks what the app depends on at runtime — `dependencies`, never\n * `devDependencies` — through workspace packages and installed ones alike,\n * since anything reached is bundled. A native package is where the walk\n * stops: installing it brings what it depends on.\n */\nexport function nativeDependencies(root: string): ExternalPackages {\n\tconst found: ExternalPackages = {};\n\tconst seen = new Set<string>();\n\tconst queue = [realpathSync(root)];\n\n\twhile (queue.length > 0) {\n\t\tconst dir = queue.shift()!;\n\t\tif (seen.has(dir)) continue;\n\t\tseen.add(dir);\n\n\t\tconst pkg = readPackage(dir);\n\t\tif (!pkg) continue;\n\t\tconst isRoot = seen.size === 1;\n\t\tconst installed = dir.split(sep).includes('node_modules');\n\n\t\tif (!isRoot && installed && isNativePackage(dir, pkg)) {\n\t\t\t// One that cannot install on Linux — fsevents — is never in an image;\n\t\t\t// whatever loads it does without.\n\t\t\tconst linux =\n\t\t\t\t!pkg.os ||\n\t\t\t\tpkg.os.includes('linux') ||\n\t\t\t\t(pkg.os.every((os) => os.startsWith('!')) &&\n\t\t\t\t\t!pkg.os.includes('!linux'));\n\t\t\tif (linux && pkg.name && pkg.version && !(pkg.name in found)) {\n\t\t\t\tfound[pkg.name] = pkg.version;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const dep of Object.keys({\n\t\t\t...pkg.dependencies,\n\t\t\t...pkg.optionalDependencies,\n\t\t})) {\n\t\t\tconst location = locate(dep, dir);\n\t\t\tif (location && !seen.has(location)) queue.push(location);\n\t\t}\n\t}\n\n\treturn Object.fromEntries(\n\t\tObject.entries(found).sort(([a], [b]) => a.localeCompare(b)),\n\t);\n}\n\n/**\n * What a bundle leaves out, with the version of each to install: the native\n * packages found under `root`, and any it was asked to leave out besides,\n * at the version installed for the app.\n */\nexport function bundleExternals(\n\troot: string,\n\tdeclared: readonly string[],\n): ExternalPackages {\n\tconst externals = nativeDependencies(root);\n\tfor (const name of declared) {\n\t\tif (name in externals) continue;\n\t\tconst location = locate(name, root);\n\t\tconst version = location ? readPackage(location)?.version : undefined;\n\t\tif (!version) throw new ExternalNotInstalled(name, root);\n\t\texternals[name] = version;\n\t}\n\treturn Object.fromEntries(\n\t\tObject.entries(externals).sort(([a], [b]) => a.localeCompare(b)),\n\t);\n}\n\n/** The package a bare specifier names: `argon2/lib` → `argon2`, `@a/b/c` → `@a/b`. */\nfunction packageOf(specifier: string): string {\n\tconst parts = specifier.split('/');\n\treturn specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]!;\n}\n\n/**\n * The packages a bundle imports at runtime rather than inlining, read from\n * esbuild's metafile. Nothing when there is no metafile.\n */\nexport function importedPackages(metafile: string): Set<string> {\n\tlet meta: {\n\t\toutputs?: Record<\n\t\t\tstring,\n\t\t\t{ imports?: { path: string; external?: boolean }[] }\n\t\t>;\n\t};\n\ttry {\n\t\tmeta = JSON.parse(readFileSync(metafile, 'utf-8'));\n\t} catch {\n\t\treturn new Set();\n\t}\n\tconst imported = new Set<string>();\n\tfor (const output of Object.values(meta.outputs ?? {})) {\n\t\tfor (const { path, external } of output.imports ?? []) {\n\t\t\tif (external && !path.startsWith('.') && !path.startsWith('node:')) {\n\t\t\t\timported.add(packageOf(path));\n\t\t\t}\n\t\t}\n\t}\n\treturn imported;\n}\n","/**\n * What a stage's secrets are, independent of where they are kept: building\n * them, changing them, and handing them to a process. Where they are kept is a\n * {@link SecretsStore}'s business — see `secretsStoreFor`.\n */\n\nimport { isReservedStageKey } from '../compose/dnsConfig.js';\nimport type { SecretsStore } from './store.js';\nimport type { EmbeddableSecrets, StageSecrets } from './types';\n\n/**\n * Initialize an empty StageSecrets object for a stage.\n */\nexport function initStageSecrets(stage: string): StageSecrets {\n\tconst now = new Date().toISOString();\n\treturn {\n\t\tstage,\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t\tservices: {},\n\t\turls: {},\n\t\tcustom: {},\n\t};\n}\n\n/**\n * Convert StageSecrets to embeddable format (flat key-value pairs).\n * This is what gets encrypted and embedded in the bundle.\n */\nexport function toEmbeddableSecrets(secrets: StageSecrets): EmbeddableSecrets {\n\treturn {\n\t\t...secrets.urls,\n\t\t// The server's address (`GKM_SERVER_*`) is gkm's own, never an app's.\n\t\t...Object.fromEntries(\n\t\t\tObject.entries(secrets.custom).filter(\n\t\t\t\t([key]) => !isReservedStageKey(key),\n\t\t\t),\n\t\t),\n\t\t// Also include individual service credentials if needed\n\t\t...(secrets.services.postgres && {\n\t\t\tPOSTGRES_USER: secrets.services.postgres.username,\n\t\t\tPOSTGRES_PASSWORD: secrets.services.postgres.password,\n\t\t\tPOSTGRES_DB: secrets.services.postgres.database ?? 'app',\n\t\t\tPOSTGRES_HOST: secrets.services.postgres.host,\n\t\t\tPOSTGRES_PORT: String(secrets.services.postgres.port),\n\t\t}),\n\t\t...(secrets.services.redis && {\n\t\t\tREDIS_PASSWORD: secrets.services.redis.password,\n\t\t\tREDIS_HOST: secrets.services.redis.host,\n\t\t\tREDIS_PORT: String(secrets.services.redis.port),\n\t\t}),\n\t\t...(secrets.services.minio && {\n\t\t\tSTORAGE_ACCESS_KEY_ID: secrets.services.minio.username,\n\t\t\tSTORAGE_SECRET_ACCESS_KEY: secrets.services.minio.password,\n\t\t\tSTORAGE_BUCKET: secrets.services.minio.bucket ?? 'app',\n\t\t\tSTORAGE_REGION: 'eu-west-1',\n\t\t\tSTORAGE_FORCE_PATH_STYLE: 'true',\n\t\t}),\n\t\t...(secrets.services.mailpit && {\n\t\t\tSMTP_HOST: secrets.services.mailpit.host,\n\t\t\tSMTP_PORT: String(secrets.services.mailpit.port),\n\t\t\tSMTP_USER: secrets.services.mailpit.username,\n\t\t\tSMTP_PASS: secrets.services.mailpit.password,\n\t\t\tSMTP_SECURE: 'false',\n\t\t\tMAIL_FROM: 'noreply@localhost',\n\t\t}),\n\t\t...(secrets.services.localstack && {\n\t\t\tAWS_ACCESS_KEY_ID:\n\t\t\t\tsecrets.services.localstack.accessKeyId ??\n\t\t\t\tsecrets.services.localstack.username,\n\t\t\tAWS_SECRET_ACCESS_KEY: secrets.services.localstack.password,\n\t\t\tAWS_REGION: secrets.services.localstack.region ?? 'us-east-1',\n\t\t\tAWS_ENDPOINT_URL: `http://${secrets.services.localstack.host}:${secrets.services.localstack.port}`,\n\t\t}),\n\t};\n}\n\n/** The same secrets with one custom value set, and `updatedAt` moved on. */\nexport function withCustomSecret(\n\tsecrets: StageSecrets,\n\tkey: string,\n\tvalue: string,\n): StageSecrets {\n\treturn {\n\t\t...secrets,\n\t\tupdatedAt: new Date().toISOString(),\n\t\tcustom: { ...secrets.custom, [key]: value },\n\t};\n}\n\n/**\n * Mask a password for display (show first 4 and last 2 chars).\n */\nexport function maskPassword(password: string): string {\n\tif (password.length <= 8) {\n\t\treturn '********';\n\t}\n\treturn `${password.slice(0, 4)}${'*'.repeat(password.length - 6)}${password.slice(-2)}`;\n}\n\n/**\n * Result of environment variable validation.\n */\nexport interface EnvValidationResult {\n\t/** Whether all required environment variables are present */\n\tvalid: boolean;\n\t/** List of missing environment variable names */\n\tmissing: string[];\n\t/** List of environment variables that are provided */\n\tprovided: string[];\n\t/** List of environment variables that were required */\n\trequired: string[];\n}\n\n/**\n * Validate that all required environment variables are present in secrets.\n *\n * @param requiredVars - Array of environment variable names required by the application\n * @param secrets - Stage secrets to validate against\n * @returns Validation result with missing and provided variables\n *\n * @example\n * ```typescript\n * const required = ['DATABASE_URL', 'API_KEY', 'JWT_SECRET'];\n * const secrets = await secretsStoreFor(workspace, 'production').then((s) => s.read('production'));\n * const result = validateEnvironmentVariables(required, secrets);\n *\n * if (!result.valid) {\n * console.error(`Missing environment variables: ${result.missing.join(', ')}`);\n * }\n * ```\n */\nexport function validateEnvironmentVariables(\n\trequiredVars: string[],\n\tsecrets: StageSecrets,\n): EnvValidationResult {\n\tconst embeddable = toEmbeddableSecrets(secrets);\n\tconst availableVars = new Set(Object.keys(embeddable));\n\n\tconst missing: string[] = [];\n\tconst provided: string[] = [];\n\n\tfor (const varName of requiredVars) {\n\t\tif (availableVars.has(varName)) {\n\t\t\tprovided.push(varName);\n\t\t} else {\n\t\t\tmissing.push(varName);\n\t\t}\n\t}\n\n\treturn {\n\t\tvalid: missing.length === 0,\n\t\tmissing: missing.sort(),\n\t\tprovided: provided.sort(),\n\t\trequired: [...requiredVars].sort(),\n\t};\n}\n","/**\n * Where a stage's secrets are kept.\n *\n * Every command that needs a stage's secrets — `gkm dev`, `test`, `deploy`,\n * `build`, `setup`, `secrets:*` — asks {@link secretsStoreFor} for that\n * stage's store and reads or writes it. None of them knows whether that is a\n * file on this machine, or S3, SSM or Secrets Manager in the stage's account: the local stage is\n * always the file, and a deployed stage is whatever `secrets.store` names.\n *\n * The same shape deploy state has (`StateProvider`): one interface, a backend\n * per place, and a custom object for any place this package does not ship.\n */\n\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { FileSecretsStore } from './file.js';\nimport { keystoreProject } from './keystore.js';\nimport { s3SecretsLocation, UnknownSecretsStoreProvider } from './providers.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface SecretsStore {\n\t/**\n\t * Which kind of store this is — `'file'`, `'s3'`, `'ssm'`,\n\t * `'secrets-manager'`, or a custom one's.\n\t */\n\treadonly name: string;\n\t/** The stage's secrets, or null when it has none here. */\n\tread(stage: string): Promise<StageSecrets | null>;\n\t/** Replace the stage's secrets. */\n\twrite(stage: string, secrets: StageSecrets): Promise<void>;\n\t/**\n\t * Delete the stage's secrets, every kept version of them included — what\n\t * `gkm compose --destroy --secrets` does. Optional for a custom store; one\n\t * without it cannot have its stage's secrets destroyed by gkm.\n\t */\n\tdelete?(stage: string): Promise<void>;\n}\n\n/** Secrets in SSM Parameter Store, in the account of the active credentials. */\nexport interface SsmSecretsStoreConfig {\n\tprovider: 'ssm';\n\tregion: string;\n}\n\n/**\n * Secrets in AWS Secrets Manager, in the account of the active credentials:\n * one secret per stage, `gkm/<project>/<stage>/secrets`. Up to 64 KB where\n * SSM holds 8 KB, at a monthly price per secret.\n */\nexport interface SecretsManagerSecretsStoreConfig {\n\tprovider: 'secrets-manager';\n\tregion: string;\n\t/**\n\t * The KMS key (id, ARN or alias) a stage's secret is created with. Unset,\n\t * it is the account's AWS-managed `aws/secretsmanager` key.\n\t */\n\tkmsKeyId?: string;\n}\n\n/**\n * Secrets in S3, one object per stage —\n * `<prefix>/<project>/<stage>/secrets.json` — in the project bucket beside the\n * deploy state and backups, or in a bucket that exists. Encrypted with SSE-S3,\n * every past document kept by the bucket's versioning, and no size limit.\n */\nexport interface S3SecretsStoreConfig {\n\tprovider: 's3';\n\t/**\n\t * A bucket that already exists. Omitted, the project bucket —\n\t * `gkm-<project>-<account id>`, created by the first write.\n\t */\n\tbucket?: string;\n\t/** The bucket's region. Omitted, the deploy state's, when it is in S3. */\n\tregion?: string;\n\t/** Key prefix inside the bucket. Omitted, the S3 state's, else `gkm`. */\n\tprefix?: string;\n}\n\n/** Any other backend: an object implementing {@link SecretsStore}. */\nexport interface CustomSecretsStoreConfig {\n\tprovider: SecretsStore;\n}\n\n/**\n * `secrets.store` in gkm.config.ts.\n *\n * `'file'` — the default — keeps each stage's secrets in the encrypted\n * `.gkm/secrets/<stage>.json`, its key in the CLI's home (`GKM_HOME`, else\n * `~/.gkm`). It cannot serve a\n * deploy from CI while `.gkm/` is gitignored; `s3`, `ssm`, `secrets-manager`\n * or a custom store can.\n */\nexport type SecretsStoreConfig =\n\t| 'file'\n\t| S3SecretsStoreConfig\n\t| SsmSecretsStoreConfig\n\t| SecretsManagerSecretsStoreConfig\n\t| CustomSecretsStoreConfig;\n\nexport interface SecretsStoreOptions {\n\t/**\n\t * The AWS profile for the stage's account. Only that profile is used —\n\t * never AWS_* from the environment — so a store cannot quietly land in\n\t * whichever account the shell was exported for.\n\t */\n\tprofile?: string;\n\t/**\n\t * The CLI's home, where a file store's keys are kept. Defaults to\n\t * `GKM_HOME`, else `~/.gkm`.\n\t */\n\thome?: string;\n}\n\n/**\n * The store a stage's secrets are kept in — what every command reads and\n * writes, for the stage it acts on.\n *\n * The local stage is always the file: its secrets belong to the machine\n * running `gkm dev`. A deployed stage uses `secrets.store`.\n */\nexport async function secretsStoreFor(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n\toptions: SecretsStoreOptions = {},\n): Promise<SecretsStore> {\n\tconst configured = workspace.secrets.store ?? 'file';\n\n\tif (stage === workspace.stages.local || configured === 'file') {\n\t\treturn new FileSecretsStore(\n\t\t\tworkspace.root,\n\t\t\tkeystoreProject(workspace, options.home),\n\t\t);\n\t}\n\n\treturn storeFromConfig(workspace, configured, options);\n}\n\n/**\n * The store a `secrets.store` value describes, for any stage — what\n * {@link secretsStoreFor} answers for a deployed stage, and what\n * `gkm secrets:migrate` builds for the store it copies to.\n */\nexport async function storeFromConfig(\n\tworkspace: NormalizedWorkspace,\n\tconfig: SecretsStoreConfig,\n\toptions: SecretsStoreOptions = {},\n): Promise<SecretsStore> {\n\tif (config === 'file') {\n\t\treturn new FileSecretsStore(\n\t\t\tworkspace.root,\n\t\t\tkeystoreProject(workspace, options.home),\n\t\t);\n\t}\n\n\tconst profile = options.profile ? { profile: options.profile } : {};\n\n\tswitch (config.provider) {\n\t\tcase 's3': {\n\t\t\tconst { S3SecretsStore } = await import('./s3.js');\n\t\t\tconst { deployIdentity } = await import('../deploy/identity.js');\n\t\t\tconst location = s3SecretsLocation(\n\t\t\t\tconfig as S3SecretsStoreConfig,\n\t\t\t\tworkspace.state,\n\t\t\t);\n\t\t\treturn new S3SecretsStore({\n\t\t\t\tproject: workspace.name,\n\t\t\t\tidentity: deployIdentity(workspace, ''),\n\t\t\t\tregion: location.region,\n\t\t\t\tprefix: location.prefix,\n\t\t\t\t...(location.bucket ? { bucket: location.bucket } : {}),\n\t\t\t\t...profile,\n\t\t\t});\n\t\t}\n\t\tcase 'ssm': {\n\t\t\tconst { AwsSecretsStore } = await import('./aws.js');\n\t\t\treturn new AwsSecretsStore({\n\t\t\t\tproject: workspace.name,\n\t\t\t\tregion: config.region,\n\t\t\t\t...profile,\n\t\t\t});\n\t\t}\n\t\tcase 'secrets-manager': {\n\t\t\tconst { kmsKeyId } = config as SecretsManagerSecretsStoreConfig;\n\t\t\tconst { SecretsManagerSecretsStore } = await import(\n\t\t\t\t'./secretsManager.js'\n\t\t\t);\n\t\t\treturn new SecretsManagerSecretsStore({\n\t\t\t\tproject: workspace.name,\n\t\t\t\tregion: config.region,\n\t\t\t\t...(kmsKeyId ? { kmsKeyId } : {}),\n\t\t\t\t...profile,\n\t\t\t});\n\t\t}\n\t\tdefault: {\n\t\t\t// Typed as a SecretsStore, but a config assembled by hand may name\n\t\t\t// a provider that is not one.\n\t\t\tconst provider: unknown = config.provider;\n\t\t\tif (typeof provider === 'object' && provider !== null) {\n\t\t\t\treturn provider as SecretsStore;\n\t\t\t}\n\t\t\tthrow new UnknownSecretsStoreProvider(provider);\n\t\t}\n\t}\n}\n\n/** Whether a stage's secrets live somewhere other than this machine. */\nexport function isRemoteStore(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n): boolean {\n\tconst configured = workspace.secrets.store ?? 'file';\n\treturn stage !== workspace.stages.local && configured !== 'file';\n}\n\nexport { FileSecretsStore };\nexport {\n\tassertKnownSecretsStore,\n\tS3SecretsStoreNeedsRegion,\n\tSECRETS_STORE_PROVIDERS,\n\ttype SecretsStoreProvider,\n\ts3SecretsLocation,\n\tUnknownSecretsStoreProvider,\n} from './providers.js';\n","/**\n * Which backend each declared kind resolves to — decided by where the project\n * deploys, and by nothing else.\n *\n * These used to be read out of a `services:` block, where one key answered two\n * questions: *does this exist* and *what backs it*. The first is the manifest's\n * — a declared `Cache` is why there is a cache — and the second is the deploy\n * target's, because the right cache for a Lambda is not the right cache for a\n * box already running Postgres. With both answered elsewhere there was nothing\n * left for the block to say, so it is gone and these read the target.\n *\n * Mail has no answer here at all: every provider speaks SMTP, so the provider\n * is whichever one the stage's mail URL points at.\n */\n\nimport { runtimeOf, type TargetSource } from '../target/runtime.js';\nimport {\n\tDEFAULT_CACHE,\n\tDEFAULT_EVENTS,\n\tDEFAULT_STORAGE,\n\ttype EventsBackend,\n\ttype MainProvider,\n\ttype StorageBackend,\n\ttype TargetCacheBackend,\n} from '../types.js';\n\n/**\n * Which family of defaults a workspace's deploy target belongs to.\n *\n * One question, asked once: **does this target run containers the project\n * controls?** Dokploy does, so a bucket or a cache can live beside the app;\n * AWS, Vercel and Cloudflare do not, so the default has to be something\n * managed. That is the whole of the distinction, and it is why `MainProvider`\n * is the right axis rather than the deploy target's own name — targets share\n * answers.\n *\n * Each target declares its answer as its `runtime` — a target package in its\n * `package.json`, so this never loads one. A workspace that names no target\n * is on AWS: an SST project predates `deploy.default: 'sst'`.\n */\nexport function providerOf(workspace: TargetSource): MainProvider {\n\tconst target = workspace.deploy?.default;\n\treturn target ? runtimeOf(target, workspace) : 'aws';\n}\n\n/**\n * The cache backend a target implies.\n *\n * The same answer locally and deployed: a local `gkm dev` for an AWS app still\n * uses the Upstash protocol, because a backend that differed between the two\n * would be worse than a slower one.\n */\nexport function cacheBackendFor(on: MainProvider): TargetCacheBackend {\n\treturn DEFAULT_CACHE[on];\n}\n\n/** Where a declared bucket lives on a target. */\nexport function storageBackendFor(on: MainProvider): StorageBackend {\n\treturn DEFAULT_STORAGE[on];\n}\n\n/**\n * Which broker carries declared queues and topics on a target.\n *\n * Only consulted when something declares one; a project with no `Topic` or\n * `Queue` has no events at all, whatever the target.\n */\nexport function eventsBackendFor(on: MainProvider): EventsBackend {\n\treturn DEFAULT_EVENTS[on];\n}\n","/**\n * How a deploy gets the credentials it acts with.\n *\n * `deploy()` never prompts and never reads a terminal: it asks a\n * `CredentialProvider` and, when the provider has nothing, stops with\n * `MissingCredential` naming what it needed and how to supply it. Whether to\n * ask a person, read a vault or fail is the caller's decision — `gkm deploy`\n * prompts at a terminal and stores what was typed; a CI job sets the\n * environment; a host passes its own provider.\n */\n\nimport { readCredentials } from '../auth/credentials';\nimport { GkmError } from '../errors';\n\n/**\n * What each kind of credential is asked for with, and what it is.\n *\n * A target that needs a kind the CLI does not know declares it by augmenting\n * this interface, and lists it in its `credentials`:\n *\n * ```ts\n * declare module '@geekmidas/cli/target' {\n * interface CredentialKinds {\n * fly: { request: { org: string }; value: { token: string } };\n * }\n * }\n * ```\n */\nexport interface CredentialKinds {\n\t/** The Dokploy API a stage deploys through. */\n\tdokploy: {\n\t\t/** `deploy.dokploy.endpoint`, when the config names one. */\n\t\trequest: { endpoint?: string };\n\t\tvalue: { endpoint: string; token: string };\n\t};\n\t/**\n\t * A container registry login, for Dokploy to pull with. Asked for only when\n\t * Dokploy has no registry for `deploy.registry` and one has to be\n\t * created.\n\t */\n\tregistry: {\n\t\t/** `deploy.registry`. */\n\t\trequest: { url: string };\n\t\tvalue: { username: string; password: string };\n\t};\n\t/**\n\t * The AWS account a stage deploys to, for the SST target's `sst deploy`.\n\t * Handed to that one command's environment and to nothing else.\n\t */\n\taws: {\n\t\t/** The stage, for a provider that keeps one account per stage. */\n\t\trequest: { stage: string };\n\t\tvalue: AwsCredential;\n\t};\n\t/**\n\t * A GoDaddy Personal Access Token, for a `dns` domain whose provider is\n\t * `godaddy`. Read on the machine that writes the records — never the\n\t * server's.\n\t */\n\tgodaddy: {\n\t\trequest: Record<never, never>;\n\t\tvalue: GoDaddyCredential;\n\t};\n\t/**\n\t * A Hostinger API token, for a `dns` domain whose provider is\n\t * `hostinger`. Like GoDaddy's, read where the records are written.\n\t */\n\thostinger: {\n\t\trequest: Record<never, never>;\n\t\tvalue: HostingerCredential;\n\t};\n}\n\n/** A Hostinger API token, from hpanel.hostinger.com/profile/api. */\nexport interface HostingerCredential {\n\ttoken: string;\n}\n\n/** A GoDaddy Personal Access Token, sent as `Authorization: Bearer <token>`. */\nexport interface GoDaddyCredential {\n\ttoken: string;\n}\n\n/**\n * Who to act as on AWS: a named profile, or keys.\n *\n * Never both. Given both, every AWS SDK takes the keys and ignores the\n * profile, so `--profile prod` with staging's keys still exported would deploy\n * production's stack into staging's account — the reason `secretsStoreFor`\n * resolves a named profile on its own, and why this cannot express the mix.\n */\nexport type AwsCredential =\n\t| {\n\t\t\t/** A profile in `~/.aws/config` — keys, SSO, an assumed role. */\n\t\t\tprofile: string;\n\t\t\tregion?: string;\n\t }\n\t| {\n\t\t\taccessKeyId: string;\n\t\t\tsecretAccessKey: string;\n\t\t\t/** Present for temporary keys: an assumed role, GitHub's OIDC. */\n\t\t\tsessionToken?: string;\n\t\t\tregion?: string;\n\t };\n\nexport type CredentialKind = keyof CredentialKinds;\n\n/** What a deploy asks a provider for. */\nexport type CredentialRequest<K extends CredentialKind = CredentialKind> = {\n\t[P in K]: { kind: P } & CredentialKinds[P]['request'];\n}[K];\n\n/** What a provider answers with. */\nexport type Credential<K extends CredentialKind> = CredentialKinds[K]['value'];\n\nexport interface CredentialProvider {\n\t/**\n\t * The credential `request` asks for, or `undefined` when this provider has\n\t * none — the deploy then raises {@link MissingCredential}.\n\t */\n\tget<K extends CredentialKind>(\n\t\trequest: CredentialRequest<K>,\n\t\toptions?: { signal?: AbortSignal },\n\t): Promise<Credential<K> | undefined>;\n}\n\n/**\n * How to supply each kind the CLI knows, for the error that says it is\n * missing. A target's own kinds are its to explain.\n */\nconst HOW_TO_PROVIDE: Partial<Record<CredentialKind, string>> = {\n\tdokploy:\n\t\t\"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.\",\n\tregistry:\n\t\t'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.',\n\tgodaddy:\n\t\t'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`.',\n\thostinger:\n\t\t'Set HOSTINGER_API_TOKEN to a token from hpanel.hostinger.com/profile/api, or run `gkm login --provider hostinger`.',\n\taws: \"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.\",\n};\n\n/** A deploy needed a credential, and its provider had none. */\nexport class MissingCredential extends GkmError {\n\tconstructor(\n\t\treadonly kind: CredentialKind,\n\t\t/** What it was for: the Dokploy endpoint or the registry URL. */\n\t\treadonly target: string | undefined,\n\t\t/** How to supply it. */\n\t\treadonly howToProvide: string = HOW_TO_PROVIDE[kind] ??\n\t\t\t\"Pass it through the deploy's CredentialProvider.\",\n\t) {\n\t\tconst what =\n\t\t\tkind === 'dokploy'\n\t\t\t\t? `No Dokploy credentials${target ? ` for ${target}` : ''}.`\n\t\t\t\t: kind === 'registry'\n\t\t\t\t\t? `Dokploy has no registry for ${target ?? 'the configured registry'}, and there are no credentials to create one with.`\n\t\t\t\t\t: kind === 'aws'\n\t\t\t\t\t\t? `No AWS credentials${target ? ` for the \"${target}\" stage` : ''}.`\n\t\t\t\t\t\t: kind === 'godaddy'\n\t\t\t\t\t\t\t? `No GoDaddy API token${target ? ` for ${target}` : ''}.`\n\t\t\t\t\t\t\t: kind === 'hostinger'\n\t\t\t\t\t\t\t\t? `No Hostinger API token${target ? ` for ${target}` : ''}.`\n\t\t\t\t\t\t\t\t: `No \"${String(kind)}\" credentials${target ? ` for ${target}` : ''}.`;\n\t\tsuper(`${what} ${howToProvide}`);\n\t\tthis.name = 'MissingCredential';\n\t}\n}\n\n/** Whatever was asked for, from the first provider that has it. */\nexport function chainCredentials(\n\t...providers: CredentialProvider[]\n): CredentialProvider {\n\treturn {\n\t\tasync get(request, options) {\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst found = await provider.get(request, options);\n\t\t\t\tif (found) return found;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nexport interface StoredCredentialsOptions {\n\t/** Where to read the variables from. Defaults to `process.env`. */\n\tenv?: NodeJS.ProcessEnv;\n\t/**\n\t * The CLI's home, whose `credentials.json` holds stored logins. Defaults\n\t * to `GKM_HOME`, else `~/.gkm`.\n\t */\n\thome?: string;\n}\n\n/**\n * Credentials from the environment, then from what `gkm login` stored. What\n * `deploy()` uses when it is handed no provider.\n *\n * - Dokploy: `DOKPLOY_API_TOKEN` / `DOKPLOY_ENDPOINT`, each falling back to\n * the stored login, and the endpoint finally to `deploy.dokploy.endpoint`.\n * Each half is read on its own: a token is a secret and belongs in the\n * environment, an endpoint is configuration and belongs in the config.\n * - Registry: `DOCKER_REGISTRY_USERNAME` / `DOCKER_REGISTRY_PASSWORD`.\n * - AWS: `AWS_PROFILE` when it is set, and then nothing else; otherwise\n * `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`. The\n * profile winning is `secretsStoreFor`'s rule: a profile is a choice of\n * account someone made, exported keys may be left over from another.\n * Read here, by name, and handed only to the command that deploys — the\n * sandbox every other step runs in passes no `AWS_*` on.\n */\nexport function storedCredentials(\n\toptions: StoredCredentialsOptions = {},\n): CredentialProvider {\n\tconst env = options.env ?? process.env;\n\n\treturn {\n\t\tasync get(asked) {\n\t\t\t// The union, so a switch on `kind` narrows it: `K` itself never is.\n\t\t\tconst request = asked as CredentialRequest;\n\t\t\tswitch (request.kind) {\n\t\t\t\tcase 'dokploy': {\n\t\t\t\t\tconst stored = (\n\t\t\t\t\t\tawait readCredentials(\n\t\t\t\t\t\t\toptions.home ? { home: options.home } : undefined,\n\t\t\t\t\t\t)\n\t\t\t\t\t).dokploy;\n\t\t\t\t\tconst token = env.DOKPLOY_API_TOKEN ?? stored?.token;\n\t\t\t\t\tconst endpoint =\n\t\t\t\t\t\tenv.DOKPLOY_ENDPOINT ?? stored?.endpoint ?? request.endpoint;\n\t\t\t\t\tif (!token || !endpoint) return undefined;\n\t\t\t\t\treturn { endpoint: endpoint.replace(/\\/$/, ''), token } as never;\n\t\t\t\t}\n\t\t\t\tcase 'registry': {\n\t\t\t\t\tconst username = env.DOCKER_REGISTRY_USERNAME;\n\t\t\t\t\tconst password = env.DOCKER_REGISTRY_PASSWORD;\n\t\t\t\t\tif (!username || !password) return undefined;\n\t\t\t\t\treturn { username, password } as never;\n\t\t\t\t}\n\t\t\t\tcase 'godaddy': {\n\t\t\t\t\t// The environment first, then the stored login.\n\t\t\t\t\tconst token =\n\t\t\t\t\t\tenv.GODADDY_API_TOKEN ||\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait readCredentials(\n\t\t\t\t\t\t\t\toptions.home ? { home: options.home } : undefined,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).godaddy?.token;\n\t\t\t\t\tif (!token) return undefined;\n\t\t\t\t\treturn { token } as never;\n\t\t\t\t}\n\t\t\t\tcase 'hostinger': {\n\t\t\t\t\tconst token =\n\t\t\t\t\t\tenv.HOSTINGER_API_TOKEN ||\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait readCredentials(\n\t\t\t\t\t\t\t\toptions.home ? { home: options.home } : undefined,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t).hostinger?.token;\n\t\t\t\t\tif (!token) return undefined;\n\t\t\t\t\treturn { token } as never;\n\t\t\t\t}\n\t\t\t\tcase 'aws': {\n\t\t\t\t\tconst region = env.AWS_REGION ?? env.AWS_DEFAULT_REGION;\n\t\t\t\t\tconst where = region ? { region } : {};\n\t\t\t\t\tif (env.AWS_PROFILE) {\n\t\t\t\t\t\treturn { profile: env.AWS_PROFILE, ...where } as never;\n\t\t\t\t\t}\n\t\t\t\t\tconst accessKeyId = env.AWS_ACCESS_KEY_ID;\n\t\t\t\t\tconst secretAccessKey = env.AWS_SECRET_ACCESS_KEY;\n\t\t\t\t\tif (!accessKeyId || !secretAccessKey) return undefined;\n\t\t\t\t\treturn {\n\t\t\t\t\t\taccessKeyId,\n\t\t\t\t\t\tsecretAccessKey,\n\t\t\t\t\t\t...(env.AWS_SESSION_TOKEN\n\t\t\t\t\t\t\t? { sessionToken: env.AWS_SESSION_TOKEN }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t...where,\n\t\t\t\t\t} as never;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// A kind a target declared: nothing stored here can answer it.\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaA,MAAa,eAAe;;AAG5B,SAAgB,QAAQ,MAAyB,QAAQ,KAAa;CACrE,MAAM,aAAa,IAAI;CACvB,OAAO,aAAa,QAAQ,UAAU,IAAI,KAAK,QAAQ,GAAG,MAAM;AACjE;;;;;;AC8BA,SAAgB,kBAAkB,SAAqC;CACtE,IAAI,SAAS,MAAM,OAAO,QAAQ;CAClC,OAAO,SAAS,OAAO,KAAK,QAAQ,MAAM,MAAM,IAAI,QAAQ;AAC7D;;;;AAKA,SAAgB,mBAAmB,SAAqC;CACvE,OAAO,KAAK,kBAAkB,OAAO,GAAG,kBAAkB;AAC3D;;;;AAKA,SAAS,qBAAqB,SAAmC;CAChE,MAAM,MAAM,kBAAkB,OAAO;CACrC,IAAI,CAAC,WAAW,GAAG,GAClB,UAAU,KAAK;EAAE,WAAW;EAAM,MAAM;CAAM,CAAC;AAEjD;;;;AAKA,eAAsB,gBACrB,SAC6B;CAC7B,MAAM,OAAO,mBAAmB,OAAO;CAEvC,IAAI,CAAC,WAAW,IAAI,GACnB,OAAO,CAAC;CAGT,IAAI;EACH,MAAM,UAAU,MAAM,SAAS,MAAM,OAAO;EAC5C,OAAO,KAAK,MAAM,OAAO;CAC1B,QAAQ;EACP,OAAO,CAAC;CACT;AACD;;;;AAKA,eAAsB,iBACrB,aACA,SACgB;CAChB,qBAAqB,OAAO;CAC5B,MAAM,OAAO,mBAAmB,OAAO;CAEvC,MAAM,UAAU,MAAM,KAAK,UAAU,aAAa,MAAM,CAAC,GA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;IAChB,MAAM,WAAW,IAAI;IACrB,MAAM,WAAW,IAAI;IACrB,IAAI,CAAC,YAAY,CAAC,UAAU,OAAO,KAAA;IACnC,OAAO;KAAE;KAAU;IAAS;GAC7B;GACA,KAAK,WAAW;IAEf,MAAM,QACL,IAAI,sBAEH,MAAM,gBACL,QAAQ,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,KAAA,CACzC,EAAA,CACC,SAAS;IACZ,IAAI,CAAC,OAAO,OAAO,KAAA;IACnB,OAAO,EAAE,MAAM;GAChB;GACA,KAAK,aAAa;IACjB,MAAM,QACL,IAAI,wBAEH,MAAM,gBACL,QAAQ,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,KAAA,CACzC,EAAA,CACC,WAAW;IACd,IAAI,CAAC,OAAO,OAAO,KAAA;IACnB,OAAO,EAAE,MAAM;GAChB;GACA,KAAK,OAAO;IACX,MAAM,SAAS,IAAI,cAAc,IAAI;IACrC,MAAM,QAAQ,SAAS,EAAE,OAAO,IAAI,CAAC;IACrC,IAAI,IAAI,aACP,OAAO;KAAE,SAAS,IAAI;KAAa,GAAG;IAAM;IAE7C,MAAM,cAAc,IAAI;IACxB,MAAM,kBAAkB,IAAI;IAC5B,IAAI,CAAC,eAAe,CAAC,iBAAiB,OAAO,KAAA;IAC7C,OAAO;KACN;KACA;KACA,GAAI,IAAI,oBACL,EAAE,cAAc,IAAI,kBAAkB,IACtC,CAAC;KACJ,GAAG;IACJ;GACD;EACD;CAGD,EACD;AACD"}
@@ -1,9 +1,8 @@
1
1
  const require_errors = require("./errors-D1x8duqI.cjs");
2
- const require_compose = require("./compose-CKBieltT.cjs");
3
- const require_apps = require("./apps-vLzb0ZSA.cjs");
4
- const require_compose$1 = require("./compose-CvNyjqwL.cjs");
5
- const require_stack = require("./stack-vBnc84e8.cjs");
6
- const require_stage = require("./stage-8KJCtYtl.cjs");
2
+ const require_stack = require("./stack-BYhtz-bE.cjs");
3
+ const require_compose = require("./compose-BEVBxf4w.cjs");
4
+ const require_credentials = require("./credentials-Eyx2tM7B.cjs");
5
+ const require_stage = require("./stage-Bc_BtQeG.cjs");
7
6
  let _geekmidas_manifest = require("@geekmidas/manifest");
8
7
  //#region src/exec/dbTunnel.ts
9
8
  /**
@@ -75,11 +74,11 @@ function loginFields(url) {
75
74
  * @throws {DatabaseNotInStage}
76
75
  */
77
76
  function ownerLogins(stack, port, construct) {
78
- const env = require_apps.envFor(stack.plan, {
77
+ const env = require_stack.envFor(stack.plan, {
79
78
  ...stack.resolution,
80
- ports: { [require_compose$1.primaryPortKey("postgres")]: port }
79
+ ports: { [require_credentials.primaryPortKey("postgres")]: port }
81
80
  });
82
- const logins = stack.plan.resources.filter((resource) => require_apps.isDatabase(resource.kind)).map((resource) => {
81
+ const logins = stack.plan.resources.filter((resource) => require_stack.isDatabase(resource.kind)).map((resource) => {
83
82
  const key = (0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "ownerUrl");
84
83
  const url = env[key] ?? env[resource.envKey];
85
84
  return url ? {
@@ -151,4 +150,4 @@ async function dbTunnel(options, deps = defaultDbTunnelDeps) {
151
150
  //#endregion
152
151
  exports.dbTunnel = dbTunnel;
153
152
 
154
- //# sourceMappingURL=dbTunnel-DSzAG_wy.cjs.map
153
+ //# sourceMappingURL=dbTunnel-DVohSZJQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dbTunnel-DSzAG_wy.cjs","names":["GkmError","LOOPBACK_SERVICES","envFor","primaryPortKey","isDatabase","providedKeyFor","defaultStageExecDeps","loadStage","ExecNotConfirmed","stageServer","dockerHost"],"sources":["../src/exec/dbTunnel.ts"],"sourcesContent":["/**\n * `gkm db:tunnel --stage <stage> [construct]`: a deployed compose stage's\n * Postgres, on this machine's loopback, and each database's owner login to\n * sign in to it with — for a SQL client, a one-off fix, a look at the data.\n *\n * The tunnel is the deploy's own: SSH on the deploy's login to the port the\n * server publishes Postgres on, its loopback alone. The owner URL is the one\n * the deploy migrates with, derived from the stage's secrets the way the\n * deploy derives it — nothing is stored, and nothing is written to disk.\n *\n * It is the owner, not the app's login, because that is what a person\n * changing the schema or its data by hand needs; it is printed, not injected,\n * because a GUI client is not a process gkm starts. `gkm exec --stage` stays\n * the app's login: what a script runs as is what the app runs as.\n */\n\nimport { providedKeyFor } from '@geekmidas/manifest';\nimport { dockerHost } from '../compose/server.js';\nimport type { ComposeStack } from '../compose/stack.js';\nimport { LOOPBACK_SERVICES } from '../compose/stack.js';\nimport { GkmError } from '../errors';\nimport { primaryPortKey } from '../reconcile/containers.js';\nimport { envFor, isDatabase } from '../reconcile/env.js';\nimport {\n\tdefaultStageExecDeps,\n\tExecNotConfirmed,\n\tloadStage,\n\ttype StageExecDeps,\n\ttype StageExecOptions,\n\tstageServer,\n} from './stage.js';\n\nconst logger = console;\n\n/** The stage's stack runs no Postgres: there is nothing to tunnel to. */\nexport class StageHasNoDatabase extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`'${stage}' runs no Postgres, so there is no database to tunnel to. ` +\n\t\t\t\t'Declare a Database construct and deploy the stage.',\n\t\t);\n\t\tthis.name = 'StageHasNoDatabase';\n\t}\n}\n\n/** The construct asked for is not one of the stage's databases. */\nexport class DatabaseNotInStage extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly construct: string,\n\t\treadonly databases: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database '${stage}' runs. Its databases are ` +\n\t\t\t\t`${databases.join(', ')}: gkm db:tunnel --stage ${stage} ` +\n\t\t\t\t`${databases[0] ?? '<construct>'}.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotInStage';\n\t}\n}\n\n/** The server publishes no Postgres: the stack is not running there. */\nexport class DatabaseNotPublished extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`No running ${project} postgres publishes ${LOOPBACK_SERVICES.postgres} ` +\n\t\t\t\t`on '${stage}'s server, so there is nothing to tunnel to. Deploy the ` +\n\t\t\t\t`stage (gkm deploy --stage ${stage}), then run this again.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotPublished';\n\t}\n}\n\n/** A database's owner login, as this machine reaches it. */\nexport interface OwnerLogin {\n\t/** The construct's id. */\n\tconstruct: string;\n\t/** The key the deploy's migrations read it from. */\n\tkey: string;\n\turl: string;\n}\n\n/** A login's URL as a SQL client's form asks for it, field by field. */\nexport function loginFields(url: string): [string, string][] {\n\tconst parsed = new URL(url);\n\treturn [\n\t\t['host', parsed.hostname],\n\t\t['port', parsed.port],\n\t\t['database', decodeURIComponent(parsed.pathname.slice(1))],\n\t\t['user', decodeURIComponent(parsed.username)],\n\t\t['password', decodeURIComponent(parsed.password)],\n\t];\n}\n\n/**\n * Each database's owner URL — every one, or the construct asked for — on\n * the port this machine reaches the stack's Postgres by: the same values the\n * deploy's migrations connect with (`migrateAndSeed`), from the same\n * derivation.\n *\n * @throws {DatabaseNotInStage}\n */\nexport function ownerLogins(\n\tstack: Pick<ComposeStack, 'stage' | 'plan' | 'resolution'>,\n\tport: number,\n\tconstruct?: string,\n): OwnerLogin[] {\n\tconst env = envFor(stack.plan, {\n\t\t...stack.resolution,\n\t\tports: { [primaryPortKey('postgres')]: port },\n\t});\n\tconst logins = stack.plan.resources\n\t\t.filter((resource) => isDatabase(resource.kind))\n\t\t.map((resource) => {\n\t\t\tconst key = providedKeyFor(resource.id, resource.kind, 'ownerUrl');\n\t\t\t// A database whose roles are not split has no owner: its one login\n\t\t\t// is the URL itself, and that is the one to sign in with.\n\t\t\tconst url = env[key] ?? env[resource.envKey];\n\t\t\treturn url ? { construct: resource.id, key, url } : undefined;\n\t\t})\n\t\t.filter((login): login is OwnerLogin => login !== undefined);\n\n\tif (construct === undefined) return logins;\n\tconst asked = logins.filter((login) => login.construct === construct);\n\tif (asked.length === 0) {\n\t\tthrow new DatabaseNotInStage(\n\t\t\tstack.stage,\n\t\t\tconstruct,\n\t\t\tlogins.map((login) => login.construct),\n\t\t);\n\t}\n\treturn asked;\n}\n\nexport interface DbTunnelOptions\n\textends Pick<\n\t\tStageExecOptions,\n\t\t'stage' | 'profile' | 'sshUser' | 'yes' | 'cwd'\n\t> {\n\t/** One database construct, by id. Every one when absent. */\n\tconstruct?: string;\n}\n\nexport interface DbTunnelDeps extends StageExecDeps {\n\t/** Resolves when the tunnel should close: Ctrl-C, by default. */\n\theld: () => Promise<void>;\n}\n\n/** Until the person presses Ctrl-C, or the process is told to stop. */\nfunction untilInterrupted(): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tconst stop = () => {\n\t\t\tprocess.off('SIGINT', stop);\n\t\t\tprocess.off('SIGTERM', stop);\n\t\t\tresolve();\n\t\t};\n\t\tprocess.on('SIGINT', stop);\n\t\tprocess.on('SIGTERM', stop);\n\t});\n}\n\nexport const defaultDbTunnelDeps: DbTunnelDeps = {\n\t...defaultStageExecDeps,\n\theld: untilInterrupted,\n};\n\n/**\n * Open a tunnel to the stage's Postgres, print each database's owner URL\n * through it, and hold it open until `deps.held` resolves. The tunnel is\n * closed however that ends.\n *\n * @throws {StageHasNoDatabase}, {DatabaseNotInStage}, {DatabaseNotPublished},\n * {ExecNotConfirmed}, {ExecStageNotComposed}, {ExecStageNotDeployed},\n * {ComposeServerUnreachable}\n */\nexport async function dbTunnel(\n\toptions: DbTunnelOptions,\n\tdeps: DbTunnelDeps = defaultDbTunnelDeps,\n): Promise<OwnerLogin[]> {\n\tconst { stage } = options;\n\tconst loaded = await loadStage(options, deps.env);\n\tconst { stack } = loaded;\n\tif (!stack.infra.includes('postgres')) throw new StageHasNoDatabase(stage);\n\t// Asked here, before anything is reached: an unknown construct is said\n\t// without an SSH login. The port is a placeholder until the tunnel opens.\n\townerLogins(stack, LOOPBACK_SERVICES.postgres, options.construct);\n\n\tif (loaded.protectedStage && !options.yes) {\n\t\tconst question = `'${stage}' is a protected stage. Open a tunnel to its database as its owner?`;\n\t\tif (!(await deps.confirm(question))) throw new ExecNotConfirmed(stage);\n\t}\n\n\tconst server = stageServer(loaded, options);\n\tawait deps.server.check(server);\n\n\tconst published = await deps.docker.published(\n\t\t{ host: dockerHost(server) },\n\t\tstack.project,\n\t\t'postgres',\n\t\tLOOPBACK_SERVICES.postgres,\n\t);\n\tif (published === undefined) {\n\t\tthrow new DatabaseNotPublished(stage, stack.project);\n\t}\n\n\tconst tunnel = await deps.server.tunnel(server, published);\n\ttry {\n\t\tconst logins = ownerLogins(stack, tunnel.port, options.construct);\n\t\tlogger.log(\n\t\t\t`🚇 '${stage}' postgres → 127.0.0.1:${tunnel.port} (over SSH to ${server.host})`,\n\t\t);\n\t\tfor (const login of logins) {\n\t\t\tlogger.log(`\\n🔑 ${login.construct} (${login.key})`);\n\t\t\tlogger.log(` ${login.url}`);\n\t\t\tfor (const [field, value] of loginFields(login.url)) {\n\t\t\t\tlogger.log(` ${`${field}:`.padEnd(10)}${value}`);\n\t\t\t}\n\t\t}\n\t\tlogger.log('\\nThe tunnel is open. Press Ctrl-C to close it.');\n\t\tawait deps.held();\n\t\treturn logins;\n\t} finally {\n\t\tawait tunnel.close();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS;;AAGf,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6GAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAEtC;CACA;CACA;CAHV,YACC,OACA,WACA,WACC;EACD,MACC,IAAI,UAAU,uBAAuB,MAAM,4BACvC,UAAU,KAAK,IAAI,EAAE,0BAA0B,MAAM,GACrD,UAAU,MAAM,cAAc,EACnC;EARS,KAAA,QAAA;EACA,KAAA,YAAA;EACA,KAAA,YAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,uBAAb,cAA0CA,eAAAA,SAAS;CAExC;CACA;CAFV,YAC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AAI,QAAQ,MAAM,UAAU,IAAI,MAAM,IAAI,EAAE;GACnD,OAAO,IAAI,MAAM,MAAM,KAAK;GAC5B,KAAK,MAAM,CAAC,OAAO,UAAU,YAAY,MAAM,GAAG,GACjD,OAAO,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,OAAO;EAEnD;EACA,OAAO,IAAI,iDAAiD;EAC5D,MAAM,KAAK,KAAK;EAChB,OAAO;CACR,UAAU;EACT,MAAM,OAAO,MAAM;CACpB;AACD"}
1
+ {"version":3,"file":"dbTunnel-DVohSZJQ.cjs","names":["GkmError","LOOPBACK_SERVICES","envFor","primaryPortKey","isDatabase","providedKeyFor","defaultStageExecDeps","loadStage","ExecNotConfirmed","stageServer","dockerHost"],"sources":["../src/exec/dbTunnel.ts"],"sourcesContent":["/**\n * `gkm db:tunnel --stage <stage> [construct]`: a deployed compose stage's\n * Postgres, on this machine's loopback, and each database's owner login to\n * sign in to it with — for a SQL client, a one-off fix, a look at the data.\n *\n * The tunnel is the deploy's own: SSH on the deploy's login to the port the\n * server publishes Postgres on, its loopback alone. The owner URL is the one\n * the deploy migrates with, derived from the stage's secrets the way the\n * deploy derives it — nothing is stored, and nothing is written to disk.\n *\n * It is the owner, not the app's login, because that is what a person\n * changing the schema or its data by hand needs; it is printed, not injected,\n * because a GUI client is not a process gkm starts. `gkm exec --stage` stays\n * the app's login: what a script runs as is what the app runs as.\n */\n\nimport { providedKeyFor } from '@geekmidas/manifest';\nimport { dockerHost } from '../compose/server.js';\nimport type { ComposeStack } from '../compose/stack.js';\nimport { LOOPBACK_SERVICES } from '../compose/stack.js';\nimport { GkmError } from '../errors';\nimport { primaryPortKey } from '../reconcile/containers.js';\nimport { envFor, isDatabase } from '../reconcile/env.js';\nimport {\n\tdefaultStageExecDeps,\n\tExecNotConfirmed,\n\tloadStage,\n\ttype StageExecDeps,\n\ttype StageExecOptions,\n\tstageServer,\n} from './stage.js';\n\nconst logger = console;\n\n/** The stage's stack runs no Postgres: there is nothing to tunnel to. */\nexport class StageHasNoDatabase extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`'${stage}' runs no Postgres, so there is no database to tunnel to. ` +\n\t\t\t\t'Declare a Database construct and deploy the stage.',\n\t\t);\n\t\tthis.name = 'StageHasNoDatabase';\n\t}\n}\n\n/** The construct asked for is not one of the stage's databases. */\nexport class DatabaseNotInStage extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly construct: string,\n\t\treadonly databases: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database '${stage}' runs. Its databases are ` +\n\t\t\t\t`${databases.join(', ')}: gkm db:tunnel --stage ${stage} ` +\n\t\t\t\t`${databases[0] ?? '<construct>'}.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotInStage';\n\t}\n}\n\n/** The server publishes no Postgres: the stack is not running there. */\nexport class DatabaseNotPublished extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`No running ${project} postgres publishes ${LOOPBACK_SERVICES.postgres} ` +\n\t\t\t\t`on '${stage}'s server, so there is nothing to tunnel to. Deploy the ` +\n\t\t\t\t`stage (gkm deploy --stage ${stage}), then run this again.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotPublished';\n\t}\n}\n\n/** A database's owner login, as this machine reaches it. */\nexport interface OwnerLogin {\n\t/** The construct's id. */\n\tconstruct: string;\n\t/** The key the deploy's migrations read it from. */\n\tkey: string;\n\turl: string;\n}\n\n/** A login's URL as a SQL client's form asks for it, field by field. */\nexport function loginFields(url: string): [string, string][] {\n\tconst parsed = new URL(url);\n\treturn [\n\t\t['host', parsed.hostname],\n\t\t['port', parsed.port],\n\t\t['database', decodeURIComponent(parsed.pathname.slice(1))],\n\t\t['user', decodeURIComponent(parsed.username)],\n\t\t['password', decodeURIComponent(parsed.password)],\n\t];\n}\n\n/**\n * Each database's owner URL — every one, or the construct asked for — on\n * the port this machine reaches the stack's Postgres by: the same values the\n * deploy's migrations connect with (`migrateAndSeed`), from the same\n * derivation.\n *\n * @throws {DatabaseNotInStage}\n */\nexport function ownerLogins(\n\tstack: Pick<ComposeStack, 'stage' | 'plan' | 'resolution'>,\n\tport: number,\n\tconstruct?: string,\n): OwnerLogin[] {\n\tconst env = envFor(stack.plan, {\n\t\t...stack.resolution,\n\t\tports: { [primaryPortKey('postgres')]: port },\n\t});\n\tconst logins = stack.plan.resources\n\t\t.filter((resource) => isDatabase(resource.kind))\n\t\t.map((resource) => {\n\t\t\tconst key = providedKeyFor(resource.id, resource.kind, 'ownerUrl');\n\t\t\t// A database whose roles are not split has no owner: its one login\n\t\t\t// is the URL itself, and that is the one to sign in with.\n\t\t\tconst url = env[key] ?? env[resource.envKey];\n\t\t\treturn url ? { construct: resource.id, key, url } : undefined;\n\t\t})\n\t\t.filter((login): login is OwnerLogin => login !== undefined);\n\n\tif (construct === undefined) return logins;\n\tconst asked = logins.filter((login) => login.construct === construct);\n\tif (asked.length === 0) {\n\t\tthrow new DatabaseNotInStage(\n\t\t\tstack.stage,\n\t\t\tconstruct,\n\t\t\tlogins.map((login) => login.construct),\n\t\t);\n\t}\n\treturn asked;\n}\n\nexport interface DbTunnelOptions\n\textends Pick<\n\t\tStageExecOptions,\n\t\t'stage' | 'profile' | 'sshUser' | 'yes' | 'cwd'\n\t> {\n\t/** One database construct, by id. Every one when absent. */\n\tconstruct?: string;\n}\n\nexport interface DbTunnelDeps extends StageExecDeps {\n\t/** Resolves when the tunnel should close: Ctrl-C, by default. */\n\theld: () => Promise<void>;\n}\n\n/** Until the person presses Ctrl-C, or the process is told to stop. */\nfunction untilInterrupted(): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tconst stop = () => {\n\t\t\tprocess.off('SIGINT', stop);\n\t\t\tprocess.off('SIGTERM', stop);\n\t\t\tresolve();\n\t\t};\n\t\tprocess.on('SIGINT', stop);\n\t\tprocess.on('SIGTERM', stop);\n\t});\n}\n\nexport const defaultDbTunnelDeps: DbTunnelDeps = {\n\t...defaultStageExecDeps,\n\theld: untilInterrupted,\n};\n\n/**\n * Open a tunnel to the stage's Postgres, print each database's owner URL\n * through it, and hold it open until `deps.held` resolves. The tunnel is\n * closed however that ends.\n *\n * @throws {StageHasNoDatabase}, {DatabaseNotInStage}, {DatabaseNotPublished},\n * {ExecNotConfirmed}, {ExecStageNotComposed}, {ExecStageNotDeployed},\n * {ComposeServerUnreachable}\n */\nexport async function dbTunnel(\n\toptions: DbTunnelOptions,\n\tdeps: DbTunnelDeps = defaultDbTunnelDeps,\n): Promise<OwnerLogin[]> {\n\tconst { stage } = options;\n\tconst loaded = await loadStage(options, deps.env);\n\tconst { stack } = loaded;\n\tif (!stack.infra.includes('postgres')) throw new StageHasNoDatabase(stage);\n\t// Asked here, before anything is reached: an unknown construct is said\n\t// without an SSH login. The port is a placeholder until the tunnel opens.\n\townerLogins(stack, LOOPBACK_SERVICES.postgres, options.construct);\n\n\tif (loaded.protectedStage && !options.yes) {\n\t\tconst question = `'${stage}' is a protected stage. Open a tunnel to its database as its owner?`;\n\t\tif (!(await deps.confirm(question))) throw new ExecNotConfirmed(stage);\n\t}\n\n\tconst server = stageServer(loaded, options);\n\tawait deps.server.check(server);\n\n\tconst published = await deps.docker.published(\n\t\t{ host: dockerHost(server) },\n\t\tstack.project,\n\t\t'postgres',\n\t\tLOOPBACK_SERVICES.postgres,\n\t);\n\tif (published === undefined) {\n\t\tthrow new DatabaseNotPublished(stage, stack.project);\n\t}\n\n\tconst tunnel = await deps.server.tunnel(server, published);\n\ttry {\n\t\tconst logins = ownerLogins(stack, tunnel.port, options.construct);\n\t\tlogger.log(\n\t\t\t`🚇 '${stage}' postgres → 127.0.0.1:${tunnel.port} (over SSH to ${server.host})`,\n\t\t);\n\t\tfor (const login of logins) {\n\t\t\tlogger.log(`\\n🔑 ${login.construct} (${login.key})`);\n\t\t\tlogger.log(` ${login.url}`);\n\t\t\tfor (const [field, value] of loginFields(login.url)) {\n\t\t\t\tlogger.log(` ${`${field}:`.padEnd(10)}${value}`);\n\t\t\t}\n\t\t}\n\t\tlogger.log('\\nThe tunnel is open. Press Ctrl-C to close it.');\n\t\tawait deps.held();\n\t\treturn logins;\n\t} finally {\n\t\tawait tunnel.close();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS;;AAGf,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6GAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAEtC;CACA;CACA;CAHV,YACC,OACA,WACA,WACC;EACD,MACC,IAAI,UAAU,uBAAuB,MAAM,4BACvC,UAAU,KAAK,IAAI,EAAE,0BAA0B,MAAM,GACrD,UAAU,MAAM,cAAc,EACnC;EARS,KAAA,QAAA;EACA,KAAA,YAAA;EACA,KAAA,YAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,uBAAb,cAA0CA,eAAAA,SAAS;CAExC;CACA;CAFV,YACC,OACA,SACC;EACD,MACC,cAAc,QAAQ,sBAAsBC,cAAAA,kBAAkB,SAAS,OAC/D,MAAM,oFACgB,MAAM,wBACrC;EAPS,KAAA,QAAA;EACA,KAAA,UAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAYA,SAAgB,YAAY,KAAiC;CAC5D,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,OAAO;EACN,CAAC,QAAQ,OAAO,QAAQ;EACxB,CAAC,QAAQ,OAAO,IAAI;EACpB,CAAC,YAAY,mBAAmB,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC;EACzD,CAAC,QAAQ,mBAAmB,OAAO,QAAQ,CAAC;EAC5C,CAAC,YAAY,mBAAmB,OAAO,QAAQ,CAAC;CACjD;AACD;;;;;;;;;AAUA,SAAgB,YACf,OACA,MACA,WACe;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BAAkB,UAAU,QAAQ,SAAS;CAEhE,IAAI,OAAO,kBAAkB,CAAC,QAAQ,KAAK;EAC1C,MAAM,WAAW,IAAI,MAAM;EAC3B,IAAI,CAAE,MAAM,KAAK,QAAQ,QAAQ,GAAI,MAAM,IAAIO,cAAAA,iBAAiB,KAAK;CACtE;CAEA,MAAM,SAASC,cAAAA,YAAY,QAAQ,OAAO;CAC1C,MAAM,KAAK,OAAO,MAAM,MAAM;CAE9B,MAAM,YAAY,MAAM,KAAK,OAAO,UACnC,EAAE,MAAMC,gBAAAA,WAAW,MAAM,EAAE,GAC3B,MAAM,SACN,YACAT,cAAAA,kBAAkB,QACnB;CACA,IAAI,cAAc,KAAA,GACjB,MAAM,IAAI,qBAAqB,OAAO,MAAM,OAAO;CAGpD,MAAM,SAAS,MAAM,KAAK,OAAO,OAAO,QAAQ,SAAS;CACzD,IAAI;EACH,MAAM,SAAS,YAAY,OAAO,OAAO,MAAM,QAAQ,SAAS;EAChE,OAAO,IACN,OAAO,MAAM,yBAAyB,OAAO,KAAK,gBAAgB,OAAO,KAAK,EAC/E;EACA,KAAK,MAAM,SAAS,QAAQ;GAC3B,OAAO,IAAI,QAAQ,MAAM,UAAU,IAAI,MAAM,IAAI,EAAE;GACnD,OAAO,IAAI,MAAM,MAAM,KAAK;GAC5B,KAAK,MAAM,CAAC,OAAO,UAAU,YAAY,MAAM,GAAG,GACjD,OAAO,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,OAAO;EAEnD;EACA,OAAO,IAAI,iDAAiD;EAC5D,MAAM,KAAK,KAAK;EAChB,OAAO;CACR,UAAU;EACT,MAAM,OAAO,MAAM;CACpB;AACD"}
@@ -1,9 +1,8 @@
1
1
  import { t as GkmError } from "./errors-C9uIyIDt.mjs";
2
- import { p as dockerHost } from "./compose-DPXoarGI.mjs";
3
- import { Ct as isDatabase, St as envFor } from "./apps-CXzjaPWR.mjs";
4
- import { ut as primaryPortKey } from "./compose-CJznzQc7.mjs";
5
- import { i as LOOPBACK_SERVICES } from "./stack-Dd-egttk.mjs";
6
- import { i as stageServer, n as defaultStageExecDeps, r as loadStage, t as ExecNotConfirmed } from "./stage-CXIdtjY2.mjs";
2
+ import { An as isDatabase, kn as envFor, n as LOOPBACK_SERVICES } from "./stack-CLHY-_2m.mjs";
3
+ import { u as dockerHost } from "./compose-Dx_nSZYU.mjs";
4
+ import { lt as primaryPortKey } from "./credentials-DW5MvS4A.mjs";
5
+ import { i as stageServer, n as defaultStageExecDeps, r as loadStage, t as ExecNotConfirmed } from "./stage-C7aYyDMr.mjs";
7
6
  import { providedKeyFor } from "@geekmidas/manifest";
8
7
  //#region src/exec/dbTunnel.ts
9
8
  /**
@@ -151,4 +150,4 @@ async function dbTunnel(options, deps = defaultDbTunnelDeps) {
151
150
  //#endregion
152
151
  export { dbTunnel };
153
152
 
154
- //# sourceMappingURL=dbTunnel-CphoKGyk.mjs.map
153
+ //# sourceMappingURL=dbTunnel-bV1CPWUv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dbTunnel-CphoKGyk.mjs","names":[],"sources":["../src/exec/dbTunnel.ts"],"sourcesContent":["/**\n * `gkm db:tunnel --stage <stage> [construct]`: a deployed compose stage's\n * Postgres, on this machine's loopback, and each database's owner login to\n * sign in to it with — for a SQL client, a one-off fix, a look at the data.\n *\n * The tunnel is the deploy's own: SSH on the deploy's login to the port the\n * server publishes Postgres on, its loopback alone. The owner URL is the one\n * the deploy migrates with, derived from the stage's secrets the way the\n * deploy derives it — nothing is stored, and nothing is written to disk.\n *\n * It is the owner, not the app's login, because that is what a person\n * changing the schema or its data by hand needs; it is printed, not injected,\n * because a GUI client is not a process gkm starts. `gkm exec --stage` stays\n * the app's login: what a script runs as is what the app runs as.\n */\n\nimport { providedKeyFor } from '@geekmidas/manifest';\nimport { dockerHost } from '../compose/server.js';\nimport type { ComposeStack } from '../compose/stack.js';\nimport { LOOPBACK_SERVICES } from '../compose/stack.js';\nimport { GkmError } from '../errors';\nimport { primaryPortKey } from '../reconcile/containers.js';\nimport { envFor, isDatabase } from '../reconcile/env.js';\nimport {\n\tdefaultStageExecDeps,\n\tExecNotConfirmed,\n\tloadStage,\n\ttype StageExecDeps,\n\ttype StageExecOptions,\n\tstageServer,\n} from './stage.js';\n\nconst logger = console;\n\n/** The stage's stack runs no Postgres: there is nothing to tunnel to. */\nexport class StageHasNoDatabase extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`'${stage}' runs no Postgres, so there is no database to tunnel to. ` +\n\t\t\t\t'Declare a Database construct and deploy the stage.',\n\t\t);\n\t\tthis.name = 'StageHasNoDatabase';\n\t}\n}\n\n/** The construct asked for is not one of the stage's databases. */\nexport class DatabaseNotInStage extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly construct: string,\n\t\treadonly databases: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database '${stage}' runs. Its databases are ` +\n\t\t\t\t`${databases.join(', ')}: gkm db:tunnel --stage ${stage} ` +\n\t\t\t\t`${databases[0] ?? '<construct>'}.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotInStage';\n\t}\n}\n\n/** The server publishes no Postgres: the stack is not running there. */\nexport class DatabaseNotPublished extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`No running ${project} postgres publishes ${LOOPBACK_SERVICES.postgres} ` +\n\t\t\t\t`on '${stage}'s server, so there is nothing to tunnel to. Deploy the ` +\n\t\t\t\t`stage (gkm deploy --stage ${stage}), then run this again.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotPublished';\n\t}\n}\n\n/** A database's owner login, as this machine reaches it. */\nexport interface OwnerLogin {\n\t/** The construct's id. */\n\tconstruct: string;\n\t/** The key the deploy's migrations read it from. */\n\tkey: string;\n\turl: string;\n}\n\n/** A login's URL as a SQL client's form asks for it, field by field. */\nexport function loginFields(url: string): [string, string][] {\n\tconst parsed = new URL(url);\n\treturn [\n\t\t['host', parsed.hostname],\n\t\t['port', parsed.port],\n\t\t['database', decodeURIComponent(parsed.pathname.slice(1))],\n\t\t['user', decodeURIComponent(parsed.username)],\n\t\t['password', decodeURIComponent(parsed.password)],\n\t];\n}\n\n/**\n * Each database's owner URL — every one, or the construct asked for — on\n * the port this machine reaches the stack's Postgres by: the same values the\n * deploy's migrations connect with (`migrateAndSeed`), from the same\n * derivation.\n *\n * @throws {DatabaseNotInStage}\n */\nexport function ownerLogins(\n\tstack: Pick<ComposeStack, 'stage' | 'plan' | 'resolution'>,\n\tport: number,\n\tconstruct?: string,\n): OwnerLogin[] {\n\tconst env = envFor(stack.plan, {\n\t\t...stack.resolution,\n\t\tports: { [primaryPortKey('postgres')]: port },\n\t});\n\tconst logins = stack.plan.resources\n\t\t.filter((resource) => isDatabase(resource.kind))\n\t\t.map((resource) => {\n\t\t\tconst key = providedKeyFor(resource.id, resource.kind, 'ownerUrl');\n\t\t\t// A database whose roles are not split has no owner: its one login\n\t\t\t// is the URL itself, and that is the one to sign in with.\n\t\t\tconst url = env[key] ?? env[resource.envKey];\n\t\t\treturn url ? { construct: resource.id, key, url } : undefined;\n\t\t})\n\t\t.filter((login): login is OwnerLogin => login !== undefined);\n\n\tif (construct === undefined) return logins;\n\tconst asked = logins.filter((login) => login.construct === construct);\n\tif (asked.length === 0) {\n\t\tthrow new DatabaseNotInStage(\n\t\t\tstack.stage,\n\t\t\tconstruct,\n\t\t\tlogins.map((login) => login.construct),\n\t\t);\n\t}\n\treturn asked;\n}\n\nexport interface DbTunnelOptions\n\textends Pick<\n\t\tStageExecOptions,\n\t\t'stage' | 'profile' | 'sshUser' | 'yes' | 'cwd'\n\t> {\n\t/** One database construct, by id. Every one when absent. */\n\tconstruct?: string;\n}\n\nexport interface DbTunnelDeps extends StageExecDeps {\n\t/** Resolves when the tunnel should close: Ctrl-C, by default. */\n\theld: () => Promise<void>;\n}\n\n/** Until the person presses Ctrl-C, or the process is told to stop. */\nfunction untilInterrupted(): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tconst stop = () => {\n\t\t\tprocess.off('SIGINT', stop);\n\t\t\tprocess.off('SIGTERM', stop);\n\t\t\tresolve();\n\t\t};\n\t\tprocess.on('SIGINT', stop);\n\t\tprocess.on('SIGTERM', stop);\n\t});\n}\n\nexport const defaultDbTunnelDeps: DbTunnelDeps = {\n\t...defaultStageExecDeps,\n\theld: untilInterrupted,\n};\n\n/**\n * Open a tunnel to the stage's Postgres, print each database's owner URL\n * through it, and hold it open until `deps.held` resolves. The tunnel is\n * closed however that ends.\n *\n * @throws {StageHasNoDatabase}, {DatabaseNotInStage}, {DatabaseNotPublished},\n * {ExecNotConfirmed}, {ExecStageNotComposed}, {ExecStageNotDeployed},\n * {ComposeServerUnreachable}\n */\nexport async function dbTunnel(\n\toptions: DbTunnelOptions,\n\tdeps: DbTunnelDeps = defaultDbTunnelDeps,\n): Promise<OwnerLogin[]> {\n\tconst { stage } = options;\n\tconst loaded = await loadStage(options, deps.env);\n\tconst { stack } = loaded;\n\tif (!stack.infra.includes('postgres')) throw new StageHasNoDatabase(stage);\n\t// Asked here, before anything is reached: an unknown construct is said\n\t// without an SSH login. The port is a placeholder until the tunnel opens.\n\townerLogins(stack, LOOPBACK_SERVICES.postgres, options.construct);\n\n\tif (loaded.protectedStage && !options.yes) {\n\t\tconst question = `'${stage}' is a protected stage. Open a tunnel to its database as its owner?`;\n\t\tif (!(await deps.confirm(question))) throw new ExecNotConfirmed(stage);\n\t}\n\n\tconst server = stageServer(loaded, options);\n\tawait deps.server.check(server);\n\n\tconst published = await deps.docker.published(\n\t\t{ host: dockerHost(server) },\n\t\tstack.project,\n\t\t'postgres',\n\t\tLOOPBACK_SERVICES.postgres,\n\t);\n\tif (published === undefined) {\n\t\tthrow new DatabaseNotPublished(stage, stack.project);\n\t}\n\n\tconst tunnel = await deps.server.tunnel(server, published);\n\ttry {\n\t\tconst logins = ownerLogins(stack, tunnel.port, options.construct);\n\t\tlogger.log(\n\t\t\t`🚇 '${stage}' postgres → 127.0.0.1:${tunnel.port} (over SSH to ${server.host})`,\n\t\t);\n\t\tfor (const login of logins) {\n\t\t\tlogger.log(`\\n🔑 ${login.construct} (${login.key})`);\n\t\t\tlogger.log(` ${login.url}`);\n\t\t\tfor (const [field, value] of loginFields(login.url)) {\n\t\t\t\tlogger.log(` ${`${field}:`.padEnd(10)}${value}`);\n\t\t\t}\n\t\t}\n\t\tlogger.log('\\nThe tunnel is open. Press Ctrl-C to close it.');\n\t\tawait deps.held();\n\t\treturn logins;\n\t} finally {\n\t\tawait tunnel.close();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS;;AAGf,IAAa,qBAAb,cAAwC,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6GAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwC,SAAS;CAEtC;CACA;CACA;CAHV,YACC,OACA,WACA,WACC;EACD,MACC,IAAI,UAAU,uBAAuB,MAAM,4BACvC,UAAU,KAAK,IAAI,EAAE,0BAA0B,MAAM,GACrD,UAAU,MAAM,cAAc,EACnC;EARS,KAAA,QAAA;EACA,KAAA,YAAA;EACA,KAAA,YAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,uBAAb,cAA0C,SAAS;CAExC;CACA;CAFV,YACC,OACA,SACC;EACD,MACC,cAAc,QAAQ,sBAAsB,kBAAkB,SAAS,OAC/D,MAAM,oFACgB,MAAM,wBACrC;EAPS,KAAA,QAAA;EACA,KAAA,UAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAYA,SAAgB,YAAY,KAAiC;CAC5D,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,OAAO;EACN,CAAC,QAAQ,OAAO,QAAQ;EACxB,CAAC,QAAQ,OAAO,IAAI;EACpB,CAAC,YAAY,mBAAmB,OAAO,SAAS,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's\n * Postgres, on this machine's loopback, and each database's owner login to\n * sign in to it with — for a SQL client, a one-off fix, a look at the data.\n *\n * The tunnel is the deploy's own: SSH on the deploy's login to the port the\n * server publishes Postgres on, its loopback alone. The owner URL is the one\n * the deploy migrates with, derived from the stage's secrets the way the\n * deploy derives it — nothing is stored, and nothing is written to disk.\n *\n * It is the owner, not the app's login, because that is what a person\n * changing the schema or its data by hand needs; it is printed, not injected,\n * because a GUI client is not a process gkm starts. `gkm exec --stage` stays\n * the app's login: what a script runs as is what the app runs as.\n */\n\nimport { providedKeyFor } from '@geekmidas/manifest';\nimport { dockerHost } from '../compose/server.js';\nimport type { ComposeStack } from '../compose/stack.js';\nimport { LOOPBACK_SERVICES } from '../compose/stack.js';\nimport { GkmError } from '../errors';\nimport { primaryPortKey } from '../reconcile/containers.js';\nimport { envFor, isDatabase } from '../reconcile/env.js';\nimport {\n\tdefaultStageExecDeps,\n\tExecNotConfirmed,\n\tloadStage,\n\ttype StageExecDeps,\n\ttype StageExecOptions,\n\tstageServer,\n} from './stage.js';\n\nconst logger = console;\n\n/** The stage's stack runs no Postgres: there is nothing to tunnel to. */\nexport class StageHasNoDatabase extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`'${stage}' runs no Postgres, so there is no database to tunnel to. ` +\n\t\t\t\t'Declare a Database construct and deploy the stage.',\n\t\t);\n\t\tthis.name = 'StageHasNoDatabase';\n\t}\n}\n\n/** The construct asked for is not one of the stage's databases. */\nexport class DatabaseNotInStage extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly construct: string,\n\t\treadonly databases: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database '${stage}' runs. Its databases are ` +\n\t\t\t\t`${databases.join(', ')}: gkm db:tunnel --stage ${stage} ` +\n\t\t\t\t`${databases[0] ?? '<construct>'}.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotInStage';\n\t}\n}\n\n/** The server publishes no Postgres: the stack is not running there. */\nexport class DatabaseNotPublished extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`No running ${project} postgres publishes ${LOOPBACK_SERVICES.postgres} ` +\n\t\t\t\t`on '${stage}'s server, so there is nothing to tunnel to. Deploy the ` +\n\t\t\t\t`stage (gkm deploy --stage ${stage}), then run this again.`,\n\t\t);\n\t\tthis.name = 'DatabaseNotPublished';\n\t}\n}\n\n/** A database's owner login, as this machine reaches it. */\nexport interface OwnerLogin {\n\t/** The construct's id. */\n\tconstruct: string;\n\t/** The key the deploy's migrations read it from. */\n\tkey: string;\n\turl: string;\n}\n\n/** A login's URL as a SQL client's form asks for it, field by field. */\nexport function loginFields(url: string): [string, string][] {\n\tconst parsed = new URL(url);\n\treturn [\n\t\t['host', parsed.hostname],\n\t\t['port', parsed.port],\n\t\t['database', decodeURIComponent(parsed.pathname.slice(1))],\n\t\t['user', decodeURIComponent(parsed.username)],\n\t\t['password', decodeURIComponent(parsed.password)],\n\t];\n}\n\n/**\n * Each database's owner URL — every one, or the construct asked for — on\n * the port this machine reaches the stack's Postgres by: the same values the\n * deploy's migrations connect with (`migrateAndSeed`), from the same\n * derivation.\n *\n * @throws {DatabaseNotInStage}\n */\nexport function ownerLogins(\n\tstack: Pick<ComposeStack, 'stage' | 'plan' | 'resolution'>,\n\tport: number,\n\tconstruct?: string,\n): OwnerLogin[] {\n\tconst env = envFor(stack.plan, {\n\t\t...stack.resolution,\n\t\tports: { [primaryPortKey('postgres')]: port },\n\t});\n\tconst logins = stack.plan.resources\n\t\t.filter((resource) => isDatabase(resource.kind))\n\t\t.map((resource) => {\n\t\t\tconst key = providedKeyFor(resource.id, resource.kind, 'ownerUrl');\n\t\t\t// A database whose roles are not split has no owner: its one login\n\t\t\t// is the URL itself, and that is the one to sign in with.\n\t\t\tconst url = env[key] ?? env[resource.envKey];\n\t\t\treturn url ? { construct: resource.id, key, url } : undefined;\n\t\t})\n\t\t.filter((login): login is OwnerLogin => login !== undefined);\n\n\tif (construct === undefined) return logins;\n\tconst asked = logins.filter((login) => login.construct === construct);\n\tif (asked.length === 0) {\n\t\tthrow new DatabaseNotInStage(\n\t\t\tstack.stage,\n\t\t\tconstruct,\n\t\t\tlogins.map((login) => login.construct),\n\t\t);\n\t}\n\treturn asked;\n}\n\nexport interface DbTunnelOptions\n\textends Pick<\n\t\tStageExecOptions,\n\t\t'stage' | 'profile' | 'sshUser' | 'yes' | 'cwd'\n\t> {\n\t/** One database construct, by id. Every one when absent. */\n\tconstruct?: string;\n}\n\nexport interface DbTunnelDeps extends StageExecDeps {\n\t/** Resolves when the tunnel should close: Ctrl-C, by default. */\n\theld: () => Promise<void>;\n}\n\n/** Until the person presses Ctrl-C, or the process is told to stop. */\nfunction untilInterrupted(): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tconst stop = () => {\n\t\t\tprocess.off('SIGINT', stop);\n\t\t\tprocess.off('SIGTERM', stop);\n\t\t\tresolve();\n\t\t};\n\t\tprocess.on('SIGINT', stop);\n\t\tprocess.on('SIGTERM', stop);\n\t});\n}\n\nexport const defaultDbTunnelDeps: DbTunnelDeps = {\n\t...defaultStageExecDeps,\n\theld: untilInterrupted,\n};\n\n/**\n * Open a tunnel to the stage's Postgres, print each database's owner URL\n * through it, and hold it open until `deps.held` resolves. The tunnel is\n * closed however that ends.\n *\n * @throws {StageHasNoDatabase}, {DatabaseNotInStage}, {DatabaseNotPublished},\n * {ExecNotConfirmed}, {ExecStageNotComposed}, {ExecStageNotDeployed},\n * {ComposeServerUnreachable}\n */\nexport async function dbTunnel(\n\toptions: DbTunnelOptions,\n\tdeps: DbTunnelDeps = defaultDbTunnelDeps,\n): Promise<OwnerLogin[]> {\n\tconst { stage } = options;\n\tconst loaded = await loadStage(options, deps.env);\n\tconst { stack } = loaded;\n\tif (!stack.infra.includes('postgres')) throw new StageHasNoDatabase(stage);\n\t// Asked here, before anything is reached: an unknown construct is said\n\t// without an SSH login. The port is a placeholder until the tunnel opens.\n\townerLogins(stack, LOOPBACK_SERVICES.postgres, options.construct);\n\n\tif (loaded.protectedStage && !options.yes) {\n\t\tconst question = `'${stage}' is a protected stage. Open a tunnel to its database as its owner?`;\n\t\tif (!(await deps.confirm(question))) throw new ExecNotConfirmed(stage);\n\t}\n\n\tconst server = stageServer(loaded, options);\n\tawait deps.server.check(server);\n\n\tconst published = await deps.docker.published(\n\t\t{ host: dockerHost(server) },\n\t\tstack.project,\n\t\t'postgres',\n\t\tLOOPBACK_SERVICES.postgres,\n\t);\n\tif (published === undefined) {\n\t\tthrow new DatabaseNotPublished(stage, stack.project);\n\t}\n\n\tconst tunnel = await deps.server.tunnel(server, published);\n\ttry {\n\t\tconst logins = ownerLogins(stack, tunnel.port, options.construct);\n\t\tlogger.log(\n\t\t\t`🚇 '${stage}' postgres → 127.0.0.1:${tunnel.port} (over SSH to ${server.host})`,\n\t\t);\n\t\tfor (const login of logins) {\n\t\t\tlogger.log(`\\n🔑 ${login.construct} (${login.key})`);\n\t\t\tlogger.log(` ${login.url}`);\n\t\t\tfor (const [field, value] of loginFields(login.url)) {\n\t\t\t\tlogger.log(` ${`${field}:`.padEnd(10)}${value}`);\n\t\t\t}\n\t\t}\n\t\tlogger.log('\\nThe tunnel is open. Press Ctrl-C to close it.');\n\t\tawait deps.held();\n\t\treturn logins;\n\t} finally {\n\t\tawait tunnel.close();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAS;;AAGf,IAAa,qBAAb,cAAwC,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6GAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwC,SAAS;CAEtC;CACA;CACA;CAHV,YACC,OACA,WACA,WACC;EACD,MACC,IAAI,UAAU,uBAAuB,MAAM,4BACvC,UAAU,KAAK,IAAI,EAAE,0BAA0B,MAAM,GACrD,UAAU,MAA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M,SAAS,QAAQ;GAC3B,OAAO,IAAI,QAAQ,MAAM,UAAU,IAAI,MAAM,IAAI,EAAE;GACnD,OAAO,IAAI,MAAM,MAAM,KAAK;GAC5B,KAAK,MAAM,CAAC,OAAO,UAAU,YAAY,MAAM,GAAG,GACjD,OAAO,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,OAAO;EAEnD;EACA,OAAO,IAAI,iDAAiD;EAC5D,MAAM,KAAK,KAAK;EAChB,OAAO;CACR,UAAU;EACT,MAAM,OAAO,MAAM;CACpB;AACD"}
@@ -1,21 +1,20 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors = require("../errors-D1x8duqI.cjs");
3
- const require_dns = require("../dns-BzYrbB2Y.cjs");
4
- const require_workspace = require("../workspace-fGwzXa5l.cjs");
5
- const require_apps = require("../apps-vLzb0ZSA.cjs");
3
+ const require_credentials = require("../credentials-n2abUWwJ.cjs");
4
+ const require_stack = require("../stack-BYhtz-bE.cjs");
5
+ const require_workspace = require("../workspace-CTspddnJ.cjs");
6
6
  const require_define = require("../define-zKgLY65H.cjs");
7
7
  const require_discover = require("../discover-OXczlq08.cjs");
8
8
  const require_config = require("../config.cjs");
9
- const require_resolve = require("../resolve-DIPHwLan.cjs");
10
- const require_notes = require("../notes-DMOLnNJI.cjs");
11
- const require_local = require("../local-DjaAcHZb.cjs");
12
- const require_sniffer = require("../sniffer-CkPIytPI.cjs");
13
- const require_deploy = require("../deploy-BaSYxpny.cjs");
9
+ const require_resolve = require("../resolve-Ced8-gj4.cjs");
10
+ const require_local = require("../local-BuR4fIW6.cjs");
11
+ const require_sniffer = require("../sniffer-XlvJLrhZ.cjs");
12
+ const require_deploy = require("../deploy-CDUWcl58.cjs");
14
13
  const require_seeds = require("../seeds-Bc3niNVb.cjs");
15
- const require_engine = require("../engine-3imTFxdN.cjs");
16
- const require_rollback = require("../rollback-Bp6hepUh.cjs");
14
+ const require_engine = require("../engine-BevpkNZe.cjs");
15
+ const require_rollback = require("../rollback-C6bCANv7.cjs");
17
16
  const require_provider = require("../provider-DLhgo-mB.cjs");
18
- const require_sst = require("../sst-DGsteg5j.cjs");
17
+ const require_sst = require("../sst-CsEjVFtz.cjs");
19
18
  let node_path = require("node:path");
20
19
  let node_fs = require("node:fs");
21
20
  //#region src/sandbox/install.ts
@@ -122,7 +121,7 @@ function installCommands(packageManager, cwd, options = {}) {
122
121
  async function installDependencies(sandbox, options = {}) {
123
122
  const cwd = options.cwd ?? sandbox.root;
124
123
  const results = [];
125
- const packageManager = options.packageManager ?? require_apps.detectPackageManager((0, node_path.resolve)(sandbox.root, cwd));
124
+ const packageManager = options.packageManager ?? require_stack.detectPackageManager((0, node_path.resolve)(sandbox.root, cwd));
126
125
  for (const [command, args] of installCommands(packageManager, (0, node_path.resolve)(sandbox.root, cwd), options)) {
127
126
  const result = await sandbox.exec(command, args, {
128
127
  cwd,
@@ -135,29 +134,29 @@ async function installDependencies(sandbox, options = {}) {
135
134
  ...options.signal ? { signal: options.signal } : {}
136
135
  });
137
136
  results.push(result);
138
- if (result.exitCode !== 0) throw new require_dns.CommandFailed(command, args, result.exitCode, result.signal);
137
+ if (result.exitCode !== 0) throw new require_stack.CommandFailed(command, args, result.exitCode, result.signal);
139
138
  }
140
139
  return results;
141
140
  }
142
141
  //#endregion
143
- exports.AllowDevServicesTakesNoValue = require_notes.AllowDevServicesTakesNoValue;
142
+ exports.AllowDevServicesTakesNoValue = require_stack.AllowDevServicesTakesNoValue;
144
143
  exports.BackendDeployFailed = require_engine.BackendDeployFailed;
145
- exports.CommandFailed = require_dns.CommandFailed;
146
- exports.CommandTimedOut = require_dns.CommandTimedOut;
144
+ exports.CommandFailed = require_stack.CommandFailed;
145
+ exports.CommandTimedOut = require_stack.CommandTimedOut;
147
146
  exports.ConfigLoadFailed = require_config.ConfigLoadFailed;
148
147
  exports.ConfigObjectNotSerializable = require_config.ConfigObjectNotSerializable;
149
148
  exports.ConstructDiscoveryFailed = require_discover.ConstructDiscoveryFailed;
150
149
  exports.ConstructsNotSerializable = require_discover.ConstructsNotSerializable;
151
- exports.DEV_SERVICES = require_notes.DEV_SERVICES;
150
+ exports.DEV_SERVICES = require_stack.DEV_SERVICES;
152
151
  exports.DeployMigrationsFailed = require_engine.DeployMigrationsFailed;
153
152
  exports.DeploySeedsFailed = require_seeds.DeploySeedsFailed;
154
153
  exports.DeployTargetNotYetSupported = require_define.DeployTargetNotYetSupported;
155
154
  exports.DeploymentFailed = require_sniffer.DeploymentFailed;
156
155
  exports.DeploymentTimedOut = require_sniffer.DeploymentTimedOut;
157
- exports.DevServicesNeedServerTarget = require_notes.DevServicesNeedServerTarget;
158
- exports.ExternalServicesNotConfigured = require_notes.ExternalServicesNotConfigured;
156
+ exports.DevServicesNeedServerTarget = require_stack.DevServicesNeedServerTarget;
157
+ exports.ExternalServicesNotConfigured = require_stack.ExternalServicesNotConfigured;
159
158
  exports.FrontendDeployFailed = require_engine.FrontendDeployFailed;
160
- exports.GKM_HOME_ENV = require_dns.GKM_HOME_ENV;
159
+ exports.GKM_HOME_ENV = require_credentials.GKM_HOME_ENV;
161
160
  exports.HealthCheckTimedOut = require_engine.HealthCheckTimedOut;
162
161
  exports.INSTALL_TIMEOUT_MS = INSTALL_TIMEOUT_MS;
163
162
  exports.InstallAllowlistNameInvalid = InstallAllowlistNameInvalid;
@@ -165,7 +164,7 @@ exports.InstallScriptsAllowlistUnsupported = InstallScriptsAllowlistUnsupported;
165
164
  exports.InvalidTargetOptions = require_resolve.InvalidTargetOptions;
166
165
  exports.LocalSandbox = require_local.LocalSandbox;
167
166
  exports.LocalStateInCi = require_sniffer.LocalStateInCi;
168
- exports.MissingCredential = require_dns.MissingCredential;
167
+ exports.MissingCredential = require_credentials.MissingCredential;
169
168
  exports.MissingEnvVars = require_engine.MissingEnvVars;
170
169
  exports.NoDeployableApps = require_deploy.NoDeployableApps;
171
170
  exports.NothingToRollBack = require_rollback.NothingToRollBack;
@@ -185,7 +184,7 @@ exports.SecretNameInvalid = require_discover.SecretNameInvalid;
185
184
  exports.SstConfigNotFound = require_sst.SstConfigNotFound;
186
185
  exports.SstOutputsUnreadable = require_sst.SstOutputsUnreadable;
187
186
  exports.StageNeverDeployed = require_rollback.StageNeverDeployed;
188
- exports.StageProviderDisabled = require_notes.StageProviderDisabled;
187
+ exports.StageProviderDisabled = require_stack.StageProviderDisabled;
189
188
  exports.StateLocked = require_sniffer.StateLocked;
190
189
  exports.StateVersionConflict = require_sniffer.StateVersionConflict;
191
190
  exports.SurfacesUnhealthy = require_sst.SurfacesUnhealthy;
@@ -199,13 +198,13 @@ exports.UnknownDeployApps = require_deploy.UnknownDeployApps;
199
198
  exports.UnknownDeployTarget = require_define.UnknownDeployTarget;
200
199
  exports.UnknownStageProvider = require_workspace.UnknownStageProvider;
201
200
  exports.allowlistedEnv = require_local.allowlistedEnv;
202
- exports.chainCredentials = require_dns.chainCredentials;
201
+ exports.chainCredentials = require_credentials.chainCredentials;
203
202
  exports.confineCwd = require_discover.confineCwd;
204
203
  exports.deploy = require_deploy.deploy;
205
- exports.deployIdentity = require_dns.deployIdentity;
206
- exports.gkmHome = require_dns.gkmHome;
204
+ exports.deployIdentity = require_credentials.deployIdentity;
205
+ exports.gkmHome = require_credentials.gkmHome;
207
206
  exports.installDependencies = installDependencies;
208
207
  exports.rollbackStage = require_rollback.rollbackStage;
209
- exports.storedCredentials = require_dns.storedCredentials;
208
+ exports.storedCredentials = require_credentials.storedCredentials;
210
209
 
211
210
  //# sourceMappingURL=public.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.cjs","names":["GkmError","existsSync","join","detectPackageManager","resolve","CommandFailed"],"sources":["../../src/sandbox/install.ts"],"sourcesContent":["/**\n * Installing a project's dependencies in a sandbox, with or without their\n * lifecycle scripts.\n *\n * `postinstall` is the oldest way into a build machine: any package in the\n * lockfile — a dependency of a dependency — runs whatever it likes the moment\n * it is installed. For a build the host trusts that is how native modules get\n * built. For one it does not, the scripts are skipped, and the few packages\n * that genuinely need theirs (esbuild's binary, a database driver) are named\n * and rebuilt — with nothing but the sandbox's environment either way.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { detectPackageManager, type PackageManager } from '../docker/templates';\nimport { GkmError } from '../errors';\nimport { CommandFailed } from '../run';\nimport type { Sandbox, SandboxOutput, SandboxResult } from './sandbox';\n\n/** Long enough for a cold install of a large monorepo. */\nexport const INSTALL_TIMEOUT_MS = 15 * 60_000;\n\nexport interface InstallOptions {\n\t/** The directory to install in. Defaults to the sandbox's root. */\n\tcwd?: string;\n\t/** Defaults to the one the lockfile above `cwd` names. */\n\tpackageManager?: PackageManager;\n\t/**\n\t * Skip every lifecycle script — dependencies' and the project's own —\n\t * except those of {@link allowScripts}. Defaults to false: scripts run as\n\t * a plain install runs them, under the package manager's own policy —\n\t * npm 12 and pnpm 10 skip dependencies' scripts nobody approved.\n\t */\n\tignoreScripts?: boolean;\n\t/**\n\t * With `ignoreScripts`, the packages whose scripts still run: rebuilt by\n\t * name once the install is done.\n\t */\n\tallowScripts?: readonly string[];\n\t/** Variables the install needs beyond the sandbox's own. */\n\tenv?: Readonly<Record<string, string>>;\n\t/** Defaults to {@link INSTALL_TIMEOUT_MS}, for each command. */\n\ttimeoutMs?: number;\n\t/** Where the package manager's output goes. Defaults to `inherit`. */\n\toutput?: SandboxOutput;\n\tsignal?: AbortSignal;\n}\n\n/** A name in `allowScripts` that is not a package name. */\nexport class InstallAllowlistNameInvalid extends GkmError {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name, so its scripts cannot be ` +\n\t\t\t\t'allowed. Name the package as it appears in package.json — ' +\n\t\t\t\t\"'esbuild', '@prisma/client'.\",\n\t\t);\n\t\tthis.name = 'InstallAllowlistNameInvalid';\n\t}\n}\n\n/** The package manager has no way to run only some packages' scripts. */\nexport class InstallScriptsAllowlistUnsupported extends GkmError {\n\tconstructor(\n\t\treadonly packageManager: string,\n\t\treadonly allowScripts: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${packageManager} cannot rebuild named packages after an install ` +\n\t\t\t\t`without scripts, so ${allowScripts.join(', ')} cannot be allowed ` +\n\t\t\t\t'theirs. Use pnpm, npm or Yarn 2+, or install with every script ' +\n\t\t\t\t'skipped.',\n\t\t);\n\t\tthis.name = 'InstallScriptsAllowlistUnsupported';\n\t}\n}\n\n/**\n * npm's package-name grammar, less a leading `-`: each name is an argument to\n * `rebuild`, and must never be read as a flag.\n */\nconst PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\\/)?[a-z0-9~][a-z0-9._~-]*$/;\n\n/**\n * The commands an install runs, in order. Exported for the tests, which\n * check each package manager's flags without installing with all four.\n */\nexport function installCommands(\n\tpackageManager: PackageManager,\n\tcwd: string,\n\toptions: Pick<InstallOptions, 'ignoreScripts' | 'allowScripts'> = {},\n): [string, string[]][] {\n\tconst ignore = options.ignoreScripts ?? false;\n\tconst allow = ignore ? [...(options.allowScripts ?? [])] : [];\n\tfor (const name of allow) {\n\t\tif (!PACKAGE_NAME.test(name)) throw new InstallAllowlistNameInvalid(name);\n\t}\n\n\tswitch (packageManager) {\n\t\tcase 'pnpm':\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'pnpm',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t\t// pnpm 10 builds no dependency it was not told to, even by name;\n\t\t\t\t// this command names exactly the ones allowed, so it may build\n\t\t\t\t// what it names.\n\t\t\t\t...(allow.length > 0\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'pnpm',\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'rebuild',\n\t\t\t\t\t\t\t\t\t'--config.dangerouslyAllowAllBuilds=true',\n\t\t\t\t\t\t\t\t\t...allow,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t] as [string, string[]],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t];\n\t\tcase 'npm': {\n\t\t\tconst locked = existsSync(join(cwd, 'package-lock.json'));\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'npm',\n\t\t\t\t\t[locked ? 'ci' : 'install', ...(ignore ? ['--ignore-scripts'] : [])],\n\t\t\t\t],\n\t\t\t\t// npm 12 runs no dependency's install script its `allowScripts`\n\t\t\t\t// policy does not approve, rebuilt by name or not, and refuses\n\t\t\t\t// `--allow-scripts` on a project's command line. This command\n\t\t\t\t// names exactly the packages allowed, so it may run what it names.\n\t\t\t\t...(allow.length > 0\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'npm',\n\t\t\t\t\t\t\t\t['rebuild', '--dangerously-allow-all-scripts', ...allow],\n\t\t\t\t\t\t\t] as [string, string[]],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t];\n\t\t}\n\t\tcase 'yarn': {\n\t\t\t// Yarn 2+ keeps a `.yarnrc.yml`; it skips builds by mode and can\n\t\t\t// rebuild by name. Yarn 1 can only skip them all.\n\t\t\tconst berry = existsSync(join(cwd, '.yarnrc.yml'));\n\t\t\tif (berry) {\n\t\t\t\treturn [\n\t\t\t\t\t[\n\t\t\t\t\t\t'yarn',\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t'install',\n\t\t\t\t\t\t\t'--immutable',\n\t\t\t\t\t\t\t...(ignore ? ['--mode=skip-build'] : []),\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\t...(allow.length > 0\n\t\t\t\t\t\t? [['yarn', ['rebuild', ...allow]] as [string, string[]]]\n\t\t\t\t\t\t: []),\n\t\t\t\t];\n\t\t\t}\n\t\t\tif (allow.length > 0) {\n\t\t\t\tthrow new InstallScriptsAllowlistUnsupported('Yarn 1', allow);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'yarn',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t];\n\t\t}\n\t\tcase 'bun':\n\t\t\tif (allow.length > 0) {\n\t\t\t\tthrow new InstallScriptsAllowlistUnsupported('bun', allow);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'bun',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t];\n\t}\n}\n\n/**\n * Install the project's dependencies in `sandbox`.\n *\n * ```ts\n * // A checkout nobody has reviewed: no scripts but esbuild's.\n * await installDependencies(sandbox, {\n * ignoreScripts: true,\n * allowScripts: ['esbuild'],\n * });\n * ```\n *\n * Resolves with each command's result, in order — with its output when\n * `output` is `capture`.\n *\n * @throws {CommandFailed} when the package manager exits unsuccessfully.\n * @throws {InstallScriptsAllowlistUnsupported} for an allowlist the package\n * manager cannot honour, before anything is installed.\n */\nexport async function installDependencies(\n\tsandbox: Sandbox,\n\toptions: InstallOptions = {},\n): Promise<SandboxResult[]> {\n\tconst cwd = options.cwd ?? sandbox.root;\n\tconst results: SandboxResult[] = [];\n\tconst packageManager =\n\t\toptions.packageManager ?? detectPackageManager(resolve(sandbox.root, cwd));\n\n\tfor (const [command, args] of installCommands(\n\t\tpackageManager,\n\t\tresolve(sandbox.root, cwd),\n\t\toptions,\n\t)) {\n\t\tconst result = await sandbox.exec(command, args, {\n\t\t\tcwd,\n\t\t\tenv: { ...sandbox.env, ...options.env },\n\t\t\ttimeoutMs: options.timeoutMs ?? INSTALL_TIMEOUT_MS,\n\t\t\toutput: options.output ?? 'inherit',\n\t\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t});\n\t\tresults.push(result);\n\t\tif (result.exitCode !== 0) {\n\t\t\tthrow new CommandFailed(\n\t\t\t\tcommand,\n\t\t\t\targs,\n\t\t\t\tresult.exitCode,\n\t\t\t\tresult.signal as NodeJS.Signals | null,\n\t\t\t);\n\t\t}\n\t}\n\treturn results;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,qBAAqB;;AA6BlC,IAAa,8BAAb,cAAiDA,eAAAA,SAAS;CACpC;CAArB,YAAY,aAA8B;EACzC,MACC,IAAI,YAAY,yIAGjB;EALoB,KAAA,cAAA;EAMpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qCAAb,cAAwDA,eAAAA,SAAS;CAEtD;CACA;CAFV,YACC,gBACA,cACC;EACD,MACC,GAAG,eAAe,sEACM,aAAa,KAAK,IAAI,EAAE,2FAGjD;EARS,KAAA,iBAAA;EACA,KAAA,eAAA;EAQT,KAAK,OAAO;CACb;AACD;;;;;AAMA,MAAM,eAAe;;;;;AAMrB,SAAgB,gBACf,gBACA,KACA,UAAkE,CAAC,GAC5C;CACvB,MAAM,SAAS,QAAQ,iBAAiB;CACxC,MAAM,QAAQ,SAAS,CAAC,GAAI,QAAQ,gBAAgB,CAAC,CAAE,IAAI,CAAC;CAC5D,KAAK,MAAM,QAAQ,OAClB,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI,4BAA4B,IAAI;CAGzE,QAAQ,gBAAR;EACC,KAAK,QACJ,OAAO,CACN,CACC,QACA;GACC;GACA;GACA,GAAI,SAAS,CAAC,kBAAkB,IAAI,CAAC;EACtC,CACD,GAIA,GAAI,MAAM,SAAS,IAChB,CACA,CACC,QACA;GACC;GACA;GACA,GAAG;EACJ,CACD,CACD,IACC,CAAC,CACL;EACD,KAAK,OAEJ,OAAO,CACN,CACC,OACA,EAAA,GAJaC,QAAAA,WAAAA,EAAAA,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AK,SAAS,MAAM;GAChD;GACA,KAAK;IAAE,GAAG,QAAQ;IAAK,GAAG,QAAQ;GAAI;GACtC,WAAW,QAAQ,aAAA;GACnB,QAAQ,QAAQ,UAAU;GAC1B,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACpD,CAAC;EACD,QAAQ,KAAK,MAAM;EACnB,IAAI,OAAO,aAAa,GACvB,MAAM,IAAIC,YAAAA,cACT,SACA,MACA,OAAO,UACP,OAAO,MACR;CAEF;CACA,OAAO;AACR"}
1
+ {"version":3,"file":"public.cjs","names":["GkmError","existsSync","join","detectPackageManager","resolve","CommandFailed"],"sources":["../../src/sandbox/install.ts"],"sourcesContent":["/**\n * Installing a project's dependencies in a sandbox, with or without their\n * lifecycle scripts.\n *\n * `postinstall` is the oldest way into a build machine: any package in the\n * lockfile — a dependency of a dependency — runs whatever it likes the moment\n * it is installed. For a build the host trusts that is how native modules get\n * built. For one it does not, the scripts are skipped, and the few packages\n * that genuinely need theirs (esbuild's binary, a database driver) are named\n * and rebuilt — with nothing but the sandbox's environment either way.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { detectPackageManager, type PackageManager } from '../docker/templates';\nimport { GkmError } from '../errors';\nimport { CommandFailed } from '../run';\nimport type { Sandbox, SandboxOutput, SandboxResult } from './sandbox';\n\n/** Long enough for a cold install of a large monorepo. */\nexport const INSTALL_TIMEOUT_MS = 15 * 60_000;\n\nexport interface InstallOptions {\n\t/** The directory to install in. Defaults to the sandbox's root. */\n\tcwd?: string;\n\t/** Defaults to the one the lockfile above `cwd` names. */\n\tpackageManager?: PackageManager;\n\t/**\n\t * Skip every lifecycle script — dependencies' and the project's own —\n\t * except those of {@link allowScripts}. Defaults to false: scripts run as\n\t * a plain install runs them, under the package manager's own policy —\n\t * npm 12 and pnpm 10 skip dependencies' scripts nobody approved.\n\t */\n\tignoreScripts?: boolean;\n\t/**\n\t * With `ignoreScripts`, the packages whose scripts still run: rebuilt by\n\t * name once the install is done.\n\t */\n\tallowScripts?: readonly string[];\n\t/** Variables the install needs beyond the sandbox's own. */\n\tenv?: Readonly<Record<string, string>>;\n\t/** Defaults to {@link INSTALL_TIMEOUT_MS}, for each command. */\n\ttimeoutMs?: number;\n\t/** Where the package manager's output goes. Defaults to `inherit`. */\n\toutput?: SandboxOutput;\n\tsignal?: AbortSignal;\n}\n\n/** A name in `allowScripts` that is not a package name. */\nexport class InstallAllowlistNameInvalid extends GkmError {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name, so its scripts cannot be ` +\n\t\t\t\t'allowed. Name the package as it appears in package.json — ' +\n\t\t\t\t\"'esbuild', '@prisma/client'.\",\n\t\t);\n\t\tthis.name = 'InstallAllowlistNameInvalid';\n\t}\n}\n\n/** The package manager has no way to run only some packages' scripts. */\nexport class InstallScriptsAllowlistUnsupported extends GkmError {\n\tconstructor(\n\t\treadonly packageManager: string,\n\t\treadonly allowScripts: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${packageManager} cannot rebuild named packages after an install ` +\n\t\t\t\t`without scripts, so ${allowScripts.join(', ')} cannot be allowed ` +\n\t\t\t\t'theirs. Use pnpm, npm or Yarn 2+, or install with every script ' +\n\t\t\t\t'skipped.',\n\t\t);\n\t\tthis.name = 'InstallScriptsAllowlistUnsupported';\n\t}\n}\n\n/**\n * npm's package-name grammar, less a leading `-`: each name is an argument to\n * `rebuild`, and must never be read as a flag.\n */\nconst PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\\/)?[a-z0-9~][a-z0-9._~-]*$/;\n\n/**\n * The commands an install runs, in order. Exported for the tests, which\n * check each package manager's flags without installing with all four.\n */\nexport function installCommands(\n\tpackageManager: PackageManager,\n\tcwd: string,\n\toptions: Pick<InstallOptions, 'ignoreScripts' | 'allowScripts'> = {},\n): [string, string[]][] {\n\tconst ignore = options.ignoreScripts ?? false;\n\tconst allow = ignore ? [...(options.allowScripts ?? [])] : [];\n\tfor (const name of allow) {\n\t\tif (!PACKAGE_NAME.test(name)) throw new InstallAllowlistNameInvalid(name);\n\t}\n\n\tswitch (packageManager) {\n\t\tcase 'pnpm':\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'pnpm',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t\t// pnpm 10 builds no dependency it was not told to, even by name;\n\t\t\t\t// this command names exactly the ones allowed, so it may build\n\t\t\t\t// what it names.\n\t\t\t\t...(allow.length > 0\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'pnpm',\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'rebuild',\n\t\t\t\t\t\t\t\t\t'--config.dangerouslyAllowAllBuilds=true',\n\t\t\t\t\t\t\t\t\t...allow,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t] as [string, string[]],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t];\n\t\tcase 'npm': {\n\t\t\tconst locked = existsSync(join(cwd, 'package-lock.json'));\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'npm',\n\t\t\t\t\t[locked ? 'ci' : 'install', ...(ignore ? ['--ignore-scripts'] : [])],\n\t\t\t\t],\n\t\t\t\t// npm 12 runs no dependency's install script its `allowScripts`\n\t\t\t\t// policy does not approve, rebuilt by name or not, and refuses\n\t\t\t\t// `--allow-scripts` on a project's command line. This command\n\t\t\t\t// names exactly the packages allowed, so it may run what it names.\n\t\t\t\t...(allow.length > 0\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'npm',\n\t\t\t\t\t\t\t\t['rebuild', '--dangerously-allow-all-scripts', ...allow],\n\t\t\t\t\t\t\t] as [string, string[]],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t];\n\t\t}\n\t\tcase 'yarn': {\n\t\t\t// Yarn 2+ keeps a `.yarnrc.yml`; it skips builds by mode and can\n\t\t\t// rebuild by name. Yarn 1 can only skip them all.\n\t\t\tconst berry = existsSync(join(cwd, '.yarnrc.yml'));\n\t\t\tif (berry) {\n\t\t\t\treturn [\n\t\t\t\t\t[\n\t\t\t\t\t\t'yarn',\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t'install',\n\t\t\t\t\t\t\t'--immutable',\n\t\t\t\t\t\t\t...(ignore ? ['--mode=skip-build'] : []),\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\t...(allow.length > 0\n\t\t\t\t\t\t? [['yarn', ['rebuild', ...allow]] as [string, string[]]]\n\t\t\t\t\t\t: []),\n\t\t\t\t];\n\t\t\t}\n\t\t\tif (allow.length > 0) {\n\t\t\t\tthrow new InstallScriptsAllowlistUnsupported('Yarn 1', allow);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'yarn',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t];\n\t\t}\n\t\tcase 'bun':\n\t\t\tif (allow.length > 0) {\n\t\t\t\tthrow new InstallScriptsAllowlistUnsupported('bun', allow);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'bun',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t];\n\t}\n}\n\n/**\n * Install the project's dependencies in `sandbox`.\n *\n * ```ts\n * // A checkout nobody has reviewed: no scripts but esbuild's.\n * await installDependencies(sandbox, {\n * ignoreScripts: true,\n * allowScripts: ['esbuild'],\n * });\n * ```\n *\n * Resolves with each command's result, in order — with its output when\n * `output` is `capture`.\n *\n * @throws {CommandFailed} when the package manager exits unsuccessfully.\n * @throws {InstallScriptsAllowlistUnsupported} for an allowlist the package\n * manager cannot honour, before anything is installed.\n */\nexport async function installDependencies(\n\tsandbox: Sandbox,\n\toptions: InstallOptions = {},\n): Promise<SandboxResult[]> {\n\tconst cwd = options.cwd ?? sandbox.root;\n\tconst results: SandboxResult[] = [];\n\tconst packageManager =\n\t\toptions.packageManager ?? detectPackageManager(resolve(sandbox.root, cwd));\n\n\tfor (const [command, args] of installCommands(\n\t\tpackageManager,\n\t\tresolve(sandbox.root, cwd),\n\t\toptions,\n\t)) {\n\t\tconst result = await sandbox.exec(command, args, {\n\t\t\tcwd,\n\t\t\tenv: { ...sandbox.env, ...options.env },\n\t\t\ttimeoutMs: options.timeoutMs ?? INSTALL_TIMEOUT_MS,\n\t\t\toutput: options.output ?? 'inherit',\n\t\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t});\n\t\tresults.push(result);\n\t\tif (result.exitCode !== 0) {\n\t\t\tthrow new CommandFailed(\n\t\t\t\tcommand,\n\t\t\t\targs,\n\t\t\t\tresult.exitCode,\n\t\t\t\tresult.signal as NodeJS.Signals | null,\n\t\t\t);\n\t\t}\n\t}\n\treturn results;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,qBAAqB;;AA6BlC,IAAa,8BAAb,cAAiDA,eAAAA,SAAS;CACpC;CAArB,YAAY,aAA8B;EACzC,MACC,IAAI,YAAY,yIAGjB;EALoB,KAAA,cAAA;EAMpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qCAAb,cAAwDA,eAAAA,SAAS;CAEtD;CACA;CAFV,YACC,gBACA,cACC;EACD,MACC,GAAG,eAAe,sEACM,aAAa,KAAK,IAAI,EAAE,2FAGjD;EARS,KAAA,iBAAA;EACA,KAAA,eAAA;E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C,kBAAkB,IAAI,CAAC;GACtC,CACD,CACD;EAED,KAAK;GACJ,IAAI,MAAM,SAAS,GAClB,MAAM,IAAI,mCAAmC,OAAO,KAAK;GAE1D,OAAO,CACN,CACC,OACA;IACC;IACA;IACA,GAAI,SAAS,CAAC,kBAAkB,IAAI,CAAC;GACtC,CACD,CACD;CACF;AACD;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,oBACrB,SACA,UAA0B,CAAC,GACA;CAC3B,MAAM,MAAM,QAAQ,OAAO,QAAQ;CACnC,MAAM,UAA2B,CAAC;CAClC,MAAM,iBACL,QAAQ,kBAAkBC,cAAAA,sBAAAA,GAAqBC,UAAAA,QAAAA,CAAQ,QAAQ,MAAM,GAAG,CAAC;CAE1E,KAAK,MAAM,CAAC,SAAS,SAAS,gBAC7B,iBAAA,GACAA,UAAAA,QAAAA,CAAQ,QAAQ,MAAM,GAAG,GACzB,OACD,GAAG;EACF,MAAM,SAAS,MAAM,QAAQ,KAAK,SAAS,MAAM;GAChD;GACA,KAAK;IAAE,GAAG,QAAQ;IAAK,GAAG,QAAQ;GAAI;GACtC,WAAW,QAAQ,aAAA;GACnB,QAAQ,QAAQ,UAAU;GAC1B,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACpD,CAAC;EACD,QAAQ,KAAK,MAAM;EACnB,IAAI,OAAO,aAAa,GACvB,MAAM,IAAIC,cAAAA,cACT,SACA,MACA,OAAO,UACP,OAAO,MACR;CAEF;CACA,OAAO;AACR"}
@@ -1,8 +1,8 @@
1
- import { At as ReleasedImage, Bt as SandboxExecOptions, D as WorkspaceConfig, Dt as StateLocked, Et as LocalStateInCi, Ft as DeployIdentity, Gt as GkmError, Ht as SandboxResult, It as deployIdentity, Lt as SECRETS_DIR_ENV, Mt as GithubActor, Nt as LocalActor, Rt as Sandbox, St as ConstructsNotSerializable, U as AnyDeployTarget, Ut as SecretNameInvalid, Vt as SandboxOutput, Wt as confineCwd, _t as StoredCredentialsOptions, at as DeployPhase, bt as ProviderKind, ct as AppDeployResult, dt as Credential, ft as CredentialKind, gt as MissingCredential, ht as CredentialRequest, it as DeployEventType, jt as Actor, kt as StateVersionConflict, lt as DeployResult, mt as CredentialProvider, nt as DeployEvent, ot as ResourceChange, pt as CredentialKinds, r as GkmConfig, rt as DeployEventError, st as ResourceVia, ut as AwsCredential, vt as chainCredentials, xt as ConstructDiscoveryFailed, yt as storedCredentials, zt as SandboxCwdEscape } from "../types-BRnmoWCt.cjs";
2
- import "../index-DJzVO6Ht.cjs";
3
- import { i as ConfigLoadFailed, o as ConfigObjectNotSerializable } from "../config-lSOwPbUy.cjs";
4
- import "../clientTelemetry-Ej1tf1VE.cjs";
5
- import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-D_UphAAH.cjs";
1
+ import { At as ReleasedImage, Bt as SandboxExecOptions, D as WorkspaceConfig, Dt as StateLocked, Et as LocalStateInCi, Ft as DeployIdentity, Gt as GkmError, Ht as SandboxResult, It as deployIdentity, Lt as SECRETS_DIR_ENV, Mt as GithubActor, Nt as LocalActor, Rt as Sandbox, St as ConstructsNotSerializable, U as AnyDeployTarget, Ut as SecretNameInvalid, Vt as SandboxOutput, Wt as confineCwd, _t as StoredCredentialsOptions, at as DeployPhase, bt as ProviderKind, ct as AppDeployResult, dt as Credential, ft as CredentialKind, gt as MissingCredential, ht as CredentialRequest, it as DeployEventType, jt as Actor, kt as StateVersionConflict, lt as DeployResult, mt as CredentialProvider, nt as DeployEvent, ot as ResourceChange, pt as CredentialKinds, r as GkmConfig, rt as DeployEventError, st as ResourceVia, ut as AwsCredential, vt as chainCredentials, xt as ConstructDiscoveryFailed, yt as storedCredentials, zt as SandboxCwdEscape } from "../types-BVDaaLas.cjs";
2
+ import "../index-Cgd-ouyI.cjs";
3
+ import { i as ConfigLoadFailed, o as ConfigObjectNotSerializable } from "../config-D9g_nYIu.cjs";
4
+ import "../clientTelemetry-N8NAguGI.cjs";
5
+ import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-BtoiRP5G.cjs";
6
6
  import { ConstructManifest, Declaration } from "@geekmidas/manifest";
7
7
  import "@geekmidas/envkit/sniffer";
8
8
  import "@geekmidas/db/pg/roles";
@@ -1,8 +1,8 @@
1
- import { At as ReleasedImage, Bt as SandboxExecOptions, D as WorkspaceConfig, Dt as StateLocked, Et as LocalStateInCi, Ft as DeployIdentity, Gt as GkmError, Ht as SandboxResult, It as deployIdentity, Lt as SECRETS_DIR_ENV, Mt as GithubActor, Nt as LocalActor, Rt as Sandbox, St as ConstructsNotSerializable, U as AnyDeployTarget, Ut as SecretNameInvalid, Vt as SandboxOutput, Wt as confineCwd, _t as StoredCredentialsOptions, at as DeployPhase, bt as ProviderKind, ct as AppDeployResult, dt as Credential, ft as CredentialKind, gt as MissingCredential, ht as CredentialRequest, it as DeployEventType, jt as Actor, kt as StateVersionConflict, lt as DeployResult, mt as CredentialProvider, nt as DeployEvent, ot as ResourceChange, pt as CredentialKinds, r as GkmConfig, rt as DeployEventError, st as ResourceVia, ut as AwsCredential, vt as chainCredentials, xt as ConstructDiscoveryFailed, yt as storedCredentials, zt as SandboxCwdEscape } from "../types-Bg7LSAD2.mjs";
2
- import "../index-Ccsgoq3_.mjs";
3
- import { i as ConfigLoadFailed, o as ConfigObjectNotSerializable } from "../config-q4ewzIA_.mjs";
4
- import "../clientTelemetry-crdjgehZ.mjs";
5
- import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-BZlClwy2.mjs";
1
+ import { At as ReleasedImage, Bt as SandboxExecOptions, D as WorkspaceConfig, Dt as StateLocked, Et as LocalStateInCi, Ft as DeployIdentity, Gt as GkmError, Ht as SandboxResult, It as deployIdentity, Lt as SECRETS_DIR_ENV, Mt as GithubActor, Nt as LocalActor, Rt as Sandbox, St as ConstructsNotSerializable, U as AnyDeployTarget, Ut as SecretNameInvalid, Vt as SandboxOutput, Wt as confineCwd, _t as StoredCredentialsOptions, at as DeployPhase, bt as ProviderKind, ct as AppDeployResult, dt as Credential, ft as CredentialKind, gt as MissingCredential, ht as CredentialRequest, it as DeployEventType, jt as Actor, kt as StateVersionConflict, lt as DeployResult, mt as CredentialProvider, nt as DeployEvent, ot as ResourceChange, pt as CredentialKinds, r as GkmConfig, rt as DeployEventError, st as ResourceVia, ut as AwsCredential, vt as chainCredentials, xt as ConstructDiscoveryFailed, yt as storedCredentials, zt as SandboxCwdEscape } from "../types-CJTKWLkK.mjs";
2
+ import "../index-BThTZV8T.mjs";
3
+ import { i as ConfigLoadFailed, o as ConfigObjectNotSerializable } from "../config-CTrfNKYd.mjs";
4
+ import "../clientTelemetry-Bzc4KXz5.mjs";
5
+ import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-Ct41f0tN.mjs";
6
6
  import { ConstructManifest, Declaration } from "@geekmidas/manifest";
7
7
  import "@geekmidas/db/pg/roles";
8
8
  import "@aws-sdk/client-s3";