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

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 (438) hide show
  1. package/README.md +323 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-B5BKAoLz.mjs +1039 -0
  7. package/dist/EndpointGenerator-B5BKAoLz.mjs.map +1 -0
  8. package/dist/EndpointGenerator-DxrRqfJ3.cjs +1098 -0
  9. package/dist/EndpointGenerator-DxrRqfJ3.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-C9dDlH9I.mjs +412 -0
  11. package/dist/GoDaddyProvider-C9dDlH9I.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DkUMcMYy.cjs +412 -0
  13. package/dist/GoDaddyProvider-DkUMcMYy.cjs.map +1 -0
  14. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-9faYOQnQ.cjs} +23 -9
  15. package/dist/HostingerProvider-9faYOQnQ.cjs.map +1 -0
  16. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-BEuKG2gz.mjs} +23 -9
  17. package/dist/HostingerProvider-BEuKG2gz.mjs.map +1 -0
  18. package/dist/LegacyStateStore-C44jUnMH.cjs +124 -0
  19. package/dist/LegacyStateStore-C44jUnMH.cjs.map +1 -0
  20. package/dist/LegacyStateStore-DPKhjUR6.mjs +124 -0
  21. package/dist/LegacyStateStore-DPKhjUR6.mjs.map +1 -0
  22. package/dist/LocalStateStore-B95WE99i.cjs +178 -0
  23. package/dist/LocalStateStore-B95WE99i.cjs.map +1 -0
  24. package/dist/LocalStateStore-BU3fWkcT.mjs +167 -0
  25. package/dist/LocalStateStore-BU3fWkcT.mjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-DOTLKBFf.cjs +539 -0
  27. package/dist/OpenApiTsGenerator-DOTLKBFf.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-Vaf0pI8u.mjs +534 -0
  29. package/dist/OpenApiTsGenerator-Vaf0pI8u.mjs.map +1 -0
  30. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
  31. package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
  32. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
  33. package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
  34. package/dist/S3StateStore-Cpbeijr5.mjs +223 -0
  35. package/dist/S3StateStore-Cpbeijr5.mjs.map +1 -0
  36. package/dist/S3StateStore-zU5kClhd.cjs +222 -0
  37. package/dist/S3StateStore-zU5kClhd.cjs.map +1 -0
  38. package/dist/SSMStateStore-BxkKMBi_.mjs +205 -0
  39. package/dist/SSMStateStore-BxkKMBi_.mjs.map +1 -0
  40. package/dist/SSMStateStore-D9uviQ3T.cjs +204 -0
  41. package/dist/SSMStateStore-D9uviQ3T.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-BybB6uez.mjs +783 -0
  43. package/dist/SubscriberGenerator-BybB6uez.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-mZpSuSU7.cjs +848 -0
  45. package/dist/SubscriberGenerator-mZpSuSU7.cjs.map +1 -0
  46. package/dist/add-Bb2IL3Yq.cjs +713 -0
  47. package/dist/add-Bb2IL3Yq.cjs.map +1 -0
  48. package/dist/add-Dj-gtqTO.mjs +711 -0
  49. package/dist/add-Dj-gtqTO.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/apps-0vc4Oz9_.cjs +6247 -0
  55. package/dist/apps-0vc4Oz9_.cjs.map +1 -0
  56. package/dist/apps-FRNlECwi.mjs +5621 -0
  57. package/dist/apps-FRNlECwi.mjs.map +1 -0
  58. package/dist/aws-8QQ8n-t6.mjs +89 -0
  59. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  60. package/dist/aws-DY9NqQIT.cjs +100 -0
  61. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  62. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  63. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  64. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  65. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  66. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  67. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  68. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  69. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  70. package/dist/backups/runner.cjs +519 -0
  71. package/dist/backups/runner.cjs.map +1 -0
  72. package/dist/backups/runner.d.cts +102 -0
  73. package/dist/backups/runner.d.cts.map +1 -0
  74. package/dist/backups/runner.d.mts +102 -0
  75. package/dist/backups/runner.d.mts.map +1 -0
  76. package/dist/backups/runner.mjs +506 -0
  77. package/dist/backups/runner.mjs.map +1 -0
  78. package/dist/{bundler-BodTL4kf.mjs → bundler-9EM4ZHcu.mjs} +59 -14
  79. package/dist/bundler-9EM4ZHcu.mjs.map +1 -0
  80. package/dist/{bundler-BeNDZdHQ.cjs → bundler-Bg2eEFEh.cjs} +59 -14
  81. package/dist/bundler-Bg2eEFEh.cjs.map +1 -0
  82. package/dist/cli-CmoSOzNq.mjs +80 -0
  83. package/dist/cli-CmoSOzNq.mjs.map +1 -0
  84. package/dist/cli-YtLjcAZT.cjs +80 -0
  85. package/dist/cli-YtLjcAZT.cjs.map +1 -0
  86. package/dist/compose-3AtZF7ul.mjs +1560 -0
  87. package/dist/compose-3AtZF7ul.mjs.map +1 -0
  88. package/dist/compose-CW1DGfYc.cjs +1919 -0
  89. package/dist/compose-CW1DGfYc.cjs.map +1 -0
  90. package/dist/compose-CnXZAYNM.mjs +3068 -0
  91. package/dist/compose-CnXZAYNM.mjs.map +1 -0
  92. package/dist/compose-D7gOSspy.cjs +3157 -0
  93. package/dist/compose-D7gOSspy.cjs.map +1 -0
  94. package/dist/config-B5Hi3mLK.cjs +821 -0
  95. package/dist/config-B5Hi3mLK.cjs.map +1 -0
  96. package/dist/config-BNmLn0dw.d.mts +291 -0
  97. package/dist/config-BNmLn0dw.d.mts.map +1 -0
  98. package/dist/config-CkuiD9Jv.d.cts +291 -0
  99. package/dist/config-CkuiD9Jv.d.cts.map +1 -0
  100. package/dist/config-DWTUVGRE.mjs +696 -0
  101. package/dist/config-DWTUVGRE.mjs.map +1 -0
  102. package/dist/config.cjs +13 -3
  103. package/dist/config.d.cts +4 -117
  104. package/dist/config.d.mts +4 -117
  105. package/dist/config.mjs +3 -3
  106. package/dist/credentialSchemas-BAklWDna.cjs +271 -0
  107. package/dist/credentialSchemas-BAklWDna.cjs.map +1 -0
  108. package/dist/credentialSchemas-mz9QZTYh.mjs +236 -0
  109. package/dist/credentialSchemas-mz9QZTYh.mjs.map +1 -0
  110. package/dist/credentials-CjFtNBVH.mjs +1834 -0
  111. package/dist/credentials-CjFtNBVH.mjs.map +1 -0
  112. package/dist/credentials-DwIRfeBL.cjs +2289 -0
  113. package/dist/credentials-DwIRfeBL.cjs.map +1 -0
  114. package/dist/databases-C1qqNxTu.mjs +588 -0
  115. package/dist/databases-C1qqNxTu.mjs.map +1 -0
  116. package/dist/databases-CrKh5jw6.cjs +703 -0
  117. package/dist/databases-CrKh5jw6.cjs.map +1 -0
  118. package/dist/define-6poNqm5O.mjs +106 -0
  119. package/dist/define-6poNqm5O.mjs.map +1 -0
  120. package/dist/define-crmMcXFS.cjs +153 -0
  121. package/dist/define-crmMcXFS.cjs.map +1 -0
  122. package/dist/deploy/public.cjs +211 -0
  123. package/dist/deploy/public.cjs.map +1 -0
  124. package/dist/deploy/public.d.cts +658 -0
  125. package/dist/deploy/public.d.cts.map +1 -0
  126. package/dist/deploy/public.d.mts +658 -0
  127. package/dist/deploy/public.d.mts.map +1 -0
  128. package/dist/deploy/public.mjs +144 -0
  129. package/dist/deploy/public.mjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  131. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  133. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  134. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  135. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  136. package/dist/deploy/sniffer-hooks.cjs +1 -1
  137. package/dist/deploy/sniffer-hooks.mjs +1 -1
  138. package/dist/deploy/sniffer-loader.cjs +2 -2
  139. package/dist/deploy/sniffer-loader.mjs +1 -1
  140. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  141. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  142. package/dist/deploy-3bsiWJxj.cjs +3925 -0
  143. package/dist/deploy-3bsiWJxj.cjs.map +1 -0
  144. package/dist/deploy-BI3fHnyb.mjs +3869 -0
  145. package/dist/deploy-BI3fHnyb.mjs.map +1 -0
  146. package/dist/discover-CRywE7yc.cjs +1085 -0
  147. package/dist/discover-CRywE7yc.cjs.map +1 -0
  148. package/dist/discover-DbDrCQ8h.mjs +940 -0
  149. package/dist/discover-DbDrCQ8h.mjs.map +1 -0
  150. package/dist/docker-CwayjAF2.cjs +1515 -0
  151. package/dist/docker-CwayjAF2.cjs.map +1 -0
  152. package/dist/docker-DPdn7tYJ.mjs +1408 -0
  153. package/dist/docker-DPdn7tYJ.mjs.map +1 -0
  154. package/dist/dokploy-BMBL-_Xu.cjs +38 -0
  155. package/dist/dokploy-BMBL-_Xu.cjs.map +1 -0
  156. package/dist/dokploy-tmnH0Du_.mjs +38 -0
  157. package/dist/dokploy-tmnH0Du_.mjs.map +1 -0
  158. package/dist/drivers-BhdC9Efj.cjs +248 -0
  159. package/dist/drivers-BhdC9Efj.cjs.map +1 -0
  160. package/dist/drivers-wcDnzf7l.mjs +213 -0
  161. package/dist/drivers-wcDnzf7l.mjs.map +1 -0
  162. package/dist/eas-BVGQAUDc.mjs +334 -0
  163. package/dist/eas-BVGQAUDc.mjs.map +1 -0
  164. package/dist/eas-meN1xady.cjs +337 -0
  165. package/dist/eas-meN1xady.cjs.map +1 -0
  166. package/dist/emit-C4KSXOeS.mjs +153 -0
  167. package/dist/emit-C4KSXOeS.mjs.map +1 -0
  168. package/dist/emit-DiW0kbue.cjs +164 -0
  169. package/dist/emit-DiW0kbue.cjs.map +1 -0
  170. package/dist/encryption-C8AMbomA.mjs +89 -0
  171. package/dist/encryption-C8AMbomA.mjs.map +1 -0
  172. package/dist/encryption-DvFVZdGz.cjs +90 -0
  173. package/dist/encryption-DvFVZdGz.cjs.map +1 -0
  174. package/dist/engine-BbWj0w3F.mjs +3217 -0
  175. package/dist/engine-BbWj0w3F.mjs.map +1 -0
  176. package/dist/engine-BmiIUVWa.cjs +3330 -0
  177. package/dist/engine-BmiIUVWa.cjs.map +1 -0
  178. package/dist/errors-D8Gwp5kU.mjs +23 -0
  179. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  180. package/dist/errors-DMC4Umsb.cjs +34 -0
  181. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  182. package/dist/github-BWqQr8q6.cjs +901 -0
  183. package/dist/github-BWqQr8q6.cjs.map +1 -0
  184. package/dist/github-Dc1daUbH.mjs +900 -0
  185. package/dist/github-Dc1daUbH.mjs.map +1 -0
  186. package/dist/googlePlay-ByaFUly7.mjs +931 -0
  187. package/dist/googlePlay-ByaFUly7.mjs.map +1 -0
  188. package/dist/googlePlay-CdVCdfU8.cjs +931 -0
  189. package/dist/googlePlay-CdVCdfU8.cjs.map +1 -0
  190. package/dist/{index-C-VLwB_Y.d.mts → index-B35vTdAW.d.cts} +38 -14
  191. package/dist/index-B35vTdAW.d.cts.map +1 -0
  192. package/dist/{index-C-HkOEBt.d.cts → index-Dv1Zj86i.d.mts} +38 -14
  193. package/dist/index-Dv1Zj86i.d.mts.map +1 -0
  194. package/dist/index.cjs +13730 -12325
  195. package/dist/index.cjs.map +1 -1
  196. package/dist/index.mjs +13771 -12364
  197. package/dist/index.mjs.map +1 -1
  198. package/dist/local-CnVFHJjS.mjs +224 -0
  199. package/dist/local-CnVFHJjS.mjs.map +1 -0
  200. package/dist/local-qevrV6dZ.cjs +241 -0
  201. package/dist/local-qevrV6dZ.cjs.map +1 -0
  202. package/dist/migrate-BEuCcCwN.mjs +267 -0
  203. package/dist/migrate-BEuCcCwN.mjs.map +1 -0
  204. package/dist/migrate-CRRps1i6.cjs +272 -0
  205. package/dist/migrate-CRRps1i6.cjs.map +1 -0
  206. package/dist/migrate-CU8_ZWP1.cjs +181 -0
  207. package/dist/migrate-CU8_ZWP1.cjs.map +1 -0
  208. package/dist/migrate-DgfKZB41.mjs +181 -0
  209. package/dist/migrate-DgfKZB41.mjs.map +1 -0
  210. package/dist/notes-BrBnyZz5.cjs +500 -0
  211. package/dist/notes-BrBnyZz5.cjs.map +1 -0
  212. package/dist/notes-CIzrdBKE.mjs +399 -0
  213. package/dist/notes-CIzrdBKE.mjs.map +1 -0
  214. package/dist/openapi.cjs +213 -7
  215. package/dist/openapi.cjs.map +1 -0
  216. package/dist/openapi.d.cts +32 -8
  217. package/dist/openapi.d.cts.map +1 -1
  218. package/dist/openapi.d.mts +32 -8
  219. package/dist/openapi.d.mts.map +1 -1
  220. package/dist/openapi.mjs +208 -2
  221. package/dist/openapi.mjs.map +1 -0
  222. package/dist/projectBucket-CDJd3prK.mjs +222 -0
  223. package/dist/projectBucket-CDJd3prK.mjs.map +1 -0
  224. package/dist/projectBucket-CKr_zObJ.cjs +263 -0
  225. package/dist/projectBucket-CKr_zObJ.cjs.map +1 -0
  226. package/dist/provider-BqpjG9QM.cjs +57 -0
  227. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  228. package/dist/provider-CEOKk8NS.mjs +46 -0
  229. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  230. package/dist/publish-Bq96_QnK.mjs +123 -0
  231. package/dist/publish-Bq96_QnK.mjs.map +1 -0
  232. package/dist/publish-DMKXh1Tb.cjs +124 -0
  233. package/dist/publish-DMKXh1Tb.cjs.map +1 -0
  234. package/dist/ready-BjFMu_1J.mjs +375 -0
  235. package/dist/ready-BjFMu_1J.mjs.map +1 -0
  236. package/dist/ready-eVMJIcWn.cjs +404 -0
  237. package/dist/ready-eVMJIcWn.cjs.map +1 -0
  238. package/dist/reconcile/public.cjs +3 -5
  239. package/dist/reconcile/public.d.cts +33 -89
  240. package/dist/reconcile/public.d.cts.map +1 -1
  241. package/dist/reconcile/public.d.mts +33 -89
  242. package/dist/reconcile/public.d.mts.map +1 -1
  243. package/dist/reconcile/public.mjs +3 -3
  244. package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
  245. package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
  246. package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
  247. package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
  248. package/dist/resolve-CSsE7frp.mjs +263 -0
  249. package/dist/resolve-CSsE7frp.mjs.map +1 -0
  250. package/dist/resolve-DF9GrosZ.cjs +316 -0
  251. package/dist/resolve-DF9GrosZ.cjs.map +1 -0
  252. package/dist/rollback-BBFGGmMa.cjs +165 -0
  253. package/dist/rollback-BBFGGmMa.cjs.map +1 -0
  254. package/dist/rollback-CZthwqus.mjs +136 -0
  255. package/dist/rollback-CZthwqus.mjs.map +1 -0
  256. package/dist/runtime-CFvcLEJW.d.cts +82 -0
  257. package/dist/runtime-CFvcLEJW.d.cts.map +1 -0
  258. package/dist/runtime-dwsH6ddo.d.mts +82 -0
  259. package/dist/runtime-dwsH6ddo.d.mts.map +1 -0
  260. package/dist/s3-BBRkezf7.mjs +215 -0
  261. package/dist/s3-BBRkezf7.mjs.map +1 -0
  262. package/dist/s3-CI2QYgXH.cjs +215 -0
  263. package/dist/s3-CI2QYgXH.cjs.map +1 -0
  264. package/dist/sandbox/config-worker.cjs +43 -0
  265. package/dist/sandbox/config-worker.cjs.map +1 -0
  266. package/dist/sandbox/config-worker.d.cts +1 -0
  267. package/dist/sandbox/config-worker.d.mts +1 -0
  268. package/dist/sandbox/config-worker.mjs +44 -0
  269. package/dist/sandbox/config-worker.mjs.map +1 -0
  270. package/dist/sandbox/credentials-worker.cjs +53 -0
  271. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  272. package/dist/sandbox/credentials-worker.d.cts +1 -0
  273. package/dist/sandbox/credentials-worker.d.mts +1 -0
  274. package/dist/sandbox/credentials-worker.mjs +54 -0
  275. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  276. package/dist/sandbox/discover-worker.cjs +47 -0
  277. package/dist/sandbox/discover-worker.cjs.map +1 -0
  278. package/dist/sandbox/discover-worker.d.cts +1 -0
  279. package/dist/sandbox/discover-worker.d.mts +1 -0
  280. package/dist/sandbox/discover-worker.mjs +48 -0
  281. package/dist/sandbox/discover-worker.mjs.map +1 -0
  282. package/dist/sandbox/migrate-worker.cjs +75 -0
  283. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  284. package/dist/sandbox/migrate-worker.d.cts +1 -0
  285. package/dist/sandbox/migrate-worker.d.mts +1 -0
  286. package/dist/sandbox/migrate-worker.mjs +76 -0
  287. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  288. package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
  289. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  290. package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
  291. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  292. package/dist/secretsManager-CQORubp9.mjs +97 -0
  293. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  294. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  295. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  296. package/dist/seeds-B3xvUAQf.cjs +363 -0
  297. package/dist/seeds-B3xvUAQf.cjs.map +1 -0
  298. package/dist/seeds-BCC8vAXR.mjs +298 -0
  299. package/dist/seeds-BCC8vAXR.mjs.map +1 -0
  300. package/dist/serverSetup-C4iAABtI.mjs +685 -0
  301. package/dist/serverSetup-C4iAABtI.mjs.map +1 -0
  302. package/dist/serverSetup-Dt2DTlwa.cjs +685 -0
  303. package/dist/serverSetup-Dt2DTlwa.cjs.map +1 -0
  304. package/dist/sniffer-C2Ot1IbK.mjs +1824 -0
  305. package/dist/sniffer-C2Ot1IbK.mjs.map +1 -0
  306. package/dist/sniffer-bTrGuu9z.cjs +1997 -0
  307. package/dist/sniffer-bTrGuu9z.cjs.map +1 -0
  308. package/dist/snsSubscriptions-CFKb7fv0.cjs +1173 -0
  309. package/dist/snsSubscriptions-CFKb7fv0.cjs.map +1 -0
  310. package/dist/snsSubscriptions-QDDDn9Qi.mjs +1048 -0
  311. package/dist/snsSubscriptions-QDDDn9Qi.mjs.map +1 -0
  312. package/dist/sst-DDRWlXdv.mjs +478 -0
  313. package/dist/sst-DDRWlXdv.mjs.map +1 -0
  314. package/dist/sst-iRdMlGKd.cjs +501 -0
  315. package/dist/sst-iRdMlGKd.cjs.map +1 -0
  316. package/dist/stack-B9iDYMrq.cjs +2431 -0
  317. package/dist/stack-B9iDYMrq.cjs.map +1 -0
  318. package/dist/stack-CIOY44aC.mjs +2256 -0
  319. package/dist/stack-CIOY44aC.mjs.map +1 -0
  320. package/dist/stage-DA74aD_V.mjs +302 -0
  321. package/dist/stage-DA74aD_V.mjs.map +1 -0
  322. package/dist/stage-ycFS9mVn.cjs +313 -0
  323. package/dist/stage-ycFS9mVn.cjs.map +1 -0
  324. package/dist/stages-B0yOikgt.cjs +190 -0
  325. package/dist/stages-B0yOikgt.cjs.map +1 -0
  326. package/dist/stages-yA9bhStl.mjs +190 -0
  327. package/dist/stages-yA9bhStl.mjs.map +1 -0
  328. package/dist/target/public.cjs +15 -0
  329. package/dist/target/public.d.cts +28 -0
  330. package/dist/target/public.d.cts.map +1 -0
  331. package/dist/target/public.d.mts +28 -0
  332. package/dist/target/public.d.mts.map +1 -0
  333. package/dist/target/public.mjs +4 -0
  334. package/dist/terminal-DX22WLvT.mjs +85 -0
  335. package/dist/terminal-DX22WLvT.mjs.map +1 -0
  336. package/dist/terminal-RxfbNUwl.cjs +85 -0
  337. package/dist/terminal-RxfbNUwl.cjs.map +1 -0
  338. package/dist/types-Bl_CwZC9.cjs +90 -0
  339. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  340. package/dist/{types-kvBQjpPo.d.mts → types-Dk--xVOT.d.cts} +2159 -364
  341. package/dist/types-Dk--xVOT.d.cts.map +1 -0
  342. package/dist/{types-RhXmHR-e.d.cts → types-DwQYpd_0.d.mts} +2157 -364
  343. package/dist/types-DwQYpd_0.d.mts.map +1 -0
  344. package/dist/types-Y1NfWlyG.mjs +61 -0
  345. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  346. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  347. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  348. package/dist/utils-D_fxUqvU.mjs +156 -0
  349. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  350. package/dist/vitest.cjs +65 -0
  351. package/dist/vitest.cjs.map +1 -0
  352. package/dist/vitest.d.cts +29 -0
  353. package/dist/vitest.d.cts.map +1 -0
  354. package/dist/vitest.d.mts +29 -0
  355. package/dist/vitest.d.mts.map +1 -0
  356. package/dist/vitest.mjs +65 -0
  357. package/dist/vitest.mjs.map +1 -0
  358. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  359. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  360. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  361. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  362. package/dist/workspace/index.cjs +6 -2
  363. package/dist/workspace/index.d.cts +3 -3
  364. package/dist/workspace/index.d.mts +3 -3
  365. package/dist/workspace/index.mjs +2 -2
  366. package/dist/workspace-1szcahj9.cjs +2916 -0
  367. package/dist/workspace-1szcahj9.cjs.map +1 -0
  368. package/dist/workspace-DFGsrjGD.mjs +2480 -0
  369. package/dist/workspace-DFGsrjGD.mjs.map +1 -0
  370. package/package.json +65 -13
  371. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  372. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  373. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  374. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  375. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  376. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  377. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  378. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  379. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  380. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  381. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  382. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  383. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  384. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  385. package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
  386. package/dist/bundler-BodTL4kf.mjs.map +0 -1
  387. package/dist/config-Q1rvKHvw.cjs +0 -467
  388. package/dist/config-Q1rvKHvw.cjs.map +0 -1
  389. package/dist/config-pqGD3hF9.mjs +0 -414
  390. package/dist/config-pqGD3hF9.mjs.map +0 -1
  391. package/dist/config.d.cts.map +0 -1
  392. package/dist/config.d.mts.map +0 -1
  393. package/dist/credentials-BekkKtY_.mjs +0 -2780
  394. package/dist/credentials-BekkKtY_.mjs.map +0 -1
  395. package/dist/credentials-Q6F0uqJq.cjs +0 -2917
  396. package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
  397. package/dist/discover-BERGFg8v.cjs +0 -288
  398. package/dist/discover-BERGFg8v.cjs.map +0 -1
  399. package/dist/discover-CK-n3w6b.mjs +0 -244
  400. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  401. package/dist/emit-BdoPFjZf.cjs +0 -253
  402. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  403. package/dist/emit-Bzq7JsMP.mjs +0 -224
  404. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  405. package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
  406. package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
  407. package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
  408. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
  409. package/dist/generator-LfZU7NlU.mjs +0 -247
  410. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  411. package/dist/generator-Wdfp0jCS.cjs +0 -282
  412. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  413. package/dist/github-BfflNPVe.cjs +0 -203
  414. package/dist/github-BfflNPVe.cjs.map +0 -1
  415. package/dist/github-CRwnxKmD.mjs +0 -203
  416. package/dist/github-CRwnxKmD.mjs.map +0 -1
  417. package/dist/index-C-HkOEBt.d.cts.map +0 -1
  418. package/dist/index-C-VLwB_Y.d.mts.map +0 -1
  419. package/dist/keystore-B4PRlbgE.mjs +0 -81
  420. package/dist/keystore-B4PRlbgE.mjs.map +0 -1
  421. package/dist/keystore-DgGRj2Yy.cjs +0 -98
  422. package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
  423. package/dist/openapi-Dcbme-Us.cjs +0 -2038
  424. package/dist/openapi-Dcbme-Us.cjs.map +0 -1
  425. package/dist/openapi-vy4JzhUv.mjs +0 -1991
  426. package/dist/openapi-vy4JzhUv.mjs.map +0 -1
  427. package/dist/storage-C-30BD1e.cjs +0 -272
  428. package/dist/storage-C-30BD1e.cjs.map +0 -1
  429. package/dist/storage-P_b3w7uj.mjs +0 -231
  430. package/dist/storage-P_b3w7uj.mjs.map +0 -1
  431. package/dist/sync-B3xxXtJT.mjs +0 -88
  432. package/dist/sync-B3xxXtJT.mjs.map +0 -1
  433. package/dist/sync-D7uTIIEi.cjs +0 -111
  434. package/dist/sync-D7uTIIEi.cjs.map +0 -1
  435. package/dist/types-RhXmHR-e.d.cts.map +0 -1
  436. package/dist/types-kvBQjpPo.d.mts.map +0 -1
  437. package/dist/workspace-CgwmXEtc.mjs.map +0 -1
  438. package/dist/workspace-mFpI_ky_.cjs.map +0 -1
@@ -0,0 +1,900 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { J as readKey, K as keystoreProject, O as isRemoteStore, U as getKeyPath, X as deployIdentity, k as secretsStoreFor } from "./credentials-CjFtNBVH.mjs";
3
+ import { N as assertDeployedStage, U as stageProvider, mt as s3SecretsLocation, pt as s3SecretsKey } from "./workspace-DFGsrjGD.mjs";
4
+ import { Yt as stageBackups, f as constructGlobs } from "./apps-FRNlECwi.mjs";
5
+ import { m as loadWorkspaceConfig } from "./config-DWTUVGRE.mjs";
6
+ import { i as discover } from "./discover-DbDrCQ8h.mjs";
7
+ import { _ as stageDnsDomains } from "./snsSubscriptions-QDDDn9Qi.mjs";
8
+ import { c as bucketName, l as iamUserName, o as backupsUserName, s as IAM_USER_PATH } from "./deploy-BI3fHnyb.mjs";
9
+ import { n as PROJECT_BUCKET_LIFECYCLE_ACTIONS, o as projectBucketName, t as PROJECT_BUCKET_CREATE_ACTIONS } from "./projectBucket-CDJd3prK.mjs";
10
+ import { n as secretsParameterName } from "./aws-8QQ8n-t6.mjs";
11
+ import { t as secretsManagerSecretName } from "./secretsManager-CQORubp9.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
+ /** The name of the inline policy a compose stage's role is given. */
208
+ const SCOPED_POLICY_NAME = "gkm-deploy";
209
+ /** Every target the stage's apps deploy through. */
210
+ function deployTargets(workspace) {
211
+ const targets = /* @__PURE__ */ new Set([workspace.deploy?.default ?? "dokploy"]);
212
+ for (const app of Object.values(workspace.apps)) targets.add(app.resolvedDeployTarget);
213
+ return [...targets].sort();
214
+ }
215
+ /**
216
+ * The access the stage's deploy role is given: `--policy-arn` when passed,
217
+ * the scoped policy for a stage only the compose target deploys, and
218
+ * `AdministratorAccess` otherwise.
219
+ */
220
+ function deployAccess(workspace, stage, policyArn, manifest = {}) {
221
+ const buckets = Object.entries(manifest).filter(([, d]) => d.kind === "objects").map(([id]) => id);
222
+ if (policyArn) return {
223
+ kind: "managed",
224
+ policyArn,
225
+ reason: "--policy-arn"
226
+ };
227
+ const targets = deployTargets(workspace);
228
+ if (targets.length !== 1 || targets[0] !== "compose") return {
229
+ kind: "managed",
230
+ policyArn: DEFAULT_POLICY_ARN,
231
+ reason: `the ${targets.join(", ")} target${targets.length === 1 ? "" : "s"} deploy${targets.length === 1 ? "s" : ""} infrastructure; --policy-arn to narrow`
232
+ };
233
+ const project = workspace.name;
234
+ const store = workspace.secrets.store ?? "file";
235
+ const state = workspace.state;
236
+ if (typeof store === "object" && typeof store.provider === "object" || state !== void 0 && typeof state.provider === "object") return {
237
+ kind: "managed",
238
+ policyArn: DEFAULT_POLICY_ARN,
239
+ reason: `a custom ${typeof store === "object" && typeof store.provider === "object" ? "secrets store" : "state provider"} cannot be scoped; --policy-arn to narrow`
240
+ };
241
+ const describe = [];
242
+ const build = [];
243
+ const projectBucketIn = (account) => projectBucketName(deployIdentity(workspace, stage).scope, account);
244
+ const projectBucketStatement = (account) => ({
245
+ Sid: "ProjectBucket",
246
+ Effect: "Allow",
247
+ Action: [...PROJECT_BUCKET_CREATE_ACTIONS],
248
+ Resource: `arn:aws:s3:::${projectBucketIn(account)}`
249
+ });
250
+ const stateInSecretsBucket = typeof store === "object" && store.provider === "s3" && state?.provider === "s3" && state.bucket === store.bucket;
251
+ if (typeof store === "object" && store.provider === "s3") {
252
+ const location = s3SecretsLocation(store, state);
253
+ const key = s3SecretsKey(location.prefix, project, stage);
254
+ const named = location.bucket;
255
+ const bucketIn = (account) => named ?? projectBucketIn(account);
256
+ describe.push(named ? `read and update s3://${named}/${key}` : `read and update ${key} in the project bucket ${projectBucketIn("<account>")}${stateInSecretsBucket ? "" : ", creating it"}`);
257
+ build.push((account) => [{
258
+ Sid: "StageSecrets",
259
+ Effect: "Allow",
260
+ Action: ["s3:GetObject", "s3:PutObject"],
261
+ Resource: `arn:aws:s3:::${bucketIn(account)}/${key}`
262
+ }, ...stateInSecretsBucket ? [] : [{
263
+ Sid: "StageSecretsBucket",
264
+ Effect: "Allow",
265
+ Action: ["s3:ListBucket"],
266
+ Resource: `arn:aws:s3:::${bucketIn(account)}`
267
+ }, ...named ? [] : [projectBucketStatement(account)]]]);
268
+ } else if (typeof store === "object" && store.provider === "ssm") {
269
+ const { region } = store;
270
+ const name = secretsParameterName(project, stage);
271
+ describe.push(`read and update ${name} (SSM, ${region})`);
272
+ build.push((account) => [{
273
+ Sid: "StageSecrets",
274
+ Effect: "Allow",
275
+ Action: ["ssm:GetParameter", "ssm:PutParameter"],
276
+ Resource: `arn:aws:ssm:${region}:${account}:parameter${name}`
277
+ }]);
278
+ } else if (typeof store === "object" && store.provider === "secrets-manager") {
279
+ const { region, kmsKeyId } = store;
280
+ const name = secretsManagerSecretName(project, stage);
281
+ describe.push(`read and update ${name} (Secrets Manager, ${region})`);
282
+ build.push((account) => {
283
+ const statements = [{
284
+ Sid: "StageSecrets",
285
+ Effect: "Allow",
286
+ Action: [
287
+ "secretsmanager:GetSecretValue",
288
+ "secretsmanager:PutSecretValue",
289
+ "secretsmanager:CreateSecret"
290
+ ],
291
+ Resource: `arn:aws:secretsmanager:${region}:${account}:secret:${name}-??????`
292
+ }];
293
+ if (kmsKeyId) statements.push({
294
+ Sid: "StageSecretsKey",
295
+ Effect: "Allow",
296
+ Action: ["kms:Decrypt", "kms:GenerateDataKey"],
297
+ Resource: kmsKeyId.startsWith("arn:") ? kmsKeyId : "*",
298
+ Condition: { StringEquals: { "kms:ViaService": `secretsmanager.${region}.amazonaws.com` } }
299
+ });
300
+ return statements;
301
+ });
302
+ }
303
+ if (state?.provider === "ssm") {
304
+ const { region } = state;
305
+ const path = `/gkm/${project}/${stage}/`;
306
+ describe.push(`read and write the deploy state under ${path} (SSM, ${region})`);
307
+ build.push((account) => [{
308
+ Sid: "StageState",
309
+ Effect: "Allow",
310
+ Action: [
311
+ "ssm:GetParameter",
312
+ "ssm:PutParameter",
313
+ "ssm:DeleteParameter"
314
+ ],
315
+ Resource: `arn:aws:ssm:${region}:${account}:parameter${path}*`
316
+ }]);
317
+ } else if (state?.provider === "s3") {
318
+ const prefix = (state.prefix ?? "gkm").replace(/\/+$/, "");
319
+ const path = `${prefix ? `${prefix}/` : ""}${project}/${stage}/`;
320
+ const named = state.bucket;
321
+ const bucketIn = (account) => named ?? projectBucketIn(account);
322
+ 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`);
323
+ build.push((account) => [...stateBucketStatements(bucketIn(account), path), ...named ? [] : [projectBucketStatement(account)]]);
324
+ }
325
+ const objects = stageProvider(workspace, "objects", stage);
326
+ if (objects.mode === "provider" && objects.name === "s3" && buckets.length) {
327
+ const { scope } = deployIdentity(workspace, stage);
328
+ const names = [...buckets].sort().map((id) => ({
329
+ bucket: bucketName({
330
+ scope,
331
+ stage,
332
+ id
333
+ }),
334
+ user: iamUserName({
335
+ scope,
336
+ stage,
337
+ id
338
+ })
339
+ }));
340
+ const suffix = "?".repeat(6);
341
+ 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)`);
342
+ build.push((account) => [
343
+ {
344
+ Sid: "StageBuckets",
345
+ Effect: "Allow",
346
+ Action: [
347
+ "s3:CreateBucket",
348
+ "s3:ListBucket",
349
+ "s3:GetBucketTagging",
350
+ "s3:PutBucketTagging",
351
+ "s3:GetBucketPublicAccessBlock",
352
+ "s3:PutBucketPublicAccessBlock",
353
+ "s3:GetBucketPolicy",
354
+ "s3:PutBucketPolicy",
355
+ "s3:GetEncryptionConfiguration",
356
+ "s3:PutEncryptionConfiguration",
357
+ "s3:GetBucketVersioning",
358
+ "s3:PutBucketVersioning",
359
+ "s3:GetBucketCORS",
360
+ "s3:PutBucketCORS",
361
+ "s3:GetBucketNotification",
362
+ "s3:PutBucketNotification",
363
+ "s3:GetLifecycleConfiguration",
364
+ "s3:PutLifecycleConfiguration"
365
+ ],
366
+ Resource: names.flatMap((n) => [`arn:aws:s3:::${n.bucket}`, `arn:aws:s3:::${n.bucket}-${suffix}`])
367
+ },
368
+ {
369
+ Sid: "StageBucketTopics",
370
+ Effect: "Allow",
371
+ Action: [
372
+ "sns:CreateTopic",
373
+ "sns:TagResource",
374
+ "sns:GetTopicAttributes",
375
+ "sns:SetTopicAttributes",
376
+ "sns:Subscribe",
377
+ "sns:Unsubscribe",
378
+ "sns:ListSubscriptionsByTopic",
379
+ "sns:GetSubscriptionAttributes",
380
+ "sns:SetSubscriptionAttributes"
381
+ ],
382
+ Resource: names.flatMap((n) => [`${n.bucket}-events`, `${n.bucket}-${suffix}-events`].flatMap((topic) => [`arn:aws:sns:*:${account}:${topic}`, `arn:aws:sns:*:${account}:${topic}:*`]))
383
+ },
384
+ {
385
+ Sid: "StageBucketDeadLetters",
386
+ Effect: "Allow",
387
+ Action: [
388
+ "sqs:CreateQueue",
389
+ "sqs:TagQueue",
390
+ "sqs:GetQueueUrl",
391
+ "sqs:GetQueueAttributes",
392
+ "sqs:SetQueueAttributes"
393
+ ],
394
+ Resource: names.flatMap((n) => [`arn:aws:sqs:*:${account}:${n.bucket}-events-dlq`, `arn:aws:sqs:*:${account}:${n.bucket}-${suffix}-events-dlq`])
395
+ },
396
+ {
397
+ Sid: "StageBucketUsers",
398
+ Effect: "Allow",
399
+ Action: [
400
+ "iam:GetUser",
401
+ "iam:CreateUser",
402
+ "iam:TagUser",
403
+ "iam:ListUserTags",
404
+ "iam:GetUserPolicy",
405
+ "iam:PutUserPolicy",
406
+ "iam:ListAccessKeys",
407
+ "iam:CreateAccessKey",
408
+ "iam:DeleteAccessKey"
409
+ ],
410
+ Resource: names.map((n) => `arn:aws:iam::${account}:user${IAM_USER_PATH}${n.user}`)
411
+ }
412
+ ]);
413
+ if (Object.values(manifest).some((d) => d.kind === "file-server") && objects.config.cdn !== false) {
414
+ describe.push("create the file servers’ certificates and CloudFront distributions (ACM, CloudFront)");
415
+ build.push(() => [{
416
+ Sid: "StageFileServerCertificates",
417
+ Effect: "Allow",
418
+ Action: [
419
+ "acm:RequestCertificate",
420
+ "acm:DescribeCertificate",
421
+ "acm:ListCertificates",
422
+ "acm:AddTagsToCertificate"
423
+ ],
424
+ Resource: "*"
425
+ }, {
426
+ Sid: "StageFileServerCdn",
427
+ Effect: "Allow",
428
+ Action: [
429
+ "cloudfront:CreateDistribution",
430
+ "cloudfront:CreateDistributionWithTags",
431
+ "cloudfront:GetDistribution",
432
+ "cloudfront:GetDistributionConfig",
433
+ "cloudfront:UpdateDistribution",
434
+ "cloudfront:ListDistributions",
435
+ "cloudfront:TagResource",
436
+ "cloudfront:CreateOriginAccessControl",
437
+ "cloudfront:GetOriginAccessControl",
438
+ "cloudfront:ListOriginAccessControls",
439
+ "cloudfront:CreateResponseHeadersPolicy",
440
+ "cloudfront:GetResponseHeadersPolicy",
441
+ "cloudfront:GetResponseHeadersPolicyConfig",
442
+ "cloudfront:UpdateResponseHeadersPolicy",
443
+ "cloudfront:ListResponseHeadersPolicies"
444
+ ],
445
+ Resource: "*"
446
+ }]);
447
+ }
448
+ }
449
+ if (stageBackups(workspace, manifest, stage).mode === "on") {
450
+ const { scope } = deployIdentity(workspace, stage);
451
+ const user = backupsUserName(scope, stage);
452
+ const bucketIn = (account) => projectBucketName(scope, account);
453
+ describe.push(`create the project bucket ${bucketIn("<account>")} and keep its lifecycle, and create the backups user ${user} and its key (S3, IAM)`);
454
+ build.push((account) => [{
455
+ Sid: "StageBackupsBucket",
456
+ Effect: "Allow",
457
+ Action: ["s3:ListBucket", .../* @__PURE__ */ new Set([...PROJECT_BUCKET_CREATE_ACTIONS, ...PROJECT_BUCKET_LIFECYCLE_ACTIONS])],
458
+ Resource: `arn:aws:s3:::${bucketIn(account)}`
459
+ }, {
460
+ Sid: "StageBackupsUser",
461
+ Effect: "Allow",
462
+ Action: [
463
+ "iam:GetUser",
464
+ "iam:CreateUser",
465
+ "iam:TagUser",
466
+ "iam:ListUserTags",
467
+ "iam:GetUserPolicy",
468
+ "iam:PutUserPolicy",
469
+ "iam:ListAccessKeys",
470
+ "iam:CreateAccessKey",
471
+ "iam:DeleteAccessKey"
472
+ ],
473
+ Resource: `arn:aws:iam::${account}:user${IAM_USER_PATH}${user}`
474
+ }]);
475
+ }
476
+ for (const { domain, config } of stageDnsDomains(stage, workspace.domains, workspace.dns)) {
477
+ if (config.provider !== "route53") continue;
478
+ const zoneId = config.hostedZoneId?.replace(/^\/?hostedzone\//, "");
479
+ describe.push(`write the A, AAAA and CNAME records of ${domain} (Route53${zoneId ? `, ${zoneId}` : ""})`);
480
+ build.push(() => [
481
+ {
482
+ Sid: "StageDnsRecords",
483
+ Effect: "Allow",
484
+ Action: ["route53:ChangeResourceRecordSets", "route53:ListResourceRecordSets"],
485
+ Resource: `arn:aws:route53:::hostedzone/${zoneId ?? "*"}`
486
+ },
487
+ {
488
+ Sid: "StageDnsChanges",
489
+ Effect: "Allow",
490
+ Action: ["route53:GetChange"],
491
+ Resource: "arn:aws:route53:::change/*"
492
+ },
493
+ ...zoneId ? [] : [{
494
+ Sid: "StageDnsZones",
495
+ Effect: "Allow",
496
+ Action: ["route53:ListHostedZonesByName"],
497
+ Resource: "*"
498
+ }]
499
+ ]);
500
+ }
501
+ return {
502
+ kind: "scoped",
503
+ statements: (account) => build.flatMap((statements) => statements(account)),
504
+ describe
505
+ };
506
+ }
507
+ /**
508
+ * Reading and writing one stage's deploy state in `bucket`, as the deploy
509
+ * role is given it.
510
+ */
511
+ function stateBucketStatements(bucket, path) {
512
+ return [{
513
+ Sid: "StageState",
514
+ Effect: "Allow",
515
+ Action: [
516
+ "s3:GetObject",
517
+ "s3:PutObject",
518
+ "s3:DeleteObject"
519
+ ],
520
+ Resource: `arn:aws:s3:::${bucket}/${path}*`
521
+ }, {
522
+ Sid: "StageStateBucket",
523
+ Effect: "Allow",
524
+ Action: ["s3:ListBucket"],
525
+ Resource: `arn:aws:s3:::${bucket}`
526
+ }];
527
+ }
528
+ /** The scoped access as a policy document, or null when it allows nothing. */
529
+ function scopedPolicyDocument(statements) {
530
+ if (statements.length === 0) return null;
531
+ return JSON.stringify({
532
+ Version: "2012-10-17",
533
+ Statement: statements
534
+ });
535
+ }
536
+ /** The account an IAM ARN is in: `arn:aws:iam::<account>:…`. */
537
+ function accountOf(arn) {
538
+ return arn.split(":")[4] ?? "";
539
+ }
540
+ //#endregion
541
+ //#region src/deploy/github.ts
542
+ /**
543
+ * `gkm deploy:github` — let GitHub Actions deploy one stage, with no keys.
544
+ *
545
+ * A stage usually lives in its own AWS account — staging in one, production in
546
+ * another — so this runs once per stage, with that account's profile:
547
+ *
548
+ * gkm deploy:github --stage staging --profile acme-dev
549
+ * gkm deploy:github --stage prod --profile acme-prod
550
+ *
551
+ * In the stage's account it makes sure GitHub's OIDC provider exists, and a
552
+ * role that only this repository's `<stage>` environment can assume. On
553
+ * GitHub it creates that environment and gives it what the generated deploy
554
+ * workflow reads: `AWS_ROLE_ARN`, and — when the stage's secrets are kept in
555
+ * the local file — its key as `GKM_SECRETS_KEY`. With `secrets.store` set to
556
+ * S3, SSM or Secrets Manager the deploy job reads them with the role instead, so
557
+ * no key is handed to GitHub, and this checks the stage's store in the same
558
+ * account, with the same profile. Re-running it converges rather than duplicating.
559
+ *
560
+ * The role trusts the exact `sub` GitHub sends for the environment, read from
561
+ * the repository's OIDC subject settings (`githubOidc.ts`) — the default, the
562
+ * immutable subject with the owner's and repository's ids, or a custom
563
+ * template. A re-run rewrites an existing role's trust to it, so running this
564
+ * again repairs a role that trusted the wrong format. What the role may do is
565
+ * `githubPolicy.ts`: `AdministratorAccess` for SST, and for a compose stage
566
+ * only its own secrets (and deploy state, when that is in AWS).
567
+ */
568
+ const logger = console;
569
+ const GITHUB_OIDC_HOST = "token.actions.githubusercontent.com";
570
+ const AUDIENCE = "sts.amazonaws.com";
571
+ /**
572
+ * The tag recording which managed policy gkm attached to the role — so a
573
+ * re-run detaches only what gkm put there, never a policy someone else did.
574
+ */
575
+ const POLICY_TAG = "gkm:policy-arn";
576
+ /** The system's `gh`. */
577
+ const ghCli = (args, input) => execFileSync("gh", args, {
578
+ encoding: "utf-8",
579
+ stdio: [
580
+ "pipe",
581
+ "pipe",
582
+ "pipe"
583
+ ],
584
+ ...input === void 0 ? {} : { input }
585
+ }).trim();
586
+ /** The role a stage deploys as: `<project>-github-<stage>`, within IAM's 64. */
587
+ function roleName(project, stage) {
588
+ return `${project}-github-${stage}`.toLowerCase().replace(/[^a-z0-9+=,.@_-]/g, "-").slice(0, 64);
589
+ }
590
+ /**
591
+ * Who may assume the role: a workflow job whose OIDC token carries exactly
592
+ * `subject` — the repository's `<stage>` environment, in the format the
593
+ * repository sends (see `githubOidc.ts`), and nothing else. Not another
594
+ * branch's job, not another environment's: that is what keeps a staging
595
+ * deploy from using the production role.
596
+ */
597
+ function trustPolicy(providerArn, subject) {
598
+ return JSON.stringify({
599
+ Version: "2012-10-17",
600
+ Statement: [{
601
+ Effect: "Allow",
602
+ Principal: { Federated: providerArn },
603
+ Action: "sts:AssumeRoleWithWebIdentity",
604
+ Condition: { StringEquals: {
605
+ [`${GITHUB_OIDC_HOST}:aud`]: AUDIENCE,
606
+ [`${GITHUB_OIDC_HOST}:sub`]: subject
607
+ } }
608
+ }]
609
+ });
610
+ }
611
+ /**
612
+ * The subject a trust policy trusts, or undefined when it names none. IAM
613
+ * hands documents back URL-encoded.
614
+ */
615
+ function trustedSubject(document) {
616
+ if (!document) return void 0;
617
+ let parsed;
618
+ try {
619
+ parsed = JSON.parse(safeDecode(document));
620
+ } catch {
621
+ return;
622
+ }
623
+ for (const statement of parsed.Statement ?? []) for (const operator of Object.values(statement.Condition ?? {})) {
624
+ const value = operator[`${GITHUB_OIDC_HOST}:sub`];
625
+ if (typeof value === "string") return value;
626
+ if (Array.isArray(value)) return value.join(", ");
627
+ }
628
+ }
629
+ function safeDecode(value) {
630
+ try {
631
+ return decodeURIComponent(value);
632
+ } catch {
633
+ return value;
634
+ }
635
+ }
636
+ /** GitHub's OIDC provider in this account, created if it is not there. */
637
+ async function ensureOidcProvider(iam) {
638
+ const { OpenIDConnectProviderList = [] } = await iam.send(new ListOpenIDConnectProvidersCommand({}));
639
+ const existing = OpenIDConnectProviderList.find((p) => p.Arn?.endsWith(`oidc-provider/${GITHUB_OIDC_HOST}`))?.Arn;
640
+ if (existing) return existing;
641
+ return (await iam.send(new CreateOpenIDConnectProviderCommand({
642
+ Url: `https://${GITHUB_OIDC_HOST}`,
643
+ ClientIDList: [AUDIENCE]
644
+ }))).OpenIDConnectProviderArn;
645
+ }
646
+ function isNoSuchEntity(error) {
647
+ return error.name === "NoSuchEntityException";
648
+ }
649
+ /**
650
+ * The deploy role, created or brought back to this trust and access.
651
+ *
652
+ * Converges: re-running rewrites the trust, and moves the role from one access
653
+ * to another — detaching a managed policy only when the role's
654
+ * {@link POLICY_TAG} says gkm attached it.
655
+ */
656
+ async function ensureRole(iam, name, trust, access) {
657
+ let arn;
658
+ let created = false;
659
+ let previousSubject;
660
+ let recorded;
661
+ try {
662
+ const { Role } = await iam.send(new GetRoleCommand({ RoleName: name }));
663
+ previousSubject = trustedSubject(Role.AssumeRolePolicyDocument);
664
+ await iam.send(new UpdateAssumeRolePolicyCommand({
665
+ RoleName: name,
666
+ PolicyDocument: trust
667
+ }));
668
+ arn = Role.Arn;
669
+ const { Tags = [] } = await iam.send(new ListRoleTagsCommand({ RoleName: name }));
670
+ recorded = Tags.find((tag) => tag.Key === POLICY_TAG)?.Value;
671
+ } catch (error) {
672
+ if (!isNoSuchEntity(error)) throw error;
673
+ const { Role } = await iam.send(new CreateRoleCommand({
674
+ RoleName: name,
675
+ AssumeRolePolicyDocument: trust,
676
+ Description: "Deploys from GitHub Actions (gkm deploy:github)",
677
+ MaxSessionDuration: 7200
678
+ }));
679
+ arn = Role.Arn;
680
+ created = true;
681
+ }
682
+ const detached = [];
683
+ const leftAttached = [];
684
+ const detach = async (policyArn) => {
685
+ try {
686
+ await iam.send(new DetachRolePolicyCommand({
687
+ RoleName: name,
688
+ PolicyArn: policyArn
689
+ }));
690
+ detached.push(policyArn);
691
+ } catch (error) {
692
+ if (!isNoSuchEntity(error)) throw error;
693
+ }
694
+ };
695
+ const deleteInline = async () => {
696
+ try {
697
+ await iam.send(new DeleteRolePolicyCommand({
698
+ RoleName: name,
699
+ PolicyName: SCOPED_POLICY_NAME
700
+ }));
701
+ } catch (error) {
702
+ if (!isNoSuchEntity(error)) throw error;
703
+ }
704
+ };
705
+ if ("managed" in access) {
706
+ await iam.send(new AttachRolePolicyCommand({
707
+ RoleName: name,
708
+ PolicyArn: access.managed
709
+ }));
710
+ if (recorded && recorded !== access.managed) await detach(recorded);
711
+ if (recorded !== access.managed) await iam.send(new TagRoleCommand({
712
+ RoleName: name,
713
+ Tags: [{
714
+ Key: POLICY_TAG,
715
+ Value: access.managed
716
+ }]
717
+ }));
718
+ if (!created) await deleteInline();
719
+ return {
720
+ arn,
721
+ created,
722
+ previousSubject,
723
+ detached,
724
+ leftAttached
725
+ };
726
+ }
727
+ if (access.inline) await iam.send(new PutRolePolicyCommand({
728
+ RoleName: name,
729
+ PolicyName: SCOPED_POLICY_NAME,
730
+ PolicyDocument: access.inline
731
+ }));
732
+ else if (!created) await deleteInline();
733
+ if (created) return {
734
+ arn,
735
+ created,
736
+ previousSubject,
737
+ detached,
738
+ leftAttached
739
+ };
740
+ if (recorded) {
741
+ await detach(recorded);
742
+ await iam.send(new UntagRoleCommand({
743
+ RoleName: name,
744
+ TagKeys: [POLICY_TAG]
745
+ }));
746
+ }
747
+ const { AttachedPolicies = [] } = await iam.send(new ListAttachedRolePoliciesCommand({ RoleName: name }));
748
+ for (const policy of AttachedPolicies) if (policy.PolicyArn && !detached.includes(policy.PolicyArn)) leftAttached.push(policy.PolicyArn);
749
+ return {
750
+ arn,
751
+ created,
752
+ previousSubject,
753
+ detached,
754
+ leftAttached
755
+ };
756
+ }
757
+ /**
758
+ * An IAM client for the stage's account.
759
+ *
760
+ * `fromIni` for a named profile, deliberately: it resolves exactly that
761
+ * profile — keys, assume-role, `credential_process` or SSO, whichever
762
+ * ~/.aws/config says — and never falls back to AWS_* in the environment. The
763
+ * provider chain checks the environment first, so exported staging keys would
764
+ * quietly win over `--profile prod` and the production role would land in the
765
+ * staging account.
766
+ */
767
+ async function iamFor(profile, endpoint) {
768
+ const config = { region: "us-east-1" };
769
+ if (profile) {
770
+ const { fromIni } = await import("@aws-sdk/credential-providers");
771
+ config.credentials = fromIni({ profile });
772
+ }
773
+ if (endpoint) {
774
+ config.endpoint = endpoint;
775
+ config.credentials = {
776
+ accessKeyId: "test",
777
+ secretAccessKey: "test"
778
+ };
779
+ }
780
+ return new IAMClient(config);
781
+ }
782
+ async function deployGithubCommand(options, deps = {}) {
783
+ const gh = deps.gh ?? ghCli;
784
+ const { workspace } = await loadWorkspaceConfig(deps.cwd);
785
+ assertDeployedStage(workspace.stages, options.stage);
786
+ const repo = options.repo ?? gh([
787
+ "repo",
788
+ "view",
789
+ "--json",
790
+ "nameWithOwner",
791
+ "-q",
792
+ ".nameWithOwner"
793
+ ]);
794
+ const role = roleName(workspace.name, options.stage);
795
+ const oidc = resolveOidcSubject(gh, repo, options.stage);
796
+ const manifest = await discover({
797
+ patterns: constructGlobs(workspace),
798
+ cwd: workspace.root
799
+ });
800
+ const access = deployAccess(workspace, options.stage, options.policyArn, manifest);
801
+ const key = await readKey(options.stage, keystoreProject(workspace));
802
+ const keyPath = getKeyPath(options.stage, keystoreProject(workspace));
803
+ const hasKey = key !== null;
804
+ const remote = isRemoteStore(workspace, options.stage);
805
+ const store = await secretsStoreFor(workspace, options.stage, { ...options.profile ? { profile: options.profile } : {} });
806
+ const hasSecrets = remote && await store.read(options.stage) !== null;
807
+ const via = options.profile ? `profile "${options.profile}"` : "the default credentials";
808
+ logger.log(`\n🔐 GitHub → AWS for stage "${options.stage}"\n`);
809
+ logger.log(` Repository: ${repo}`);
810
+ logger.log(` AWS profile: ${options.profile ?? "(default credentials)"}`);
811
+ logger.log(` Role: ${role}`);
812
+ if (access.kind === "managed") logger.log(` Policy: ${access.policyArn} (${access.reason})`);
813
+ else if (access.describe.length > 0) {
814
+ logger.log(` Policy: inline "${SCOPED_POLICY_NAME}", scoped to the compose deploy — only:`);
815
+ for (const line of access.describe) logger.log(` ${line}`);
816
+ } else logger.log(" Policy: none — a compose deploy with file secrets and local state reads nothing from AWS");
817
+ logger.log(` Trusted by: ${oidc.subject} only (${SUBJECT_KINDS[oidc.kind]})`);
818
+ if (oidc.warning) logger.log(` ⚠ ${oidc.warning}`);
819
+ 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}`}`);
820
+ else logger.log(` Secrets key: ${hasKey ? keyPath : `none at ${keyPath} — run gkm secrets:init --stage ${options.stage} first`}`);
821
+ if (options.dryRun) {
822
+ if (access.kind === "scoped") {
823
+ const document = scopedPolicyDocument(access.statements("<account>"));
824
+ if (document) logger.log(`\n Inline policy:\n${JSON.stringify(JSON.parse(document), null, 2).replace(/^/gm, " ")}`);
825
+ }
826
+ logger.log("\n --dry-run: nothing changed.\n");
827
+ return {
828
+ repo,
829
+ subject: oidc.subject
830
+ };
831
+ }
832
+ const iam = deps.iam ?? await iamFor(options.profile);
833
+ const providerArn = await ensureOidcProvider(iam).catch((error) => {
834
+ if (/SSO session/i.test(String(error?.message)) && options.profile) throw new SsoSessionExpired(options.profile);
835
+ throw error;
836
+ });
837
+ const outcome = await ensureRole(iam, role, trustPolicy(providerArn, oidc.subject), access.kind === "managed" ? { managed: access.policyArn } : { inline: scopedPolicyDocument(access.statements(accountOf(providerArn))) });
838
+ const roleArn = outcome.arn;
839
+ logger.log(`\n ✓ AWS: ${roleArn}${outcome.created ? " (created)" : ""}`);
840
+ if (!outcome.created) logger.log(outcome.previousSubject === oidc.subject ? ` ✓ Trust: unchanged, ${oidc.subject}` : ` ✓ Trust: ${outcome.previousSubject ?? "(no subject)"} → ${oidc.subject}`);
841
+ for (const detached of outcome.detached) logger.log(` ✓ Detached ${detached} (attached by gkm, no longer needed)`);
842
+ 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}` : ""}`);
843
+ gh([
844
+ "api",
845
+ "--method",
846
+ "PUT",
847
+ `repos/${repo}/environments/${options.stage}`
848
+ ]);
849
+ gh([
850
+ "variable",
851
+ "set",
852
+ "AWS_ROLE_ARN",
853
+ "--env",
854
+ options.stage,
855
+ "--repo",
856
+ repo,
857
+ "--body",
858
+ roleArn
859
+ ]);
860
+ logger.log(` ✓ GitHub: environment "${options.stage}", AWS_ROLE_ARN`);
861
+ if (remote) {
862
+ 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})` : ""}.`);
863
+ } else if (hasKey) {
864
+ gh([
865
+ "secret",
866
+ "set",
867
+ "GKM_SECRETS_KEY",
868
+ "--env",
869
+ options.stage,
870
+ "--repo",
871
+ repo
872
+ ], key);
873
+ logger.log(" ✓ GitHub: GKM_SECRETS_KEY");
874
+ } else logger.log(` ⚠ No secrets key for "${options.stage}"; run gkm secrets:init --stage ${options.stage}, then this again.`);
875
+ logger.log(`\n Protect it: add required reviewers to the "${options.stage}" environment in the repository settings.\n`);
876
+ return {
877
+ roleArn,
878
+ repo,
879
+ subject: oidc.subject
880
+ };
881
+ }
882
+ const SUBJECT_KINDS = {
883
+ default: "the repository's default subject",
884
+ immutable: "the repository's immutable subject",
885
+ custom: "the repository's custom subject template",
886
+ assumed: "assumed: the default format"
887
+ };
888
+ /** The profile's SSO login has lapsed; the fix is one command away. */
889
+ var SsoSessionExpired = class extends GkmError {
890
+ profile;
891
+ constructor(profile) {
892
+ super(`The SSO session for profile "${profile}" has expired or is invalid. Run: aws sso login --profile ${profile}`);
893
+ this.profile = profile;
894
+ this.name = "SsoSessionExpired";
895
+ }
896
+ };
897
+ //#endregion
898
+ export { deployGithubCommand, ghCli };
899
+
900
+ //# sourceMappingURL=github-Dc1daUbH.mjs.map