@geekmidas/cli 10.0.0-alpha.136 → 10.0.0-alpha.137
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-D3p5WQOv.cjs → EndpointGenerator-BGKb_Ie6.cjs} +2 -2
- package/dist/{EndpointGenerator-D3p5WQOv.cjs.map → EndpointGenerator-BGKb_Ie6.cjs.map} +1 -1
- package/dist/{EndpointGenerator-Bm6xwLIF.mjs → EndpointGenerator-DDfPq2AZ.mjs} +2 -2
- package/dist/{EndpointGenerator-Bm6xwLIF.mjs.map → EndpointGenerator-DDfPq2AZ.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-BZJtRv5p.cjs → GoDaddyProvider-BcP8dWX-.cjs} +2 -2
- package/dist/{GoDaddyProvider-BZJtRv5p.cjs.map → GoDaddyProvider-BcP8dWX-.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-CDTSKt1k.mjs → GoDaddyProvider-D8KVrUYm.mjs} +2 -2
- package/dist/{GoDaddyProvider-CDTSKt1k.mjs.map → GoDaddyProvider-D8KVrUYm.mjs.map} +1 -1
- package/dist/{LegacyStateStore-CfhOur9W.mjs → LegacyStateStore-63cJw4AV.mjs} +3 -3
- package/dist/{LegacyStateStore-CfhOur9W.mjs.map → LegacyStateStore-63cJw4AV.mjs.map} +1 -1
- package/dist/{LegacyStateStore-CmQbzQGC.cjs → LegacyStateStore-De4hd05H.cjs} +3 -3
- package/dist/{LegacyStateStore-CmQbzQGC.cjs.map → LegacyStateStore-De4hd05H.cjs.map} +1 -1
- package/dist/{LocalStateStore-3ZT4-yUX.cjs → LocalStateStore-SiFl-guR.cjs} +2 -2
- package/dist/{LocalStateStore-3ZT4-yUX.cjs.map → LocalStateStore-SiFl-guR.cjs.map} +1 -1
- package/dist/{LocalStateStore-k3i8wp2q.mjs → LocalStateStore-jDPIJHLS.mjs} +2 -2
- package/dist/{LocalStateStore-k3i8wp2q.mjs.map → LocalStateStore-jDPIJHLS.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-HkNH_xw-.cjs → OpenApiTsGenerator-DoLFZu4i.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-HkNH_xw-.cjs.map → OpenApiTsGenerator-DoLFZu4i.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BB6dGP8i.mjs → OpenApiTsGenerator-l1DUhgLV.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-BB6dGP8i.mjs.map → OpenApiTsGenerator-l1DUhgLV.mjs.map} +1 -1
- package/dist/{S3StateStore-D71GhBoc.mjs → S3StateStore-CudutATE.mjs} +2 -2
- package/dist/{S3StateStore-D71GhBoc.mjs.map → S3StateStore-CudutATE.mjs.map} +1 -1
- package/dist/{S3StateStore-Cf2DoRBZ.cjs → S3StateStore-UvVhNR69.cjs} +2 -2
- package/dist/{S3StateStore-Cf2DoRBZ.cjs.map → S3StateStore-UvVhNR69.cjs.map} +1 -1
- package/dist/{SSMStateStore-agvlAonC.cjs → SSMStateStore-BpZqNwDW.cjs} +2 -2
- package/dist/{SSMStateStore-agvlAonC.cjs.map → SSMStateStore-BpZqNwDW.cjs.map} +1 -1
- package/dist/{SSMStateStore-B40DvAuy.mjs → SSMStateStore-kpFFubgP.mjs} +2 -2
- package/dist/{SSMStateStore-B40DvAuy.mjs.map → SSMStateStore-kpFFubgP.mjs.map} +1 -1
- package/dist/{SubscriberGenerator-uDZW1ddC.cjs → SubscriberGenerator-DDCqRTbq.cjs} +3 -3
- package/dist/{SubscriberGenerator-uDZW1ddC.cjs.map → SubscriberGenerator-DDCqRTbq.cjs.map} +1 -1
- package/dist/{SubscriberGenerator-CI7roxx9.mjs → SubscriberGenerator-zUd87wvg.mjs} +3 -3
- package/dist/{SubscriberGenerator-CI7roxx9.mjs.map → SubscriberGenerator-zUd87wvg.mjs.map} +1 -1
- package/dist/{add-BpJ40b1f.cjs → add-BDCl-l_l.cjs} +9 -15
- package/dist/add-BDCl-l_l.cjs.map +1 -0
- package/dist/{add-Cj6yp560.mjs → add-D1cRGiH4.mjs} +9 -15
- package/dist/add-D1cRGiH4.mjs.map +1 -0
- package/dist/{bundler-BjIag8nr.mjs → bundler-BKE3xo6D.mjs} +5 -5
- package/dist/{bundler-BjIag8nr.mjs.map → bundler-BKE3xo6D.mjs.map} +1 -1
- package/dist/{bundler-D0YmORqs.cjs → bundler-p1JT47FO.cjs} +5 -5
- package/dist/{bundler-D0YmORqs.cjs.map → bundler-p1JT47FO.cjs.map} +1 -1
- package/dist/{cli-ffQmsXua.cjs → cli-BxWKJRgE.cjs} +3 -3
- package/dist/{cli-ffQmsXua.cjs.map → cli-BxWKJRgE.cjs.map} +1 -1
- package/dist/{cli-CJwPXzWW.mjs → cli-CaqHWpud.mjs} +3 -3
- package/dist/{cli-CJwPXzWW.mjs.map → cli-CaqHWpud.mjs.map} +1 -1
- package/dist/{compose-D6L79YLV.mjs → compose-BAT7wsdE.mjs} +13 -19
- package/dist/compose-BAT7wsdE.mjs.map +1 -0
- package/dist/{compose-Diz_QC7m.cjs → compose-DKddjrXC.cjs} +13 -19
- package/dist/compose-DKddjrXC.cjs.map +1 -0
- package/dist/{config-CnrwEcSa.d.mts → config-B7HaIfYM.d.mts} +3 -3
- package/dist/{config-CnrwEcSa.d.mts.map → config-B7HaIfYM.d.mts.map} +1 -1
- package/dist/{config-DlKOvs3Y.d.cts → config-DySjXKd2.d.cts} +3 -3
- package/dist/{config-DlKOvs3Y.d.cts.map → config-DySjXKd2.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-CM0rxWmS.cjs → credentialSchemas-BJMvQlks.cjs} +2 -2
- package/dist/{credentialSchemas-CM0rxWmS.cjs.map → credentialSchemas-BJMvQlks.cjs.map} +1 -1
- package/dist/{credentialSchemas-DPOGqOrU.mjs → credentialSchemas-DYzO2_yG.mjs} +2 -2
- package/dist/{credentialSchemas-DPOGqOrU.mjs.map → credentialSchemas-DYzO2_yG.mjs.map} +1 -1
- package/dist/deploy/public.cjs +8 -8
- package/dist/deploy/public.d.cts +3 -3
- package/dist/deploy/public.d.mts +3 -3
- package/dist/deploy/public.mjs +8 -8
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +2 -2
- package/dist/{deploy-D6wCG-OQ.mjs → deploy-C5UDDUU7.mjs} +26 -40
- package/dist/deploy-C5UDDUU7.mjs.map +1 -0
- package/dist/{deploy-CZHTReh1.cjs → deploy-CwlYj_tU.cjs} +26 -40
- package/dist/deploy-CwlYj_tU.cjs.map +1 -0
- package/dist/{derive-Bsnm81mg.mjs → derive-Cd7Hl3r2.mjs} +4 -4
- package/dist/derive-Cd7Hl3r2.mjs.map +1 -0
- package/dist/{derive-ClMgyPzp.cjs → derive-CgZfoBU2.cjs} +3 -3
- package/dist/derive-CgZfoBU2.cjs.map +1 -0
- package/dist/{discover-DEOspD9M.cjs → discover-B3G8eyWX.cjs} +181 -43
- package/dist/discover-B3G8eyWX.cjs.map +1 -0
- package/dist/{discover-DOhYSKY_.mjs → discover-DWtHjc1x.mjs} +177 -39
- package/dist/discover-DWtHjc1x.mjs.map +1 -0
- package/dist/{dokploy-Dad-f6mO.mjs → dokploy-BaGPz931.mjs} +2 -2
- package/dist/{dokploy-Dad-f6mO.mjs.map → dokploy-BaGPz931.mjs.map} +1 -1
- package/dist/{dokploy-BeqMm-aL.cjs → dokploy-D8JRpnNM.cjs} +2 -2
- package/dist/{dokploy-BeqMm-aL.cjs.map → dokploy-D8JRpnNM.cjs.map} +1 -1
- package/dist/{eas-CamaGWDL.mjs → eas-_k4YqH8L.mjs} +3 -3
- package/dist/{eas-CamaGWDL.mjs.map → eas-_k4YqH8L.mjs.map} +1 -1
- package/dist/{eas-DWYhlJCr.cjs → eas-m37zU75L.cjs} +3 -3
- package/dist/{eas-DWYhlJCr.cjs.map → eas-m37zU75L.cjs.map} +1 -1
- package/dist/emit-Bj6XSivk.mjs +136 -0
- package/dist/emit-Bj6XSivk.mjs.map +1 -0
- package/dist/emit-CDC__ubE.cjs +147 -0
- package/dist/emit-CDC__ubE.cjs.map +1 -0
- package/dist/{encryption-DmDnVYe4.mjs → encryption-B1wVX-iK.mjs} +2 -2
- package/dist/{encryption-DmDnVYe4.mjs.map → encryption-B1wVX-iK.mjs.map} +1 -1
- package/dist/{encryption-UjD4kDRB.cjs → encryption-CKt33qlB.cjs} +2 -2
- package/dist/{encryption-UjD4kDRB.cjs.map → encryption-CKt33qlB.cjs.map} +1 -1
- package/dist/{engine-BxHQrByl.mjs → engine-B66avdZg.mjs} +9 -14
- package/dist/engine-B66avdZg.mjs.map +1 -0
- package/dist/{engine-BaRuSjJf.cjs → engine-CazVehBM.cjs} +9 -14
- package/dist/engine-CazVehBM.cjs.map +1 -0
- package/dist/{github-Fvg_6wTt.mjs → github-DJS6FXj4.mjs} +5 -5
- package/dist/{github-Fvg_6wTt.mjs.map → github-DJS6FXj4.mjs.map} +1 -1
- package/dist/{github-BO-bu8kf.cjs → github-DvoKzLo9.cjs} +5 -5
- package/dist/{github-BO-bu8kf.cjs.map → github-DvoKzLo9.cjs.map} +1 -1
- package/dist/{googlePlay-Dnlvz3rE.cjs → googlePlay-BRAykqXD.cjs} +3 -3
- package/dist/{googlePlay-Dnlvz3rE.cjs.map → googlePlay-BRAykqXD.cjs.map} +1 -1
- package/dist/{googlePlay-C5TgJQcS.mjs → googlePlay-B_5CB5YP.mjs} +3 -3
- package/dist/{googlePlay-C5TgJQcS.mjs.map → googlePlay-B_5CB5YP.mjs.map} +1 -1
- package/dist/{index-BYJMHnMt.d.cts → index-BymyHYdL.d.mts} +2 -2
- package/dist/{index-BYJMHnMt.d.cts.map → index-BymyHYdL.d.mts.map} +1 -1
- package/dist/{index-CBCGDhD6.d.mts → index-CTKfBwU3.d.cts} +2 -2
- package/dist/{index-CBCGDhD6.d.mts.map → index-CTKfBwU3.d.cts.map} +1 -1
- package/dist/index.cjs +68 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +68 -68
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-Qe7kNf7P.mjs → migrate-CUXjEMyM.mjs} +3 -3
- package/dist/{migrate-Qe7kNf7P.mjs.map → migrate-CUXjEMyM.mjs.map} +1 -1
- package/dist/{migrate-BYvhE1Ek.cjs → migrate-DgBQ5hMl.cjs} +3 -3
- package/dist/{migrate-BYvhE1Ek.cjs.map → migrate-DgBQ5hMl.cjs.map} +1 -1
- package/dist/{migrate-DYncKsiF.cjs → migrate-Vz5SqDC9.cjs} +2 -2
- package/dist/{migrate-DYncKsiF.cjs.map → migrate-Vz5SqDC9.cjs.map} +1 -1
- package/dist/{migrate-SLRDSOkN.mjs → migrate-wns_j863.mjs} +2 -2
- package/dist/{migrate-SLRDSOkN.mjs.map → migrate-wns_j863.mjs.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-CZ7650El.mjs → publish-BZ4WnlQF.mjs} +2 -2
- package/dist/{publish-CZ7650El.mjs.map → publish-BZ4WnlQF.mjs.map} +1 -1
- package/dist/{publish-CdgAuHGF.cjs → publish-C1WzNW-y.cjs} +2 -2
- package/dist/{publish-CdgAuHGF.cjs.map → publish-C1WzNW-y.cjs.map} +1 -1
- package/dist/{ready-DhkmqsOH.cjs → ready-D0u7jGFV.cjs} +5 -5
- package/dist/{ready-DhkmqsOH.cjs.map → ready-D0u7jGFV.cjs.map} +1 -1
- package/dist/{ready-AcAH2WL6.mjs → ready-DyvWvbiq.mjs} +5 -5
- package/dist/{ready-AcAH2WL6.mjs.map → ready-DyvWvbiq.mjs.map} +1 -1
- package/dist/reconcile/public.cjs +3 -3
- package/dist/reconcile/public.d.cts +24 -29
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +24 -29
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/{resolve-MoZFp8BC.mjs → resolve-D42nz9oe.mjs} +4 -4
- package/dist/{resolve-MoZFp8BC.mjs.map → resolve-D42nz9oe.mjs.map} +1 -1
- package/dist/{resolve-jB0LX21y.cjs → resolve-DBXRljeQ.cjs} +4 -4
- package/dist/{resolve-jB0LX21y.cjs.map → resolve-DBXRljeQ.cjs.map} +1 -1
- package/dist/{rollback-BpM_ekEG.mjs → rollback-DKWjVtwa.mjs} +4 -4
- package/dist/{rollback-BpM_ekEG.mjs.map → rollback-DKWjVtwa.mjs.map} +1 -1
- package/dist/{rollback-CTkBmEzm.cjs → rollback-s8OXlOCr.cjs} +4 -4
- package/dist/{rollback-CTkBmEzm.cjs.map → rollback-s8OXlOCr.cjs.map} +1 -1
- package/dist/{runtime-CBro-1N4.d.cts → runtime-Dl601UcU.d.cts} +2 -2
- package/dist/{runtime-CBro-1N4.d.cts.map → runtime-Dl601UcU.d.cts.map} +1 -1
- package/dist/{runtime-f9aiOHxq.d.mts → runtime-mR2O0z64.d.mts} +2 -2
- package/dist/{runtime-f9aiOHxq.d.mts.map → runtime-mR2O0z64.d.mts.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 -4
- package/dist/sandbox/discover-worker.cjs.map +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -4
- package/dist/sandbox/discover-worker.mjs.map +1 -1
- package/dist/sandbox/migrate-worker.cjs +1 -1
- package/dist/sandbox/migrate-worker.mjs +1 -1
- package/dist/{seeds-6IhH9esB.cjs → seeds-D70hodXu.cjs} +25 -30
- package/dist/seeds-D70hodXu.cjs.map +1 -0
- package/dist/{seeds-D4qjzFDF.mjs → seeds-WyxyXjxu.mjs} +25 -30
- package/dist/seeds-WyxyXjxu.mjs.map +1 -0
- package/dist/{serverSetup-CRJvE-KF.cjs → serverSetup-3kQPTiSi.cjs} +5 -5
- package/dist/{serverSetup-CRJvE-KF.cjs.map → serverSetup-3kQPTiSi.cjs.map} +1 -1
- package/dist/{serverSetup-23Jmihhj.mjs → serverSetup-D2CKwf96.mjs} +5 -5
- package/dist/{serverSetup-23Jmihhj.mjs.map → serverSetup-D2CKwf96.mjs.map} +1 -1
- package/dist/{sniffer-Ve5oNbHX.cjs → sniffer-BXvUF1hF.cjs} +7 -7
- package/dist/{sniffer-Ve5oNbHX.cjs.map → sniffer-BXvUF1hF.cjs.map} +1 -1
- package/dist/{sniffer-DbGKPWFo.mjs → sniffer-C7Y1pnTH.mjs} +7 -7
- package/dist/{sniffer-DbGKPWFo.mjs.map → sniffer-C7Y1pnTH.mjs.map} +1 -1
- package/dist/{snsSubscriptions-Cr6pcIgx.cjs → snsSubscriptions-DNVQKnuw.cjs} +3 -3
- package/dist/{snsSubscriptions-Cr6pcIgx.cjs.map → snsSubscriptions-DNVQKnuw.cjs.map} +1 -1
- package/dist/{snsSubscriptions-CUi0Wtto.mjs → snsSubscriptions-DS6047gE.mjs} +3 -3
- package/dist/{snsSubscriptions-CUi0Wtto.mjs.map → snsSubscriptions-DS6047gE.mjs.map} +1 -1
- package/dist/{sst-WPkIfa64.mjs → sst-Bz2HJlqc.mjs} +2 -2
- package/dist/{sst-WPkIfa64.mjs.map → sst-Bz2HJlqc.mjs.map} +1 -1
- package/dist/{sst-CHOp2-qt.cjs → sst-lvCHdYsY.cjs} +2 -2
- package/dist/{sst-CHOp2-qt.cjs.map → sst-lvCHdYsY.cjs.map} +1 -1
- package/dist/{stage-BiLP7bXI.cjs → stage-BBre_tHU.cjs} +5 -8
- package/dist/stage-BBre_tHU.cjs.map +1 -0
- package/dist/{stage-DrHKRHLN.mjs → stage-_YcfLSj-.mjs} +5 -8
- package/dist/stage-_YcfLSj-.mjs.map +1 -0
- 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-DBwedwSS.cjs → terminal-BIZRxV-e.cjs} +2 -2
- package/dist/{terminal-DBwedwSS.cjs.map → terminal-BIZRxV-e.cjs.map} +1 -1
- package/dist/{terminal-CebFDhWQ.mjs → terminal-PEvt24kO.mjs} +2 -2
- package/dist/{terminal-CebFDhWQ.mjs.map → terminal-PEvt24kO.mjs.map} +1 -1
- package/dist/{types-C5Zvkpc_.d.mts → types-C-uwKr3O.d.mts} +1 -18
- package/dist/types-C-uwKr3O.d.mts.map +1 -0
- package/dist/{types-CSOoemtk.d.cts → types-DOYYfQme.d.cts} +1 -18
- package/dist/types-DOYYfQme.d.cts.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/package.json +15 -15
- package/dist/add-BpJ40b1f.cjs.map +0 -1
- package/dist/add-Cj6yp560.mjs.map +0 -1
- package/dist/compose-D6L79YLV.mjs.map +0 -1
- package/dist/compose-Diz_QC7m.cjs.map +0 -1
- package/dist/deploy-CZHTReh1.cjs.map +0 -1
- package/dist/deploy-D6wCG-OQ.mjs.map +0 -1
- package/dist/derive-Bsnm81mg.mjs.map +0 -1
- package/dist/derive-ClMgyPzp.cjs.map +0 -1
- package/dist/discover-DEOspD9M.cjs.map +0 -1
- package/dist/discover-DOhYSKY_.mjs.map +0 -1
- package/dist/emit-CYloptRS.cjs +0 -243
- package/dist/emit-CYloptRS.cjs.map +0 -1
- package/dist/emit-CiJGdy_f.mjs +0 -226
- package/dist/emit-CiJGdy_f.mjs.map +0 -1
- package/dist/engine-BaRuSjJf.cjs.map +0 -1
- package/dist/engine-BxHQrByl.mjs.map +0 -1
- package/dist/seeds-6IhH9esB.cjs.map +0 -1
- package/dist/seeds-D4qjzFDF.mjs.map +0 -1
- package/dist/stage-BiLP7bXI.cjs.map +0 -1
- package/dist/stage-DrHKRHLN.mjs.map +0 -1
- package/dist/types-C5Zvkpc_.d.mts.map +0 -1
- package/dist/types-CSOoemtk.d.cts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eas-DWYhlJCr.cjs","names":["GkmError","spawn","join","delimiter","appKey","loadStage","mobileStage","existsSync","readFile","easWorkflowPath","easWorkflow","writeFile","mkdir","dirname"],"sources":["../src/mobile/eas.ts"],"sourcesContent":["/**\n * `gkm eas:sync --stage <stage>`: a mobile app's EAS project set up for a\n * deployed stage, from what the workspace declares — so a store build, which\n * EAS runs on its own machines, outside gkm, is built with the same values\n * the stage's servers were deployed with.\n *\n * - **`eas.json`**: the stage's build profile (`build.<stage>`) reads its EAS\n * environment and listens on its channel; its submit profile\n * (`submit.<stage>.android`) has its Play track and release status — see\n * `mobileStage`. Every other field is left as it is.\n * - **The EAS environment**: each value the app's build reads for the stage\n * (`StackMobileApp.values`) — its scheme, its edges' public URLs under\n * `EXPO_PUBLIC_`, and every stage secret already named so — set with\n * `eas env:set`, as `plaintext`: a bundle inlines them, so none is secret.\n * Nothing else is written: no server key reaches EAS.\n */\n\nimport { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { delimiter, dirname, join } from 'node:path';\nimport type {\n\tConstructManifest,\n\tMobileAppDeclaration,\n} from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport { loadStage } from '../exec/stage.js';\nimport { appKey } from '../workspace/derive.js';\nimport { easWorkflow, easWorkflowPath } from './easWorkflow.js';\nimport { type MobileStage, mobileStage } from './stage.js';\n\nconst logger = console;\n\n/** The workspace declares no `MobileApp`: nothing to set up. */\nexport class NoMobileApp extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'The workspace declares no MobileApp, so there is no EAS project to set ' +\n\t\t\t\t\"up. Declare one: new MobileApp('App', { path: 'apps/app' }).dependsOn([api, auth]).\",\n\t\t);\n\t\tthis.name = 'NoMobileApp';\n\t}\n}\n\n/** Several `MobileApp`s, and nothing to say which. */\nexport class MobileAppNotChosen extends GkmError {\n\tconstructor(readonly apps: readonly string[]) {\n\t\tsuper(\n\t\t\t`The workspace declares ${apps.length} mobile apps (${apps.join(', ')}). ` +\n\t\t\t\t`Run from one's directory, or name it: --app ${apps[0]}.`,\n\t\t);\n\t\tthis.name = 'MobileAppNotChosen';\n\t}\n}\n\n/** `--app` names no `MobileApp`. */\nexport class MobileAppUnknown extends GkmError {\n\tconstructor(\n\t\treadonly app: string,\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${app}' is not one of the workspace's mobile apps (${apps.join(', ')}).`,\n\t\t);\n\t\tthis.name = 'MobileAppUnknown';\n\t}\n}\n\n/** `eas` is not installed where the app is. */\nexport class EasCliMissing extends GkmError {\n\tconstructor(readonly dir: string) {\n\t\tsuper(\n\t\t\t`No \\`eas\\` to run in ${dir}. Add it to the app: pnpm add -D eas-cli ` +\n\t\t\t\t'(or install it globally: npm install -g eas-cli).',\n\t\t);\n\t\tthis.name = 'EasCliMissing';\n\t}\n}\n\n/** `eas` refused a command. */\nexport class EasCommandFailed extends GkmError {\n\tconstructor(\n\t\treadonly command: string,\n\t\treadonly code: number | null,\n\t\treadonly stderr: string,\n\t) {\n\t\tsuper(\n\t\t\t`\\`eas ${command}\\` failed (exit ${code}): ${stderr.trim() || 'it said nothing'}. ` +\n\t\t\t\t'In CI, EXPO_TOKEN must be set; on this machine, `eas login`.',\n\t\t);\n\t\tthis.name = 'EasCommandFailed';\n\t}\n}\n\n/** A platform EAS builds for. */\nexport type EasPlatform = 'ios' | 'android';\n\n/** What gkm asks of EAS, so tests can stand in. */\nexport interface EasCli {\n\t/** Create or update a variable in one of the project's environments. */\n\tsetEnv(\n\t\tdir: string,\n\t\tvariable: { environment: string; name: string; value: string },\n\t): Promise<void>;\n\t/**\n\t * The fingerprint of the app's native code, as a build with `profile`\n\t * would compute it — what its runtime version is.\n\t */\n\tfingerprint(\n\t\tdir: string,\n\t\toptions: { platform: EasPlatform; profile: string },\n\t): Promise<string>;\n\t/** A finished store build of `profile` with that fingerprint, if any. */\n\tstoreBuild(\n\t\tdir: string,\n\t\toptions: { platform: EasPlatform; profile: string; fingerprint: string },\n\t): Promise<string | undefined>;\n\t/** Start a store build of `profile`, submitted to the store when asked. */\n\tbuild(\n\t\tdir: string,\n\t\toptions: {\n\t\t\tplatform: EasPlatform;\n\t\t\tprofile: string;\n\t\t\tsubmit: boolean;\n\t\t\twait: boolean;\n\t\t},\n\t): Promise<void>;\n\t/** Publish an update of the app's JavaScript on a channel. */\n\tupdate(\n\t\tdir: string,\n\t\toptions: {\n\t\t\tplatform: EasPlatform;\n\t\t\tchannel: string;\n\t\t\tenvironment: string;\n\t\t\tmessage: string;\n\t\t},\n\t): Promise<void>;\n}\n\n/**\n * Run `eas` in `dir`: the app's own, else the workspace's, else the one on\n * PATH. What it prints on stdout is answered; a failure is\n * {@link EasCommandFailed} with what it said.\n */\nfunction runEas(\n\troot: string,\n\tdir: string,\n\targs: readonly string[],\n\toptions: { inherit?: boolean; env?: Readonly<Record<string, string>> } = {},\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = spawn('eas', [...args, '--non-interactive'], {\n\t\t\tcwd: dir,\n\t\t\t// A build's or an update's progress is the user's to read.\n\t\t\tstdio: ['ignore', options.inherit ? 'inherit' : 'pipe', 'pipe'],\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...options.env,\n\t\t\t\tPATH: [\n\t\t\t\t\tjoin(dir, 'node_modules', '.bin'),\n\t\t\t\t\tjoin(root, 'node_modules', '.bin'),\n\t\t\t\t\tprocess.env.PATH,\n\t\t\t\t].join(delimiter),\n\t\t\t},\n\t\t});\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\t\tchild.stdout?.on('data', (chunk: Buffer) => {\n\t\t\tstdout += chunk.toString();\n\t\t});\n\t\tchild.stderr?.on('data', (chunk: Buffer) => {\n\t\t\tstderr += chunk.toString();\n\t\t\tif (options.inherit) process.stderr.write(chunk);\n\t\t});\n\t\tconst command = args.slice(0, 3).join(' ');\n\t\tchild.on('error', (error: NodeJS.ErrnoException) =>\n\t\t\treject(\n\t\t\t\terror.code === 'ENOENT'\n\t\t\t\t\t? new EasCliMissing(dir)\n\t\t\t\t\t: new EasCommandFailed(command, null, error.message),\n\t\t\t),\n\t\t);\n\t\tchild.on('close', (code) =>\n\t\t\tcode === 0\n\t\t\t\t? resolve(stdout)\n\t\t\t\t: reject(new EasCommandFailed(command, code, stderr)),\n\t\t);\n\t});\n}\n\n/** The JSON `eas … --json` printed, read for `what`. */\nfunction easJson(output: string, what: string): unknown {\n\ttry {\n\t\treturn JSON.parse(output);\n\t} catch {\n\t\tthrow new EasCommandFailed(what, 0, `not JSON: ${output.slice(0, 200)}`);\n\t}\n}\n\n/**\n * The real one — never a prompt (`--non-interactive`). `env` is what the\n * app's `app.config.ts` reads for the stage: every `eas` command evaluates\n * it, and one that reads a value it lacks fails before it starts — and a\n * fingerprint computed here must match the one EAS computes with the\n * stage's values.\n */\nexport function easCli(\n\troot: string,\n\tenv: Readonly<Record<string, string>> = {},\n): EasCli {\n\tconst run = (\n\t\tdir: string,\n\t\targs: readonly string[],\n\t\toptions: { inherit?: boolean } = {},\n\t) => runEas(root, dir, args, { ...options, env });\n\treturn {\n\t\tasync setEnv(dir, { environment, name, value }) {\n\t\t\tawait run(dir, [\n\t\t\t\t'env:set',\n\t\t\t\t'--environment',\n\t\t\t\tenvironment,\n\t\t\t\t'--name',\n\t\t\t\tname,\n\t\t\t\t'--value',\n\t\t\t\tvalue,\n\t\t\t\t'--visibility',\n\t\t\t\t'plaintext',\n\t\t\t\t'--scope',\n\t\t\t\t'project',\n\t\t\t]);\n\t\t},\n\n\t\tasync fingerprint(dir, { platform, profile }) {\n\t\t\tconst output = await run(dir, [\n\t\t\t\t'fingerprint:generate',\n\t\t\t\t'--platform',\n\t\t\t\tplatform,\n\t\t\t\t'--build-profile',\n\t\t\t\tprofile,\n\t\t\t\t'--json',\n\t\t\t]);\n\t\t\tconst hash = (\n\t\t\t\teasJson(output, 'fingerprint:generate') as { hash?: unknown }\n\t\t\t).hash;\n\t\t\tif (typeof hash !== 'string') {\n\t\t\t\tthrow new EasCommandFailed('fingerprint:generate', 0, 'no hash');\n\t\t\t}\n\t\t\treturn hash;\n\t\t},\n\n\t\tasync storeBuild(dir, { platform, profile, fingerprint }) {\n\t\t\tconst output = await run(dir, [\n\t\t\t\t'build:list',\n\t\t\t\t'--platform',\n\t\t\t\tplatform,\n\t\t\t\t'--build-profile',\n\t\t\t\tprofile,\n\t\t\t\t'--fingerprint-hash',\n\t\t\t\tfingerprint,\n\t\t\t\t'--status',\n\t\t\t\t'finished',\n\t\t\t\t'--distribution',\n\t\t\t\t'store',\n\t\t\t\t'--limit',\n\t\t\t\t'1',\n\t\t\t\t'--json',\n\t\t\t]);\n\t\t\tconst builds = easJson(output, 'build:list');\n\t\t\tif (!Array.isArray(builds)) return undefined;\n\t\t\tconst id = (builds[0] as { id?: unknown } | undefined)?.id;\n\t\t\treturn typeof id === 'string' ? id : undefined;\n\t\t},\n\n\t\tasync build(dir, { platform, profile, submit, wait }) {\n\t\t\tawait run(\n\t\t\t\tdir,\n\t\t\t\t[\n\t\t\t\t\t'build',\n\t\t\t\t\t'--platform',\n\t\t\t\t\tplatform,\n\t\t\t\t\t'--profile',\n\t\t\t\t\tprofile,\n\t\t\t\t\t...(submit ? ['--auto-submit'] : []),\n\t\t\t\t\t...(wait ? [] : ['--no-wait']),\n\t\t\t\t],\n\t\t\t\t{ inherit: true },\n\t\t\t);\n\t\t},\n\n\t\tasync update(dir, { platform, channel, environment, message }) {\n\t\t\tawait run(\n\t\t\t\tdir,\n\t\t\t\t[\n\t\t\t\t\t'update',\n\t\t\t\t\t'--platform',\n\t\t\t\t\tplatform,\n\t\t\t\t\t'--channel',\n\t\t\t\t\tchannel,\n\t\t\t\t\t'--environment',\n\t\t\t\t\tenvironment,\n\t\t\t\t\t'--message',\n\t\t\t\t\tmessage,\n\t\t\t\t],\n\t\t\t\t{ inherit: true },\n\t\t\t);\n\t\t},\n\t};\n}\n\n/**\n * The mobile app a command is about: the one `--app` names, else the one\n * this directory is, else the only one.\n *\n * @throws {NoMobileApp}, {MobileAppNotChosen}, {MobileAppUnknown}\n */\nexport function chooseMobileApp(\n\tmanifest: ConstructManifest,\n\tapp: string | undefined,\n\there: string | undefined,\n): MobileAppDeclaration {\n\tconst declarations = Object.values(manifest).filter(\n\t\t(declaration): declaration is MobileAppDeclaration =>\n\t\t\tdeclaration.kind === 'mobile-app',\n\t);\n\tconst names = declarations.map((declaration) => appKey(declaration.id));\n\tif (declarations.length === 0) throw new NoMobileApp();\n\tconst name =\n\t\tapp ??\n\t\t(here && names.includes(here)\n\t\t\t? here\n\t\t\t: names.length === 1\n\t\t\t\t? names[0]\n\t\t\t\t: undefined);\n\tif (!name) throw new MobileAppNotChosen(names);\n\tconst declaration = declarations.find((d) => appKey(d.id) === name);\n\tif (!declaration) throw new MobileAppUnknown(name, names);\n\treturn declaration;\n}\n\n/** `eas.json`, as far as gkm writes it. */\ninterface EasJson {\n\tbuild?: Record<string, Record<string, unknown>>;\n\tsubmit?: Record<string, Record<string, unknown>>;\n\t[key: string]: unknown;\n}\n\n/**\n * `eas.json` with the stage's build and submit profiles as `stage` says:\n * every field gkm does not decide is kept.\n */\nexport function withStageProfiles(\n\teasJson: EasJson,\n\tstage: MobileStage,\n): EasJson {\n\tconst build = easJson.build?.[stage.stage] ?? {};\n\tconst submit = easJson.submit?.[stage.stage] ?? {};\n\tconst android = (submit.android as Record<string, unknown> | undefined) ?? {};\n\treturn {\n\t\t...easJson,\n\t\tbuild: {\n\t\t\t...easJson.build,\n\t\t\t[stage.stage]: {\n\t\t\t\t...build,\n\t\t\t\tenvironment: stage.environment,\n\t\t\t\tchannel: stage.channel,\n\t\t\t},\n\t\t},\n\t\tsubmit: {\n\t\t\t...easJson.submit,\n\t\t\t[stage.stage]: {\n\t\t\t\t...submit,\n\t\t\t\tandroid: {\n\t\t\t\t\t...android,\n\t\t\t\t\ttrack: stage.android.track,\n\t\t\t\t\treleaseStatus: stage.android.releaseStatus,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport interface EasSyncOptions {\n\tstage: string;\n\t/** The mobile app, by its app key; the one here, or the only one, if not. */\n\tapp?: string;\n\t/** The AWS profile for the stage's account, where its secrets are kept. */\n\tprofile?: string;\n\tcwd?: string;\n\t/** Say what would be written, and write nothing. */\n\tdryRun?: boolean;\n}\n\n/** What a sync wrote — or, dry, would. */\nexport interface EasSyncResult {\n\tapp: string;\n\t/** The workspace's root, where its `eas` may be installed. */\n\troot: string;\n\tdir: string;\n\tstage: MobileStage;\n\tvalues: Record<string, string>;\n\t/** Whether `eas.json` changed. */\n\teasJsonChanged: boolean;\n\t/** The stage's EAS workflow, relative to the app, and whether it changed. */\n\tworkflow: { path: string; changed: boolean };\n}\n\n/**\n * Set up a mobile app's EAS project for a deployed stage.\n *\n * @throws {NoMobileApp}, {MobileAppNotChosen}, {MobileAppUnknown},\n * {MobileAppStageUndeclared}, {EasCliMissing}, {EasCommandFailed} — and\n * what loading the stage throws: {UndeclaredStage}, {ExecStageNotComposed},\n * {ExecStageNotDeployed}\n */\nexport async function easSync(\n\toptions: EasSyncOptions,\n\teas?: EasCli,\n): Promise<EasSyncResult> {\n\tconst loaded = await loadStage(options);\n\tconst { workspace, manifest, stack } = loaded;\n\n\tconst declaration = chooseMobileApp(manifest, options.app, loaded.appName);\n\tconst name = appKey(declaration.id);\n\n\tconst stage = mobileStage(workspace, declaration, options.stage);\n\tconst values =\n\t\tstack.mobileApps.find((candidate) => candidate.name === name)?.values ?? {};\n\tconst dir = join(workspace.root, declaration.app.path);\n\n\tconst path = join(dir, 'eas.json');\n\tconst before = existsSync(path)\n\t\t? (JSON.parse(await readFile(path, 'utf8')) as EasJson)\n\t\t: {};\n\tconst after = withStageProfiles(before, stage);\n\tconst easJsonChanged = JSON.stringify(before) !== JSON.stringify(after);\n\n\tconst workflowPath = easWorkflowPath(stage.stage);\n\tconst workflowFile = join(dir, workflowPath);\n\tconst workflowYaml = easWorkflow(stage, {\n\t\trelease: workspace.stages.protected?.includes(stage.stage) ?? false,\n\t\tiosSubmits: Boolean(\n\t\t\t(after.submit?.[stage.stage]?.ios as { ascAppId?: string } | undefined)\n\t\t\t\t?.ascAppId,\n\t\t),\n\t});\n\tconst workflow = {\n\t\tpath: workflowPath,\n\t\tchanged:\n\t\t\t!existsSync(workflowFile) ||\n\t\t\t(await readFile(workflowFile, 'utf8')) !== workflowYaml,\n\t};\n\n\tconst where = `${name} on '${stage.stage}': EAS environment '${stage.environment}', channel '${stage.channel}', Play track '${stage.android.track}' (${stage.android.releaseStatus})`;\n\tif (options.dryRun) {\n\t\tlogger.log(`📱 ${where} (dry run)`);\n\t\tif (easJsonChanged) {\n\t\t\tlogger.log(\n\t\t\t\t` would write build.${stage.stage} and submit.${stage.stage} in ${path}`,\n\t\t\t);\n\t\t}\n\t\tif (workflow.changed) logger.log(` would write ${workflowFile}`);\n\t\tfor (const [key, value] of Object.entries(values)) {\n\t\t\tlogger.log(` would set ${key}=${value}`);\n\t\t}\n\t\treturn {\n\t\t\tapp: name,\n\t\t\troot: workspace.root,\n\t\t\tdir,\n\t\t\tstage,\n\t\t\tvalues,\n\t\t\teasJsonChanged,\n\t\t\tworkflow,\n\t\t};\n\t}\n\n\tlogger.log(`📱 ${where}`);\n\tif (easJsonChanged) {\n\t\tawait writeFile(path, `${JSON.stringify(after, null, 2)}\\n`);\n\t\tlogger.log(\n\t\t\t` wrote build.${stage.stage} and submit.${stage.stage} in ${path}`,\n\t\t);\n\t}\n\tif (workflow.changed) {\n\t\tawait mkdir(dirname(workflowFile), { recursive: true });\n\t\tawait writeFile(workflowFile, workflowYaml);\n\t\tlogger.log(` wrote ${workflowFile}`);\n\t}\n\tconst cli = eas ?? easCli(workspace.root, values);\n\tfor (const [key, value] of Object.entries(values)) {\n\t\tawait cli.setEnv(dir, { environment: stage.environment, name: key, value });\n\t\tlogger.log(` set ${key}`);\n\t}\n\treturn {\n\t\tapp: name,\n\t\troot: workspace.root,\n\t\tdir,\n\t\tstage,\n\t\tvalues,\n\t\teasJsonChanged,\n\t\tworkflow,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,SAAS;;AAGf,IAAa,cAAb,cAAiCA,eAAAA,SAAS;CACzC,cAAc;EACb,MACC,4JAED;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAC3B;CAArB,YAAY,MAAkC;EAC7C,MACC,0BAA0B,KAAK,OAAO,gBAAgB,KAAK,KAAK,IAAI,EAAE,iDACtB,KAAK,GAAG,EACzD;EAJoB,KAAA,OAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CACA;CAFV,YACC,KACA,MACC;EACD,MACC,IAAI,IAAI,+CAA+C,KAAK,KAAK,IAAI,EAAE,GACxE;EALS,KAAA,MAAA;EACA,KAAA,OAAA;EAKT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,gBAAb,cAAmCA,eAAAA,SAAS;CACtB;CAArB,YAAY,KAAsB;EACjC,MACC,wBAAwB,IAAI,2FAE7B;EAJoB,KAAA,MAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CACA;CACA;CAHV,YACC,SACA,MACA,QACC;EACD,MACC,SAAS,QAAQ,kBAAkB,KAAK,KAAK,OAAO,KAAK,KAAK,kBAAkB,iEAEjF;EAPS,KAAA,UAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EAMT,KAAK,OAAO;CACb;AACD;;;;;;AAoDA,SAAS,OACR,MACA,KACA,MACA,UAAyE,CAAC,GACxD;CAClB,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,MAAM,SAAA,GAAQC,mBAAA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gB,IAAI,GAAG,OAAO;EAE1C,OAAO;GACN,KAAK;GACL,MAAM,UAAU;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;CAEA,OAAO,IAAI,MAAM,OAAO;CACxB,IAAI,gBAAgB;EACnB,OAAA,GAAMG,iBAAAA,UAAAA,CAAU,MAAM,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,EAAE,GAAG;EAC3D,OAAO,IACN,kBAAkB,MAAM,MAAM,cAAc,MAAM,MAAM,MAAM,MAC/D;CACD;CACA,IAAI,SAAS,SAAS;EACrB,OAAA,GAAMC,iBAAAA,MAAAA,EAAAA,GAAMC,UAAAA,QAAAA,CAAQ,YAAY,GAAG,EAAE,WAAW,KAAK,CAAC;EACtD,OAAA,GAAMF,iBAAAA,UAAAA,CAAU,cAAc,YAAY;EAC1C,OAAO,IAAI,YAAY,cAAc;CACtC;CACA,MAAM,MAAM,OAAO,OAAO,UAAU,MAAM,MAAM;CAChD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;EAClD,MAAM,IAAI,OAAO,KAAK;GAAE,aAAa,MAAM;GAAa,MAAM;GAAK;EAAM,CAAC;EAC1E,OAAO,IAAI,UAAU,KAAK;CAC3B;CACA,OAAO;EACN,KAAK;EACL,MAAM,UAAU;EAChB;EACA;EACA;EACA;EACA;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"eas-m37zU75L.cjs","names":["GkmError","spawn","join","delimiter","appKey","loadStage","mobileStage","existsSync","readFile","easWorkflowPath","easWorkflow","writeFile","mkdir","dirname"],"sources":["../src/mobile/eas.ts"],"sourcesContent":["/**\n * `gkm eas:sync --stage <stage>`: a mobile app's EAS project set up for a\n * deployed stage, from what the workspace declares — so a store build, which\n * EAS runs on its own machines, outside gkm, is built with the same values\n * the stage's servers were deployed with.\n *\n * - **`eas.json`**: the stage's build profile (`build.<stage>`) reads its EAS\n * environment and listens on its channel; its submit profile\n * (`submit.<stage>.android`) has its Play track and release status — see\n * `mobileStage`. Every other field is left as it is.\n * - **The EAS environment**: each value the app's build reads for the stage\n * (`StackMobileApp.values`) — its scheme, its edges' public URLs under\n * `EXPO_PUBLIC_`, and every stage secret already named so — set with\n * `eas env:set`, as `plaintext`: a bundle inlines them, so none is secret.\n * Nothing else is written: no server key reaches EAS.\n */\n\nimport { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { delimiter, dirname, join } from 'node:path';\nimport type {\n\tConstructManifest,\n\tMobileAppDeclaration,\n} from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport { loadStage } from '../exec/stage.js';\nimport { appKey } from '../workspace/derive.js';\nimport { easWorkflow, easWorkflowPath } from './easWorkflow.js';\nimport { type MobileStage, mobileStage } from './stage.js';\n\nconst logger = console;\n\n/** The workspace declares no `MobileApp`: nothing to set up. */\nexport class NoMobileApp extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'The workspace declares no MobileApp, so there is no EAS project to set ' +\n\t\t\t\t\"up. Declare one: new MobileApp('App', { path: 'apps/app' }).dependsOn([api, auth]).\",\n\t\t);\n\t\tthis.name = 'NoMobileApp';\n\t}\n}\n\n/** Several `MobileApp`s, and nothing to say which. */\nexport class MobileAppNotChosen extends GkmError {\n\tconstructor(readonly apps: readonly string[]) {\n\t\tsuper(\n\t\t\t`The workspace declares ${apps.length} mobile apps (${apps.join(', ')}). ` +\n\t\t\t\t`Run from one's directory, or name it: --app ${apps[0]}.`,\n\t\t);\n\t\tthis.name = 'MobileAppNotChosen';\n\t}\n}\n\n/** `--app` names no `MobileApp`. */\nexport class MobileAppUnknown extends GkmError {\n\tconstructor(\n\t\treadonly app: string,\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${app}' is not one of the workspace's mobile apps (${apps.join(', ')}).`,\n\t\t);\n\t\tthis.name = 'MobileAppUnknown';\n\t}\n}\n\n/** `eas` is not installed where the app is. */\nexport class EasCliMissing extends GkmError {\n\tconstructor(readonly dir: string) {\n\t\tsuper(\n\t\t\t`No \\`eas\\` to run in ${dir}. Add it to the app: pnpm add -D eas-cli ` +\n\t\t\t\t'(or install it globally: npm install -g eas-cli).',\n\t\t);\n\t\tthis.name = 'EasCliMissing';\n\t}\n}\n\n/** `eas` refused a command. */\nexport class EasCommandFailed extends GkmError {\n\tconstructor(\n\t\treadonly command: string,\n\t\treadonly code: number | null,\n\t\treadonly stderr: string,\n\t) {\n\t\tsuper(\n\t\t\t`\\`eas ${command}\\` failed (exit ${code}): ${stderr.trim() || 'it said nothing'}. ` +\n\t\t\t\t'In CI, EXPO_TOKEN must be set; on this machine, `eas login`.',\n\t\t);\n\t\tthis.name = 'EasCommandFailed';\n\t}\n}\n\n/** A platform EAS builds for. */\nexport type EasPlatform = 'ios' | 'android';\n\n/** What gkm asks of EAS, so tests can stand in. */\nexport interface EasCli {\n\t/** Create or update a variable in one of the project's environments. */\n\tsetEnv(\n\t\tdir: string,\n\t\tvariable: { environment: string; name: string; value: string },\n\t): Promise<void>;\n\t/**\n\t * The fingerprint of the app's native code, as a build with `profile`\n\t * would compute it — what its runtime version is.\n\t */\n\tfingerprint(\n\t\tdir: string,\n\t\toptions: { platform: EasPlatform; profile: string },\n\t): Promise<string>;\n\t/** A finished store build of `profile` with that fingerprint, if any. */\n\tstoreBuild(\n\t\tdir: string,\n\t\toptions: { platform: EasPlatform; profile: string; fingerprint: string },\n\t): Promise<string | undefined>;\n\t/** Start a store build of `profile`, submitted to the store when asked. */\n\tbuild(\n\t\tdir: string,\n\t\toptions: {\n\t\t\tplatform: EasPlatform;\n\t\t\tprofile: string;\n\t\t\tsubmit: boolean;\n\t\t\twait: boolean;\n\t\t},\n\t): Promise<void>;\n\t/** Publish an update of the app's JavaScript on a channel. */\n\tupdate(\n\t\tdir: string,\n\t\toptions: {\n\t\t\tplatform: EasPlatform;\n\t\t\tchannel: string;\n\t\t\tenvironment: string;\n\t\t\tmessage: string;\n\t\t},\n\t): Promise<void>;\n}\n\n/**\n * Run `eas` in `dir`: the app's own, else the workspace's, else the one on\n * PATH. What it prints on stdout is answered; a failure is\n * {@link EasCommandFailed} with what it said.\n */\nfunction runEas(\n\troot: string,\n\tdir: string,\n\targs: readonly string[],\n\toptions: { inherit?: boolean; env?: Readonly<Record<string, string>> } = {},\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = spawn('eas', [...args, '--non-interactive'], {\n\t\t\tcwd: dir,\n\t\t\t// A build's or an update's progress is the user's to read.\n\t\t\tstdio: ['ignore', options.inherit ? 'inherit' : 'pipe', 'pipe'],\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...options.env,\n\t\t\t\tPATH: [\n\t\t\t\t\tjoin(dir, 'node_modules', '.bin'),\n\t\t\t\t\tjoin(root, 'node_modules', '.bin'),\n\t\t\t\t\tprocess.env.PATH,\n\t\t\t\t].join(delimiter),\n\t\t\t},\n\t\t});\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\t\tchild.stdout?.on('data', (chunk: Buffer) => {\n\t\t\tstdout += chunk.toString();\n\t\t});\n\t\tchild.stderr?.on('data', (chunk: Buffer) => {\n\t\t\tstderr += chunk.toString();\n\t\t\tif (options.inherit) process.stderr.write(chunk);\n\t\t});\n\t\tconst command = args.slice(0, 3).join(' ');\n\t\tchild.on('error', (error: NodeJS.ErrnoException) =>\n\t\t\treject(\n\t\t\t\terror.code === 'ENOENT'\n\t\t\t\t\t? new EasCliMissing(dir)\n\t\t\t\t\t: new EasCommandFailed(command, null, error.message),\n\t\t\t),\n\t\t);\n\t\tchild.on('close', (code) =>\n\t\t\tcode === 0\n\t\t\t\t? resolve(stdout)\n\t\t\t\t: reject(new EasCommandFailed(command, code, stderr)),\n\t\t);\n\t});\n}\n\n/** The JSON `eas … --json` printed, read for `what`. */\nfunction easJson(output: string, what: string): unknown {\n\ttry {\n\t\treturn JSON.parse(output);\n\t} catch {\n\t\tthrow new EasCommandFailed(what, 0, `not JSON: ${output.slice(0, 200)}`);\n\t}\n}\n\n/**\n * The real one — never a prompt (`--non-interactive`). `env` is what the\n * app's `app.config.ts` reads for the stage: every `eas` command evaluates\n * it, and one that reads a value it lacks fails before it starts — and a\n * fingerprint computed here must match the one EAS computes with the\n * stage's values.\n */\nexport function easCli(\n\troot: string,\n\tenv: Readonly<Record<string, string>> = {},\n): EasCli {\n\tconst run = (\n\t\tdir: string,\n\t\targs: readonly string[],\n\t\toptions: { inherit?: boolean } = {},\n\t) => runEas(root, dir, args, { ...options, env });\n\treturn {\n\t\tasync setEnv(dir, { environment, name, value }) {\n\t\t\tawait run(dir, [\n\t\t\t\t'env:set',\n\t\t\t\t'--environment',\n\t\t\t\tenvironment,\n\t\t\t\t'--name',\n\t\t\t\tname,\n\t\t\t\t'--value',\n\t\t\t\tvalue,\n\t\t\t\t'--visibility',\n\t\t\t\t'plaintext',\n\t\t\t\t'--scope',\n\t\t\t\t'project',\n\t\t\t]);\n\t\t},\n\n\t\tasync fingerprint(dir, { platform, profile }) {\n\t\t\tconst output = await run(dir, [\n\t\t\t\t'fingerprint:generate',\n\t\t\t\t'--platform',\n\t\t\t\tplatform,\n\t\t\t\t'--build-profile',\n\t\t\t\tprofile,\n\t\t\t\t'--json',\n\t\t\t]);\n\t\t\tconst hash = (\n\t\t\t\teasJson(output, 'fingerprint:generate') as { hash?: unknown }\n\t\t\t).hash;\n\t\t\tif (typeof hash !== 'string') {\n\t\t\t\tthrow new EasCommandFailed('fingerprint:generate', 0, 'no hash');\n\t\t\t}\n\t\t\treturn hash;\n\t\t},\n\n\t\tasync storeBuild(dir, { platform, profile, fingerprint }) {\n\t\t\tconst output = await run(dir, [\n\t\t\t\t'build:list',\n\t\t\t\t'--platform',\n\t\t\t\tplatform,\n\t\t\t\t'--build-profile',\n\t\t\t\tprofile,\n\t\t\t\t'--fingerprint-hash',\n\t\t\t\tfingerprint,\n\t\t\t\t'--status',\n\t\t\t\t'finished',\n\t\t\t\t'--distribution',\n\t\t\t\t'store',\n\t\t\t\t'--limit',\n\t\t\t\t'1',\n\t\t\t\t'--json',\n\t\t\t]);\n\t\t\tconst builds = easJson(output, 'build:list');\n\t\t\tif (!Array.isArray(builds)) return undefined;\n\t\t\tconst id = (builds[0] as { id?: unknown } | undefined)?.id;\n\t\t\treturn typeof id === 'string' ? id : undefined;\n\t\t},\n\n\t\tasync build(dir, { platform, profile, submit, wait }) {\n\t\t\tawait run(\n\t\t\t\tdir,\n\t\t\t\t[\n\t\t\t\t\t'build',\n\t\t\t\t\t'--platform',\n\t\t\t\t\tplatform,\n\t\t\t\t\t'--profile',\n\t\t\t\t\tprofile,\n\t\t\t\t\t...(submit ? ['--auto-submit'] : []),\n\t\t\t\t\t...(wait ? [] : ['--no-wait']),\n\t\t\t\t],\n\t\t\t\t{ inherit: true },\n\t\t\t);\n\t\t},\n\n\t\tasync update(dir, { platform, channel, environment, message }) {\n\t\t\tawait run(\n\t\t\t\tdir,\n\t\t\t\t[\n\t\t\t\t\t'update',\n\t\t\t\t\t'--platform',\n\t\t\t\t\tplatform,\n\t\t\t\t\t'--channel',\n\t\t\t\t\tchannel,\n\t\t\t\t\t'--environment',\n\t\t\t\t\tenvironment,\n\t\t\t\t\t'--message',\n\t\t\t\t\tmessage,\n\t\t\t\t],\n\t\t\t\t{ inherit: true },\n\t\t\t);\n\t\t},\n\t};\n}\n\n/**\n * The mobile app a command is about: the one `--app` names, else the one\n * this directory is, else the only one.\n *\n * @throws {NoMobileApp}, {MobileAppNotChosen}, {MobileAppUnknown}\n */\nexport function chooseMobileApp(\n\tmanifest: ConstructManifest,\n\tapp: string | undefined,\n\there: string | undefined,\n): MobileAppDeclaration {\n\tconst declarations = Object.values(manifest).filter(\n\t\t(declaration): declaration is MobileAppDeclaration =>\n\t\t\tdeclaration.kind === 'mobile-app',\n\t);\n\tconst names = declarations.map((declaration) => appKey(declaration.id));\n\tif (declarations.length === 0) throw new NoMobileApp();\n\tconst name =\n\t\tapp ??\n\t\t(here && names.includes(here)\n\t\t\t? here\n\t\t\t: names.length === 1\n\t\t\t\t? names[0]\n\t\t\t\t: undefined);\n\tif (!name) throw new MobileAppNotChosen(names);\n\tconst declaration = declarations.find((d) => appKey(d.id) === name);\n\tif (!declaration) throw new MobileAppUnknown(name, names);\n\treturn declaration;\n}\n\n/** `eas.json`, as far as gkm writes it. */\ninterface EasJson {\n\tbuild?: Record<string, Record<string, unknown>>;\n\tsubmit?: Record<string, Record<string, unknown>>;\n\t[key: string]: unknown;\n}\n\n/**\n * `eas.json` with the stage's build and submit profiles as `stage` says:\n * every field gkm does not decide is kept.\n */\nexport function withStageProfiles(\n\teasJson: EasJson,\n\tstage: MobileStage,\n): EasJson {\n\tconst build = easJson.build?.[stage.stage] ?? {};\n\tconst submit = easJson.submit?.[stage.stage] ?? {};\n\tconst android = (submit.android as Record<string, unknown> | undefined) ?? {};\n\treturn {\n\t\t...easJson,\n\t\tbuild: {\n\t\t\t...easJson.build,\n\t\t\t[stage.stage]: {\n\t\t\t\t...build,\n\t\t\t\tenvironment: stage.environment,\n\t\t\t\tchannel: stage.channel,\n\t\t\t},\n\t\t},\n\t\tsubmit: {\n\t\t\t...easJson.submit,\n\t\t\t[stage.stage]: {\n\t\t\t\t...submit,\n\t\t\t\tandroid: {\n\t\t\t\t\t...android,\n\t\t\t\t\ttrack: stage.android.track,\n\t\t\t\t\treleaseStatus: stage.android.releaseStatus,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport interface EasSyncOptions {\n\tstage: string;\n\t/** The mobile app, by its app key; the one here, or the only one, if not. */\n\tapp?: string;\n\t/** The AWS profile for the stage's account, where its secrets are kept. */\n\tprofile?: string;\n\tcwd?: string;\n\t/** Say what would be written, and write nothing. */\n\tdryRun?: boolean;\n}\n\n/** What a sync wrote — or, dry, would. */\nexport interface EasSyncResult {\n\tapp: string;\n\t/** The workspace's root, where its `eas` may be installed. */\n\troot: string;\n\tdir: string;\n\tstage: MobileStage;\n\tvalues: Record<string, string>;\n\t/** Whether `eas.json` changed. */\n\teasJsonChanged: boolean;\n\t/** The stage's EAS workflow, relative to the app, and whether it changed. */\n\tworkflow: { path: string; changed: boolean };\n}\n\n/**\n * Set up a mobile app's EAS project for a deployed stage.\n *\n * @throws {NoMobileApp}, {MobileAppNotChosen}, {MobileAppUnknown},\n * {MobileAppStageUndeclared}, {EasCliMissing}, {EasCommandFailed} — and\n * what loading the stage throws: {UndeclaredStage}, {ExecStageNotComposed},\n * {ExecStageNotDeployed}\n */\nexport async function easSync(\n\toptions: EasSyncOptions,\n\teas?: EasCli,\n): Promise<EasSyncResult> {\n\tconst loaded = await loadStage(options);\n\tconst { workspace, manifest, stack } = loaded;\n\n\tconst declaration = chooseMobileApp(manifest, options.app, loaded.appName);\n\tconst name = appKey(declaration.id);\n\n\tconst stage = mobileStage(workspace, declaration, options.stage);\n\tconst values =\n\t\tstack.mobileApps.find((candidate) => candidate.name === name)?.values ?? {};\n\tconst dir = join(workspace.root, declaration.app.path);\n\n\tconst path = join(dir, 'eas.json');\n\tconst before = existsSync(path)\n\t\t? (JSON.parse(await readFile(path, 'utf8')) as EasJson)\n\t\t: {};\n\tconst after = withStageProfiles(before, stage);\n\tconst easJsonChanged = JSON.stringify(before) !== JSON.stringify(after);\n\n\tconst workflowPath = easWorkflowPath(stage.stage);\n\tconst workflowFile = join(dir, workflowPath);\n\tconst workflowYaml = easWorkflow(stage, {\n\t\trelease: workspace.stages.protected?.includes(stage.stage) ?? false,\n\t\tiosSubmits: Boolean(\n\t\t\t(after.submit?.[stage.stage]?.ios as { ascAppId?: string } | undefined)\n\t\t\t\t?.ascAppId,\n\t\t),\n\t});\n\tconst workflow = {\n\t\tpath: workflowPath,\n\t\tchanged:\n\t\t\t!existsSync(workflowFile) ||\n\t\t\t(await readFile(workflowFile, 'utf8')) !== workflowYaml,\n\t};\n\n\tconst where = `${name} on '${stage.stage}': EAS environment '${stage.environment}', channel '${stage.channel}', Play track '${stage.android.track}' (${stage.android.releaseStatus})`;\n\tif (options.dryRun) {\n\t\tlogger.log(`📱 ${where} (dry run)`);\n\t\tif (easJsonChanged) {\n\t\t\tlogger.log(\n\t\t\t\t` would write build.${stage.stage} and submit.${stage.stage} in ${path}`,\n\t\t\t);\n\t\t}\n\t\tif (workflow.changed) logger.log(` would write ${workflowFile}`);\n\t\tfor (const [key, value] of Object.entries(values)) {\n\t\t\tlogger.log(` would set ${key}=${value}`);\n\t\t}\n\t\treturn {\n\t\t\tapp: name,\n\t\t\troot: workspace.root,\n\t\t\tdir,\n\t\t\tstage,\n\t\t\tvalues,\n\t\t\teasJsonChanged,\n\t\t\tworkflow,\n\t\t};\n\t}\n\n\tlogger.log(`📱 ${where}`);\n\tif (easJsonChanged) {\n\t\tawait writeFile(path, `${JSON.stringify(after, null, 2)}\\n`);\n\t\tlogger.log(\n\t\t\t` wrote build.${stage.stage} and submit.${stage.stage} in ${path}`,\n\t\t);\n\t}\n\tif (workflow.changed) {\n\t\tawait mkdir(dirname(workflowFile), { recursive: true });\n\t\tawait writeFile(workflowFile, workflowYaml);\n\t\tlogger.log(` wrote ${workflowFile}`);\n\t}\n\tconst cli = eas ?? easCli(workspace.root, values);\n\tfor (const [key, value] of Object.entries(values)) {\n\t\tawait cli.setEnv(dir, { environment: stage.environment, name: key, value });\n\t\tlogger.log(` set ${key}`);\n\t}\n\treturn {\n\t\tapp: name,\n\t\troot: workspace.root,\n\t\tdir,\n\t\tstage,\n\t\tvalues,\n\t\teasJsonChanged,\n\t\tworkflow,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,SAAS;;AAGf,IAAa,cAAb,cAAiCA,eAAAA,SAAS;CACzC,cAAc;EACb,MACC,4JAED;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAC3B;CAArB,YAAY,MAAkC;EAC7C,MACC,0BAA0B,KAAK,OAAO,gBAAgB,KAAK,KAAK,IAAI,EAAE,iDACtB,KAAK,GAAG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F,iBAAAA,UAAAA,CAAU,cAAc,YAAY;EAC1C,OAAO,IAAI,YAAY,cAAc;CACtC;CACA,MAAM,MAAM,OAAO,OAAO,UAAU,MAAM,MAAM;CAChD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;EAClD,MAAM,IAAI,OAAO,KAAK;GAAE,aAAa,MAAM;GAAa,MAAM;GAAK;EAAM,CAAC;EAC1E,OAAO,IAAI,UAAU,KAAK;CAC3B;CACA,OAAO;EACN,KAAK;EACL,MAAM,UAAU;EAChB;EACA;EACA;EACA;EACA;CACD;AACD"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { canonicalId } from "@geekmidas/manifest";
|
|
2
|
+
//#region src/reconcile/emit.ts
|
|
3
|
+
/**
|
|
4
|
+
* Point each handler discovery found at the entry the build generated for it.
|
|
5
|
+
*
|
|
6
|
+
* Discovery already nested every endpoint, route, cron, function, consumer,
|
|
7
|
+
* subscriber and processor, with its edges — the graph is the same for every
|
|
8
|
+
* command. A build adds one fact: where it wrote each handler. So this
|
|
9
|
+
* replaces `handler` and nothing else, and a handler the build generated no
|
|
10
|
+
* entry of its own for keeps its source.
|
|
11
|
+
*
|
|
12
|
+
* That is the `server` provider's whole application: it generates one
|
|
13
|
+
* catch-all — `ALL *` pointing at the Hono app that routes in-process — which
|
|
14
|
+
* matches no endpoint, so every endpoint keeps the source it was found at.
|
|
15
|
+
*/
|
|
16
|
+
function withHandlers(manifest, generated) {
|
|
17
|
+
const next = { ...manifest };
|
|
18
|
+
const at = (list, id, handler) => list.map((item) => item.id === id ? {
|
|
19
|
+
...item,
|
|
20
|
+
handler
|
|
21
|
+
} : item);
|
|
22
|
+
for (const route of generated.routes ?? []) for (const [id, declaration] of Object.entries(next)) {
|
|
23
|
+
if (declaration.kind !== "rest-api") continue;
|
|
24
|
+
if (route.surface && route.surface !== id) continue;
|
|
25
|
+
next[id] = {
|
|
26
|
+
...declaration,
|
|
27
|
+
endpoints: declaration.endpoints.map((endpoint) => endpoint.method === route.method && endpoint.path === route.path ? {
|
|
28
|
+
...endpoint,
|
|
29
|
+
handler: route.handler
|
|
30
|
+
} : endpoint)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
for (const fn of [...generated.functions ?? [], ...generated.crons ?? []]) {
|
|
34
|
+
const declaration = next[fn.name];
|
|
35
|
+
if (declaration?.kind === "function" || declaration?.kind === "cron") next[fn.name] = {
|
|
36
|
+
...declaration,
|
|
37
|
+
handler: fn.handler
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
for (const consumer of generated.queues ?? []) {
|
|
41
|
+
const queue = next[canonicalId(consumer.name)];
|
|
42
|
+
if (queue?.kind !== "queue") continue;
|
|
43
|
+
next[queue.id] = {
|
|
44
|
+
...queue,
|
|
45
|
+
worker: {
|
|
46
|
+
...queue.worker,
|
|
47
|
+
handler: consumer.handler
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
for (const subscriber of generated.subscribers ?? []) {
|
|
52
|
+
const bucket = subscriber.bucket ? next[canonicalId(subscriber.bucket)] : void 0;
|
|
53
|
+
if (bucket?.kind === "objects") {
|
|
54
|
+
next[bucket.id] = {
|
|
55
|
+
...bucket,
|
|
56
|
+
subscribers: at(bucket.subscribers ?? [], subscriber.name, subscriber.handler)
|
|
57
|
+
};
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const topic = subscriber.topic ? next[canonicalId(subscriber.topic)] : void 0;
|
|
61
|
+
if (topic?.kind !== "topic") continue;
|
|
62
|
+
next[topic.id] = {
|
|
63
|
+
...topic,
|
|
64
|
+
subscribers: at(topic.subscribers, subscriber.name, subscriber.handler)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
for (const processor of generated.processors ?? []) {
|
|
68
|
+
const server = next[processor.fileServer];
|
|
69
|
+
if (server?.kind !== "file-server") continue;
|
|
70
|
+
next[server.id] = {
|
|
71
|
+
...server,
|
|
72
|
+
processors: at(server.processors ?? [], processor.name, processor.handler)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return next;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The manifest as TypeScript source.
|
|
79
|
+
*
|
|
80
|
+
* Pure, so what gets written can be asserted without touching a filesystem.
|
|
81
|
+
*/
|
|
82
|
+
function manifestModule(manifest, backends = {}) {
|
|
83
|
+
return `${HEADER}
|
|
84
|
+
export const constructs = ${serialise(manifest)} as const satisfies ConstructManifest;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Where the backends that are *config* rather than declaration resolved to.
|
|
88
|
+
*
|
|
89
|
+
* Recorded because they were being answered twice: once by the build, which
|
|
90
|
+
* registers exactly one cache driver, and once by a deploy config, which told
|
|
91
|
+
* the provisioner something else. The result was a deployed URL the running code
|
|
92
|
+
* had no driver for — two documents disagreeing about one fact, which is what
|
|
93
|
+
* this manifest exists to stop.
|
|
94
|
+
*/
|
|
95
|
+
export const backends = ${serialise(backends)} as const;
|
|
96
|
+
|
|
97
|
+
// Derived types
|
|
98
|
+
export type Ids = IdsOf<typeof constructs>;
|
|
99
|
+
export type Construct<Id extends Ids> = DeclarationOf<typeof constructs, Id>;
|
|
100
|
+
export type Kind = Construct<Ids>['kind'];
|
|
101
|
+
|
|
102
|
+
// Useful union types
|
|
103
|
+
export type ProvidedKeys = AllProvidedKeys<typeof constructs>;
|
|
104
|
+
export type Surfaces = IdsOfKind<typeof constructs, 'rest-api'>;
|
|
105
|
+
export type CacheBackend = (typeof backends)['cache'];
|
|
106
|
+
export type EmailBackend = (typeof backends)['email'];
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
const HEADER = `// Generated by \`gkm build\`. Do not edit.
|
|
110
|
+
//
|
|
111
|
+
// Discovery imports application code, so it runs once here rather than in every
|
|
112
|
+
// consumer — a deploy config that discovered for itself would evaluate the whole
|
|
113
|
+
// runtime graph inside its own toolchain. This is the result, as literals.
|
|
114
|
+
|
|
115
|
+
import type {
|
|
116
|
+
AllProvidedKeys,
|
|
117
|
+
ConstructManifest,
|
|
118
|
+
DeclarationOf,
|
|
119
|
+
IdsOf,
|
|
120
|
+
IdsOfKind,
|
|
121
|
+
} from '@geekmidas/manifest';
|
|
122
|
+
`;
|
|
123
|
+
/**
|
|
124
|
+
* JSON, re-indented with tabs and with keys left unquoted where they can be.
|
|
125
|
+
*
|
|
126
|
+
* Cosmetic, and worth it: this file is read by people trying to work out what
|
|
127
|
+
* their app declares, and a wall of quoted keys reads as output rather than as
|
|
128
|
+
* something anyone is expected to understand.
|
|
129
|
+
*/
|
|
130
|
+
function serialise(value) {
|
|
131
|
+
return JSON.stringify(value, null, " ").replace(/^(\t*)"([A-Za-z_$][\w$]*)":/gm, "$1$2:").replace(/"/g, "'");
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { withHandlers as n, manifestModule as t };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=emit-Bj6XSivk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-Bj6XSivk.mjs","names":[],"sources":["../src/reconcile/emit.ts"],"sourcesContent":["/**\n * The manifest, written out as a module.\n *\n * Discovery imports the application's own code — that is how it finds\n * constructs — so anything calling it evaluates the whole runtime graph: React\n * email templates, database clients, modules that read env at import time. That\n * is fine inside `gkm dev`, which is already running the app. It is not fine\n * inside a deploy config, where it fails on the first thing the deploy toolchain\n * does not expect and would keep failing on the next.\n *\n * So discovery happens once, in the build, and everything downstream reads what\n * it wrote. The same split `RestApi` makes by naming a routes glob rather than\n * importing route modules.\n *\n * A module rather than JSON, because a manifest is not just data to this\n * codebase — `as const satisfies ConstructManifest` is what keeps every id,\n * kind and provided key a *literal*, so `IdsOf`, `ProvidedKeys` and the rest\n * can select out of it. `JSON.parse` returns `any` and gives all of that up.\n */\n\nimport type {\n\tConstructManifest,\n\tCronInfo,\n\tDeclaration,\n\tFunctionInfo,\n\tProcessorInfo,\n\tQueueInfo,\n\tRouteInfo,\n\tSubscriberInfo,\n} from '@geekmidas/manifest';\nimport { canonicalId } from '@geekmidas/manifest';\nimport type { CacheBackend, EmailBackend } from '../types.js';\n\n/** What a build generated: the entry each handler was written to. */\nexport interface GeneratedHandlers {\n\t/** Each route, with the surface the app that generated it serves. */\n\troutes?: readonly (RouteInfo & { surface?: string })[];\n\tfunctions?: readonly FunctionInfo[];\n\tcrons?: readonly CronInfo[];\n\tqueues?: readonly QueueInfo[];\n\tsubscribers?: readonly SubscriberInfo[];\n\tprocessors?: readonly ProcessorInfo[];\n}\n\n/**\n * Point each handler discovery found at the entry the build generated for it.\n *\n * Discovery already nested every endpoint, route, cron, function, consumer,\n * subscriber and processor, with its edges — the graph is the same for every\n * command. A build adds one fact: where it wrote each handler. So this\n * replaces `handler` and nothing else, and a handler the build generated no\n * entry of its own for keeps its source.\n *\n * That is the `server` provider's whole application: it generates one\n * catch-all — `ALL *` pointing at the Hono app that routes in-process — which\n * matches no endpoint, so every endpoint keeps the source it was found at.\n */\nexport function withHandlers(\n\tmanifest: ConstructManifest,\n\tgenerated: GeneratedHandlers,\n): ConstructManifest {\n\tconst next: Record<string, Declaration> = { ...manifest };\n\tconst at = <T extends { id: string; handler: string }>(\n\t\tlist: readonly T[],\n\t\tid: string,\n\t\thandler: string,\n\t): T[] => list.map((item) => (item.id === id ? { ...item, handler } : item));\n\n\tfor (const route of generated.routes ?? []) {\n\t\tfor (const [id, declaration] of Object.entries(next)) {\n\t\t\tif (declaration.kind !== 'rest-api') continue;\n\t\t\tif (route.surface && route.surface !== id) continue;\n\t\t\tnext[id] = {\n\t\t\t\t...declaration,\n\t\t\t\tendpoints: declaration.endpoints.map((endpoint) =>\n\t\t\t\t\tendpoint.method === route.method && endpoint.path === route.path\n\t\t\t\t\t\t? { ...endpoint, handler: route.handler }\n\t\t\t\t\t\t: endpoint,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n\n\tfor (const fn of [\n\t\t...(generated.functions ?? []),\n\t\t...(generated.crons ?? []),\n\t]) {\n\t\tconst declaration = next[fn.name];\n\t\tif (declaration?.kind === 'function' || declaration?.kind === 'cron') {\n\t\t\tnext[fn.name] = { ...declaration, handler: fn.handler };\n\t\t}\n\t}\n\n\tfor (const consumer of generated.queues ?? []) {\n\t\tconst queue = next[canonicalId(consumer.name)];\n\t\tif (queue?.kind !== 'queue') continue;\n\t\tnext[queue.id] = {\n\t\t\t...queue,\n\t\t\tworker: { ...queue.worker, handler: consumer.handler },\n\t\t};\n\t}\n\n\tfor (const subscriber of generated.subscribers ?? []) {\n\t\tconst bucket = subscriber.bucket\n\t\t\t? next[canonicalId(subscriber.bucket)]\n\t\t\t: undefined;\n\t\tif (bucket?.kind === 'objects') {\n\t\t\tnext[bucket.id] = {\n\t\t\t\t...bucket,\n\t\t\t\tsubscribers: at(\n\t\t\t\t\tbucket.subscribers ?? [],\n\t\t\t\t\tsubscriber.name,\n\t\t\t\t\tsubscriber.handler,\n\t\t\t\t),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\t\tconst topic = subscriber.topic\n\t\t\t? next[canonicalId(subscriber.topic)]\n\t\t\t: undefined;\n\t\tif (topic?.kind !== 'topic') continue;\n\t\tnext[topic.id] = {\n\t\t\t...topic,\n\t\t\tsubscribers: at(topic.subscribers, subscriber.name, subscriber.handler),\n\t\t};\n\t}\n\n\tfor (const processor of generated.processors ?? []) {\n\t\tconst server = next[processor.fileServer];\n\t\tif (server?.kind !== 'file-server') continue;\n\t\tnext[server.id] = {\n\t\t\t...server,\n\t\t\tprocessors: at(\n\t\t\t\tserver.processors ?? [],\n\t\t\t\tprocessor.name,\n\t\t\t\tprocessor.handler,\n\t\t\t),\n\t\t};\n\t}\n\n\treturn next;\n}\n\n/**\n * The manifest as TypeScript source.\n *\n * Pure, so what gets written can be asserted without touching a filesystem.\n */\nexport function manifestModule(\n\tmanifest: ConstructManifest,\n\tbackends: Backends = {},\n): string {\n\treturn `${HEADER}\nexport const constructs = ${serialise(manifest)} as const satisfies ConstructManifest;\n\n/**\n * Where the backends that are *config* rather than declaration resolved to.\n *\n * Recorded because they were being answered twice: once by the build, which\n * registers exactly one cache driver, and once by a deploy config, which told\n * the provisioner something else. The result was a deployed URL the running code\n * had no driver for — two documents disagreeing about one fact, which is what\n * this manifest exists to stop.\n */\nexport const backends = ${serialise(backends)} as const;\n\n// Derived types\nexport type Ids = IdsOf<typeof constructs>;\nexport type Construct<Id extends Ids> = DeclarationOf<typeof constructs, Id>;\nexport type Kind = Construct<Ids>['kind'];\n\n// Useful union types\nexport type ProvidedKeys = AllProvidedKeys<typeof constructs>;\nexport type Surfaces = IdsOfKind<typeof constructs, 'rest-api'>;\nexport type CacheBackend = (typeof backends)['cache'];\nexport type EmailBackend = (typeof backends)['email'];\n`;\n}\n\n/** The choices that are deployment config rather than declaration. */\nexport interface Backends {\n\tcache?: CacheBackend;\n\temail?: EmailBackend;\n\t/**\n\t * The labels no tenant of the wildcard site may take — every app's own\n\t * and the workspace's `protectedSubdomains`. Config the AWS target cannot\n\t * read for itself, so it travels with the manifest.\n\t */\n\tprotectedSubdomains?: readonly string[];\n}\n\nconst HEADER = `// Generated by \\`gkm build\\`. Do not edit.\n//\n// Discovery imports application code, so it runs once here rather than in every\n// consumer — a deploy config that discovered for itself would evaluate the whole\n// runtime graph inside its own toolchain. This is the result, as literals.\n\nimport type {\n\tAllProvidedKeys,\n\tConstructManifest,\n\tDeclarationOf,\n\tIdsOf,\n\tIdsOfKind,\n} from '@geekmidas/manifest';\n`;\n\n/**\n * JSON, re-indented with tabs and with keys left unquoted where they can be.\n *\n * Cosmetic, and worth it: this file is read by people trying to work out what\n * their app declares, and a wall of quoted keys reads as output rather than as\n * something anyone is expected to understand.\n */\nfunction serialise(value: object): string {\n\treturn JSON.stringify(value, null, '\\t')\n\t\t.replace(/^(\\t*)\"([A-Za-z_$][\\w$]*)\":/gm, '$1$2:')\n\t\t.replace(/\"/g, \"'\");\n}\n"],"mappings":";;;;;;;;;;;;;;;A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Z;GACD;GACA;EACD;EACA,MAAM,QAAQ,WAAW,QACtB,KAAK,YAAY,WAAW,KAAK,KACjC,KAAA;EACH,IAAI,OAAO,SAAS,SAAS;EAC7B,KAAK,MAAM,MAAM;GAChB,GAAG;GACH,aAAa,GAAG,MAAM,aAAa,WAAW,MAAM,WAAW,OAAO;EACvE;CACD;CAEA,KAAK,MAAM,aAAa,UAAU,cAAc,CAAC,GAAG;EACnD,MAAM,SAAS,KAAK,UAAU;EAC9B,IAAI,QAAQ,SAAS,eAAe;EACpC,KAAK,OAAO,MAAM;GACjB,GAAG;GACH,YAAY,GACX,OAAO,cAAc,CAAC,GACtB,UAAU,MACV,UAAU,OACX;EACD;CACD;CAEA,OAAO;AACR;;;;;;AAOA,SAAgB,eACf,UACA,WAAqB,CAAC,GACb;CACT,OAAO,GAAG,OAAO;4BACU,UAAU,QAAQ,EAAE;;;;;;;;;;;0BAWtB,UAAU,QAAQ,EAAE;;;;;;;;;;;;;AAa9C;AAcA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;AAsBf,SAAS,UAAU,OAAuB;CACzC,OAAO,KAAK,UAAU,OAAO,MAAM,GAAI,CAAC,CACtC,QAAQ,iCAAiC,OAAO,CAAC,CACjD,QAAQ,MAAM,GAAG;AACpB"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
2
|
+
//#region src/reconcile/emit.ts
|
|
3
|
+
/**
|
|
4
|
+
* Point each handler discovery found at the entry the build generated for it.
|
|
5
|
+
*
|
|
6
|
+
* Discovery already nested every endpoint, route, cron, function, consumer,
|
|
7
|
+
* subscriber and processor, with its edges — the graph is the same for every
|
|
8
|
+
* command. A build adds one fact: where it wrote each handler. So this
|
|
9
|
+
* replaces `handler` and nothing else, and a handler the build generated no
|
|
10
|
+
* entry of its own for keeps its source.
|
|
11
|
+
*
|
|
12
|
+
* That is the `server` provider's whole application: it generates one
|
|
13
|
+
* catch-all — `ALL *` pointing at the Hono app that routes in-process — which
|
|
14
|
+
* matches no endpoint, so every endpoint keeps the source it was found at.
|
|
15
|
+
*/
|
|
16
|
+
function withHandlers(manifest, generated) {
|
|
17
|
+
const next = { ...manifest };
|
|
18
|
+
const at = (list, id, handler) => list.map((item) => item.id === id ? {
|
|
19
|
+
...item,
|
|
20
|
+
handler
|
|
21
|
+
} : item);
|
|
22
|
+
for (const route of generated.routes ?? []) for (const [id, declaration] of Object.entries(next)) {
|
|
23
|
+
if (declaration.kind !== "rest-api") continue;
|
|
24
|
+
if (route.surface && route.surface !== id) continue;
|
|
25
|
+
next[id] = {
|
|
26
|
+
...declaration,
|
|
27
|
+
endpoints: declaration.endpoints.map((endpoint) => endpoint.method === route.method && endpoint.path === route.path ? {
|
|
28
|
+
...endpoint,
|
|
29
|
+
handler: route.handler
|
|
30
|
+
} : endpoint)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
for (const fn of [...generated.functions ?? [], ...generated.crons ?? []]) {
|
|
34
|
+
const declaration = next[fn.name];
|
|
35
|
+
if (declaration?.kind === "function" || declaration?.kind === "cron") next[fn.name] = {
|
|
36
|
+
...declaration,
|
|
37
|
+
handler: fn.handler
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
for (const consumer of generated.queues ?? []) {
|
|
41
|
+
const queue = next[(0, _geekmidas_manifest.canonicalId)(consumer.name)];
|
|
42
|
+
if (queue?.kind !== "queue") continue;
|
|
43
|
+
next[queue.id] = {
|
|
44
|
+
...queue,
|
|
45
|
+
worker: {
|
|
46
|
+
...queue.worker,
|
|
47
|
+
handler: consumer.handler
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
for (const subscriber of generated.subscribers ?? []) {
|
|
52
|
+
const bucket = subscriber.bucket ? next[(0, _geekmidas_manifest.canonicalId)(subscriber.bucket)] : void 0;
|
|
53
|
+
if (bucket?.kind === "objects") {
|
|
54
|
+
next[bucket.id] = {
|
|
55
|
+
...bucket,
|
|
56
|
+
subscribers: at(bucket.subscribers ?? [], subscriber.name, subscriber.handler)
|
|
57
|
+
};
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const topic = subscriber.topic ? next[(0, _geekmidas_manifest.canonicalId)(subscriber.topic)] : void 0;
|
|
61
|
+
if (topic?.kind !== "topic") continue;
|
|
62
|
+
next[topic.id] = {
|
|
63
|
+
...topic,
|
|
64
|
+
subscribers: at(topic.subscribers, subscriber.name, subscriber.handler)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
for (const processor of generated.processors ?? []) {
|
|
68
|
+
const server = next[processor.fileServer];
|
|
69
|
+
if (server?.kind !== "file-server") continue;
|
|
70
|
+
next[server.id] = {
|
|
71
|
+
...server,
|
|
72
|
+
processors: at(server.processors ?? [], processor.name, processor.handler)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return next;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The manifest as TypeScript source.
|
|
79
|
+
*
|
|
80
|
+
* Pure, so what gets written can be asserted without touching a filesystem.
|
|
81
|
+
*/
|
|
82
|
+
function manifestModule(manifest, backends = {}) {
|
|
83
|
+
return `${HEADER}
|
|
84
|
+
export const constructs = ${serialise(manifest)} as const satisfies ConstructManifest;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Where the backends that are *config* rather than declaration resolved to.
|
|
88
|
+
*
|
|
89
|
+
* Recorded because they were being answered twice: once by the build, which
|
|
90
|
+
* registers exactly one cache driver, and once by a deploy config, which told
|
|
91
|
+
* the provisioner something else. The result was a deployed URL the running code
|
|
92
|
+
* had no driver for — two documents disagreeing about one fact, which is what
|
|
93
|
+
* this manifest exists to stop.
|
|
94
|
+
*/
|
|
95
|
+
export const backends = ${serialise(backends)} as const;
|
|
96
|
+
|
|
97
|
+
// Derived types
|
|
98
|
+
export type Ids = IdsOf<typeof constructs>;
|
|
99
|
+
export type Construct<Id extends Ids> = DeclarationOf<typeof constructs, Id>;
|
|
100
|
+
export type Kind = Construct<Ids>['kind'];
|
|
101
|
+
|
|
102
|
+
// Useful union types
|
|
103
|
+
export type ProvidedKeys = AllProvidedKeys<typeof constructs>;
|
|
104
|
+
export type Surfaces = IdsOfKind<typeof constructs, 'rest-api'>;
|
|
105
|
+
export type CacheBackend = (typeof backends)['cache'];
|
|
106
|
+
export type EmailBackend = (typeof backends)['email'];
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
const HEADER = `// Generated by \`gkm build\`. Do not edit.
|
|
110
|
+
//
|
|
111
|
+
// Discovery imports application code, so it runs once here rather than in every
|
|
112
|
+
// consumer — a deploy config that discovered for itself would evaluate the whole
|
|
113
|
+
// runtime graph inside its own toolchain. This is the result, as literals.
|
|
114
|
+
|
|
115
|
+
import type {
|
|
116
|
+
AllProvidedKeys,
|
|
117
|
+
ConstructManifest,
|
|
118
|
+
DeclarationOf,
|
|
119
|
+
IdsOf,
|
|
120
|
+
IdsOfKind,
|
|
121
|
+
} from '@geekmidas/manifest';
|
|
122
|
+
`;
|
|
123
|
+
/**
|
|
124
|
+
* JSON, re-indented with tabs and with keys left unquoted where they can be.
|
|
125
|
+
*
|
|
126
|
+
* Cosmetic, and worth it: this file is read by people trying to work out what
|
|
127
|
+
* their app declares, and a wall of quoted keys reads as output rather than as
|
|
128
|
+
* something anyone is expected to understand.
|
|
129
|
+
*/
|
|
130
|
+
function serialise(value) {
|
|
131
|
+
return JSON.stringify(value, null, " ").replace(/^(\t*)"([A-Za-z_$][\w$]*)":/gm, "$1$2:").replace(/"/g, "'");
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
Object.defineProperty(exports, "manifestModule", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function() {
|
|
137
|
+
return manifestModule;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "withHandlers", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function() {
|
|
143
|
+
return withHandlers;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=emit-CDC__ubE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-CDC__ubE.cjs","names":["canonicalId"],"sources":["../src/reconcile/emit.ts"],"sourcesContent":["/**\n * The manifest, written out as a module.\n *\n * Discovery imports the application's own code — that is how it finds\n * constructs — so anything calling it evaluates the whole runtime graph: React\n * email templates, database clients, modules that read env at import time. That\n * is fine inside `gkm dev`, which is already running the app. It is not fine\n * inside a deploy config, where it fails on the first thing the deploy toolchain\n * does not expect and would keep failing on the next.\n *\n * So discovery happens once, in the build, and everything downstream reads what\n * it wrote. The same split `RestApi` makes by naming a routes glob rather than\n * importing route modules.\n *\n * A module rather than JSON, because a manifest is not just data to this\n * codebase — `as const satisfies ConstructManifest` is what keeps every id,\n * kind and provided key a *literal*, so `IdsOf`, `ProvidedKeys` and the rest\n * can select out of it. `JSON.parse` returns `any` and gives all of that up.\n */\n\nimport type {\n\tConstructManifest,\n\tCronInfo,\n\tDeclaration,\n\tFunctionInfo,\n\tProcessorInfo,\n\tQueueInfo,\n\tRouteInfo,\n\tSubscriberInfo,\n} from '@geekmidas/manifest';\nimport { canonicalId } from '@geekmidas/manifest';\nimport type { CacheBackend, EmailBackend } from '../types.js';\n\n/** What a build generated: the entry each handler was written to. */\nexport interface GeneratedHandlers {\n\t/** Each route, with the surface the app that generated it serves. */\n\troutes?: readonly (RouteInfo & { surface?: string })[];\n\tfunctions?: readonly FunctionInfo[];\n\tcrons?: readonly CronInfo[];\n\tqueues?: readonly QueueInfo[];\n\tsubscribers?: readonly SubscriberInfo[];\n\tprocessors?: readonly ProcessorInfo[];\n}\n\n/**\n * Point each handler discovery found at the entry the build generated for it.\n *\n * Discovery already nested every endpoint, route, cron, function, consumer,\n * subscriber and processor, with its edges — the graph is the same for every\n * command. A build adds one fact: where it wrote each handler. So this\n * replaces `handler` and nothing else, and a handler the build generated no\n * entry of its own for keeps its source.\n *\n * That is the `server` provider's whole application: it generates one\n * catch-all — `ALL *` pointing at the Hono app that routes in-process — which\n * matches no endpoint, so every endpoint keeps the source it was found at.\n */\nexport function withHandlers(\n\tmanifest: ConstructManifest,\n\tgenerated: GeneratedHandlers,\n): ConstructManifest {\n\tconst next: Record<string, Declaration> = { ...manifest };\n\tconst at = <T extends { id: string; handler: string }>(\n\t\tlist: readonly T[],\n\t\tid: string,\n\t\thandler: string,\n\t): T[] => list.map((item) => (item.id === id ? { ...item, handler } : item));\n\n\tfor (const route of generated.routes ?? []) {\n\t\tfor (const [id, declaration] of Object.entries(next)) {\n\t\t\tif (declaration.kind !== 'rest-api') continue;\n\t\t\tif (route.surface && route.surface !== id) continue;\n\t\t\tnext[id] = {\n\t\t\t\t...declaration,\n\t\t\t\tendpoints: declaration.endpoints.map((endpoint) =>\n\t\t\t\t\tendpoint.method === route.method && endpoint.path === route.path\n\t\t\t\t\t\t? { ...endpoint, handler: route.handler }\n\t\t\t\t\t\t: endpoint,\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t}\n\n\tfor (const fn of [\n\t\t...(generated.functions ?? []),\n\t\t...(generated.crons ?? []),\n\t]) {\n\t\tconst declaration = next[fn.name];\n\t\tif (declaration?.kind === 'function' || declaration?.kind === 'cron') {\n\t\t\tnext[fn.name] = { ...declaration, handler: fn.handler };\n\t\t}\n\t}\n\n\tfor (const consumer of generated.queues ?? []) {\n\t\tconst queue = next[canonicalId(consumer.name)];\n\t\tif (queue?.kind !== 'queue') continue;\n\t\tnext[queue.id] = {\n\t\t\t...queue,\n\t\t\tworker: { ...queue.worker, handler: consumer.handler },\n\t\t};\n\t}\n\n\tfor (const subscriber of generated.subscribers ?? []) {\n\t\tconst bucket = subscriber.bucket\n\t\t\t? next[canonicalId(subscriber.bucket)]\n\t\t\t: undefined;\n\t\tif (bucket?.kind === 'objects') {\n\t\t\tnext[bucket.id] = {\n\t\t\t\t...bucket,\n\t\t\t\tsubscribers: at(\n\t\t\t\t\tbucket.subscribers ?? [],\n\t\t\t\t\tsubscriber.name,\n\t\t\t\t\tsubscriber.handler,\n\t\t\t\t),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\t\tconst topic = subscriber.topic\n\t\t\t? next[canonicalId(subscriber.topic)]\n\t\t\t: undefined;\n\t\tif (topic?.kind !== 'topic') continue;\n\t\tnext[topic.id] = {\n\t\t\t...topic,\n\t\t\tsubscribers: at(topic.subscribers, subscriber.name, subscriber.handler),\n\t\t};\n\t}\n\n\tfor (const processor of generated.processors ?? []) {\n\t\tconst server = next[processor.fileServer];\n\t\tif (server?.kind !== 'file-server') continue;\n\t\tnext[server.id] = {\n\t\t\t...server,\n\t\t\tprocessors: at(\n\t\t\t\tserver.processors ?? [],\n\t\t\t\tprocessor.name,\n\t\t\t\tprocessor.handler,\n\t\t\t),\n\t\t};\n\t}\n\n\treturn next;\n}\n\n/**\n * The manifest as TypeScript source.\n *\n * Pure, so what gets written can be asserted without touching a filesystem.\n */\nexport function manifestModule(\n\tmanifest: ConstructManifest,\n\tbackends: Backends = {},\n): string {\n\treturn `${HEADER}\nexport const constructs = ${serialise(manifest)} as const satisfies ConstructManifest;\n\n/**\n * Where the backends that are *config* rather than declaration resolved to.\n *\n * Recorded because they were being answered twice: once by the build, which\n * registers exactly one cache driver, and once by a deploy config, which told\n * the provisioner something else. The result was a deployed URL the running code\n * had no driver for — two documents disagreeing about one fact, which is what\n * this manifest exists to stop.\n */\nexport const backends = ${serialise(backends)} as const;\n\n// Derived types\nexport type Ids = IdsOf<typeof constructs>;\nexport type Construct<Id extends Ids> = DeclarationOf<typeof constructs, Id>;\nexport type Kind = Construct<Ids>['kind'];\n\n// Useful union types\nexport type ProvidedKeys = AllProvidedKeys<typeof constructs>;\nexport type Surfaces = IdsOfKind<typeof constructs, 'rest-api'>;\nexport type CacheBackend = (typeof backends)['cache'];\nexport type EmailBackend = (typeof backends)['email'];\n`;\n}\n\n/** The choices that are deployment config rather than declaration. */\nexport interface Backends {\n\tcache?: CacheBackend;\n\temail?: EmailBackend;\n\t/**\n\t * The labels no tenant of the wildcard site may take — every app's own\n\t * and the workspace's `protectedSubdomains`. Config the AWS target cannot\n\t * read for itself, so it travels with the manifest.\n\t */\n\tprotectedSubdomains?: readonly string[];\n}\n\nconst HEADER = `// Generated by \\`gkm build\\`. Do not edit.\n//\n// Discovery imports application code, so it runs once here rather than in every\n// consumer — a deploy config that discovered for itself would evaluate the whole\n// runtime graph inside its own toolchain. This is the result, as literals.\n\nimport type {\n\tAllProvidedKeys,\n\tConstructManifest,\n\tDeclarationOf,\n\tIdsOf,\n\tIdsOfKind,\n} from '@geekmidas/manifest';\n`;\n\n/**\n * JSON, re-indented with tabs and with keys left unquoted where they can be.\n *\n * Cosmetic, and worth it: this file is read by people trying to work out what\n * their app declares, and a wall of quoted keys reads as output rather than as\n * something anyone is expected to understand.\n */\nfunction serialise(value: object): string {\n\treturn JSON.stringify(value, null, '\\t')\n\t\t.replace(/^(\\t*)\"([A-Za-z_$][\\w$]*)\":/gm, '$1$2:')\n\t\t.replace(/\"/g, \"'\");\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,SAAgB,aACf,UACA,WACoB;CACpB,MAAM,OAAoC,EAAE,GAAG,SAAS;CACxD,MAAM,MACL,MACA,IACA,YACS,KAAK,KAAK,SAAU,KAAK,OAAO,KAAK;EAAE,GAAG;EAAM;CAAQ,IAAI,IAAK;CAE3E,KAAK,MAAM,SAAS,UAAU,UAAU,CAAC,GACxC,KAAK,MAAM,CAAC,IAAI,gBAAgB,OAAO,QAAQ,IAAI,GAAG;EACrD,IAAI,YAAY,SAAS,YAAY;EACrC,IAAI,MAAM,WAAW,MAAM,YAAY,IAAI;EAC3C,KAAK,MAAM;GACV,GAAG;GACH,WAAW,YAAY,UAAU,KAAK,aACrC,SAAS,WAAW,MAAM,UAAU,SAAS,SAAS,MAAM,OACzD;IAAE,GAAG;IAAU,SAAS,MAAM;GAAQ,IACtC,QACJ;EACD;CACD;CAGD,KA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AAgB,eACf,UACA,WAAqB,CAAC,GACb;CACT,OAAO,GAAG,OAAO;4BACU,UAAU,QAAQ,EAAE;;;;;;;;;;;0BAWtB,UAAU,QAAQ,EAAE;;;;;;;;;;;;;AAa9C;AAcA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;AAsBf,SAAS,UAAU,OAAuB;CACzC,OAAO,KAAK,UAAU,OAAO,MAAM,GAAI,CAAC,CACtC,QAAQ,iCAAiC,OAAO,CAAC,CACjD,QAAQ,MAAM,GAAG;AACpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
2
|
import { N as assertDeployedStage } from "./workspace-aiDQZMje.mjs";
|
|
3
|
-
import { Rt as providerOf, Yt as secretsStoreFor, nn as withCustomSecret } from "./seeds-
|
|
3
|
+
import { Rt as providerOf, Yt as secretsStoreFor, nn as withCustomSecret } from "./seeds-WyxyXjxu.mjs";
|
|
4
4
|
import { loadWorkspaceSettings } from "./config.mjs";
|
|
5
5
|
import { canonicalId, provideKey } from "@geekmidas/manifest";
|
|
6
6
|
import { parseKeyring, retireKey, rotateKeyring } from "@geekmidas/constructs/encryption";
|
|
@@ -86,4 +86,4 @@ async function updateKeyring(construct, { stage }, context, update) {
|
|
|
86
86
|
//#endregion
|
|
87
87
|
export { encryptionRetireCommand, encryptionRotateCommand };
|
|
88
88
|
|
|
89
|
-
//# sourceMappingURL=encryption-
|
|
89
|
+
//# sourceMappingURL=encryption-B1wVX-iK.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-
|
|
1
|
+
{"version":3,"file":"encryption-B1wVX-iK.mjs","names":[],"sources":["../src/encryption/index.ts"],"sourcesContent":["/**\n * `gkm encryption:rotate` and `gkm encryption:retire` — the keyring of an\n * `Encryption` construct on a server stage.\n *\n * Rotating adds a key in front and keeps every older one, so what they wrote\n * still opens. Retiring removes one, and is the half that makes rotating worth\n * doing: until a key is gone, it still opens everything it ever wrote. It is\n * never automatic, because the only thing that knows nothing is left under a\n * key is the sweep that re-encrypted the column — so it is done after one,\n * deliberately, by name.\n *\n * Neither applies everywhere, and each says so rather than doing something\n * that looks right: a local stage's keyring is derived and would be replaced on\n * the next `gkm dev`, and on AWS the key is KMS's, which rotates it itself and\n * never strands a value.\n */\n\nimport {\n\tparseKeyring,\n\tretireKey,\n\trotateKeyring,\n} from '@geekmidas/constructs/encryption';\nimport { canonicalId, provideKey } from '@geekmidas/manifest';\nimport { loadWorkspaceSettings } from '../config';\nimport { GkmError } from '../errors';\nimport { withCustomSecret } from '../secrets/storage.js';\nimport { type SecretsStore, secretsStoreFor } from '../secrets/store.js';\nimport { providerOf } from '../workspace/backends.js';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\nconst logger = console;\n\nexport class LocalKeyringIsDerived extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly stage: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' is the local stage, where ${construct}'s keyring is derived from the project and stage — nothing stored there would be read. Rotate a deployed stage: gkm encryption:rotate ${construct} --stage <stage>.`,\n\t\t);\n\t\tthis.name = 'LocalKeyringIsDerived';\n\t}\n}\n\nexport class KmsRotatesItself extends GkmError {\n\tconstructor(readonly construct: string) {\n\t\tsuper(\n\t\t\t`${construct} is a KMS key on AWS: KMS rotates it yearly and keeps every version, so no value is ever stranded and there is no key to retire. Nothing to do here.`,\n\t\t);\n\t\tthis.name = 'KmsRotatesItself';\n\t}\n}\n\nexport class NoKeyringYet extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly stage: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' has no ${key} yet. The first deploy generates ${construct}'s keyring: gkm deploy --stage ${stage}.`,\n\t\t);\n\t\tthis.name = 'NoKeyringYet';\n\t}\n}\n\nexport interface EncryptionCommandOptions {\n\tstage: string;\n}\n\n/** Where a command reads and writes; the real ones unless a test says. */\nexport interface EncryptionCommandContext {\n\tworkspace?: NormalizedWorkspace;\n\tstore?: SecretsStore;\n}\n\nexport async function encryptionRotateCommand(\n\tconstruct: string,\n\toptions: EncryptionCommandOptions,\n\tcontext: EncryptionCommandContext = {},\n): Promise<string> {\n\treturn updateKeyring(construct, options, context, (id, url) => {\n\t\tconst next = rotateKeyring(id, url);\n\t\tconst [current, ...older] = parseKeyring(id, next).keys.map(({ id }) => id);\n\n\t\tlogger.log(`\\n✓ ${id} on '${options.stage}' now writes with '${current}'.`);\n\t\tlogger.log(\n\t\t\t` Still opening: ${older.join(', ')}. Redeploy to start writing with '${current}', reencrypt what is stored, then: gkm encryption:retire ${id} <key> --stage ${options.stage}`,\n\t\t);\n\t\treturn next;\n\t});\n}\n\nexport async function encryptionRetireCommand(\n\tconstruct: string,\n\tkeyId: string,\n\toptions: EncryptionCommandOptions,\n\tcontext: EncryptionCommandContext = {},\n): Promise<string> {\n\treturn updateKeyring(construct, options, context, (id, url) => {\n\t\tconst next = retireKey(id, url, keyId);\n\n\t\tlogger.log(\n\t\t\t`\\n✓ ${id} on '${options.stage}' no longer holds '${keyId}'. Anything still under it cannot be read after the next deploy.`,\n\t\t);\n\t\treturn next;\n\t});\n}\n\nasync function updateKeyring(\n\tconstruct: string,\n\t{ stage }: EncryptionCommandOptions,\n\tcontext: EncryptionCommandContext,\n\tupdate: (id: string, url: string) => string,\n): Promise<string> {\n\tconst workspace = context.workspace ?? (await loadWorkspaceSettings());\n\tconst id = canonicalId(construct);\n\n\tif (stage === workspace.stages.local) {\n\t\tthrow new LocalKeyringIsDerived(id, stage);\n\t}\n\tassertDeployedStage(workspace.stages, stage);\n\tif (providerOf(workspace) === 'aws') throw new KmsRotatesItself(id);\n\n\tconst store = context.store ?? (await secretsStoreFor(workspace, stage));\n\tconst key = provideKey(id, 'url');\n\tconst secrets = await store.read(stage);\n\tconst url = secrets?.custom[key];\n\tif (!secrets || !url) throw new NoKeyringYet(id, stage, key);\n\n\tconst next = update(id, url);\n\tawait store.write(stage, withCustomSecret(secrets, key, next));\n\treturn next;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,SAAS;AAEf,IAAa,wBAAb,cAA2C,SAAS;CAEzC;CACA;CAFV,YACC,WACA,OACC;EACD,MACC,IAAI,MAAM,8BAA8B,UAAU,wIAAwI,UAAU,kBACrM;EALS,KAAA,YAAA;EACA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;AAEA,IAAa,mBAAb,cAAsC,SAAS;CACzB;CAArB,YAAY,WAA4B;EACvC,MACC,GAAG,UAAU,qJACd;EAHoB,KAAA,YAAA;EAIpB,KAAK,OAAO;CACb;AACD;AAEA,IAAa,eAAb,cAAkC,SAAS;CAEhC;CACA;CACA;CAHV,YACC,WACA,OACA,KACC;EACD,MACC,IAAI,MAAM,WAAW,IAAI,mCAAmC,UAAU,iCAAiC,MAAM,EAC9G;EANS,KAAA,YAAA;EACA,KAAA,QAAA;EACA,KAAA,MAAA;EAKT,KAAK,OAAO;CACb;AACD;AAYA,eAAsB,wBACrB,WACA,SACA,UAAoC,CAAC,GACnB;CAClB,OAAO,cAAc,WAAW,SAAS,UAAU,IAAI,QAAQ;EAC9D,MAAM,OAAO,cAAc,IAAI,GAAG;EAClC,MAAM,CAAC,SAAS,GAAG,SAAS,aAAa,IAAI,IAAI,CAAC,CAAC,KAAK,KAAK,EAAE,SAAS,EAAE;EAE1E,OAAO,IAAI,OAAO,GAAG,OAAO,QAAQ,MAAM,qBAAqB,QAAQ,GAAG;EAC1E,OAAO,IACN,oBAAoB,MAAM,KAAK,IAAI,EAAE,oCAAoC,QAAQ,2DAA2D,GAAG,iBAAiB,QAAQ,OACzK;EACA,OAAO;CACR,CAAC;AACF;AAEA,eAAsB,wBACrB,WACA,OACA,SACA,UAAoC,CAAC,GACnB;CAClB,OAAO,cAAc,WAAW,SAAS,UAAU,IAAI,QAAQ;EAC9D,MAAM,OAAO,UAAU,IAAI,KAAK,KAAK;EAErC,OAAO,IACN,OAAO,GAAG,OAAO,QAAQ,MAAM,qBAAqB,MAAM,iEAC3D;EACA,OAAO;CACR,CAAC;AACF;AAEA,eAAe,cACd,WACA,EAAE,SACF,SACA,QACkB;CAClB,MAAM,YAAY,QAAQ,aAAc,MAAM,sBAAsB;CACpE,MAAM,KAAK,YAAY,SAAS;CAEhC,IAAI,UAAU,UAAU,OAAO,OAC9B,MAAM,IAAI,sBAAsB,IAAI,KAAK;CAE1C,oBAAoB,UAAU,QAAQ,KAAK;CAC3C,IAAI,WAAW,SAAS,MAAM,OAAO,MAAM,IAAI,iBAAiB,EAAE;CAElE,MAAM,QAAQ,QAAQ,SAAU,MAAM,gBAAgB,WAAW,KAAK;CACtE,MAAM,MAAM,WAAW,IAAI,KAAK;CAChC,MAAM,UAAU,MAAM,MAAM,KAAK,KAAK;CACtC,MAAM,MAAM,SAAS,OAAO;CAC5B,IAAI,CAAC,WAAW,CAAC,KAAK,MAAM,IAAI,aAAa,IAAI,OAAO,GAAG;CAE3D,MAAM,OAAO,OAAO,IAAI,GAAG;CAC3B,MAAM,MAAM,MAAM,OAAO,iBAAiB,SAAS,KAAK,IAAI,CAAC;CAC7D,OAAO;AACR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
2
2
|
const require_workspace = require("./workspace-secxwA6K.cjs");
|
|
3
|
-
const require_seeds = require("./seeds-
|
|
3
|
+
const require_seeds = require("./seeds-D70hodXu.cjs");
|
|
4
4
|
const require_config = require("./config.cjs");
|
|
5
5
|
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
6
6
|
let _geekmidas_constructs_encryption = require("@geekmidas/constructs/encryption");
|
|
@@ -87,4 +87,4 @@ async function updateKeyring(construct, { stage }, context, update) {
|
|
|
87
87
|
exports.encryptionRetireCommand = encryptionRetireCommand;
|
|
88
88
|
exports.encryptionRotateCommand = encryptionRotateCommand;
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=encryption-
|
|
90
|
+
//# sourceMappingURL=encryption-CKt33qlB.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-
|
|
1
|
+
{"version":3,"file":"encryption-CKt33qlB.cjs","names":["GkmError","rotateKeyring","parseKeyring","retireKey","loadWorkspaceSettings","canonicalId","providerOf","secretsStoreFor","provideKey","withCustomSecret"],"sources":["../src/encryption/index.ts"],"sourcesContent":["/**\n * `gkm encryption:rotate` and `gkm encryption:retire` — the keyring of an\n * `Encryption` construct on a server stage.\n *\n * Rotating adds a key in front and keeps every older one, so what they wrote\n * still opens. Retiring removes one, and is the half that makes rotating worth\n * doing: until a key is gone, it still opens everything it ever wrote. It is\n * never automatic, because the only thing that knows nothing is left under a\n * key is the sweep that re-encrypted the column — so it is done after one,\n * deliberately, by name.\n *\n * Neither applies everywhere, and each says so rather than doing something\n * that looks right: a local stage's keyring is derived and would be replaced on\n * the next `gkm dev`, and on AWS the key is KMS's, which rotates it itself and\n * never strands a value.\n */\n\nimport {\n\tparseKeyring,\n\tretireKey,\n\trotateKeyring,\n} from '@geekmidas/constructs/encryption';\nimport { canonicalId, provideKey } from '@geekmidas/manifest';\nimport { loadWorkspaceSettings } from '../config';\nimport { GkmError } from '../errors';\nimport { withCustomSecret } from '../secrets/storage.js';\nimport { type SecretsStore, secretsStoreFor } from '../secrets/store.js';\nimport { providerOf } from '../workspace/backends.js';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\nconst logger = console;\n\nexport class LocalKeyringIsDerived extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly stage: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' is the local stage, where ${construct}'s keyring is derived from the project and stage — nothing stored there would be read. Rotate a deployed stage: gkm encryption:rotate ${construct} --stage <stage>.`,\n\t\t);\n\t\tthis.name = 'LocalKeyringIsDerived';\n\t}\n}\n\nexport class KmsRotatesItself extends GkmError {\n\tconstructor(readonly construct: string) {\n\t\tsuper(\n\t\t\t`${construct} is a KMS key on AWS: KMS rotates it yearly and keeps every version, so no value is ever stranded and there is no key to retire. Nothing to do here.`,\n\t\t);\n\t\tthis.name = 'KmsRotatesItself';\n\t}\n}\n\nexport class NoKeyringYet extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly stage: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' has no ${key} yet. The first deploy generates ${construct}'s keyring: gkm deploy --stage ${stage}.`,\n\t\t);\n\t\tthis.name = 'NoKeyringYet';\n\t}\n}\n\nexport interface EncryptionCommandOptions {\n\tstage: string;\n}\n\n/** Where a command reads and writes; the real ones unless a test says. */\nexport interface EncryptionCommandContext {\n\tworkspace?: NormalizedWorkspace;\n\tstore?: SecretsStore;\n}\n\nexport async function encryptionRotateCommand(\n\tconstruct: string,\n\toptions: EncryptionCommandOptions,\n\tcontext: EncryptionCommandContext = {},\n): Promise<string> {\n\treturn updateKeyring(construct, options, context, (id, url) => {\n\t\tconst next = rotateKeyring(id, url);\n\t\tconst [current, ...older] = parseKeyring(id, next).keys.map(({ id }) => id);\n\n\t\tlogger.log(`\\n✓ ${id} on '${options.stage}' now writes with '${current}'.`);\n\t\tlogger.log(\n\t\t\t` Still opening: ${older.join(', ')}. Redeploy to start writing with '${current}', reencrypt what is stored, then: gkm encryption:retire ${id} <key> --stage ${options.stage}`,\n\t\t);\n\t\treturn next;\n\t});\n}\n\nexport async function encryptionRetireCommand(\n\tconstruct: string,\n\tkeyId: string,\n\toptions: EncryptionCommandOptions,\n\tcontext: EncryptionCommandContext = {},\n): Promise<string> {\n\treturn updateKeyring(construct, options, context, (id, url) => {\n\t\tconst next = retireKey(id, url, keyId);\n\n\t\tlogger.log(\n\t\t\t`\\n✓ ${id} on '${options.stage}' no longer holds '${keyId}'. Anything still under it cannot be read after the next deploy.`,\n\t\t);\n\t\treturn next;\n\t});\n}\n\nasync function updateKeyring(\n\tconstruct: string,\n\t{ stage }: EncryptionCommandOptions,\n\tcontext: EncryptionCommandContext,\n\tupdate: (id: string, url: string) => string,\n): Promise<string> {\n\tconst workspace = context.workspace ?? (await loadWorkspaceSettings());\n\tconst id = canonicalId(construct);\n\n\tif (stage === workspace.stages.local) {\n\t\tthrow new LocalKeyringIsDerived(id, stage);\n\t}\n\tassertDeployedStage(workspace.stages, stage);\n\tif (providerOf(workspace) === 'aws') throw new KmsRotatesItself(id);\n\n\tconst store = context.store ?? (await secretsStoreFor(workspace, stage));\n\tconst key = provideKey(id, 'url');\n\tconst secrets = await store.read(stage);\n\tconst url = secrets?.custom[key];\n\tif (!secrets || !url) throw new NoKeyringYet(id, stage, key);\n\n\tconst next = update(id, url);\n\tawait store.write(stage, withCustomSecret(secrets, key, next));\n\treturn next;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,SAAS;AAEf,IAAa,wBAAb,cAA2CA,eAAAA,SAAS;CAEzC;CACA;CAFV,YACC,WACA,OACC;EACD,MACC,IAAI,MAAM,8BAA8B,UAAU,wIAAwI,UAAU,kBACrM;EALS,KAAA,YAAA;EACA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;AAEA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CACzB;CAArB,YAAY,WAA4B;EACvC,MACC,GAAG,UAAU,qJACd;EAHoB,KAAA,YAAA;EAIpB,KAAK,OAAO;CACb;AACD;AAEA,IAAa,eAAb,cAAkCA,eAAAA,SAAS;CAEhC;CACA;CACA;CAHV,YACC,WACA,OACA,KACC;EACD,MACC,IAAI,MAAM,WAAW,IAAI,mCAAmC,UAAU,iCAAiC,MAAM,EAC9G;EANS,KAAA,YAAA;EACA,KAAA,QAAA;EACA,KAAA,MAAA;EAKT,KAAK,OAAO;CACb;AACD;AAYA,eAAsB,wBACrB,WACA,SACA,UAAoC,CAAC,GACnB;CAClB,OAAO,cAAc,WAAW,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AAC,KAAK,MAAM,IAAI,aAAa,IAAI,OAAO,GAAG;CAE3D,MAAM,OAAO,OAAO,IAAI,GAAG;CAC3B,MAAM,MAAM,MAAM,OAAOC,cAAAA,iBAAiB,SAAS,KAAK,IAAI,CAAC;CAC7D,OAAO;AACR"}
|
|
@@ -2,13 +2,13 @@ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
|
2
2
|
import { c as runOutput, s as run, t as MissingCredential } from "./credentials-DpfnUvIR.mjs";
|
|
3
3
|
import { I as otlpTelemetryEnv, L as resolveStageTelemetry, ht as isReservedStageKey, u as getAppBuildOrder, v as getPublicEnvPrefix, y as stripPublicPrefix } from "./workspace-aiDQZMje.mjs";
|
|
4
4
|
import { a as discriminatedUnion, c as literal, d as object, l as looseObject, n as array, p as string } from "./schemas-BCwKKA42.mjs";
|
|
5
|
-
import { $n as telemetryOf, C as getGeneratedSecret, Ct as backendsOf, D as setBackupState, E as setApplicationId, F as DockerBuildFailed, I as DockerPushFailed, It as cacheBackendFor, Jn as resourceName, Ln as withGeneratedSecrets, Lt as eventsBackendFor, N as stageProviderNotes, O as setGeneratedSecret, Qt as initStageSecrets, R as dockerCommand, Rt as providerOf, S as getBackupState, T as recordRollback, U as workerDockerfileOf, Yn as appTelemetry, Zn as scopeTelemetryEnv, _t as appEnvKeys, an as PROCESSOR_PORT, bn as applyPostgres, br as resolveHost, bt as processorEnvKeys, c as currentActor, ct as ExternalServicesNotConfigured, d as DeployJournal, dt as devServicesUsed, er as usesTelemetry, et as PROCESSOR_ORIGIN_SECRET_ENV, ft as externalServices, g as verifyDnsRecords, h as orchestrateDns, hn as workerUnits, ht as stageServiceDeclarations, it as validateImageRef, k as setPostgresBackupId, lt as STORAGE_KEY_PAIR, mn as processorUnits, n as reportDatabaseRuns, nt as originSecretKey, r as reportPlannedSeeds, rt as processorOriginHost, sn as WORKER_PORT, t as DeploySeedsFailed, tn as toEmbeddableSecrets, vt as dockerfileOf, w as recordRelease, wt as constructGlobs, x as createEmptyState, xt as workerEnvKeys, y as asDokployState, yr as isMainFrontendApp, zt as storageBackendFor } from "./seeds-
|
|
6
|
-
import { t as appKey } from "./derive-
|
|
5
|
+
import { $n as telemetryOf, C as getGeneratedSecret, Ct as backendsOf, D as setBackupState, E as setApplicationId, F as DockerBuildFailed, I as DockerPushFailed, It as cacheBackendFor, Jn as resourceName, Ln as withGeneratedSecrets, Lt as eventsBackendFor, N as stageProviderNotes, O as setGeneratedSecret, Qt as initStageSecrets, R as dockerCommand, Rt as providerOf, S as getBackupState, T as recordRollback, U as workerDockerfileOf, Yn as appTelemetry, Zn as scopeTelemetryEnv, _t as appEnvKeys, an as PROCESSOR_PORT, bn as applyPostgres, br as resolveHost, bt as processorEnvKeys, c as currentActor, ct as ExternalServicesNotConfigured, d as DeployJournal, dt as devServicesUsed, er as usesTelemetry, et as PROCESSOR_ORIGIN_SECRET_ENV, ft as externalServices, g as verifyDnsRecords, h as orchestrateDns, hn as workerUnits, ht as stageServiceDeclarations, it as validateImageRef, k as setPostgresBackupId, lt as STORAGE_KEY_PAIR, mn as processorUnits, n as reportDatabaseRuns, nt as originSecretKey, r as reportPlannedSeeds, rt as processorOriginHost, sn as WORKER_PORT, t as DeploySeedsFailed, tn as toEmbeddableSecrets, vt as dockerfileOf, w as recordRelease, wt as constructGlobs, x as createEmptyState, xt as workerEnvKeys, y as asDokployState, yr as isMainFrontendApp, zt as storageBackendFor } from "./seeds-WyxyXjxu.mjs";
|
|
6
|
+
import { t as appKey } from "./derive-Cd7Hl3r2.mjs";
|
|
7
7
|
import { a as imageRef, c as ownershipMarker, i as imageName, l as projectName, o as isOwnedBy, s as markerOf, t as applicationName } from "./identity-CBXr4wNi.mjs";
|
|
8
|
-
import { f as output, i as discover, l as runWorker } from "./discover-
|
|
8
|
+
import { f as output, i as discover, l as runWorker } from "./discover-DWtHjc1x.mjs";
|
|
9
9
|
import { i as activeSandbox } from "./sandbox-CbVB7uOD.mjs";
|
|
10
10
|
import { t as LocalSandbox } from "./local-B7Zv1NoA.mjs";
|
|
11
|
-
import { D as encryptSecrets, E as eventError, g as StateVersionConflict, k as keyFingerprint, m as StateStoreBusy, o as DokployApi, s as DokployApiError, t as sniffAllApps } from "./sniffer-
|
|
11
|
+
import { D as encryptSecrets, E as eventError, g as StateVersionConflict, k as keyFingerprint, m as StateStoreBusy, o as DokployApi, s as DokployApiError, t as sniffAllApps } from "./sniffer-C7Y1pnTH.mjs";
|
|
12
12
|
import { f as plannedSeeds, y as migrationFiles } from "./databases-Db48ZIXL.mjs";
|
|
13
13
|
import { join, relative } from "node:path";
|
|
14
14
|
import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
@@ -1957,17 +1957,13 @@ async function validateDokploy(phase) {
|
|
|
1957
1957
|
const stored = await phase.secrets.read();
|
|
1958
1958
|
const services = externalServices({
|
|
1959
1959
|
stage,
|
|
1960
|
-
declarations: stageServiceDeclarations({
|
|
1961
|
-
manifest: phase.manifest,
|
|
1962
|
-
...phase.runnables ? { runnables: phase.runnables } : {}
|
|
1963
|
-
}),
|
|
1960
|
+
declarations: stageServiceDeclarations({ manifest: phase.manifest }),
|
|
1964
1961
|
supplied: stored?.custom ?? {},
|
|
1965
1962
|
allow: phase.allowDevServices,
|
|
1966
1963
|
...workspace.domains?.[stage] ? { domain: workspace.domains[stage] } : {},
|
|
1967
1964
|
providers: stageProviderNotes(workspace, stage)
|
|
1968
1965
|
});
|
|
1969
1966
|
const devServices = devServicesUsed(services);
|
|
1970
|
-
const runnables = phase.runnables ?? {};
|
|
1971
1967
|
const background = phase.background ?? {};
|
|
1972
1968
|
const workers = workerUnits(workspace, phase.manifest, background).filter((worker) => appsToDeployNames.includes(worker.app));
|
|
1973
1969
|
if (workers.length > 0) logger.log(` Deploying workers: ${workers.map((w) => `${w.name} (from ${w.app})`).join(", ")}`);
|
|
@@ -1978,7 +1974,6 @@ async function validateDokploy(phase) {
|
|
|
1978
1974
|
devServices: devServices.map((use) => use.service),
|
|
1979
1975
|
workers,
|
|
1980
1976
|
processors,
|
|
1981
|
-
runnables,
|
|
1982
1977
|
preflight: await preflight(run),
|
|
1983
1978
|
verify: verifySettings(workspace.deploy.dokploy?.verify),
|
|
1984
1979
|
atomic: phase.atomic,
|
|
@@ -2398,7 +2393,7 @@ async function releaseDokploy(run) {
|
|
|
2398
2393
|
...sniffedVars
|
|
2399
2394
|
])], envContext);
|
|
2400
2395
|
if (!valid) throw new MissingEnvVars(appName, missing, stage);
|
|
2401
|
-
const own = appEnvKeys(run.manifest, appName
|
|
2396
|
+
const own = appEnvKeys(run.manifest, appName);
|
|
2402
2397
|
const withDeclared = scopeTelemetryEnv({
|
|
2403
2398
|
...resolved,
|
|
2404
2399
|
...Object.fromEntries(Object.entries(declaredEnv).filter(([key]) => own === void 0 || own.has(key)))
|
|
@@ -2443,7 +2438,7 @@ async function releaseDokploy(run) {
|
|
|
2443
2438
|
logger.log(`\n 🧵 Deploying ${worker.name} (worker ${worker.id})...`);
|
|
2444
2439
|
try {
|
|
2445
2440
|
const application = await ensureApplication(api, journal, worker.name, applicationName(identity, worker.name), project.projectId, environmentId, applied);
|
|
2446
|
-
const keys = [...workerEnvKeys(run.manifest, worker.id
|
|
2441
|
+
const keys = [...workerEnvKeys(run.manifest, worker.id) ?? []].sort();
|
|
2447
2442
|
const secrets = prepareSecretsForApp(stageSecrets, {
|
|
2448
2443
|
appName: worker.name,
|
|
2449
2444
|
requiredEnvVars: keys,
|
|
@@ -2515,7 +2510,7 @@ async function releaseDokploy(run) {
|
|
|
2515
2510
|
if (!domain || !secret) throw new ProcessorsNeedCdn(unit.id, secretKey, stage);
|
|
2516
2511
|
try {
|
|
2517
2512
|
const application = await ensureApplication(api, journal, unit.name, applicationName(identity, unit.name), project.projectId, environmentId, applied);
|
|
2518
|
-
const keys = [...processorEnvKeys(run.manifest, unit.id
|
|
2513
|
+
const keys = [...processorEnvKeys(run.manifest, unit.id) ?? []].sort();
|
|
2519
2514
|
const secrets = prepareSecretsForApp(stageSecrets, {
|
|
2520
2515
|
appName: unit.name,
|
|
2521
2516
|
requiredEnvVars: keys,
|
|
@@ -3212,4 +3207,4 @@ const MOBILE_SKIP_REASON = "deploys via its framework toolchain";
|
|
|
3212
3207
|
//#endregion
|
|
3213
3208
|
export { RegistryNotConfigured as _, dokployResult as a, releaseDokploy as c, validateDokploy as d, verifyDokploy as f, RegistryAmbiguous as g, HealthCheckTimedOut as h, dokployApi as i, restoreImage as l, DeployMigrationsFailed as m, FrontendDeployFailed as n, planDokploy as o, verifySettings as p, MissingEnvVars as r, provisionDokploy as s, BackendDeployFailed as t, rollbackDokploy as u, RegistryNotFound as v, ProjectNotOwned as y };
|
|
3214
3209
|
|
|
3215
|
-
//# sourceMappingURL=engine-
|
|
3210
|
+
//# sourceMappingURL=engine-B66avdZg.mjs.map
|