@geekmidas/cli 10.0.0-alpha.19 → 10.0.0-alpha.190

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 (436) hide show
  1. package/README.md +323 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-CBKH87_b.mjs +1043 -0
  7. package/dist/EndpointGenerator-CBKH87_b.mjs.map +1 -0
  8. package/dist/EndpointGenerator-iyA3HkOH.cjs +1102 -0
  9. package/dist/EndpointGenerator-iyA3HkOH.cjs.map +1 -0
  10. package/dist/LegacyStateStore-CWiswz6T.mjs +124 -0
  11. package/dist/LegacyStateStore-CWiswz6T.mjs.map +1 -0
  12. package/dist/LegacyStateStore-CuSe37fl.cjs +124 -0
  13. package/dist/LegacyStateStore-CuSe37fl.cjs.map +1 -0
  14. package/dist/LocalStateStore-BciJ_DF0.cjs +178 -0
  15. package/dist/LocalStateStore-BciJ_DF0.cjs.map +1 -0
  16. package/dist/LocalStateStore-CLHasLJI.mjs +167 -0
  17. package/dist/LocalStateStore-CLHasLJI.mjs.map +1 -0
  18. package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs +534 -0
  19. package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs.map +1 -0
  20. package/dist/OpenApiTsGenerator-vy-fOJgs.cjs +539 -0
  21. package/dist/OpenApiTsGenerator-vy-fOJgs.cjs.map +1 -0
  22. package/dist/S3StateStore-BHLRjoj3.cjs +222 -0
  23. package/dist/S3StateStore-BHLRjoj3.cjs.map +1 -0
  24. package/dist/S3StateStore-CTiv2_ON.mjs +223 -0
  25. package/dist/S3StateStore-CTiv2_ON.mjs.map +1 -0
  26. package/dist/SSMStateStore-BqT3MXXb.cjs +204 -0
  27. package/dist/SSMStateStore-BqT3MXXb.cjs.map +1 -0
  28. package/dist/SSMStateStore-D6qqaem2.mjs +205 -0
  29. package/dist/SSMStateStore-D6qqaem2.mjs.map +1 -0
  30. package/dist/SubscriberGenerator-Cfoz8uTY.mjs +787 -0
  31. package/dist/SubscriberGenerator-Cfoz8uTY.mjs.map +1 -0
  32. package/dist/SubscriberGenerator-CxzECrfj.cjs +852 -0
  33. package/dist/SubscriberGenerator-CxzECrfj.cjs.map +1 -0
  34. package/dist/add-B2OmIQzs.cjs +712 -0
  35. package/dist/add-B2OmIQzs.cjs.map +1 -0
  36. package/dist/add-CXwL549o.mjs +710 -0
  37. package/dist/add-CXwL549o.mjs.map +1 -0
  38. package/dist/appPorts-BoXMwolc.mjs +249 -0
  39. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  40. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  41. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  42. package/dist/aws-BXfiWNbi.cjs +108 -0
  43. package/dist/aws-BXfiWNbi.cjs.map +1 -0
  44. package/dist/aws-BjvSTTcE.mjs +97 -0
  45. package/dist/aws-BjvSTTcE.mjs.map +1 -0
  46. package/dist/awsStore-BYYCmXiq.mjs +121 -0
  47. package/dist/awsStore-BYYCmXiq.mjs.map +1 -0
  48. package/dist/awsStore-DKQUElJL.cjs +138 -0
  49. package/dist/awsStore-DKQUElJL.cjs.map +1 -0
  50. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  51. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  52. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  53. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  54. package/dist/backups/runner.cjs +1007 -0
  55. package/dist/backups/runner.cjs.map +1 -0
  56. package/dist/backups/runner.d.cts +187 -0
  57. package/dist/backups/runner.d.cts.map +1 -0
  58. package/dist/backups/runner.d.mts +187 -0
  59. package/dist/backups/runner.d.mts.map +1 -0
  60. package/dist/backups/runner.mjs +984 -0
  61. package/dist/backups/runner.mjs.map +1 -0
  62. package/dist/{bundler-mwH7WOb1.mjs → bundler-CHXyJFsS.mjs} +68 -15
  63. package/dist/bundler-CHXyJFsS.mjs.map +1 -0
  64. package/dist/{bundler-mjqGAvu1.cjs → bundler-CLoVtcBi.cjs} +67 -14
  65. package/dist/bundler-CLoVtcBi.cjs.map +1 -0
  66. package/dist/cli-Bjua3PaZ.mjs +80 -0
  67. package/dist/cli-Bjua3PaZ.mjs.map +1 -0
  68. package/dist/cli-DiuUr1Am.cjs +80 -0
  69. package/dist/cli-DiuUr1Am.cjs.map +1 -0
  70. package/dist/clientTelemetry-DXuYNH-J.d.cts +10 -0
  71. package/dist/clientTelemetry-DXuYNH-J.d.cts.map +1 -0
  72. package/dist/clientTelemetry-eC8VQ6nB.d.mts +10 -0
  73. package/dist/clientTelemetry-eC8VQ6nB.d.mts.map +1 -0
  74. package/dist/compose-DUOETDhc.mjs +2855 -0
  75. package/dist/compose-DUOETDhc.mjs.map +1 -0
  76. package/dist/compose-gnNrY3NQ.cjs +2939 -0
  77. package/dist/compose-gnNrY3NQ.cjs.map +1 -0
  78. package/dist/config-1zirYXeO.d.mts +300 -0
  79. package/dist/config-1zirYXeO.d.mts.map +1 -0
  80. package/dist/config-rSlB-bXj.d.cts +300 -0
  81. package/dist/config-rSlB-bXj.d.cts.map +1 -0
  82. package/dist/config.cjs +462 -9
  83. package/dist/config.cjs.map +1 -0
  84. package/dist/config.d.cts +4 -117
  85. package/dist/config.d.mts +4 -117
  86. package/dist/config.mjs +446 -3
  87. package/dist/config.mjs.map +1 -0
  88. package/dist/credentialSchemas-D_85KW2k.mjs +236 -0
  89. package/dist/credentialSchemas-D_85KW2k.mjs.map +1 -0
  90. package/dist/credentialSchemas-DjK6xKMk.cjs +271 -0
  91. package/dist/credentialSchemas-DjK6xKMk.cjs.map +1 -0
  92. package/dist/credentials-BI52H1ad.cjs +2911 -0
  93. package/dist/credentials-BI52H1ad.cjs.map +1 -0
  94. package/dist/credentials-Cp09PIsc.cjs +1451 -0
  95. package/dist/credentials-Cp09PIsc.cjs.map +1 -0
  96. package/dist/credentials-DbjLhvix.mjs +1140 -0
  97. package/dist/credentials-DbjLhvix.mjs.map +1 -0
  98. package/dist/credentials-VLP_959f.mjs +2390 -0
  99. package/dist/credentials-VLP_959f.mjs.map +1 -0
  100. package/dist/databases-CV22HzrI.mjs +588 -0
  101. package/dist/databases-CV22HzrI.mjs.map +1 -0
  102. package/dist/databases-DwYYH2mX.cjs +703 -0
  103. package/dist/databases-DwYYH2mX.cjs.map +1 -0
  104. package/dist/dbTunnel-CLsqWr7o.mjs +153 -0
  105. package/dist/dbTunnel-CLsqWr7o.mjs.map +1 -0
  106. package/dist/dbTunnel-DQcdaaLi.cjs +153 -0
  107. package/dist/dbTunnel-DQcdaaLi.cjs.map +1 -0
  108. package/dist/define-BfrNaY82.mjs +106 -0
  109. package/dist/define-BfrNaY82.mjs.map +1 -0
  110. package/dist/define-zKgLY65H.cjs +153 -0
  111. package/dist/define-zKgLY65H.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +210 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +659 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +659 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +143 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  121. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  122. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  123. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  124. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  125. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  126. package/dist/deploy/sniffer-hooks.cjs +1 -1
  127. package/dist/deploy/sniffer-hooks.mjs +1 -1
  128. package/dist/deploy/sniffer-loader.cjs +2 -2
  129. package/dist/deploy/sniffer-loader.mjs +1 -1
  130. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  131. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  132. package/dist/deploy-DhIy2Ftj.mjs +3854 -0
  133. package/dist/deploy-DhIy2Ftj.mjs.map +1 -0
  134. package/dist/deploy-DpQ_4Pu1.cjs +3910 -0
  135. package/dist/deploy-DpQ_4Pu1.cjs.map +1 -0
  136. package/dist/destroy-DmTDT6V7.cjs +791 -0
  137. package/dist/destroy-DmTDT6V7.cjs.map +1 -0
  138. package/dist/destroy-wV9yNLQV.mjs +790 -0
  139. package/dist/destroy-wV9yNLQV.mjs.map +1 -0
  140. package/dist/discover-Dfmn6HQ7.mjs +940 -0
  141. package/dist/discover-Dfmn6HQ7.mjs.map +1 -0
  142. package/dist/discover-OXczlq08.cjs +1085 -0
  143. package/dist/discover-OXczlq08.cjs.map +1 -0
  144. package/dist/dokploy-B61ww4Yb.cjs +38 -0
  145. package/dist/dokploy-B61ww4Yb.cjs.map +1 -0
  146. package/dist/dokploy-Jhl3sPd4.mjs +38 -0
  147. package/dist/dokploy-Jhl3sPd4.mjs.map +1 -0
  148. package/dist/drivers-BQRb3KsL.mjs +294 -0
  149. package/dist/drivers-BQRb3KsL.mjs.map +1 -0
  150. package/dist/drivers-DP7__dJX.cjs +377 -0
  151. package/dist/drivers-DP7__dJX.cjs.map +1 -0
  152. package/dist/eas-BmvO40xS.mjs +334 -0
  153. package/dist/eas-BmvO40xS.mjs.map +1 -0
  154. package/dist/eas-X09Gz8_E.cjs +337 -0
  155. package/dist/eas-X09Gz8_E.cjs.map +1 -0
  156. package/dist/emit-C4KSXOeS.mjs +153 -0
  157. package/dist/emit-C4KSXOeS.mjs.map +1 -0
  158. package/dist/emit-DiW0kbue.cjs +164 -0
  159. package/dist/emit-DiW0kbue.cjs.map +1 -0
  160. package/dist/encryption-BBIUewnL.cjs +90 -0
  161. package/dist/encryption-BBIUewnL.cjs.map +1 -0
  162. package/dist/encryption-BOmswIgE.mjs +89 -0
  163. package/dist/encryption-BOmswIgE.mjs.map +1 -0
  164. package/dist/engine-BhjhShKf.cjs +3333 -0
  165. package/dist/engine-BhjhShKf.cjs.map +1 -0
  166. package/dist/engine-DW2H3KNa.mjs +3220 -0
  167. package/dist/engine-DW2H3KNa.mjs.map +1 -0
  168. package/dist/errors-C9uIyIDt.mjs +27 -0
  169. package/dist/errors-C9uIyIDt.mjs.map +1 -0
  170. package/dist/errors-D1x8duqI.cjs +38 -0
  171. package/dist/errors-D1x8duqI.cjs.map +1 -0
  172. package/dist/github-Ptbigbrq.mjs +986 -0
  173. package/dist/github-Ptbigbrq.mjs.map +1 -0
  174. package/dist/github-xUtu4Ur7.cjs +987 -0
  175. package/dist/github-xUtu4Ur7.cjs.map +1 -0
  176. package/dist/googlePlay-B4xhz5xT.cjs +931 -0
  177. package/dist/googlePlay-B4xhz5xT.cjs.map +1 -0
  178. package/dist/googlePlay-C9rrwN5b.mjs +931 -0
  179. package/dist/googlePlay-C9rrwN5b.mjs.map +1 -0
  180. package/dist/iam-D7mXd6by.cjs +521 -0
  181. package/dist/iam-D7mXd6by.cjs.map +1 -0
  182. package/dist/iam-DNlbVN_l.mjs +442 -0
  183. package/dist/iam-DNlbVN_l.mjs.map +1 -0
  184. package/dist/{index-RCUizGxL.d.cts → index-B1gfXH5K.d.mts} +38 -14
  185. package/dist/index-B1gfXH5K.d.mts.map +1 -0
  186. package/dist/{index-B4H4XF7A.d.mts → index-CunkOPOu.d.cts} +38 -14
  187. package/dist/index-CunkOPOu.d.cts.map +1 -0
  188. package/dist/index.cjs +15566 -13457
  189. package/dist/index.cjs.map +1 -1
  190. package/dist/index.mjs +15249 -13138
  191. package/dist/index.mjs.map +1 -1
  192. package/dist/local-CvC-z86k.mjs +224 -0
  193. package/dist/local-CvC-z86k.mjs.map +1 -0
  194. package/dist/local-DAJrhvSC.cjs +241 -0
  195. package/dist/local-DAJrhvSC.cjs.map +1 -0
  196. package/dist/migrate-0-A4BOcd.cjs +272 -0
  197. package/dist/migrate-0-A4BOcd.cjs.map +1 -0
  198. package/dist/migrate-C_36JSwV.mjs +181 -0
  199. package/dist/migrate-C_36JSwV.mjs.map +1 -0
  200. package/dist/migrate-DHbXzZIJ.mjs +267 -0
  201. package/dist/migrate-DHbXzZIJ.mjs.map +1 -0
  202. package/dist/migrate-fGWfv2DV.cjs +181 -0
  203. package/dist/migrate-fGWfv2DV.cjs.map +1 -0
  204. package/dist/next.cjs +59 -0
  205. package/dist/next.cjs.map +1 -0
  206. package/dist/next.d.cts +44 -0
  207. package/dist/next.d.cts.map +1 -0
  208. package/dist/next.d.mts +44 -0
  209. package/dist/next.d.mts.map +1 -0
  210. package/dist/next.mjs +58 -0
  211. package/dist/next.mjs.map +1 -0
  212. package/dist/openapi.cjs +213 -7
  213. package/dist/openapi.cjs.map +1 -0
  214. package/dist/openapi.d.cts +27 -8
  215. package/dist/openapi.d.cts.map +1 -1
  216. package/dist/openapi.d.mts +27 -8
  217. package/dist/openapi.d.mts.map +1 -1
  218. package/dist/openapi.mjs +208 -2
  219. package/dist/openapi.mjs.map +1 -0
  220. package/dist/projectBucket-BAoFOQtA.cjs +263 -0
  221. package/dist/projectBucket-BAoFOQtA.cjs.map +1 -0
  222. package/dist/projectBucket-Dxub09V1.mjs +222 -0
  223. package/dist/projectBucket-Dxub09V1.mjs.map +1 -0
  224. package/dist/provider-BvjDbsTR.mjs +46 -0
  225. package/dist/provider-BvjDbsTR.mjs.map +1 -0
  226. package/dist/provider-DLhgo-mB.cjs +57 -0
  227. package/dist/provider-DLhgo-mB.cjs.map +1 -0
  228. package/dist/publish-BX8_zXaf.cjs +124 -0
  229. package/dist/publish-BX8_zXaf.cjs.map +1 -0
  230. package/dist/publish-DE_yBzlz.mjs +123 -0
  231. package/dist/publish-DE_yBzlz.mjs.map +1 -0
  232. package/dist/ready-DCvnFZnJ.cjs +404 -0
  233. package/dist/ready-DCvnFZnJ.cjs.map +1 -0
  234. package/dist/ready-sSPuiZ7N.mjs +375 -0
  235. package/dist/ready-sSPuiZ7N.mjs.map +1 -0
  236. package/dist/reconcile/public.cjs +3 -5
  237. package/dist/reconcile/public.d.cts +33 -89
  238. package/dist/reconcile/public.d.cts.map +1 -1
  239. package/dist/reconcile/public.d.mts +33 -89
  240. package/dist/reconcile/public.d.mts.map +1 -1
  241. package/dist/reconcile/public.mjs +3 -3
  242. package/dist/reconcile--I7V4Klj.mjs +34 -0
  243. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  244. package/dist/reconcile-CuCQBa5-.cjs +34 -0
  245. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  246. package/dist/resolve-CPB2jkB4.cjs +316 -0
  247. package/dist/resolve-CPB2jkB4.cjs.map +1 -0
  248. package/dist/resolve-DCPtP7-X.mjs +263 -0
  249. package/dist/resolve-DCPtP7-X.mjs.map +1 -0
  250. package/dist/rollback-sefKrjlE.mjs +137 -0
  251. package/dist/rollback-sefKrjlE.mjs.map +1 -0
  252. package/dist/rollback-ygh2qRWo.cjs +166 -0
  253. package/dist/rollback-ygh2qRWo.cjs.map +1 -0
  254. package/dist/runtime-BwiWhqkI.d.cts +82 -0
  255. package/dist/runtime-BwiWhqkI.d.cts.map +1 -0
  256. package/dist/runtime-Dx5F8-IL.d.mts +82 -0
  257. package/dist/runtime-Dx5F8-IL.d.mts.map +1 -0
  258. package/dist/s3-Bcvbg8io.cjs +240 -0
  259. package/dist/s3-Bcvbg8io.cjs.map +1 -0
  260. package/dist/s3-DK1ofU4f.mjs +240 -0
  261. package/dist/s3-DK1ofU4f.mjs.map +1 -0
  262. package/dist/sandbox/config-worker.cjs +43 -0
  263. package/dist/sandbox/config-worker.cjs.map +1 -0
  264. package/dist/sandbox/config-worker.d.cts +1 -0
  265. package/dist/sandbox/config-worker.d.mts +1 -0
  266. package/dist/sandbox/config-worker.mjs +44 -0
  267. package/dist/sandbox/config-worker.mjs.map +1 -0
  268. package/dist/sandbox/credentials-worker.cjs +53 -0
  269. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  270. package/dist/sandbox/credentials-worker.d.cts +1 -0
  271. package/dist/sandbox/credentials-worker.d.mts +1 -0
  272. package/dist/sandbox/credentials-worker.mjs +54 -0
  273. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  274. package/dist/sandbox/discover-worker.cjs +47 -0
  275. package/dist/sandbox/discover-worker.cjs.map +1 -0
  276. package/dist/sandbox/discover-worker.d.cts +1 -0
  277. package/dist/sandbox/discover-worker.d.mts +1 -0
  278. package/dist/sandbox/discover-worker.mjs +48 -0
  279. package/dist/sandbox/discover-worker.mjs.map +1 -0
  280. package/dist/sandbox/migrate-worker.cjs +75 -0
  281. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  282. package/dist/sandbox/migrate-worker.d.cts +1 -0
  283. package/dist/sandbox/migrate-worker.d.mts +1 -0
  284. package/dist/sandbox/migrate-worker.mjs +76 -0
  285. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  286. package/dist/{workspace-CRD9YinV.cjs → schemas-BCwKKA42.mjs} +399 -1179
  287. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  288. package/dist/{workspace-Bu3xNCej.mjs → schemas-BQ_v0lEX.cjs} +487 -982
  289. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  290. package/dist/secretsManager-CjTo6CRq.mjs +113 -0
  291. package/dist/secretsManager-CjTo6CRq.mjs.map +1 -0
  292. package/dist/secretsManager-CvmBGjdM.cjs +124 -0
  293. package/dist/secretsManager-CvmBGjdM.cjs.map +1 -0
  294. package/dist/seeds-Bc3niNVb.cjs +382 -0
  295. package/dist/seeds-Bc3niNVb.cjs.map +1 -0
  296. package/dist/seeds-Ccn0Ru2T.mjs +299 -0
  297. package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
  298. package/dist/serverSetup-ClU2iSeU.cjs +686 -0
  299. package/dist/serverSetup-ClU2iSeU.cjs.map +1 -0
  300. package/dist/serverSetup-D68Otrp0.mjs +686 -0
  301. package/dist/serverSetup-D68Otrp0.mjs.map +1 -0
  302. package/dist/sniffer-CFOmQQit.cjs +1997 -0
  303. package/dist/sniffer-CFOmQQit.cjs.map +1 -0
  304. package/dist/sniffer-CRF3eD_B.mjs +1824 -0
  305. package/dist/sniffer-CRF3eD_B.mjs.map +1 -0
  306. package/dist/snsSubscriptions-CwA6Ceg2.mjs +1024 -0
  307. package/dist/snsSubscriptions-CwA6Ceg2.mjs.map +1 -0
  308. package/dist/snsSubscriptions-S_CMCXqI.cjs +1149 -0
  309. package/dist/snsSubscriptions-S_CMCXqI.cjs.map +1 -0
  310. package/dist/sst-BgG7dJJu.cjs +514 -0
  311. package/dist/sst-BgG7dJJu.cjs.map +1 -0
  312. package/dist/sst-CDnHFO3U.mjs +491 -0
  313. package/dist/sst-CDnHFO3U.mjs.map +1 -0
  314. package/dist/stack-BXmLQf3K.mjs +10920 -0
  315. package/dist/stack-BXmLQf3K.mjs.map +1 -0
  316. package/dist/stack-BtnflNSa.cjs +11901 -0
  317. package/dist/stack-BtnflNSa.cjs.map +1 -0
  318. package/dist/stage-BbQidxxa.mjs +302 -0
  319. package/dist/stage-BbQidxxa.mjs.map +1 -0
  320. package/dist/stage-ssuPXLhP.cjs +331 -0
  321. package/dist/stage-ssuPXLhP.cjs.map +1 -0
  322. package/dist/stages-CQwD2QxS.cjs +190 -0
  323. package/dist/stages-CQwD2QxS.cjs.map +1 -0
  324. package/dist/stages-MA2sXnX4.mjs +190 -0
  325. package/dist/stages-MA2sXnX4.mjs.map +1 -0
  326. package/dist/target/public.cjs +15 -0
  327. package/dist/target/public.d.cts +28 -0
  328. package/dist/target/public.d.cts.map +1 -0
  329. package/dist/target/public.d.mts +28 -0
  330. package/dist/target/public.d.mts.map +1 -0
  331. package/dist/target/public.mjs +4 -0
  332. package/dist/terminal-BEGE1AEV.mjs +85 -0
  333. package/dist/terminal-BEGE1AEV.mjs.map +1 -0
  334. package/dist/terminal-BecJpgA3.cjs +85 -0
  335. package/dist/terminal-BecJpgA3.cjs.map +1 -0
  336. package/dist/{types-7R81hu0i.d.mts → types-BvokH0ya.d.cts} +2235 -459
  337. package/dist/types-BvokH0ya.d.cts.map +1 -0
  338. package/dist/{types-N7c2O2m7.d.cts → types-DmLnGeii.d.mts} +2233 -459
  339. package/dist/types-DmLnGeii.d.mts.map +1 -0
  340. package/dist/utils-CdKxD8Lt.mjs +156 -0
  341. package/dist/utils-CdKxD8Lt.mjs.map +1 -0
  342. package/dist/utils-DBqXbB8P.cjs +205 -0
  343. package/dist/utils-DBqXbB8P.cjs.map +1 -0
  344. package/dist/vitest.cjs +65 -0
  345. package/dist/vitest.cjs.map +1 -0
  346. package/dist/vitest.d.cts +29 -0
  347. package/dist/vitest.d.cts.map +1 -0
  348. package/dist/vitest.d.mts +29 -0
  349. package/dist/vitest.d.mts.map +1 -0
  350. package/dist/vitest.mjs +65 -0
  351. package/dist/vitest.mjs.map +1 -0
  352. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  353. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  354. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  355. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  356. package/dist/workspace/index.cjs +6 -2
  357. package/dist/workspace/index.d.cts +3 -3
  358. package/dist/workspace/index.d.mts +3 -3
  359. package/dist/workspace/index.mjs +2 -2
  360. package/dist/workspace-DEmfa9RO.cjs +3689 -0
  361. package/dist/workspace-DEmfa9RO.cjs.map +1 -0
  362. package/dist/workspace-RgU7TBgg.mjs +3133 -0
  363. package/dist/workspace-RgU7TBgg.mjs.map +1 -0
  364. package/package.json +76 -13
  365. package/dist/HostingerProvider-BY26bWwB.mjs +0 -243
  366. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  367. package/dist/HostingerProvider-BZFGYYVA.cjs +0 -243
  368. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  369. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  370. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  371. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  372. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  373. package/dist/Route53Provider-Cvj40A8I.mjs +0 -209
  374. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  375. package/dist/Route53Provider-DVILBsvV.cjs +0 -209
  376. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  377. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  378. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  379. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  380. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  381. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  382. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  383. package/dist/bundler-mjqGAvu1.cjs.map +0 -1
  384. package/dist/bundler-mwH7WOb1.mjs.map +0 -1
  385. package/dist/config-DSXI480r.cjs +0 -467
  386. package/dist/config-DSXI480r.cjs.map +0 -1
  387. package/dist/config-DdKkoUE1.mjs +0 -414
  388. package/dist/config-DdKkoUE1.mjs.map +0 -1
  389. package/dist/config.d.cts.map +0 -1
  390. package/dist/config.d.mts.map +0 -1
  391. package/dist/credentials-C6Pfn6GY.cjs +0 -2939
  392. package/dist/credentials-C6Pfn6GY.cjs.map +0 -1
  393. package/dist/credentials-lbv-j0Be.mjs +0 -2802
  394. package/dist/credentials-lbv-j0Be.mjs.map +0 -1
  395. package/dist/discover-BERGFg8v.cjs +0 -288
  396. package/dist/discover-BERGFg8v.cjs.map +0 -1
  397. package/dist/discover-CK-n3w6b.mjs +0 -244
  398. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  399. package/dist/emit-BdoPFjZf.cjs +0 -253
  400. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  401. package/dist/emit-Bzq7JsMP.mjs +0 -224
  402. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  403. package/dist/generator-LfZU7NlU.mjs +0 -247
  404. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  405. package/dist/generator-Wdfp0jCS.cjs +0 -282
  406. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  407. package/dist/github-BvfpvBcW.cjs +0 -216
  408. package/dist/github-BvfpvBcW.cjs.map +0 -1
  409. package/dist/github-DW3CP-4D.mjs +0 -216
  410. package/dist/github-DW3CP-4D.mjs.map +0 -1
  411. package/dist/index-B4H4XF7A.d.mts.map +0 -1
  412. package/dist/index-RCUizGxL.d.cts.map +0 -1
  413. package/dist/openapi-B8bu_OXN.cjs +0 -2038
  414. package/dist/openapi-B8bu_OXN.cjs.map +0 -1
  415. package/dist/openapi-DfjbhrsM.mjs +0 -1991
  416. package/dist/openapi-DfjbhrsM.mjs.map +0 -1
  417. package/dist/reconcile-gb1lz1Dk.mjs +0 -113
  418. package/dist/reconcile-gb1lz1Dk.mjs.map +0 -1
  419. package/dist/reconcile-hx_vBvux.cjs +0 -136
  420. package/dist/reconcile-hx_vBvux.cjs.map +0 -1
  421. package/dist/ssm-BKN1Cg4z.mjs +0 -60
  422. package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
  423. package/dist/ssm-FxeSAt35.cjs +0 -60
  424. package/dist/ssm-FxeSAt35.cjs.map +0 -1
  425. package/dist/storage-DgypfSD6.cjs +0 -351
  426. package/dist/storage-DgypfSD6.cjs.map +0 -1
  427. package/dist/storage-TP0x118M.mjs +0 -304
  428. package/dist/storage-TP0x118M.mjs.map +0 -1
  429. package/dist/transfer-DjFZRgub.mjs +0 -122
  430. package/dist/transfer-DjFZRgub.mjs.map +0 -1
  431. package/dist/transfer-SeiSeKEF.cjs +0 -151
  432. package/dist/transfer-SeiSeKEF.cjs.map +0 -1
  433. package/dist/types-7R81hu0i.d.mts.map +0 -1
  434. package/dist/types-N7c2O2m7.d.cts.map +0 -1
  435. package/dist/workspace-Bu3xNCej.mjs.map +0 -1
  436. package/dist/workspace-CRD9YinV.cjs.map +0 -1
@@ -0,0 +1,986 @@
1
+ import { t as GkmError } from "./errors-C9uIyIDt.mjs";
2
+ import { A as deployIdentity, C as getKeyPath, E as keystoreProject, O as readKey, c as isRemoteStore, l as secretsStoreFor } from "./credentials-DbjLhvix.mjs";
3
+ import { Hn as stageBackups, jt as constructGlobs } from "./stack-BXmLQf3K.mjs";
4
+ import { J as inboxBucketId, N as assertDeployedStage, Nt as s3SecretsKey, Pt as s3SecretsLocation, U as stageProvider, Y as inboxTopicName, nt as bucketName, q as emailUserName, rt as iamUserName, tt as IAM_USER_PATH } from "./workspace-RgU7TBgg.mjs";
5
+ import { i as discover } from "./discover-Dfmn6HQ7.mjs";
6
+ import { loadWorkspaceConfig } from "./config.mjs";
7
+ import { l as backupsUserName } from "./deploy-DhIy2Ftj.mjs";
8
+ import { b as stageDnsDomains } from "./snsSubscriptions-CwA6Ceg2.mjs";
9
+ import { n as PROJECT_BUCKET_LIFECYCLE_ACTIONS, o as projectBucketName, t as PROJECT_BUCKET_CREATE_ACTIONS } from "./projectBucket-Dxub09V1.mjs";
10
+ import { n as secretsParameterName } from "./aws-BjvSTTcE.mjs";
11
+ import { t as secretsManagerSecretName } from "./secretsManager-CjTo6CRq.mjs";
12
+ import { execFileSync } from "node:child_process";
13
+ import { AttachRolePolicyCommand, CreateOpenIDConnectProviderCommand, CreateRoleCommand, DeleteRolePolicyCommand, DetachRolePolicyCommand, GetRoleCommand, IAMClient, ListAttachedRolePoliciesCommand, ListOpenIDConnectProvidersCommand, ListRoleTagsCommand, PutRolePolicyCommand, TagRoleCommand, UntagRoleCommand, UpdateAssumeRolePolicyCommand } from "@aws-sdk/client-iam";
14
+ //#region src/deploy/githubOidc.ts
15
+ /**
16
+ * The `sub` GitHub puts in a deploy job's OIDC token — what the deploy role's
17
+ * trust policy has to match exactly.
18
+ *
19
+ * It is not always `repo:<owner>/<name>:environment:<stage>`. A repository
20
+ * (or its organisation) decides the format, and says which through
21
+ * `GET /repos/{owner}/{repo}/actions/oidc/customization/sub`:
22
+ *
23
+ * - the default: `repo:<owner>/<name>:environment:<stage>`;
24
+ * - the immutable subject — the default for repositories created after
25
+ * 15 July 2026, opt-in before — puts the owner's and the repository's ids in
26
+ * the `repo` segment: `repo:<owner>@<ownerId>/<name>@<repoId>:environment:<stage>`.
27
+ * The API hands that segment back as `sub_claim_prefix`;
28
+ * - a custom template (`use_default: false`) builds the `sub` from
29
+ * `include_claim_keys`, in order, each as `<key>:<value>` joined by `:`,
30
+ * where `context` is `environment:<stage>` in an environment job.
31
+ *
32
+ * A `:` inside a value is sent as `%3A`.
33
+ *
34
+ * See https://docs.github.com/en/actions/reference/security/oidc.
35
+ */
36
+ /**
37
+ * Template keys whose values are known for a repository's environment job
38
+ * before the job runs. Anything else — `job_workflow_ref`, `ref`, `sha`,
39
+ * `run_id`, `workflow`, `actor`, a custom property — depends on the run.
40
+ */
41
+ const SUPPORTED_CLAIM_KEYS = [
42
+ "repo",
43
+ "context",
44
+ "environment",
45
+ "repository",
46
+ "repository_owner",
47
+ "repository_owner_id",
48
+ "repository_id",
49
+ "repository_visibility"
50
+ ];
51
+ const NEEDS_FACTS = /* @__PURE__ */ new Set([
52
+ "repository_owner_id",
53
+ "repository_id",
54
+ "repository_visibility"
55
+ ]);
56
+ /** A `:` inside a claim value is sent as `%3A`. */
57
+ function claim(value) {
58
+ return value.replaceAll(":", "%3A");
59
+ }
60
+ /** Whether {@link oidcSubject} needs the repository's ids or visibility. */
61
+ function needsRepoFacts(customization) {
62
+ const immutableWithoutPrefix = customization.use_immutable_subject === true && !customization.sub_claim_prefix;
63
+ if (customization.use_default) return immutableWithoutPrefix;
64
+ return (customization.include_claim_keys ?? []).some((key) => NEEDS_FACTS.has(key) || key === "repo" && immutableWithoutPrefix);
65
+ }
66
+ /**
67
+ * The exact `sub` of a job in `repo`'s `stage` environment.
68
+ *
69
+ * @throws OidcSubjectNotSupported when a custom template includes a claim
70
+ * whose value depends on the run, so no one subject can be trusted.
71
+ */
72
+ function oidcSubject(repo, stage, customization, facts) {
73
+ const [owner = "", name = ""] = repo.split("/");
74
+ const environment = `environment:${claim(stage)}`;
75
+ const repoSegment = () => {
76
+ if (customization.sub_claim_prefix) return customization.sub_claim_prefix;
77
+ if (customization.use_immutable_subject) {
78
+ if (!facts) throw new RepoFactsRequired(repo);
79
+ return `repo:${owner}@${facts.ownerId}/${name}@${facts.repoId}`;
80
+ }
81
+ return `repo:${repo}`;
82
+ };
83
+ const immutable = customization.use_immutable_subject === true || customization.sub_claim_prefix !== void 0;
84
+ if (customization.use_default) return {
85
+ subject: `${repoSegment()}:${environment}`,
86
+ kind: immutable ? "immutable" : "default"
87
+ };
88
+ const keys = customization.include_claim_keys ?? [];
89
+ const unsupported = keys.filter((key) => !SUPPORTED_CLAIM_KEYS.includes(key));
90
+ if (keys.length === 0 || unsupported.length > 0) throw new OidcSubjectNotSupported(repo, keys, unsupported);
91
+ if (keys.some((key) => NEEDS_FACTS.has(key)) && !facts) throw new RepoFactsRequired(repo);
92
+ return {
93
+ subject: keys.map((key) => {
94
+ switch (key) {
95
+ case "repo": return repoSegment();
96
+ case "context":
97
+ case "environment": return environment;
98
+ case "repository": return `repository:${claim(repo)}`;
99
+ case "repository_owner": return `repository_owner:${claim(owner)}`;
100
+ case "repository_owner_id": return `repository_owner_id:${facts.ownerId}`;
101
+ case "repository_id": return `repository_id:${facts.repoId}`;
102
+ default: return `repository_visibility:${claim(facts.visibility)}`;
103
+ }
104
+ }).join(":"),
105
+ kind: "custom"
106
+ };
107
+ }
108
+ /** The endpoint a repository's subject format is read from. */
109
+ function customizationEndpoint(repo) {
110
+ return `repos/${repo}/actions/oidc/customization/sub`;
111
+ }
112
+ /**
113
+ * The `sub` GitHub will send for `repo`'s `stage` environment, read from the
114
+ * repository's OIDC settings through `gh`.
115
+ *
116
+ * A repository on a custom template that names no keys of its own uses its
117
+ * organisation's, read from `orgs/{owner}/actions/oidc/customization/sub`.
118
+ * When the settings cannot be read at all — no permission, or a GitHub
119
+ * Enterprise Server without the endpoint — the default format is assumed, with
120
+ * a warning saying where to check it.
121
+ */
122
+ function resolveOidcSubject(gh, repo, stage) {
123
+ const endpoint = customizationEndpoint(repo);
124
+ let customization;
125
+ try {
126
+ customization = JSON.parse(gh(["api", endpoint]));
127
+ } catch {
128
+ return {
129
+ subject: `repo:${repo}:environment:${claim(stage)}`,
130
+ kind: "assumed",
131
+ warning: `Could not read ${endpoint}, so the default subject format is assumed. Check it with: gh api ${endpoint} — a repository on the immutable subject or a custom template sends a different sub, and the role would not be assumable.`
132
+ };
133
+ }
134
+ if (!customization.use_default && (customization.include_claim_keys ?? []).length === 0) {
135
+ const [owner = ""] = repo.split("/");
136
+ const orgEndpoint = `orgs/${owner}/actions/oidc/customization/sub`;
137
+ let org;
138
+ try {
139
+ org = JSON.parse(gh(["api", orgEndpoint]));
140
+ } catch {
141
+ throw new OrgOidcTemplateUnreadable(repo, orgEndpoint);
142
+ }
143
+ customization = {
144
+ ...customization,
145
+ include_claim_keys: org.include_claim_keys ?? [],
146
+ use_immutable_subject: customization.use_immutable_subject ?? org.use_immutable_subject
147
+ };
148
+ }
149
+ const facts = needsRepoFacts(customization) ? readRepoFacts(gh, repo) : void 0;
150
+ return oidcSubject(repo, stage, customization, facts);
151
+ }
152
+ function readRepoFacts(gh, repo) {
153
+ const raw = JSON.parse(gh(["api", `repos/${repo}`]));
154
+ return {
155
+ ownerId: raw.owner.id,
156
+ repoId: raw.id,
157
+ visibility: raw.visibility
158
+ };
159
+ }
160
+ /**
161
+ * The repository's custom subject template includes a claim whose value
162
+ * depends on the run — or names none — so no one subject can be trusted.
163
+ */
164
+ var OidcSubjectNotSupported = class extends GkmError {
165
+ repo;
166
+ includeClaimKeys;
167
+ unsupportedKeys;
168
+ constructor(repo, includeClaimKeys, unsupportedKeys) {
169
+ super(`${repo} builds its OIDC subject from a custom template, ${JSON.stringify(includeClaimKeys)}, and ${unsupportedKeys.length > 0 ? `${unsupportedKeys.join(", ")} depend${unsupportedKeys.length === 1 ? "s" : ""} on the run` : "it names no claims"}, so the deploy role cannot trust one exact subject. Set the repository back to the default subject — gh api --method PUT ${customizationEndpoint(repo)} -F use_default=true — (or keep the immutable one by also passing -F use_immutable_subject=true), or use a template built only from ${SUPPORTED_CLAIM_KEYS.join(", ")}; then run this again.`);
170
+ this.repo = repo;
171
+ this.includeClaimKeys = includeClaimKeys;
172
+ this.unsupportedKeys = unsupportedKeys;
173
+ this.name = "OidcSubjectNotSupported";
174
+ }
175
+ };
176
+ /** The subject needs the repository's ids, and none were read. */
177
+ var RepoFactsRequired = class extends GkmError {
178
+ repo;
179
+ constructor(repo) {
180
+ super(`The OIDC subject of ${repo} includes its owner and repository ids; read them with gh api repos/${repo} and pass them in.`);
181
+ this.repo = repo;
182
+ this.name = "RepoFactsRequired";
183
+ }
184
+ };
185
+ /**
186
+ * The repository uses its organisation's subject template, and that template
187
+ * could not be read — so what GitHub sends is unknown, and is not guessed.
188
+ */
189
+ var OrgOidcTemplateUnreadable = class extends GkmError {
190
+ repo;
191
+ endpoint;
192
+ constructor(repo, endpoint) {
193
+ super(`${repo} uses its organisation's OIDC subject template, and ${endpoint} could not be read. Run this as an organisation owner (gh auth refresh -s admin:org), or set the repository back to the default subject with gh api --method PUT ${customizationEndpoint(repo)} -F use_default=true; then run this again.`);
194
+ this.repo = repo;
195
+ this.endpoint = endpoint;
196
+ this.name = "OrgOidcTemplateUnreadable";
197
+ }
198
+ };
199
+ //#endregion
200
+ //#region src/deploy/githubPolicy.ts
201
+ /**
202
+ * What SST needs to create a stack is most of AWS, so this is the default
203
+ * outside compose — said out loud in the output, and replaceable with
204
+ * `--policy-arn`.
205
+ */
206
+ const DEFAULT_POLICY_ARN = "arn:aws:iam::aws:policy/AdministratorAccess";
207
+ /**
208
+ * What the deploy does to a bucket of the stage's: creates it, and puts each
209
+ * of its settings back where they drifted.
210
+ */
211
+ const BUCKET_ACTIONS = [
212
+ "s3:CreateBucket",
213
+ "s3:ListBucket",
214
+ "s3:GetBucketTagging",
215
+ "s3:PutBucketTagging",
216
+ "s3:GetBucketPublicAccessBlock",
217
+ "s3:PutBucketPublicAccessBlock",
218
+ "s3:GetBucketPolicy",
219
+ "s3:PutBucketPolicy",
220
+ "s3:GetEncryptionConfiguration",
221
+ "s3:PutEncryptionConfiguration",
222
+ "s3:GetBucketVersioning",
223
+ "s3:PutBucketVersioning",
224
+ "s3:GetBucketCORS",
225
+ "s3:PutBucketCORS",
226
+ "s3:GetBucketNotification",
227
+ "s3:PutBucketNotification",
228
+ "s3:GetLifecycleConfiguration",
229
+ "s3:PutLifecycleConfiguration"
230
+ ];
231
+ /** What the deploy does to a topic a bucket or an inbox announces on. */
232
+ const TOPIC_ACTIONS = [
233
+ "sns:CreateTopic",
234
+ "sns:TagResource",
235
+ "sns:GetTopicAttributes",
236
+ "sns:SetTopicAttributes",
237
+ "sns:Subscribe",
238
+ "sns:Unsubscribe",
239
+ "sns:ListSubscriptionsByTopic",
240
+ "sns:GetSubscriptionAttributes",
241
+ "sns:SetSubscriptionAttributes"
242
+ ];
243
+ /** What the deploy does to an IAM user it reaches a resource with, and its key. */
244
+ const USER_ACTIONS = [
245
+ "iam:GetUser",
246
+ "iam:CreateUser",
247
+ "iam:TagUser",
248
+ "iam:ListUserTags",
249
+ "iam:GetUserPolicy",
250
+ "iam:PutUserPolicy",
251
+ "iam:ListAccessKeys",
252
+ "iam:CreateAccessKey",
253
+ "iam:DeleteAccessKey"
254
+ ];
255
+ /**
256
+ * The ARNs a statement over the deploy's IAM users names: each under gkm's
257
+ * path, and again without one. IAM authorizes a call on a user that does not
258
+ * exist yet (the first deploy's `GetUser`) against `user/<name>`, since it
259
+ * has no path to know, so a stage's first deploy from CI is denied without it.
260
+ */
261
+ function userArns(account, users) {
262
+ return users.flatMap((user) => [`arn:aws:iam::${account}:user${IAM_USER_PATH}${user}`, `arn:aws:iam::${account}:user/${user}`]);
263
+ }
264
+ /** The name of the inline policy a compose stage's role is given. */
265
+ const SCOPED_POLICY_NAME = "gkm-deploy";
266
+ /** Every target the stage's apps deploy through. */
267
+ function deployTargets(workspace) {
268
+ const targets = /* @__PURE__ */ new Set([workspace.deploy?.default ?? "dokploy"]);
269
+ for (const app of Object.values(workspace.apps)) targets.add(app.resolvedDeployTarget);
270
+ return [...targets].sort();
271
+ }
272
+ /**
273
+ * The access the stage's deploy role is given: `--policy-arn` when passed,
274
+ * the scoped policy for a stage only the compose target deploys, and
275
+ * `AdministratorAccess` otherwise.
276
+ */
277
+ function deployAccess(workspace, stage, policyArn, manifest = {}) {
278
+ const buckets = Object.entries(manifest).filter(([, d]) => d.kind === "objects").map(([id]) => id);
279
+ if (policyArn) return {
280
+ kind: "managed",
281
+ policyArn,
282
+ reason: "--policy-arn"
283
+ };
284
+ const targets = deployTargets(workspace);
285
+ if (targets.length !== 1 || targets[0] !== "compose") return {
286
+ kind: "managed",
287
+ policyArn: DEFAULT_POLICY_ARN,
288
+ reason: `the ${targets.join(", ")} target${targets.length === 1 ? "" : "s"} deploy${targets.length === 1 ? "s" : ""} infrastructure; --policy-arn to narrow`
289
+ };
290
+ const project = workspace.name;
291
+ const store = workspace.secrets.store ?? "file";
292
+ const state = workspace.state;
293
+ if (typeof store === "object" && typeof store.provider === "object" || state !== void 0 && typeof state.provider === "object") return {
294
+ kind: "managed",
295
+ policyArn: DEFAULT_POLICY_ARN,
296
+ reason: `a custom ${typeof store === "object" && typeof store.provider === "object" ? "secrets store" : "state provider"} cannot be scoped; --policy-arn to narrow`
297
+ };
298
+ const describe = [];
299
+ const build = [];
300
+ const projectBucketIn = (account) => projectBucketName(deployIdentity(workspace, stage).scope, account);
301
+ const projectBucketStatement = (account) => ({
302
+ Sid: "ProjectBucket",
303
+ Effect: "Allow",
304
+ Action: [...PROJECT_BUCKET_CREATE_ACTIONS],
305
+ Resource: `arn:aws:s3:::${projectBucketIn(account)}`
306
+ });
307
+ const stateInSecretsBucket = typeof store === "object" && store.provider === "s3" && state?.provider === "s3" && state.bucket === store.bucket;
308
+ if (typeof store === "object" && store.provider === "s3") {
309
+ const location = s3SecretsLocation(store, state);
310
+ const key = s3SecretsKey(location.prefix, project, stage);
311
+ const named = location.bucket;
312
+ const bucketIn = (account) => named ?? projectBucketIn(account);
313
+ describe.push(named ? `read and update s3://${named}/${key}` : `read and update ${key} in the project bucket ${projectBucketIn("<account>")}${stateInSecretsBucket ? "" : ", creating it"}`);
314
+ build.push((account) => [{
315
+ Sid: "StageSecrets",
316
+ Effect: "Allow",
317
+ Action: ["s3:GetObject", "s3:PutObject"],
318
+ Resource: `arn:aws:s3:::${bucketIn(account)}/${key}`
319
+ }, ...stateInSecretsBucket ? [] : [{
320
+ Sid: "StageSecretsBucket",
321
+ Effect: "Allow",
322
+ Action: ["s3:ListBucket"],
323
+ Resource: `arn:aws:s3:::${bucketIn(account)}`
324
+ }, ...named ? [] : [projectBucketStatement(account)]]]);
325
+ } else if (typeof store === "object" && store.provider === "ssm") {
326
+ const { region } = store;
327
+ const name = secretsParameterName(project, stage);
328
+ describe.push(`read and update ${name} (SSM, ${region})`);
329
+ build.push((account) => [{
330
+ Sid: "StageSecrets",
331
+ Effect: "Allow",
332
+ Action: ["ssm:GetParameter", "ssm:PutParameter"],
333
+ Resource: `arn:aws:ssm:${region}:${account}:parameter${name}`
334
+ }]);
335
+ } else if (typeof store === "object" && store.provider === "secrets-manager") {
336
+ const { region, kmsKeyId } = store;
337
+ const name = secretsManagerSecretName(project, stage);
338
+ describe.push(`read and update ${name} (Secrets Manager, ${region})`);
339
+ build.push((account) => {
340
+ const statements = [{
341
+ Sid: "StageSecrets",
342
+ Effect: "Allow",
343
+ Action: [
344
+ "secretsmanager:GetSecretValue",
345
+ "secretsmanager:PutSecretValue",
346
+ "secretsmanager:CreateSecret"
347
+ ],
348
+ Resource: `arn:aws:secretsmanager:${region}:${account}:secret:${name}-??????`
349
+ }];
350
+ if (kmsKeyId) statements.push({
351
+ Sid: "StageSecretsKey",
352
+ Effect: "Allow",
353
+ Action: ["kms:Decrypt", "kms:GenerateDataKey"],
354
+ Resource: kmsKeyId.startsWith("arn:") ? kmsKeyId : "*",
355
+ Condition: { StringEquals: { "kms:ViaService": `secretsmanager.${region}.amazonaws.com` } }
356
+ });
357
+ return statements;
358
+ });
359
+ }
360
+ if (state?.provider === "ssm") {
361
+ const { region } = state;
362
+ const path = `/gkm/${project}/${stage}/`;
363
+ describe.push(`read and write the deploy state under ${path} (SSM, ${region})`);
364
+ build.push((account) => [{
365
+ Sid: "StageState",
366
+ Effect: "Allow",
367
+ Action: [
368
+ "ssm:GetParameter",
369
+ "ssm:PutParameter",
370
+ "ssm:DeleteParameter"
371
+ ],
372
+ Resource: `arn:aws:ssm:${region}:${account}:parameter${path}*`
373
+ }]);
374
+ } else if (state?.provider === "s3") {
375
+ const prefix = (state.prefix ?? "gkm").replace(/\/+$/, "");
376
+ const path = `${prefix ? `${prefix}/` : ""}${project}/${stage}/`;
377
+ const named = state.bucket;
378
+ const bucketIn = (account) => named ?? projectBucketIn(account);
379
+ describe.push(named ? `read and write the deploy state under s3://${named}/${path}` : `create the project bucket ${projectBucketIn("<account>")}, and read and write the deploy state under ${path} in it`);
380
+ build.push((account) => [...stateBucketStatements(bucketIn(account), path), ...named ? [] : [projectBucketStatement(account)]]);
381
+ }
382
+ const objects = stageProvider(workspace, "objects", stage);
383
+ if (objects.mode === "provider" && objects.name === "s3" && buckets.length) {
384
+ const { scope } = deployIdentity(workspace, stage);
385
+ const names = [...buckets].sort().map((id) => ({
386
+ bucket: bucketName({
387
+ scope,
388
+ stage,
389
+ id
390
+ }),
391
+ user: iamUserName({
392
+ scope,
393
+ stage,
394
+ id
395
+ })
396
+ }));
397
+ const suffix = "?".repeat(6);
398
+ describe.push(`create and configure the buckets ${names.map((n) => n.bucket).join(", ")}, their IAM users, and — for a bucket a subscriber watches — its events topic, dead-letter queue and subscriptions (S3, IAM, SNS, SQS)`);
399
+ build.push((account) => [
400
+ {
401
+ Sid: "StageBuckets",
402
+ Effect: "Allow",
403
+ Action: BUCKET_ACTIONS,
404
+ Resource: names.flatMap((n) => [`arn:aws:s3:::${n.bucket}`, `arn:aws:s3:::${n.bucket}-${suffix}`])
405
+ },
406
+ {
407
+ Sid: "StageBucketTopics",
408
+ Effect: "Allow",
409
+ Action: TOPIC_ACTIONS,
410
+ Resource: names.flatMap((n) => [`${n.bucket}-events`, `${n.bucket}-${suffix}-events`].flatMap((topic) => [`arn:aws:sns:*:${account}:${topic}`, `arn:aws:sns:*:${account}:${topic}:*`]))
411
+ },
412
+ {
413
+ Sid: "StageBucketDeadLetters",
414
+ Effect: "Allow",
415
+ Action: [
416
+ "sqs:CreateQueue",
417
+ "sqs:TagQueue",
418
+ "sqs:GetQueueUrl",
419
+ "sqs:GetQueueAttributes",
420
+ "sqs:SetQueueAttributes"
421
+ ],
422
+ Resource: names.flatMap((n) => [`arn:aws:sqs:*:${account}:${n.bucket}-events-dlq`, `arn:aws:sqs:*:${account}:${n.bucket}-${suffix}-events-dlq`])
423
+ },
424
+ {
425
+ Sid: "StageBucketUsers",
426
+ Effect: "Allow",
427
+ Action: USER_ACTIONS,
428
+ Resource: userArns(account, names.map((n) => n.user))
429
+ }
430
+ ]);
431
+ if (Object.values(manifest).some((d) => d.kind === "file-server") && objects.config.cdn !== false) {
432
+ describe.push("create the file servers’ certificates and CloudFront distributions (ACM, CloudFront)");
433
+ build.push(() => [{
434
+ Sid: "StageFileServerCertificates",
435
+ Effect: "Allow",
436
+ Action: [
437
+ "acm:RequestCertificate",
438
+ "acm:DescribeCertificate",
439
+ "acm:ListCertificates",
440
+ "acm:AddTagsToCertificate"
441
+ ],
442
+ Resource: "*"
443
+ }, {
444
+ Sid: "StageFileServerCdn",
445
+ Effect: "Allow",
446
+ Action: [
447
+ "cloudfront:CreateDistribution",
448
+ "cloudfront:CreateDistributionWithTags",
449
+ "cloudfront:GetDistribution",
450
+ "cloudfront:GetDistributionConfig",
451
+ "cloudfront:UpdateDistribution",
452
+ "cloudfront:ListDistributions",
453
+ "cloudfront:TagResource",
454
+ "cloudfront:CreateOriginAccessControl",
455
+ "cloudfront:GetOriginAccessControl",
456
+ "cloudfront:ListOriginAccessControls",
457
+ "cloudfront:CreateResponseHeadersPolicy",
458
+ "cloudfront:GetResponseHeadersPolicy",
459
+ "cloudfront:GetResponseHeadersPolicyConfig",
460
+ "cloudfront:UpdateResponseHeadersPolicy",
461
+ "cloudfront:ListResponseHeadersPolicies"
462
+ ],
463
+ Resource: "*"
464
+ }]);
465
+ }
466
+ }
467
+ const emails = Object.entries(manifest).filter(([, d]) => d.kind === "email").map(([id]) => id).sort();
468
+ const email = stageProvider(workspace, "email", stage);
469
+ if (email.mode === "provider" && email.name === "ses" && emails.length) {
470
+ const { scope } = deployIdentity(workspace, stage);
471
+ const users = emails.map((id) => emailUserName(scope, stage, id));
472
+ describe.push(`verify the sending domain in SES and create the mail users ${users.join(", ")} and their keys (SES, IAM)`);
473
+ build.push((account) => [{
474
+ Sid: "StageMailIdentity",
475
+ Effect: "Allow",
476
+ Action: [
477
+ "ses:GetIdentityDkimAttributes",
478
+ "ses:VerifyDomainDkim",
479
+ "ses:SetIdentityDkimEnabled",
480
+ "ses:GetSendQuota"
481
+ ],
482
+ Resource: "*"
483
+ }, {
484
+ Sid: "StageMailUsers",
485
+ Effect: "Allow",
486
+ Action: USER_ACTIONS,
487
+ Resource: userArns(account, users)
488
+ }]);
489
+ }
490
+ const inboxes = Object.entries(manifest).filter(([, d]) => d.kind === "inbox").map(([id]) => id).sort();
491
+ const inbox = stageProvider(workspace, "inbox", stage);
492
+ if (inbox.mode === "provider" && inbox.name === "ses" && inboxes.length) {
493
+ const { scope } = deployIdentity(workspace, stage);
494
+ const names = inboxes.map((id) => {
495
+ const named = {
496
+ scope,
497
+ stage,
498
+ id: inboxBucketId(id)
499
+ };
500
+ return {
501
+ bucket: bucketName(named),
502
+ user: iamUserName(named),
503
+ topic: inboxTopicName(scope, stage, id)
504
+ };
505
+ });
506
+ const suffix = "?".repeat(6);
507
+ describe.push(`verify the stage's domain in SES and keep its receipt rules, and create the inbox buckets ${names.map((n) => n.bucket).join(", ")}, their IAM users and topics (SES, S3, IAM, SNS)`);
508
+ build.push((account) => [
509
+ {
510
+ Sid: "StageInboxRules",
511
+ Effect: "Allow",
512
+ Action: [
513
+ "ses:VerifyDomainDkim",
514
+ "ses:DescribeActiveReceiptRuleSet",
515
+ "ses:CreateReceiptRuleSet",
516
+ "ses:SetActiveReceiptRuleSet",
517
+ "ses:DescribeReceiptRuleSet",
518
+ "ses:DescribeReceiptRule",
519
+ "ses:CreateReceiptRule",
520
+ "ses:UpdateReceiptRule",
521
+ "ses:DeleteReceiptRule"
522
+ ],
523
+ Resource: "*"
524
+ },
525
+ {
526
+ Sid: "StageInboxBuckets",
527
+ Effect: "Allow",
528
+ Action: BUCKET_ACTIONS,
529
+ Resource: names.flatMap((n) => [`arn:aws:s3:::${n.bucket}`, `arn:aws:s3:::${n.bucket}-${suffix}`])
530
+ },
531
+ {
532
+ Sid: "StageInboxTopics",
533
+ Effect: "Allow",
534
+ Action: TOPIC_ACTIONS,
535
+ Resource: names.flatMap((n) => [`arn:aws:sns:*:${account}:${n.topic}`, `arn:aws:sns:*:${account}:${n.topic}:*`])
536
+ },
537
+ {
538
+ Sid: "StageInboxUsers",
539
+ Effect: "Allow",
540
+ Action: USER_ACTIONS,
541
+ Resource: userArns(account, names.map((n) => n.user))
542
+ }
543
+ ]);
544
+ }
545
+ if (stageBackups(workspace, manifest, stage).mode === "on") {
546
+ const { scope } = deployIdentity(workspace, stage);
547
+ const user = backupsUserName(scope, stage);
548
+ const bucketIn = (account) => projectBucketName(scope, account);
549
+ describe.push(`create the project bucket ${bucketIn("<account>")} and keep its lifecycle, and create the backups user ${user} and its key (S3, IAM)`);
550
+ build.push((account) => [{
551
+ Sid: "StageBackupsBucket",
552
+ Effect: "Allow",
553
+ Action: ["s3:ListBucket", .../* @__PURE__ */ new Set([...PROJECT_BUCKET_CREATE_ACTIONS, ...PROJECT_BUCKET_LIFECYCLE_ACTIONS])],
554
+ Resource: `arn:aws:s3:::${bucketIn(account)}`
555
+ }, {
556
+ Sid: "StageBackupsUser",
557
+ Effect: "Allow",
558
+ Action: USER_ACTIONS,
559
+ Resource: userArns(account, [user])
560
+ }]);
561
+ }
562
+ for (const { domain, config } of stageDnsDomains(stage, workspace.domains, workspace.dns)) {
563
+ if (config.provider !== "route53") continue;
564
+ const zoneId = config.hostedZoneId?.replace(/^\/?hostedzone\//, "");
565
+ describe.push(`write the A, AAAA and CNAME records of ${domain} (Route53${zoneId ? `, ${zoneId}` : ""})`);
566
+ build.push(() => [
567
+ {
568
+ Sid: "StageDnsRecords",
569
+ Effect: "Allow",
570
+ Action: ["route53:ChangeResourceRecordSets", "route53:ListResourceRecordSets"],
571
+ Resource: `arn:aws:route53:::hostedzone/${zoneId ?? "*"}`
572
+ },
573
+ {
574
+ Sid: "StageDnsChanges",
575
+ Effect: "Allow",
576
+ Action: ["route53:GetChange"],
577
+ Resource: "arn:aws:route53:::change/*"
578
+ },
579
+ ...zoneId ? [] : [{
580
+ Sid: "StageDnsZones",
581
+ Effect: "Allow",
582
+ Action: ["route53:ListHostedZonesByName"],
583
+ Resource: "*"
584
+ }]
585
+ ]);
586
+ }
587
+ return {
588
+ kind: "scoped",
589
+ statements: (account) => build.flatMap((statements) => statements(account)),
590
+ describe
591
+ };
592
+ }
593
+ /**
594
+ * Reading and writing one stage's deploy state in `bucket`, as the deploy
595
+ * role is given it.
596
+ */
597
+ function stateBucketStatements(bucket, path) {
598
+ return [{
599
+ Sid: "StageState",
600
+ Effect: "Allow",
601
+ Action: [
602
+ "s3:GetObject",
603
+ "s3:PutObject",
604
+ "s3:DeleteObject"
605
+ ],
606
+ Resource: `arn:aws:s3:::${bucket}/${path}*`
607
+ }, {
608
+ Sid: "StageStateBucket",
609
+ Effect: "Allow",
610
+ Action: ["s3:ListBucket"],
611
+ Resource: `arn:aws:s3:::${bucket}`
612
+ }];
613
+ }
614
+ /** The scoped access as a policy document, or null when it allows nothing. */
615
+ function scopedPolicyDocument(statements) {
616
+ if (statements.length === 0) return null;
617
+ return JSON.stringify({
618
+ Version: "2012-10-17",
619
+ Statement: statements
620
+ });
621
+ }
622
+ /** The account an IAM ARN is in: `arn:aws:iam::<account>:…`. */
623
+ function accountOf(arn) {
624
+ return arn.split(":")[4] ?? "";
625
+ }
626
+ //#endregion
627
+ //#region src/deploy/github.ts
628
+ /**
629
+ * `gkm deploy:github` — let GitHub Actions deploy one stage, with no keys.
630
+ *
631
+ * A stage usually lives in its own AWS account — staging in one, production in
632
+ * another — so this runs once per stage, with that account's profile:
633
+ *
634
+ * gkm deploy:github --stage staging --profile acme-dev
635
+ * gkm deploy:github --stage prod --profile acme-prod
636
+ *
637
+ * In the stage's account it makes sure GitHub's OIDC provider exists, and a
638
+ * role that only this repository's `<stage>` environment can assume. On
639
+ * GitHub it creates that environment and gives it what the generated deploy
640
+ * workflow reads: `AWS_ROLE_ARN`, and — when the stage's secrets are kept in
641
+ * the local file — its key as `GKM_SECRETS_KEY`. With `secrets.store` set to
642
+ * S3, SSM or Secrets Manager the deploy job reads them with the role instead, so
643
+ * no key is handed to GitHub, and this checks the stage's store in the same
644
+ * account, with the same profile. Re-running it converges rather than duplicating.
645
+ *
646
+ * The role trusts the exact `sub` GitHub sends for the environment, read from
647
+ * the repository's OIDC subject settings (`githubOidc.ts`) — the default, the
648
+ * immutable subject with the owner's and repository's ids, or a custom
649
+ * template. A re-run rewrites an existing role's trust to it, so running this
650
+ * again repairs a role that trusted the wrong format. What the role may do is
651
+ * `githubPolicy.ts`: `AdministratorAccess` for SST, and for a compose stage
652
+ * only its own secrets (and deploy state, when that is in AWS).
653
+ */
654
+ const logger = console;
655
+ const GITHUB_OIDC_HOST = "token.actions.githubusercontent.com";
656
+ const AUDIENCE = "sts.amazonaws.com";
657
+ /**
658
+ * The tag recording which managed policy gkm attached to the role — so a
659
+ * re-run detaches only what gkm put there, never a policy someone else did.
660
+ */
661
+ const POLICY_TAG = "gkm:policy-arn";
662
+ /** The system's `gh`. */
663
+ const ghCli = (args, input) => execFileSync("gh", args, {
664
+ encoding: "utf-8",
665
+ stdio: [
666
+ "pipe",
667
+ "pipe",
668
+ "pipe"
669
+ ],
670
+ ...input === void 0 ? {} : { input }
671
+ }).trim();
672
+ /** The role a stage deploys as: `<project>-github-<stage>`, within IAM's 64. */
673
+ function roleName(project, stage) {
674
+ return `${project}-github-${stage}`.toLowerCase().replace(/[^a-z0-9+=,.@_-]/g, "-").slice(0, 64);
675
+ }
676
+ /**
677
+ * Who may assume the role: a workflow job whose OIDC token carries exactly
678
+ * `subject` — the repository's `<stage>` environment, in the format the
679
+ * repository sends (see `githubOidc.ts`), and nothing else. Not another
680
+ * branch's job, not another environment's: that is what keeps a staging
681
+ * deploy from using the production role.
682
+ */
683
+ function trustPolicy(providerArn, subject) {
684
+ return JSON.stringify({
685
+ Version: "2012-10-17",
686
+ Statement: [{
687
+ Effect: "Allow",
688
+ Principal: { Federated: providerArn },
689
+ Action: "sts:AssumeRoleWithWebIdentity",
690
+ Condition: { StringEquals: {
691
+ [`${GITHUB_OIDC_HOST}:aud`]: AUDIENCE,
692
+ [`${GITHUB_OIDC_HOST}:sub`]: subject
693
+ } }
694
+ }]
695
+ });
696
+ }
697
+ /**
698
+ * The subject a trust policy trusts, or undefined when it names none. IAM
699
+ * hands documents back URL-encoded.
700
+ */
701
+ function trustedSubject(document) {
702
+ if (!document) return void 0;
703
+ let parsed;
704
+ try {
705
+ parsed = JSON.parse(safeDecode(document));
706
+ } catch {
707
+ return;
708
+ }
709
+ for (const statement of parsed.Statement ?? []) for (const operator of Object.values(statement.Condition ?? {})) {
710
+ const value = operator[`${GITHUB_OIDC_HOST}:sub`];
711
+ if (typeof value === "string") return value;
712
+ if (Array.isArray(value)) return value.join(", ");
713
+ }
714
+ }
715
+ function safeDecode(value) {
716
+ try {
717
+ return decodeURIComponent(value);
718
+ } catch {
719
+ return value;
720
+ }
721
+ }
722
+ /** GitHub's OIDC provider in this account, created if it is not there. */
723
+ async function ensureOidcProvider(iam) {
724
+ const { OpenIDConnectProviderList = [] } = await iam.send(new ListOpenIDConnectProvidersCommand({}));
725
+ const existing = OpenIDConnectProviderList.find((p) => p.Arn?.endsWith(`oidc-provider/${GITHUB_OIDC_HOST}`))?.Arn;
726
+ if (existing) return existing;
727
+ return (await iam.send(new CreateOpenIDConnectProviderCommand({
728
+ Url: `https://${GITHUB_OIDC_HOST}`,
729
+ ClientIDList: [AUDIENCE]
730
+ }))).OpenIDConnectProviderArn;
731
+ }
732
+ function isNoSuchEntity(error) {
733
+ return error.name === "NoSuchEntityException";
734
+ }
735
+ /**
736
+ * The deploy role, created or brought back to this trust and access.
737
+ *
738
+ * Converges: re-running rewrites the trust, and moves the role from one access
739
+ * to another — detaching a managed policy only when the role's
740
+ * {@link POLICY_TAG} says gkm attached it.
741
+ */
742
+ async function ensureRole(iam, name, trust, access) {
743
+ let arn;
744
+ let created = false;
745
+ let previousSubject;
746
+ let recorded;
747
+ try {
748
+ const { Role } = await iam.send(new GetRoleCommand({ RoleName: name }));
749
+ previousSubject = trustedSubject(Role.AssumeRolePolicyDocument);
750
+ await iam.send(new UpdateAssumeRolePolicyCommand({
751
+ RoleName: name,
752
+ PolicyDocument: trust
753
+ }));
754
+ arn = Role.Arn;
755
+ const { Tags = [] } = await iam.send(new ListRoleTagsCommand({ RoleName: name }));
756
+ recorded = Tags.find((tag) => tag.Key === POLICY_TAG)?.Value;
757
+ } catch (error) {
758
+ if (!isNoSuchEntity(error)) throw error;
759
+ const { Role } = await iam.send(new CreateRoleCommand({
760
+ RoleName: name,
761
+ AssumeRolePolicyDocument: trust,
762
+ Description: "Deploys from GitHub Actions (gkm deploy:github)",
763
+ MaxSessionDuration: 7200
764
+ }));
765
+ arn = Role.Arn;
766
+ created = true;
767
+ }
768
+ const detached = [];
769
+ const leftAttached = [];
770
+ const detach = async (policyArn) => {
771
+ try {
772
+ await iam.send(new DetachRolePolicyCommand({
773
+ RoleName: name,
774
+ PolicyArn: policyArn
775
+ }));
776
+ detached.push(policyArn);
777
+ } catch (error) {
778
+ if (!isNoSuchEntity(error)) throw error;
779
+ }
780
+ };
781
+ const deleteInline = async () => {
782
+ try {
783
+ await iam.send(new DeleteRolePolicyCommand({
784
+ RoleName: name,
785
+ PolicyName: SCOPED_POLICY_NAME
786
+ }));
787
+ } catch (error) {
788
+ if (!isNoSuchEntity(error)) throw error;
789
+ }
790
+ };
791
+ if ("managed" in access) {
792
+ await iam.send(new AttachRolePolicyCommand({
793
+ RoleName: name,
794
+ PolicyArn: access.managed
795
+ }));
796
+ if (recorded && recorded !== access.managed) await detach(recorded);
797
+ if (recorded !== access.managed) await iam.send(new TagRoleCommand({
798
+ RoleName: name,
799
+ Tags: [{
800
+ Key: POLICY_TAG,
801
+ Value: access.managed
802
+ }]
803
+ }));
804
+ if (!created) await deleteInline();
805
+ return {
806
+ arn,
807
+ created,
808
+ previousSubject,
809
+ detached,
810
+ leftAttached
811
+ };
812
+ }
813
+ if (access.inline) await iam.send(new PutRolePolicyCommand({
814
+ RoleName: name,
815
+ PolicyName: SCOPED_POLICY_NAME,
816
+ PolicyDocument: access.inline
817
+ }));
818
+ else if (!created) await deleteInline();
819
+ if (created) return {
820
+ arn,
821
+ created,
822
+ previousSubject,
823
+ detached,
824
+ leftAttached
825
+ };
826
+ if (recorded) {
827
+ await detach(recorded);
828
+ await iam.send(new UntagRoleCommand({
829
+ RoleName: name,
830
+ TagKeys: [POLICY_TAG]
831
+ }));
832
+ }
833
+ const { AttachedPolicies = [] } = await iam.send(new ListAttachedRolePoliciesCommand({ RoleName: name }));
834
+ for (const policy of AttachedPolicies) if (policy.PolicyArn && !detached.includes(policy.PolicyArn)) leftAttached.push(policy.PolicyArn);
835
+ return {
836
+ arn,
837
+ created,
838
+ previousSubject,
839
+ detached,
840
+ leftAttached
841
+ };
842
+ }
843
+ /**
844
+ * An IAM client for the stage's account.
845
+ *
846
+ * `fromIni` for a named profile, deliberately: it resolves exactly that
847
+ * profile — keys, assume-role, `credential_process` or SSO, whichever
848
+ * ~/.aws/config says — and never falls back to AWS_* in the environment. The
849
+ * provider chain checks the environment first, so exported staging keys would
850
+ * quietly win over `--profile prod` and the production role would land in the
851
+ * staging account.
852
+ */
853
+ async function iamFor(profile, endpoint) {
854
+ const config = { region: "us-east-1" };
855
+ if (profile) {
856
+ const { fromIni } = await import("@aws-sdk/credential-providers");
857
+ config.credentials = fromIni({ profile });
858
+ }
859
+ if (endpoint) {
860
+ config.endpoint = endpoint;
861
+ config.credentials = {
862
+ accessKeyId: "test",
863
+ secretAccessKey: "test"
864
+ };
865
+ }
866
+ return new IAMClient(config);
867
+ }
868
+ async function deployGithubCommand(options, deps = {}) {
869
+ const gh = deps.gh ?? ghCli;
870
+ const { workspace } = await loadWorkspaceConfig(deps.cwd);
871
+ assertDeployedStage(workspace.stages, options.stage);
872
+ const repo = options.repo ?? gh([
873
+ "repo",
874
+ "view",
875
+ "--json",
876
+ "nameWithOwner",
877
+ "-q",
878
+ ".nameWithOwner"
879
+ ]);
880
+ const role = roleName(workspace.name, options.stage);
881
+ const oidc = resolveOidcSubject(gh, repo, options.stage);
882
+ const manifest = await discover({
883
+ patterns: constructGlobs(workspace),
884
+ cwd: workspace.root
885
+ });
886
+ const access = deployAccess(workspace, options.stage, options.policyArn, manifest);
887
+ const key = await readKey(options.stage, keystoreProject(workspace));
888
+ const keyPath = getKeyPath(options.stage, keystoreProject(workspace));
889
+ const hasKey = key !== null;
890
+ const remote = isRemoteStore(workspace, options.stage);
891
+ const store = await secretsStoreFor(workspace, options.stage, { ...options.profile ? { profile: options.profile } : {} });
892
+ const hasSecrets = remote && await store.read(options.stage) !== null;
893
+ const via = options.profile ? `profile "${options.profile}"` : "the default credentials";
894
+ logger.log(`\n🔐 GitHub → AWS for stage "${options.stage}"\n`);
895
+ logger.log(` Repository: ${repo}`);
896
+ logger.log(` AWS profile: ${options.profile ?? "(default credentials)"}`);
897
+ logger.log(` Role: ${role}`);
898
+ if (access.kind === "managed") logger.log(` Policy: ${access.policyArn} (${access.reason})`);
899
+ else if (access.describe.length > 0) {
900
+ logger.log(` Policy: inline "${SCOPED_POLICY_NAME}", scoped to the compose deploy — only:`);
901
+ for (const line of access.describe) logger.log(` ${line}`);
902
+ } else logger.log(" Policy: none — a compose deploy with file secrets and local state reads nothing from AWS");
903
+ logger.log(` Trusted by: ${oidc.subject} only (${SUBJECT_KINDS[oidc.kind]})`);
904
+ if (oidc.warning) logger.log(` ⚠ ${oidc.warning}`);
905
+ if (remote) logger.log(` Secrets: ${hasSecrets ? `in the store (${store.name}), read with ${via}` : `none in the store yet — gkm secrets:set <KEY> '…' --stage ${options.stage}`}`);
906
+ else logger.log(` Secrets key: ${hasKey ? keyPath : `none at ${keyPath} — run gkm secrets:init --stage ${options.stage} first`}`);
907
+ if (options.dryRun) {
908
+ if (access.kind === "scoped") {
909
+ const document = scopedPolicyDocument(access.statements("<account>"));
910
+ if (document) logger.log(`\n Inline policy:\n${JSON.stringify(JSON.parse(document), null, 2).replace(/^/gm, " ")}`);
911
+ }
912
+ logger.log("\n --dry-run: nothing changed.\n");
913
+ return {
914
+ repo,
915
+ subject: oidc.subject
916
+ };
917
+ }
918
+ const iam = deps.iam ?? await iamFor(options.profile);
919
+ const providerArn = await ensureOidcProvider(iam).catch((error) => {
920
+ if (/SSO session/i.test(String(error?.message)) && options.profile) throw new SsoSessionExpired(options.profile);
921
+ throw error;
922
+ });
923
+ const outcome = await ensureRole(iam, role, trustPolicy(providerArn, oidc.subject), access.kind === "managed" ? { managed: access.policyArn } : { inline: scopedPolicyDocument(access.statements(accountOf(providerArn))) });
924
+ const roleArn = outcome.arn;
925
+ logger.log(`\n ✓ AWS: ${roleArn}${outcome.created ? " (created)" : ""}`);
926
+ if (!outcome.created) logger.log(outcome.previousSubject === oidc.subject ? ` ✓ Trust: unchanged, ${oidc.subject}` : ` ✓ Trust: ${outcome.previousSubject ?? "(no subject)"} → ${oidc.subject}`);
927
+ for (const detached of outcome.detached) logger.log(` ✓ Detached ${detached} (attached by gkm, no longer needed)`);
928
+ if (access.kind === "scoped") for (const attached of outcome.leftAttached) logger.log(` ⚠ ${attached} is still attached to ${role}. gkm has no record of attaching it, so it is left; the compose deploy does not need it. Detach it with: aws iam detach-role-policy --role-name ${role} --policy-arn ${attached}${options.profile ? ` --profile ${options.profile}` : ""}`);
929
+ gh([
930
+ "api",
931
+ "--method",
932
+ "PUT",
933
+ `repos/${repo}/environments/${options.stage}`
934
+ ]);
935
+ gh([
936
+ "variable",
937
+ "set",
938
+ "AWS_ROLE_ARN",
939
+ "--env",
940
+ options.stage,
941
+ "--repo",
942
+ repo,
943
+ "--body",
944
+ roleArn
945
+ ]);
946
+ logger.log(` ✓ GitHub: environment "${options.stage}", AWS_ROLE_ARN`);
947
+ if (remote) {
948
+ if (!hasSecrets) logger.log(` ⚠ The "${options.stage}" store holds no secrets yet; set them with gkm secrets:set <KEY> '…' --stage ${options.stage}${options.profile ? ` (AWS_PROFILE=${options.profile})` : ""}.`);
949
+ } else if (hasKey) {
950
+ gh([
951
+ "secret",
952
+ "set",
953
+ "GKM_SECRETS_KEY",
954
+ "--env",
955
+ options.stage,
956
+ "--repo",
957
+ repo
958
+ ], key);
959
+ logger.log(" ✓ GitHub: GKM_SECRETS_KEY");
960
+ } else logger.log(` ⚠ No secrets key for "${options.stage}"; run gkm secrets:init --stage ${options.stage}, then this again.`);
961
+ logger.log(`\n Protect it: add required reviewers to the "${options.stage}" environment in the repository settings.\n`);
962
+ return {
963
+ roleArn,
964
+ repo,
965
+ subject: oidc.subject
966
+ };
967
+ }
968
+ const SUBJECT_KINDS = {
969
+ default: "the repository's default subject",
970
+ immutable: "the repository's immutable subject",
971
+ custom: "the repository's custom subject template",
972
+ assumed: "assumed: the default format"
973
+ };
974
+ /** The profile's SSO login has lapsed; the fix is one command away. */
975
+ var SsoSessionExpired = class extends GkmError {
976
+ profile;
977
+ constructor(profile) {
978
+ super(`The SSO session for profile "${profile}" has expired or is invalid. Run: aws sso login --profile ${profile}`);
979
+ this.profile = profile;
980
+ this.name = "SsoSessionExpired";
981
+ }
982
+ };
983
+ //#endregion
984
+ export { deployGithubCommand, ghCli };
985
+
986
+ //# sourceMappingURL=github-Ptbigbrq.mjs.map