@geekmidas/cli 10.0.0-alpha.163 → 10.0.0-alpha.165

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 (223) hide show
  1. package/dist/{GoDaddyProvider-COSh6bNI.mjs → GoDaddyProvider-C7zClznh.mjs} +2 -2
  2. package/dist/{GoDaddyProvider-COSh6bNI.mjs.map → GoDaddyProvider-C7zClznh.mjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-DyhN8PEn.cjs → GoDaddyProvider-Dx6v4Goj.cjs} +2 -2
  4. package/dist/{GoDaddyProvider-DyhN8PEn.cjs.map → GoDaddyProvider-Dx6v4Goj.cjs.map} +1 -1
  5. package/dist/{HostingerProvider-5Nekoneq.mjs → HostingerProvider-BALtMnss.mjs} +2 -2
  6. package/dist/{HostingerProvider-5Nekoneq.mjs.map → HostingerProvider-BALtMnss.mjs.map} +1 -1
  7. package/dist/{HostingerProvider-DG08aTyh.cjs → HostingerProvider-COuTy74z.cjs} +2 -2
  8. package/dist/{HostingerProvider-DG08aTyh.cjs.map → HostingerProvider-COuTy74z.cjs.map} +1 -1
  9. package/dist/{LegacyStateStore-5W4kFia3.cjs → LegacyStateStore-C0rh3dKV.cjs} +3 -3
  10. package/dist/{LegacyStateStore-5W4kFia3.cjs.map → LegacyStateStore-C0rh3dKV.cjs.map} +1 -1
  11. package/dist/{LegacyStateStore-CafGn2Yl.mjs → LegacyStateStore-CcNLLGX-.mjs} +3 -3
  12. package/dist/{LegacyStateStore-CafGn2Yl.mjs.map → LegacyStateStore-CcNLLGX-.mjs.map} +1 -1
  13. package/dist/{LocalStateStore-DrTw_EIu.mjs → LocalStateStore-CxCCBQkS.mjs} +2 -2
  14. package/dist/{LocalStateStore-DrTw_EIu.mjs.map → LocalStateStore-CxCCBQkS.mjs.map} +1 -1
  15. package/dist/{LocalStateStore--CJ7ksx6.cjs → LocalStateStore-Dcq3wd1v.cjs} +2 -2
  16. package/dist/{LocalStateStore--CJ7ksx6.cjs.map → LocalStateStore-Dcq3wd1v.cjs.map} +1 -1
  17. package/dist/{S3StateStore-M8vVPpr7.cjs → S3StateStore-Cgf1owUZ.cjs} +4 -4
  18. package/dist/{S3StateStore-M8vVPpr7.cjs.map → S3StateStore-Cgf1owUZ.cjs.map} +1 -1
  19. package/dist/{S3StateStore-DGEwSkf2.mjs → S3StateStore-DUwCcCgj.mjs} +4 -4
  20. package/dist/{S3StateStore-DGEwSkf2.mjs.map → S3StateStore-DUwCcCgj.mjs.map} +1 -1
  21. package/dist/{SSMStateStore-VYfuykBd.mjs → SSMStateStore-A_N_T4b0.mjs} +2 -2
  22. package/dist/{SSMStateStore-VYfuykBd.mjs.map → SSMStateStore-A_N_T4b0.mjs.map} +1 -1
  23. package/dist/{SSMStateStore-B2A27u0C.cjs → SSMStateStore-BarWA07O.cjs} +2 -2
  24. package/dist/{SSMStateStore-B2A27u0C.cjs.map → SSMStateStore-BarWA07O.cjs.map} +1 -1
  25. package/dist/{add-CistiUc6.mjs → add-DAeCqI9O.mjs} +5 -5
  26. package/dist/{add-CistiUc6.mjs.map → add-DAeCqI9O.mjs.map} +1 -1
  27. package/dist/{add-CijlgwVr.cjs → add-DVSNjsI8.cjs} +5 -5
  28. package/dist/{add-CijlgwVr.cjs.map → add-DVSNjsI8.cjs.map} +1 -1
  29. package/dist/{apps-BE97n0jO.mjs → apps-Ck_Ie6gN.mjs} +17 -12
  30. package/dist/apps-Ck_Ie6gN.mjs.map +1 -0
  31. package/dist/{apps-5iJb710M.cjs → apps-S3RMvFyk.cjs} +17 -12
  32. package/dist/apps-S3RMvFyk.cjs.map +1 -0
  33. package/dist/{bundler-D4E7kCYb.cjs → bundler-B_vQ_591.cjs} +6 -6
  34. package/dist/{bundler-D4E7kCYb.cjs.map → bundler-B_vQ_591.cjs.map} +1 -1
  35. package/dist/{bundler-D-SXSUZI.mjs → bundler-Bbn0opSb.mjs} +6 -6
  36. package/dist/{bundler-D-SXSUZI.mjs.map → bundler-Bbn0opSb.mjs.map} +1 -1
  37. package/dist/{cli-BAn-gJ6S.mjs → cli-CMykD9Py.mjs} +5 -5
  38. package/dist/{cli-BAn-gJ6S.mjs.map → cli-CMykD9Py.mjs.map} +1 -1
  39. package/dist/{cli-CI-wO3-w.cjs → cli-fs4D-3cd.cjs} +5 -5
  40. package/dist/{cli-CI-wO3-w.cjs.map → cli-fs4D-3cd.cjs.map} +1 -1
  41. package/dist/{compose-Dk0Z8zdf.mjs → compose-BtjZNCC-.mjs} +21 -9
  42. package/dist/compose-BtjZNCC-.mjs.map +1 -0
  43. package/dist/{compose-Dpkkp-Qq.cjs → compose-CNJO99Tv.cjs} +5 -5
  44. package/dist/{compose-Dpkkp-Qq.cjs.map → compose-CNJO99Tv.cjs.map} +1 -1
  45. package/dist/{compose-CuoV9T9U.mjs → compose-Cm6EWvjX.mjs} +5 -5
  46. package/dist/{compose-CuoV9T9U.mjs.map → compose-Cm6EWvjX.mjs.map} +1 -1
  47. package/dist/{compose-BoxgqTF8.cjs → compose-DmcYTLhO.cjs} +21 -9
  48. package/dist/compose-DmcYTLhO.cjs.map +1 -0
  49. package/dist/{config-DNoWqavN.d.cts → config-B8gSu59v.d.mts} +3 -3
  50. package/dist/{config-BxSSAzVi.d.mts.map → config-B8gSu59v.d.mts.map} +1 -1
  51. package/dist/{config-CLXSXbcs.cjs → config-CXj-9eRo.cjs} +77 -8
  52. package/dist/config-CXj-9eRo.cjs.map +1 -0
  53. package/dist/{config-Da9bxnkT.mjs → config-Di0oJwM9.mjs} +72 -9
  54. package/dist/config-Di0oJwM9.mjs.map +1 -0
  55. package/dist/{config-BxSSAzVi.d.mts → config-u5XdE1Cq.d.cts} +3 -3
  56. package/dist/{config-DNoWqavN.d.cts.map → config-u5XdE1Cq.d.cts.map} +1 -1
  57. package/dist/config.cjs +1 -1
  58. package/dist/config.d.cts +3 -3
  59. package/dist/config.d.mts +3 -3
  60. package/dist/config.mjs +1 -1
  61. package/dist/{credentials-DhCCRQJp.mjs → credentials-C-yuISKH.mjs} +5 -5
  62. package/dist/{credentials-DhCCRQJp.mjs.map → credentials-C-yuISKH.mjs.map} +1 -1
  63. package/dist/{credentials-BR3dNNtO.cjs → credentials-DVYgFK_H.cjs} +5 -5
  64. package/dist/{credentials-BR3dNNtO.cjs.map → credentials-DVYgFK_H.cjs.map} +1 -1
  65. package/dist/deploy/public.cjs +12 -12
  66. package/dist/deploy/public.d.cts +4 -4
  67. package/dist/deploy/public.d.cts.map +1 -1
  68. package/dist/deploy/public.d.mts +4 -4
  69. package/dist/deploy/public.d.mts.map +1 -1
  70. package/dist/deploy/public.mjs +12 -12
  71. package/dist/{deploy-C4Qb-A-z.mjs → deploy-CuSF9y7t.mjs} +167 -58
  72. package/dist/deploy-CuSF9y7t.mjs.map +1 -0
  73. package/dist/{deploy-CGywNg5R.cjs → deploy-DGXMqTan.cjs} +166 -57
  74. package/dist/deploy-DGXMqTan.cjs.map +1 -0
  75. package/dist/{destroy-IUx8vz1q.cjs → destroy-BROvAzQQ.cjs} +10 -10
  76. package/dist/{destroy-IUx8vz1q.cjs.map → destroy-BROvAzQQ.cjs.map} +1 -1
  77. package/dist/{destroy-xjqqzAmU.mjs → destroy-DpRGLdt1.mjs} +10 -10
  78. package/dist/{destroy-xjqqzAmU.mjs.map → destroy-DpRGLdt1.mjs.map} +1 -1
  79. package/dist/{docker-zaY5JoqN.mjs → docker-CRVWdGH9.mjs} +5 -5
  80. package/dist/{docker-zaY5JoqN.mjs.map → docker-CRVWdGH9.mjs.map} +1 -1
  81. package/dist/{docker-CIpOFfOw.cjs → docker-qq5xNUP2.cjs} +5 -5
  82. package/dist/{docker-CIpOFfOw.cjs.map → docker-qq5xNUP2.cjs.map} +1 -1
  83. package/dist/{dokploy-BTzdAG5F.mjs → dokploy-DcH7hY84.mjs} +2 -2
  84. package/dist/{dokploy-BTzdAG5F.mjs.map → dokploy-DcH7hY84.mjs.map} +1 -1
  85. package/dist/{dokploy-DLVSItVD.cjs → dokploy-Duyj4-pa.cjs} +2 -2
  86. package/dist/{dokploy-DLVSItVD.cjs.map → dokploy-Duyj4-pa.cjs.map} +1 -1
  87. package/dist/{eas-C1WvLOi1.mjs → eas-C11dyfIw.mjs} +3 -3
  88. package/dist/{eas-C1WvLOi1.mjs.map → eas-C11dyfIw.mjs.map} +1 -1
  89. package/dist/{eas-B6VYsGLs.cjs → eas-DqTDImhv.cjs} +3 -3
  90. package/dist/{eas-B6VYsGLs.cjs.map → eas-DqTDImhv.cjs.map} +1 -1
  91. package/dist/{encryption-oVcZSyLK.cjs → encryption-CsOfA6QT.cjs} +3 -3
  92. package/dist/{encryption-oVcZSyLK.cjs.map → encryption-CsOfA6QT.cjs.map} +1 -1
  93. package/dist/{encryption-DdnL7dor.mjs → encryption-DsZwqQyL.mjs} +3 -3
  94. package/dist/{encryption-DdnL7dor.mjs.map → encryption-DsZwqQyL.mjs.map} +1 -1
  95. package/dist/{engine-Viv9p-yK.mjs → engine-CdU3Oggs.mjs} +10 -10
  96. package/dist/{engine-Viv9p-yK.mjs.map → engine-CdU3Oggs.mjs.map} +1 -1
  97. package/dist/{engine-_zA1Selg.cjs → engine-WllCnGNy.cjs} +10 -10
  98. package/dist/{engine-_zA1Selg.cjs.map → engine-WllCnGNy.cjs.map} +1 -1
  99. package/dist/{github-82k5-OZO.cjs → github-B3lKrKIn.cjs} +7 -7
  100. package/dist/{github-82k5-OZO.cjs.map → github-B3lKrKIn.cjs.map} +1 -1
  101. package/dist/{github-DxgGIvq1.mjs → github-Bt3V7pdf.mjs} +7 -7
  102. package/dist/{github-DxgGIvq1.mjs.map → github-Bt3V7pdf.mjs.map} +1 -1
  103. package/dist/{googlePlay-C5T1SOGW.cjs → googlePlay-B7P3Ahps.cjs} +5 -5
  104. package/dist/{googlePlay-C5T1SOGW.cjs.map → googlePlay-B7P3Ahps.cjs.map} +1 -1
  105. package/dist/{googlePlay-C4UsG1Vd.mjs → googlePlay-D-6pUHGU.mjs} +5 -5
  106. package/dist/{googlePlay-C4UsG1Vd.mjs.map → googlePlay-D-6pUHGU.mjs.map} +1 -1
  107. package/dist/{index-Dy4ojz5P.d.cts → index-1H93w_H6.d.cts} +2 -2
  108. package/dist/{index-BC1BLv9Q.d.mts.map → index-1H93w_H6.d.cts.map} +1 -1
  109. package/dist/{index-BC1BLv9Q.d.mts → index-DFZ0SMwN.d.mts} +2 -2
  110. package/dist/{index-Dy4ojz5P.d.cts.map → index-DFZ0SMwN.d.mts.map} +1 -1
  111. package/dist/index.cjs +64 -64
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.mjs +64 -64
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/{local-Bqx5Xj3z.mjs → local-B4H2Lsr6.mjs} +2 -2
  116. package/dist/{local-Bqx5Xj3z.mjs.map → local-B4H2Lsr6.mjs.map} +1 -1
  117. package/dist/{local-vSeEreyp.cjs → local-Cs_aQJ45.cjs} +2 -2
  118. package/dist/{local-vSeEreyp.cjs.map → local-Cs_aQJ45.cjs.map} +1 -1
  119. package/dist/{migrate-DvdpT5Y4.cjs → migrate-BQSPfKHa.cjs} +5 -5
  120. package/dist/{migrate-DvdpT5Y4.cjs.map → migrate-BQSPfKHa.cjs.map} +1 -1
  121. package/dist/{migrate-D8PSR_08.mjs → migrate-C8JFuMT-.mjs} +3 -3
  122. package/dist/{migrate-D8PSR_08.mjs.map → migrate-C8JFuMT-.mjs.map} +1 -1
  123. package/dist/{migrate-CEhUGDFy.mjs → migrate-CQ-PNghX.mjs} +5 -5
  124. package/dist/{migrate-CEhUGDFy.mjs.map → migrate-CQ-PNghX.mjs.map} +1 -1
  125. package/dist/{migrate-CLSY8gSY.cjs → migrate-CphnV0sY.cjs} +3 -3
  126. package/dist/{migrate-CLSY8gSY.cjs.map → migrate-CphnV0sY.cjs.map} +1 -1
  127. package/dist/{notes-B9ro_R3x.cjs → notes-BtyuHcKA.cjs} +4 -4
  128. package/dist/notes-BtyuHcKA.cjs.map +1 -0
  129. package/dist/{notes-CdbUjLBC.mjs → notes-IlQ35E3R.mjs} +4 -4
  130. package/dist/notes-IlQ35E3R.mjs.map +1 -0
  131. package/dist/openapi.cjs +1 -1
  132. package/dist/openapi.d.cts +1 -1
  133. package/dist/openapi.d.mts +1 -1
  134. package/dist/openapi.mjs +1 -1
  135. package/dist/{projectBucket-DUtWAxWn.cjs → projectBucket-0Lvy2J0h.cjs} +2 -2
  136. package/dist/{projectBucket-DUtWAxWn.cjs.map → projectBucket-0Lvy2J0h.cjs.map} +1 -1
  137. package/dist/{projectBucket-DPaUiLyY.mjs → projectBucket-SHlF0_Pr.mjs} +2 -2
  138. package/dist/{projectBucket-DPaUiLyY.mjs.map → projectBucket-SHlF0_Pr.mjs.map} +1 -1
  139. package/dist/{publish-CoCRpbPl.mjs → publish-C9IJb1Ez.mjs} +2 -2
  140. package/dist/{publish-CoCRpbPl.mjs.map → publish-C9IJb1Ez.mjs.map} +1 -1
  141. package/dist/{publish-DbR3j4TS.cjs → publish-igpjCzZj.cjs} +2 -2
  142. package/dist/{publish-DbR3j4TS.cjs.map → publish-igpjCzZj.cjs.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-DDcPuS_G.cjs → resolve-5T34quci.cjs} +4 -4
  146. package/dist/{resolve-DDcPuS_G.cjs.map → resolve-5T34quci.cjs.map} +1 -1
  147. package/dist/{resolve-BjRvKEpw.mjs → resolve-Cl8CVASM.mjs} +4 -4
  148. package/dist/{resolve-BjRvKEpw.mjs.map → resolve-Cl8CVASM.mjs.map} +1 -1
  149. package/dist/{rollback-xLGFZaHy.mjs → rollback-1JLE6qPo.mjs} +7 -7
  150. package/dist/{rollback-xLGFZaHy.mjs.map → rollback-1JLE6qPo.mjs.map} +1 -1
  151. package/dist/{rollback-CvlebzBY.cjs → rollback-DMPb940C.cjs} +7 -7
  152. package/dist/{rollback-CvlebzBY.cjs.map → rollback-DMPb940C.cjs.map} +1 -1
  153. package/dist/{runtime-MZ5Pqgan.d.mts → runtime-CKOkIrw0.d.cts} +2 -2
  154. package/dist/{runtime-BySbkdBz.d.cts.map → runtime-CKOkIrw0.d.cts.map} +1 -1
  155. package/dist/{runtime-BySbkdBz.d.cts → runtime-Cdvv8SfU.d.mts} +2 -2
  156. package/dist/{runtime-MZ5Pqgan.d.mts.map → runtime-Cdvv8SfU.d.mts.map} +1 -1
  157. package/dist/{s3-CXA6Lleo.mjs → s3-CCuNLgHk.mjs} +2 -2
  158. package/dist/{s3-CXA6Lleo.mjs.map → s3-CCuNLgHk.mjs.map} +1 -1
  159. package/dist/{s3-D9pFisyo.cjs → s3-DkiOi5J1.cjs} +2 -2
  160. package/dist/{s3-D9pFisyo.cjs.map → s3-DkiOi5J1.cjs.map} +1 -1
  161. package/dist/{seeds-D7q1zKCJ.cjs → seeds-Bc3niNVb.cjs} +95 -82
  162. package/dist/seeds-Bc3niNVb.cjs.map +1 -0
  163. package/dist/{seeds-y1rzXlAc.mjs → seeds-Ccn0Ru2T.mjs} +84 -83
  164. package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
  165. package/dist/{serverSetup-CzoKT3nH.mjs → serverSetup-C0pLpF5w.mjs} +7 -7
  166. package/dist/{serverSetup-CzoKT3nH.mjs.map → serverSetup-C0pLpF5w.mjs.map} +1 -1
  167. package/dist/{serverSetup-BXk8SGuz.cjs → serverSetup-JYZxj371.cjs} +7 -7
  168. package/dist/{serverSetup-BXk8SGuz.cjs.map → serverSetup-JYZxj371.cjs.map} +1 -1
  169. package/dist/{sniffer-Csft3UaJ.mjs → sniffer-CiV4xGbe.mjs} +7 -7
  170. package/dist/{sniffer-Csft3UaJ.mjs.map → sniffer-CiV4xGbe.mjs.map} +1 -1
  171. package/dist/{sniffer-B2jgjk-F.cjs → sniffer-DB4Ocija.cjs} +7 -7
  172. package/dist/{sniffer-B2jgjk-F.cjs.map → sniffer-DB4Ocija.cjs.map} +1 -1
  173. package/dist/{snsSubscriptions-DgbFGyac.mjs → snsSubscriptions-C_-6fqBd.mjs} +2 -2
  174. package/dist/{snsSubscriptions-DgbFGyac.mjs.map → snsSubscriptions-C_-6fqBd.mjs.map} +1 -1
  175. package/dist/{snsSubscriptions-CSyPnoEQ.cjs → snsSubscriptions-DpYvMVR9.cjs} +2 -2
  176. package/dist/{snsSubscriptions-CSyPnoEQ.cjs.map → snsSubscriptions-DpYvMVR9.cjs.map} +1 -1
  177. package/dist/{sst-CmNUadAV.mjs → sst-BUzuE84X.mjs} +5 -5
  178. package/dist/{sst-CmNUadAV.mjs.map → sst-BUzuE84X.mjs.map} +1 -1
  179. package/dist/{sst-BtrgnhHy.cjs → sst-D1oSl_1d.cjs} +5 -5
  180. package/dist/{sst-BtrgnhHy.cjs.map → sst-D1oSl_1d.cjs.map} +1 -1
  181. package/dist/{stack-dVgzDUiH.mjs → stack-DhBBTTIa.mjs} +8 -8
  182. package/dist/stack-DhBBTTIa.mjs.map +1 -0
  183. package/dist/{stack-9qBhn2pd.cjs → stack-TUs2DY7v.cjs} +8 -8
  184. package/dist/stack-TUs2DY7v.cjs.map +1 -0
  185. package/dist/{stage-HEZZZJKr.cjs → stage-B3qg7LoZ.cjs} +6 -6
  186. package/dist/{stage-HEZZZJKr.cjs.map → stage-B3qg7LoZ.cjs.map} +1 -1
  187. package/dist/{stage-CwXpkN-y.mjs → stage-DuLwZ9wu.mjs} +6 -6
  188. package/dist/{stage-CwXpkN-y.mjs.map → stage-DuLwZ9wu.mjs.map} +1 -1
  189. package/dist/{stages-gG-DGHLb.mjs → stages-CW7qtiJ2.mjs} +2 -2
  190. package/dist/{stages-gG-DGHLb.mjs.map → stages-CW7qtiJ2.mjs.map} +1 -1
  191. package/dist/{stages-rzyes8Ew.cjs → stages-CtqmEJJW.cjs} +2 -2
  192. package/dist/{stages-rzyes8Ew.cjs.map → stages-CtqmEJJW.cjs.map} +1 -1
  193. package/dist/target/public.cjs +1 -1
  194. package/dist/target/public.d.cts +2 -2
  195. package/dist/target/public.d.mts +2 -2
  196. package/dist/target/public.mjs +1 -1
  197. package/dist/{terminal-BqqGsi0O.mjs → terminal-B_TanNPL.mjs} +2 -2
  198. package/dist/{terminal-BqqGsi0O.mjs.map → terminal-B_TanNPL.mjs.map} +1 -1
  199. package/dist/{terminal-8AA2uK0U.cjs → terminal-CXZWPHMW.cjs} +2 -2
  200. package/dist/{terminal-8AA2uK0U.cjs.map → terminal-CXZWPHMW.cjs.map} +1 -1
  201. package/dist/{types-BsfPHUFZ.d.cts → types-DEmuMHsS.d.cts} +9 -1
  202. package/dist/types-DEmuMHsS.d.cts.map +1 -0
  203. package/dist/{types-BXboFkn9.d.mts → types-g_S0_RAi.d.mts} +9 -1
  204. package/dist/types-g_S0_RAi.d.mts.map +1 -0
  205. package/dist/workspace/index.d.cts +2 -2
  206. package/dist/workspace/index.d.mts +2 -2
  207. package/package.json +15 -15
  208. package/dist/apps-5iJb710M.cjs.map +0 -1
  209. package/dist/apps-BE97n0jO.mjs.map +0 -1
  210. package/dist/compose-BoxgqTF8.cjs.map +0 -1
  211. package/dist/compose-Dk0Z8zdf.mjs.map +0 -1
  212. package/dist/config-CLXSXbcs.cjs.map +0 -1
  213. package/dist/config-Da9bxnkT.mjs.map +0 -1
  214. package/dist/deploy-C4Qb-A-z.mjs.map +0 -1
  215. package/dist/deploy-CGywNg5R.cjs.map +0 -1
  216. package/dist/notes-B9ro_R3x.cjs.map +0 -1
  217. package/dist/notes-CdbUjLBC.mjs.map +0 -1
  218. package/dist/seeds-D7q1zKCJ.cjs.map +0 -1
  219. package/dist/seeds-y1rzXlAc.mjs.map +0 -1
  220. package/dist/stack-9qBhn2pd.cjs.map +0 -1
  221. package/dist/stack-dVgzDUiH.mjs.map +0 -1
  222. package/dist/types-BXboFkn9.d.mts.map +0 -1
  223. package/dist/types-BsfPHUFZ.d.cts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  const require_errors = require("./errors-DMC4Umsb.cjs");
2
2
  const require_workspace = require("./workspace-VhzmoxOv.cjs");
3
- const require_projectBucket = require("./projectBucket-DUtWAxWn.cjs");
3
+ const require_projectBucket = require("./projectBucket-0Lvy2J0h.cjs");
4
4
  const require_awsStore = require("./awsStore-u3ehhMoY.cjs");
5
5
  let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
6
6
  let _aws_sdk_client_sts = require("@aws-sdk/client-sts");
@@ -237,4 +237,4 @@ var S3SecretsStore = class {
237
237
  //#endregion
238
238
  exports.S3SecretsStore = S3SecretsStore;
239
239
 
240
- //# sourceMappingURL=s3-D9pFisyo.cjs.map
240
+ //# sourceMappingURL=s3-DkiOi5J1.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"s3-D9pFisyo.cjs","names":["GkmError","projectBucketName","s3SecretsKey","awsClientConfig","S3Client","STSClient","withStageCredentials","callerAccountId","ensureProjectBucket","findProjectBucket","GetObjectCommand","PutObjectCommand","ListObjectVersionsCommand","DeleteObjectsCommand","HeadObjectCommand"],"sources":["../src/secrets/s3.ts"],"sourcesContent":["/**\n * A stage's secrets in S3: one object per stage,\n * `<prefix>/<project>/<stage>/secrets.json`, in the project bucket beside the\n * deploy state (`providers/projectBucket.ts`) — or in a bucket the config\n * names, which must exist.\n *\n * Encrypted at rest with SSE-S3, asked for on every write although the\n * project bucket defaults to it, so no KMS key is another place to keep. The\n * bucket's versioning keeps every past document. Unlike an SSM parameter\n * there is no size to outgrow.\n *\n * The project bucket is created by the first write, never by a read: a stage\n * whose bucket or object does not exist yet has no secrets. Every write is\n * conditional — `If-Match` on the ETag this store last read for the stage,\n * `If-None-Match: *` when it read none — so two `secrets:set` runs at once\n * cannot each overwrite the other's key: the second is refused with\n * {@link StageSecretsChanged}.\n */\n\nimport {\n\tDeleteObjectsCommand,\n\tGetObjectCommand,\n\tHeadObjectCommand,\n\tListObjectVersionsCommand,\n\tPutObjectCommand,\n\tS3Client,\n\ttype S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { STSClient } from '@aws-sdk/client-sts';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\nimport {\n\tcallerAccountId,\n\tensureProjectBucket,\n\tfindProjectBucket,\n\tprojectBucketName,\n} from '../providers/projectBucket.js';\nimport {\n\ttype AwsStoreOptions,\n\tawsClientConfig,\n\twithStageCredentials,\n} from './awsStore.js';\nimport { s3SecretsKey } from './providers.js';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface S3SecretsStoreOptions extends AwsStoreOptions {\n\t/** The deploy identity: the project bucket's name and its tag. */\n\tidentity: Pick<DeployIdentity, 'scope' | 'key'>;\n\t/** A bucket that exists; omitted, the project bucket. */\n\tbucket?: string;\n\t/** Key prefix inside the bucket, without a trailing slash. */\n\tprefix: string;\n\t/** For tests: credentials to use instead of the default chain. */\n\tcredentials?: S3ClientConfig['credentials'];\n}\n\n/**\n * Another run wrote the stage's secrets after this one read them. Nothing was\n * written: the change is to be made again, on top of theirs.\n */\nexport class StageSecretsChanged extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** `s3://<bucket>/<key>` */\n\t\treadonly location: string,\n\t) {\n\t\tsuper(\n\t\t\t`The secrets for stage \"${stage}\" at ${location} changed after this command read them — ` +\n\t\t\t\t'another secrets command or deploy wrote them first. Nothing was written; run the command ' +\n\t\t\t\t'again to make the change on top of theirs.',\n\t\t);\n\t\tthis.name = 'StageSecretsChanged';\n\t}\n}\n\ninterface S3Failure {\n\tname?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/** A conditional write that lost: the object is not what the write assumed. */\nfunction lostRace(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'PreconditionFailed' ||\n\t\tname === 'ConditionalRequestConflict' ||\n\t\t$metadata?.httpStatusCode === 412 ||\n\t\t$metadata?.httpStatusCode === 409\n\t);\n}\n\nfunction notFound(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'NoSuchKey' ||\n\t\tname === 'NotFound' ||\n\t\t$metadata?.httpStatusCode === 404\n\t);\n}\n\nexport class S3SecretsStore implements SecretsStore {\n\treadonly name = 's3';\n\n\tprivate clients?: { s3: S3Client; sts: STSClient };\n\t/** The bucket's name, once known. */\n\tprivate bucketName?: string;\n\t/** Whether the bucket is known to exist. */\n\tprivate exists = false;\n\t/** The ETag each stage was last read at — null: read, and not there. */\n\tprivate readonly etags = new Map<string, string | null>();\n\n\tconstructor(private readonly options: S3SecretsStoreOptions) {\n\t\tif (options.bucket) {\n\t\t\tthis.bucketName = options.bucket;\n\t\t\tthis.exists = true;\n\t\t}\n\t}\n\n\t/** The bucket's name; the project bucket's is known after the first call. */\n\tget bucket(): string {\n\t\treturn (\n\t\t\tthis.bucketName ??\n\t\t\tprojectBucketName(this.options.identity.scope, '<account id>')\n\t\t);\n\t}\n\n\t/** Where a stage's secrets are kept: `s3://<bucket>/<key>`. */\n\tlocation(stage: string): string {\n\t\treturn `s3://${this.bucket}/${this.key(stage)}`;\n\t}\n\n\tprivate key(stage: string): string {\n\t\treturn s3SecretsKey(this.options.prefix, this.options.project, stage);\n\t}\n\n\tprivate async client(): Promise<{ s3: S3Client; sts: STSClient }> {\n\t\tif (this.clients) return this.clients;\n\t\tconst base = await awsClientConfig(this.options);\n\t\tconst endpoint =\n\t\t\tbase.endpoint ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL_S3 ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL;\n\t\tconst credentials = this.options.credentials ?? base.credentials;\n\t\tthis.clients = {\n\t\t\ts3: new S3Client({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(endpoint ? { endpoint, forcePathStyle: true } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t\tsts: new STSClient({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(base.endpoint ? { endpoint: base.endpoint } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t};\n\t\treturn this.clients;\n\t}\n\n\t/** One AWS call, a missing or expired credential refused by name. */\n\tprivate call<T>(\n\t\tstage: string,\n\t\taccess: 'read' | 'write',\n\t\trun: () => Promise<T>,\n\t): Promise<T> {\n\t\treturn withStageCredentials(\n\t\t\t{ stage, store: this.name, profile: this.options.profile, access },\n\t\t\trun,\n\t\t);\n\t}\n\n\t/**\n\t * The bucket, or null for a project bucket that does not exist yet and is\n\t * not to be created (a read).\n\t */\n\tprivate async use(\n\t\tstage: string,\n\t\tcreate: boolean,\n\t): Promise<{ s3: S3Client; bucket: string | null }> {\n\t\tconst { s3, sts } = await this.client();\n\t\tif (this.exists) return { s3, bucket: this.bucketName! };\n\t\tconst access = create ? 'write' : 'read';\n\t\tthis.bucketName ??= projectBucketName(\n\t\t\tthis.options.identity.scope,\n\t\t\tawait this.call(stage, access, () => callerAccountId(sts)),\n\t\t);\n\t\tconst bucket = this.bucketName;\n\t\tif (create) {\n\t\t\tawait this.call(stage, access, () =>\n\t\t\t\tensureProjectBucket(s3, {\n\t\t\t\t\tbucket,\n\t\t\t\t\tregion: this.options.region,\n\t\t\t\t\tidentity: this.options.identity,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (\n\t\t\t(await this.call(stage, access, () => findProjectBucket(s3, bucket))) ===\n\t\t\t'none'\n\t\t) {\n\t\t\treturn { s3, bucket: null };\n\t\t}\n\t\tthis.exists = true;\n\t\treturn { s3, bucket };\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * read it with, or they have expired\n\t */\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) {\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tconst response = await this.call(stage, 'read', () =>\n\t\t\t\ts3.send(new GetObjectCommand({ Bucket: bucket, Key: this.key(stage) })),\n\t\t\t);\n\t\t\tconst body = await (\n\t\t\t\tresponse.Body as {\n\t\t\t\t\ttransformToString(encoding: string): Promise<string>;\n\t\t\t\t}\n\t\t\t).transformToString('utf-8');\n\t\t\tthis.remember(stage, response.ETag);\n\t\t\treturn JSON.parse(body) as StageSecrets;\n\t\t} catch (error) {\n\t\t\tif (!notFound(error)) throw error;\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Replace the stage's secrets — on the condition that they are still what\n\t * this store last read. A stage never read here is replaced as it is now.\n\t *\n\t * @throws {StageSecretsChanged} when another run wrote them in between\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * write it with, or they have expired\n\t */\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, true);\n\t\tconst Bucket = bucket!;\n\t\tconst Key = this.key(stage);\n\t\tconst expected = this.etags.has(stage)\n\t\t\t? (this.etags.get(stage) ?? null)\n\t\t\t: await this.currentEtag(s3, stage, Bucket, Key);\n\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew PutObjectCommand({\n\t\t\t\t\t\tBucket,\n\t\t\t\t\t\tKey,\n\t\t\t\t\t\tBody: JSON.stringify(secrets),\n\t\t\t\t\t\tContentType: 'application/json',\n\t\t\t\t\t\tServerSideEncryption: 'AES256',\n\t\t\t\t\t\t...(expected === null\n\t\t\t\t\t\t\t? { IfNoneMatch: '*' }\n\t\t\t\t\t\t\t: { IfMatch: expected }),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.remember(stage, ETag);\n\t\t} catch (error) {\n\t\t\tif (lostRace(error)) {\n\t\t\t\tthis.etags.delete(stage);\n\t\t\t\tthrow new StageSecretsChanged(stage, `s3://${Bucket}/${Key}`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Every version of the stage's secrets: the bucket keeps each past\n\t * document, and a secret left in an old version is not destroyed.\n\t */\n\tasync delete(stage: string): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) return;\n\t\tconst Key = this.key(stage);\n\t\tconst listed = await this.call(stage, 'write', () =>\n\t\t\ts3.send(new ListObjectVersionsCommand({ Bucket: bucket, Prefix: Key })),\n\t\t);\n\t\tconst objects = [\n\t\t\t...(listed.Versions ?? []),\n\t\t\t...(listed.DeleteMarkers ?? []),\n\t\t]\n\t\t\t.filter((o) => o.Key === Key)\n\t\t\t.map((o) => ({\n\t\t\t\tKey,\n\t\t\t\t...(o.VersionId ? { VersionId: o.VersionId } : {}),\n\t\t\t}));\n\t\tif (objects.length > 0) {\n\t\t\tawait this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew DeleteObjectsCommand({\n\t\t\t\t\t\tBucket: bucket,\n\t\t\t\t\t\tDelete: { Objects: objects, Quiet: true },\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tthis.etags.set(stage, null);\n\t}\n\n\t/**\n\t * The ETag the stage is now at. Some S3-compatible servers answer without\n\t * one: then nothing is remembered, and the next write asks for it first.\n\t */\n\tprivate remember(stage: string, etag: string | undefined): void {\n\t\tif (etag) this.etags.set(stage, etag);\n\t\telse this.etags.delete(stage);\n\t}\n\n\tprivate async currentEtag(\n\t\ts3: S3Client,\n\t\tstage: string,\n\t\tBucket: string,\n\t\tKey: string,\n\t): Promise<string | null> {\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(new HeadObjectCommand({ Bucket, Key })),\n\t\t\t);\n\t\t\treturn ETag ?? null;\n\t\t} catch (error) {\n\t\t\tif (notFound(error)) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,sBAAb,cAAyCA,eAAAA,SAAS;CAEvC;CAEA;CAHV,YACC,OAEA,UACC;EACD,MACC,0BAA0B,MAAM,OAAO,SAAS,4KAGj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IC,mBAAAA,0BAA0B;GAAE,QAAQ;GAAQ,QAAQ;EAAI,CAAC,CAAC,CACvE;EACA,MAAM,UAAU,CACf,GAAI,OAAO,YAAY,CAAC,GACxB,GAAI,OAAO,iBAAiB,CAAC,CAC9B,CAAC,CACC,QAAQ,MAAM,EAAE,QAAQ,GAAG,CAAC,CAC5B,KAAK,OAAO;GACZ;GACA,GAAI,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,IAAI,CAAC;EACjD,EAAE;EACH,IAAI,QAAQ,SAAS,GACpB,MAAM,KAAK,KAAK,OAAO,eACtB,GAAG,KACF,IAAIC,mBAAAA,qBAAqB;GACxB,QAAQ;GACR,QAAQ;IAAE,SAAS;IAAS,OAAO;GAAK;EACzC,CAAC,CACF,CACD;EAED,KAAK,MAAM,IAAI,OAAO,IAAI;CAC3B;;;;;CAMA,SAAiB,OAAe,MAAgC;EAC/D,IAAI,MAAM,KAAK,MAAM,IAAI,OAAO,IAAI;OAC/B,KAAK,MAAM,OAAO,KAAK;CAC7B;CAEA,MAAc,YACb,IACA,OACA,QACA,KACyB;EACzB,IAAI;GACH,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,OAAO,eACvC,GAAG,KAAK,IAAIC,mBAAAA,kBAAkB;IAAE;IAAQ;GAAI,CAAC,CAAC,CAC/C;GACA,OAAO,QAAQ;EAChB,SAAS,OAAO;GACf,IAAI,SAAS,KAAK,GAAG,OAAO;GAC5B,MAAM;EACP;CACD;AACD"}
1
+ {"version":3,"file":"s3-DkiOi5J1.cjs","names":["GkmError","projectBucketName","s3SecretsKey","awsClientConfig","S3Client","STSClient","withStageCredentials","callerAccountId","ensureProjectBucket","findProjectBucket","GetObjectCommand","PutObjectCommand","ListObjectVersionsCommand","DeleteObjectsCommand","HeadObjectCommand"],"sources":["../src/secrets/s3.ts"],"sourcesContent":["/**\n * A stage's secrets in S3: one object per stage,\n * `<prefix>/<project>/<stage>/secrets.json`, in the project bucket beside the\n * deploy state (`providers/projectBucket.ts`) — or in a bucket the config\n * names, which must exist.\n *\n * Encrypted at rest with SSE-S3, asked for on every write although the\n * project bucket defaults to it, so no KMS key is another place to keep. The\n * bucket's versioning keeps every past document. Unlike an SSM parameter\n * there is no size to outgrow.\n *\n * The project bucket is created by the first write, never by a read: a stage\n * whose bucket or object does not exist yet has no secrets. Every write is\n * conditional — `If-Match` on the ETag this store last read for the stage,\n * `If-None-Match: *` when it read none — so two `secrets:set` runs at once\n * cannot each overwrite the other's key: the second is refused with\n * {@link StageSecretsChanged}.\n */\n\nimport {\n\tDeleteObjectsCommand,\n\tGetObjectCommand,\n\tHeadObjectCommand,\n\tListObjectVersionsCommand,\n\tPutObjectCommand,\n\tS3Client,\n\ttype S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { STSClient } from '@aws-sdk/client-sts';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\nimport {\n\tcallerAccountId,\n\tensureProjectBucket,\n\tfindProjectBucket,\n\tprojectBucketName,\n} from '../providers/projectBucket.js';\nimport {\n\ttype AwsStoreOptions,\n\tawsClientConfig,\n\twithStageCredentials,\n} from './awsStore.js';\nimport { s3SecretsKey } from './providers.js';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface S3SecretsStoreOptions extends AwsStoreOptions {\n\t/** The deploy identity: the project bucket's name and its tag. */\n\tidentity: Pick<DeployIdentity, 'scope' | 'key'>;\n\t/** A bucket that exists; omitted, the project bucket. */\n\tbucket?: string;\n\t/** Key prefix inside the bucket, without a trailing slash. */\n\tprefix: string;\n\t/** For tests: credentials to use instead of the default chain. */\n\tcredentials?: S3ClientConfig['credentials'];\n}\n\n/**\n * Another run wrote the stage's secrets after this one read them. Nothing was\n * written: the change is to be made again, on top of theirs.\n */\nexport class StageSecretsChanged extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** `s3://<bucket>/<key>` */\n\t\treadonly location: string,\n\t) {\n\t\tsuper(\n\t\t\t`The secrets for stage \"${stage}\" at ${location} changed after this command read them — ` +\n\t\t\t\t'another secrets command or deploy wrote them first. Nothing was written; run the command ' +\n\t\t\t\t'again to make the change on top of theirs.',\n\t\t);\n\t\tthis.name = 'StageSecretsChanged';\n\t}\n}\n\ninterface S3Failure {\n\tname?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/** A conditional write that lost: the object is not what the write assumed. */\nfunction lostRace(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'PreconditionFailed' ||\n\t\tname === 'ConditionalRequestConflict' ||\n\t\t$metadata?.httpStatusCode === 412 ||\n\t\t$metadata?.httpStatusCode === 409\n\t);\n}\n\nfunction notFound(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'NoSuchKey' ||\n\t\tname === 'NotFound' ||\n\t\t$metadata?.httpStatusCode === 404\n\t);\n}\n\nexport class S3SecretsStore implements SecretsStore {\n\treadonly name = 's3';\n\n\tprivate clients?: { s3: S3Client; sts: STSClient };\n\t/** The bucket's name, once known. */\n\tprivate bucketName?: string;\n\t/** Whether the bucket is known to exist. */\n\tprivate exists = false;\n\t/** The ETag each stage was last read at — null: read, and not there. */\n\tprivate readonly etags = new Map<string, string | null>();\n\n\tconstructor(private readonly options: S3SecretsStoreOptions) {\n\t\tif (options.bucket) {\n\t\t\tthis.bucketName = options.bucket;\n\t\t\tthis.exists = true;\n\t\t}\n\t}\n\n\t/** The bucket's name; the project bucket's is known after the first call. */\n\tget bucket(): string {\n\t\treturn (\n\t\t\tthis.bucketName ??\n\t\t\tprojectBucketName(this.options.identity.scope, '<account id>')\n\t\t);\n\t}\n\n\t/** Where a stage's secrets are kept: `s3://<bucket>/<key>`. */\n\tlocation(stage: string): string {\n\t\treturn `s3://${this.bucket}/${this.key(stage)}`;\n\t}\n\n\tprivate key(stage: string): string {\n\t\treturn s3SecretsKey(this.options.prefix, this.options.project, stage);\n\t}\n\n\tprivate async client(): Promise<{ s3: S3Client; sts: STSClient }> {\n\t\tif (this.clients) return this.clients;\n\t\tconst base = await awsClientConfig(this.options);\n\t\tconst endpoint =\n\t\t\tbase.endpoint ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL_S3 ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL;\n\t\tconst credentials = this.options.credentials ?? base.credentials;\n\t\tthis.clients = {\n\t\t\ts3: new S3Client({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(endpoint ? { endpoint, forcePathStyle: true } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t\tsts: new STSClient({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(base.endpoint ? { endpoint: base.endpoint } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t};\n\t\treturn this.clients;\n\t}\n\n\t/** One AWS call, a missing or expired credential refused by name. */\n\tprivate call<T>(\n\t\tstage: string,\n\t\taccess: 'read' | 'write',\n\t\trun: () => Promise<T>,\n\t): Promise<T> {\n\t\treturn withStageCredentials(\n\t\t\t{ stage, store: this.name, profile: this.options.profile, access },\n\t\t\trun,\n\t\t);\n\t}\n\n\t/**\n\t * The bucket, or null for a project bucket that does not exist yet and is\n\t * not to be created (a read).\n\t */\n\tprivate async use(\n\t\tstage: string,\n\t\tcreate: boolean,\n\t): Promise<{ s3: S3Client; bucket: string | null }> {\n\t\tconst { s3, sts } = await this.client();\n\t\tif (this.exists) return { s3, bucket: this.bucketName! };\n\t\tconst access = create ? 'write' : 'read';\n\t\tthis.bucketName ??= projectBucketName(\n\t\t\tthis.options.identity.scope,\n\t\t\tawait this.call(stage, access, () => callerAccountId(sts)),\n\t\t);\n\t\tconst bucket = this.bucketName;\n\t\tif (create) {\n\t\t\tawait this.call(stage, access, () =>\n\t\t\t\tensureProjectBucket(s3, {\n\t\t\t\t\tbucket,\n\t\t\t\t\tregion: this.options.region,\n\t\t\t\t\tidentity: this.options.identity,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (\n\t\t\t(await this.call(stage, access, () => findProjectBucket(s3, bucket))) ===\n\t\t\t'none'\n\t\t) {\n\t\t\treturn { s3, bucket: null };\n\t\t}\n\t\tthis.exists = true;\n\t\treturn { s3, bucket };\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * read it with, or they have expired\n\t */\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) {\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tconst response = await this.call(stage, 'read', () =>\n\t\t\t\ts3.send(new GetObjectCommand({ Bucket: bucket, Key: this.key(stage) })),\n\t\t\t);\n\t\t\tconst body = await (\n\t\t\t\tresponse.Body as {\n\t\t\t\t\ttransformToString(encoding: string): Promise<string>;\n\t\t\t\t}\n\t\t\t).transformToString('utf-8');\n\t\t\tthis.remember(stage, response.ETag);\n\t\t\treturn JSON.parse(body) as StageSecrets;\n\t\t} catch (error) {\n\t\t\tif (!notFound(error)) throw error;\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Replace the stage's secrets — on the condition that they are still what\n\t * this store last read. A stage never read here is replaced as it is now.\n\t *\n\t * @throws {StageSecretsChanged} when another run wrote them in between\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * write it with, or they have expired\n\t */\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, true);\n\t\tconst Bucket = bucket!;\n\t\tconst Key = this.key(stage);\n\t\tconst expected = this.etags.has(stage)\n\t\t\t? (this.etags.get(stage) ?? null)\n\t\t\t: await this.currentEtag(s3, stage, Bucket, Key);\n\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew PutObjectCommand({\n\t\t\t\t\t\tBucket,\n\t\t\t\t\t\tKey,\n\t\t\t\t\t\tBody: JSON.stringify(secrets),\n\t\t\t\t\t\tContentType: 'application/json',\n\t\t\t\t\t\tServerSideEncryption: 'AES256',\n\t\t\t\t\t\t...(expected === null\n\t\t\t\t\t\t\t? { IfNoneMatch: '*' }\n\t\t\t\t\t\t\t: { IfMatch: expected }),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.remember(stage, ETag);\n\t\t} catch (error) {\n\t\t\tif (lostRace(error)) {\n\t\t\t\tthis.etags.delete(stage);\n\t\t\t\tthrow new StageSecretsChanged(stage, `s3://${Bucket}/${Key}`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Every version of the stage's secrets: the bucket keeps each past\n\t * document, and a secret left in an old version is not destroyed.\n\t */\n\tasync delete(stage: string): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) return;\n\t\tconst Key = this.key(stage);\n\t\tconst listed = await this.call(stage, 'write', () =>\n\t\t\ts3.send(new ListObjectVersionsCommand({ Bucket: bucket, Prefix: Key })),\n\t\t);\n\t\tconst objects = [\n\t\t\t...(listed.Versions ?? []),\n\t\t\t...(listed.DeleteMarkers ?? []),\n\t\t]\n\t\t\t.filter((o) => o.Key === Key)\n\t\t\t.map((o) => ({\n\t\t\t\tKey,\n\t\t\t\t...(o.VersionId ? { VersionId: o.VersionId } : {}),\n\t\t\t}));\n\t\tif (objects.length > 0) {\n\t\t\tawait this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew DeleteObjectsCommand({\n\t\t\t\t\t\tBucket: bucket,\n\t\t\t\t\t\tDelete: { Objects: objects, Quiet: true },\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tthis.etags.set(stage, null);\n\t}\n\n\t/**\n\t * The ETag the stage is now at. Some S3-compatible servers answer without\n\t * one: then nothing is remembered, and the next write asks for it first.\n\t */\n\tprivate remember(stage: string, etag: string | undefined): void {\n\t\tif (etag) this.etags.set(stage, etag);\n\t\telse this.etags.delete(stage);\n\t}\n\n\tprivate async currentEtag(\n\t\ts3: S3Client,\n\t\tstage: string,\n\t\tBucket: string,\n\t\tKey: string,\n\t): Promise<string | null> {\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(new HeadObjectCommand({ Bucket, Key })),\n\t\t\t);\n\t\t\treturn ETag ?? null;\n\t\t} catch (error) {\n\t\t\tif (notFound(error)) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,sBAAb,cAAyCA,eAAAA,SAAS;CAEvC;CAEA;CAHV,YACC,OAEA,UACC;EACD,MACC,0BAA0B,MAAM,OAAO,SAAS,4KAGjD;EARS,KAAA,QAAA;EAEA,KAAA,WAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAQA,SAAS,SAAS,OAAyB;CAC1C,MAAM,EAAE,MAAM,cAAc;CAC5B,OACC,SAAS,wBACT,SAAS,gCACT,WAAW,mBAAmB,OAC9B,WAAW,mBAAmB;AAEhC;AAEA,SAAS,SAAS,OAAyB;CAC1C,MAAM,EAAE,MAAM,cAAc;CAC5B,OACC,SAAS,eACT,SAAS,cACT,WAAW,mBAAmB;AAEhC;AAEA,IAAa,iBAAb,MAAoD;CAWtB;CAV7B,OAAgB;CAEhB;;CAEA;;CAEA,SAAiB;;CAEjB,wBAAyB,IAAI,IAA2B;CAExD,YAAY,SAAiD;EAAhC,KAAA,UAAA;EAC5B,IAAI,QAAQ,QAAQ;GACnB,KAAK,aAAa,QAAQ;GAC1B,KAAK,SAAS;EACf;CACD;;CAGA,IAAI,SAAiB;EACpB,OACC,KAAK,cACLC,sBAAAA,kBAAkB,KAAK,QAAQ,SAAS,OAAO,cAAc;CAE/D;;CAGA,SAAS,OAAuB;EAC/B,OAAO,QAAQ,KAA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;GACH,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,OAAO,eACvC,GAAG,KAAK,IAAIC,mBAAAA,kBAAkB;IAAE;IAAQ;GAAI,CAAC,CAAC,CAC/C;GACA,OAAO,QAAQ;EAChB,SAAS,OAAO;GACf,IAAI,SAAS,KAAK,GAAG,OAAO;GAC5B,MAAM;EACP;CACD;AACD"}
@@ -1,4 +1,86 @@
1
1
  let node_os = require("node:os");
2
+ //#region src/deploy/dnsResources.ts
3
+ /** The resource type of a DNS record gkm wrote. */
4
+ const DNS_RECORD_RESOURCE = "dns-record";
5
+ /** A record's full name: `api.example.com`, or the domain for `@`. */
6
+ function dnsRecordFqdn(domain, name) {
7
+ return name === "@" || name === "" ? domain : `${name}.${domain}`;
8
+ }
9
+ /** `dns-record:<fqdn>:<type>` */
10
+ function dnsResourceKey(fqdn, type) {
11
+ return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
12
+ }
13
+ /** The resource record a written DNS record is kept as. */
14
+ function dnsRecordResource(record) {
15
+ const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
16
+ const type = record.type.toUpperCase();
17
+ const data = {
18
+ domain: record.domain,
19
+ name: record.name,
20
+ value: record.value,
21
+ ttl: record.ttl,
22
+ ...record.provider ? { provider: record.provider } : {},
23
+ ...record.source ? { source: record.source } : {}
24
+ };
25
+ return {
26
+ key: dnsResourceKey(fqdn, type),
27
+ type: DNS_RECORD_RESOURCE,
28
+ id: `${fqdn} ${type}`,
29
+ status: "ready",
30
+ data
31
+ };
32
+ }
33
+ /** Records that gkm wrote `record` — or updates the value it holds. */
34
+ async function recordDnsResource(journal, record) {
35
+ const { key, type, id, data } = dnsRecordResource(record);
36
+ await journal.ready({
37
+ key,
38
+ type,
39
+ ...data ? { data } : {}
40
+ }, id);
41
+ }
42
+ /** Forgets a DNS record gkm deleted. */
43
+ async function forgetDnsResource(journal, record) {
44
+ await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
45
+ }
46
+ /**
47
+ * The changes a DNS step made, kept: what it created, updated or wrote is
48
+ * recorded, what it deleted is forgotten. A record it found already right is
49
+ * recorded only if gkm wrote it before; one it left to a person is not.
50
+ */
51
+ async function recordDnsChanges(journal, changes, providerOf) {
52
+ for (const change of changes) {
53
+ if (change.action === "delete") {
54
+ await forgetDnsResource(journal, change);
55
+ continue;
56
+ }
57
+ const written = change.action === "create" || change.action === "update" || change.action === "write";
58
+ const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
59
+ if (!written && !known || change.value === void 0) continue;
60
+ const provider = providerOf(change.domain);
61
+ await recordDnsResource(journal, {
62
+ domain: change.domain,
63
+ name: change.name,
64
+ type: change.type,
65
+ value: change.value,
66
+ ttl: change.ttl ?? 0,
67
+ ...provider ? { provider } : {}
68
+ });
69
+ }
70
+ }
71
+ /** Every DNS record gkm wrote for the stage, from its resource records. */
72
+ function dnsResources(resources) {
73
+ return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
74
+ const data = record.data ?? {};
75
+ const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
76
+ return {
77
+ ...data,
78
+ type,
79
+ fqdn
80
+ };
81
+ }).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
82
+ }
83
+ //#endregion
2
84
  //#region src/deploy/journal.ts
3
85
  var DeployJournal = class DeployJournal {
4
86
  store;
@@ -154,87 +236,6 @@ function describeActor(actor) {
154
236
  return `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ""}${actor.run})`;
155
237
  }
156
238
  //#endregion
157
- //#region src/deploy/dnsResources.ts
158
- /** The resource type of a DNS record gkm wrote. */
159
- const DNS_RECORD_RESOURCE = "dns-record";
160
- /** A record's full name: `api.example.com`, or the domain for `@`. */
161
- function dnsRecordFqdn(domain, name) {
162
- return name === "@" || name === "" ? domain : `${name}.${domain}`;
163
- }
164
- /** `dns-record:<fqdn>:<type>` */
165
- function dnsResourceKey(fqdn, type) {
166
- return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
167
- }
168
- /** The resource record a written DNS record is kept as. */
169
- function dnsRecordResource(record) {
170
- const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
171
- const type = record.type.toUpperCase();
172
- const data = {
173
- domain: record.domain,
174
- name: record.name,
175
- value: record.value,
176
- ttl: record.ttl,
177
- ...record.provider ? { provider: record.provider } : {}
178
- };
179
- return {
180
- key: dnsResourceKey(fqdn, type),
181
- type: DNS_RECORD_RESOURCE,
182
- id: `${fqdn} ${type}`,
183
- status: "ready",
184
- data
185
- };
186
- }
187
- /** Records that gkm wrote `record` — or updates the value it holds. */
188
- async function recordDnsResource(journal, record) {
189
- const { key, type, id, data } = dnsRecordResource(record);
190
- await journal.ready({
191
- key,
192
- type,
193
- ...data ? { data } : {}
194
- }, id);
195
- }
196
- /** Forgets a DNS record gkm deleted. */
197
- async function forgetDnsResource(journal, record) {
198
- await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
199
- }
200
- /**
201
- * The changes a DNS step made, kept: what it created, updated or wrote is
202
- * recorded, what it deleted is forgotten. A record it found already right is
203
- * recorded only if gkm wrote it before; one it left to a person is not.
204
- */
205
- async function recordDnsChanges(journal, changes, providerOf) {
206
- for (const change of changes) {
207
- if (change.action === "delete") {
208
- await forgetDnsResource(journal, change);
209
- continue;
210
- }
211
- const written = change.action === "create" || change.action === "update" || change.action === "write";
212
- const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
213
- if (!written && !known || change.value === void 0) continue;
214
- const provider = providerOf(change.domain);
215
- await recordDnsResource(journal, {
216
- domain: change.domain,
217
- name: change.name,
218
- type: change.type,
219
- value: change.value,
220
- ttl: change.ttl ?? 0,
221
- ...provider ? { provider } : {}
222
- });
223
- }
224
- }
225
- /** Every DNS record gkm wrote for the stage, from its resource records. */
226
- function dnsResources(resources) {
227
- return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
228
- const data = record.data ?? {};
229
- const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
230
- return {
231
- ...data,
232
- type,
233
- fqdn
234
- };
235
- }).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
236
- }
237
- //#endregion
238
239
  //#region src/target/seeds.ts
239
240
  /** A seed of a deployed stage failed; the release stopped before any app. */
240
241
  var DeploySeedsFailed = class extends Error {
@@ -329,6 +330,12 @@ Object.defineProperty(exports, "dnsRecordResource", {
329
330
  return dnsRecordResource;
330
331
  }
331
332
  });
333
+ Object.defineProperty(exports, "dnsResourceKey", {
334
+ enumerable: true,
335
+ get: function() {
336
+ return dnsResourceKey;
337
+ }
338
+ });
332
339
  Object.defineProperty(exports, "dnsResources", {
333
340
  enumerable: true,
334
341
  get: function() {
@@ -353,6 +360,12 @@ Object.defineProperty(exports, "recordDnsChanges", {
353
360
  return recordDnsChanges;
354
361
  }
355
362
  });
363
+ Object.defineProperty(exports, "recordDnsResource", {
364
+ enumerable: true,
365
+ get: function() {
366
+ return recordDnsResource;
367
+ }
368
+ });
356
369
  Object.defineProperty(exports, "reportDatabaseRuns", {
357
370
  enumerable: true,
358
371
  get: function() {
@@ -366,4 +379,4 @@ Object.defineProperty(exports, "reportPlannedSeeds", {
366
379
  }
367
380
  });
368
381
 
369
- //# sourceMappingURL=seeds-D7q1zKCJ.cjs.map
382
+ //# sourceMappingURL=seeds-Bc3niNVb.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seeds-Bc3niNVb.cjs","names":["userInfo","hostname"],"sources":["../src/deploy/dnsResources.ts","../src/deploy/journal.ts","../src/deploy/actor.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n\t/**\n\t * `provider`: a resource provider asked for it — a DKIM, MX, validation\n\t * or CDN record — rather than the stack's hosts. Pruned when no provider\n\t * asks for it on a deploy, not when the stack stops serving it.\n\t */\n\tsource?: 'provider';\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t\t...(record.source ? { source: record.source } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;;AAaA,MAAa,sBAAsB;;AA4BnC,SAAgB,cAAc,QAAgB,MAAsB;CACnE,OAAO,SAAS,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG;AAC1D;;AAGA,SAAgB,eAAe,MAAc,MAAsB;CAClE,OAAO,GAAG,oBAAoB,GAAG,KAAK,YAAY,EAAE,GAAG,KAAK,YAAY;AACzE;;AAGA,SAAgB,kBAAkB,QAA0C;CAC3E,MAAM,OAAO,cAAc,OAAO,QAAQ,OAAO,IAAI,CAAC,CAAC,YAAY;CACnE,MAAM,OAAO,OAAO,KAAK,YAAY;CACrC,MAAM,OAAwB;EAC7B,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,OAAO,OAAO;EACd,KAAK,OAAO;EACZ,GAAI,OAAO,WAAW,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EACvD,GAAI,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;CAClD;CACA,OAAO;EACN,KAAK,eAAe,MAAM,IAAI;EAC9B,MAAM;EACN,IAAI,GAAG,KAAK,GAAG;EACf,QAAQ;EACR;CACD;AACD;;AAGA,eAAsB,kBACrB,SACA,QACgB;CAChB,MAAM,EAAE,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;EASlB,KAAK,OAAO;CACb;AACD;;;;;AAMA,SAAS,aAAa,OAAwB;CAC7C,MAAM,WAAW,UAChB,SAAS,OAAO,UAAU,YAAY,aAAa,QAChD,OAAO,MAAM,OAAO,IACpB,KAAA;CAKJ,QAHC,SAAS,OAAO,UAAU,YAAY,WAAW,QAC9C,QAAQ,MAAM,KAAK,IACnB,KAAA,MACY,QAAQ,KAAK,KAAK,OAAO,KAAK;AAC/C;;;;;;AAqBA,SAAgB,mBACf,YACA,OACA,KACA,MACO;CACP,KAAK,MAAM,EAAE,WAAW,QAAQ,aAAa,YAAY;EACxD,IAAI,QAAQ,WAAW,GAAG;EAC1B,IAAI,QAAQ,OAAO,YAAY,QAAQ,QAAQ;EAC/C,KAAK,MAAM,QAAQ,SAAS,IAAI,QAAQ,MAAM;EAC9C,KAAK;GACJ,MAAM;GACN;GACA;GACA,SAAS,CAAC,GAAG,OAAO;EACrB,CAAC;CACF;CACA,KAAK,MAAM,EAAE,WAAW,QAAQ,YAAY,OAAO;EAClD,IAAI,OAAO,WAAW,GAAG;EACzB,IAAI,MAAM,OAAO,QAAQ,OAAO,QAAQ;EACxC,KAAK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
@@ -1,4 +1,86 @@
1
1
  import { hostname, userInfo } from "node:os";
2
+ //#region src/deploy/dnsResources.ts
3
+ /** The resource type of a DNS record gkm wrote. */
4
+ const DNS_RECORD_RESOURCE = "dns-record";
5
+ /** A record's full name: `api.example.com`, or the domain for `@`. */
6
+ function dnsRecordFqdn(domain, name) {
7
+ return name === "@" || name === "" ? domain : `${name}.${domain}`;
8
+ }
9
+ /** `dns-record:<fqdn>:<type>` */
10
+ function dnsResourceKey(fqdn, type) {
11
+ return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
12
+ }
13
+ /** The resource record a written DNS record is kept as. */
14
+ function dnsRecordResource(record) {
15
+ const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
16
+ const type = record.type.toUpperCase();
17
+ const data = {
18
+ domain: record.domain,
19
+ name: record.name,
20
+ value: record.value,
21
+ ttl: record.ttl,
22
+ ...record.provider ? { provider: record.provider } : {},
23
+ ...record.source ? { source: record.source } : {}
24
+ };
25
+ return {
26
+ key: dnsResourceKey(fqdn, type),
27
+ type: DNS_RECORD_RESOURCE,
28
+ id: `${fqdn} ${type}`,
29
+ status: "ready",
30
+ data
31
+ };
32
+ }
33
+ /** Records that gkm wrote `record` — or updates the value it holds. */
34
+ async function recordDnsResource(journal, record) {
35
+ const { key, type, id, data } = dnsRecordResource(record);
36
+ await journal.ready({
37
+ key,
38
+ type,
39
+ ...data ? { data } : {}
40
+ }, id);
41
+ }
42
+ /** Forgets a DNS record gkm deleted. */
43
+ async function forgetDnsResource(journal, record) {
44
+ await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
45
+ }
46
+ /**
47
+ * The changes a DNS step made, kept: what it created, updated or wrote is
48
+ * recorded, what it deleted is forgotten. A record it found already right is
49
+ * recorded only if gkm wrote it before; one it left to a person is not.
50
+ */
51
+ async function recordDnsChanges(journal, changes, providerOf) {
52
+ for (const change of changes) {
53
+ if (change.action === "delete") {
54
+ await forgetDnsResource(journal, change);
55
+ continue;
56
+ }
57
+ const written = change.action === "create" || change.action === "update" || change.action === "write";
58
+ const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
59
+ if (!written && !known || change.value === void 0) continue;
60
+ const provider = providerOf(change.domain);
61
+ await recordDnsResource(journal, {
62
+ domain: change.domain,
63
+ name: change.name,
64
+ type: change.type,
65
+ value: change.value,
66
+ ttl: change.ttl ?? 0,
67
+ ...provider ? { provider } : {}
68
+ });
69
+ }
70
+ }
71
+ /** Every DNS record gkm wrote for the stage, from its resource records. */
72
+ function dnsResources(resources) {
73
+ return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
74
+ const data = record.data ?? {};
75
+ const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
76
+ return {
77
+ ...data,
78
+ type,
79
+ fqdn
80
+ };
81
+ }).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
82
+ }
83
+ //#endregion
2
84
  //#region src/deploy/journal.ts
3
85
  var DeployJournal = class DeployJournal {
4
86
  store;
@@ -154,87 +236,6 @@ function describeActor(actor) {
154
236
  return `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ""}${actor.run})`;
155
237
  }
156
238
  //#endregion
157
- //#region src/deploy/dnsResources.ts
158
- /** The resource type of a DNS record gkm wrote. */
159
- const DNS_RECORD_RESOURCE = "dns-record";
160
- /** A record's full name: `api.example.com`, or the domain for `@`. */
161
- function dnsRecordFqdn(domain, name) {
162
- return name === "@" || name === "" ? domain : `${name}.${domain}`;
163
- }
164
- /** `dns-record:<fqdn>:<type>` */
165
- function dnsResourceKey(fqdn, type) {
166
- return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
167
- }
168
- /** The resource record a written DNS record is kept as. */
169
- function dnsRecordResource(record) {
170
- const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
171
- const type = record.type.toUpperCase();
172
- const data = {
173
- domain: record.domain,
174
- name: record.name,
175
- value: record.value,
176
- ttl: record.ttl,
177
- ...record.provider ? { provider: record.provider } : {}
178
- };
179
- return {
180
- key: dnsResourceKey(fqdn, type),
181
- type: DNS_RECORD_RESOURCE,
182
- id: `${fqdn} ${type}`,
183
- status: "ready",
184
- data
185
- };
186
- }
187
- /** Records that gkm wrote `record` — or updates the value it holds. */
188
- async function recordDnsResource(journal, record) {
189
- const { key, type, id, data } = dnsRecordResource(record);
190
- await journal.ready({
191
- key,
192
- type,
193
- ...data ? { data } : {}
194
- }, id);
195
- }
196
- /** Forgets a DNS record gkm deleted. */
197
- async function forgetDnsResource(journal, record) {
198
- await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
199
- }
200
- /**
201
- * The changes a DNS step made, kept: what it created, updated or wrote is
202
- * recorded, what it deleted is forgotten. A record it found already right is
203
- * recorded only if gkm wrote it before; one it left to a person is not.
204
- */
205
- async function recordDnsChanges(journal, changes, providerOf) {
206
- for (const change of changes) {
207
- if (change.action === "delete") {
208
- await forgetDnsResource(journal, change);
209
- continue;
210
- }
211
- const written = change.action === "create" || change.action === "update" || change.action === "write";
212
- const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
213
- if (!written && !known || change.value === void 0) continue;
214
- const provider = providerOf(change.domain);
215
- await recordDnsResource(journal, {
216
- domain: change.domain,
217
- name: change.name,
218
- type: change.type,
219
- value: change.value,
220
- ttl: change.ttl ?? 0,
221
- ...provider ? { provider } : {}
222
- });
223
- }
224
- }
225
- /** Every DNS record gkm wrote for the stage, from its resource records. */
226
- function dnsResources(resources) {
227
- return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
228
- const data = record.data ?? {};
229
- const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
230
- return {
231
- ...data,
232
- type,
233
- fqdn
234
- };
235
- }).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
236
- }
237
- //#endregion
238
239
  //#region src/target/seeds.ts
239
240
  /** A seed of a deployed stage failed; the release stopped before any app. */
240
241
  var DeploySeedsFailed = class extends Error {
@@ -293,6 +294,6 @@ function reportPlannedSeeds(planned, log) {
293
294
  for (const { folder, seeds } of planned) log(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(", ")})`);
294
295
  }
295
296
  //#endregion
296
- export { dnsRecordResource as a, recordDnsChanges as c, isCi as d, DeployJournal as f, dnsRecordFqdn as i, currentActor as l, reportDatabaseRuns as n, dnsResources as o, reportPlannedSeeds as r, forgetDnsResource as s, DeploySeedsFailed as t, describeActor as u };
297
+ export { describeActor as a, dnsRecordFqdn as c, dnsResources as d, forgetDnsResource as f, currentActor as i, dnsRecordResource as l, recordDnsResource as m, reportDatabaseRuns as n, isCi as o, recordDnsChanges as p, reportPlannedSeeds as r, DeployJournal as s, DeploySeedsFailed as t, dnsResourceKey as u };
297
298
 
298
- //# sourceMappingURL=seeds-y1rzXlAc.mjs.map
299
+ //# sourceMappingURL=seeds-Ccn0Ru2T.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seeds-Ccn0Ru2T.mjs","names":[],"sources":["../src/deploy/dnsResources.ts","../src/deploy/journal.ts","../src/deploy/actor.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n\t/**\n\t * `provider`: a resource provider asked for it — a DKIM, MX, validation\n\t * or CDN record — rather than the stack's hosts. Pruned when no provider\n\t * asks for it on a deploy, not when the stack stops serving it.\n\t */\n\tsource?: 'provider';\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t\t...(record.source ? { source: record.source } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;;AAaA,MAAa,sBAAsB;;AA4BnC,SAAgB,cAAc,QAAgB,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ACA,KAAK,MAAM,EAAE,WAAW,QAAQ,YAAY,OAAO;EAClD,IAAI,OAAO,WAAW,GAAG;EACzB,IAAI,MAAM,OAAO,QAAQ,OAAO,QAAQ;EACxC,KAAK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
@@ -1,12 +1,12 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
- import { k as secretsStoreFor, m as createComposeState } from "./credentials-DhCCRQJp.mjs";
3
- import { u as composeServer } from "./compose-Dk0Z8zdf.mjs";
2
+ import { k as secretsStoreFor, m as createComposeState } from "./credentials-C-yuISKH.mjs";
3
+ import { u as composeServer } from "./compose-BtjZNCC-.mjs";
4
4
  import { N as assertDeployedStage } from "./workspace-D5Vm2qcy.mjs";
5
- import { m as loadWorkspaceConfig } from "./config-Da9bxnkT.mjs";
6
- import { S as createStateStore } from "./sniffer-Csft3UaJ.mjs";
7
- import { f as DeployJournal, u as describeActor } from "./seeds-y1rzXlAc.mjs";
5
+ import { m as loadWorkspaceConfig } from "./config-Di0oJwM9.mjs";
6
+ import { S as createStateStore } from "./sniffer-CiV4xGbe.mjs";
7
+ import { a as describeActor, s as DeployJournal } from "./seeds-Ccn0Ru2T.mjs";
8
8
  import { u as prompt } from "./index.mjs";
9
- import { ghCli } from "./github-DxgGIvq1.mjs";
9
+ import { ghCli } from "./github-Bt3V7pdf.mjs";
10
10
  import { dirname, join, resolve } from "node:path";
11
11
  import { existsSync } from "node:fs";
12
12
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
@@ -682,4 +682,4 @@ async function composeServerCommand(options, deps = {}) {
682
682
  //#endregion
683
683
  export { composeServerCommand };
684
684
 
685
- //# sourceMappingURL=serverSetup-CzoKT3nH.mjs.map
685
+ //# sourceMappingURL=serverSetup-C0pLpF5w.mjs.map