@geekmidas/cli 10.0.0-alpha.146 → 10.0.0-alpha.148
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/{GoDaddyProvider-BESq24p-.mjs → GoDaddyProvider-CGgS-I6m.mjs} +2 -2
- package/dist/{GoDaddyProvider-BESq24p-.mjs.map → GoDaddyProvider-CGgS-I6m.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-BK5N6-fx.cjs → GoDaddyProvider-D_dZQJIX.cjs} +2 -2
- package/dist/{GoDaddyProvider-BK5N6-fx.cjs.map → GoDaddyProvider-D_dZQJIX.cjs.map} +1 -1
- package/dist/{HostingerProvider-BV30wTNI.mjs → HostingerProvider-CWRE6auw.mjs} +2 -2
- package/dist/{HostingerProvider-BV30wTNI.mjs.map → HostingerProvider-CWRE6auw.mjs.map} +1 -1
- package/dist/{HostingerProvider-BbQod5OB.cjs → HostingerProvider-eGuDBjfN.cjs} +2 -2
- package/dist/{HostingerProvider-BbQod5OB.cjs.map → HostingerProvider-eGuDBjfN.cjs.map} +1 -1
- package/dist/{LegacyStateStore-Ck3HI28A.mjs → LegacyStateStore-CLyFmPIj.mjs} +2 -2
- package/dist/{LegacyStateStore-Ck3HI28A.mjs.map → LegacyStateStore-CLyFmPIj.mjs.map} +1 -1
- package/dist/{LegacyStateStore-OEno6vIb.cjs → LegacyStateStore-DyX9-7R_.cjs} +2 -2
- package/dist/{LegacyStateStore-OEno6vIb.cjs.map → LegacyStateStore-DyX9-7R_.cjs.map} +1 -1
- package/dist/{LocalStateStore-ukDFg6GM.cjs → LocalStateStore-C-v8K8zO.cjs} +2 -2
- package/dist/{LocalStateStore-ukDFg6GM.cjs.map → LocalStateStore-C-v8K8zO.cjs.map} +1 -1
- package/dist/{LocalStateStore-Fa54CpLw.mjs → LocalStateStore-DQVwsyTh.mjs} +2 -2
- package/dist/{LocalStateStore-Fa54CpLw.mjs.map → LocalStateStore-DQVwsyTh.mjs.map} +1 -1
- package/dist/{S3StateStore-Cjuft2Lk.cjs → S3StateStore-GA-DOTmj.cjs} +4 -4
- package/dist/{S3StateStore-Cjuft2Lk.cjs.map → S3StateStore-GA-DOTmj.cjs.map} +1 -1
- package/dist/{S3StateStore-D53985SR.mjs → S3StateStore-gR_6fNF6.mjs} +4 -4
- package/dist/{S3StateStore-D53985SR.mjs.map → S3StateStore-gR_6fNF6.mjs.map} +1 -1
- package/dist/{SSMStateStore-CRjV2h2G.mjs → SSMStateStore-CT68N-Ti.mjs} +2 -2
- package/dist/{SSMStateStore-CRjV2h2G.mjs.map → SSMStateStore-CT68N-Ti.mjs.map} +1 -1
- package/dist/{SSMStateStore-CnJgw3_-.cjs → SSMStateStore-kdb9rf7x.cjs} +2 -2
- package/dist/{SSMStateStore-CnJgw3_-.cjs.map → SSMStateStore-kdb9rf7x.cjs.map} +1 -1
- package/dist/{add-CG_4mNir.cjs → add-C7_WJEv2.cjs} +7 -8
- package/dist/{add-CG_4mNir.cjs.map → add-C7_WJEv2.cjs.map} +1 -1
- package/dist/{add-D0-1UyFj.mjs → add-CvmRPEfW.mjs} +6 -7
- package/dist/{add-D0-1UyFj.mjs.map → add-CvmRPEfW.mjs.map} +1 -1
- package/dist/{apps-DHi6E_yH.cjs → apps-ClZkLcMz.cjs} +771 -17
- package/dist/apps-ClZkLcMz.cjs.map +1 -0
- package/dist/{apps-DWALM-8s.mjs → apps-CmKxFPTj.mjs} +611 -19
- package/dist/apps-CmKxFPTj.mjs.map +1 -0
- package/dist/{bundler-Cb5ynXXS.mjs → bundler-D6IEJvq4.mjs} +6 -6
- package/dist/{bundler-Cb5ynXXS.mjs.map → bundler-D6IEJvq4.mjs.map} +1 -1
- package/dist/{bundler-Co_7zpYC.cjs → bundler-Ronn7-mL.cjs} +6 -6
- package/dist/{bundler-Co_7zpYC.cjs.map → bundler-Ronn7-mL.cjs.map} +1 -1
- package/dist/{cli-D_9WqN6C.mjs → cli-AZVyGSRn.mjs} +4 -4
- package/dist/{cli-D_9WqN6C.mjs.map → cli-AZVyGSRn.mjs.map} +1 -1
- package/dist/{cli-C5M_7Kux.cjs → cli-B1g2OvS0.cjs} +4 -4
- package/dist/{cli-C5M_7Kux.cjs.map → cli-B1g2OvS0.cjs.map} +1 -1
- package/dist/{compose-BeQ01iYk.cjs → compose-B5AsRVqr.cjs} +291 -36
- package/dist/compose-B5AsRVqr.cjs.map +1 -0
- package/dist/{compose-DxmEMeTu.mjs → compose-BRNMF29g.mjs} +286 -31
- package/dist/compose-BRNMF29g.mjs.map +1 -0
- package/dist/{compose-7p0-3ogo.mjs → compose-DNuENvIt.mjs} +15 -9
- package/dist/{compose-7p0-3ogo.mjs.map → compose-DNuENvIt.mjs.map} +1 -1
- package/dist/{compose-C10hkeHU.cjs → compose-DVPWitEu.cjs} +32 -8
- package/dist/{compose-C10hkeHU.cjs.map → compose-DVPWitEu.cjs.map} +1 -1
- package/dist/{config-B-wza0Xk.mjs → config-BLrAd7Of.mjs} +2 -2
- package/dist/{config-B-wza0Xk.mjs.map → config-BLrAd7Of.mjs.map} +1 -1
- package/dist/{config-BcL1Fojs.d.cts → config-CRk2vdSp.d.mts} +3 -3
- package/dist/{config-BbivVpq0.d.mts.map → config-CRk2vdSp.d.mts.map} +1 -1
- package/dist/{config-CWExbDxA.cjs → config-juUyBlb1.cjs} +2 -2
- package/dist/{config-CWExbDxA.cjs.map → config-juUyBlb1.cjs.map} +1 -1
- package/dist/{config-BbivVpq0.d.mts → config-oBgsbLip.d.cts} +3 -3
- package/dist/{config-BcL1Fojs.d.cts.map → config-oBgsbLip.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/{credentials-Csnd7M8M.cjs → credentials-CrQglKgo.cjs} +6 -70
- package/dist/credentials-CrQglKgo.cjs.map +1 -0
- package/dist/{credentials-B5Oe4fLE.mjs → credentials-FRF4PZYo.mjs} +8 -42
- package/dist/credentials-FRF4PZYo.mjs.map +1 -0
- package/dist/deploy/public.cjs +12 -12
- package/dist/deploy/public.d.cts +3 -3
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +3 -3
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +12 -12
- package/dist/{deploy-6DDEG4Ai.mjs → deploy-DI_tg5Mi.mjs} +13 -13
- package/dist/{deploy-6DDEG4Ai.mjs.map → deploy-DI_tg5Mi.mjs.map} +1 -1
- package/dist/{deploy-BwNxJ3ZI.cjs → deploy-DTBod420.cjs} +31 -31
- package/dist/{deploy-BwNxJ3ZI.cjs.map → deploy-DTBod420.cjs.map} +1 -1
- package/dist/{docker-BZnNUJCy.cjs → docker-CnWX5QNR.cjs} +8 -8
- package/dist/{docker-BZnNUJCy.cjs.map → docker-CnWX5QNR.cjs.map} +1 -1
- package/dist/{docker-Ch5aPQ04.mjs → docker-DsJNWnaX.mjs} +5 -5
- package/dist/{docker-Ch5aPQ04.mjs.map → docker-DsJNWnaX.mjs.map} +1 -1
- package/dist/{dokploy-Cn7dQqmE.cjs → dokploy-CxttPnYP.cjs} +2 -2
- package/dist/{dokploy-Cn7dQqmE.cjs.map → dokploy-CxttPnYP.cjs.map} +1 -1
- package/dist/{dokploy-CTWw3WSo.mjs → dokploy-Dd2mXHgX.mjs} +2 -2
- package/dist/{dokploy-CTWw3WSo.mjs.map → dokploy-Dd2mXHgX.mjs.map} +1 -1
- package/dist/{eas-IPjz0PWK.cjs → eas-B-JskJLP.cjs} +3 -3
- package/dist/{eas-IPjz0PWK.cjs.map → eas-B-JskJLP.cjs.map} +1 -1
- package/dist/{eas-D0B8H7hT.mjs → eas-B_yjP_Sl.mjs} +3 -3
- package/dist/{eas-D0B8H7hT.mjs.map → eas-B_yjP_Sl.mjs.map} +1 -1
- package/dist/{encryption-C9auXcSV.mjs → encryption-dUnvnbu8.mjs} +4 -4
- package/dist/{encryption-C9auXcSV.mjs.map → encryption-dUnvnbu8.mjs.map} +1 -1
- package/dist/{encryption-vK64UP4M.cjs → encryption-yW6cWTsN.cjs} +4 -4
- package/dist/{encryption-vK64UP4M.cjs.map → encryption-yW6cWTsN.cjs.map} +1 -1
- package/dist/{engine-C3N2WhbC.mjs → engine-W1gbyy7T.mjs} +17 -12
- package/dist/engine-W1gbyy7T.mjs.map +1 -0
- package/dist/{engine-Icqv5JI6.cjs → engine-oBwumCI2.cjs} +21 -16
- package/dist/engine-oBwumCI2.cjs.map +1 -0
- package/dist/{github-D24wTOe2.mjs → github-D2-FIlNY.mjs} +8 -9
- package/dist/{github-D24wTOe2.mjs.map → github-D2-FIlNY.mjs.map} +1 -1
- package/dist/{github-DUuNInc0.cjs → github-DLucfS9E.cjs} +9 -10
- package/dist/{github-DUuNInc0.cjs.map → github-DLucfS9E.cjs.map} +1 -1
- package/dist/{googlePlay-BGDKlnPx.cjs → googlePlay-C91kIbBZ.cjs} +5 -5
- package/dist/{googlePlay-BGDKlnPx.cjs.map → googlePlay-C91kIbBZ.cjs.map} +1 -1
- package/dist/{googlePlay-Cy-MaYr2.mjs → googlePlay-CapfGnZ8.mjs} +5 -5
- package/dist/{googlePlay-Cy-MaYr2.mjs.map → googlePlay-CapfGnZ8.mjs.map} +1 -1
- package/dist/{index-C1jffZ5_.d.cts → index-B35vTdAW.d.cts} +2 -2
- package/dist/{index-BZZeEWug.d.mts.map → index-B35vTdAW.d.cts.map} +1 -1
- package/dist/{index-BZZeEWug.d.mts → index-Dv1Zj86i.d.mts} +2 -2
- package/dist/{index-C1jffZ5_.d.cts.map → index-Dv1Zj86i.d.mts.map} +1 -1
- package/dist/index.cjs +99 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +87 -69
- package/dist/index.mjs.map +1 -1
- package/dist/{local-CdpBgn3d.mjs → local-2SR2d_BC.mjs} +2 -2
- package/dist/{local-CdpBgn3d.mjs.map → local-2SR2d_BC.mjs.map} +1 -1
- package/dist/{local-B4xobzh-.cjs → local-l5_-A-zI.cjs} +2 -2
- package/dist/{local-B4xobzh-.cjs.map → local-l5_-A-zI.cjs.map} +1 -1
- package/dist/{migrate--hMBtpx-.cjs → migrate-B05YVukh.cjs} +4 -4
- package/dist/{migrate--hMBtpx-.cjs.map → migrate-B05YVukh.cjs.map} +1 -1
- package/dist/{migrate-DVrXTq58.mjs → migrate-C0ecSkL2.mjs} +4 -4
- package/dist/{migrate-DVrXTq58.mjs.map → migrate-C0ecSkL2.mjs.map} +1 -1
- package/dist/{migrate-DwQ-zaMy.cjs → migrate-DNLNhKNT.cjs} +6 -6
- package/dist/{migrate-DwQ-zaMy.cjs.map → migrate-DNLNhKNT.cjs.map} +1 -1
- package/dist/{migrate-DhZfvCkJ.mjs → migrate-KdqlzELQ.mjs} +6 -6
- package/dist/{migrate-DhZfvCkJ.mjs.map → migrate-KdqlzELQ.mjs.map} +1 -1
- package/dist/{notes-z5OOMqm4.mjs → notes-Cj8jL1kS.mjs} +4 -4
- package/dist/{notes-z5OOMqm4.mjs.map → notes-Cj8jL1kS.mjs.map} +1 -1
- package/dist/{notes-C2b5RzGl.cjs → notes-DTTUGZyi.cjs} +4 -4
- package/dist/{notes-C2b5RzGl.cjs.map → notes-DTTUGZyi.cjs.map} +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/{projectBucket-DPD0_B8N.mjs → projectBucket-6BKUPlDp.mjs} +2 -2
- package/dist/{projectBucket-DPD0_B8N.mjs.map → projectBucket-6BKUPlDp.mjs.map} +1 -1
- package/dist/{projectBucket-Dk_aZ1cD.cjs → projectBucket-CjJB-nom.cjs} +2 -2
- package/dist/{projectBucket-Dk_aZ1cD.cjs.map → projectBucket-CjJB-nom.cjs.map} +1 -1
- package/dist/{publish-CDvh-9OG.cjs → publish-Cj36G3de.cjs} +2 -2
- package/dist/{publish-CDvh-9OG.cjs.map → publish-Cj36G3de.cjs.map} +1 -1
- package/dist/{publish-Bmc1Wfs3.mjs → publish-DRsFN1td.mjs} +2 -2
- package/dist/{publish-Bmc1Wfs3.mjs.map → publish-DRsFN1td.mjs.map} +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-CuxPZ3ga.cjs → resolve-C1NkdIcy.cjs} +4 -4
- package/dist/{resolve-CuxPZ3ga.cjs.map → resolve-C1NkdIcy.cjs.map} +1 -1
- package/dist/{resolve-DHARlMdl.mjs → resolve-DjbMNLt-.mjs} +4 -4
- package/dist/{resolve-DHARlMdl.mjs.map → resolve-DjbMNLt-.mjs.map} +1 -1
- package/dist/{rollback-DxHut8C-.cjs → rollback-531Va3dw.cjs} +7 -7
- package/dist/{rollback-DxHut8C-.cjs.map → rollback-531Va3dw.cjs.map} +1 -1
- package/dist/{rollback-DZq_dIbl.mjs → rollback-D0ZpwlFq.mjs} +7 -7
- package/dist/{rollback-DZq_dIbl.mjs.map → rollback-D0ZpwlFq.mjs.map} +1 -1
- package/dist/{runtime-Bvgyxm88.d.cts → runtime-CFvcLEJW.d.cts} +2 -2
- package/dist/{runtime-Bvgyxm88.d.cts.map → runtime-CFvcLEJW.d.cts.map} +1 -1
- package/dist/{runtime-CeAt1IJd.d.mts → runtime-dwsH6ddo.d.mts} +2 -2
- package/dist/{runtime-CeAt1IJd.d.mts.map → runtime-dwsH6ddo.d.mts.map} +1 -1
- package/dist/{s3-Dhy58V_y.cjs → s3-BSfFgbms.cjs} +3 -3
- package/dist/{s3-Dhy58V_y.cjs.map → s3-BSfFgbms.cjs.map} +1 -1
- package/dist/{s3-Cd7UK2y8.mjs → s3-Ho00alt7.mjs} +3 -3
- package/dist/{s3-Cd7UK2y8.mjs.map → s3-Ho00alt7.mjs.map} +1 -1
- package/dist/{serverSetup-qe5bdBhO.mjs → serverSetup-BW1RgJXo.mjs} +7 -7
- package/dist/{serverSetup-qe5bdBhO.mjs.map → serverSetup-BW1RgJXo.mjs.map} +1 -1
- package/dist/{serverSetup-DYiKHMVp.cjs → serverSetup-C59lCe80.cjs} +7 -7
- package/dist/{serverSetup-DYiKHMVp.cjs.map → serverSetup-C59lCe80.cjs.map} +1 -1
- package/dist/{sniffer-DFix2ORf.cjs → sniffer-BL7X_kzC.cjs} +7 -7
- package/dist/{sniffer-DFix2ORf.cjs.map → sniffer-BL7X_kzC.cjs.map} +1 -1
- package/dist/{sniffer-BNcLP8MO.mjs → sniffer-DrmSlwg9.mjs} +7 -7
- package/dist/{sniffer-BNcLP8MO.mjs.map → sniffer-DrmSlwg9.mjs.map} +1 -1
- package/dist/{snsSubscriptions-Dr-gJWtR.cjs → snsSubscriptions-B8nZBBEE.cjs} +3 -3
- package/dist/{snsSubscriptions-Dr-gJWtR.cjs.map → snsSubscriptions-B8nZBBEE.cjs.map} +1 -1
- package/dist/{snsSubscriptions-BwX28_Kl.mjs → snsSubscriptions-DF7YGauz.mjs} +3 -3
- package/dist/{snsSubscriptions-BwX28_Kl.mjs.map → snsSubscriptions-DF7YGauz.mjs.map} +1 -1
- package/dist/{sst-Bvtx6uZ9.mjs → sst-C-RSpWC2.mjs} +5 -5
- package/dist/{sst-Bvtx6uZ9.mjs.map → sst-C-RSpWC2.mjs.map} +1 -1
- package/dist/{sst-CoKFPW7f.cjs → sst-Dvko43Y3.cjs} +5 -5
- package/dist/{sst-CoKFPW7f.cjs.map → sst-Dvko43Y3.cjs.map} +1 -1
- package/dist/{stack-BeSbt_7k.mjs → stack-CVzOFHed.mjs} +70 -387
- package/dist/stack-CVzOFHed.mjs.map +1 -0
- package/dist/{stack-DbaKGKnI.cjs → stack-l_eQ63Gl.cjs} +73 -462
- package/dist/stack-l_eQ63Gl.cjs.map +1 -0
- package/dist/{stage-BblkSR2C.mjs → stage-JMlDwobz.mjs} +18 -15
- package/dist/stage-JMlDwobz.mjs.map +1 -0
- package/dist/{stage-DI5mzoAi.cjs → stage-_vzQ82Gz.cjs} +19 -16
- package/dist/stage-_vzQ82Gz.cjs.map +1 -0
- package/dist/{stages-C-bVwvJZ.cjs → stages-Bs1THSy7.cjs} +3 -3
- package/dist/{stages-C-bVwvJZ.cjs.map → stages-Bs1THSy7.cjs.map} +1 -1
- package/dist/{stages-DBsDvEbo.mjs → stages-_xCG4Ymu.mjs} +3 -3
- package/dist/{stages-DBsDvEbo.mjs.map → stages-_xCG4Ymu.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-DDqusYW0.mjs → terminal-BnKPi06T.mjs} +2 -2
- package/dist/{terminal-DDqusYW0.mjs.map → terminal-BnKPi06T.mjs.map} +1 -1
- package/dist/{terminal-Bxy_A8iP.cjs → terminal-CdPFlCS_.cjs} +2 -2
- package/dist/{terminal-Bxy_A8iP.cjs.map → terminal-CdPFlCS_.cjs.map} +1 -1
- package/dist/{types-Dy1eV7yc.d.cts → types-Dk--xVOT.d.cts} +31 -11
- package/dist/{types-Dy1eV7yc.d.cts.map → types-Dk--xVOT.d.cts.map} +1 -1
- package/dist/{types-C6hDCkV2.d.mts → types-DwQYpd_0.d.mts} +31 -11
- package/dist/{types-C6hDCkV2.d.mts.map → types-DwQYpd_0.d.mts.map} +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-BbbkJDUU.cjs → workspace-1szcahj9.cjs} +19 -27
- package/dist/workspace-1szcahj9.cjs.map +1 -0
- package/dist/{workspace-CZGJdcTs.mjs → workspace-DFGsrjGD.mjs} +19 -27
- package/dist/workspace-DFGsrjGD.mjs.map +1 -0
- package/package.json +15 -15
- package/dist/apps-DHi6E_yH.cjs.map +0 -1
- package/dist/apps-DWALM-8s.mjs.map +0 -1
- package/dist/compose-BeQ01iYk.cjs.map +0 -1
- package/dist/compose-DxmEMeTu.mjs.map +0 -1
- package/dist/credentials-B5Oe4fLE.mjs.map +0 -1
- package/dist/credentials-Csnd7M8M.cjs.map +0 -1
- package/dist/engine-C3N2WhbC.mjs.map +0 -1
- package/dist/engine-Icqv5JI6.cjs.map +0 -1
- package/dist/stack-BeSbt_7k.mjs.map +0 -1
- package/dist/stack-DbaKGKnI.cjs.map +0 -1
- package/dist/stage-BblkSR2C.mjs.map +0 -1
- package/dist/stage-DI5mzoAi.cjs.map +0 -1
- package/dist/workspace-BbbkJDUU.cjs.map +0 -1
- package/dist/workspace-CZGJdcTs.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as bundleExternals, R as externalsManifestName, z as importedPackages } from "./credentials-FRF4PZYo.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -97,10 +97,10 @@ async function bundleServer(options) {
|
|
|
97
97
|
for (const ext of Object.keys(candidates)) args.push(`--external:${ext}`);
|
|
98
98
|
let masterKey;
|
|
99
99
|
if (stage) {
|
|
100
|
-
const { toEmbeddableSecrets, validateEnvironmentVariables, initStageSecrets } = await import("./credentials-
|
|
101
|
-
const { FileSecretsStore, secretsStoreFor } = await import("./credentials-
|
|
100
|
+
const { toEmbeddableSecrets, validateEnvironmentVariables, initStageSecrets } = await import("./credentials-FRF4PZYo.mjs").then((n) => n.P);
|
|
101
|
+
const { FileSecretsStore, secretsStoreFor } = await import("./credentials-FRF4PZYo.mjs").then((n) => n.j);
|
|
102
102
|
const { ConfigNotFound, loadWorkspaceSettings } = await import("./config.mjs");
|
|
103
|
-
const { encryptSecrets, generateDefineOptions } = await import("./sniffer-
|
|
103
|
+
const { encryptSecrets, generateDefineOptions } = await import("./sniffer-DrmSlwg9.mjs").then((n) => n.O);
|
|
104
104
|
const store = await loadWorkspaceSettings().then((workspace) => secretsStoreFor(workspace, stage), (error) => {
|
|
105
105
|
if (error instanceof ConfigNotFound) return new FileSecretsStore(process.cwd());
|
|
106
106
|
throw error;
|
|
@@ -148,7 +148,7 @@ async function bundleServer(options) {
|
|
|
148
148
|
const encryptedPath = join(gkmDir, "credentials.enc");
|
|
149
149
|
const ivPath = join(gkmDir, "credentials.iv");
|
|
150
150
|
if (existsSync(encryptedPath) && existsSync(ivPath)) {
|
|
151
|
-
const { generateDefineOptions } = await import("./sniffer-
|
|
151
|
+
const { generateDefineOptions } = await import("./sniffer-DrmSlwg9.mjs").then((n) => n.O);
|
|
152
152
|
const defines = generateDefineOptions({
|
|
153
153
|
encrypted: readFileSync(encryptedPath, "utf-8").trim(),
|
|
154
154
|
iv: readFileSync(ivPath, "utf-8").trim(),
|
|
@@ -190,4 +190,4 @@ async function bundleServer(options) {
|
|
|
190
190
|
//#endregion
|
|
191
191
|
export { bundleServer };
|
|
192
192
|
|
|
193
|
-
//# sourceMappingURL=bundler-
|
|
193
|
+
//# sourceMappingURL=bundler-D6IEJvq4.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler-Cb5ynXXS.mjs","names":[],"sources":["../src/build/bundler.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport type { Construct } from '@geekmidas/constructs';\nimport {\n\tbundleExternals,\n\texternalsManifestName,\n\timportedPackages,\n} from './native';\n\n/**\n * Banner to inject into ESM bundle for CJS compatibility.\n * Creates a `require` function using Node's createRequire for packages\n * that internally use CommonJS require() for Node builtins.\n */\nconst ESM_CJS_COMPAT_BANNER =\n\t'import { createRequire } from \"module\"; const require = createRequire(import.meta.url);';\n\nexport interface BundleOptions {\n\t/** Entry point file (e.g., .gkm/server/server.ts) */\n\tentryPoint: string;\n\t/** Output directory for bundled files */\n\toutputDir: string;\n\t/** The bundle's file name in `outputDir`. Defaults to `server.mjs`. */\n\toutfile?: string;\n\t/** Minify the output (default: true) */\n\tminify: boolean;\n\t/** Generate sourcemaps (default: false) */\n\tsourcemap: boolean;\n\t/**\n\t * Packages to leave out of the bundle besides its native ones, which are\n\t * always left out and recorded beside it — see `externalsManifestName`.\n\t */\n\texternal: string[];\n\t/** Stage for secrets injection (optional) */\n\tstage?: string;\n\t/** Constructs to validate environment variables for */\n\tconstructs?: Construct[];\n}\n\nexport interface BundleResult {\n\t/** Path to the bundled output */\n\toutputPath: string;\n\t/** Ephemeral master key for deployment (only if stage was provided) */\n\tmasterKey?: string;\n\t/** What the bundle left out, at the version to install beside it. */\n\texternals: Record<string, string>;\n}\n\n/** The app a bundle is built for: the nearest `package.json` above its entry. */\nfunction appRootOf(entryPoint: string): string {\n\tlet dir = dirname(entryPoint);\n\twhile (!existsSync(join(dir, 'package.json'))) {\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return dirname(entryPoint);\n\t\tdir = parent;\n\t}\n\treturn dir;\n}\n\n/**\n * The esbuild binary, resolved from this package rather than from PATH.\n *\n * It used to be `npx esbuild`, which is two assumptions: that esbuild is\n * installed somewhere npx can find, and that the *app's* directory is where to\n * look. Neither holds — the CLI did not depend on esbuild at all, so a deploy\n * run from an app that had not installed it failed at the bundle step with\n * `sh: esbuild: command not found`, after provisioning had already happened.\n *\n * The same fix `bin/gkm.mjs` makes for tsx: resolve from this package's own\n * `node_modules`, so the tool the CLI shells out to is the one it depends on.\n */\nfunction esbuildBinary(): string {\n\tconst require = createRequire(import.meta.url);\n\n\ttry {\n\t\t// The package root, then its bin — `require.resolve('esbuild')` gives the\n\t\t// JS entry point, which is a library rather than the CLI.\n\t\tconst pkg = require.resolve('esbuild/package.json');\n\t\treturn join(dirname(pkg), 'bin', 'esbuild');\n\t} catch {\n\t\t// Better a PATH lookup than a hard failure: a project that installed\n\t\t// esbuild itself still works.\n\t\treturn 'esbuild';\n\t}\n}\n\n/**\n * Collect the environment variables a build cannot proceed without.\n *\n * Uses the SnifferEnvironmentParser to detect which env vars each service\n * reads, and keeps only the ones it cannot do without. `markOptional` is what\n * separates them: the sniffer already knows which reads went through\n * `.optional()` or `.default()`, and asking for that distinction is the\n * difference between a build that stops and one that proceeds correctly.\n *\n * Without it, a key that is *absent by design* failed the build. A surface\n * publishes `AUTH_COOKIE_DOMAIN` only when there is a domain to widen a cookie\n * to — one host has nothing to share it with, so the derivation correctly\n * yields nothing, and Better Auth reads it as optional for exactly that\n * reason. Treating every sniffed read as required made the honest answer\n * indistinguishable from a missing secret.\n *\n * @param constructs - Array of constructs to analyze\n * @returns Deduplicated, sorted names of the required variables\n */\nasync function collectRequiredEnvVars(\n\tconstructs: Construct[],\n): Promise<string[]> {\n\t// A key read optionally by one construct and required by another stays\n\t// required: the strictest read is the one that fails at runtime, and taking\n\t// the union of the required reads is what says so.\n\tconst required = new Set<string>();\n\n\tfor (const construct of constructs) {\n\t\tfor (const name of await construct.getEnvironment({ markOptional: true })) {\n\t\t\tif (!name.endsWith('?')) required.add(name);\n\t\t}\n\t}\n\n\treturn Array.from(required).sort();\n}\n\n/**\n * Bundle the server application using esbuild.\n * Creates a fully standalone bundle with all dependencies included.\n *\n * @param options - Bundle configuration options\n * @returns Bundle result with output path and optional master key\n */\n\nexport async function bundleServer(\n\toptions: BundleOptions,\n): Promise<BundleResult> {\n\tconst {\n\t\tentryPoint,\n\t\toutputDir,\n\t\tminify,\n\t\tsourcemap,\n\t\texternal,\n\t\tstage,\n\t\tconstructs,\n\t} = options;\n\n\t// Ensure output directory exists\n\tawait mkdir(outputDir, { recursive: true });\n\n\tconst outfile = options.outfile ?? 'server.mjs';\n\tconst mjsOutput = join(outputDir, outfile);\n\n\t// A package with native code loads a binary from beside its own source,\n\t// built for the platform it was installed on: inlined, it finds neither.\n\t// Every one the app could reach stays out of the bundle, and the ones the\n\t// bundle imports are installed for the image's platform at this version.\n\tconst candidates = bundleExternals(appRootOf(entryPoint), external);\n\tconst metafile = join(outputDir, `.${outfile}.meta.json`);\n\n\t// Build command-line arguments for esbuild\n\tconst args = [\n\t\tesbuildBinary(),\n\t\tentryPoint,\n\t\t'--bundle',\n\t\t'--platform=node',\n\t\t'--target=node22',\n\t\t'--format=esm',\n\t\t`--outfile=${mjsOutput}`,\n\t\t'--packages=bundle', // Bundle all dependencies for standalone output\n\t\t`--banner:js=${ESM_CJS_COMPAT_BANNER}`, // CJS compatibility for packages like pino\n\t\t`--metafile=${metafile}`,\n\t];\n\n\tif (minify) {\n\t\t// Names kept: an error's class name is what a log line's `err.type` and\n\t\t// a response's `name` say, and minified they read `_6`.\n\t\targs.push('--minify', '--keep-names');\n\t}\n\n\tif (sourcemap) {\n\t\targs.push('--sourcemap');\n\t}\n\n\tfor (const ext of Object.keys(candidates)) {\n\t\targs.push(`--external:${ext}`);\n\t}\n\n\t// Handle secrets injection if stage is provided\n\tlet masterKey: string | undefined;\n\n\tif (stage) {\n\t\tconst {\n\t\t\ttoEmbeddableSecrets,\n\t\t\tvalidateEnvironmentVariables,\n\t\t\tinitStageSecrets,\n\t\t} = await import('../secrets/storage');\n\t\tconst { FileSecretsStore, secretsStoreFor } = await import(\n\t\t\t'../secrets/store'\n\t\t);\n\t\tconst { ConfigNotFound, loadWorkspaceSettings } = await import('../config');\n\t\tconst { encryptSecrets, generateDefineOptions } = await import(\n\t\t\t'../secrets/encryption'\n\t\t);\n\n\t\t// The stage's own store — SSM or Secrets Manager for a deployed stage\n\t\t// kept there. Outside\n\t\t// any workspace nothing names one, so it is the file.\n\t\tconst store = await loadWorkspaceSettings().then(\n\t\t\t(workspace) => secretsStoreFor(workspace, stage),\n\t\t\t(error) => {\n\t\t\t\tif (error instanceof ConfigNotFound) {\n\t\t\t\t\treturn new FileSecretsStore(process.cwd());\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tlet secrets = await store.read(stage);\n\n\t\tif (!secrets) {\n\t\t\t// Auto-initialize secrets for the stage\n\t\t\tconsole.log(` Initializing secrets for stage \"${stage}\"...`);\n\t\t\tsecrets = initStageSecrets(stage);\n\t\t\tawait store.write(stage, secrets);\n\t\t\tconsole.log(` ✓ Created the \"${stage}\" secrets (${store.name})`);\n\t\t}\n\n\t\t// Validate environment variables if constructs are provided\n\t\tif (constructs && constructs.length > 0) {\n\t\t\tconsole.log(' Analyzing environment variable requirements...');\n\t\t\tconst requiredVars = await collectRequiredEnvVars(constructs);\n\n\t\t\tif (requiredVars.length > 0) {\n\t\t\t\tconst validation = validateEnvironmentVariables(requiredVars, secrets);\n\n\t\t\t\tif (!validation.valid) {\n\t\t\t\t\tconst errorMessage = [\n\t\t\t\t\t\t`Missing environment variables for stage \"${stage}\":`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t...validation.missing.map((v) => ` ❌ ${v}`),\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'To fix this, either:',\n\t\t\t\t\t\t` 1. Add the missing variables to the \"${stage}\" secrets using:`,\n\t\t\t\t\t\t` gkm secrets:set <KEY> <VALUE> --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t` 2. Or import from a JSON file:`,\n\t\t\t\t\t\t` gkm secrets:import secrets.json --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'Required variables:',\n\t\t\t\t\t\t...validation.required.map((v) =>\n\t\t\t\t\t\t\tvalidation.missing.includes(v) ? ` ❌ ${v}` : ` ✓ ${v}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t].join('\\n');\n\n\t\t\t\t\tthrow new Error(errorMessage);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t` ✓ All ${requiredVars.length} required environment variables found`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Convert to embeddable format and encrypt\n\t\tconst embeddable = toEmbeddableSecrets(secrets);\n\t\tconst encrypted = encryptSecrets(embeddable);\n\t\tmasterKey = encrypted.masterKey;\n\n\t\t// Add define options for build-time injection using esbuild's --define:KEY=VALUE format\n\t\tconst defines = generateDefineOptions(encrypted);\n\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t// `value` is already a JS string literal; quoting it again would\n\t\t\t// embed the quotes, and the IV would not parse as hex.\n\t\t\targs.push(`--define:${key}=${value}`);\n\t\t}\n\n\t\tconsole.log(` Secrets encrypted for stage \"${stage}\"`);\n\t} else {\n\t\t// Credentials encrypted elsewhere — an image build hands them in as a\n\t\t// BuildKit secret and writes them beside the app's `.gkm/server` — are\n\t\t// embedded as they are; whoever encrypted them holds the key.\n\t\tconst gkmDir = join(outputDir, '..', '..');\n\t\tconst encryptedPath = join(gkmDir, 'credentials.enc');\n\t\tconst ivPath = join(gkmDir, 'credentials.iv');\n\t\tif (existsSync(encryptedPath) && existsSync(ivPath)) {\n\t\t\tconst { generateDefineOptions } = await import('../secrets/encryption');\n\t\t\tconst defines = generateDefineOptions({\n\t\t\t\tencrypted: readFileSync(encryptedPath, 'utf-8').trim(),\n\t\t\t\tiv: readFileSync(ivPath, 'utf-8').trim(),\n\t\t\t\tmasterKey: '',\n\t\t\t});\n\t\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t\targs.push(`--define:${key}=${value}`);\n\t\t\t}\n\t\t\tconsole.log(' Embedded the encrypted credentials the build was given');\n\t\t}\n\t}\n\n\ttry {\n\t\t// Run esbuild with command-line arguments\n\t\tconst [cmd, ...cmdArgs] = args as [string, ...string[]];\n\t\tconst result = spawnSync(cmd, cmdArgs, {\n\t\t\tcwd: process.cwd(),\n\t\t\tstdio: 'inherit',\n\t\t\tshell: process.platform === 'win32', // Only use shell on Windows for npx resolution\n\t\t});\n\n\t\tif (result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\t\tif (result.status !== 0) {\n\t\t\tthrow new Error(`esbuild exited with code ${result.status}`);\n\t\t}\n\n\t\t// Add shebang to the bundled file\n\t\tconst { readFile } = await import('node:fs/promises');\n\t\tconst content = await readFile(mjsOutput, 'utf-8');\n\t\tif (!content.startsWith('#!')) {\n\t\t\tawait writeFile(mjsOutput, `#!/usr/bin/env node\\n${content}`);\n\t\t}\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to bundle server: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t);\n\t}\n\n\t// Declared ones always; a native package only where the bundle imports it\n\t// — an app that depends on `@geekmidas/cli` reaches esbuild, and never\n\t// runs it.\n\tconst imported = importedPackages(metafile);\n\tawait rm(metafile, { force: true });\n\tconst externals = Object.fromEntries(\n\t\tObject.entries(candidates).filter(\n\t\t\t([name]) => external.includes(name) || imported.has(name),\n\t\t),\n\t);\n\tawait writeFile(\n\t\tjoin(outputDir, externalsManifestName(outfile)),\n\t\t`${JSON.stringify({ private: true, dependencies: externals }, null, 2)}\\n`,\n\t);\n\tif (Object.keys(externals).length > 0) {\n\t\tconsole.log(\n\t\t\t` Left out of the bundle, installed beside it: ${Object.keys(externals).join(', ')}`,\n\t\t);\n\t}\n\n\treturn {\n\t\toutputPath: mjsOutput,\n\t\tmasterKey,\n\t\texternals,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,wBACL;;AAkCD,SAAS,UAAU,YAA4B;CAC9C,IAAI,MAAM,QAAQ,UAAU;CAC5B,OAAO,CAAC,WAAW,KAAK,KAAK,cAAc,CAAC,GAAG;EAC9C,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO,QAAQ,UAAU;EAC7C,MAAM;CACP;CACA,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAS,gBAAwB;CAChC,MAAM,UAAU,cAAc,YAAY,GAAG;CAE7C,IAAI;EAGH,MAAM,MAAM,QAAQ,QAAQ,sBAAsB;EAClD,OAAO,KAAK,QAAQ,GAAG,GAAG,OAAO,SAAS;CAC3C,QAAQ;EAGP,OAAO;CACR;AACD;;;;;;;;;;;;;;;;;;;;AAqBA,eAAe,uBACd,YACoB;CAIpB,MAAM,2BAAW,IAAI,IAAY;CAEjC,KAAK,MAAM,aAAa,YACvB,KAAK,MAAM,QAAQ,MAA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O,KAAK,SAAS,CAAC,CAAC,SAAS,GACnC,QAAQ,IACP,kDAAkD,OAAO,KAAK,SAAS,CAAC,CAAC,KAAK,IAAI,GACnF;CAGD,OAAO;EACN,YAAY;EACZ;EACA;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"bundler-D6IEJvq4.mjs","names":[],"sources":["../src/build/bundler.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport type { Construct } from '@geekmidas/constructs';\nimport {\n\tbundleExternals,\n\texternalsManifestName,\n\timportedPackages,\n} from './native';\n\n/**\n * Banner to inject into ESM bundle for CJS compatibility.\n * Creates a `require` function using Node's createRequire for packages\n * that internally use CommonJS require() for Node builtins.\n */\nconst ESM_CJS_COMPAT_BANNER =\n\t'import { createRequire } from \"module\"; const require = createRequire(import.meta.url);';\n\nexport interface BundleOptions {\n\t/** Entry point file (e.g., .gkm/server/server.ts) */\n\tentryPoint: string;\n\t/** Output directory for bundled files */\n\toutputDir: string;\n\t/** The bundle's file name in `outputDir`. Defaults to `server.mjs`. */\n\toutfile?: string;\n\t/** Minify the output (default: true) */\n\tminify: boolean;\n\t/** Generate sourcemaps (default: false) */\n\tsourcemap: boolean;\n\t/**\n\t * Packages to leave out of the bundle besides its native ones, which are\n\t * always left out and recorded beside it — see `externalsManifestName`.\n\t */\n\texternal: string[];\n\t/** Stage for secrets injection (optional) */\n\tstage?: string;\n\t/** Constructs to validate environment variables for */\n\tconstructs?: Construct[];\n}\n\nexport interface BundleResult {\n\t/** Path to the bundled output */\n\toutputPath: string;\n\t/** Ephemeral master key for deployment (only if stage was provided) */\n\tmasterKey?: string;\n\t/** What the bundle left out, at the version to install beside it. */\n\texternals: Record<string, string>;\n}\n\n/** The app a bundle is built for: the nearest `package.json` above its entry. */\nfunction appRootOf(entryPoint: string): string {\n\tlet dir = dirname(entryPoint);\n\twhile (!existsSync(join(dir, 'package.json'))) {\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return dirname(entryPoint);\n\t\tdir = parent;\n\t}\n\treturn dir;\n}\n\n/**\n * The esbuild binary, resolved from this package rather than from PATH.\n *\n * It used to be `npx esbuild`, which is two assumptions: that esbuild is\n * installed somewhere npx can find, and that the *app's* directory is where to\n * look. Neither holds — the CLI did not depend on esbuild at all, so a deploy\n * run from an app that had not installed it failed at the bundle step with\n * `sh: esbuild: command not found`, after provisioning had already happened.\n *\n * The same fix `bin/gkm.mjs` makes for tsx: resolve from this package's own\n * `node_modules`, so the tool the CLI shells out to is the one it depends on.\n */\nfunction esbuildBinary(): string {\n\tconst require = createRequire(import.meta.url);\n\n\ttry {\n\t\t// The package root, then its bin — `require.resolve('esbuild')` gives the\n\t\t// JS entry point, which is a library rather than the CLI.\n\t\tconst pkg = require.resolve('esbuild/package.json');\n\t\treturn join(dirname(pkg), 'bin', 'esbuild');\n\t} catch {\n\t\t// Better a PATH lookup than a hard failure: a project that installed\n\t\t// esbuild itself still works.\n\t\treturn 'esbuild';\n\t}\n}\n\n/**\n * Collect the environment variables a build cannot proceed without.\n *\n * Uses the SnifferEnvironmentParser to detect which env vars each service\n * reads, and keeps only the ones it cannot do without. `markOptional` is what\n * separates them: the sniffer already knows which reads went through\n * `.optional()` or `.default()`, and asking for that distinction is the\n * difference between a build that stops and one that proceeds correctly.\n *\n * Without it, a key that is *absent by design* failed the build. A surface\n * publishes `AUTH_COOKIE_DOMAIN` only when there is a domain to widen a cookie\n * to — one host has nothing to share it with, so the derivation correctly\n * yields nothing, and Better Auth reads it as optional for exactly that\n * reason. Treating every sniffed read as required made the honest answer\n * indistinguishable from a missing secret.\n *\n * @param constructs - Array of constructs to analyze\n * @returns Deduplicated, sorted names of the required variables\n */\nasync function collectRequiredEnvVars(\n\tconstructs: Construct[],\n): Promise<string[]> {\n\t// A key read optionally by one construct and required by another stays\n\t// required: the strictest read is the one that fails at runtime, and taking\n\t// the union of the required reads is what says so.\n\tconst required = new Set<string>();\n\n\tfor (const construct of constructs) {\n\t\tfor (const name of await construct.getEnvironment({ markOptional: true })) {\n\t\t\tif (!name.endsWith('?')) required.add(name);\n\t\t}\n\t}\n\n\treturn Array.from(required).sort();\n}\n\n/**\n * Bundle the server application using esbuild.\n * Creates a fully standalone bundle with all dependencies included.\n *\n * @param options - Bundle configuration options\n * @returns Bundle result with output path and optional master key\n */\n\nexport async function bundleServer(\n\toptions: BundleOptions,\n): Promise<BundleResult> {\n\tconst {\n\t\tentryPoint,\n\t\toutputDir,\n\t\tminify,\n\t\tsourcemap,\n\t\texternal,\n\t\tstage,\n\t\tconstructs,\n\t} = options;\n\n\t// Ensure output directory exists\n\tawait mkdir(outputDir, { recursive: true });\n\n\tconst outfile = options.outfile ?? 'server.mjs';\n\tconst mjsOutput = join(outputDir, outfile);\n\n\t// A package with native code loads a binary from beside its own source,\n\t// built for the platform it was installed on: inlined, it finds neither.\n\t// Every one the app could reach stays out of the bundle, and the ones the\n\t// bundle imports are installed for the image's platform at this version.\n\tconst candidates = bundleExternals(appRootOf(entryPoint), external);\n\tconst metafile = join(outputDir, `.${outfile}.meta.json`);\n\n\t// Build command-line arguments for esbuild\n\tconst args = [\n\t\tesbuildBinary(),\n\t\tentryPoint,\n\t\t'--bundle',\n\t\t'--platform=node',\n\t\t'--target=node22',\n\t\t'--format=esm',\n\t\t`--outfile=${mjsOutput}`,\n\t\t'--packages=bundle', // Bundle all dependencies for standalone output\n\t\t`--banner:js=${ESM_CJS_COMPAT_BANNER}`, // CJS compatibility for packages like pino\n\t\t`--metafile=${metafile}`,\n\t];\n\n\tif (minify) {\n\t\t// Names kept: an error's class name is what a log line's `err.type` and\n\t\t// a response's `name` say, and minified they read `_6`.\n\t\targs.push('--minify', '--keep-names');\n\t}\n\n\tif (sourcemap) {\n\t\targs.push('--sourcemap');\n\t}\n\n\tfor (const ext of Object.keys(candidates)) {\n\t\targs.push(`--external:${ext}`);\n\t}\n\n\t// Handle secrets injection if stage is provided\n\tlet masterKey: string | undefined;\n\n\tif (stage) {\n\t\tconst {\n\t\t\ttoEmbeddableSecrets,\n\t\t\tvalidateEnvironmentVariables,\n\t\t\tinitStageSecrets,\n\t\t} = await import('../secrets/storage');\n\t\tconst { FileSecretsStore, secretsStoreFor } = await import(\n\t\t\t'../secrets/store'\n\t\t);\n\t\tconst { ConfigNotFound, loadWorkspaceSettings } = await import('../config');\n\t\tconst { encryptSecrets, generateDefineOptions } = await import(\n\t\t\t'../secrets/encryption'\n\t\t);\n\n\t\t// The stage's own store — SSM or Secrets Manager for a deployed stage\n\t\t// kept there. Outside\n\t\t// any workspace nothing names one, so it is the file.\n\t\tconst store = await loadWorkspaceSettings().then(\n\t\t\t(workspace) => secretsStoreFor(workspace, stage),\n\t\t\t(error) => {\n\t\t\t\tif (error instanceof ConfigNotFound) {\n\t\t\t\t\treturn new FileSecretsStore(process.cwd());\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tlet secrets = await store.read(stage);\n\n\t\tif (!secrets) {\n\t\t\t// Auto-initialize secrets for the stage\n\t\t\tconsole.log(` Initializing secrets for stage \"${stage}\"...`);\n\t\t\tsecrets = initStageSecrets(stage);\n\t\t\tawait store.write(stage, secrets);\n\t\t\tconsole.log(` ✓ Created the \"${stage}\" secrets (${store.name})`);\n\t\t}\n\n\t\t// Validate environment variables if constructs are provided\n\t\tif (constructs && constructs.length > 0) {\n\t\t\tconsole.log(' Analyzing environment variable requirements...');\n\t\t\tconst requiredVars = await collectRequiredEnvVars(constructs);\n\n\t\t\tif (requiredVars.length > 0) {\n\t\t\t\tconst validation = validateEnvironmentVariables(requiredVars, secrets);\n\n\t\t\t\tif (!validation.valid) {\n\t\t\t\t\tconst errorMessage = [\n\t\t\t\t\t\t`Missing environment variables for stage \"${stage}\":`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t...validation.missing.map((v) => ` ❌ ${v}`),\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'To fix this, either:',\n\t\t\t\t\t\t` 1. Add the missing variables to the \"${stage}\" secrets using:`,\n\t\t\t\t\t\t` gkm secrets:set <KEY> <VALUE> --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t` 2. Or import from a JSON file:`,\n\t\t\t\t\t\t` gkm secrets:import secrets.json --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'Required variables:',\n\t\t\t\t\t\t...validation.required.map((v) =>\n\t\t\t\t\t\t\tvalidation.missing.includes(v) ? ` ❌ ${v}` : ` ✓ ${v}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t].join('\\n');\n\n\t\t\t\t\tthrow new Error(errorMessage);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t` ✓ All ${requiredVars.length} required environment variables found`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Convert to embeddable format and encrypt\n\t\tconst embeddable = toEmbeddableSecrets(secrets);\n\t\tconst encrypted = encryptSecrets(embeddable);\n\t\tmasterKey = encrypted.masterKey;\n\n\t\t// Add define options for build-time injection using esbuild's --define:KEY=VALUE format\n\t\tconst defines = generateDefineOptions(encrypted);\n\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t// `value` is already a JS string literal; quoting it again would\n\t\t\t// embed the quotes, and the IV would not parse as hex.\n\t\t\targs.push(`--define:${key}=${value}`);\n\t\t}\n\n\t\tconsole.log(` Secrets encrypted for stage \"${stage}\"`);\n\t} else {\n\t\t// Credentials encrypted elsewhere — an image build hands them in as a\n\t\t// BuildKit secret and writes them beside the app's `.gkm/server` — are\n\t\t// embedded as they are; whoever encrypted them holds the key.\n\t\tconst gkmDir = join(outputDir, '..', '..');\n\t\tconst encryptedPath = join(gkmDir, 'credentials.enc');\n\t\tconst ivPath = join(gkmDir, 'credentials.iv');\n\t\tif (existsSync(encryptedPath) && existsSync(ivPath)) {\n\t\t\tconst { generateDefineOptions } = await import('../secrets/encryption');\n\t\t\tconst defines = generateDefineOptions({\n\t\t\t\tencrypted: readFileSync(encryptedPath, 'utf-8').trim(),\n\t\t\t\tiv: readFileSync(ivPath, 'utf-8').trim(),\n\t\t\t\tmasterKey: '',\n\t\t\t});\n\t\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t\targs.push(`--define:${key}=${value}`);\n\t\t\t}\n\t\t\tconsole.log(' Embedded the encrypted credentials the build was given');\n\t\t}\n\t}\n\n\ttry {\n\t\t// Run esbuild with command-line arguments\n\t\tconst [cmd, ...cmdArgs] = args as [string, ...string[]];\n\t\tconst result = spawnSync(cmd, cmdArgs, {\n\t\t\tcwd: process.cwd(),\n\t\t\tstdio: 'inherit',\n\t\t\tshell: process.platform === 'win32', // Only use shell on Windows for npx resolution\n\t\t});\n\n\t\tif (result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\t\tif (result.status !== 0) {\n\t\t\tthrow new Error(`esbuild exited with code ${result.status}`);\n\t\t}\n\n\t\t// Add shebang to the bundled file\n\t\tconst { readFile } = await import('node:fs/promises');\n\t\tconst content = await readFile(mjsOutput, 'utf-8');\n\t\tif (!content.startsWith('#!')) {\n\t\t\tawait writeFile(mjsOutput, `#!/usr/bin/env node\\n${content}`);\n\t\t}\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to bundle server: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t);\n\t}\n\n\t// Declared ones always; a native package only where the bundle imports it\n\t// — an app that depends on `@geekmidas/cli` reaches esbuild, and never\n\t// runs it.\n\tconst imported = importedPackages(metafile);\n\tawait rm(metafile, { force: true });\n\tconst externals = Object.fromEntries(\n\t\tObject.entries(candidates).filter(\n\t\t\t([name]) => external.includes(name) || imported.has(name),\n\t\t),\n\t);\n\tawait writeFile(\n\t\tjoin(outputDir, externalsManifestName(outfile)),\n\t\t`${JSON.stringify({ private: true, dependencies: externals }, null, 2)}\\n`,\n\t);\n\tif (Object.keys(externals).length > 0) {\n\t\tconsole.log(\n\t\t\t` Left out of the bundle, installed beside it: ${Object.keys(externals).join(', ')}`,\n\t\t);\n\t}\n\n\treturn {\n\t\toutputPath: mjsOutput,\n\t\tmasterKey,\n\t\texternals,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,wBACL;;AAkCD,SAAS,UAAU,YAA4B;CAC9C,IAAI,MAAM,QAAQ,UAAU;CAC5B,OAAO,CAAC,WAAW,KAAK,KAAK,cAAc,CAAC,GAAG;EAC9C,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO,QAAQ,UAAU;EAC7C,MAAM;CACP;CACA,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAS,gBAAwB;CAChC,MAAM,UAAU,cAAc,YAAY,GAAG;CAE7C,IAAI;EAGH,MAAM,MAAM,QAAQ,QAAQ,sBAAsB;EAClD,OAAO,KAAK,QAAQ,GAAG,GAAG,OAAO,SAAS;CAC3C,QAAQ;EAGP,OAAO;CACR;AACD;;;;;;;;;;;;;;;;;;;;AAqBA,eAAe,uBACd,YACoB;CAIpB,MAAM,2BAAW,IAAI,IAAY;CAEjC,KAAK,MAAM,aAAa,YACvB,KAAK,MAAM,QAAQ,MAAM,UAAU,eAAe,EAAE,cAAc,KAAK,CAAC,GACvE,IAAI,CAAC,KAAK,SAAS,GAAG,GAAG,SAAS,IAAI,IAAI;CAI5C,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,KAAK;AAClC;;;;;;;;AAUA,eAAsB,aACrB,SACwB;CACxB,MAAM,EACL,YACA,WACA,QACA,WACA,UACA,OACA,eACG;CAGJ,MAAM,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;CAE1C,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,YAAY,KAAK,WAAW,OAAO;CAMzC,MAAM,aAAa,gBAAgB,UAAU,UAAU,GAAG,QAAQ;CAClE,MAAM,WAAW,KAAK,WAAW,IAAI,QAAQ,WAAW;CAGxD,MAAM,OAA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OAAO;GACP,OAAO,QAAQ,aAAa;EAC7B,CAAC;EAED,IAAI,OAAO,OACV,MAAM,OAAO;EAEd,IAAI,OAAO,WAAW,GACrB,MAAM,IAAI,MAAM,4BAA4B,OAAO,QAAQ;EAI5D,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,UAAU,MAAM,SAAS,WAAW,OAAO;EACjD,IAAI,CAAC,QAAQ,WAAW,IAAI,GAC3B,MAAM,UAAU,WAAW,wBAAwB,SAAS;CAE9D,SAAS,OAAO;EACf,MAAM,IAAI,MACT,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,iBACtE;CACD;CAKA,MAAM,WAAW,iBAAiB,QAAQ;CAC1C,MAAM,GAAG,UAAU,EAAE,OAAO,KAAK,CAAC;CAClC,MAAM,YAAY,OAAO,YACxB,OAAO,QAAQ,UAAU,CAAC,CAAC,QACzB,CAAC,UAAU,SAAS,SAAS,IAAI,KAAK,SAAS,IAAI,IAAI,CACzD,CACD;CACA,MAAM,UACL,KAAK,WAAW,sBAAsB,OAAO,CAAC,GAC9C,GAAG,KAAK,UAAU;EAAE,SAAS;EAAM,cAAc;CAAU,GAAG,MAAM,CAAC,EAAE,GACxE;CACA,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS,GACnC,QAAQ,IACP,kDAAkD,OAAO,KAAK,SAAS,CAAC,CAAC,KAAK,IAAI,GACnF;CAGD,OAAO;EACN,YAAY;EACZ;EACA;CACD;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_credentials = require("./credentials-
|
|
1
|
+
const require_credentials = require("./credentials-CrQglKgo.cjs");
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -97,10 +97,10 @@ async function bundleServer(options) {
|
|
|
97
97
|
for (const ext of Object.keys(candidates)) args.push(`--external:${ext}`);
|
|
98
98
|
let masterKey;
|
|
99
99
|
if (stage) {
|
|
100
|
-
const { toEmbeddableSecrets, validateEnvironmentVariables, initStageSecrets } = await Promise.resolve().then(() => require("./credentials-
|
|
101
|
-
const { FileSecretsStore, secretsStoreFor } = await Promise.resolve().then(() => require("./credentials-
|
|
100
|
+
const { toEmbeddableSecrets, validateEnvironmentVariables, initStageSecrets } = await Promise.resolve().then(() => require("./credentials-CrQglKgo.cjs")).then((n) => n.storage_exports);
|
|
101
|
+
const { FileSecretsStore, secretsStoreFor } = await Promise.resolve().then(() => require("./credentials-CrQglKgo.cjs")).then((n) => n.store_exports);
|
|
102
102
|
const { ConfigNotFound, loadWorkspaceSettings } = await Promise.resolve().then(() => require("./config.cjs"));
|
|
103
|
-
const { encryptSecrets, generateDefineOptions } = await Promise.resolve().then(() => require("./sniffer-
|
|
103
|
+
const { encryptSecrets, generateDefineOptions } = await Promise.resolve().then(() => require("./sniffer-BL7X_kzC.cjs")).then((n) => n.encryption_exports);
|
|
104
104
|
const store = await loadWorkspaceSettings().then((workspace) => secretsStoreFor(workspace, stage), (error) => {
|
|
105
105
|
if (error instanceof ConfigNotFound) return new FileSecretsStore(process.cwd());
|
|
106
106
|
throw error;
|
|
@@ -148,7 +148,7 @@ async function bundleServer(options) {
|
|
|
148
148
|
const encryptedPath = (0, node_path.join)(gkmDir, "credentials.enc");
|
|
149
149
|
const ivPath = (0, node_path.join)(gkmDir, "credentials.iv");
|
|
150
150
|
if ((0, node_fs.existsSync)(encryptedPath) && (0, node_fs.existsSync)(ivPath)) {
|
|
151
|
-
const { generateDefineOptions } = await Promise.resolve().then(() => require("./sniffer-
|
|
151
|
+
const { generateDefineOptions } = await Promise.resolve().then(() => require("./sniffer-BL7X_kzC.cjs")).then((n) => n.encryption_exports);
|
|
152
152
|
const defines = generateDefineOptions({
|
|
153
153
|
encrypted: (0, node_fs.readFileSync)(encryptedPath, "utf-8").trim(),
|
|
154
154
|
iv: (0, node_fs.readFileSync)(ivPath, "utf-8").trim(),
|
|
@@ -190,4 +190,4 @@ async function bundleServer(options) {
|
|
|
190
190
|
//#endregion
|
|
191
191
|
exports.bundleServer = bundleServer;
|
|
192
192
|
|
|
193
|
-
//# sourceMappingURL=bundler-
|
|
193
|
+
//# sourceMappingURL=bundler-Ronn7-mL.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler-Co_7zpYC.cjs","names":["dirname","existsSync","join","require","createRequire","mkdir","bundleExternals","readFileSync","spawnSync","writeFile","importedPackages","rm","externalsManifestName"],"sources":["../src/build/bundler.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport type { Construct } from '@geekmidas/constructs';\nimport {\n\tbundleExternals,\n\texternalsManifestName,\n\timportedPackages,\n} from './native';\n\n/**\n * Banner to inject into ESM bundle for CJS compatibility.\n * Creates a `require` function using Node's createRequire for packages\n * that internally use CommonJS require() for Node builtins.\n */\nconst ESM_CJS_COMPAT_BANNER =\n\t'import { createRequire } from \"module\"; const require = createRequire(import.meta.url);';\n\nexport interface BundleOptions {\n\t/** Entry point file (e.g., .gkm/server/server.ts) */\n\tentryPoint: string;\n\t/** Output directory for bundled files */\n\toutputDir: string;\n\t/** The bundle's file name in `outputDir`. Defaults to `server.mjs`. */\n\toutfile?: string;\n\t/** Minify the output (default: true) */\n\tminify: boolean;\n\t/** Generate sourcemaps (default: false) */\n\tsourcemap: boolean;\n\t/**\n\t * Packages to leave out of the bundle besides its native ones, which are\n\t * always left out and recorded beside it — see `externalsManifestName`.\n\t */\n\texternal: string[];\n\t/** Stage for secrets injection (optional) */\n\tstage?: string;\n\t/** Constructs to validate environment variables for */\n\tconstructs?: Construct[];\n}\n\nexport interface BundleResult {\n\t/** Path to the bundled output */\n\toutputPath: string;\n\t/** Ephemeral master key for deployment (only if stage was provided) */\n\tmasterKey?: string;\n\t/** What the bundle left out, at the version to install beside it. */\n\texternals: Record<string, string>;\n}\n\n/** The app a bundle is built for: the nearest `package.json` above its entry. */\nfunction appRootOf(entryPoint: string): string {\n\tlet dir = dirname(entryPoint);\n\twhile (!existsSync(join(dir, 'package.json'))) {\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return dirname(entryPoint);\n\t\tdir = parent;\n\t}\n\treturn dir;\n}\n\n/**\n * The esbuild binary, resolved from this package rather than from PATH.\n *\n * It used to be `npx esbuild`, which is two assumptions: that esbuild is\n * installed somewhere npx can find, and that the *app's* directory is where to\n * look. Neither holds — the CLI did not depend on esbuild at all, so a deploy\n * run from an app that had not installed it failed at the bundle step with\n * `sh: esbuild: command not found`, after provisioning had already happened.\n *\n * The same fix `bin/gkm.mjs` makes for tsx: resolve from this package's own\n * `node_modules`, so the tool the CLI shells out to is the one it depends on.\n */\nfunction esbuildBinary(): string {\n\tconst require = createRequire(import.meta.url);\n\n\ttry {\n\t\t// The package root, then its bin — `require.resolve('esbuild')` gives the\n\t\t// JS entry point, which is a library rather than the CLI.\n\t\tconst pkg = require.resolve('esbuild/package.json');\n\t\treturn join(dirname(pkg), 'bin', 'esbuild');\n\t} catch {\n\t\t// Better a PATH lookup than a hard failure: a project that installed\n\t\t// esbuild itself still works.\n\t\treturn 'esbuild';\n\t}\n}\n\n/**\n * Collect the environment variables a build cannot proceed without.\n *\n * Uses the SnifferEnvironmentParser to detect which env vars each service\n * reads, and keeps only the ones it cannot do without. `markOptional` is what\n * separates them: the sniffer already knows which reads went through\n * `.optional()` or `.default()`, and asking for that distinction is the\n * difference between a build that stops and one that proceeds correctly.\n *\n * Without it, a key that is *absent by design* failed the build. A surface\n * publishes `AUTH_COOKIE_DOMAIN` only when there is a domain to widen a cookie\n * to — one host has nothing to share it with, so the derivation correctly\n * yields nothing, and Better Auth reads it as optional for exactly that\n * reason. Treating every sniffed read as required made the honest answer\n * indistinguishable from a missing secret.\n *\n * @param constructs - Array of constructs to analyze\n * @returns Deduplicated, sorted names of the required variables\n */\nasync function collectRequiredEnvVars(\n\tconstructs: Construct[],\n): Promise<string[]> {\n\t// A key read optionally by one construct and required by another stays\n\t// required: the strictest read is the one that fails at runtime, and taking\n\t// the union of the required reads is what says so.\n\tconst required = new Set<string>();\n\n\tfor (const construct of constructs) {\n\t\tfor (const name of await construct.getEnvironment({ markOptional: true })) {\n\t\t\tif (!name.endsWith('?')) required.add(name);\n\t\t}\n\t}\n\n\treturn Array.from(required).sort();\n}\n\n/**\n * Bundle the server application using esbuild.\n * Creates a fully standalone bundle with all dependencies included.\n *\n * @param options - Bundle configuration options\n * @returns Bundle result with output path and optional master key\n */\n\nexport async function bundleServer(\n\toptions: BundleOptions,\n): Promise<BundleResult> {\n\tconst {\n\t\tentryPoint,\n\t\toutputDir,\n\t\tminify,\n\t\tsourcemap,\n\t\texternal,\n\t\tstage,\n\t\tconstructs,\n\t} = options;\n\n\t// Ensure output directory exists\n\tawait mkdir(outputDir, { recursive: true });\n\n\tconst outfile = options.outfile ?? 'server.mjs';\n\tconst mjsOutput = join(outputDir, outfile);\n\n\t// A package with native code loads a binary from beside its own source,\n\t// built for the platform it was installed on: inlined, it finds neither.\n\t// Every one the app could reach stays out of the bundle, and the ones the\n\t// bundle imports are installed for the image's platform at this version.\n\tconst candidates = bundleExternals(appRootOf(entryPoint), external);\n\tconst metafile = join(outputDir, `.${outfile}.meta.json`);\n\n\t// Build command-line arguments for esbuild\n\tconst args = [\n\t\tesbuildBinary(),\n\t\tentryPoint,\n\t\t'--bundle',\n\t\t'--platform=node',\n\t\t'--target=node22',\n\t\t'--format=esm',\n\t\t`--outfile=${mjsOutput}`,\n\t\t'--packages=bundle', // Bundle all dependencies for standalone output\n\t\t`--banner:js=${ESM_CJS_COMPAT_BANNER}`, // CJS compatibility for packages like pino\n\t\t`--metafile=${metafile}`,\n\t];\n\n\tif (minify) {\n\t\t// Names kept: an error's class name is what a log line's `err.type` and\n\t\t// a response's `name` say, and minified they read `_6`.\n\t\targs.push('--minify', '--keep-names');\n\t}\n\n\tif (sourcemap) {\n\t\targs.push('--sourcemap');\n\t}\n\n\tfor (const ext of Object.keys(candidates)) {\n\t\targs.push(`--external:${ext}`);\n\t}\n\n\t// Handle secrets injection if stage is provided\n\tlet masterKey: string | undefined;\n\n\tif (stage) {\n\t\tconst {\n\t\t\ttoEmbeddableSecrets,\n\t\t\tvalidateEnvironmentVariables,\n\t\t\tinitStageSecrets,\n\t\t} = await import('../secrets/storage');\n\t\tconst { FileSecretsStore, secretsStoreFor } = await import(\n\t\t\t'../secrets/store'\n\t\t);\n\t\tconst { ConfigNotFound, loadWorkspaceSettings } = await import('../config');\n\t\tconst { encryptSecrets, generateDefineOptions } = await import(\n\t\t\t'../secrets/encryption'\n\t\t);\n\n\t\t// The stage's own store — SSM or Secrets Manager for a deployed stage\n\t\t// kept there. Outside\n\t\t// any workspace nothing names one, so it is the file.\n\t\tconst store = await loadWorkspaceSettings().then(\n\t\t\t(workspace) => secretsStoreFor(workspace, stage),\n\t\t\t(error) => {\n\t\t\t\tif (error instanceof ConfigNotFound) {\n\t\t\t\t\treturn new FileSecretsStore(process.cwd());\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tlet secrets = await store.read(stage);\n\n\t\tif (!secrets) {\n\t\t\t// Auto-initialize secrets for the stage\n\t\t\tconsole.log(` Initializing secrets for stage \"${stage}\"...`);\n\t\t\tsecrets = initStageSecrets(stage);\n\t\t\tawait store.write(stage, secrets);\n\t\t\tconsole.log(` ✓ Created the \"${stage}\" secrets (${store.name})`);\n\t\t}\n\n\t\t// Validate environment variables if constructs are provided\n\t\tif (constructs && constructs.length > 0) {\n\t\t\tconsole.log(' Analyzing environment variable requirements...');\n\t\t\tconst requiredVars = await collectRequiredEnvVars(constructs);\n\n\t\t\tif (requiredVars.length > 0) {\n\t\t\t\tconst validation = validateEnvironmentVariables(requiredVars, secrets);\n\n\t\t\t\tif (!validation.valid) {\n\t\t\t\t\tconst errorMessage = [\n\t\t\t\t\t\t`Missing environment variables for stage \"${stage}\":`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t...validation.missing.map((v) => ` ❌ ${v}`),\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'To fix this, either:',\n\t\t\t\t\t\t` 1. Add the missing variables to the \"${stage}\" secrets using:`,\n\t\t\t\t\t\t` gkm secrets:set <KEY> <VALUE> --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t` 2. Or import from a JSON file:`,\n\t\t\t\t\t\t` gkm secrets:import secrets.json --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'Required variables:',\n\t\t\t\t\t\t...validation.required.map((v) =>\n\t\t\t\t\t\t\tvalidation.missing.includes(v) ? ` ❌ ${v}` : ` ✓ ${v}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t].join('\\n');\n\n\t\t\t\t\tthrow new Error(errorMessage);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t` ✓ All ${requiredVars.length} required environment variables found`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Convert to embeddable format and encrypt\n\t\tconst embeddable = toEmbeddableSecrets(secrets);\n\t\tconst encrypted = encryptSecrets(embeddable);\n\t\tmasterKey = encrypted.masterKey;\n\n\t\t// Add define options for build-time injection using esbuild's --define:KEY=VALUE format\n\t\tconst defines = generateDefineOptions(encrypted);\n\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t// `value` is already a JS string literal; quoting it again would\n\t\t\t// embed the quotes, and the IV would not parse as hex.\n\t\t\targs.push(`--define:${key}=${value}`);\n\t\t}\n\n\t\tconsole.log(` Secrets encrypted for stage \"${stage}\"`);\n\t} else {\n\t\t// Credentials encrypted elsewhere — an image build hands them in as a\n\t\t// BuildKit secret and writes them beside the app's `.gkm/server` — are\n\t\t// embedded as they are; whoever encrypted them holds the key.\n\t\tconst gkmDir = join(outputDir, '..', '..');\n\t\tconst encryptedPath = join(gkmDir, 'credentials.enc');\n\t\tconst ivPath = join(gkmDir, 'credentials.iv');\n\t\tif (existsSync(encryptedPath) && existsSync(ivPath)) {\n\t\t\tconst { generateDefineOptions } = await import('../secrets/encryption');\n\t\t\tconst defines = generateDefineOptions({\n\t\t\t\tencrypted: readFileSync(encryptedPath, 'utf-8').trim(),\n\t\t\t\tiv: readFileSync(ivPath, 'utf-8').trim(),\n\t\t\t\tmasterKey: '',\n\t\t\t});\n\t\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t\targs.push(`--define:${key}=${value}`);\n\t\t\t}\n\t\t\tconsole.log(' Embedded the encrypted credentials the build was given');\n\t\t}\n\t}\n\n\ttry {\n\t\t// Run esbuild with command-line arguments\n\t\tconst [cmd, ...cmdArgs] = args as [string, ...string[]];\n\t\tconst result = spawnSync(cmd, cmdArgs, {\n\t\t\tcwd: process.cwd(),\n\t\t\tstdio: 'inherit',\n\t\t\tshell: process.platform === 'win32', // Only use shell on Windows for npx resolution\n\t\t});\n\n\t\tif (result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\t\tif (result.status !== 0) {\n\t\t\tthrow new Error(`esbuild exited with code ${result.status}`);\n\t\t}\n\n\t\t// Add shebang to the bundled file\n\t\tconst { readFile } = await import('node:fs/promises');\n\t\tconst content = await readFile(mjsOutput, 'utf-8');\n\t\tif (!content.startsWith('#!')) {\n\t\t\tawait writeFile(mjsOutput, `#!/usr/bin/env node\\n${content}`);\n\t\t}\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to bundle server: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t);\n\t}\n\n\t// Declared ones always; a native package only where the bundle imports it\n\t// — an app that depends on `@geekmidas/cli` reaches esbuild, and never\n\t// runs it.\n\tconst imported = importedPackages(metafile);\n\tawait rm(metafile, { force: true });\n\tconst externals = Object.fromEntries(\n\t\tObject.entries(candidates).filter(\n\t\t\t([name]) => external.includes(name) || imported.has(name),\n\t\t),\n\t);\n\tawait writeFile(\n\t\tjoin(outputDir, externalsManifestName(outfile)),\n\t\t`${JSON.stringify({ private: true, dependencies: externals }, null, 2)}\\n`,\n\t);\n\tif (Object.keys(externals).length > 0) {\n\t\tconsole.log(\n\t\t\t` Left out of the bundle, installed beside it: ${Object.keys(externals).join(', ')}`,\n\t\t);\n\t}\n\n\treturn {\n\t\toutputPath: mjsOutput,\n\t\tmasterKey,\n\t\texternals,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,wBACL;;AAkCD,SAAS,UAAU,YAA4B;CAC9C,IAAI,OAAA,GAAMA,UAAAA,QAAAA,CAAQ,UAAU;CAC5B,OAAO,EAAA,GAACC,QAAAA,WAAAA,EAAAA,GAAWC,UAAAA,KAAAA,CAAK,KAAK,cAAc,CAAC,GAAG;EAC9C,MAAM,UAAA,GAASF,UAAAA,QAAAA,CAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,QAAA,GAAOA,UAAAA,QAAAA,CAAQ,UAAU;EAC7C,MAAM;CACP;CACA,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAS,gBAAwB;CAChC,MAAMG,aAAAA,GAAUC,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;CAE7C,IAAI;EAGH,MAAM,MAAMD,UAAQ,QAAQ,sBAAsB;EAClD,QAAA,GAAOD,UAAAA,KAAAA,EAAAA,GAAKF,UAAAA,QAAAA,CAAQ,GAAG,GAAG,OAAO,SAAS;CAC3C,QAAQ;EAGP,OAAO;CACR;AACD;;;;;;;;;;;;;;;;;;;;AAqBA,eAAe,uBACd,YACoB;CAIpB,MAAM,2BAAW,IAAI,IAAY;CAEjC,KAAK,MAAM,aAAa,YACvB,KAAK,MAAM,QAAQ,MAAM,UAAU,eAAe,EAAE,cAAc,KAAK,CAAC,GACvE,IAAI,CAAC,KAAK,SAAS,GAAG,GAAG,SAAS,IAAI,IAAI;CAI5C,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,KAAK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iBAAiB,QAAQ;CAC1C,OAAA,GAAMC,iBAAAA,GAAAA,CAAG,UAAU,EAAE,OAAO,KAAK,CAAC;CAClC,MAAM,YAAY,OAAO,YACxB,OAAO,QAAQ,UAAU,CAAC,CAAC,QACzB,CAAC,UAAU,SAAS,SAAS,IAAI,KAAK,SAAS,IAAI,IAAI,CACzD,CACD;CACA,OAAA,GAAMF,iBAAAA,UAAAA,EAAAA,GACLP,UAAAA,KAAAA,CAAK,WAAWU,oBAAAA,sBAAsB,OAAO,CAAC,GAC9C,GAAG,KAAK,UAAU;EAAE,SAAS;EAAM,cAAc;CAAU,GAAG,MAAM,CAAC,EAAE,GACxE;CACA,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS,GACnC,QAAQ,IACP,kDAAkD,OAAO,KAAK,SAAS,CAAC,CAAC,KAAK,IAAI,GACnF;CAGD,OAAO;EACN,YAAY;EACZ;EACA;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"bundler-Ronn7-mL.cjs","names":["dirname","existsSync","join","require","createRequire","mkdir","bundleExternals","readFileSync","spawnSync","writeFile","importedPackages","rm","externalsManifestName"],"sources":["../src/build/bundler.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport type { Construct } from '@geekmidas/constructs';\nimport {\n\tbundleExternals,\n\texternalsManifestName,\n\timportedPackages,\n} from './native';\n\n/**\n * Banner to inject into ESM bundle for CJS compatibility.\n * Creates a `require` function using Node's createRequire for packages\n * that internally use CommonJS require() for Node builtins.\n */\nconst ESM_CJS_COMPAT_BANNER =\n\t'import { createRequire } from \"module\"; const require = createRequire(import.meta.url);';\n\nexport interface BundleOptions {\n\t/** Entry point file (e.g., .gkm/server/server.ts) */\n\tentryPoint: string;\n\t/** Output directory for bundled files */\n\toutputDir: string;\n\t/** The bundle's file name in `outputDir`. Defaults to `server.mjs`. */\n\toutfile?: string;\n\t/** Minify the output (default: true) */\n\tminify: boolean;\n\t/** Generate sourcemaps (default: false) */\n\tsourcemap: boolean;\n\t/**\n\t * Packages to leave out of the bundle besides its native ones, which are\n\t * always left out and recorded beside it — see `externalsManifestName`.\n\t */\n\texternal: string[];\n\t/** Stage for secrets injection (optional) */\n\tstage?: string;\n\t/** Constructs to validate environment variables for */\n\tconstructs?: Construct[];\n}\n\nexport interface BundleResult {\n\t/** Path to the bundled output */\n\toutputPath: string;\n\t/** Ephemeral master key for deployment (only if stage was provided) */\n\tmasterKey?: string;\n\t/** What the bundle left out, at the version to install beside it. */\n\texternals: Record<string, string>;\n}\n\n/** The app a bundle is built for: the nearest `package.json` above its entry. */\nfunction appRootOf(entryPoint: string): string {\n\tlet dir = dirname(entryPoint);\n\twhile (!existsSync(join(dir, 'package.json'))) {\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return dirname(entryPoint);\n\t\tdir = parent;\n\t}\n\treturn dir;\n}\n\n/**\n * The esbuild binary, resolved from this package rather than from PATH.\n *\n * It used to be `npx esbuild`, which is two assumptions: that esbuild is\n * installed somewhere npx can find, and that the *app's* directory is where to\n * look. Neither holds — the CLI did not depend on esbuild at all, so a deploy\n * run from an app that had not installed it failed at the bundle step with\n * `sh: esbuild: command not found`, after provisioning had already happened.\n *\n * The same fix `bin/gkm.mjs` makes for tsx: resolve from this package's own\n * `node_modules`, so the tool the CLI shells out to is the one it depends on.\n */\nfunction esbuildBinary(): string {\n\tconst require = createRequire(import.meta.url);\n\n\ttry {\n\t\t// The package root, then its bin — `require.resolve('esbuild')` gives the\n\t\t// JS entry point, which is a library rather than the CLI.\n\t\tconst pkg = require.resolve('esbuild/package.json');\n\t\treturn join(dirname(pkg), 'bin', 'esbuild');\n\t} catch {\n\t\t// Better a PATH lookup than a hard failure: a project that installed\n\t\t// esbuild itself still works.\n\t\treturn 'esbuild';\n\t}\n}\n\n/**\n * Collect the environment variables a build cannot proceed without.\n *\n * Uses the SnifferEnvironmentParser to detect which env vars each service\n * reads, and keeps only the ones it cannot do without. `markOptional` is what\n * separates them: the sniffer already knows which reads went through\n * `.optional()` or `.default()`, and asking for that distinction is the\n * difference between a build that stops and one that proceeds correctly.\n *\n * Without it, a key that is *absent by design* failed the build. A surface\n * publishes `AUTH_COOKIE_DOMAIN` only when there is a domain to widen a cookie\n * to — one host has nothing to share it with, so the derivation correctly\n * yields nothing, and Better Auth reads it as optional for exactly that\n * reason. Treating every sniffed read as required made the honest answer\n * indistinguishable from a missing secret.\n *\n * @param constructs - Array of constructs to analyze\n * @returns Deduplicated, sorted names of the required variables\n */\nasync function collectRequiredEnvVars(\n\tconstructs: Construct[],\n): Promise<string[]> {\n\t// A key read optionally by one construct and required by another stays\n\t// required: the strictest read is the one that fails at runtime, and taking\n\t// the union of the required reads is what says so.\n\tconst required = new Set<string>();\n\n\tfor (const construct of constructs) {\n\t\tfor (const name of await construct.getEnvironment({ markOptional: true })) {\n\t\t\tif (!name.endsWith('?')) required.add(name);\n\t\t}\n\t}\n\n\treturn Array.from(required).sort();\n}\n\n/**\n * Bundle the server application using esbuild.\n * Creates a fully standalone bundle with all dependencies included.\n *\n * @param options - Bundle configuration options\n * @returns Bundle result with output path and optional master key\n */\n\nexport async function bundleServer(\n\toptions: BundleOptions,\n): Promise<BundleResult> {\n\tconst {\n\t\tentryPoint,\n\t\toutputDir,\n\t\tminify,\n\t\tsourcemap,\n\t\texternal,\n\t\tstage,\n\t\tconstructs,\n\t} = options;\n\n\t// Ensure output directory exists\n\tawait mkdir(outputDir, { recursive: true });\n\n\tconst outfile = options.outfile ?? 'server.mjs';\n\tconst mjsOutput = join(outputDir, outfile);\n\n\t// A package with native code loads a binary from beside its own source,\n\t// built for the platform it was installed on: inlined, it finds neither.\n\t// Every one the app could reach stays out of the bundle, and the ones the\n\t// bundle imports are installed for the image's platform at this version.\n\tconst candidates = bundleExternals(appRootOf(entryPoint), external);\n\tconst metafile = join(outputDir, `.${outfile}.meta.json`);\n\n\t// Build command-line arguments for esbuild\n\tconst args = [\n\t\tesbuildBinary(),\n\t\tentryPoint,\n\t\t'--bundle',\n\t\t'--platform=node',\n\t\t'--target=node22',\n\t\t'--format=esm',\n\t\t`--outfile=${mjsOutput}`,\n\t\t'--packages=bundle', // Bundle all dependencies for standalone output\n\t\t`--banner:js=${ESM_CJS_COMPAT_BANNER}`, // CJS compatibility for packages like pino\n\t\t`--metafile=${metafile}`,\n\t];\n\n\tif (minify) {\n\t\t// Names kept: an error's class name is what a log line's `err.type` and\n\t\t// a response's `name` say, and minified they read `_6`.\n\t\targs.push('--minify', '--keep-names');\n\t}\n\n\tif (sourcemap) {\n\t\targs.push('--sourcemap');\n\t}\n\n\tfor (const ext of Object.keys(candidates)) {\n\t\targs.push(`--external:${ext}`);\n\t}\n\n\t// Handle secrets injection if stage is provided\n\tlet masterKey: string | undefined;\n\n\tif (stage) {\n\t\tconst {\n\t\t\ttoEmbeddableSecrets,\n\t\t\tvalidateEnvironmentVariables,\n\t\t\tinitStageSecrets,\n\t\t} = await import('../secrets/storage');\n\t\tconst { FileSecretsStore, secretsStoreFor } = await import(\n\t\t\t'../secrets/store'\n\t\t);\n\t\tconst { ConfigNotFound, loadWorkspaceSettings } = await import('../config');\n\t\tconst { encryptSecrets, generateDefineOptions } = await import(\n\t\t\t'../secrets/encryption'\n\t\t);\n\n\t\t// The stage's own store — SSM or Secrets Manager for a deployed stage\n\t\t// kept there. Outside\n\t\t// any workspace nothing names one, so it is the file.\n\t\tconst store = await loadWorkspaceSettings().then(\n\t\t\t(workspace) => secretsStoreFor(workspace, stage),\n\t\t\t(error) => {\n\t\t\t\tif (error instanceof ConfigNotFound) {\n\t\t\t\t\treturn new FileSecretsStore(process.cwd());\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tlet secrets = await store.read(stage);\n\n\t\tif (!secrets) {\n\t\t\t// Auto-initialize secrets for the stage\n\t\t\tconsole.log(` Initializing secrets for stage \"${stage}\"...`);\n\t\t\tsecrets = initStageSecrets(stage);\n\t\t\tawait store.write(stage, secrets);\n\t\t\tconsole.log(` ✓ Created the \"${stage}\" secrets (${store.name})`);\n\t\t}\n\n\t\t// Validate environment variables if constructs are provided\n\t\tif (constructs && constructs.length > 0) {\n\t\t\tconsole.log(' Analyzing environment variable requirements...');\n\t\t\tconst requiredVars = await collectRequiredEnvVars(constructs);\n\n\t\t\tif (requiredVars.length > 0) {\n\t\t\t\tconst validation = validateEnvironmentVariables(requiredVars, secrets);\n\n\t\t\t\tif (!validation.valid) {\n\t\t\t\t\tconst errorMessage = [\n\t\t\t\t\t\t`Missing environment variables for stage \"${stage}\":`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t...validation.missing.map((v) => ` ❌ ${v}`),\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'To fix this, either:',\n\t\t\t\t\t\t` 1. Add the missing variables to the \"${stage}\" secrets using:`,\n\t\t\t\t\t\t` gkm secrets:set <KEY> <VALUE> --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t` 2. Or import from a JSON file:`,\n\t\t\t\t\t\t` gkm secrets:import secrets.json --stage ${stage}`,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'Required variables:',\n\t\t\t\t\t\t...validation.required.map((v) =>\n\t\t\t\t\t\t\tvalidation.missing.includes(v) ? ` ❌ ${v}` : ` ✓ ${v}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t].join('\\n');\n\n\t\t\t\t\tthrow new Error(errorMessage);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t` ✓ All ${requiredVars.length} required environment variables found`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Convert to embeddable format and encrypt\n\t\tconst embeddable = toEmbeddableSecrets(secrets);\n\t\tconst encrypted = encryptSecrets(embeddable);\n\t\tmasterKey = encrypted.masterKey;\n\n\t\t// Add define options for build-time injection using esbuild's --define:KEY=VALUE format\n\t\tconst defines = generateDefineOptions(encrypted);\n\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t// `value` is already a JS string literal; quoting it again would\n\t\t\t// embed the quotes, and the IV would not parse as hex.\n\t\t\targs.push(`--define:${key}=${value}`);\n\t\t}\n\n\t\tconsole.log(` Secrets encrypted for stage \"${stage}\"`);\n\t} else {\n\t\t// Credentials encrypted elsewhere — an image build hands them in as a\n\t\t// BuildKit secret and writes them beside the app's `.gkm/server` — are\n\t\t// embedded as they are; whoever encrypted them holds the key.\n\t\tconst gkmDir = join(outputDir, '..', '..');\n\t\tconst encryptedPath = join(gkmDir, 'credentials.enc');\n\t\tconst ivPath = join(gkmDir, 'credentials.iv');\n\t\tif (existsSync(encryptedPath) && existsSync(ivPath)) {\n\t\t\tconst { generateDefineOptions } = await import('../secrets/encryption');\n\t\t\tconst defines = generateDefineOptions({\n\t\t\t\tencrypted: readFileSync(encryptedPath, 'utf-8').trim(),\n\t\t\t\tiv: readFileSync(ivPath, 'utf-8').trim(),\n\t\t\t\tmasterKey: '',\n\t\t\t});\n\t\t\tfor (const [key, value] of Object.entries(defines)) {\n\t\t\t\targs.push(`--define:${key}=${value}`);\n\t\t\t}\n\t\t\tconsole.log(' Embedded the encrypted credentials the build was given');\n\t\t}\n\t}\n\n\ttry {\n\t\t// Run esbuild with command-line arguments\n\t\tconst [cmd, ...cmdArgs] = args as [string, ...string[]];\n\t\tconst result = spawnSync(cmd, cmdArgs, {\n\t\t\tcwd: process.cwd(),\n\t\t\tstdio: 'inherit',\n\t\t\tshell: process.platform === 'win32', // Only use shell on Windows for npx resolution\n\t\t});\n\n\t\tif (result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\t\tif (result.status !== 0) {\n\t\t\tthrow new Error(`esbuild exited with code ${result.status}`);\n\t\t}\n\n\t\t// Add shebang to the bundled file\n\t\tconst { readFile } = await import('node:fs/promises');\n\t\tconst content = await readFile(mjsOutput, 'utf-8');\n\t\tif (!content.startsWith('#!')) {\n\t\t\tawait writeFile(mjsOutput, `#!/usr/bin/env node\\n${content}`);\n\t\t}\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to bundle server: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t);\n\t}\n\n\t// Declared ones always; a native package only where the bundle imports it\n\t// — an app that depends on `@geekmidas/cli` reaches esbuild, and never\n\t// runs it.\n\tconst imported = importedPackages(metafile);\n\tawait rm(metafile, { force: true });\n\tconst externals = Object.fromEntries(\n\t\tObject.entries(candidates).filter(\n\t\t\t([name]) => external.includes(name) || imported.has(name),\n\t\t),\n\t);\n\tawait writeFile(\n\t\tjoin(outputDir, externalsManifestName(outfile)),\n\t\t`${JSON.stringify({ private: true, dependencies: externals }, null, 2)}\\n`,\n\t);\n\tif (Object.keys(externals).length > 0) {\n\t\tconsole.log(\n\t\t\t` Left out of the bundle, installed beside it: ${Object.keys(externals).join(', ')}`,\n\t\t);\n\t}\n\n\treturn {\n\t\toutputPath: mjsOutput,\n\t\tmasterKey,\n\t\texternals,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,wBACL;;AAkCD,SAAS,UAAU,YAA4B;CAC9C,IAAI,OAAA,GAAMA,UAAAA,QAAAA,CAAQ,UAAU;CAC5B,OAAO,EAAA,GAACC,QAAAA,WAAAA,EAAAA,GAAWC,UAAAA,KAAAA,CAAK,KAAK,cAAc,CAAC,GAAG;EAC9C,MAAM,UAAA,GAASF,UAAAA,QAAAA,CAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,QAAA,GAAOA,UAAAA,QAAAA,CAAQ,UAAU;EAC7C,MAAM;CACP;CACA,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAS,gBAAwB;CAChC,MAAMG,aAAAA,GAAUC,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;CAE7C,IAAI;EAGH,MAAM,MAAMD,UAAQ,QAAQ,sBAAsB;EAClD,QAA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AC;EAED,IAAI,OAAO,OACV,MAAM,OAAO;EAEd,IAAI,OAAO,WAAW,GACrB,MAAM,IAAI,MAAM,4BAA4B,OAAO,QAAQ;EAI5D,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,UAAU,MAAM,SAAS,WAAW,OAAO;EACjD,IAAI,CAAC,QAAQ,WAAW,IAAI,GAC3B,OAAA,GAAMC,iBAAAA,UAAAA,CAAU,WAAW,wBAAwB,SAAS;CAE9D,SAAS,OAAO;EACf,MAAM,IAAI,MACT,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,iBACtE;CACD;CAKA,MAAM,WAAWC,oBAAAA,iBAAiB,QAAQ;CAC1C,OAAA,GAAMC,iBAAAA,GAAAA,CAAG,UAAU,EAAE,OAAO,KAAK,CAAC;CAClC,MAAM,YAAY,OAAO,YACxB,OAAO,QAAQ,UAAU,CAAC,CAAC,QACzB,CAAC,UAAU,SAAS,SAAS,IAAI,KAAK,SAAS,IAAI,IAAI,CACzD,CACD;CACA,OAAA,GAAMF,iBAAAA,UAAAA,EAAAA,GACLP,UAAAA,KAAAA,CAAK,WAAWU,oBAAAA,sBAAsB,OAAO,CAAC,GAC9C,GAAG,KAAK,UAAU;EAAE,SAAS;EAAM,cAAc;CAAU,GAAG,MAAM,CAAC,EAAE,GACxE;CACA,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS,GACnC,QAAQ,IACP,kDAAkD,OAAO,KAAK,SAAS,CAAC,CAAC,KAAK,IAAI,GACnF;CAGD,OAAO;EACN,YAAY;EACZ;EACA;CACD;AACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as storedCredentials } from "./credentials-
|
|
2
|
-
import { t as deploy } from "./deploy-
|
|
1
|
+
import { r as storedCredentials } from "./credentials-FRF4PZYo.mjs";
|
|
2
|
+
import { t as deploy } from "./deploy-DI_tg5Mi.mjs";
|
|
3
3
|
import { s as formatError } from "./index.mjs";
|
|
4
4
|
import { n as targetForProvider } from "./provider-CEOKk8NS.mjs";
|
|
5
|
-
import { terminalCredentials } from "./terminal-
|
|
5
|
+
import { terminalCredentials } from "./terminal-BnKPi06T.mjs";
|
|
6
6
|
//#region src/deploy/cli.ts
|
|
7
7
|
/**
|
|
8
8
|
* `gkm deploy`: the terminal around `deploy()`. CLI layer only.
|
|
@@ -68,4 +68,4 @@ async function deployCli(options, streams = { stdout: process.stdout }) {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
export { deployCli };
|
|
70
70
|
|
|
71
|
-
//# sourceMappingURL=cli-
|
|
71
|
+
//# sourceMappingURL=cli-AZVyGSRn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-
|
|
1
|
+
{"version":3,"file":"cli-AZVyGSRn.mjs","names":[],"sources":["../src/deploy/cli.ts"],"sourcesContent":["/**\n * `gkm deploy`: the terminal around `deploy()`. CLI layer only.\n *\n * Everything that belongs to a person at a terminal lives here and nowhere\n * below it: prompting for a missing login (and storing it), printing progress,\n * and turning the outcome into an exit code. The deploy itself is the same\n * `deploy()` a host calls.\n */\n\nimport { formatError } from '../debug';\nimport { targetForProvider } from '../target/provider';\nimport { storedCredentials } from './credentials';\nimport { deploy } from './deploy';\nimport { terminalCredentials } from './terminal';\n\nexport interface DeployCliOptions {\n\t/** The project directory: `--cwd`, else where the command was run. */\n\tcwd: string;\n\t/** `--target`: where to deploy. Defaults to `deploy.default`. */\n\ttarget?: string;\n\t/** `--provider`, deprecated: `dokploy` means `--target dokploy`. */\n\tprovider?: string;\n\tstage: string;\n\ttag?: string;\n\t/**\n\t * Print each event as one JSON object per line on stdout, instead of the\n\t * progress lines. Nothing prompts: a missing credential fails the run.\n\t */\n\tjson?: boolean;\n\t/** Plan only: create, change, build and push nothing. */\n\tdryRun?: boolean;\n\t/** On a failed release, roll back every app, not only the failed ones. */\n\tatomic?: boolean;\n\t/** `--allow-dev-services`. */\n\tallowDevServices?: boolean;\n\t/** `--skip-dns`. */\n\tskipDns?: boolean;\n\t/** `--rotate-keys`. */\n\trotateKeys?: boolean;\n\t/** `--retire-old-keys`. */\n\tretireOldKeys?: boolean;\n}\n\n/** Where the command writes. The process's own streams, outside tests. */\nexport interface DeployCliStreams {\n\tstdout: Pick<NodeJS.WriteStream, 'write'>;\n}\n\n/**\n * Run `gkm deploy` and resolve with its exit code: 0 when the run finished,\n * 1 when anything stopped it.\n */\nexport async function deployCli(\n\toptions: DeployCliOptions,\n\tstreams: DeployCliStreams = { stdout: process.stdout },\n): Promise<number> {\n\tlet target = options.target;\n\tif (options.provider !== undefined && target === undefined) {\n\t\ttry {\n\t\t\t// On stderr, so a `--json` run's stdout still carries only events.\n\t\t\ttarget = targetForProvider(options.provider, (message) =>\n\t\t\t\tconsole.warn(message),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(formatError(error));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tconst input = {\n\t\tcwd: options.cwd,\n\t\tstage: options.stage,\n\t\t...(target ? { target } : {}),\n\t\t...(options.tag ? { tag: options.tag } : {}),\n\t\t...(options.dryRun ? { dryRun: true } : {}),\n\t\t...(options.atomic ? { atomic: true } : {}),\n\t\t...(options.allowDevServices ? { allowDevServices: true } : {}),\n\t\t...(options.skipDns ? { skipDns: true } : {}),\n\t\t...(options.rotateKeys ? { rotateKeys: true } : {}),\n\t\t...(options.retireOldKeys ? { retireOldKeys: true } : {}),\n\t};\n\n\tif (options.json) {\n\t\t// stdout carries the events and nothing else: docker's own output goes\n\t\t// to stderr, and nobody is asked anything — a prompt would be written\n\t\t// into the stream a program is parsing.\n\t\tconst run = deploy({\n\t\t\t...input,\n\t\t\tcredentials: storedCredentials(),\n\t\t\tchildOutput: 'stderr',\n\t\t});\n\t\tfor await (const event of run) {\n\t\t\tstreams.stdout.write(`${JSON.stringify(event)}\\n`);\n\t\t}\n\t\treturn run.result.then(\n\t\t\t() => 0,\n\t\t\t(error) => {\n\t\t\t\tconsole.error(formatError(error));\n\t\t\t\treturn 1;\n\t\t\t},\n\t\t);\n\t}\n\n\t// The lines arrive as they are written, rather than as events read back a\n\t// tick later, so they interleave with a prompt exactly as they always did.\n\tconst run = deploy({\n\t\t...input,\n\t\tcredentials: terminalCredentials(storedCredentials()),\n\t\tlogger: {\n\t\t\tinfo: (message) => console.log(message),\n\t\t\twarn: (message) => console.warn(message),\n\t\t\terror: (message) => console.error(message),\n\t\t},\n\t});\n\n\ttry {\n\t\tawait run.result;\n\t\treturn 0;\n\t} catch (error) {\n\t\tconsole.error(formatError(error));\n\t\treturn 1;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoDA,eAAsB,UACrB,SACA,UAA4B,EAAE,QAAQ,QAAQ,OAAO,GACnC;CAClB,IAAI,SAAS,QAAQ;CACrB,IAAI,QAAQ,aAAa,KAAA,KAAa,WAAW,KAAA,GAChD,IAAI;EAEH,SAAS,kBAAkB,QAAQ,WAAW,YAC7C,QAAQ,KAAK,OAAO,CACrB;CACD,SAAS,OAAO;EACf,QAAQ,MAAM,YAAY,KAAK,CAAC;EAChC,OAAO;CACR;CAGD,MAAM,QAAQ;EACb,KAAK,QAAQ;EACb,OAAO,QAAQ;EACf,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAI,QAAQ,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC;EAC1C,GAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;EACzC,GAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;EACzC,GAAI,QAAQ,mBAAmB,EAAE,kBAAkB,KAAK,IAAI,CAAC;EAC7D,GAAI,QAAQ,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;EAC3C,GAAI,QAAQ,aAAa,EAAE,YAAY,KAAK,IAAI,CAAC;EACjD,GAAI,QAAQ,gBAAgB,EAAE,eAAe,KAAK,IAAI,CAAC;CACxD;CAEA,IAAI,QAAQ,MAAM;EAIjB,MAAM,MAAM,OAAO;GAClB,GAAG;GACH,aAAa,kBAAkB;GAC/B,aAAa;EACd,CAAC;EACD,WAAW,MAAM,SAAS,KACzB,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,KAAK,EAAE,GAAG;EAElD,OAAO,IAAI,OAAO,WACX,IACL,UAAU;GACV,QAAQ,MAAM,YAAY,KAAK,CAAC;GAChC,OAAO;EACR,CACD;CACD;CAIA,MAAM,MAAM,OAAO;EAClB,GAAG;EACH,aAAa,oBAAoB,kBAAkB,CAAC;EACpD,QAAQ;GACP,OAAO,YAAY,QAAQ,IAAI,OAAO;GACtC,OAAO,YAAY,QAAQ,KAAK,OAAO;GACvC,QAAQ,YAAY,QAAQ,MAAM,OAAO;EAC1C;CACD,CAAC;CAED,IAAI;EACH,MAAM,IAAI;EACV,OAAO;CACR,SAAS,OAAO;EACf,QAAQ,MAAM,YAAY,KAAK,CAAC;EAChC,OAAO;CACR;AACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_credentials = require("./credentials-
|
|
2
|
-
const require_deploy = require("./deploy-
|
|
1
|
+
const require_credentials = require("./credentials-CrQglKgo.cjs");
|
|
2
|
+
const require_deploy = require("./deploy-DTBod420.cjs");
|
|
3
3
|
const require_index = require("./index.cjs");
|
|
4
4
|
const require_provider = require("./provider-BqpjG9QM.cjs");
|
|
5
|
-
const require_terminal = require("./terminal-
|
|
5
|
+
const require_terminal = require("./terminal-CdPFlCS_.cjs");
|
|
6
6
|
//#region src/deploy/cli.ts
|
|
7
7
|
/**
|
|
8
8
|
* `gkm deploy`: the terminal around `deploy()`. CLI layer only.
|
|
@@ -68,4 +68,4 @@ async function deployCli(options, streams = { stdout: process.stdout }) {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
exports.deployCli = deployCli;
|
|
70
70
|
|
|
71
|
-
//# sourceMappingURL=cli-
|
|
71
|
+
//# sourceMappingURL=cli-B1g2OvS0.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-
|
|
1
|
+
{"version":3,"file":"cli-B1g2OvS0.cjs","names":["targetForProvider","formatError","deploy","storedCredentials","terminalCredentials"],"sources":["../src/deploy/cli.ts"],"sourcesContent":["/**\n * `gkm deploy`: the terminal around `deploy()`. CLI layer only.\n *\n * Everything that belongs to a person at a terminal lives here and nowhere\n * below it: prompting for a missing login (and storing it), printing progress,\n * and turning the outcome into an exit code. The deploy itself is the same\n * `deploy()` a host calls.\n */\n\nimport { formatError } from '../debug';\nimport { targetForProvider } from '../target/provider';\nimport { storedCredentials } from './credentials';\nimport { deploy } from './deploy';\nimport { terminalCredentials } from './terminal';\n\nexport interface DeployCliOptions {\n\t/** The project directory: `--cwd`, else where the command was run. */\n\tcwd: string;\n\t/** `--target`: where to deploy. Defaults to `deploy.default`. */\n\ttarget?: string;\n\t/** `--provider`, deprecated: `dokploy` means `--target dokploy`. */\n\tprovider?: string;\n\tstage: string;\n\ttag?: string;\n\t/**\n\t * Print each event as one JSON object per line on stdout, instead of the\n\t * progress lines. Nothing prompts: a missing credential fails the run.\n\t */\n\tjson?: boolean;\n\t/** Plan only: create, change, build and push nothing. */\n\tdryRun?: boolean;\n\t/** On a failed release, roll back every app, not only the failed ones. */\n\tatomic?: boolean;\n\t/** `--allow-dev-services`. */\n\tallowDevServices?: boolean;\n\t/** `--skip-dns`. */\n\tskipDns?: boolean;\n\t/** `--rotate-keys`. */\n\trotateKeys?: boolean;\n\t/** `--retire-old-keys`. */\n\tretireOldKeys?: boolean;\n}\n\n/** Where the command writes. The process's own streams, outside tests. */\nexport interface DeployCliStreams {\n\tstdout: Pick<NodeJS.WriteStream, 'write'>;\n}\n\n/**\n * Run `gkm deploy` and resolve with its exit code: 0 when the run finished,\n * 1 when anything stopped it.\n */\nexport async function deployCli(\n\toptions: DeployCliOptions,\n\tstreams: DeployCliStreams = { stdout: process.stdout },\n): Promise<number> {\n\tlet target = options.target;\n\tif (options.provider !== undefined && target === undefined) {\n\t\ttry {\n\t\t\t// On stderr, so a `--json` run's stdout still carries only events.\n\t\t\ttarget = targetForProvider(options.provider, (message) =>\n\t\t\t\tconsole.warn(message),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(formatError(error));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tconst input = {\n\t\tcwd: options.cwd,\n\t\tstage: options.stage,\n\t\t...(target ? { target } : {}),\n\t\t...(options.tag ? { tag: options.tag } : {}),\n\t\t...(options.dryRun ? { dryRun: true } : {}),\n\t\t...(options.atomic ? { atomic: true } : {}),\n\t\t...(options.allowDevServices ? { allowDevServices: true } : {}),\n\t\t...(options.skipDns ? { skipDns: true } : {}),\n\t\t...(options.rotateKeys ? { rotateKeys: true } : {}),\n\t\t...(options.retireOldKeys ? { retireOldKeys: true } : {}),\n\t};\n\n\tif (options.json) {\n\t\t// stdout carries the events and nothing else: docker's own output goes\n\t\t// to stderr, and nobody is asked anything — a prompt would be written\n\t\t// into the stream a program is parsing.\n\t\tconst run = deploy({\n\t\t\t...input,\n\t\t\tcredentials: storedCredentials(),\n\t\t\tchildOutput: 'stderr',\n\t\t});\n\t\tfor await (const event of run) {\n\t\t\tstreams.stdout.write(`${JSON.stringify(event)}\\n`);\n\t\t}\n\t\treturn run.result.then(\n\t\t\t() => 0,\n\t\t\t(error) => {\n\t\t\t\tconsole.error(formatError(error));\n\t\t\t\treturn 1;\n\t\t\t},\n\t\t);\n\t}\n\n\t// The lines arrive as they are written, rather than as events read back a\n\t// tick later, so they interleave with a prompt exactly as they always did.\n\tconst run = deploy({\n\t\t...input,\n\t\tcredentials: terminalCredentials(storedCredentials()),\n\t\tlogger: {\n\t\t\tinfo: (message) => console.log(message),\n\t\t\twarn: (message) => console.warn(message),\n\t\t\terror: (message) => console.error(message),\n\t\t},\n\t});\n\n\ttry {\n\t\tawait run.result;\n\t\treturn 0;\n\t} catch (error) {\n\t\tconsole.error(formatError(error));\n\t\treturn 1;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoDA,eAAsB,UACrB,SACA,U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