@geekmidas/cli 10.0.0-alpha.139 → 10.0.0-alpha.140
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.
- package/dist/{EndpointGenerator-DDfPq2AZ.mjs → EndpointGenerator-BMRL04ic.mjs} +2 -2
- package/dist/{EndpointGenerator-DDfPq2AZ.mjs.map → EndpointGenerator-BMRL04ic.mjs.map} +1 -1
- package/dist/{EndpointGenerator-BGKb_Ie6.cjs → EndpointGenerator-ePscnbwB.cjs} +2 -2
- package/dist/{EndpointGenerator-BGKb_Ie6.cjs.map → EndpointGenerator-ePscnbwB.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-baMIwhIy.mjs → GoDaddyProvider-BgY6mqoH.mjs} +42 -17
- package/dist/GoDaddyProvider-BgY6mqoH.mjs.map +1 -0
- package/dist/{GoDaddyProvider-DA0rzRQt.cjs → GoDaddyProvider-C-rs22Zv.cjs} +42 -17
- package/dist/GoDaddyProvider-C-rs22Zv.cjs.map +1 -0
- package/dist/{HostingerProvider-Cjh_2Ml6.mjs → HostingerProvider-CgMuKgO_.mjs} +13 -4
- package/dist/HostingerProvider-CgMuKgO_.mjs.map +1 -0
- package/dist/{HostingerProvider-OdQmKXE3.cjs → HostingerProvider-DEqpvoiD.cjs} +13 -4
- package/dist/HostingerProvider-DEqpvoiD.cjs.map +1 -0
- package/dist/{LegacyStateStore-h1u5xlpb.cjs → LegacyStateStore-6xskEtld.cjs} +3 -3
- package/dist/{LegacyStateStore-h1u5xlpb.cjs.map → LegacyStateStore-6xskEtld.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BSrw1yNS.mjs → LegacyStateStore-Dx65SWE9.mjs} +3 -3
- package/dist/{LegacyStateStore-BSrw1yNS.mjs.map → LegacyStateStore-Dx65SWE9.mjs.map} +1 -1
- package/dist/{LocalStateStore-HmKqUWkF.cjs → LocalStateStore-DFtTtHty.cjs} +2 -2
- package/dist/{LocalStateStore-HmKqUWkF.cjs.map → LocalStateStore-DFtTtHty.cjs.map} +1 -1
- package/dist/{LocalStateStore-BlH6Eanc.mjs → LocalStateStore-Dto39TCx.mjs} +2 -2
- package/dist/{LocalStateStore-BlH6Eanc.mjs.map → LocalStateStore-Dto39TCx.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-DSy2gbfi.mjs → OpenApiTsGenerator-B-PQLx8X.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-DSy2gbfi.mjs.map → OpenApiTsGenerator-B-PQLx8X.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-B33Y_6oe.cjs → OpenApiTsGenerator-BvacdbiG.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-B33Y_6oe.cjs.map → OpenApiTsGenerator-BvacdbiG.cjs.map} +1 -1
- package/dist/{S3StateStore-Ccz7J7Cf.cjs → S3StateStore-B-9ea-sX.cjs} +2 -2
- package/dist/{S3StateStore-Ccz7J7Cf.cjs.map → S3StateStore-B-9ea-sX.cjs.map} +1 -1
- package/dist/{S3StateStore-CwVWjNXJ.mjs → S3StateStore-C01zMOYm.mjs} +2 -2
- package/dist/{S3StateStore-CwVWjNXJ.mjs.map → S3StateStore-C01zMOYm.mjs.map} +1 -1
- package/dist/{SSMStateStore-CAxcx0U2.cjs → SSMStateStore-CKArcPUh.cjs} +2 -2
- package/dist/{SSMStateStore-CAxcx0U2.cjs.map → SSMStateStore-CKArcPUh.cjs.map} +1 -1
- package/dist/{SSMStateStore-CASt-lob.mjs → SSMStateStore-k-4XM7mb.mjs} +2 -2
- package/dist/{SSMStateStore-CASt-lob.mjs.map → SSMStateStore-k-4XM7mb.mjs.map} +1 -1
- package/dist/{SubscriberGenerator-zUd87wvg.mjs → SubscriberGenerator-DLPH-ynS.mjs} +148 -11
- package/dist/SubscriberGenerator-DLPH-ynS.mjs.map +1 -0
- package/dist/{SubscriberGenerator-DDCqRTbq.cjs → SubscriberGenerator-DR4Y7ihK.cjs} +170 -9
- package/dist/SubscriberGenerator-DR4Y7ihK.cjs.map +1 -0
- package/dist/{add-Cq7B_VSJ.cjs → add-BgzsYxUq.cjs} +6 -6
- package/dist/{add-Cq7B_VSJ.cjs.map → add-BgzsYxUq.cjs.map} +1 -1
- package/dist/{add-6tyL4tWq.mjs → add-CiIrpOb9.mjs} +6 -6
- package/dist/{add-6tyL4tWq.mjs.map → add-CiIrpOb9.mjs.map} +1 -1
- package/dist/{bundler-CXuVyqXY.mjs → bundler-C4uMSy8e.mjs} +5 -5
- package/dist/{bundler-CXuVyqXY.mjs.map → bundler-C4uMSy8e.mjs.map} +1 -1
- package/dist/{bundler-DRmdcbXx.cjs → bundler-DKxuDoVL.cjs} +5 -5
- package/dist/{bundler-DRmdcbXx.cjs.map → bundler-DKxuDoVL.cjs.map} +1 -1
- package/dist/{cli-DxtrQdRa.mjs → cli-Bm2is6R_.mjs} +3 -3
- package/dist/{cli-DxtrQdRa.mjs.map → cli-Bm2is6R_.mjs.map} +1 -1
- package/dist/{cli-DYru-gjk.cjs → cli-na0npMhC.cjs} +3 -3
- package/dist/{cli-DYru-gjk.cjs.map → cli-na0npMhC.cjs.map} +1 -1
- package/dist/{compose-Bdx2rqtO.mjs → compose-CVatM7Cl.mjs} +31 -7
- package/dist/compose-CVatM7Cl.mjs.map +1 -0
- package/dist/{compose-DJMHSSDI.cjs → compose-D8U9ygdm.cjs} +31 -7
- package/dist/compose-D8U9ygdm.cjs.map +1 -0
- package/dist/{config-B7HaIfYM.d.mts → config-BbivVpq0.d.mts} +3 -3
- package/dist/{config-B7HaIfYM.d.mts.map → config-BbivVpq0.d.mts.map} +1 -1
- package/dist/{config-DySjXKd2.d.cts → config-BcL1Fojs.d.cts} +3 -3
- package/dist/{config-DySjXKd2.d.cts.map → config-BcL1Fojs.d.cts.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +2 -2
- package/dist/{credentialSchemas-DYzO2_yG.mjs → credentialSchemas-DUCSYl9a.mjs} +2 -2
- package/dist/{credentialSchemas-DYzO2_yG.mjs.map → credentialSchemas-DUCSYl9a.mjs.map} +1 -1
- package/dist/{credentialSchemas-BJMvQlks.cjs → credentialSchemas-DZ2Nh5li.cjs} +2 -2
- package/dist/{credentialSchemas-BJMvQlks.cjs.map → credentialSchemas-DZ2Nh5li.cjs.map} +1 -1
- package/dist/deploy/public.cjs +8 -8
- package/dist/deploy/public.d.cts +3 -8
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +3 -8
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +8 -8
- package/dist/{deploy-o5n6l4MO.mjs → deploy-CDcO08Xz.mjs} +457 -47
- package/dist/deploy-CDcO08Xz.mjs.map +1 -0
- package/dist/{deploy-88E_1bHW.cjs → deploy-DrQB7ytj.cjs} +457 -46
- package/dist/deploy-DrQB7ytj.cjs.map +1 -0
- package/dist/{discover-DWtHjc1x.mjs → discover-B2m8ytyq.mjs} +2 -2
- package/dist/{discover-DWtHjc1x.mjs.map → discover-B2m8ytyq.mjs.map} +1 -1
- package/dist/{discover-B3G8eyWX.cjs → discover-yqeJ2Bx7.cjs} +2 -2
- package/dist/{discover-B3G8eyWX.cjs.map → discover-yqeJ2Bx7.cjs.map} +1 -1
- package/dist/{dokploy-al6V2P9s.cjs → dokploy-BKjPDvSN.cjs} +2 -2
- package/dist/{dokploy-al6V2P9s.cjs.map → dokploy-BKjPDvSN.cjs.map} +1 -1
- package/dist/{dokploy-C1QCPJ1t.mjs → dokploy-k4_ZN8zN.mjs} +2 -2
- package/dist/{dokploy-C1QCPJ1t.mjs.map → dokploy-k4_ZN8zN.mjs.map} +1 -1
- package/dist/{eas-D0jmXv7F.mjs → eas-B1wBvwPH.mjs} +2 -2
- package/dist/{eas-D0jmXv7F.mjs.map → eas-B1wBvwPH.mjs.map} +1 -1
- package/dist/{eas-DAsdU35R.cjs → eas-Bg4dI6n2.cjs} +2 -2
- package/dist/{eas-DAsdU35R.cjs.map → eas-Bg4dI6n2.cjs.map} +1 -1
- package/dist/{encryption-G8Ouiy55.mjs → encryption-Bve0PVOo.mjs} +3 -3
- package/dist/{encryption-G8Ouiy55.mjs.map → encryption-Bve0PVOo.mjs.map} +1 -1
- package/dist/{encryption-C5c50qvt.cjs → encryption-DL_y8t6V.cjs} +3 -3
- package/dist/{encryption-C5c50qvt.cjs.map → encryption-DL_y8t6V.cjs.map} +1 -1
- package/dist/{engine-9C68_A78.cjs → engine-BhR5lt_V.cjs} +5 -5
- package/dist/{engine-9C68_A78.cjs.map → engine-BhR5lt_V.cjs.map} +1 -1
- package/dist/{engine-bEuItjJN.mjs → engine-HMLf20iZ.mjs} +5 -5
- package/dist/{engine-bEuItjJN.mjs.map → engine-HMLf20iZ.mjs.map} +1 -1
- package/dist/{github-R-Pot7QV.cjs → github-B2hJVl-n.cjs} +6 -6
- package/dist/{github-R-Pot7QV.cjs.map → github-B2hJVl-n.cjs.map} +1 -1
- package/dist/{github-Buh2ldNN.mjs → github-DKn9ACi2.mjs} +6 -6
- package/dist/{github-Buh2ldNN.mjs.map → github-DKn9ACi2.mjs.map} +1 -1
- package/dist/{googlePlay-B_X_DJp0.mjs → googlePlay-CWq7ND_X.mjs} +3 -3
- package/dist/{googlePlay-B_X_DJp0.mjs.map → googlePlay-CWq7ND_X.mjs.map} +1 -1
- package/dist/{googlePlay-Bi5qneXA.cjs → googlePlay-DtuN0-7D.cjs} +3 -3
- package/dist/{googlePlay-Bi5qneXA.cjs.map → googlePlay-DtuN0-7D.cjs.map} +1 -1
- package/dist/{index-CTKfBwU3.d.cts → index-BZZeEWug.d.mts} +2 -2
- package/dist/{index-BymyHYdL.d.mts.map → index-BZZeEWug.d.mts.map} +1 -1
- package/dist/{index-BymyHYdL.d.mts → index-C1jffZ5_.d.cts} +2 -2
- package/dist/{index-CTKfBwU3.d.cts.map → index-C1jffZ5_.d.cts.map} +1 -1
- package/dist/index.cjs +61 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +61 -61
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-DjCvZL4P.cjs → migrate-BLVZqHtN.cjs} +3 -3
- package/dist/{migrate-DjCvZL4P.cjs.map → migrate-BLVZqHtN.cjs.map} +1 -1
- package/dist/{migrate-WkC0pay4.mjs → migrate-DCvD4RJW.mjs} +4 -4
- package/dist/{migrate-WkC0pay4.mjs.map → migrate-DCvD4RJW.mjs.map} +1 -1
- package/dist/{migrate-C9abovJK.mjs → migrate-W0ruUNb9.mjs} +3 -3
- package/dist/{migrate-C9abovJK.mjs.map → migrate-W0ruUNb9.mjs.map} +1 -1
- package/dist/{migrate-Bv4AqxYP.cjs → migrate-iUui7B4q.cjs} +4 -4
- package/dist/{migrate-Bv4AqxYP.cjs.map → migrate-iUui7B4q.cjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/{publish-BbJ7Ols2.cjs → publish-CqvDA5ry.cjs} +2 -2
- package/dist/{publish-BbJ7Ols2.cjs.map → publish-CqvDA5ry.cjs.map} +1 -1
- package/dist/{publish-BVsLFs-n.mjs → publish-CxIBBD3b.mjs} +2 -2
- package/dist/{publish-BVsLFs-n.mjs.map → publish-CxIBBD3b.mjs.map} +1 -1
- package/dist/{ready-B_to-BSY.mjs → ready-CGqJ74Kt.mjs} +5 -5
- package/dist/{ready-B_to-BSY.mjs.map → ready-CGqJ74Kt.mjs.map} +1 -1
- package/dist/{ready-C-nMK_FB.cjs → ready-DuU0FXSj.cjs} +5 -5
- package/dist/{ready-C-nMK_FB.cjs.map → ready-DuU0FXSj.cjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-CBEFNYca.cjs → resolve-BEVVvi13.cjs} +3 -3
- package/dist/{resolve-CBEFNYca.cjs.map → resolve-BEVVvi13.cjs.map} +1 -1
- package/dist/{resolve-CTYtfl0x.mjs → resolve-CMC0MI0Z.mjs} +3 -3
- package/dist/{resolve-CTYtfl0x.mjs.map → resolve-CMC0MI0Z.mjs.map} +1 -1
- package/dist/{rollback-BT6oPcnZ.mjs → rollback-CZiQkukY.mjs} +5 -5
- package/dist/{rollback-BT6oPcnZ.mjs.map → rollback-CZiQkukY.mjs.map} +1 -1
- package/dist/{rollback-RzUJ728z.cjs → rollback-e0zGkaBx.cjs} +5 -5
- package/dist/{rollback-RzUJ728z.cjs.map → rollback-e0zGkaBx.cjs.map} +1 -1
- package/dist/{runtime-mR2O0z64.d.mts → runtime-Bvgyxm88.d.cts} +2 -2
- package/dist/{runtime-Dl601UcU.d.cts.map → runtime-Bvgyxm88.d.cts.map} +1 -1
- package/dist/{runtime-Dl601UcU.d.cts → runtime-CeAt1IJd.d.mts} +2 -2
- package/dist/{runtime-mR2O0z64.d.mts.map → runtime-CeAt1IJd.d.mts.map} +1 -1
- package/dist/{s3-BUkV5_fV.cjs → s3-BKnL6YGQ.cjs} +2 -2
- package/dist/{s3-BUkV5_fV.cjs.map → s3-BKnL6YGQ.cjs.map} +1 -1
- package/dist/{s3-VpdagzYE.mjs → s3-DW7SLsb8.mjs} +2 -2
- package/dist/{s3-VpdagzYE.mjs.map → s3-DW7SLsb8.mjs.map} +1 -1
- package/dist/sandbox/credentials-worker.cjs +2 -2
- package/dist/sandbox/credentials-worker.mjs +2 -2
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox/migrate-worker.cjs +1 -1
- package/dist/sandbox/migrate-worker.mjs +1 -1
- package/dist/{seeds-CcK_C30B.cjs → seeds-BR_7hJTw.cjs} +122 -13
- package/dist/seeds-BR_7hJTw.cjs.map +1 -0
- package/dist/{seeds-CSNYLc4p.mjs → seeds-nCxxlP5h.mjs} +111 -14
- package/dist/seeds-nCxxlP5h.mjs.map +1 -0
- package/dist/{serverSetup-DiJPhPOz.mjs → serverSetup-C3Tt9X1R.mjs} +6 -6
- package/dist/{serverSetup-DiJPhPOz.mjs.map → serverSetup-C3Tt9X1R.mjs.map} +1 -1
- package/dist/{serverSetup-C2U4-2i0.cjs → serverSetup-D2Xzsp2t.cjs} +6 -6
- package/dist/{serverSetup-C2U4-2i0.cjs.map → serverSetup-D2Xzsp2t.cjs.map} +1 -1
- package/dist/{sniffer-B1iineXX.cjs → sniffer-BWgXPFAt.cjs} +8 -8
- package/dist/{sniffer-B1iineXX.cjs.map → sniffer-BWgXPFAt.cjs.map} +1 -1
- package/dist/{sniffer-z-p2lTtc.mjs → sniffer-eEF_fIId.mjs} +8 -8
- package/dist/{sniffer-z-p2lTtc.mjs.map → sniffer-eEF_fIId.mjs.map} +1 -1
- package/dist/{snsSubscriptions-CYy7Faid.mjs → snsSubscriptions-BSoqUgsq.mjs} +28 -13
- package/dist/snsSubscriptions-BSoqUgsq.mjs.map +1 -0
- package/dist/{snsSubscriptions-C7wClS6U.cjs → snsSubscriptions-Y9declDd.cjs} +28 -13
- package/dist/snsSubscriptions-Y9declDd.cjs.map +1 -0
- package/dist/{stage-Cn3EEIB9.cjs → stage-BEcxppsu.cjs} +6 -6
- package/dist/{stage-Cn3EEIB9.cjs.map → stage-BEcxppsu.cjs.map} +1 -1
- package/dist/{stage-Cx1KKX_o.mjs → stage-DhcbcAar.mjs} +6 -6
- package/dist/{stage-Cx1KKX_o.mjs.map → stage-DhcbcAar.mjs.map} +1 -1
- package/dist/{stages-CuV3zh-h.cjs → stages--icWbhPy.cjs} +2 -2
- package/dist/{stages-CuV3zh-h.cjs.map → stages--icWbhPy.cjs.map} +1 -1
- package/dist/{stages-COSKjrfd.mjs → stages-CUwSy39f.mjs} +2 -2
- package/dist/{stages-COSKjrfd.mjs.map → stages-CUwSy39f.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-BIZRxV-e.cjs → terminal-DURcYlVX.cjs} +2 -2
- package/dist/{terminal-BIZRxV-e.cjs.map → terminal-DURcYlVX.cjs.map} +1 -1
- package/dist/{terminal-PEvt24kO.mjs → terminal-yOZ7kKF9.mjs} +2 -2
- package/dist/{terminal-PEvt24kO.mjs.map → terminal-yOZ7kKF9.mjs.map} +1 -1
- package/dist/{types-DOYYfQme.d.cts → types-C6hDCkV2.d.mts} +168 -129
- package/dist/types-C6hDCkV2.d.mts.map +1 -0
- package/dist/{types-C-uwKr3O.d.mts → types-Dy1eV7yc.d.cts} +169 -128
- package/dist/types-Dy1eV7yc.d.cts.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-aiDQZMje.mjs → workspace-BbfBFtjn.mjs} +95 -10
- package/dist/workspace-BbfBFtjn.mjs.map +1 -0
- package/dist/{workspace-secxwA6K.cjs → workspace-Dkm3HL9e.cjs} +118 -9
- package/dist/workspace-Dkm3HL9e.cjs.map +1 -0
- package/package.json +16 -15
- package/dist/GoDaddyProvider-DA0rzRQt.cjs.map +0 -1
- package/dist/GoDaddyProvider-baMIwhIy.mjs.map +0 -1
- package/dist/HostingerProvider-Cjh_2Ml6.mjs.map +0 -1
- package/dist/HostingerProvider-OdQmKXE3.cjs.map +0 -1
- package/dist/SubscriberGenerator-DDCqRTbq.cjs.map +0 -1
- package/dist/SubscriberGenerator-zUd87wvg.mjs.map +0 -1
- package/dist/compose-Bdx2rqtO.mjs.map +0 -1
- package/dist/compose-DJMHSSDI.cjs.map +0 -1
- package/dist/deploy-88E_1bHW.cjs.map +0 -1
- package/dist/deploy-o5n6l4MO.mjs.map +0 -1
- package/dist/seeds-CSNYLc4p.mjs.map +0 -1
- package/dist/seeds-CcK_C30B.cjs.map +0 -1
- package/dist/snsSubscriptions-C7wClS6U.cjs.map +0 -1
- package/dist/snsSubscriptions-CYy7Faid.mjs.map +0 -1
- package/dist/types-C-uwKr3O.d.mts.map +0 -1
- package/dist/types-DOYYfQme.d.cts.map +0 -1
- package/dist/workspace-aiDQZMje.mjs.map +0 -1
- package/dist/workspace-secxwA6K.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stages-CuV3zh-h.cjs","names":["UndeclaredStage","GkmError","s3SecretsLocation","loadWorkspaceSettings","appendFile","GkmError"],"sources":["../src/stages/plan.ts","../src/stages/index.ts"],"sourcesContent":["/**\n * Which stages a workflow run builds and deploys, from the event that started\n * it and the project's `stages`.\n *\n * The rules live here, in tested code, rather than in a workflow's YAML or in\n * the action that runs `gkm stages --github-output`: a project's deploy\n * workflow names no stage, and what it does for each event is decided by the\n * CLI the project installed.\n *\n * | event | build | deploy |\n * | ------------------- | ------------------ | ------------------------------- |\n * | `push` | every deployed | deployed, less the protected |\n * | `release` | none | the protected |\n * | `workflow_dispatch` | none | the one stage named |\n * | anything else | none | none |\n *\n * A push builds every deployed stage, protected ones included, so a release\n * deploys images built from the very commit its tag names; a release and a\n * manual run deploy what a push already built.\n */\n\nimport { GkmError } from '../errors';\nimport { UndeclaredStage } from '../workspace/stages.js';\nimport type { StagesConfig } from '../workspace/types.js';\n\nexport interface StagePlan {\n\t/** The stages whose images this run builds and pushes. */\n\tbuild: string[];\n\t/** The stages this run deploys. */\n\tdeploy: string[];\n}\n\nexport interface PlanInput {\n\t/** The GitHub event name: `push`, `release`, `workflow_dispatch`, … */\n\tevent: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport function planStages(stages: StagesConfig, input: PlanInput): StagePlan {\n\tconst kept = stages.protected ?? [];\n\n\tswitch (input.event) {\n\t\tcase 'push':\n\t\t\treturn {\n\t\t\t\tbuild: [...stages.deployed],\n\t\t\t\tdeploy: stages.deployed.filter((stage) => !kept.includes(stage)),\n\t\t\t};\n\t\tcase 'release':\n\t\t\treturn { build: [], deploy: [...kept] };\n\t\tcase 'workflow_dispatch': {\n\t\t\tconst stage = input.stage?.trim();\n\t\t\tif (!stage) throw new DispatchNamesNoStage(stages.deployed);\n\t\t\tif (!stages.deployed.includes(stage)) {\n\t\t\t\tthrow new UndeclaredStage(stage, stages.deployed);\n\t\t\t}\n\t\t\treturn { build: [], deploy: [stage] };\n\t\t}\n\t\tdefault:\n\t\t\treturn { build: [], deploy: [] };\n\t}\n}\n\n/**\n * A manual run with no stage. Refused rather than read as \"nothing to do\", so\n * a run started with the field left empty fails where it can be seen.\n */\nexport class DispatchNamesNoStage extends GkmError {\n\tconstructor(readonly deployed: readonly string[]) {\n\t\tsuper(\n\t\t\t`A manual run deploys one stage, and none was given. Run the workflow again with stage set to one of: ${deployed.join(', ') || 'nothing yet — gkm.config.ts deploys to no stage'}.`,\n\t\t);\n\t\tthis.name = 'DispatchNamesNoStage';\n\t}\n}\n","/**\n * `gkm stages` — the workspace's stages, as gkm.config.ts declares them.\n *\n * ```bash\n * gkm stages # a table\n * gkm stages --json # {\"local\":\"dev\",\"deployed\":[\"prod\"],\"protected\":[\"prod\"]}\n * gkm stages --github-output # a workflow run's build and deploy matrices\n * ```\n *\n * The config is read by the normal loader (and sandbox), so a workflow never\n * parses TypeScript to learn which stages exist. `--github-output` is what the\n * `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and\n * which of them this run builds and deploys, to `$GITHUB_OUTPUT`.\n */\n\nimport { appendFile } from 'node:fs/promises';\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { s3SecretsLocation } from '../secrets/providers.js';\nimport type { NormalizedWorkspace, StagesConfig } from '../workspace/types.js';\nimport { planStages } from './plan.js';\n\nexport { DispatchNamesNoStage, type PlanInput, planStages } from './plan.js';\n\nexport interface StagesOptions {\n\t/** Print the stages as JSON. */\n\tjson?: boolean;\n\t/** Write the outputs a deploy workflow reads to `$GITHUB_OUTPUT`. */\n\tgithubOutput?: boolean;\n\t/** The event to plan for; defaults to `GITHUB_EVENT_NAME`. */\n\tevent?: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport interface StagesDeps {\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Where lines go; stdout by default. */\n\tlog?: (line: string) => void;\n}\n\n/** The stages, as `gkm stages --json` prints them. */\nexport interface StagesJson {\n\tlocal: string;\n\tdeployed: string[];\n\tprotected: string[];\n}\n\nexport function stagesJson(stages: StagesConfig): StagesJson {\n\treturn {\n\t\tlocal: stages.local,\n\t\tdeployed: [...stages.deployed],\n\t\tprotected: [...(stages.protected ?? [])],\n\t};\n}\n\n/**\n * The region of the workspace's AWS secrets store — `s3`, `ssm` or\n * `secrets-manager` — or `''` when its deployed stages keep their secrets\n * anywhere else. A job assumes the stage's AWS role only when this is set.\n */\nexport function awsSecretsRegion(workspace: NormalizedWorkspace): string {\n\tconst store = workspace.secrets?.store;\n\tif (typeof store !== 'object' || store === null) return '';\n\tif (store.provider === 's3') {\n\t\treturn s3SecretsLocation(store, workspace.state).region;\n\t}\n\tif (store.provider === 'ssm' || store.provider === 'secrets-manager') {\n\t\treturn store.region;\n\t}\n\treturn '';\n}\n\n/**\n * The host a workflow logs in to for `deploy.registry`, as Docker reads an\n * image name: the first part when it names a host (a dot, a port, or\n * `localhost`), Docker Hub's `docker.io` for a bare namespace, and `''` when\n * no registry is set. Read at run time, so a workflow follows the config\n * rather than what it said when the workflow was written.\n */\nexport function registryHost(workspace: NormalizedWorkspace): string {\n\tconst registry = workspace.deploy?.registry?.trim();\n\tif (!registry) return '';\n\tconst first = registry.split('/')[0]!;\n\treturn first.includes('.') || first.includes(':') || first === 'localhost'\n\t\t? first\n\t\t: 'docker.io';\n}\n\n/**\n * Every output the stages action sets, each a string `fromJSON()` reads, for\n * one workflow run.\n */\nexport function githubOutputs(\n\tworkspace: NormalizedWorkspace,\n\tinput: { event: string; stage?: string },\n): Record<string, string> {\n\tconst stages = stagesJson(workspace.stages);\n\tconst plan = planStages(workspace.stages, input);\n\n\treturn {\n\t\tlocal: JSON.stringify(stages.local),\n\t\tdeployed: JSON.stringify(stages.deployed),\n\t\tprotected: JSON.stringify(stages.protected),\n\t\tbuild: JSON.stringify(plan.build),\n\t\tdeploy: JSON.stringify(plan.deploy),\n\t\t// A matrix over an empty list is an error on GitHub, so a job over one\n\t\t// is skipped on these instead.\n\t\t'has-build': String(plan.build.length > 0),\n\t\t'has-deploy': String(plan.deploy.length > 0),\n\t\t'aws-region': awsSecretsRegion(workspace),\n\t\tregistry: registryHost(workspace),\n\t};\n}\n\n/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */\nexport function formatGithubOutputs(outputs: Record<string, string>): string {\n\treturn Object.entries(outputs)\n\t\t.map(([name, value]) => `${name}=${value}\\n`)\n\t\t.join('');\n}\n\n/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */\nfunction workflowCommandData(message: string): string {\n\treturn message\n\t\t.replaceAll('%', '%25')\n\t\t.replaceAll('\\r', '%0D')\n\t\t.replaceAll('\\n', '%0A');\n}\n\nfunction table(stages: StagesJson): string {\n\tconst rows: [string, string][] = [\n\t\t['STAGE', 'KIND'],\n\t\t[stages.local, 'local'],\n\t\t...stages.deployed.map((name): [string, string] => [\n\t\t\tname,\n\t\t\tstages.protected.includes(name) ? 'deployed, protected' : 'deployed',\n\t\t]),\n\t];\n\tconst width = Math.max(...rows.map(([name]) => name.length));\n\treturn rows\n\t\t.map(([name, kind]) => `${name.padEnd(width)} ${kind}`)\n\t\t.join('\\n');\n}\n\nexport async function stagesCommand(\n\toptions: StagesOptions,\n\tdeps: StagesDeps = {},\n): Promise<void> {\n\tconst env = deps.env ?? process.env;\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\n\tif (!options.githubOutput) {\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst stages = stagesJson(workspace.stages);\n\t\tlog(options.json ? JSON.stringify(stages) : table(stages));\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst file = env.GITHUB_OUTPUT;\n\t\tif (!file) throw new GithubOutputNotSet();\n\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst event = options.event || env.GITHUB_EVENT_NAME;\n\t\tif (!event) throw new GithubEventNotSet();\n\n\t\tconst outputs = githubOutputs(workspace, {\n\t\t\tevent,\n\t\t\t...(options.stage ? { stage: options.stage } : {}),\n\t\t});\n\t\tawait appendFile(file, formatGithubOutputs(outputs));\n\n\t\tlog(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);\n\t} catch (error) {\n\t\t// Annotated on the run, where whoever started it looks first.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlog(`::error title=gkm stages::${workflowCommandData(message)}`);\n\t\tthrow error;\n\t}\n}\n\n/** `--github-output` outside a GitHub Actions step, which sets the file. */\nexport class GithubOutputNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output writes to the file GITHUB_OUTPUT names, and it is not set. Run it in a GitHub Actions step, or set GITHUB_OUTPUT to a file to write to.',\n\t\t);\n\t\tthis.name = 'GithubOutputNotSet';\n\t}\n}\n\n/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */\nexport class GithubEventNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output plans for an event, and none was given. Pass --event (push, release, workflow_dispatch), or run it in a GitHub Actions step, which sets GITHUB_EVENT_NAME.',\n\t\t);\n\t\tthis.name = 'GithubEventNotSet';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,WAAW,QAAsB,OAA6B;CAC7E,MAAM,OAAO,OAAO,aAAa,CAAC;CAElC,QAAQ,MAAM,OAAd;EACC,KAAK,QACJ,OAAO;GACN,OAAO,CAAC,GAAG,OAAO,QAAQ;GAC1B,QAAQ,OAAO,SAAS,QA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AC,CACvD,KAAK,IAAI;AACZ;AAEA,eAAsB,cACrB,SACA,OAAmB,CAAC,GACJ;CAChB,MAAM,MAAM,KAAK,OAAO,QAAQ;CAChC,MAAM,MAAM,KAAK,SAAS,SAAiB,QAAQ,IAAI,IAAI;CAE3D,IAAI,CAAC,QAAQ,cAAc;EAE1B,MAAM,SAAS,YAAW,MADFC,eAAAA,sBAAsB,KAAK,GAAG,EAAA,CAClB,MAAM;EAC1C,IAAI,QAAQ,OAAO,KAAK,UAAU,MAAM,IAAI,MAAM,MAAM,CAAC;EACzD;CACD;CAEA,IAAI;EACH,MAAM,OAAO,IAAI;EACjB,IAAI,CAAC,MAAM,MAAM,IAAI,mBAAmB;EAExC,MAAM,YAAY,MAAMA,eAAAA,sBAAsB,KAAK,GAAG;EACtD,MAAM,QAAQ,QAAQ,SAAS,IAAI;EACnC,IAAI,CAAC,OAAO,MAAM,IAAI,kBAAkB;EAExC,MAAM,UAAU,cAAc,WAAW;GACxC;GACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjD,CAAC;EACD,OAAA,GAAMC,iBAAAA,WAAAA,CAAW,MAAM,oBAAoB,OAAO,CAAC;EAEnD,IAAI,GAAG,MAAM,UAAU,QAAQ,MAAM,WAAW,QAAQ,QAAQ;CACjE,SAAS,OAAO;EAGf,IAAI,6BAA6B,oBADjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACT,GAAG;EAC/D,MAAM;CACP;AACD;;AAGA,IAAa,qBAAb,cAAwCC,eAAAA,SAAS;CAChD,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAC/C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
|
1
|
+
{"version":3,"file":"stages--icWbhPy.cjs","names":["UndeclaredStage","GkmError","s3SecretsLocation","loadWorkspaceSettings","appendFile","GkmError"],"sources":["../src/stages/plan.ts","../src/stages/index.ts"],"sourcesContent":["/**\n * Which stages a workflow run builds and deploys, from the event that started\n * it and the project's `stages`.\n *\n * The rules live here, in tested code, rather than in a workflow's YAML or in\n * the action that runs `gkm stages --github-output`: a project's deploy\n * workflow names no stage, and what it does for each event is decided by the\n * CLI the project installed.\n *\n * | event | build | deploy |\n * | ------------------- | ------------------ | ------------------------------- |\n * | `push` | every deployed | deployed, less the protected |\n * | `release` | none | the protected |\n * | `workflow_dispatch` | none | the one stage named |\n * | anything else | none | none |\n *\n * A push builds every deployed stage, protected ones included, so a release\n * deploys images built from the very commit its tag names; a release and a\n * manual run deploy what a push already built.\n */\n\nimport { GkmError } from '../errors';\nimport { UndeclaredStage } from '../workspace/stages.js';\nimport type { StagesConfig } from '../workspace/types.js';\n\nexport interface StagePlan {\n\t/** The stages whose images this run builds and pushes. */\n\tbuild: string[];\n\t/** The stages this run deploys. */\n\tdeploy: string[];\n}\n\nexport interface PlanInput {\n\t/** The GitHub event name: `push`, `release`, `workflow_dispatch`, … */\n\tevent: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport function planStages(stages: StagesConfig, input: PlanInput): StagePlan {\n\tconst kept = stages.protected ?? [];\n\n\tswitch (input.event) {\n\t\tcase 'push':\n\t\t\treturn {\n\t\t\t\tbuild: [...stages.deployed],\n\t\t\t\tdeploy: stages.deployed.filter((stage) => !kept.includes(stage)),\n\t\t\t};\n\t\tcase 'release':\n\t\t\treturn { build: [], deploy: [...kept] };\n\t\tcase 'workflow_dispatch': {\n\t\t\tconst stage = input.stage?.trim();\n\t\t\tif (!stage) throw new DispatchNamesNoStage(stages.deployed);\n\t\t\tif (!stages.deployed.includes(stage)) {\n\t\t\t\tthrow new UndeclaredStage(stage, stages.deployed);\n\t\t\t}\n\t\t\treturn { build: [], deploy: [stage] };\n\t\t}\n\t\tdefault:\n\t\t\treturn { build: [], deploy: [] };\n\t}\n}\n\n/**\n * A manual run with no stage. Refused rather than read as \"nothing to do\", so\n * a run started with the field left empty fails where it can be seen.\n */\nexport class DispatchNamesNoStage extends GkmError {\n\tconstructor(readonly deployed: readonly string[]) {\n\t\tsuper(\n\t\t\t`A manual run deploys one stage, and none was given. Run the workflow again with stage set to one of: ${deployed.join(', ') || 'nothing yet — gkm.config.ts deploys to no stage'}.`,\n\t\t);\n\t\tthis.name = 'DispatchNamesNoStage';\n\t}\n}\n","/**\n * `gkm stages` — the workspace's stages, as gkm.config.ts declares them.\n *\n * ```bash\n * gkm stages # a table\n * gkm stages --json # {\"local\":\"dev\",\"deployed\":[\"prod\"],\"protected\":[\"prod\"]}\n * gkm stages --github-output # a workflow run's build and deploy matrices\n * ```\n *\n * The config is read by the normal loader (and sandbox), so a workflow never\n * parses TypeScript to learn which stages exist. `--github-output` is what the\n * `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and\n * which of them this run builds and deploys, to `$GITHUB_OUTPUT`.\n */\n\nimport { appendFile } from 'node:fs/promises';\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { s3SecretsLocation } from '../secrets/providers.js';\nimport type { NormalizedWorkspace, StagesConfig } from '../workspace/types.js';\nimport { planStages } from './plan.js';\n\nexport { DispatchNamesNoStage, type PlanInput, planStages } from './plan.js';\n\nexport interface StagesOptions {\n\t/** Print the stages as JSON. */\n\tjson?: boolean;\n\t/** Write the outputs a deploy workflow reads to `$GITHUB_OUTPUT`. */\n\tgithubOutput?: boolean;\n\t/** The event to plan for; defaults to `GITHUB_EVENT_NAME`. */\n\tevent?: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport interface StagesDeps {\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Where lines go; stdout by default. */\n\tlog?: (line: string) => void;\n}\n\n/** The stages, as `gkm stages --json` prints them. */\nexport interface StagesJson {\n\tlocal: string;\n\tdeployed: string[];\n\tprotected: string[];\n}\n\nexport function stagesJson(stages: StagesConfig): StagesJson {\n\treturn {\n\t\tlocal: stages.local,\n\t\tdeployed: [...stages.deployed],\n\t\tprotected: [...(stages.protected ?? [])],\n\t};\n}\n\n/**\n * The region of the workspace's AWS secrets store — `s3`, `ssm` or\n * `secrets-manager` — or `''` when its deployed stages keep their secrets\n * anywhere else. A job assumes the stage's AWS role only when this is set.\n */\nexport function awsSecretsRegion(workspace: NormalizedWorkspace): string {\n\tconst store = workspace.secrets?.store;\n\tif (typeof store !== 'object' || store === null) return '';\n\tif (store.provider === 's3') {\n\t\treturn s3SecretsLocation(store, workspace.state).region;\n\t}\n\tif (store.provider === 'ssm' || store.provider === 'secrets-manager') {\n\t\treturn store.region;\n\t}\n\treturn '';\n}\n\n/**\n * The host a workflow logs in to for `deploy.registry`, as Docker reads an\n * image name: the first part when it names a host (a dot, a port, or\n * `localhost`), Docker Hub's `docker.io` for a bare namespace, and `''` when\n * no registry is set. Read at run time, so a workflow follows the config\n * rather than what it said when the workflow was written.\n */\nexport function registryHost(workspace: NormalizedWorkspace): string {\n\tconst registry = workspace.deploy?.registry?.trim();\n\tif (!registry) return '';\n\tconst first = registry.split('/')[0]!;\n\treturn first.includes('.') || first.includes(':') || first === 'localhost'\n\t\t? first\n\t\t: 'docker.io';\n}\n\n/**\n * Every output the stages action sets, each a string `fromJSON()` reads, for\n * one workflow run.\n */\nexport function githubOutputs(\n\tworkspace: NormalizedWorkspace,\n\tinput: { event: string; stage?: string },\n): Record<string, string> {\n\tconst stages = stagesJson(workspace.stages);\n\tconst plan = planStages(workspace.stages, input);\n\n\treturn {\n\t\tlocal: JSON.stringify(stages.local),\n\t\tdeployed: JSON.stringify(stages.deployed),\n\t\tprotected: JSON.stringify(stages.protected),\n\t\tbuild: JSON.stringify(plan.build),\n\t\tdeploy: JSON.stringify(plan.deploy),\n\t\t// A matrix over an empty list is an error on GitHub, so a job over one\n\t\t// is skipped on these instead.\n\t\t'has-build': String(plan.build.length > 0),\n\t\t'has-deploy': String(plan.deploy.length > 0),\n\t\t'aws-region': awsSecretsRegion(workspace),\n\t\tregistry: registryHost(workspace),\n\t};\n}\n\n/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */\nexport function formatGithubOutputs(outputs: Record<string, string>): string {\n\treturn Object.entries(outputs)\n\t\t.map(([name, value]) => `${name}=${value}\\n`)\n\t\t.join('');\n}\n\n/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */\nfunction workflowCommandData(message: string): string {\n\treturn message\n\t\t.replaceAll('%', '%25')\n\t\t.replaceAll('\\r', '%0D')\n\t\t.replaceAll('\\n', '%0A');\n}\n\nfunction table(stages: StagesJson): string {\n\tconst rows: [string, string][] = [\n\t\t['STAGE', 'KIND'],\n\t\t[stages.local, 'local'],\n\t\t...stages.deployed.map((name): [string, string] => [\n\t\t\tname,\n\t\t\tstages.protected.includes(name) ? 'deployed, protected' : 'deployed',\n\t\t]),\n\t];\n\tconst width = Math.max(...rows.map(([name]) => name.length));\n\treturn rows\n\t\t.map(([name, kind]) => `${name.padEnd(width)} ${kind}`)\n\t\t.join('\\n');\n}\n\nexport async function stagesCommand(\n\toptions: StagesOptions,\n\tdeps: StagesDeps = {},\n): Promise<void> {\n\tconst env = deps.env ?? process.env;\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\n\tif (!options.githubOutput) {\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst stages = stagesJson(workspace.stages);\n\t\tlog(options.json ? JSON.stringify(stages) : table(stages));\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst file = env.GITHUB_OUTPUT;\n\t\tif (!file) throw new GithubOutputNotSet();\n\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst event = options.event || env.GITHUB_EVENT_NAME;\n\t\tif (!event) throw new GithubEventNotSet();\n\n\t\tconst outputs = githubOutputs(workspace, {\n\t\t\tevent,\n\t\t\t...(options.stage ? { stage: options.stage } : {}),\n\t\t});\n\t\tawait appendFile(file, formatGithubOutputs(outputs));\n\n\t\tlog(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);\n\t} catch (error) {\n\t\t// Annotated on the run, where whoever started it looks first.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlog(`::error title=gkm stages::${workflowCommandData(message)}`);\n\t\tthrow error;\n\t}\n}\n\n/** `--github-output` outside a GitHub Actions step, which sets the file. */\nexport class GithubOutputNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output writes to the file GITHUB_OUTPUT names, and it is not set. Run it in a GitHub Actions step, or set GITHUB_OUTPUT to a file to write to.',\n\t\t);\n\t\tthis.name = 'GithubOutputNotSet';\n\t}\n}\n\n/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */\nexport class GithubEventNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output plans for an event, and none was given. Pass --event (push, release, workflow_dispatch), or run it in a GitHub Actions step, which sets GITHUB_EVENT_NAME.',\n\t\t);\n\t\tthis.name = 'GithubEventNotSet';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,WAAW,QAAsB,OAA6B;CAC7E,MAAM,OAAO,OAAO,aAAa,CAAC;CAElC,QAAQ,MAAM,OAAd;EACC,KAAK,QACJ,OAAO;GACN,OAAO,CAAC,GAAG,OAAO,QAAQ;GAC1B,QAAQ,OAAO,SAAS,QAAQ,UAAU,CAAC,KAAK,SAAS,KAAK,CAAC;EAChE;EACD,KAAK,WACJ,OAAO;GAAE,OAAO,CAAC;GAAG,QAAQ,CAAC,GAAG,IAAI;EAAE;EACvC,KAAK,qBAAqB;GACzB,MAAM,QAAQ,MAAM,OAAO,KAAK;GAChC,IAAI,CAAC,OAAO,MAAM,IAAI,qBAAqB,OAAO,QAAQ;GAC1D,IAAI,CAAC,OAAO,SAAS,SAAS,KAAK,GAClC,MAAM,IAAIA,kBAAAA,gBAAgB,OAAO,OAAO,QAAQ;GAEjD,OAAO;IAAE,OAAO,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;EACH,MAAM,OAAO,IAAI;EACjB,IAAI,CAAC,MAAM,MAAM,IAAI,mBAAmB;EAExC,MAAM,YAAY,MAAMA,eAAAA,sBAAsB,KAAK,GAAG;EACtD,MAAM,QAAQ,QAAQ,SAAS,IAAI;EACnC,IAAI,CAAC,OAAO,MAAM,IAAI,kBAAkB;EAExC,MAAM,UAAU,cAAc,WAAW;GACxC;GACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjD,CAAC;EACD,OAAA,GAAMC,iBAAAA,WAAAA,CAAW,MAAM,oBAAoB,OAAO,CAAC;EAEnD,IAAI,GAAG,MAAM,UAAU,QAAQ,MAAM,WAAW,QAAQ,QAAQ;CACjE,SAAS,OAAO;EAGf,IAAI,6BAA6B,oBADjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACT,GAAG;EAC/D,MAAM;CACP;AACD;;AAGA,IAAa,qBAAb,cAAwCC,eAAAA,SAAS;CAChD,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAC/C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
|
-
import { M as UndeclaredStage,
|
|
2
|
+
import { M as UndeclaredStage, mt as s3SecretsLocation } from "./workspace-BbfBFtjn.mjs";
|
|
3
3
|
import { loadWorkspaceSettings } from "./config.mjs";
|
|
4
4
|
import { appendFile } from "node:fs/promises";
|
|
5
5
|
//#region src/stages/plan.ts
|
|
@@ -187,4 +187,4 @@ var GithubEventNotSet = class extends GkmError {
|
|
|
187
187
|
//#endregion
|
|
188
188
|
export { stagesCommand };
|
|
189
189
|
|
|
190
|
-
//# sourceMappingURL=stages-
|
|
190
|
+
//# sourceMappingURL=stages-CUwSy39f.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stages-COSKjrfd.mjs","names":[],"sources":["../src/stages/plan.ts","../src/stages/index.ts"],"sourcesContent":["/**\n * Which stages a workflow run builds and deploys, from the event that started\n * it and the project's `stages`.\n *\n * The rules live here, in tested code, rather than in a workflow's YAML or in\n * the action that runs `gkm stages --github-output`: a project's deploy\n * workflow names no stage, and what it does for each event is decided by the\n * CLI the project installed.\n *\n * | event | build | deploy |\n * | ------------------- | ------------------ | ------------------------------- |\n * | `push` | every deployed | deployed, less the protected |\n * | `release` | none | the protected |\n * | `workflow_dispatch` | none | the one stage named |\n * | anything else | none | none |\n *\n * A push builds every deployed stage, protected ones included, so a release\n * deploys images built from the very commit its tag names; a release and a\n * manual run deploy what a push already built.\n */\n\nimport { GkmError } from '../errors';\nimport { UndeclaredStage } from '../workspace/stages.js';\nimport type { StagesConfig } from '../workspace/types.js';\n\nexport interface StagePlan {\n\t/** The stages whose images this run builds and pushes. */\n\tbuild: string[];\n\t/** The stages this run deploys. */\n\tdeploy: string[];\n}\n\nexport interface PlanInput {\n\t/** The GitHub event name: `push`, `release`, `workflow_dispatch`, … */\n\tevent: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport function planStages(stages: StagesConfig, input: PlanInput): StagePlan {\n\tconst kept = stages.protected ?? [];\n\n\tswitch (input.event) {\n\t\tcase 'push':\n\t\t\treturn {\n\t\t\t\tbuild: [...stages.deployed],\n\t\t\t\tdeploy: stages.deployed.filter((stage) => !kept.includes(stage)),\n\t\t\t};\n\t\tcase 'release':\n\t\t\treturn { build: [], deploy: [...kept] };\n\t\tcase 'workflow_dispatch': {\n\t\t\tconst stage = input.stage?.trim();\n\t\t\tif (!stage) throw new DispatchNamesNoStage(stages.deployed);\n\t\t\tif (!stages.deployed.includes(stage)) {\n\t\t\t\tthrow new UndeclaredStage(stage, stages.deployed);\n\t\t\t}\n\t\t\treturn { build: [], deploy: [stage] };\n\t\t}\n\t\tdefault:\n\t\t\treturn { build: [], deploy: [] };\n\t}\n}\n\n/**\n * A manual run with no stage. Refused rather than read as \"nothing to do\", so\n * a run started with the field left empty fails where it can be seen.\n */\nexport class DispatchNamesNoStage extends GkmError {\n\tconstructor(readonly deployed: readonly string[]) {\n\t\tsuper(\n\t\t\t`A manual run deploys one stage, and none was given. Run the workflow again with stage set to one of: ${deployed.join(', ') || 'nothing yet — gkm.config.ts deploys to no stage'}.`,\n\t\t);\n\t\tthis.name = 'DispatchNamesNoStage';\n\t}\n}\n","/**\n * `gkm stages` — the workspace's stages, as gkm.config.ts declares them.\n *\n * ```bash\n * gkm stages # a table\n * gkm stages --json # {\"local\":\"dev\",\"deployed\":[\"prod\"],\"protected\":[\"prod\"]}\n * gkm stages --github-output # a workflow run's build and deploy matrices\n * ```\n *\n * The config is read by the normal loader (and sandbox), so a workflow never\n * parses TypeScript to learn which stages exist. `--github-output` is what the\n * `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and\n * which of them this run builds and deploys, to `$GITHUB_OUTPUT`.\n */\n\nimport { appendFile } from 'node:fs/promises';\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { s3SecretsLocation } from '../secrets/providers.js';\nimport type { NormalizedWorkspace, StagesConfig } from '../workspace/types.js';\nimport { planStages } from './plan.js';\n\nexport { DispatchNamesNoStage, type PlanInput, planStages } from './plan.js';\n\nexport interface StagesOptions {\n\t/** Print the stages as JSON. */\n\tjson?: boolean;\n\t/** Write the outputs a deploy workflow reads to `$GITHUB_OUTPUT`. */\n\tgithubOutput?: boolean;\n\t/** The event to plan for; defaults to `GITHUB_EVENT_NAME`. */\n\tevent?: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport interface StagesDeps {\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Where lines go; stdout by default. */\n\tlog?: (line: string) => void;\n}\n\n/** The stages, as `gkm stages --json` prints them. */\nexport interface StagesJson {\n\tlocal: string;\n\tdeployed: string[];\n\tprotected: string[];\n}\n\nexport function stagesJson(stages: StagesConfig): StagesJson {\n\treturn {\n\t\tlocal: stages.local,\n\t\tdeployed: [...stages.deployed],\n\t\tprotected: [...(stages.protected ?? [])],\n\t};\n}\n\n/**\n * The region of the workspace's AWS secrets store — `s3`, `ssm` or\n * `secrets-manager` — or `''` when its deployed stages keep their secrets\n * anywhere else. A job assumes the stage's AWS role only when this is set.\n */\nexport function awsSecretsRegion(workspace: NormalizedWorkspace): string {\n\tconst store = workspace.secrets?.store;\n\tif (typeof store !== 'object' || store === null) return '';\n\tif (store.provider === 's3') {\n\t\treturn s3SecretsLocation(store, workspace.state).region;\n\t}\n\tif (store.provider === 'ssm' || store.provider === 'secrets-manager') {\n\t\treturn store.region;\n\t}\n\treturn '';\n}\n\n/**\n * The host a workflow logs in to for `deploy.registry`, as Docker reads an\n * image name: the first part when it names a host (a dot, a port, or\n * `localhost`), Docker Hub's `docker.io` for a bare namespace, and `''` when\n * no registry is set. Read at run time, so a workflow follows the config\n * rather than what it said when the workflow was written.\n */\nexport function registryHost(workspace: NormalizedWorkspace): string {\n\tconst registry = workspace.deploy?.registry?.trim();\n\tif (!registry) return '';\n\tconst first = registry.split('/')[0]!;\n\treturn first.includes('.') || first.includes(':') || first === 'localhost'\n\t\t? first\n\t\t: 'docker.io';\n}\n\n/**\n * Every output the stages action sets, each a string `fromJSON()` reads, for\n * one workflow run.\n */\nexport function githubOutputs(\n\tworkspace: NormalizedWorkspace,\n\tinput: { event: string; stage?: string },\n): Record<string, string> {\n\tconst stages = stagesJson(workspace.stages);\n\tconst plan = planStages(workspace.stages, input);\n\n\treturn {\n\t\tlocal: JSON.stringify(stages.local),\n\t\tdeployed: JSON.stringify(stages.deployed),\n\t\tprotected: JSON.stringify(stages.protected),\n\t\tbuild: JSON.stringify(plan.build),\n\t\tdeploy: JSON.stringify(plan.deploy),\n\t\t// A matrix over an empty list is an error on GitHub, so a job over one\n\t\t// is skipped on these instead.\n\t\t'has-build': String(plan.build.length > 0),\n\t\t'has-deploy': String(plan.deploy.length > 0),\n\t\t'aws-region': awsSecretsRegion(workspace),\n\t\tregistry: registryHost(workspace),\n\t};\n}\n\n/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */\nexport function formatGithubOutputs(outputs: Record<string, string>): string {\n\treturn Object.entries(outputs)\n\t\t.map(([name, value]) => `${name}=${value}\\n`)\n\t\t.join('');\n}\n\n/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */\nfunction workflowCommandData(message: string): string {\n\treturn message\n\t\t.replaceAll('%', '%25')\n\t\t.replaceAll('\\r', '%0D')\n\t\t.replaceAll('\\n', '%0A');\n}\n\nfunction table(stages: StagesJson): string {\n\tconst rows: [string, string][] = [\n\t\t['STAGE', 'KIND'],\n\t\t[stages.local, 'local'],\n\t\t...stages.deployed.map((name): [string, string] => [\n\t\t\tname,\n\t\t\tstages.protected.includes(name) ? 'deployed, protected' : 'deployed',\n\t\t]),\n\t];\n\tconst width = Math.max(...rows.map(([name]) => name.length));\n\treturn rows\n\t\t.map(([name, kind]) => `${name.padEnd(width)} ${kind}`)\n\t\t.join('\\n');\n}\n\nexport async function stagesCommand(\n\toptions: StagesOptions,\n\tdeps: StagesDeps = {},\n): Promise<void> {\n\tconst env = deps.env ?? process.env;\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\n\tif (!options.githubOutput) {\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst stages = stagesJson(workspace.stages);\n\t\tlog(options.json ? JSON.stringify(stages) : table(stages));\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst file = env.GITHUB_OUTPUT;\n\t\tif (!file) throw new GithubOutputNotSet();\n\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst event = options.event || env.GITHUB_EVENT_NAME;\n\t\tif (!event) throw new GithubEventNotSet();\n\n\t\tconst outputs = githubOutputs(workspace, {\n\t\t\tevent,\n\t\t\t...(options.stage ? { stage: options.stage } : {}),\n\t\t});\n\t\tawait appendFile(file, formatGithubOutputs(outputs));\n\n\t\tlog(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);\n\t} catch (error) {\n\t\t// Annotated on the run, where whoever started it looks first.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlog(`::error title=gkm stages::${workflowCommandData(message)}`);\n\t\tthrow error;\n\t}\n}\n\n/** `--github-output` outside a GitHub Actions step, which sets the file. */\nexport class GithubOutputNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output writes to the file GITHUB_OUTPUT names, and it is not set. Run it in a GitHub Actions step, or set GITHUB_OUTPUT to a file to write to.',\n\t\t);\n\t\tthis.name = 'GithubOutputNotSet';\n\t}\n}\n\n/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */\nexport class GithubEventNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output plans for an event, and none was given. Pass --event (push, release, workflow_dispatch), or run it in a GitHub Actions step, which sets GITHUB_EVENT_NAME.',\n\t\t);\n\t\tthis.name = 'GithubEventNotSet';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,WAAW,QAAsB,OAA6B;CAC7E,MAAM,OAAO,OAAO,aAAa,CAAC;CAElC,QAAQ,MAAM,OAAd;EACC,KAAK,QACJ,OAAO;GACN,OAAO,CAAC,GAAG,OAAO,QAAQ;GAC1B,QAAQ,OAAO,SAAS,QAAQ,UAAU,CAAC,KAAK,SAAS,KAAK,CAAC;EAChE;EACD,KAAK,WACJ,OAAO;GAAE,OAAO,CAAC;GAAG,QAAQ,CAAC,GAAG,IAAI;EAAE;EACvC,KAAK,qBAAqB;GACzB,MAAM,QAAQ,MAAM,OAAO,KAAK;GAChC,IAAI,CAAC,OAAO,MAAM,IAAI,qBAAqB,OAAO,QAAQ;GAC1D,IAAI,CAAC,OAAO,SAAS,SAAS,KAAK,GAClC,MAAM,IAAI,gB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C;EACzD;CACD;CAEA,IAAI;EACH,MAAM,OAAO,IAAI;EACjB,IAAI,CAAC,MAAM,MAAM,IAAI,mBAAmB;EAExC,MAAM,YAAY,MAAM,sBAAsB,KAAK,GAAG;EACtD,MAAM,QAAQ,QAAQ,SAAS,IAAI;EACnC,IAAI,CAAC,OAAO,MAAM,IAAI,kBAAkB;EAExC,MAAM,UAAU,cAAc,WAAW;GACxC;GACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjD,CAAC;EACD,MAAM,WAAW,MAAM,oBAAoB,OAAO,CAAC;EAEnD,IAAI,GAAG,MAAM,UAAU,QAAQ,MAAM,WAAW,QAAQ,QAAQ;CACjE,SAAS,OAAO;EAGf,IAAI,6BAA6B,oBADjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACT,GAAG;EAC/D,MAAM;CACP;AACD;;AAGA,IAAa,qBAAb,cAAwC,SAAS;CAChD,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,SAAS;CAC/C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
|
1
|
+
{"version":3,"file":"stages-CUwSy39f.mjs","names":[],"sources":["../src/stages/plan.ts","../src/stages/index.ts"],"sourcesContent":["/**\n * Which stages a workflow run builds and deploys, from the event that started\n * it and the project's `stages`.\n *\n * The rules live here, in tested code, rather than in a workflow's YAML or in\n * the action that runs `gkm stages --github-output`: a project's deploy\n * workflow names no stage, and what it does for each event is decided by the\n * CLI the project installed.\n *\n * | event | build | deploy |\n * | ------------------- | ------------------ | ------------------------------- |\n * | `push` | every deployed | deployed, less the protected |\n * | `release` | none | the protected |\n * | `workflow_dispatch` | none | the one stage named |\n * | anything else | none | none |\n *\n * A push builds every deployed stage, protected ones included, so a release\n * deploys images built from the very commit its tag names; a release and a\n * manual run deploy what a push already built.\n */\n\nimport { GkmError } from '../errors';\nimport { UndeclaredStage } from '../workspace/stages.js';\nimport type { StagesConfig } from '../workspace/types.js';\n\nexport interface StagePlan {\n\t/** The stages whose images this run builds and pushes. */\n\tbuild: string[];\n\t/** The stages this run deploys. */\n\tdeploy: string[];\n}\n\nexport interface PlanInput {\n\t/** The GitHub event name: `push`, `release`, `workflow_dispatch`, … */\n\tevent: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport function planStages(stages: StagesConfig, input: PlanInput): StagePlan {\n\tconst kept = stages.protected ?? [];\n\n\tswitch (input.event) {\n\t\tcase 'push':\n\t\t\treturn {\n\t\t\t\tbuild: [...stages.deployed],\n\t\t\t\tdeploy: stages.deployed.filter((stage) => !kept.includes(stage)),\n\t\t\t};\n\t\tcase 'release':\n\t\t\treturn { build: [], deploy: [...kept] };\n\t\tcase 'workflow_dispatch': {\n\t\t\tconst stage = input.stage?.trim();\n\t\t\tif (!stage) throw new DispatchNamesNoStage(stages.deployed);\n\t\t\tif (!stages.deployed.includes(stage)) {\n\t\t\t\tthrow new UndeclaredStage(stage, stages.deployed);\n\t\t\t}\n\t\t\treturn { build: [], deploy: [stage] };\n\t\t}\n\t\tdefault:\n\t\t\treturn { build: [], deploy: [] };\n\t}\n}\n\n/**\n * A manual run with no stage. Refused rather than read as \"nothing to do\", so\n * a run started with the field left empty fails where it can be seen.\n */\nexport class DispatchNamesNoStage extends GkmError {\n\tconstructor(readonly deployed: readonly string[]) {\n\t\tsuper(\n\t\t\t`A manual run deploys one stage, and none was given. Run the workflow again with stage set to one of: ${deployed.join(', ') || 'nothing yet — gkm.config.ts deploys to no stage'}.`,\n\t\t);\n\t\tthis.name = 'DispatchNamesNoStage';\n\t}\n}\n","/**\n * `gkm stages` — the workspace's stages, as gkm.config.ts declares them.\n *\n * ```bash\n * gkm stages # a table\n * gkm stages --json # {\"local\":\"dev\",\"deployed\":[\"prod\"],\"protected\":[\"prod\"]}\n * gkm stages --github-output # a workflow run's build and deploy matrices\n * ```\n *\n * The config is read by the normal loader (and sandbox), so a workflow never\n * parses TypeScript to learn which stages exist. `--github-output` is what the\n * `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and\n * which of them this run builds and deploys, to `$GITHUB_OUTPUT`.\n */\n\nimport { appendFile } from 'node:fs/promises';\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { s3SecretsLocation } from '../secrets/providers.js';\nimport type { NormalizedWorkspace, StagesConfig } from '../workspace/types.js';\nimport { planStages } from './plan.js';\n\nexport { DispatchNamesNoStage, type PlanInput, planStages } from './plan.js';\n\nexport interface StagesOptions {\n\t/** Print the stages as JSON. */\n\tjson?: boolean;\n\t/** Write the outputs a deploy workflow reads to `$GITHUB_OUTPUT`. */\n\tgithubOutput?: boolean;\n\t/** The event to plan for; defaults to `GITHUB_EVENT_NAME`. */\n\tevent?: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport interface StagesDeps {\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Where lines go; stdout by default. */\n\tlog?: (line: string) => void;\n}\n\n/** The stages, as `gkm stages --json` prints them. */\nexport interface StagesJson {\n\tlocal: string;\n\tdeployed: string[];\n\tprotected: string[];\n}\n\nexport function stagesJson(stages: StagesConfig): StagesJson {\n\treturn {\n\t\tlocal: stages.local,\n\t\tdeployed: [...stages.deployed],\n\t\tprotected: [...(stages.protected ?? [])],\n\t};\n}\n\n/**\n * The region of the workspace's AWS secrets store — `s3`, `ssm` or\n * `secrets-manager` — or `''` when its deployed stages keep their secrets\n * anywhere else. A job assumes the stage's AWS role only when this is set.\n */\nexport function awsSecretsRegion(workspace: NormalizedWorkspace): string {\n\tconst store = workspace.secrets?.store;\n\tif (typeof store !== 'object' || store === null) return '';\n\tif (store.provider === 's3') {\n\t\treturn s3SecretsLocation(store, workspace.state).region;\n\t}\n\tif (store.provider === 'ssm' || store.provider === 'secrets-manager') {\n\t\treturn store.region;\n\t}\n\treturn '';\n}\n\n/**\n * The host a workflow logs in to for `deploy.registry`, as Docker reads an\n * image name: the first part when it names a host (a dot, a port, or\n * `localhost`), Docker Hub's `docker.io` for a bare namespace, and `''` when\n * no registry is set. Read at run time, so a workflow follows the config\n * rather than what it said when the workflow was written.\n */\nexport function registryHost(workspace: NormalizedWorkspace): string {\n\tconst registry = workspace.deploy?.registry?.trim();\n\tif (!registry) return '';\n\tconst first = registry.split('/')[0]!;\n\treturn first.includes('.') || first.includes(':') || first === 'localhost'\n\t\t? first\n\t\t: 'docker.io';\n}\n\n/**\n * Every output the stages action sets, each a string `fromJSON()` reads, for\n * one workflow run.\n */\nexport function githubOutputs(\n\tworkspace: NormalizedWorkspace,\n\tinput: { event: string; stage?: string },\n): Record<string, string> {\n\tconst stages = stagesJson(workspace.stages);\n\tconst plan = planStages(workspace.stages, input);\n\n\treturn {\n\t\tlocal: JSON.stringify(stages.local),\n\t\tdeployed: JSON.stringify(stages.deployed),\n\t\tprotected: JSON.stringify(stages.protected),\n\t\tbuild: JSON.stringify(plan.build),\n\t\tdeploy: JSON.stringify(plan.deploy),\n\t\t// A matrix over an empty list is an error on GitHub, so a job over one\n\t\t// is skipped on these instead.\n\t\t'has-build': String(plan.build.length > 0),\n\t\t'has-deploy': String(plan.deploy.length > 0),\n\t\t'aws-region': awsSecretsRegion(workspace),\n\t\tregistry: registryHost(workspace),\n\t};\n}\n\n/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */\nexport function formatGithubOutputs(outputs: Record<string, string>): string {\n\treturn Object.entries(outputs)\n\t\t.map(([name, value]) => `${name}=${value}\\n`)\n\t\t.join('');\n}\n\n/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */\nfunction workflowCommandData(message: string): string {\n\treturn message\n\t\t.replaceAll('%', '%25')\n\t\t.replaceAll('\\r', '%0D')\n\t\t.replaceAll('\\n', '%0A');\n}\n\nfunction table(stages: StagesJson): string {\n\tconst rows: [string, string][] = [\n\t\t['STAGE', 'KIND'],\n\t\t[stages.local, 'local'],\n\t\t...stages.deployed.map((name): [string, string] => [\n\t\t\tname,\n\t\t\tstages.protected.includes(name) ? 'deployed, protected' : 'deployed',\n\t\t]),\n\t];\n\tconst width = Math.max(...rows.map(([name]) => name.length));\n\treturn rows\n\t\t.map(([name, kind]) => `${name.padEnd(width)} ${kind}`)\n\t\t.join('\\n');\n}\n\nexport async function stagesCommand(\n\toptions: StagesOptions,\n\tdeps: StagesDeps = {},\n): Promise<void> {\n\tconst env = deps.env ?? process.env;\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\n\tif (!options.githubOutput) {\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst stages = stagesJson(workspace.stages);\n\t\tlog(options.json ? JSON.stringify(stages) : table(stages));\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst file = env.GITHUB_OUTPUT;\n\t\tif (!file) throw new GithubOutputNotSet();\n\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst event = options.event || env.GITHUB_EVENT_NAME;\n\t\tif (!event) throw new GithubEventNotSet();\n\n\t\tconst outputs = githubOutputs(workspace, {\n\t\t\tevent,\n\t\t\t...(options.stage ? { stage: options.stage } : {}),\n\t\t});\n\t\tawait appendFile(file, formatGithubOutputs(outputs));\n\n\t\tlog(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);\n\t} catch (error) {\n\t\t// Annotated on the run, where whoever started it looks first.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlog(`::error title=gkm stages::${workflowCommandData(message)}`);\n\t\tthrow error;\n\t}\n}\n\n/** `--github-output` outside a GitHub Actions step, which sets the file. */\nexport class GithubOutputNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output writes to the file GITHUB_OUTPUT names, and it is not set. Run it in a GitHub Actions step, or set GITHUB_OUTPUT to a file to write to.',\n\t\t);\n\t\tthis.name = 'GithubOutputNotSet';\n\t}\n}\n\n/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */\nexport class GithubEventNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output plans for an event, and none was given. Pass --event (push, release, workflow_dispatch), or run it in a GitHub Actions step, which sets GITHUB_EVENT_NAME.',\n\t\t);\n\t\tthis.name = 'GithubEventNotSet';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,WAAW,QAAsB,OAA6B;CAC7E,MAAM,OAAO,OAAO,aAAa,CAAC;CAElC,QAAQ,MAAM,OAAd;EACC,KAAK,QACJ,OAAO;GACN,OAAO,CAAC,GAAG,OAAO,QAAQ;GAC1B,QAAQ,OAAO,SAAS,QAAQ,UAAU,CAAC,KAAK,SAAS,KAAK,CAAC;EAChE;EACD,KAAK,WACJ,OAAO;GAAE,OAAO,CAAC;GAAG,QAAQ,CAAC,GAAG,IAAI;EAAE;EACvC,KAAK,qBAAqB;GACzB,MAAM,QAAQ,MAAM,OAAO,KAAK;GAChC,IAAI,CAAC,OAAO,MAAM,IAAI,qBAAqB,OAAO,QAAQ;GAC1D,IAAI,CAAC,OAAO,SAAS,SAAS,KAAK,GAClC,MAAM,IAAI,gBAAgB,OAAO,OAAO,QAAQ;GAEjD,OAAO;IAAE,OAAO,CAAC;IAAG,QAAQ,CAAC,KAAK;GAAE;EACrC;EACA,SACC,OAAO;GAAE,OAAO,CAAC;GAAG,QAAQ,CAAC;EAAE;CACjC;AACD;;;;;AAMA,IAAa,uBAAb,cAA0C,SAAS;CAC7B;CAArB,YAAY,UAAsC;EACjD,MACC,wGAAwG,SAAS,KAAK,IAAI,KAAK,kDAAkD,EAClL;EAHoB,KAAA,WAAA;EAIpB,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;;;;ACzBA,SAAgB,WAAW,QAAkC;CAC5D,OAAO;EACN,OAAO,OAAO;EACd,UAAU,CAAC,GAAG,OAAO,QAAQ;EAC7B,WAAW,CAAC,GAAI,OAAO,aAAa,CAAC,CAAE;CACxC;A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AM,UAAU,OAAO,KAAK,CACT,GAAG;EAC/D,MAAM;CACP;AACD;;AAGA,IAAa,qBAAb,cAAwC,SAAS;CAChD,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,SAAS;CAC/C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
package/dist/target/public.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_define = require("../define-crmMcXFS.cjs");
|
|
3
|
-
const require_resolve = require("../resolve-
|
|
3
|
+
const require_resolve = require("../resolve-BEVVvi13.cjs");
|
|
4
4
|
const require_provider = require("../provider-BqpjG9QM.cjs");
|
|
5
5
|
exports.DeployTargetNotYetSupported = require_define.DeployTargetNotYetSupported;
|
|
6
6
|
exports.InvalidTargetOptions = require_resolve.InvalidTargetOptions;
|
package/dist/target/public.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as TargetOptions,
|
|
2
|
-
import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-
|
|
1
|
+
import { $ as TargetOptions, Ft as DeployIdentity, G as DeployPhaseContext, J as DeployTarget, K as DeployRuntime, Ot as StateStore, Pt as StageSecrets, Q as TargetEvent, U as AnyDeployTarget, W as DeployFailure, X as DeployTargetEntry, Y as DeployTargetCapabilities, Z as DeployTargetLogger, at as DeployPhase, ct as AppDeployResult, dt as Credential, et as TargetOptionsIssue, ft as CredentialKind, ht as CredentialRequest, it as DeployEventType, lt as DeployResult, mt as CredentialProvider, nt as DeployEvent, ot as ResourceChange, pt as CredentialKinds, q as DeploySecrets, rt as DeployEventError, st as ResourceVia, tt as TargetOptionsSchema, ut as AwsCredential } from "../types-Dy1eV7yc.cjs";
|
|
2
|
+
import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-Bvgyxm88.cjs";
|
|
3
3
|
//#region src/target/define.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* A deploy target, typed from what it is written with: the options from its
|
package/dist/target/public.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as TargetOptions,
|
|
2
|
-
import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-
|
|
1
|
+
import { $ as TargetOptions, Ft as DeployIdentity, G as DeployPhaseContext, J as DeployTarget, K as DeployRuntime, Ot as StateStore, Pt as StageSecrets, Q as TargetEvent, U as AnyDeployTarget, W as DeployFailure, X as DeployTargetEntry, Y as DeployTargetCapabilities, Z as DeployTargetLogger, at as DeployPhase, ct as AppDeployResult, dt as Credential, et as TargetOptionsIssue, ft as CredentialKind, ht as CredentialRequest, it as DeployEventType, lt as DeployResult, mt as CredentialProvider, nt as DeployEvent, ot as ResourceChange, pt as CredentialKinds, q as DeploySecrets, rt as DeployEventError, st as ResourceVia, tt as TargetOptionsSchema, ut as AwsCredential } from "../types-C6hDCkV2.mjs";
|
|
2
|
+
import { a as TargetRuntimeMismatch, c as DeployTargetNotYetSupported, i as TargetPackageInvalid, l as UnknownDeployTarget, n as InvalidTargetOptions, o as ProviderRemoved, r as TargetEntryInvalid, s as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-CeAt1IJd.mjs";
|
|
3
3
|
//#region src/target/define.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* A deploy target, typed from what it is written with: the options from its
|
package/dist/target/public.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as UnknownDeployTarget, i as DeployTargetNotYetSupported, n as isDeployTarget, t as defineTarget } from "../define-6poNqm5O.mjs";
|
|
2
|
-
import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-
|
|
2
|
+
import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-CMC0MI0Z.mjs";
|
|
3
3
|
import { t as ProviderRemoved } from "../provider-CEOKk8NS.mjs";
|
|
4
4
|
export { DeployTargetNotYetSupported, InvalidTargetOptions, ProviderRemoved, TargetEntryInvalid, TargetPackageInvalid, TargetPackageNotFound, TargetRuntimeMismatch, TargetRuntimeUndeclared, UnknownDeployTarget, defineTarget, isDeployTarget };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
2
2
|
const require_credentials = require("./credentials-D7XJypNd.cjs");
|
|
3
|
-
const require_discover = require("./discover-
|
|
3
|
+
const require_discover = require("./discover-yqeJ2Bx7.cjs");
|
|
4
4
|
const require_index = require("./index.cjs");
|
|
5
5
|
//#region src/deploy/terminal.ts
|
|
6
6
|
/**
|
|
@@ -82,4 +82,4 @@ function terminalCredentials(base = require_credentials.storedCredentials()) {
|
|
|
82
82
|
//#endregion
|
|
83
83
|
exports.terminalCredentials = terminalCredentials;
|
|
84
84
|
|
|
85
|
-
//# sourceMappingURL=terminal-
|
|
85
|
+
//# sourceMappingURL=terminal-DURcYlVX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-
|
|
1
|
+
{"version":3,"file":"terminal-DURcYlVX.cjs","names":["output","GkmError","canPrompt","prompt","validateDokployToken","storeDokployCredentials","storedCredentials","chainCredentials"],"sources":["../src/deploy/terminal.ts"],"sourcesContent":["/**\n * The credentials `gkm deploy` can ask a person for. CLI layer only.\n *\n * `deploy()` asks its `CredentialProvider` and stops with `MissingCredential`\n * when the answer is nothing. At a terminal, `gkm deploy` would rather ask:\n * this provider reads the environment and the stored login first, and only\n * when both are empty prompts — and stores a Dokploy login it validated, so\n * the next deploy does not ask again. With no terminal it answers nothing, and\n * the deploy says what was missing instead of waiting on a prompt nobody sees.\n */\n\nimport { validateDokployToken } from '../auth';\nimport { storeDokployCredentials } from '../auth/credentials';\nimport { GkmError } from '../errors';\nimport { output } from '../output';\nimport { canPrompt, prompt } from '../prompt';\nimport {\n\ttype CredentialProvider,\n\ttype CredentialRequest,\n\tchainCredentials,\n\tstoredCredentials,\n} from './credentials';\n\nconst logger = output;\n\n/** What answers a deploy prompt without a terminal. */\nconst INSTEAD = 'Please configure manually.';\n\n/** The Dokploy URL typed at the prompt is not a URL. */\nexport class DokployEndpointInvalid extends GkmError {\n\tconstructor(readonly endpoint: string) {\n\t\tsuper('Invalid URL format');\n\t\tthis.name = 'DokployEndpointInvalid';\n\t}\n}\n\n/** Dokploy refused the token typed at the prompt; nothing was stored. */\nexport class DokployTokenRejected extends GkmError {\n\tconstructor(readonly endpoint: string) {\n\t\tsuper('Invalid credentials. Please check your token.');\n\t\tthis.name = 'DokployTokenRejected';\n\t}\n}\n\n/** Asks the person at the terminal for what nothing else supplied. */\nfunction asking(): CredentialProvider {\n\treturn {\n\t\tasync get(asked) {\n\t\t\tif (!canPrompt()) return undefined;\n\t\t\t// The union, so checking `kind` narrows it: `K` itself never is.\n\t\t\tconst request = asked as CredentialRequest;\n\n\t\t\tif (request.kind === 'dokploy') {\n\t\t\t\tlogger.log(\"\\n📋 Dokploy credentials not found. Let's set them up.\");\n\t\t\t\tconst endpoint = (\n\t\t\t\t\tawait prompt('Dokploy URL (e.g., https://dokploy.example.com): ', {\n\t\t\t\t\t\tinstead: INSTEAD,\n\t\t\t\t\t})\n\t\t\t\t).replace(/\\/$/, '');\n\n\t\t\t\ttry {\n\t\t\t\t\tnew URL(endpoint);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new DokployEndpointInvalid(endpoint);\n\t\t\t\t}\n\n\t\t\t\tlogger.log(`\\nGenerate a token at: ${endpoint}/settings/profile\\n`);\n\t\t\t\tconst token = await prompt('API Token: ', {\n\t\t\t\t\thidden: true,\n\t\t\t\t\tinstead: INSTEAD,\n\t\t\t\t});\n\n\t\t\t\tlogger.log('\\nValidating credentials...');\n\t\t\t\tif (!(await validateDokployToken(endpoint, token))) {\n\t\t\t\t\tthrow new DokployTokenRejected(endpoint);\n\t\t\t\t}\n\n\t\t\t\tawait storeDokployCredentials(token, endpoint);\n\t\t\t\tlogger.log('✓ Credentials saved');\n\t\t\t\treturn { endpoint, token } as never;\n\t\t\t}\n\n\t\t\t// AWS is a profile or a role, set up with the AWS CLI — not keys\n\t\t\t// typed into a deploy.\n\t\t\tif (request.kind !== 'registry') return undefined;\n\n\t\t\tlogger.log(\n\t\t\t\t` Dokploy has no registry for ${request.url}. Let's create one.`,\n\t\t\t);\n\t\t\tconst username = await prompt('Registry username: ', {\n\t\t\t\tinstead: INSTEAD,\n\t\t\t});\n\t\t\tconst password = await prompt('Registry password/token: ', {\n\t\t\t\thidden: true,\n\t\t\t\tinstead: INSTEAD,\n\t\t\t});\n\t\t\treturn { username, password } as never;\n\t\t},\n\t};\n}\n\n/**\n * The environment, then the stored login, then — at a terminal — the person\n * running the command.\n */\nexport function terminalCredentials(\n\tbase: CredentialProvider = storedCredentials(),\n): CredentialProvider {\n\treturn chainCredentials(base, asking());\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,SAASA,iBAAAA;;AAGf,MAAM,UAAU;;AAGhB,IAAa,yBAAb,cAA4CC,eAAAA,SAAS;CAC/B;CAArB,YAAY,UAA2B;EACtC,MAAM,oBAAoB;EADN,KAAA,WAAA;EAEpB,KAAK,OAAO;CACb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ACvC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
2
|
import { _ as storeDokployCredentials, n as chainCredentials, r as storedCredentials } from "./credentials-DpfnUvIR.mjs";
|
|
3
|
-
import { f as output } from "./discover-
|
|
3
|
+
import { f as output } from "./discover-B2m8ytyq.mjs";
|
|
4
4
|
import { c as validateDokployToken, l as canPrompt, u as prompt } from "./index.mjs";
|
|
5
5
|
//#region src/deploy/terminal.ts
|
|
6
6
|
/**
|
|
@@ -82,4 +82,4 @@ function terminalCredentials(base = storedCredentials()) {
|
|
|
82
82
|
//#endregion
|
|
83
83
|
export { terminalCredentials };
|
|
84
84
|
|
|
85
|
-
//# sourceMappingURL=terminal-
|
|
85
|
+
//# sourceMappingURL=terminal-yOZ7kKF9.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-
|
|
1
|
+
{"version":3,"file":"terminal-yOZ7kKF9.mjs","names":[],"sources":["../src/deploy/terminal.ts"],"sourcesContent":["/**\n * The credentials `gkm deploy` can ask a person for. CLI layer only.\n *\n * `deploy()` asks its `CredentialProvider` and stops with `MissingCredential`\n * when the answer is nothing. At a terminal, `gkm deploy` would rather ask:\n * this provider reads the environment and the stored login first, and only\n * when both are empty prompts — and stores a Dokploy login it validated, so\n * the next deploy does not ask again. With no terminal it answers nothing, and\n * the deploy says what was missing instead of waiting on a prompt nobody sees.\n */\n\nimport { validateDokployToken } from '../auth';\nimport { storeDokployCredentials } from '../auth/credentials';\nimport { GkmError } from '../errors';\nimport { output } from '../output';\nimport { canPrompt, prompt } from '../prompt';\nimport {\n\ttype CredentialProvider,\n\ttype CredentialRequest,\n\tchainCredentials,\n\tstoredCredentials,\n} from './credentials';\n\nconst logger = output;\n\n/** What answers a deploy prompt without a terminal. */\nconst INSTEAD = 'Please configure manually.';\n\n/** The Dokploy URL typed at the prompt is not a URL. */\nexport class DokployEndpointInvalid extends GkmError {\n\tconstructor(readonly endpoint: string) {\n\t\tsuper('Invalid URL format');\n\t\tthis.name = 'DokployEndpointInvalid';\n\t}\n}\n\n/** Dokploy refused the token typed at the prompt; nothing was stored. */\nexport class DokployTokenRejected extends GkmError {\n\tconstructor(readonly endpoint: string) {\n\t\tsuper('Invalid credentials. Please check your token.');\n\t\tthis.name = 'DokployTokenRejected';\n\t}\n}\n\n/** Asks the person at the terminal for what nothing else supplied. */\nfunction asking(): CredentialProvider {\n\treturn {\n\t\tasync get(asked) {\n\t\t\tif (!canPrompt()) return undefined;\n\t\t\t// The union, so checking `kind` narrows it: `K` itself never is.\n\t\t\tconst request = asked as CredentialRequest;\n\n\t\t\tif (request.kind === 'dokploy') {\n\t\t\t\tlogger.log(\"\\n📋 Dokploy credentials not found. Let's set them up.\");\n\t\t\t\tconst endpoint = (\n\t\t\t\t\tawait prompt('Dokploy URL (e.g., https://dokploy.example.com): ', {\n\t\t\t\t\t\tinstead: INSTEAD,\n\t\t\t\t\t})\n\t\t\t\t).replace(/\\/$/, '');\n\n\t\t\t\ttry {\n\t\t\t\t\tnew URL(endpoint);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new DokployEndpointInvalid(endpoint);\n\t\t\t\t}\n\n\t\t\t\tlogger.log(`\\nGenerate a token at: ${endpoint}/settings/profile\\n`);\n\t\t\t\tconst token = await prompt('API Token: ', {\n\t\t\t\t\thidden: true,\n\t\t\t\t\tinstead: INSTEAD,\n\t\t\t\t});\n\n\t\t\t\tlogger.log('\\nValidating credentials...');\n\t\t\t\tif (!(await validateDokployToken(endpoint, token))) {\n\t\t\t\t\tthrow new DokployTokenRejected(endpoint);\n\t\t\t\t}\n\n\t\t\t\tawait storeDokployCredentials(token, endpoint);\n\t\t\t\tlogger.log('✓ Credentials saved');\n\t\t\t\treturn { endpoint, token } as never;\n\t\t\t}\n\n\t\t\t// AWS is a profile or a role, set up with the AWS CLI — not keys\n\t\t\t// typed into a deploy.\n\t\t\tif (request.kind !== 'registry') return undefined;\n\n\t\t\tlogger.log(\n\t\t\t\t` Dokploy has no registry for ${request.url}. Let's create one.`,\n\t\t\t);\n\t\t\tconst username = await prompt('Registry username: ', {\n\t\t\t\tinstead: INSTEAD,\n\t\t\t});\n\t\t\tconst password = await prompt('Registry password/token: ', {\n\t\t\t\thidden: true,\n\t\t\t\tinstead: INSTEAD,\n\t\t\t});\n\t\t\treturn { username, password } as never;\n\t\t},\n\t};\n}\n\n/**\n * The environment, then the stored login, then — at a terminal — the person\n * running the command.\n */\nexport function terminalCredentials(\n\tbase: CredentialProvider = storedCredentials(),\n): CredentialProvider {\n\treturn chainCredentials(base, asking());\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,SAAS;;AAGf,MAAM,UAAU;;AAGhB,IAAa,yBAAb,cAA4C,SAAS;CAC/B;CAArB,YAAY,UAA2B;EACtC,MAAM,oBAAoB;EADN,KAAA,WAAA;EAEpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,uBAAb,cAA0C,SAAS;CAC7B;CAArB,YAAY,UAA2B;EACtC,MAAM,+CAA+C;EADjC,KAAA,WAAA;EAEpB,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,SAA6B;CACrC,OAAO,EACN,MAAM,IAAI,OAAO;EAChB,IAAI,CAAC,UAAU,GAAG,OAAO,KAAA;EAEzB,MAAM,UAAU;EAEhB,IAAI,QAAQ,SAAS,WAAW;GAC/B,OAAO,IAAI,wDAAwD;GACnE,MAAM,YACL,MAAM,OAAO,qDAAqD,EACjE,SAAS,QACV,CAAC,EAAA,CACA,QAAQ,OAAO,EAAE;GAEnB,IAAI;IACH,IAAI,IAAI,QAAQ;GACjB,QAAQ;IACP,MAAM,IAAI,uBAAuB,QAAQ;GAC1C;GAEA,OAAO,IAAI,0BAA0B,SAAS,oBAAoB;GAClE,MAAM,QAAQ,MAAM,OAAO,eAAe;IACzC,QAAQ;IACR,SAAS;GACV,CAAC;GAED,OAAO,IAAI,6BAA6B;GACxC,IAAI,CAAE,MAAM,qBAAqB,UAAU,KAAK,GAC/C,MAAM,IAAI,qBAAqB,QAAQ;GAGxC,MAAM,wBAAwB,OAAO,QAAQ;GAC7C,OAAO,IAAI,qBAAqB;GAChC,OAAO;IAAE;IAAU;GAAM;EAC1B;EAIA,IAAI,QAAQ,SAAS,YAAY,OAAO,KAAA;EAExC,OAAO,IACN,kCAAkC,QAAQ,IAAI,oBAC/C;EAQA,OAAO;GAAE,UAAA,MAPc,OAAO,uBAAuB,EACpD,SAAS,QACV,CAAC;GAKkB,UAAA,MAJI,OAAO,6BAA6B;IAC1D,QAAQ;IACR,SAAS;GACV,CAAC;EAC2B;CAC7B,EACD;AACD;;;;;AAMA,SAAgB,oBACf,OAA2B,kBAAkB,GACxB;CACrB,OAAO,iBAAiB,MAAM,OAAO,CAAC;AACvC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ConstructManifest, Declaration } from "@geekmidas/manifest";
|
|
2
|
-
//#endregion
|
|
3
2
|
//#region src/errors.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The errors gkm raises on purpose.
|
|
@@ -639,6 +638,149 @@ interface CustomStateConfig {
|
|
|
639
638
|
*/
|
|
640
639
|
type StateConfig = LocalStateConfig | SSMStateConfig | S3StateConfig | CustomStateConfig;
|
|
641
640
|
//#endregion
|
|
641
|
+
//#region src/reconcile/discover.d.ts
|
|
642
|
+
/** The construct face discovery needs: an id, and the ability to declare. */
|
|
643
|
+
interface Declarable {
|
|
644
|
+
id: string;
|
|
645
|
+
declare(): Declaration[];
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Whether a module export is a construct.
|
|
649
|
+
*
|
|
650
|
+
* Deliberately loose about what else it carries — a construct that also has a
|
|
651
|
+
* `service` is still a construct, and requiring one would exclude the kinds that
|
|
652
|
+
* own no address.
|
|
653
|
+
*/
|
|
654
|
+
declare function isDeclarable(value: unknown): value is Declarable;
|
|
655
|
+
interface DiscoverOptions {
|
|
656
|
+
/** The glob(s) to search. One pattern, not one per kind. */
|
|
657
|
+
patterns: string | readonly string[];
|
|
658
|
+
cwd?: string;
|
|
659
|
+
/**
|
|
660
|
+
* Re-import changed modules, for the dev watcher.
|
|
661
|
+
*
|
|
662
|
+
* A single glob makes discovery more central, not less: a new construct file
|
|
663
|
+
* has to be picked up on `add`, not only on `change`.
|
|
664
|
+
*/
|
|
665
|
+
bustCache?: boolean;
|
|
666
|
+
/**
|
|
667
|
+
* Filled in with where each construct was found, when provided.
|
|
668
|
+
*
|
|
669
|
+
* Discovery is the only thing that knows: it globbed the files and imported
|
|
670
|
+
* them. Everything downstream that needs to *write* an import — the build,
|
|
671
|
+
* generating a server entry that reads a surface's logger — would otherwise
|
|
672
|
+
* have to be told the path in config, which is the string this removes.
|
|
673
|
+
*
|
|
674
|
+
* An out-parameter rather than a second return value so that every existing
|
|
675
|
+
* caller, which wants the manifest and nothing else, is unchanged.
|
|
676
|
+
*/
|
|
677
|
+
sources?: Record<string, ConstructSource>;
|
|
678
|
+
/**
|
|
679
|
+
* Filled in, when provided, with the files each worker's background work is
|
|
680
|
+
* declared in — its crons, queue consumers and topic subscribers — keyed by
|
|
681
|
+
* the worker.
|
|
682
|
+
*
|
|
683
|
+
* What says which app's build carries a worker's entry: the one whose
|
|
684
|
+
* directory holds its work. A worker declares no path of its own.
|
|
685
|
+
*/
|
|
686
|
+
background?: Record<string, string[]>;
|
|
687
|
+
/**
|
|
688
|
+
* Filled in, when provided, with the files that export something built
|
|
689
|
+
* from each surface — an endpoint, a WebSocket route — keyed by the
|
|
690
|
+
* surface. What a surface that serves itself imports its routes from.
|
|
691
|
+
*/
|
|
692
|
+
served?: Record<string, string[]>;
|
|
693
|
+
/**
|
|
694
|
+
* Filled in, when provided, with each worker's subscribers — by the export
|
|
695
|
+
* a push route is named after, and the key its deliveries come from: its
|
|
696
|
+
* topic's, or its bucket's events — keyed by the worker.
|
|
697
|
+
*
|
|
698
|
+
* What says which worker SNS pushes to, and on which paths: a build bound
|
|
699
|
+
* for a server records no subscriber in the manifest, because none has a
|
|
700
|
+
* handler of its own there.
|
|
701
|
+
*/
|
|
702
|
+
subscribers?: Record<string, BoundSubscriber[]>;
|
|
703
|
+
/**
|
|
704
|
+
* Import the construct modules in this sandbox rather than in this
|
|
705
|
+
* process. Defaults to the run's own (`withSandbox`), so a deploy's every
|
|
706
|
+
* discovery — the engine's included — happens there; with neither, they
|
|
707
|
+
* are imported here, as before.
|
|
708
|
+
*/
|
|
709
|
+
sandbox?: Sandbox;
|
|
710
|
+
}
|
|
711
|
+
/** A worker's subscriber — to a topic or to a bucket — as discovery found it. */
|
|
712
|
+
interface BoundSubscriber {
|
|
713
|
+
/** Its export — what its push route is named after. */
|
|
714
|
+
name: string;
|
|
715
|
+
/**
|
|
716
|
+
* The env key its deliveries come from: its topic's publisher connection
|
|
717
|
+
* string, or its bucket's events connection string. An `sns://` value is
|
|
718
|
+
* what makes SNS push to it.
|
|
719
|
+
*/
|
|
720
|
+
connectionKey: string;
|
|
721
|
+
/**
|
|
722
|
+
* The event types a topic subscriber names — its SNS subscription's filter
|
|
723
|
+
* on the `type` attribute the topic's publisher sets. Absent for a
|
|
724
|
+
* bucket's subscriber: S3 sets no such attribute, and the subscriber's own
|
|
725
|
+
* filter decides.
|
|
726
|
+
*/
|
|
727
|
+
events?: readonly string[];
|
|
728
|
+
}
|
|
729
|
+
/** Importing a construct module, or declaring one, threw in the sandbox. */
|
|
730
|
+
declare class ConstructDiscoveryFailed extends Error {
|
|
731
|
+
readonly errorName: string;
|
|
732
|
+
readonly detail: string;
|
|
733
|
+
constructor(errorName: string, detail: string);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* The constructs' declarations hold something that is not data, and the
|
|
737
|
+
* sandbox they were discovered in hands the deploy nothing but data.
|
|
738
|
+
*/
|
|
739
|
+
declare class ConstructsNotSerializable extends Error {
|
|
740
|
+
readonly paths: readonly string[];
|
|
741
|
+
constructor(paths: readonly string[]);
|
|
742
|
+
}
|
|
743
|
+
/** Where a construct was declared, and under what name. */
|
|
744
|
+
interface ConstructSource {
|
|
745
|
+
/** Absolute path to the module that exported it. */
|
|
746
|
+
file: string;
|
|
747
|
+
/** The name it was exported as — what an import statement has to say. */
|
|
748
|
+
exportName: string;
|
|
749
|
+
/**
|
|
750
|
+
* The exported construct itself.
|
|
751
|
+
*
|
|
752
|
+
* What a declaration cannot say — whether it serves itself — the object can
|
|
753
|
+
* be asked, and discovery already imported it.
|
|
754
|
+
*/
|
|
755
|
+
construct: unknown;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Build the construct manifest for a project.
|
|
759
|
+
*
|
|
760
|
+
* Runs the manifest's own validation before returning, so an app is wrong here
|
|
761
|
+
* — where the error names a file — rather than at deploy.
|
|
762
|
+
*
|
|
763
|
+
* @throws {DuplicateConstruct} when two exports claim one id.
|
|
764
|
+
*/
|
|
765
|
+
declare function discover(options: DiscoverOptions): Promise<ConstructManifest>;
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/providers/types.d.ts
|
|
768
|
+
/** The manifest kinds a stage can name a provider for. */
|
|
769
|
+
declare const PROVIDER_KINDS: readonly ['objects', 'inbox'];
|
|
770
|
+
type ProviderKind = (typeof PROVIDER_KINDS)[number];
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region src/providers/ses/config.d.ts
|
|
773
|
+
/** `inbox: { provider: 'ses' }` — each inbox received by SES in the stage's account. */
|
|
774
|
+
interface SesInboxConfig {
|
|
775
|
+
provider: 'ses';
|
|
776
|
+
/**
|
|
777
|
+
* Where mail is received, and the inbox's bucket and topic live. Defaults
|
|
778
|
+
* to the secrets store's region, then `AWS_REGION` — and must be one SES
|
|
779
|
+
* receives mail in.
|
|
780
|
+
*/
|
|
781
|
+
region?: string;
|
|
782
|
+
}
|
|
783
|
+
//#endregion
|
|
642
784
|
//#region src/deploy/credentials.d.ts
|
|
643
785
|
/**
|
|
644
786
|
* What each kind of credential is asked for with, and what it is.
|
|
@@ -1040,132 +1182,6 @@ type DeployEvent = {
|
|
|
1040
1182
|
/** Every `type` a deploy event can have. */
|
|
1041
1183
|
type DeployEventType = DeployEvent['type'];
|
|
1042
1184
|
//#endregion
|
|
1043
|
-
//#region src/reconcile/discover.d.ts
|
|
1044
|
-
/** The construct face discovery needs: an id, and the ability to declare. */
|
|
1045
|
-
interface Declarable {
|
|
1046
|
-
id: string;
|
|
1047
|
-
declare(): Declaration[];
|
|
1048
|
-
}
|
|
1049
|
-
/**
|
|
1050
|
-
* Whether a module export is a construct.
|
|
1051
|
-
*
|
|
1052
|
-
* Deliberately loose about what else it carries — a construct that also has a
|
|
1053
|
-
* `service` is still a construct, and requiring one would exclude the kinds that
|
|
1054
|
-
* own no address.
|
|
1055
|
-
*/
|
|
1056
|
-
declare function isDeclarable(value: unknown): value is Declarable;
|
|
1057
|
-
interface DiscoverOptions {
|
|
1058
|
-
/** The glob(s) to search. One pattern, not one per kind. */
|
|
1059
|
-
patterns: string | readonly string[];
|
|
1060
|
-
cwd?: string;
|
|
1061
|
-
/**
|
|
1062
|
-
* Re-import changed modules, for the dev watcher.
|
|
1063
|
-
*
|
|
1064
|
-
* A single glob makes discovery more central, not less: a new construct file
|
|
1065
|
-
* has to be picked up on `add`, not only on `change`.
|
|
1066
|
-
*/
|
|
1067
|
-
bustCache?: boolean;
|
|
1068
|
-
/**
|
|
1069
|
-
* Filled in with where each construct was found, when provided.
|
|
1070
|
-
*
|
|
1071
|
-
* Discovery is the only thing that knows: it globbed the files and imported
|
|
1072
|
-
* them. Everything downstream that needs to *write* an import — the build,
|
|
1073
|
-
* generating a server entry that reads a surface's logger — would otherwise
|
|
1074
|
-
* have to be told the path in config, which is the string this removes.
|
|
1075
|
-
*
|
|
1076
|
-
* An out-parameter rather than a second return value so that every existing
|
|
1077
|
-
* caller, which wants the manifest and nothing else, is unchanged.
|
|
1078
|
-
*/
|
|
1079
|
-
sources?: Record<string, ConstructSource>;
|
|
1080
|
-
/**
|
|
1081
|
-
* Filled in, when provided, with the files each worker's background work is
|
|
1082
|
-
* declared in — its crons, queue consumers and topic subscribers — keyed by
|
|
1083
|
-
* the worker.
|
|
1084
|
-
*
|
|
1085
|
-
* What says which app's build carries a worker's entry: the one whose
|
|
1086
|
-
* directory holds its work. A worker declares no path of its own.
|
|
1087
|
-
*/
|
|
1088
|
-
background?: Record<string, string[]>;
|
|
1089
|
-
/**
|
|
1090
|
-
* Filled in, when provided, with the files that export something built
|
|
1091
|
-
* from each surface — an endpoint, a WebSocket route — keyed by the
|
|
1092
|
-
* surface. What a surface that serves itself imports its routes from.
|
|
1093
|
-
*/
|
|
1094
|
-
served?: Record<string, string[]>;
|
|
1095
|
-
/**
|
|
1096
|
-
* Filled in, when provided, with each worker's subscribers — by the export
|
|
1097
|
-
* a push route is named after, and the key its deliveries come from: its
|
|
1098
|
-
* topic's, or its bucket's events — keyed by the worker.
|
|
1099
|
-
*
|
|
1100
|
-
* What says which worker SNS pushes to, and on which paths: a build bound
|
|
1101
|
-
* for a server records no subscriber in the manifest, because none has a
|
|
1102
|
-
* handler of its own there.
|
|
1103
|
-
*/
|
|
1104
|
-
subscribers?: Record<string, BoundSubscriber[]>;
|
|
1105
|
-
/**
|
|
1106
|
-
* Import the construct modules in this sandbox rather than in this
|
|
1107
|
-
* process. Defaults to the run's own (`withSandbox`), so a deploy's every
|
|
1108
|
-
* discovery — the engine's included — happens there; with neither, they
|
|
1109
|
-
* are imported here, as before.
|
|
1110
|
-
*/
|
|
1111
|
-
sandbox?: Sandbox;
|
|
1112
|
-
}
|
|
1113
|
-
/** A worker's subscriber — to a topic or to a bucket — as discovery found it. */
|
|
1114
|
-
interface BoundSubscriber {
|
|
1115
|
-
/** Its export — what its push route is named after. */
|
|
1116
|
-
name: string;
|
|
1117
|
-
/**
|
|
1118
|
-
* The env key its deliveries come from: its topic's publisher connection
|
|
1119
|
-
* string, or its bucket's events connection string. An `sns://` value is
|
|
1120
|
-
* what makes SNS push to it.
|
|
1121
|
-
*/
|
|
1122
|
-
connectionKey: string;
|
|
1123
|
-
/**
|
|
1124
|
-
* The event types a topic subscriber names — its SNS subscription's filter
|
|
1125
|
-
* on the `type` attribute the topic's publisher sets. Absent for a
|
|
1126
|
-
* bucket's subscriber: S3 sets no such attribute, and the subscriber's own
|
|
1127
|
-
* filter decides.
|
|
1128
|
-
*/
|
|
1129
|
-
events?: readonly string[];
|
|
1130
|
-
}
|
|
1131
|
-
/** Importing a construct module, or declaring one, threw in the sandbox. */
|
|
1132
|
-
declare class ConstructDiscoveryFailed extends Error {
|
|
1133
|
-
readonly errorName: string;
|
|
1134
|
-
readonly detail: string;
|
|
1135
|
-
constructor(errorName: string, detail: string);
|
|
1136
|
-
}
|
|
1137
|
-
/**
|
|
1138
|
-
* The constructs' declarations hold something that is not data, and the
|
|
1139
|
-
* sandbox they were discovered in hands the deploy nothing but data.
|
|
1140
|
-
*/
|
|
1141
|
-
declare class ConstructsNotSerializable extends Error {
|
|
1142
|
-
readonly paths: readonly string[];
|
|
1143
|
-
constructor(paths: readonly string[]);
|
|
1144
|
-
}
|
|
1145
|
-
/** Where a construct was declared, and under what name. */
|
|
1146
|
-
interface ConstructSource {
|
|
1147
|
-
/** Absolute path to the module that exported it. */
|
|
1148
|
-
file: string;
|
|
1149
|
-
/** The name it was exported as — what an import statement has to say. */
|
|
1150
|
-
exportName: string;
|
|
1151
|
-
/**
|
|
1152
|
-
* The exported construct itself.
|
|
1153
|
-
*
|
|
1154
|
-
* What a declaration cannot say — whether it serves itself — the object can
|
|
1155
|
-
* be asked, and discovery already imported it.
|
|
1156
|
-
*/
|
|
1157
|
-
construct: unknown;
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* Build the construct manifest for a project.
|
|
1161
|
-
*
|
|
1162
|
-
* Runs the manifest's own validation before returning, so an app is wrong here
|
|
1163
|
-
* — where the error names a file — rather than at deploy.
|
|
1164
|
-
*
|
|
1165
|
-
* @throws {DuplicateConstruct} when two exports claim one id.
|
|
1166
|
-
*/
|
|
1167
|
-
declare function discover(options: DiscoverOptions): Promise<ConstructManifest>;
|
|
1168
|
-
//#endregion
|
|
1169
1185
|
//#region src/target/types.d.ts
|
|
1170
1186
|
/**
|
|
1171
1187
|
* Which family of defaults a target's deploys belong to.
|
|
@@ -6266,6 +6282,7 @@ declare const WorkspaceConfigSchema: ZodObject<{
|
|
|
6266
6282
|
sampleRate: ZodOptional<ZodNumber>;
|
|
6267
6283
|
}, $strict>]>>>;
|
|
6268
6284
|
objects: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
6285
|
+
inbox: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
6269
6286
|
backups: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
6270
6287
|
}, $strip>>;
|
|
6271
6288
|
stages: ZodObject<{
|
|
@@ -6740,6 +6757,23 @@ type StageTelemetryConfig = 'self-hosted' | SelfHostedTelemetryConfig | OtlpTele
|
|
|
6740
6757
|
* ```
|
|
6741
6758
|
*/
|
|
6742
6759
|
type StageObjectsConfig = 'external' | S3ObjectsConfig | false;
|
|
6760
|
+
/**
|
|
6761
|
+
* What receives one deployed stage's inboxes — `deploy.inbox`, by stage:
|
|
6762
|
+
*
|
|
6763
|
+
* - `{ provider: 'ses' }` — the deploy creates each inbox in the stage's AWS
|
|
6764
|
+
* account: its own bucket and topic, the domain's SES identity and MX
|
|
6765
|
+
* records, and a receipt rule in the region's active rule set.
|
|
6766
|
+
* - `'external'` — the default: the stage's secrets hold each inbox's keys.
|
|
6767
|
+
* - `false` — the stage receives no mail; an inbox on it is refused.
|
|
6768
|
+
*
|
|
6769
|
+
* Every local stage receives through Mailpit, whatever this says.
|
|
6770
|
+
*
|
|
6771
|
+
* @example
|
|
6772
|
+
* ```ts
|
|
6773
|
+
* inbox: { production: { provider: 'ses', region: 'eu-west-1' } }
|
|
6774
|
+
* ```
|
|
6775
|
+
*/
|
|
6776
|
+
type StageInboxConfig = 'external' | SesInboxConfig | false;
|
|
6743
6777
|
/**
|
|
6744
6778
|
* One deployed compose stage's backups — `deploy.backups`, by stage.
|
|
6745
6779
|
*
|
|
@@ -6898,6 +6932,11 @@ interface DeployConfig<S extends string = string> {
|
|
|
6898
6932
|
* `ObjectStorage` and `FileServer` produce. See {@link StageObjectsConfig}.
|
|
6899
6933
|
*/
|
|
6900
6934
|
objects?: StageMap<S, StageObjectsConfig>;
|
|
6935
|
+
/**
|
|
6936
|
+
* What receives each deployed stage's inboxes — the `inbox` kind `Inbox`
|
|
6937
|
+
* produces. See {@link StageInboxConfig}.
|
|
6938
|
+
*/
|
|
6939
|
+
inbox?: StageMap<S, StageInboxConfig>;
|
|
6901
6940
|
/**
|
|
6902
6941
|
* When each deployed compose stage's databases are backed up, and how
|
|
6903
6942
|
* long a backup is kept — see {@link StageBackupsConfig}.
|
|
@@ -7895,5 +7934,5 @@ interface GkmConfig {
|
|
|
7895
7934
|
dns?: WorkspaceDnsConfig;
|
|
7896
7935
|
}
|
|
7897
7936
|
//#endregion
|
|
7898
|
-
export { TargetOptions as $, BackendFramework as A,
|
|
7899
|
-
//# sourceMappingURL=types-
|
|
7937
|
+
export { TargetOptions as $, BackendFramework as A, ReleasedImage as At, isPhase2DeployTarget as B, SandboxExecOptions as Bt, SecretsConfig as C, DiscoverOptions as Ct, WorkspaceConfig as D, StateLocked as Dt, StageTelemetryConfig as E, LocalStateInCi as Et, SUPPORTED_DEPLOY_TARGETS as F, DeployIdentity as Ft, DeployPhaseContext as G, GkmError as Gt, validateWorkspaceConfig as H, SandboxResult as Ht, WorkspaceConfigSchema as I, deployIdentity as It, DeployTarget as J, DeployRuntime as K, formatValidationErrors as L, SECRETS_DIR_ENV as Lt, FrontendFramework as M, GithubActor as Mt, MobileFramework as N, LocalActor as Nt, WorkspaceInput as O, StateStore as Ot, PHASE_2_DEPLOY_TARGETS as P, StageSecrets as Pt, TargetEvent as Q, getDeployTargetError as R, Sandbox as Rt, OtlpTelemetryConfig as S, ConstructsNotSerializable as St, SharedConfig as T, isDeclarable as Tt, AnyDeployTarget as U, SecretNameInvalid as Ut, safeValidateWorkspaceConfig as V, SandboxOutput as Vt, DeployFailure as W, confineCwd as Wt, DeployTargetEntry as X, DeployTargetCapabilities as Y, DeployTargetLogger as Z, InferredWorkspaceConfig as _, StoredCredentialsOptions as _t, Routes as a, DeployPhase as at, NormalizedAppConfig as b, ProviderKind as bt, AppInput as c, AppDeployResult as ct, ConstrainedApps as d, Credential as dt, TargetOptionsIssue as et, DeployConfig as f, CredentialKind as ft, InferAppNames as g, MissingCredential as gt, DokployWorkspaceConfig as h, CredentialRequest as ht, OpenApiConfig as i, DeployEventType as it, Framework as j, Actor as jt, isWorkspaceConfig as k, StateVersionConflict as kt, AppsRecord as l, DeployResult as lt, DevConfig as m, CredentialProvider as mt, EmailBackend as n, DeployEvent as nt, AppConfig as o, ResourceChange as ot, DeployTargetName as p, CredentialKinds as pt, DeploySecrets as q, GkmConfig as r, DeployEventError as rt, AppConfigInput as s, ResourceVia as st, CacheBackend as t, TargetOptionsSchema as tt, ComposeWorkspaceConfig as u, AwsCredential as ut, LoadedConfig as v, chainCredentials as vt, SelfHostedTelemetryConfig as w, discover as wt, NormalizedWorkspace as x, ConstructDiscoveryFailed as xt, ModelsConfig as y, storedCredentials as yt, isDeployTargetSupported as z, SandboxCwdEscape as zt };
|
|
7938
|
+
//# sourceMappingURL=types-C6hDCkV2.d.mts.map
|