@geekmidas/cli 10.0.0-alpha.11 → 10.0.0-alpha.111

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 (513) hide show
  1. package/README.md +315 -414
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-BwbYTMtB.cjs +1090 -0
  7. package/dist/EndpointGenerator-BwbYTMtB.cjs.map +1 -0
  8. package/dist/EndpointGenerator-CvLX8bpx.mjs +1031 -0
  9. package/dist/EndpointGenerator-CvLX8bpx.mjs.map +1 -0
  10. package/dist/GoDaddyProvider-CPabc3XW.mjs +388 -0
  11. package/dist/GoDaddyProvider-CPabc3XW.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DWrDIXzQ.cjs +388 -0
  13. package/dist/GoDaddyProvider-DWrDIXzQ.cjs.map +1 -0
  14. package/dist/{HostingerProvider-BcyFRbqV.mjs → HostingerProvider-BNpS9aRJ.mjs} +29 -25
  15. package/dist/HostingerProvider-BNpS9aRJ.mjs.map +1 -0
  16. package/dist/{HostingerProvider-BOvsgATO.cjs → HostingerProvider-DR1iws1P.cjs} +29 -25
  17. package/dist/HostingerProvider-DR1iws1P.cjs.map +1 -0
  18. package/dist/LegacyStateStore-BdXoAlYY.mjs +124 -0
  19. package/dist/LegacyStateStore-BdXoAlYY.mjs.map +1 -0
  20. package/dist/LegacyStateStore-fsyPGBWu.cjs +124 -0
  21. package/dist/LegacyStateStore-fsyPGBWu.cjs.map +1 -0
  22. package/dist/LocalStateStore-AtviUBky.cjs +178 -0
  23. package/dist/LocalStateStore-AtviUBky.cjs.map +1 -0
  24. package/dist/LocalStateStore-BrAX5yy7.mjs +167 -0
  25. package/dist/LocalStateStore-BrAX5yy7.mjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-BD6ZOQ51.cjs +541 -0
  27. package/dist/OpenApiTsGenerator-BD6ZOQ51.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-DXXFXSbO.mjs +536 -0
  29. package/dist/OpenApiTsGenerator-DXXFXSbO.mjs.map +1 -0
  30. package/dist/{Route53Provider-CH9XH7bz.cjs → Route53Provider-Bllus2NR.cjs} +21 -22
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-C0xmer8U.mjs → Route53Provider-QXxjkZO1.mjs} +13 -13
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-Cx7njkBz.mjs +223 -0
  35. package/dist/S3StateStore-Cx7njkBz.mjs.map +1 -0
  36. package/dist/S3StateStore-tn5g80Sx.cjs +222 -0
  37. package/dist/S3StateStore-tn5g80Sx.cjs.map +1 -0
  38. package/dist/SSMStateStore-CAFde-Fq.cjs +204 -0
  39. package/dist/SSMStateStore-CAFde-Fq.cjs.map +1 -0
  40. package/dist/SSMStateStore-sqZ3oDmn.mjs +205 -0
  41. package/dist/SSMStateStore-sqZ3oDmn.mjs.map +1 -0
  42. package/dist/SubscriberGenerator-CeH7wbYt.cjs +571 -0
  43. package/dist/SubscriberGenerator-CeH7wbYt.cjs.map +1 -0
  44. package/dist/SubscriberGenerator-DHnIYwUU.mjs +518 -0
  45. package/dist/SubscriberGenerator-DHnIYwUU.mjs.map +1 -0
  46. package/dist/add-Cs8yT5iH.cjs +719 -0
  47. package/dist/add-Cs8yT5iH.cjs.map +1 -0
  48. package/dist/add-DJE7zqJ4.mjs +717 -0
  49. package/dist/add-DJE7zqJ4.mjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/aws-8QQ8n-t6.mjs +89 -0
  55. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  56. package/dist/aws-DY9NqQIT.cjs +100 -0
  57. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  58. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  59. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  60. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  61. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  62. package/dist/{backup-provisioner-DXXg6FIL.mjs → backup-provisioner-C8DnCmxK.mjs} +11 -8
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-cE2PuCTb.cjs → backup-provisioner-oDEsPj02.cjs} +22 -20
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/backups/runner.cjs +519 -0
  67. package/dist/backups/runner.cjs.map +1 -0
  68. package/dist/backups/runner.d.cts +102 -0
  69. package/dist/backups/runner.d.cts.map +1 -0
  70. package/dist/backups/runner.d.mts +102 -0
  71. package/dist/backups/runner.d.mts.map +1 -0
  72. package/dist/backups/runner.mjs +506 -0
  73. package/dist/backups/runner.mjs.map +1 -0
  74. package/dist/{bundler-S3ek7ea-.mjs → bundler-DrySVbXF.mjs} +36 -32
  75. package/dist/bundler-DrySVbXF.mjs.map +1 -0
  76. package/dist/{bundler-CaTGtiaO.cjs → bundler-NrtItVBp.cjs} +38 -35
  77. package/dist/bundler-NrtItVBp.cjs.map +1 -0
  78. package/dist/cli-Br5ApIgR.mjs +71 -0
  79. package/dist/cli-Br5ApIgR.mjs.map +1 -0
  80. package/dist/cli-CHzpFBh-.cjs +71 -0
  81. package/dist/cli-CHzpFBh-.cjs.map +1 -0
  82. package/dist/compose-ByIbIrzs.cjs +3345 -0
  83. package/dist/compose-ByIbIrzs.cjs.map +1 -0
  84. package/dist/compose-CDC2bCme.mjs +3202 -0
  85. package/dist/compose-CDC2bCme.mjs.map +1 -0
  86. package/dist/config-D48erO2j.d.mts +269 -0
  87. package/dist/config-D48erO2j.d.mts.map +1 -0
  88. package/dist/config-DHDtsQrB.d.cts +269 -0
  89. package/dist/config-DHDtsQrB.d.cts.map +1 -0
  90. package/dist/config.cjs +421 -11
  91. package/dist/config.cjs.map +1 -0
  92. package/dist/config.d.cts +4 -120
  93. package/dist/config.d.mts +4 -120
  94. package/dist/config.mjs +405 -4
  95. package/dist/config.mjs.map +1 -0
  96. package/dist/credentialSchemas-Cf5Pf8VE.mjs +237 -0
  97. package/dist/credentialSchemas-Cf5Pf8VE.mjs.map +1 -0
  98. package/dist/credentialSchemas-D_VUCDUh.cjs +272 -0
  99. package/dist/credentialSchemas-D_VUCDUh.cjs.map +1 -0
  100. package/dist/credentials-B5N5yKk6.mjs +267 -0
  101. package/dist/credentials-B5N5yKk6.mjs.map +1 -0
  102. package/dist/credentials-Zqr3QQYB.cjs +350 -0
  103. package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
  104. package/dist/databases-BeGP5eDh.mjs +495 -0
  105. package/dist/databases-BeGP5eDh.mjs.map +1 -0
  106. package/dist/databases-DGALFDG3.cjs +598 -0
  107. package/dist/databases-DGALFDG3.cjs.map +1 -0
  108. package/dist/define-6poNqm5O.mjs +106 -0
  109. package/dist/define-6poNqm5O.mjs.map +1 -0
  110. package/dist/define-crmMcXFS.cjs +153 -0
  111. package/dist/define-crmMcXFS.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +212 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +653 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +653 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +145 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  121. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  122. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  123. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  124. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  125. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  126. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  127. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  128. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  129. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  131. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  133. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  134. package/dist/deploy/sniffer-hooks.cjs +13 -7
  135. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  136. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  137. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  138. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  139. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  140. package/dist/deploy/sniffer-hooks.mjs +10 -3
  141. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  142. package/dist/deploy/sniffer-loader.cjs +16 -7
  143. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  144. package/dist/deploy/sniffer-loader.d.cts +1 -1
  145. package/dist/deploy/sniffer-loader.d.mts +1 -1
  146. package/dist/deploy/sniffer-loader.mjs +14 -3
  147. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  148. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  149. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  150. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  151. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  152. package/dist/deploy/sniffer-routes-worker.mjs +4 -4
  153. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  154. package/dist/deploy/sniffer-worker.cjs +15 -6
  155. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  156. package/dist/deploy/sniffer-worker.d.cts +1 -3
  157. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  158. package/dist/deploy/sniffer-worker.d.mts +1 -3
  159. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  160. package/dist/deploy/sniffer-worker.mjs +15 -4
  161. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  162. package/dist/deploy-DLq9-m6H.mjs +2317 -0
  163. package/dist/deploy-DLq9-m6H.mjs.map +1 -0
  164. package/dist/deploy-Dl_NavYE.cjs +2390 -0
  165. package/dist/deploy-Dl_NavYE.cjs.map +1 -0
  166. package/dist/derive-B4vDpzgP.mjs +150 -0
  167. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  168. package/dist/derive-DAbo49sm.cjs +161 -0
  169. package/dist/derive-DAbo49sm.cjs.map +1 -0
  170. package/dist/discover-Bsr7HjqJ.cjs +616 -0
  171. package/dist/discover-Bsr7HjqJ.cjs.map +1 -0
  172. package/dist/discover-Ca8U75dl.mjs +537 -0
  173. package/dist/discover-Ca8U75dl.mjs.map +1 -0
  174. package/dist/discover-CvTtV5ZD.d.cts +108 -0
  175. package/dist/discover-CvTtV5ZD.d.cts.map +1 -0
  176. package/dist/discover-W2kab9Lc.d.mts +108 -0
  177. package/dist/discover-W2kab9Lc.d.mts.map +1 -0
  178. package/dist/dns-C2TGXUF4.cjs +1057 -0
  179. package/dist/dns-C2TGXUF4.cjs.map +1 -0
  180. package/dist/dns-pzftumxg.mjs +926 -0
  181. package/dist/dns-pzftumxg.mjs.map +1 -0
  182. package/dist/dokploy-B7-OwY2s.mjs +38 -0
  183. package/dist/dokploy-B7-OwY2s.mjs.map +1 -0
  184. package/dist/dokploy-OqBh8G4g.cjs +38 -0
  185. package/dist/dokploy-OqBh8G4g.cjs.map +1 -0
  186. package/dist/drivers-D11JHxrD.mjs +177 -0
  187. package/dist/drivers-D11JHxrD.mjs.map +1 -0
  188. package/dist/drivers-GKaA6ITM.cjs +200 -0
  189. package/dist/drivers-GKaA6ITM.cjs.map +1 -0
  190. package/dist/eas-6ezdJtry.mjs +316 -0
  191. package/dist/eas-6ezdJtry.mjs.map +1 -0
  192. package/dist/eas-BkLA60P2.cjs +319 -0
  193. package/dist/eas-BkLA60P2.cjs.map +1 -0
  194. package/dist/{emit-CIlvnDvV.mjs → emit-C1e8qD08.mjs} +13 -26
  195. package/dist/emit-C1e8qD08.mjs.map +1 -0
  196. package/dist/{emit-CUD1BWls.cjs → emit-Dmc1nvdS.cjs} +31 -57
  197. package/dist/emit-Dmc1nvdS.cjs.map +1 -0
  198. package/dist/encryption-DJv_jEXi.mjs +89 -0
  199. package/dist/encryption-DJv_jEXi.mjs.map +1 -0
  200. package/dist/encryption-DoVnVU82.cjs +90 -0
  201. package/dist/encryption-DoVnVU82.cjs.map +1 -0
  202. package/dist/engine-CJhQb50j.cjs +3196 -0
  203. package/dist/engine-CJhQb50j.cjs.map +1 -0
  204. package/dist/engine-Db71-OZL.mjs +3083 -0
  205. package/dist/engine-Db71-OZL.mjs.map +1 -0
  206. package/dist/errors-D8Gwp5kU.mjs +23 -0
  207. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  208. package/dist/errors-DMC4Umsb.cjs +34 -0
  209. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  210. package/dist/github-D2eABlxM.mjs +829 -0
  211. package/dist/github-D2eABlxM.mjs.map +1 -0
  212. package/dist/github-DDOHjdS9.cjs +829 -0
  213. package/dist/github-DDOHjdS9.cjs.map +1 -0
  214. package/dist/googlePlay-DNgybe5t.cjs +931 -0
  215. package/dist/googlePlay-DNgybe5t.cjs.map +1 -0
  216. package/dist/googlePlay-DY9vZQ1p.mjs +931 -0
  217. package/dist/googlePlay-DY9vZQ1p.mjs.map +1 -0
  218. package/dist/identity-CBXr4wNi.mjs +129 -0
  219. package/dist/identity-CBXr4wNi.mjs.map +1 -0
  220. package/dist/identity-CbLfgQNT.cjs +182 -0
  221. package/dist/identity-CbLfgQNT.cjs.map +1 -0
  222. package/dist/{index-Ayxg_DQY.d.mts → index-8OfpOtSI.d.cts} +39 -24
  223. package/dist/index-8OfpOtSI.d.cts.map +1 -0
  224. package/dist/{index-CR5urhWX.d.cts → index-Dpji6Bxq.d.mts} +39 -24
  225. package/dist/index-Dpji6Bxq.d.mts.map +1 -0
  226. package/dist/index.cjs +13571 -12366
  227. package/dist/index.cjs.map +1 -1
  228. package/dist/index.d.cts +1 -1
  229. package/dist/index.d.mts +1 -1
  230. package/dist/index.mjs +14106 -12914
  231. package/dist/index.mjs.map +1 -1
  232. package/dist/local-BwC2v2Y8.mjs +224 -0
  233. package/dist/local-BwC2v2Y8.mjs.map +1 -0
  234. package/dist/local-DNhnkugT.cjs +241 -0
  235. package/dist/local-DNhnkugT.cjs.map +1 -0
  236. package/dist/migrate-B9GswIAr.mjs +266 -0
  237. package/dist/migrate-B9GswIAr.mjs.map +1 -0
  238. package/dist/migrate-CQUGbptv.mjs +181 -0
  239. package/dist/migrate-CQUGbptv.mjs.map +1 -0
  240. package/dist/migrate-GLBZlrlJ.cjs +181 -0
  241. package/dist/migrate-GLBZlrlJ.cjs.map +1 -0
  242. package/dist/migrate-bDQzFvBN.cjs +271 -0
  243. package/dist/migrate-bDQzFvBN.cjs.map +1 -0
  244. package/dist/openapi.cjs +214 -10
  245. package/dist/openapi.cjs.map +1 -0
  246. package/dist/openapi.d.cts +38 -17
  247. package/dist/openapi.d.cts.map +1 -1
  248. package/dist/openapi.d.mts +38 -17
  249. package/dist/openapi.d.mts.map +1 -1
  250. package/dist/openapi.mjs +208 -5
  251. package/dist/openapi.mjs.map +1 -0
  252. package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
  253. package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
  254. package/dist/projectBucket-C_DN4WzF.mjs +222 -0
  255. package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
  256. package/dist/provider-BqpjG9QM.cjs +57 -0
  257. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  258. package/dist/provider-CEOKk8NS.mjs +46 -0
  259. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  260. package/dist/publish-B-EIjfQ0.mjs +123 -0
  261. package/dist/publish-B-EIjfQ0.mjs.map +1 -0
  262. package/dist/publish-CPgSbtcs.cjs +124 -0
  263. package/dist/publish-CPgSbtcs.cjs.map +1 -0
  264. package/dist/ready-BMFjxBYA.cjs +404 -0
  265. package/dist/ready-BMFjxBYA.cjs.map +1 -0
  266. package/dist/ready-CIt5SOtg.mjs +375 -0
  267. package/dist/ready-CIt5SOtg.mjs.map +1 -0
  268. package/dist/reconcile/public.cjs +3 -5
  269. package/dist/reconcile/public.d.cts +11 -87
  270. package/dist/reconcile/public.d.cts.map +1 -1
  271. package/dist/reconcile/public.d.mts +11 -87
  272. package/dist/reconcile/public.d.mts.map +1 -1
  273. package/dist/reconcile/public.mjs +3 -4
  274. package/dist/{reconcile-C13ERt1U.mjs → reconcile--I7V4Klj.mjs} +4 -7
  275. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  276. package/dist/{reconcile-CYMhFSYy.cjs → reconcile-CuCQBa5-.cjs} +5 -8
  277. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  278. package/dist/resolve-CxDqDmCD.mjs +263 -0
  279. package/dist/resolve-CxDqDmCD.mjs.map +1 -0
  280. package/dist/resolve-wG49Woex.cjs +316 -0
  281. package/dist/resolve-wG49Woex.cjs.map +1 -0
  282. package/dist/rollback-BQgEdr_p.mjs +136 -0
  283. package/dist/rollback-BQgEdr_p.mjs.map +1 -0
  284. package/dist/rollback-Cw-Z0mWn.cjs +165 -0
  285. package/dist/rollback-Cw-Z0mWn.cjs.map +1 -0
  286. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  287. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  288. package/dist/run-BJLIerMM.mjs +133 -0
  289. package/dist/run-BJLIerMM.mjs.map +1 -0
  290. package/dist/run-fVZ-rLnc.cjs +174 -0
  291. package/dist/run-fVZ-rLnc.cjs.map +1 -0
  292. package/dist/runtime-ACdfK59n.d.cts +82 -0
  293. package/dist/runtime-ACdfK59n.d.cts.map +1 -0
  294. package/dist/runtime-YyQuekxi.d.mts +82 -0
  295. package/dist/runtime-YyQuekxi.d.mts.map +1 -0
  296. package/dist/s3-CrPoA89T.cjs +215 -0
  297. package/dist/s3-CrPoA89T.cjs.map +1 -0
  298. package/dist/s3-DQXZdmCM.mjs +215 -0
  299. package/dist/s3-DQXZdmCM.mjs.map +1 -0
  300. package/dist/sandbox/config-worker.cjs +43 -0
  301. package/dist/sandbox/config-worker.cjs.map +1 -0
  302. package/dist/sandbox/config-worker.d.cts +1 -0
  303. package/dist/sandbox/config-worker.d.mts +1 -0
  304. package/dist/sandbox/config-worker.mjs +44 -0
  305. package/dist/sandbox/config-worker.mjs.map +1 -0
  306. package/dist/sandbox/credentials-worker.cjs +54 -0
  307. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  308. package/dist/sandbox/credentials-worker.d.cts +1 -0
  309. package/dist/sandbox/credentials-worker.d.mts +1 -0
  310. package/dist/sandbox/credentials-worker.mjs +55 -0
  311. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  312. package/dist/sandbox/discover-worker.cjs +47 -0
  313. package/dist/sandbox/discover-worker.cjs.map +1 -0
  314. package/dist/sandbox/discover-worker.d.cts +1 -0
  315. package/dist/sandbox/discover-worker.d.mts +1 -0
  316. package/dist/sandbox/discover-worker.mjs +48 -0
  317. package/dist/sandbox/discover-worker.mjs.map +1 -0
  318. package/dist/sandbox/migrate-worker.cjs +75 -0
  319. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  320. package/dist/sandbox/migrate-worker.d.cts +1 -0
  321. package/dist/sandbox/migrate-worker.d.mts +1 -0
  322. package/dist/sandbox/migrate-worker.mjs +76 -0
  323. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  324. package/dist/sandbox-C4g1eG31.d.mts +104 -0
  325. package/dist/sandbox-C4g1eG31.d.mts.map +1 -0
  326. package/dist/sandbox-CHv3OYXg.cjs +165 -0
  327. package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
  328. package/dist/sandbox-CbVB7uOD.mjs +118 -0
  329. package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
  330. package/dist/sandbox-CdKgQ3XU.d.cts +104 -0
  331. package/dist/sandbox-CdKgQ3XU.d.cts.map +1 -0
  332. package/dist/{workspace-C-a3G_U0.cjs → schemas-BCwKKA42.mjs} +958 -1868
  333. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  334. package/dist/{workspace-DaEX7FEg.mjs → schemas-BQ_v0lEX.cjs} +1048 -1678
  335. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  336. package/dist/secretsManager-CQORubp9.mjs +97 -0
  337. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  338. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  339. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  340. package/dist/seeds-CIk0l4SC.mjs +8197 -0
  341. package/dist/seeds-CIk0l4SC.mjs.map +1 -0
  342. package/dist/seeds-Dk8YkLkM.cjs +9176 -0
  343. package/dist/seeds-Dk8YkLkM.cjs.map +1 -0
  344. package/dist/sniffer-2aK7cB2u.cjs +1998 -0
  345. package/dist/sniffer-2aK7cB2u.cjs.map +1 -0
  346. package/dist/sniffer-CABMO-Bh.mjs +1825 -0
  347. package/dist/sniffer-CABMO-Bh.mjs.map +1 -0
  348. package/dist/sst-B-Uz4cvm.cjs +464 -0
  349. package/dist/sst-B-Uz4cvm.cjs.map +1 -0
  350. package/dist/sst-C1pxbFEd.mjs +441 -0
  351. package/dist/sst-C1pxbFEd.mjs.map +1 -0
  352. package/dist/stage-DjxR_7C0.mjs +302 -0
  353. package/dist/stage-DjxR_7C0.mjs.map +1 -0
  354. package/dist/stage-DrCS0vKD.cjs +313 -0
  355. package/dist/stage-DrCS0vKD.cjs.map +1 -0
  356. package/dist/stages-DJrOYLZ-.mjs +176 -0
  357. package/dist/stages-DJrOYLZ-.mjs.map +1 -0
  358. package/dist/stages-_3RVNG83.cjs +176 -0
  359. package/dist/stages-_3RVNG83.cjs.map +1 -0
  360. package/dist/target/public.cjs +15 -0
  361. package/dist/target/public.d.cts +28 -0
  362. package/dist/target/public.d.cts.map +1 -0
  363. package/dist/target/public.d.mts +28 -0
  364. package/dist/target/public.d.mts.map +1 -0
  365. package/dist/target/public.mjs +4 -0
  366. package/dist/terminal-D_NRPW4W.cjs +85 -0
  367. package/dist/terminal-D_NRPW4W.cjs.map +1 -0
  368. package/dist/terminal-mXM-Lqc6.mjs +85 -0
  369. package/dist/terminal-mXM-Lqc6.mjs.map +1 -0
  370. package/dist/types-B6UXlEkf.d.cts +7650 -0
  371. package/dist/types-B6UXlEkf.d.cts.map +1 -0
  372. package/dist/types-HqVPddRK.d.mts +7649 -0
  373. package/dist/types-HqVPddRK.d.mts.map +1 -0
  374. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  375. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  376. package/dist/utils-D_fxUqvU.mjs +156 -0
  377. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  378. package/dist/vitest.cjs +65 -0
  379. package/dist/vitest.cjs.map +1 -0
  380. package/dist/vitest.d.cts +29 -0
  381. package/dist/vitest.d.cts.map +1 -0
  382. package/dist/vitest.d.mts +29 -0
  383. package/dist/vitest.d.mts.map +1 -0
  384. package/dist/vitest.mjs +65 -0
  385. package/dist/vitest.mjs.map +1 -0
  386. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  387. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  388. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  389. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  390. package/dist/workspace/index.cjs +8 -4
  391. package/dist/workspace/index.d.cts +3 -3
  392. package/dist/workspace/index.d.mts +3 -3
  393. package/dist/workspace/index.mjs +2 -3
  394. package/dist/workspace-BwqQnool.cjs +2806 -0
  395. package/dist/workspace-BwqQnool.cjs.map +1 -0
  396. package/dist/workspace-D1QbNd55.mjs +2394 -0
  397. package/dist/workspace-D1QbNd55.mjs.map +1 -0
  398. package/package.json +54 -22
  399. package/dist/CachedStateProvider-BEBl2wQT.cjs +0 -60
  400. package/dist/CachedStateProvider-BEBl2wQT.cjs.map +0 -1
  401. package/dist/CachedStateProvider-C-8wtlto.mjs +0 -3
  402. package/dist/CachedStateProvider-Co4n5Wvs.mjs +0 -54
  403. package/dist/CachedStateProvider-Co4n5Wvs.mjs.map +0 -1
  404. package/dist/CachedStateProvider-DqhGpzsm.cjs +0 -3
  405. package/dist/HostingerProvider-BOvsgATO.cjs.map +0 -1
  406. package/dist/HostingerProvider-BcyFRbqV.mjs.map +0 -1
  407. package/dist/LocalStateProvider-Bq-0C0sg.mjs +0 -42
  408. package/dist/LocalStateProvider-Bq-0C0sg.mjs.map +0 -1
  409. package/dist/LocalStateProvider-yjXZXZDM.cjs +0 -43
  410. package/dist/LocalStateProvider-yjXZXZDM.cjs.map +0 -1
  411. package/dist/Route53Provider-C0xmer8U.mjs.map +0 -1
  412. package/dist/Route53Provider-CH9XH7bz.cjs.map +0 -1
  413. package/dist/SSMStateProvider-CXtNgPfy.cjs +0 -66
  414. package/dist/SSMStateProvider-CXtNgPfy.cjs.map +0 -1
  415. package/dist/SSMStateProvider-DOZifZfE.mjs +0 -66
  416. package/dist/SSMStateProvider-DOZifZfE.mjs.map +0 -1
  417. package/dist/backup-provisioner-DXXg6FIL.mjs.map +0 -1
  418. package/dist/backup-provisioner-cE2PuCTb.cjs.map +0 -1
  419. package/dist/bundler-CaTGtiaO.cjs.map +0 -1
  420. package/dist/bundler-S3ek7ea-.mjs.map +0 -1
  421. package/dist/chunk-Duj1WY3L.mjs +0 -7
  422. package/dist/config-B0L2tvvC.mjs +0 -402
  423. package/dist/config-B0L2tvvC.mjs.map +0 -1
  424. package/dist/config-HhDpJmLO.cjs +0 -462
  425. package/dist/config-HhDpJmLO.cjs.map +0 -1
  426. package/dist/config.d.cts.map +0 -1
  427. package/dist/config.d.mts.map +0 -1
  428. package/dist/credentials-B2Pyh3bJ.cjs +0 -2681
  429. package/dist/credentials-B2Pyh3bJ.cjs.map +0 -1
  430. package/dist/credentials-B5zRHdAl.mjs +0 -141
  431. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  432. package/dist/credentials-BapzjyV5.cjs +0 -195
  433. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  434. package/dist/credentials-CZrys9C5.mjs +0 -2549
  435. package/dist/credentials-CZrys9C5.mjs.map +0 -1
  436. package/dist/discover-CAlFgYec.mjs +0 -229
  437. package/dist/discover-CAlFgYec.mjs.map +0 -1
  438. package/dist/discover-DTmFeloL.cjs +0 -271
  439. package/dist/discover-DTmFeloL.cjs.map +0 -1
  440. package/dist/dokploy-api-5cK2InBm.cjs +0 -3
  441. package/dist/dokploy-api-D2Ny4Jrc.mjs +0 -3
  442. package/dist/dokploy-api-pdaBryoY.mjs +0 -706
  443. package/dist/dokploy-api-pdaBryoY.mjs.map +0 -1
  444. package/dist/dokploy-api-zqKe9lHH.cjs +0 -718
  445. package/dist/dokploy-api-zqKe9lHH.cjs.map +0 -1
  446. package/dist/emit-CIlvnDvV.mjs.map +0 -1
  447. package/dist/emit-CUD1BWls.cjs.map +0 -1
  448. package/dist/encryption-D2pL3tHH.cjs +0 -54
  449. package/dist/encryption-D2pL3tHH.cjs.map +0 -1
  450. package/dist/encryption-YDsXXi6w.mjs +0 -3
  451. package/dist/encryption-_4zwjOAR.mjs +0 -42
  452. package/dist/encryption-_4zwjOAR.mjs.map +0 -1
  453. package/dist/encryption-sQ2Oxx0d.cjs +0 -4
  454. package/dist/fullstack-secrets-D6MyHhQP.cjs +0 -111
  455. package/dist/fullstack-secrets-D6MyHhQP.cjs.map +0 -1
  456. package/dist/fullstack-secrets-METaRLS1.mjs +0 -87
  457. package/dist/fullstack-secrets-METaRLS1.mjs.map +0 -1
  458. package/dist/generator-CNzBw7g5.cjs +0 -289
  459. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  460. package/dist/generator-VE2JrFlY.mjs +0 -253
  461. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  462. package/dist/github-BrvaPkFf.cjs +0 -197
  463. package/dist/github-BrvaPkFf.cjs.map +0 -1
  464. package/dist/github-CrpsXSfV.mjs +0 -196
  465. package/dist/github-CrpsXSfV.mjs.map +0 -1
  466. package/dist/index-Ayxg_DQY.d.mts.map +0 -1
  467. package/dist/index-CR5urhWX.d.cts.map +0 -1
  468. package/dist/keystore-C9rint2E.cjs +0 -101
  469. package/dist/keystore-C9rint2E.cjs.map +0 -1
  470. package/dist/keystore-TxeYM7an.mjs +0 -83
  471. package/dist/keystore-TxeYM7an.mjs.map +0 -1
  472. package/dist/openapi-DaKlTKxz.cjs +0 -2075
  473. package/dist/openapi-DaKlTKxz.cjs.map +0 -1
  474. package/dist/openapi-react-query-BKH334Ug.cjs +0 -173
  475. package/dist/openapi-react-query-BKH334Ug.cjs.map +0 -1
  476. package/dist/openapi-react-query-DoR5CmzQ.mjs +0 -167
  477. package/dist/openapi-react-query-DoR5CmzQ.mjs.map +0 -1
  478. package/dist/openapi-react-query.cjs +0 -4
  479. package/dist/openapi-react-query.d.cts +0 -11
  480. package/dist/openapi-react-query.d.cts.map +0 -1
  481. package/dist/openapi-react-query.d.mts +0 -11
  482. package/dist/openapi-react-query.d.mts.map +0 -1
  483. package/dist/openapi-react-query.mjs +0 -4
  484. package/dist/openapi-y1d7Kalt.mjs +0 -2021
  485. package/dist/openapi-y1d7Kalt.mjs.map +0 -1
  486. package/dist/reconcile-C13ERt1U.mjs.map +0 -1
  487. package/dist/reconcile-CYMhFSYy.cjs.map +0 -1
  488. package/dist/setup-BWgMs4gg.mjs +0 -12
  489. package/dist/setup-DOv92pIu.cjs +0 -473
  490. package/dist/setup-DOv92pIu.cjs.map +0 -1
  491. package/dist/setup-DQo_h_yK.mjs +0 -443
  492. package/dist/setup-DQo_h_yK.mjs.map +0 -1
  493. package/dist/setup-lCx_DcUo.cjs +0 -12
  494. package/dist/storage-B020InPW.mjs +0 -222
  495. package/dist/storage-B020InPW.mjs.map +0 -1
  496. package/dist/storage-CSNplaJn.cjs +0 -282
  497. package/dist/storage-CSNplaJn.cjs.map +0 -1
  498. package/dist/storage-DGBzMLZa.mjs +0 -4
  499. package/dist/storage-DlVol_oj.cjs +0 -8
  500. package/dist/sync-0ILCb-1S.cjs +0 -93
  501. package/dist/sync-0ILCb-1S.cjs.map +0 -1
  502. package/dist/sync-CzHXiR9c.mjs +0 -76
  503. package/dist/sync-CzHXiR9c.mjs.map +0 -1
  504. package/dist/sync-DYENfOt4.cjs +0 -4
  505. package/dist/sync-HAau6h_R.mjs +0 -3
  506. package/dist/types-CL7jPFM2.d.mts +0 -2220
  507. package/dist/types-CL7jPFM2.d.mts.map +0 -1
  508. package/dist/types-Y3fKQSAK.d.cts +0 -2220
  509. package/dist/types-Y3fKQSAK.d.cts.map +0 -1
  510. package/dist/workspace-C-a3G_U0.cjs.map +0 -1
  511. package/dist/workspace-DQxxs7Jk.cjs +0 -10
  512. package/dist/workspace-DaEX7FEg.mjs.map +0 -1
  513. package/dist/workspace-DbI580qS.mjs +0 -9
@@ -0,0 +1,222 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import "./identity-CBXr4wNi.mjs";
3
+ import { createHash } from "node:crypto";
4
+ //#region src/providers/projectBucket.ts
5
+ /**
6
+ * The project bucket: one S3 bucket per project and AWS account, created and
7
+ * owned by gkm, that holds what gkm keeps for every stage — the deploy state
8
+ * under `<prefix>/<project>/<stage>/`, and anything else gkm writes per stage
9
+ * beside it.
10
+ *
11
+ * Nothing can record its name — the deploy state lives in it — so the name is
12
+ * worked out the same way every time: `gkm-<scope>-<account id>`, the scope
13
+ * being the one the `s3` objects provider names its buckets with. The account
14
+ * id keeps it from clashing with another account's project of the same name
15
+ * without a random suffix; a clash that happens anyway (HeadBucket 403) is
16
+ * refused, never adopted.
17
+ *
18
+ * Created with versioning, SSE-S3, every public access blocked, ownership
19
+ * enforced for the bucket owner, a lifecycle that expires old versions, and
20
+ * the tag `gkm:project=<identity key>`.
21
+ */
22
+ /** What the project part may take: 63 less `gkm-`, `-` and a 12-digit id. */
23
+ const SCOPE_MAX = 46;
24
+ /** The tag the bucket is created with, as the `s3` provider tags its own. */
25
+ const PROJECT_BUCKET_TAG = "gkm:project";
26
+ /** The bucket's name is held by another account, or cannot be reached. */
27
+ var ProjectBucketTaken = class extends GkmError {
28
+ bucket;
29
+ status;
30
+ constructor(bucket, status) {
31
+ super(`The project bucket '${bucket}' ${status === 301 ? "is in another region than the one configured" : "exists and this account cannot reach it — another account holds the name"} (HTTP ${status}). Name a bucket you own instead — in gkm.config.ts: state: { provider: 's3', bucket: '<your bucket>', region: '<its region>' } — or run with the credentials of the account the name is for.`);
32
+ this.bucket = bucket;
33
+ this.status = status;
34
+ this.name = "ProjectBucketTaken";
35
+ }
36
+ };
37
+ /** The running credentials may not create the project bucket. */
38
+ var ProjectBucketNotCreatable = class extends GkmError {
39
+ bucket;
40
+ reason;
41
+ constructor(bucket, reason) {
42
+ super(`The project bucket '${bucket}' does not exist yet, and these credentials cannot create it (${reason}). Run the first deploy with credentials allowed s3:CreateBucket and the bucket put-config actions on it — \`gkm deploy:github\` grants them to the CI role — or name an existing bucket: state: { provider: 's3', bucket, region }.`);
43
+ this.bucket = bucket;
44
+ this.reason = reason;
45
+ this.name = "ProjectBucketNotCreatable";
46
+ }
47
+ };
48
+ /** {@link projectBucket}, from a deploy identity's scope. */
49
+ function projectBucketName(scope, accountId) {
50
+ let part = scope.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
51
+ if (part.length > SCOPE_MAX) {
52
+ const hash = createHash("sha256").update(scope).digest("hex").slice(0, 6);
53
+ part = `${part.slice(0, 39).replace(/-+$/, "")}-${hash}`;
54
+ }
55
+ return `gkm-${part}-${accountId}`;
56
+ }
57
+ /** The account the credentials are in — what the bucket is named by. */
58
+ async function callerAccountId(sts) {
59
+ const { GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
60
+ const { Account } = await sts.send(new GetCallerIdentityCommand({}));
61
+ return Account ?? "";
62
+ }
63
+ /**
64
+ * The bucket's whole lifecycle configuration. A put replaces every rule the
65
+ * bucket has, so this is the one place the set is built: the bucket's own
66
+ * noncurrent-version expiry, and any per-prefix expiry passed in.
67
+ */
68
+ function projectBucketLifecycle(expiries = []) {
69
+ return [{
70
+ ID: "gkm-noncurrent-versions",
71
+ Status: "Enabled",
72
+ Filter: { Prefix: "" },
73
+ NoncurrentVersionExpiration: { NoncurrentDays: 90 },
74
+ Expiration: { ExpiredObjectDeleteMarker: true }
75
+ }, ...expiries.map((expiry) => ({
76
+ ID: expiry.id,
77
+ Status: "Enabled",
78
+ Filter: { Prefix: expiry.prefix },
79
+ Expiration: { Days: expiry.days },
80
+ ...expiry.abortIncompleteDays ? { AbortIncompleteMultipartUpload: { DaysAfterInitiation: expiry.abortIncompleteDays } } : {}
81
+ }))];
82
+ }
83
+ /** A lifecycle rule reduced to what gkm sets, for comparing with what is there. */
84
+ function canonicalRule(rule) {
85
+ return JSON.stringify({
86
+ id: rule.ID ?? "",
87
+ status: rule.Status ?? "",
88
+ prefix: rule.Filter?.Prefix ?? rule.Prefix ?? "",
89
+ days: rule.Expiration?.Days ?? null,
90
+ markers: rule.Expiration?.ExpiredObjectDeleteMarker ?? null,
91
+ noncurrent: rule.NoncurrentVersionExpiration?.NoncurrentDays ?? null,
92
+ abort: rule.AbortIncompleteMultipartUpload?.DaysAfterInitiation ?? null
93
+ });
94
+ }
95
+ /** Whether two rule sets say the same thing, in any order. */
96
+ function sameLifecycle(a, b) {
97
+ const canonical = (rules) => rules.map(canonicalRule).sort().join("\n");
98
+ return canonical(a) === canonical(b);
99
+ }
100
+ /**
101
+ * The project bucket's lifecycle put to {@link projectBucketLifecycle} of
102
+ * `expiries` — every stage's — when what it holds says anything else.
103
+ * Returns whether it was put; with `dryRun`, whether it would be.
104
+ */
105
+ async function reconcileProjectBucketLifecycle(s3, bucket, expiries, options = {}) {
106
+ const S3 = await import("@aws-sdk/client-s3");
107
+ const rules = projectBucketLifecycle(expiries);
108
+ let current = [];
109
+ try {
110
+ current = (await s3.send(new S3.GetBucketLifecycleConfigurationCommand({ Bucket: bucket }))).Rules ?? [];
111
+ } catch (error) {
112
+ const failure = error;
113
+ if ((failure.Code ?? failure.name) !== "NoSuchLifecycleConfiguration") throw error;
114
+ }
115
+ if (sameLifecycle(current, rules)) return false;
116
+ if (!options.dryRun) await s3.send(new S3.PutBucketLifecycleConfigurationCommand({
117
+ Bucket: bucket,
118
+ LifecycleConfiguration: { Rules: rules }
119
+ }));
120
+ return true;
121
+ }
122
+ /**
123
+ * Whether `bucket` is this account's (`ours`) or does not exist (`none`).
124
+ * Mapped by status: a HEAD has no body, so SDK v3 names a 301, 400 or 403
125
+ * `Unknown`.
126
+ *
127
+ * @throws {ProjectBucketTaken} on a 403 or 301
128
+ */
129
+ async function findProjectBucket(s3, bucket) {
130
+ const { HeadBucketCommand } = await import("@aws-sdk/client-s3");
131
+ try {
132
+ await s3.send(new HeadBucketCommand({ Bucket: bucket }));
133
+ return "ours";
134
+ } catch (error) {
135
+ const status = error.$metadata?.httpStatusCode;
136
+ if (status === 404) return "none";
137
+ if (status === 403 || status === 301) throw new ProjectBucketTaken(bucket, status);
138
+ throw error;
139
+ }
140
+ }
141
+ /**
142
+ * The project bucket, created and configured if it does not exist yet.
143
+ * Returns whether this call created it. One that exists is used as it is.
144
+ *
145
+ * @throws {ProjectBucketTaken} when another account holds the name
146
+ * @throws {ProjectBucketNotCreatable} when the credentials may not create it
147
+ */
148
+ async function ensureProjectBucket(s3, options) {
149
+ const { bucket: Bucket, region } = options;
150
+ if (await findProjectBucket(s3, Bucket) === "ours") return { created: false };
151
+ const S3 = await import("@aws-sdk/client-s3");
152
+ try {
153
+ await s3.send(new S3.CreateBucketCommand({
154
+ Bucket,
155
+ ObjectOwnership: "BucketOwnerEnforced",
156
+ ...region === "us-east-1" ? {} : { CreateBucketConfiguration: { LocationConstraint: region } }
157
+ }));
158
+ } catch (error) {
159
+ const failure = error;
160
+ const code = failure.Code ?? failure.name;
161
+ if (code !== "BucketAlreadyOwnedByYou") {
162
+ if (code === "BucketAlreadyExists") throw new ProjectBucketTaken(Bucket, 409);
163
+ if (code === "AccessDenied" || failure.$metadata?.httpStatusCode === 403) throw new ProjectBucketNotCreatable(Bucket, failure.message ?? "AccessDenied");
164
+ throw error;
165
+ }
166
+ }
167
+ await s3.send(new S3.PutPublicAccessBlockCommand({
168
+ Bucket,
169
+ PublicAccessBlockConfiguration: {
170
+ BlockPublicAcls: true,
171
+ IgnorePublicAcls: true,
172
+ BlockPublicPolicy: true,
173
+ RestrictPublicBuckets: true
174
+ }
175
+ }));
176
+ await s3.send(new S3.PutBucketOwnershipControlsCommand({
177
+ Bucket,
178
+ OwnershipControls: { Rules: [{ ObjectOwnership: "BucketOwnerEnforced" }] }
179
+ }));
180
+ await s3.send(new S3.PutBucketEncryptionCommand({
181
+ Bucket,
182
+ ServerSideEncryptionConfiguration: { Rules: [{ ApplyServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" } }] }
183
+ }));
184
+ await s3.send(new S3.PutBucketVersioningCommand({
185
+ Bucket,
186
+ VersioningConfiguration: { Status: "Enabled" }
187
+ }));
188
+ await s3.send(new S3.PutBucketLifecycleConfigurationCommand({
189
+ Bucket,
190
+ LifecycleConfiguration: { Rules: projectBucketLifecycle(options.expiries) }
191
+ }));
192
+ await s3.send(new S3.PutBucketTaggingCommand({
193
+ Bucket,
194
+ Tagging: { TagSet: [{
195
+ Key: PROJECT_BUCKET_TAG,
196
+ Value: options.identity.key
197
+ }] }
198
+ }));
199
+ return { created: true };
200
+ }
201
+ /**
202
+ * The IAM actions creating and configuring the project bucket takes — what a
203
+ * role that runs the first deploy needs on it, beside object access.
204
+ */
205
+ const PROJECT_BUCKET_CREATE_ACTIONS = [
206
+ "s3:CreateBucket",
207
+ "s3:PutBucketVersioning",
208
+ "s3:PutEncryptionConfiguration",
209
+ "s3:PutBucketPublicAccessBlock",
210
+ "s3:PutBucketOwnershipControls",
211
+ "s3:PutLifecycleConfiguration",
212
+ "s3:PutBucketTagging"
213
+ ];
214
+ /**
215
+ * What keeping the project bucket's lifecycle takes on a bucket that exists:
216
+ * reading it, to put it back only when it drifted.
217
+ */
218
+ const PROJECT_BUCKET_LIFECYCLE_ACTIONS = ["s3:GetLifecycleConfiguration", "s3:PutLifecycleConfiguration"];
219
+ //#endregion
220
+ export { findProjectBucket as a, ensureProjectBucket as i, PROJECT_BUCKET_LIFECYCLE_ACTIONS as n, projectBucketName as o, callerAccountId as r, reconcileProjectBucketLifecycle as s, PROJECT_BUCKET_CREATE_ACTIONS as t };
221
+
222
+ //# sourceMappingURL=projectBucket-C_DN4WzF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectBucket-C_DN4WzF.mjs","names":[],"sources":["../src/providers/projectBucket.ts"],"sourcesContent":["/**\n * The project bucket: one S3 bucket per project and AWS account, created and\n * owned by gkm, that holds what gkm keeps for every stage — the deploy state\n * under `<prefix>/<project>/<stage>/`, and anything else gkm writes per stage\n * beside it.\n *\n * Nothing can record its name — the deploy state lives in it — so the name is\n * worked out the same way every time: `gkm-<scope>-<account id>`, the scope\n * being the one the `s3` objects provider names its buckets with. The account\n * id keeps it from clashing with another account's project of the same name\n * without a random suffix; a clash that happens anyway (HeadBucket 403) is\n * refused, never adopted.\n *\n * Created with versioning, SSE-S3, every public access blocked, ownership\n * enforced for the bucket owner, a lifecycle that expires old versions, and\n * the tag `gkm:project=<identity key>`.\n */\n\nimport { createHash } from 'node:crypto';\nimport type {\n\tBucketLocationConstraint,\n\tLifecycleRule,\n\tS3Client,\n} from '@aws-sdk/client-s3';\nimport type { STSClient } from '@aws-sdk/client-sts';\nimport { type DeployIdentity, deployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\n\n/** S3's limit on a bucket name. */\nconst BUCKET_NAME_MAX = 63;\n/** What the project part may take: 63 less `gkm-`, `-` and a 12-digit id. */\nconst SCOPE_MAX = BUCKET_NAME_MAX - 'gkm-'.length - 1 - 12;\n\n/** The tag the bucket is created with, as the `s3` provider tags its own. */\nexport const PROJECT_BUCKET_TAG = 'gkm:project';\n\n/** How long a replaced or deleted object's old version is kept. */\nexport const NONCURRENT_VERSION_DAYS = 90;\n\n/** The bucket's name is held by another account, or cannot be reached. */\nexport class ProjectBucketTaken extends GkmError {\n\tconstructor(\n\t\treadonly bucket: string,\n\t\t/** HeadBucket's status: 403 another account's, 301 another region's. */\n\t\treadonly status: number,\n\t) {\n\t\tconst why =\n\t\t\tstatus === 301\n\t\t\t\t? 'is in another region than the one configured'\n\t\t\t\t: 'exists and this account cannot reach it — another account holds the name';\n\t\tsuper(\n\t\t\t`The project bucket '${bucket}' ${why} (HTTP ${status}). Name a bucket ` +\n\t\t\t\t\"you own instead — in gkm.config.ts: state: { provider: 's3', \" +\n\t\t\t\t\"bucket: '<your bucket>', region: '<its region>' } — or run with the \" +\n\t\t\t\t'credentials of the account the name is for.',\n\t\t);\n\t\tthis.name = 'ProjectBucketTaken';\n\t}\n}\n\n/** The running credentials may not create the project bucket. */\nexport class ProjectBucketNotCreatable extends GkmError {\n\tconstructor(\n\t\treadonly bucket: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`The project bucket '${bucket}' does not exist yet, and these ` +\n\t\t\t\t`credentials cannot create it (${reason}). Run the first deploy with ` +\n\t\t\t\t'credentials allowed s3:CreateBucket and the bucket put-config ' +\n\t\t\t\t'actions on it — `gkm deploy:github` grants them to the CI role — ' +\n\t\t\t\t\"or name an existing bucket: state: { provider: 's3', bucket, region }.\",\n\t\t);\n\t\tthis.name = 'ProjectBucketNotCreatable';\n\t}\n}\n\n/**\n * The project bucket's name: `gkm-<scope>-<account id>`, lowercase and\n * DNS-safe. A scope too long to fit keeps its start and ends in a hash of\n * the whole, so two long scopes never share a name.\n */\nexport function projectBucket(\n\tworkspace: { name: string; deploy?: { namespace?: string } },\n\toptions: { accountId: string },\n): string {\n\tconst { scope } = deployIdentity(workspace, '');\n\treturn projectBucketName(scope, options.accountId);\n}\n\n/** {@link projectBucket}, from a deploy identity's scope. */\nexport function projectBucketName(scope: string, accountId: string): string {\n\tlet part = scope\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '-')\n\t\t.replace(/^-+|-+$/g, '');\n\tif (part.length > SCOPE_MAX) {\n\t\tconst hash = createHash('sha256').update(scope).digest('hex').slice(0, 6);\n\t\tpart = `${part.slice(0, SCOPE_MAX - 7).replace(/-+$/, '')}-${hash}`;\n\t}\n\treturn `gkm-${part}-${accountId}`;\n}\n\n/** The account the credentials are in — what the bucket is named by. */\nexport async function callerAccountId(sts: STSClient): Promise<string> {\n\tconst { GetCallerIdentityCommand } = await import('@aws-sdk/client-sts');\n\tconst { Account } = await sts.send(new GetCallerIdentityCommand({}));\n\treturn Account ?? '';\n}\n\n/** An expiry for one stage's prefix, added beside the bucket's own rule. */\nexport interface PrefixExpiry {\n\t/** Rule id, unique in the bucket — e.g. `backups-production`. */\n\tid: string;\n\t/** Key prefix it applies to — e.g. `gkm/acme/production/backups/`. */\n\tprefix: string;\n\t/** Days after which a current object expires. */\n\tdays: number;\n\t/**\n\t * Days after which a multipart upload under the prefix that never\n\t * completed is aborted — its parts are stored, and billed, until it is.\n\t */\n\tabortIncompleteDays?: number;\n}\n\n/**\n * The bucket's whole lifecycle configuration. A put replaces every rule the\n * bucket has, so this is the one place the set is built: the bucket's own\n * noncurrent-version expiry, and any per-prefix expiry passed in.\n */\nexport function projectBucketLifecycle(\n\texpiries: readonly PrefixExpiry[] = [],\n): LifecycleRule[] {\n\treturn [\n\t\t{\n\t\t\tID: 'gkm-noncurrent-versions',\n\t\t\tStatus: 'Enabled',\n\t\t\tFilter: { Prefix: '' },\n\t\t\tNoncurrentVersionExpiration: { NoncurrentDays: NONCURRENT_VERSION_DAYS },\n\t\t\t// A lock is deleted every run; its markers go once nothing is under them.\n\t\t\tExpiration: { ExpiredObjectDeleteMarker: true },\n\t\t},\n\t\t...expiries.map(\n\t\t\t(expiry): LifecycleRule => ({\n\t\t\t\tID: expiry.id,\n\t\t\t\tStatus: 'Enabled',\n\t\t\t\tFilter: { Prefix: expiry.prefix },\n\t\t\t\tExpiration: { Days: expiry.days },\n\t\t\t\t...(expiry.abortIncompleteDays\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAbortIncompleteMultipartUpload: {\n\t\t\t\t\t\t\t\tDaysAfterInitiation: expiry.abortIncompleteDays,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}),\n\t\t),\n\t];\n}\n\n/** A lifecycle rule reduced to what gkm sets, for comparing with what is there. */\nfunction canonicalRule(rule: LifecycleRule): string {\n\treturn JSON.stringify({\n\t\tid: rule.ID ?? '',\n\t\tstatus: rule.Status ?? '',\n\t\tprefix: rule.Filter?.Prefix ?? rule.Prefix ?? '',\n\t\tdays: rule.Expiration?.Days ?? null,\n\t\tmarkers: rule.Expiration?.ExpiredObjectDeleteMarker ?? null,\n\t\tnoncurrent: rule.NoncurrentVersionExpiration?.NoncurrentDays ?? null,\n\t\tabort: rule.AbortIncompleteMultipartUpload?.DaysAfterInitiation ?? null,\n\t});\n}\n\n/** Whether two rule sets say the same thing, in any order. */\nexport function sameLifecycle(\n\ta: readonly LifecycleRule[],\n\tb: readonly LifecycleRule[],\n): boolean {\n\tconst canonical = (rules: readonly LifecycleRule[]) =>\n\t\trules.map(canonicalRule).sort().join('\\n');\n\treturn canonical(a) === canonical(b);\n}\n\n/**\n * The project bucket's lifecycle put to {@link projectBucketLifecycle} of\n * `expiries` — every stage's — when what it holds says anything else.\n * Returns whether it was put; with `dryRun`, whether it would be.\n */\nexport async function reconcileProjectBucketLifecycle(\n\ts3: S3Client,\n\tbucket: string,\n\texpiries: readonly PrefixExpiry[],\n\toptions: { dryRun?: boolean } = {},\n): Promise<boolean> {\n\tconst S3 = await import('@aws-sdk/client-s3');\n\tconst rules = projectBucketLifecycle(expiries);\n\tlet current: LifecycleRule[] = [];\n\ttry {\n\t\tconst out = await s3.send(\n\t\t\tnew S3.GetBucketLifecycleConfigurationCommand({ Bucket: bucket }),\n\t\t);\n\t\tcurrent = out.Rules ?? [];\n\t} catch (error) {\n\t\tconst failure = error as S3Failure;\n\t\tconst code = failure.Code ?? failure.name;\n\t\tif (code !== 'NoSuchLifecycleConfiguration') throw error;\n\t}\n\tif (sameLifecycle(current, rules)) return false;\n\tif (!options.dryRun) {\n\t\tawait s3.send(\n\t\t\tnew S3.PutBucketLifecycleConfigurationCommand({\n\t\t\t\tBucket: bucket,\n\t\t\t\tLifecycleConfiguration: { Rules: rules },\n\t\t\t}),\n\t\t);\n\t}\n\treturn true;\n}\n\ninterface S3Failure {\n\tname?: string;\n\tCode?: string;\n\tmessage?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/**\n * Whether `bucket` is this account's (`ours`) or does not exist (`none`).\n * Mapped by status: a HEAD has no body, so SDK v3 names a 301, 400 or 403\n * `Unknown`.\n *\n * @throws {ProjectBucketTaken} on a 403 or 301\n */\nexport async function findProjectBucket(\n\ts3: S3Client,\n\tbucket: string,\n): Promise<'ours' | 'none'> {\n\tconst { HeadBucketCommand } = await import('@aws-sdk/client-s3');\n\ttry {\n\t\tawait s3.send(new HeadBucketCommand({ Bucket: bucket }));\n\t\treturn 'ours';\n\t} catch (error) {\n\t\tconst status = (error as S3Failure).$metadata?.httpStatusCode;\n\t\tif (status === 404) return 'none';\n\t\tif (status === 403 || status === 301) {\n\t\t\tthrow new ProjectBucketTaken(bucket, status);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport interface EnsureProjectBucketOptions {\n\tbucket: string;\n\tregion: string;\n\t/** The deploy identity the bucket is tagged with. */\n\tidentity: Pick<DeployIdentity, 'key'>;\n\t/** Per-prefix expiries beside the bucket's own rule. */\n\texpiries?: readonly PrefixExpiry[];\n}\n\n/**\n * The project bucket, created and configured if it does not exist yet.\n * Returns whether this call created it. One that exists is used as it is.\n *\n * @throws {ProjectBucketTaken} when another account holds the name\n * @throws {ProjectBucketNotCreatable} when the credentials may not create it\n */\nexport async function ensureProjectBucket(\n\ts3: S3Client,\n\toptions: EnsureProjectBucketOptions,\n): Promise<{ created: boolean }> {\n\tconst { bucket: Bucket, region } = options;\n\tif ((await findProjectBucket(s3, Bucket)) === 'ours') {\n\t\treturn { created: false };\n\t}\n\n\tconst S3 = await import('@aws-sdk/client-s3');\n\ttry {\n\t\tawait s3.send(\n\t\t\tnew S3.CreateBucketCommand({\n\t\t\t\tBucket,\n\t\t\t\tObjectOwnership: 'BucketOwnerEnforced',\n\t\t\t\t// us-east-1 is the one region named by leaving it out.\n\t\t\t\t...(region === 'us-east-1'\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tCreateBucketConfiguration: {\n\t\t\t\t\t\t\t\tLocationConstraint: region as BucketLocationConstraint,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t} catch (error) {\n\t\tconst failure = error as S3Failure;\n\t\tconst code = failure.Code ?? failure.name;\n\t\t// Another run created it a moment ago: configure it all the same.\n\t\tif (code !== 'BucketAlreadyOwnedByYou') {\n\t\t\tif (code === 'BucketAlreadyExists') {\n\t\t\t\tthrow new ProjectBucketTaken(Bucket, 409);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcode === 'AccessDenied' ||\n\t\t\t\tfailure.$metadata?.httpStatusCode === 403\n\t\t\t) {\n\t\t\t\tthrow new ProjectBucketNotCreatable(\n\t\t\t\t\tBucket,\n\t\t\t\t\tfailure.message ?? 'AccessDenied',\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tawait s3.send(\n\t\tnew S3.PutPublicAccessBlockCommand({\n\t\t\tBucket,\n\t\t\tPublicAccessBlockConfiguration: {\n\t\t\t\tBlockPublicAcls: true,\n\t\t\t\tIgnorePublicAcls: true,\n\t\t\t\tBlockPublicPolicy: true,\n\t\t\t\tRestrictPublicBuckets: true,\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketOwnershipControlsCommand({\n\t\t\tBucket,\n\t\t\tOwnershipControls: {\n\t\t\t\tRules: [{ ObjectOwnership: 'BucketOwnerEnforced' }],\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketEncryptionCommand({\n\t\t\tBucket,\n\t\t\tServerSideEncryptionConfiguration: {\n\t\t\t\tRules: [\n\t\t\t\t\t{ ApplyServerSideEncryptionByDefault: { SSEAlgorithm: 'AES256' } },\n\t\t\t\t],\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketVersioningCommand({\n\t\t\tBucket,\n\t\t\tVersioningConfiguration: { Status: 'Enabled' },\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketLifecycleConfigurationCommand({\n\t\t\tBucket,\n\t\t\tLifecycleConfiguration: {\n\t\t\t\tRules: projectBucketLifecycle(options.expiries),\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketTaggingCommand({\n\t\t\tBucket,\n\t\t\tTagging: {\n\t\t\t\tTagSet: [{ Key: PROJECT_BUCKET_TAG, Value: options.identity.key }],\n\t\t\t},\n\t\t}),\n\t);\n\treturn { created: true };\n}\n\n/**\n * The IAM actions creating and configuring the project bucket takes — what a\n * role that runs the first deploy needs on it, beside object access.\n */\nexport const PROJECT_BUCKET_CREATE_ACTIONS = [\n\t's3:CreateBucket',\n\t's3:PutBucketVersioning',\n\t's3:PutEncryptionConfiguration',\n\t's3:PutBucketPublicAccessBlock',\n\t's3:PutBucketOwnershipControls',\n\t's3:PutLifecycleConfiguration',\n\t's3:PutBucketTagging',\n] as const;\n\n/**\n * What keeping the project bucket's lifecycle takes on a bucket that exists:\n * reading it, to put it back only when it drifted.\n */\nexport const PROJECT_BUCKET_LIFECYCLE_ACTIONS = [\n\t's3:GetLifecycleConfiguration',\n\t's3:PutLifecycleConfiguration',\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,YAAY;;AAGlB,MAAa,qBAAqB;;AAMlC,IAAa,qBAAb,cAAwC,SAAS;CAEtC;CAEA;CAHV,YACC,QAEA,QACC;EAKD,MACC,uBAAuB,OAAO,IAJ9B,WAAW,MACR,iDACA,2EAEmC,SAAS,OAAO,8LAIvD;EAbS,KAAA,SAAA;EAEA,KAAA,SAAA;EAYT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,4BAAb,cAA+C,SAAS;CAE7C;CACA;CAFV,YACC,QACA,QACC;EACD,MACC,uBAAuB,OAAO,gEACI,OAAO,qOAI1C;EATS,KAAA,SAAA;EACA,KAAA,SAAA;EAST,KAAK,OAAO;CACb;AACD;;AAgBA,SAAgB,kBAAkB,OAAe,WAA2B;CAC3E,IAAI,OAAO,MACT,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE;CACxB,IAAI,KAAK,SAAS,WAAW;EAC5B,MAAM,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;EACxE,OAAO,GAAG,KAAK,MAAM,GAAG,EAAa,CAAC,CAAC,QAAQ,OAAO,EAAE,EAAE,GAAG;CAC9D;CACA,OAAO,OAAO,KAAK,GAAG;AACvB;;AAGA,eAAsB,gBAAgB,KAAiC;CACtE,MAAM,EAAE,6BAA6B,MAAM,OAAO;CAClD,MAAM,EAAE,YAAY,MAAM,IAAI,KAAK,IAAI,yBAAyB,CAAC,CAAC,CAAC;CACnE,OAAO,WAAW;AACnB;;;;;;AAsBA,SAAgB,uBACf,WAAoC,CAAC,GACnB;CAClB,OAAO,CACN;EACC,IAAI;EACJ,QAAQ;EACR,QAAQ,EAAE,QAAQ,GAAG;EACrB,6BAA6B,EAAE,gBAAA,GAAwC;EAEvE,YAAY,EAAE,2BAA2B,KAAK;CAC/C,GACA,GAAG,SAAS,KACV,YAA2B;EAC3B,IAAI,OAAO;EACX,QAAQ;EACR,QAAQ,EAAE,QAAQ,OAAO,OAAO;EAChC,YAAY,EAAE,MAAM,OAAO,KAAK;EAChC,GAAI,OAAO,sBACR,EACA,gCAAgC,EAC/B,qBAAqB,OAAO,oBAC7B,EACD,IACC,CAAC;CACL,EACD,CACD;AACD;;AAGA,SAAS,cAAc,MAA6B;CACnD,OAAO,KAAK,UAAU;EACrB,IAAI,KAAK,MAAM;EACf,QAAQ,KAAK,UAAU;EACvB,QAAQ,KAAK,QAAQ,UAAU,KAAK,UAAU;EAC9C,MAAM,KAAK,YAAY,QAAQ;EAC/B,SAAS,KAAK,YAAY,6BAA6B;EACvD,YAAY,KAAK,6BAA6B,kBAAkB;EAChE,OAAO,KAAK,gCAAgC,uBAAuB;CACpE,CAAC;AACF;;AAGA,SAAgB,cACf,GACA,GACU;CACV,MAAM,aAAa,UAClB,MAAM,IAAI,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;CAC1C,OAAO,UAAU,CAAC,MAAM,UAAU,CAAC;AACpC;;;;;;AAOA,eAAsB,gCACrB,IACA,QACA,UACA,UAAgC,CAAC,GACd;CACnB,MAAM,KAAK,MAAM,OAAO;CACxB,MAAM,QAAQ,uBAAuB,QAAQ;CAC7C,IAAI,UAA2B,CAAC;CAChC,IAAI;EAIH,WAAU,MAHQ,GAAG,KACpB,IAAI,GAAG,uCAAuC,EAAE,QAAQ,OAAO,CAAC,CACjE,EAAA,CACc,SAAS,CAAC;CACzB,SAAS,OAAO;EACf,MAAM,UAAU;EAEhB,KADa,QAAQ,QAAQ,QAAQ,UACxB,gCAAgC,MAAM;CACpD;CACA,IAAI,cAAc,SAAS,KAAK,GAAG,OAAO;CAC1C,IAAI,CAAC,QAAQ,QACZ,MAAM,GAAG,KACR,IAAI,GAAG,uCAAuC;EAC7C,QAAQ;EACR,wBAAwB,EAAE,OAAO,MAAM;CACxC,CAAC,CACF;CAED,OAAO;AACR;;;;;;;;AAgBA,eAAsB,kBACrB,IACA,QAC2B;CAC3B,MAAM,EAAE,sBAAsB,MAAM,OAAO;CAC3C,IAAI;EACH,MAAM,GAAG,KAAK,IAAI,kBAAkB,EAAE,QAAQ,OAAO,CAAC,CAAC;EACvD,OAAO;CACR,SAAS,OAAO;EACf,MAAM,SAAU,MAAoB,WAAW;EAC/C,IAAI,WAAW,KAAK,OAAO;EAC3B,IAAI,WAAW,OAAO,WAAW,KAChC,MAAM,IAAI,mBAAmB,QAAQ,MAAM;EAE5C,MAAM;CACP;AACD;;;;;;;;AAkBA,eAAsB,oBACrB,IACA,SACgC;CAChC,MAAM,EAAE,QAAQ,QAAQ,WAAW;CACnC,IAAK,MAAM,kBAAkB,IAAI,MAAM,MAAO,QAC7C,OAAO,EAAE,SAAS,MAAM;CAGzB,MAAM,KAAK,MAAM,OAAO;CACxB,IAAI;EACH,MAAM,GAAG,KACR,IAAI,GAAG,oBAAoB;GAC1B;GACA,iBAAiB;GAEjB,GAAI,WAAW,cACZ,CAAC,IACD,EACA,2BAA2B,EAC1B,oBAAoB,OACrB,EACD;EACH,CAAC,CACF;CACD,SAAS,OAAO;EACf,MAAM,UAAU;EAChB,MAAM,OAAO,QAAQ,QAAQ,QAAQ;EAErC,IAAI,SAAS,2BAA2B;GACvC,IAAI,SAAS,uBACZ,MAAM,IAAI,mBAAmB,QAAQ,GAAG;GAEzC,IACC,SAAS,kBACT,QAAQ,WAAW,mBAAmB,KAEtC,MAAM,IAAI,0BACT,QACA,QAAQ,WAAW,cACpB;GAED,MAAM;EACP;CACD;CAEA,MAAM,GAAG,KACR,IAAI,GAAG,4BAA4B;EAClC;EACA,gCAAgC;GAC/B,iBAAiB;GACjB,kBAAkB;GAClB,mBAAmB;GACnB,uBAAuB;EACxB;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,kCAAkC;EACxC;EACA,mBAAmB,EAClB,OAAO,CAAC,EAAE,iBAAiB,sBAAsB,CAAC,EACnD;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,2BAA2B;EACjC;EACA,mCAAmC,EAClC,OAAO,CACN,EAAE,oCAAoC,EAAE,cAAc,SAAS,EAAE,CAClE,EACD;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,2BAA2B;EACjC;EACA,yBAAyB,EAAE,QAAQ,UAAU;CAC9C,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,uCAAuC;EAC7C;EACA,wBAAwB,EACvB,OAAO,uBAAuB,QAAQ,QAAQ,EAC/C;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,wBAAwB;EAC9B;EACA,SAAS,EACR,QAAQ,CAAC;GAAE,KAAK;GAAoB,OAAO,QAAQ,SAAS;EAAI,CAAC,EAClE;CACD,CAAC,CACF;CACA,OAAO,EAAE,SAAS,KAAK;AACxB;;;;;AAMA,MAAa,gCAAgC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;AAMA,MAAa,mCAAmC,CAC/C,gCACA,8BACD"}
@@ -0,0 +1,57 @@
1
+ const require_errors = require("./errors-DMC4Umsb.cjs");
2
+ const require_define = require("./define-crmMcXFS.cjs");
3
+ //#region src/target/provider.ts
4
+ /**
5
+ * `gkm deploy --provider`, from before there were targets.
6
+ *
7
+ * It named three things, and only one of them ever deployed a workspace:
8
+ * `dokploy` is now the target of that name; `docker` and `aws-lambda` were
9
+ * accepted and always failed, so they are gone with a pointer to what does
10
+ * the job.
11
+ */
12
+ /** What each removed provider's job is done with now. */
13
+ const REMOVED = {
14
+ docker: "Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`",
15
+ "aws-lambda": "Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm deploy --stage <stage>`, which runs `sst deploy`"
16
+ };
17
+ /** A `--provider` that no longer exists. */
18
+ var ProviderRemoved = class extends require_errors.GkmError {
19
+ provider;
20
+ instead;
21
+ constructor(provider, instead) {
22
+ super(`--provider ${provider} has been removed. ${instead}.`);
23
+ this.provider = provider;
24
+ this.instead = instead;
25
+ this.name = "ProviderRemoved";
26
+ }
27
+ };
28
+ /** The deprecation `--provider` prints when it still means something. */
29
+ function providerDeprecation(provider) {
30
+ return `--provider is deprecated; use --target ${provider}.`;
31
+ }
32
+ /**
33
+ * The target a `--provider` value means. `warn` hears the deprecation; a
34
+ * provider that is gone, or a target not deployable yet, throws.
35
+ */
36
+ function targetForProvider(provider, warn) {
37
+ const removed = REMOVED[provider];
38
+ if (removed) throw new ProviderRemoved(provider, removed);
39
+ if (provider === "vercel" || provider === "cloudflare") throw new require_define.DeployTargetNotYetSupported(provider);
40
+ warn(providerDeprecation(provider));
41
+ return provider;
42
+ }
43
+ //#endregion
44
+ Object.defineProperty(exports, "ProviderRemoved", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return ProviderRemoved;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "targetForProvider", {
51
+ enumerable: true,
52
+ get: function() {
53
+ return targetForProvider;
54
+ }
55
+ });
56
+
57
+ //# sourceMappingURL=provider-BqpjG9QM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-BqpjG9QM.cjs","names":["GkmError","DeployTargetNotYetSupported"],"sources":["../src/target/provider.ts"],"sourcesContent":["/**\n * `gkm deploy --provider`, from before there were targets.\n *\n * It named three things, and only one of them ever deployed a workspace:\n * `dokploy` is now the target of that name; `docker` and `aws-lambda` were\n * accepted and always failed, so they are gone with a pointer to what does\n * the job.\n */\n\nimport { GkmError } from '../errors';\nimport { DeployTargetNotYetSupported } from './builtins';\n\n/** What each removed provider's job is done with now. */\nconst REMOVED: Record<string, string> = {\n\tdocker:\n\t\t'Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`',\n\t'aws-lambda':\n\t\t\"Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm deploy --stage <stage>`, which runs `sst deploy`\",\n};\n\n/** A `--provider` that no longer exists. */\nexport class ProviderRemoved extends GkmError {\n\tconstructor(\n\t\treadonly provider: string,\n\t\t/** What to use instead. */\n\t\treadonly instead: string,\n\t) {\n\t\tsuper(`--provider ${provider} has been removed. ${instead}.`);\n\t\tthis.name = 'ProviderRemoved';\n\t}\n}\n\n/** The deprecation `--provider` prints when it still means something. */\nexport function providerDeprecation(provider: string): string {\n\treturn `--provider is deprecated; use --target ${provider}.`;\n}\n\n/**\n * The target a `--provider` value means. `warn` hears the deprecation; a\n * provider that is gone, or a target not deployable yet, throws.\n */\nexport function targetForProvider(\n\tprovider: string,\n\twarn: (message: string) => void,\n): string {\n\tconst removed = REMOVED[provider];\n\tif (removed) throw new ProviderRemoved(provider, removed);\n\tif (provider === 'vercel' || provider === 'cloudflare') {\n\t\tthrow new DeployTargetNotYetSupported(provider);\n\t}\n\twarn(providerDeprecation(provider));\n\treturn provider;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,UAAkC;CACvC,QACC;CACD,cACC;AACF;;AAGA,IAAa,kBAAb,cAAqCA,eAAAA,SAAS;CAEnC;CAEA;CAHV,YACC,UAEA,SACC;EACD,MAAM,cAAc,SAAS,qBAAqB,QAAQ,EAAE;EAJnD,KAAA,WAAA;EAEA,KAAA,UAAA;EAGT,KAAK,OAAO;CACb;AACD;;AAGA,SAAgB,oBAAoB,UAA0B;CAC7D,OAAO,0CAA0C,SAAS;AAC3D;;;;;AAMA,SAAgB,kBACf,UACA,MACS;CACT,MAAM,UAAU,QAAQ;CACxB,IAAI,SAAS,MAAM,IAAI,gBAAgB,UAAU,OAAO;CACxD,IAAI,aAAa,YAAY,aAAa,cACzC,MAAM,IAAIC,eAAAA,4BAA4B,QAAQ;CAE/C,KAAK,oBAAoB,QAAQ,CAAC;CAClC,OAAO;AACR"}
@@ -0,0 +1,46 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { i as DeployTargetNotYetSupported } from "./define-6poNqm5O.mjs";
3
+ //#region src/target/provider.ts
4
+ /**
5
+ * `gkm deploy --provider`, from before there were targets.
6
+ *
7
+ * It named three things, and only one of them ever deployed a workspace:
8
+ * `dokploy` is now the target of that name; `docker` and `aws-lambda` were
9
+ * accepted and always failed, so they are gone with a pointer to what does
10
+ * the job.
11
+ */
12
+ /** What each removed provider's job is done with now. */
13
+ const REMOVED = {
14
+ docker: "Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`",
15
+ "aws-lambda": "Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm deploy --stage <stage>`, which runs `sst deploy`"
16
+ };
17
+ /** A `--provider` that no longer exists. */
18
+ var ProviderRemoved = class extends GkmError {
19
+ provider;
20
+ instead;
21
+ constructor(provider, instead) {
22
+ super(`--provider ${provider} has been removed. ${instead}.`);
23
+ this.provider = provider;
24
+ this.instead = instead;
25
+ this.name = "ProviderRemoved";
26
+ }
27
+ };
28
+ /** The deprecation `--provider` prints when it still means something. */
29
+ function providerDeprecation(provider) {
30
+ return `--provider is deprecated; use --target ${provider}.`;
31
+ }
32
+ /**
33
+ * The target a `--provider` value means. `warn` hears the deprecation; a
34
+ * provider that is gone, or a target not deployable yet, throws.
35
+ */
36
+ function targetForProvider(provider, warn) {
37
+ const removed = REMOVED[provider];
38
+ if (removed) throw new ProviderRemoved(provider, removed);
39
+ if (provider === "vercel" || provider === "cloudflare") throw new DeployTargetNotYetSupported(provider);
40
+ warn(providerDeprecation(provider));
41
+ return provider;
42
+ }
43
+ //#endregion
44
+ export { targetForProvider as n, ProviderRemoved as t };
45
+
46
+ //# sourceMappingURL=provider-CEOKk8NS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-CEOKk8NS.mjs","names":[],"sources":["../src/target/provider.ts"],"sourcesContent":["/**\n * `gkm deploy --provider`, from before there were targets.\n *\n * It named three things, and only one of them ever deployed a workspace:\n * `dokploy` is now the target of that name; `docker` and `aws-lambda` were\n * accepted and always failed, so they are gone with a pointer to what does\n * the job.\n */\n\nimport { GkmError } from '../errors';\nimport { DeployTargetNotYetSupported } from './builtins';\n\n/** What each removed provider's job is done with now. */\nconst REMOVED: Record<string, string> = {\n\tdocker:\n\t\t'Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`',\n\t'aws-lambda':\n\t\t\"Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm deploy --stage <stage>`, which runs `sst deploy`\",\n};\n\n/** A `--provider` that no longer exists. */\nexport class ProviderRemoved extends GkmError {\n\tconstructor(\n\t\treadonly provider: string,\n\t\t/** What to use instead. */\n\t\treadonly instead: string,\n\t) {\n\t\tsuper(`--provider ${provider} has been removed. ${instead}.`);\n\t\tthis.name = 'ProviderRemoved';\n\t}\n}\n\n/** The deprecation `--provider` prints when it still means something. */\nexport function providerDeprecation(provider: string): string {\n\treturn `--provider is deprecated; use --target ${provider}.`;\n}\n\n/**\n * The target a `--provider` value means. `warn` hears the deprecation; a\n * provider that is gone, or a target not deployable yet, throws.\n */\nexport function targetForProvider(\n\tprovider: string,\n\twarn: (message: string) => void,\n): string {\n\tconst removed = REMOVED[provider];\n\tif (removed) throw new ProviderRemoved(provider, removed);\n\tif (provider === 'vercel' || provider === 'cloudflare') {\n\t\tthrow new DeployTargetNotYetSupported(provider);\n\t}\n\twarn(providerDeprecation(provider));\n\treturn provider;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,UAAkC;CACvC,QACC;CACD,cACC;AACF;;AAGA,IAAa,kBAAb,cAAqC,SAAS;CAEnC;CAEA;CAHV,YACC,UAEA,SACC;EACD,MAAM,cAAc,SAAS,qBAAqB,QAAQ,EAAE;EAJnD,KAAA,WAAA;EAEA,KAAA,UAAA;EAGT,KAAK,OAAO;CACb;AACD;;AAGA,SAAgB,oBAAoB,UAA0B;CAC7D,OAAO,0CAA0C,SAAS;AAC3D;;;;;AAMA,SAAgB,kBACf,UACA,MACS;CACT,MAAM,UAAU,QAAQ;CACxB,IAAI,SAAS,MAAM,IAAI,gBAAgB,UAAU,OAAO;CACxD,IAAI,aAAa,YAAY,aAAa,cACzC,MAAM,IAAI,4BAA4B,QAAQ;CAE/C,KAAK,oBAAoB,QAAQ,CAAC;CAClC,OAAO;AACR"}
@@ -0,0 +1,123 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { easCli, easSync } from "./eas-6ezdJtry.mjs";
3
+ import { join } from "node:path";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { spawnSync } from "node:child_process";
6
+ //#region src/mobile/publish.ts
7
+ /**
8
+ * `gkm publish --stage <stage>`: a mobile app shipped for a deployed stage.
9
+ *
10
+ * First the stage's EAS project is synced (`gkm eas:sync`), so what is built
11
+ * reads the stage's values. Then, per platform, the cheapest release that
12
+ * gets the app's current code to the stage's users:
13
+ *
14
+ * - **An update**, when a store build with the same native code is already
15
+ * out: the fingerprint `runtimeVersion: { policy: 'fingerprint' }` gives a
16
+ * build is computed with the stage's profile, and a finished store build
17
+ * of that profile with that fingerprint means only JavaScript changed. It
18
+ * goes out on the stage's channel (`eas update`), which only builds of
19
+ * that runtime receive.
20
+ * - **A store build**, otherwise, submitted to the store as the stage's
21
+ * submit profile says (`eas build --auto-submit`): Android to its Play
22
+ * track; iOS to App Store Connect once `submit.<stage>.ios.ascAppId` is
23
+ * set — without it, iOS is built and not submitted, and gkm says so,
24
+ * rather than leave a prompt nobody in CI can answer.
25
+ *
26
+ * `--build` or `--update` decides instead. An update with no store build to
27
+ * receive it reaches nobody, so `--update` without one is refused.
28
+ */
29
+ const logger = console;
30
+ /** `--update`, and no store build has this native code. */
31
+ var NoStoreBuildForUpdate = class extends GkmError {
32
+ platform;
33
+ stage;
34
+ fingerprint;
35
+ constructor(platform, stage, fingerprint) {
36
+ super(`No ${platform} store build of '${stage}' has this native code (fingerprint ${fingerprint}), so an update would reach nobody: a phone only takes updates for the runtime it was built with. Build one: gkm publish --stage ${stage} --platform ${platform} --build.`);
37
+ this.platform = platform;
38
+ this.stage = stage;
39
+ this.fingerprint = fingerprint;
40
+ this.name = "NoStoreBuildForUpdate";
41
+ }
42
+ };
43
+ /** `--build` and `--update` together. */
44
+ var PublishModeConflict = class extends GkmError {
45
+ constructor() {
46
+ super("Pass --build or --update, not both: one release per platform.");
47
+ this.name = "PublishModeConflict";
48
+ }
49
+ };
50
+ /**
51
+ * Ship a mobile app for a deployed stage.
52
+ *
53
+ * @throws {NoStoreBuildForUpdate} — and what `easSync` throws
54
+ */
55
+ async function publish(options, eas) {
56
+ const synced = await easSync(options, eas);
57
+ const cli = eas ?? easCli(synced.root, synced.values);
58
+ const { dir, stage } = synced;
59
+ const profile = stage.stage;
60
+ const easJson = existsSync(join(dir, "eas.json")) ? JSON.parse(readFileSync(join(dir, "eas.json"), "utf8")) : {};
61
+ const iosSubmits = Boolean(easJson.submit?.[profile]?.ios?.ascAppId);
62
+ const platforms = !options.platform || options.platform === "all" ? ["ios", "android"] : [options.platform];
63
+ const releases = [];
64
+ for (const platform of platforms) {
65
+ const fingerprint = await cli.fingerprint(dir, {
66
+ platform,
67
+ profile
68
+ });
69
+ const storeBuild = options.mode === "build" ? void 0 : await cli.storeBuild(dir, {
70
+ platform,
71
+ profile,
72
+ fingerprint
73
+ });
74
+ if (options.mode === "update" && !storeBuild) throw new NoStoreBuildForUpdate(platform, profile, fingerprint);
75
+ const release = options.mode ?? (storeBuild ? "update" : "build");
76
+ const submit = platform === "android" || iosSubmits;
77
+ releases.push({
78
+ platform,
79
+ fingerprint,
80
+ ...storeBuild ? { storeBuild } : {},
81
+ release,
82
+ submit: release === "build" && submit
83
+ });
84
+ const why = storeBuild ? `store build ${storeBuild} has this native code` : "no store build has this native code";
85
+ if (release === "update") {
86
+ logger.log(`🔁 ${platform}: an update on '${stage.channel}' (${why})${options.dryRun ? " (dry run)" : ""}`);
87
+ if (options.dryRun) continue;
88
+ await cli.update(dir, {
89
+ platform,
90
+ channel: stage.channel,
91
+ environment: stage.environment,
92
+ message: options.message ?? commitSubject(synced.root, profile)
93
+ });
94
+ continue;
95
+ }
96
+ const where = platform === "android" ? `submitted to Play's ${stage.android.track} track (${stage.android.releaseStatus})` : iosSubmits ? "submitted to App Store Connect" : `not submitted: submit.${profile}.ios.ascAppId is not set in eas.json`;
97
+ logger.log(`📦 ${platform}: a store build of '${profile}', ${where} (${why})${options.dryRun ? " (dry run)" : ""}`);
98
+ if (options.dryRun) continue;
99
+ await cli.build(dir, {
100
+ platform,
101
+ profile,
102
+ submit,
103
+ wait: options.wait ?? false
104
+ });
105
+ }
106
+ return releases;
107
+ }
108
+ /** The current commit's subject, for an update's message. */
109
+ function commitSubject(root, stage) {
110
+ const result = spawnSync("git", [
111
+ "log",
112
+ "-1",
113
+ "--format=%s"
114
+ ], {
115
+ cwd: root,
116
+ encoding: "utf8"
117
+ });
118
+ return (result.status === 0 ? result.stdout.trim() : "") || `gkm publish --stage ${stage}`;
119
+ }
120
+ //#endregion
121
+ export { PublishModeConflict, publish };
122
+
123
+ //# sourceMappingURL=publish-B-EIjfQ0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-B-EIjfQ0.mjs","names":[],"sources":["../src/mobile/publish.ts"],"sourcesContent":["/**\n * `gkm publish --stage <stage>`: a mobile app shipped for a deployed stage.\n *\n * First the stage's EAS project is synced (`gkm eas:sync`), so what is built\n * reads the stage's values. Then, per platform, the cheapest release that\n * gets the app's current code to the stage's users:\n *\n * - **An update**, when a store build with the same native code is already\n * out: the fingerprint `runtimeVersion: { policy: 'fingerprint' }` gives a\n * build is computed with the stage's profile, and a finished store build\n * of that profile with that fingerprint means only JavaScript changed. It\n * goes out on the stage's channel (`eas update`), which only builds of\n * that runtime receive.\n * - **A store build**, otherwise, submitted to the store as the stage's\n * submit profile says (`eas build --auto-submit`): Android to its Play\n * track; iOS to App Store Connect once `submit.<stage>.ios.ascAppId` is\n * set — without it, iOS is built and not submitted, and gkm says so,\n * rather than leave a prompt nobody in CI can answer.\n *\n * `--build` or `--update` decides instead. An update with no store build to\n * receive it reaches nobody, so `--update` without one is refused.\n */\n\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { GkmError } from '../errors';\nimport {\n\ttype EasCli,\n\ttype EasPlatform,\n\ttype EasSyncOptions,\n\teasCli,\n\teasSync,\n} from './eas.js';\n\nconst logger = console;\n\n/** `--update`, and no store build has this native code. */\nexport class NoStoreBuildForUpdate extends GkmError {\n\tconstructor(\n\t\treadonly platform: EasPlatform,\n\t\treadonly stage: string,\n\t\treadonly fingerprint: string,\n\t) {\n\t\tsuper(\n\t\t\t`No ${platform} store build of '${stage}' has this native code ` +\n\t\t\t\t`(fingerprint ${fingerprint}), so an update would reach nobody: a phone ` +\n\t\t\t\t'only takes updates for the runtime it was built with. Build one: ' +\n\t\t\t\t`gkm publish --stage ${stage} --platform ${platform} --build.`,\n\t\t);\n\t\tthis.name = 'NoStoreBuildForUpdate';\n\t}\n}\n\n/** `--build` and `--update` together. */\nexport class PublishModeConflict extends GkmError {\n\tconstructor() {\n\t\tsuper('Pass --build or --update, not both: one release per platform.');\n\t\tthis.name = 'PublishModeConflict';\n\t}\n}\n\nexport interface PublishOptions extends EasSyncOptions {\n\t/** `ios`, `android`, or both (the default). */\n\tplatform?: EasPlatform | 'all';\n\t/** Build, or update, whatever the fingerprint says. */\n\tmode?: 'build' | 'update';\n\t/** Wait for a build to finish (and submit), rather than leave it on EAS. */\n\twait?: boolean;\n\t/** The update's message: the commit's subject by default. */\n\tmessage?: string;\n}\n\n/** What one platform's release was — or, dry, would be. */\nexport interface PlatformRelease {\n\tplatform: EasPlatform;\n\tfingerprint: string;\n\t/** The store build that already has this native code, if one does. */\n\tstoreBuild?: string;\n\trelease: 'build' | 'update';\n\t/** Whether a build is submitted to its store. */\n\tsubmit: boolean;\n}\n\n/**\n * Ship a mobile app for a deployed stage.\n *\n * @throws {NoStoreBuildForUpdate} — and what `easSync` throws\n */\nexport async function publish(\n\toptions: PublishOptions,\n\teas?: EasCli,\n): Promise<PlatformRelease[]> {\n\tconst synced = await easSync(options, eas);\n\tconst cli = eas ?? easCli(synced.root, synced.values);\n\tconst { dir, stage } = synced;\n\tconst profile = stage.stage;\n\n\tconst easJson = existsSync(join(dir, 'eas.json'))\n\t\t? (JSON.parse(readFileSync(join(dir, 'eas.json'), 'utf8')) as {\n\t\t\t\tsubmit?: Record<string, { ios?: { ascAppId?: string } }>;\n\t\t\t})\n\t\t: {};\n\tconst iosSubmits = Boolean(easJson.submit?.[profile]?.ios?.ascAppId);\n\n\tconst platforms: EasPlatform[] =\n\t\t!options.platform || options.platform === 'all'\n\t\t\t? ['ios', 'android']\n\t\t\t: [options.platform];\n\n\tconst releases: PlatformRelease[] = [];\n\tfor (const platform of platforms) {\n\t\tconst fingerprint = await cli.fingerprint(dir, { platform, profile });\n\t\tconst storeBuild =\n\t\t\toptions.mode === 'build'\n\t\t\t\t? undefined\n\t\t\t\t: await cli.storeBuild(dir, { platform, profile, fingerprint });\n\t\tif (options.mode === 'update' && !storeBuild) {\n\t\t\tthrow new NoStoreBuildForUpdate(platform, profile, fingerprint);\n\t\t}\n\t\tconst release = options.mode ?? (storeBuild ? 'update' : 'build');\n\t\tconst submit = platform === 'android' || iosSubmits;\n\t\treleases.push({\n\t\t\tplatform,\n\t\t\tfingerprint,\n\t\t\t...(storeBuild ? { storeBuild } : {}),\n\t\t\trelease,\n\t\t\tsubmit: release === 'build' && submit,\n\t\t});\n\n\t\tconst why = storeBuild\n\t\t\t? `store build ${storeBuild} has this native code`\n\t\t\t: 'no store build has this native code';\n\t\tif (release === 'update') {\n\t\t\tlogger.log(\n\t\t\t\t`🔁 ${platform}: an update on '${stage.channel}' (${why})${options.dryRun ? ' (dry run)' : ''}`,\n\t\t\t);\n\t\t\tif (options.dryRun) continue;\n\t\t\tawait cli.update(dir, {\n\t\t\t\tplatform,\n\t\t\t\tchannel: stage.channel,\n\t\t\t\tenvironment: stage.environment,\n\t\t\t\tmessage: options.message ?? commitSubject(synced.root, profile),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst where =\n\t\t\tplatform === 'android'\n\t\t\t\t? `submitted to Play's ${stage.android.track} track (${stage.android.releaseStatus})`\n\t\t\t\t: iosSubmits\n\t\t\t\t\t? 'submitted to App Store Connect'\n\t\t\t\t\t: `not submitted: submit.${profile}.ios.ascAppId is not set in eas.json`;\n\t\tlogger.log(\n\t\t\t`📦 ${platform}: a store build of '${profile}', ${where} (${why})${options.dryRun ? ' (dry run)' : ''}`,\n\t\t);\n\t\tif (options.dryRun) continue;\n\t\tawait cli.build(dir, {\n\t\t\tplatform,\n\t\t\tprofile,\n\t\t\tsubmit,\n\t\t\twait: options.wait ?? false,\n\t\t});\n\t}\n\treturn releases;\n}\n\n/** The current commit's subject, for an update's message. */\nfunction commitSubject(root: string, stage: string): string {\n\tconst result = spawnSync('git', ['log', '-1', '--format=%s'], {\n\t\tcwd: root,\n\t\tencoding: 'utf8',\n\t});\n\tconst subject = result.status === 0 ? result.stdout.trim() : '';\n\treturn subject || `gkm publish --stage ${stage}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,SAAS;;AAGf,IAAa,wBAAb,cAA2C,SAAS;CAEzC;CACA;CACA;CAHV,YACC,UACA,OACA,aACC;EACD,MACC,MAAM,SAAS,mBAAmB,MAAM,sCACvB,YAAY,mIAEL,MAAM,cAAc,SAAS,UACtD;EATS,KAAA,WAAA;EACA,KAAA,QAAA;EACA,KAAA,cAAA;EAQT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,sBAAb,cAAyC,SAAS;CACjD,cAAc;EACb,MAAM,+DAA+D;EACrE,KAAK,OAAO;CACb;AACD;;;;;;AA6BA,eAAsB,QACrB,SACA,KAC6B;CAC7B,MAAM,SAAS,MAAM,QAAQ,SAAS,GAAG;CACzC,MAAM,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO,MAAM;CACpD,MAAM,EAAE,KAAK,UAAU;CACvB,MAAM,UAAU,MAAM;CAEtB,MAAM,UAAU,WAAW,KAAK,KAAK,UAAU,CAAC,IAC5C,KAAK,MAAM,aAAa,KAAK,KAAK,UAAU,GAAG,MAAM,CAAC,IAGvD,CAAC;CACJ,MAAM,aAAa,QAAQ,QAAQ,SAAS,QAAQ,EAAE,KAAK,QAAQ;CAEnE,MAAM,YACL,CAAC,QAAQ,YAAY,QAAQ,aAAa,QACvC,CAAC,OAAO,SAAS,IACjB,CAAC,QAAQ,QAAQ;CAErB,MAAM,WAA8B,CAAC;CACrC,KAAK,MAAM,YAAY,WAAW;EACjC,MAAM,cAAc,MAAM,IAAI,YAAY,KAAK;GAAE;GAAU;EAAQ,CAAC;EACpE,MAAM,aACL,QAAQ,SAAS,UACd,KAAA,IACA,MAAM,IAAI,WAAW,KAAK;GAAE;GAAU;GAAS;EAAY,CAAC;EAChE,IAAI,QAAQ,SAAS,YAAY,CAAC,YACjC,MAAM,IAAI,sBAAsB,UAAU,SAAS,WAAW;EAE/D,MAAM,UAAU,QAAQ,SAAS,aAAa,WAAW;EACzD,MAAM,SAAS,aAAa,aAAa;EACzC,SAAS,KAAK;GACb;GACA;GACA,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;GACnC;GACA,QAAQ,YAAY,WAAW;EAChC,CAAC;EAED,MAAM,MAAM,aACT,eAAe,WAAW,yBAC1B;EACH,IAAI,YAAY,UAAU;GACzB,OAAO,IACN,MAAM,SAAS,kBAAkB,MAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ,SAAS,eAAe,IAC5F;GACA,IAAI,QAAQ,QAAQ;GACpB,MAAM,IAAI,OAAO,KAAK;IACrB;IACA,SAAS,MAAM;IACf,aAAa,MAAM;IACnB,SAAS,QAAQ,WAAW,cAAc,OAAO,MAAM,OAAO;GAC/D,CAAC;GACD;EACD;EAEA,MAAM,QACL,aAAa,YACV,uBAAuB,MAAM,QAAQ,MAAM,UAAU,MAAM,QAAQ,cAAc,KACjF,aACC,mCACA,yBAAyB,QAAQ;EACtC,OAAO,IACN,MAAM,SAAS,sBAAsB,QAAQ,KAAK,MAAM,IAAI,IAAI,GAAG,QAAQ,SAAS,eAAe,IACpG;EACA,IAAI,QAAQ,QAAQ;EACpB,MAAM,IAAI,MAAM,KAAK;GACpB;GACA;GACA;GACA,MAAM,QAAQ,QAAQ;EACvB,CAAC;CACF;CACA,OAAO;AACR;;AAGA,SAAS,cAAc,MAAc,OAAuB;CAC3D,MAAM,SAAS,UAAU,OAAO;EAAC;EAAO;EAAM;CAAa,GAAG;EAC7D,KAAK;EACL,UAAU;CACX,CAAC;CAED,QADgB,OAAO,WAAW,IAAI,OAAO,OAAO,KAAK,IAAI,OAC3C,uBAAuB;AAC1C"}
@@ -0,0 +1,124 @@
1
+ const require_errors = require("./errors-DMC4Umsb.cjs");
2
+ const require_eas = require("./eas-BkLA60P2.cjs");
3
+ let node_path = require("node:path");
4
+ let node_fs = require("node:fs");
5
+ let node_child_process = require("node:child_process");
6
+ //#region src/mobile/publish.ts
7
+ /**
8
+ * `gkm publish --stage <stage>`: a mobile app shipped for a deployed stage.
9
+ *
10
+ * First the stage's EAS project is synced (`gkm eas:sync`), so what is built
11
+ * reads the stage's values. Then, per platform, the cheapest release that
12
+ * gets the app's current code to the stage's users:
13
+ *
14
+ * - **An update**, when a store build with the same native code is already
15
+ * out: the fingerprint `runtimeVersion: { policy: 'fingerprint' }` gives a
16
+ * build is computed with the stage's profile, and a finished store build
17
+ * of that profile with that fingerprint means only JavaScript changed. It
18
+ * goes out on the stage's channel (`eas update`), which only builds of
19
+ * that runtime receive.
20
+ * - **A store build**, otherwise, submitted to the store as the stage's
21
+ * submit profile says (`eas build --auto-submit`): Android to its Play
22
+ * track; iOS to App Store Connect once `submit.<stage>.ios.ascAppId` is
23
+ * set — without it, iOS is built and not submitted, and gkm says so,
24
+ * rather than leave a prompt nobody in CI can answer.
25
+ *
26
+ * `--build` or `--update` decides instead. An update with no store build to
27
+ * receive it reaches nobody, so `--update` without one is refused.
28
+ */
29
+ const logger = console;
30
+ /** `--update`, and no store build has this native code. */
31
+ var NoStoreBuildForUpdate = class extends require_errors.GkmError {
32
+ platform;
33
+ stage;
34
+ fingerprint;
35
+ constructor(platform, stage, fingerprint) {
36
+ super(`No ${platform} store build of '${stage}' has this native code (fingerprint ${fingerprint}), so an update would reach nobody: a phone only takes updates for the runtime it was built with. Build one: gkm publish --stage ${stage} --platform ${platform} --build.`);
37
+ this.platform = platform;
38
+ this.stage = stage;
39
+ this.fingerprint = fingerprint;
40
+ this.name = "NoStoreBuildForUpdate";
41
+ }
42
+ };
43
+ /** `--build` and `--update` together. */
44
+ var PublishModeConflict = class extends require_errors.GkmError {
45
+ constructor() {
46
+ super("Pass --build or --update, not both: one release per platform.");
47
+ this.name = "PublishModeConflict";
48
+ }
49
+ };
50
+ /**
51
+ * Ship a mobile app for a deployed stage.
52
+ *
53
+ * @throws {NoStoreBuildForUpdate} — and what `easSync` throws
54
+ */
55
+ async function publish(options, eas) {
56
+ const synced = await require_eas.easSync(options, eas);
57
+ const cli = eas ?? require_eas.easCli(synced.root, synced.values);
58
+ const { dir, stage } = synced;
59
+ const profile = stage.stage;
60
+ const easJson = (0, node_fs.existsSync)((0, node_path.join)(dir, "eas.json")) ? JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(dir, "eas.json"), "utf8")) : {};
61
+ const iosSubmits = Boolean(easJson.submit?.[profile]?.ios?.ascAppId);
62
+ const platforms = !options.platform || options.platform === "all" ? ["ios", "android"] : [options.platform];
63
+ const releases = [];
64
+ for (const platform of platforms) {
65
+ const fingerprint = await cli.fingerprint(dir, {
66
+ platform,
67
+ profile
68
+ });
69
+ const storeBuild = options.mode === "build" ? void 0 : await cli.storeBuild(dir, {
70
+ platform,
71
+ profile,
72
+ fingerprint
73
+ });
74
+ if (options.mode === "update" && !storeBuild) throw new NoStoreBuildForUpdate(platform, profile, fingerprint);
75
+ const release = options.mode ?? (storeBuild ? "update" : "build");
76
+ const submit = platform === "android" || iosSubmits;
77
+ releases.push({
78
+ platform,
79
+ fingerprint,
80
+ ...storeBuild ? { storeBuild } : {},
81
+ release,
82
+ submit: release === "build" && submit
83
+ });
84
+ const why = storeBuild ? `store build ${storeBuild} has this native code` : "no store build has this native code";
85
+ if (release === "update") {
86
+ logger.log(`🔁 ${platform}: an update on '${stage.channel}' (${why})${options.dryRun ? " (dry run)" : ""}`);
87
+ if (options.dryRun) continue;
88
+ await cli.update(dir, {
89
+ platform,
90
+ channel: stage.channel,
91
+ environment: stage.environment,
92
+ message: options.message ?? commitSubject(synced.root, profile)
93
+ });
94
+ continue;
95
+ }
96
+ const where = platform === "android" ? `submitted to Play's ${stage.android.track} track (${stage.android.releaseStatus})` : iosSubmits ? "submitted to App Store Connect" : `not submitted: submit.${profile}.ios.ascAppId is not set in eas.json`;
97
+ logger.log(`📦 ${platform}: a store build of '${profile}', ${where} (${why})${options.dryRun ? " (dry run)" : ""}`);
98
+ if (options.dryRun) continue;
99
+ await cli.build(dir, {
100
+ platform,
101
+ profile,
102
+ submit,
103
+ wait: options.wait ?? false
104
+ });
105
+ }
106
+ return releases;
107
+ }
108
+ /** The current commit's subject, for an update's message. */
109
+ function commitSubject(root, stage) {
110
+ const result = (0, node_child_process.spawnSync)("git", [
111
+ "log",
112
+ "-1",
113
+ "--format=%s"
114
+ ], {
115
+ cwd: root,
116
+ encoding: "utf8"
117
+ });
118
+ return (result.status === 0 ? result.stdout.trim() : "") || `gkm publish --stage ${stage}`;
119
+ }
120
+ //#endregion
121
+ exports.PublishModeConflict = PublishModeConflict;
122
+ exports.publish = publish;
123
+
124
+ //# sourceMappingURL=publish-CPgSbtcs.cjs.map