@geekmidas/cli 10.0.0-alpha.62 → 10.0.0-alpha.64
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/README.md +2 -0
- package/dist/{HostingerProvider-DyD1Hin8.cjs → HostingerProvider-Bx2lHHvu.cjs} +3 -3
- package/dist/{HostingerProvider-DyD1Hin8.cjs.map → HostingerProvider-Bx2lHHvu.cjs.map} +1 -1
- package/dist/{HostingerProvider-B92qH4dC.mjs → HostingerProvider-Cd4aS5Kj.mjs} +2 -2
- package/dist/{HostingerProvider-B92qH4dC.mjs.map → HostingerProvider-Cd4aS5Kj.mjs.map} +1 -1
- package/dist/{LegacyStateStore-UHJEBLdn.cjs → LegacyStateStore-C2abV49N.cjs} +2 -2
- package/dist/{LegacyStateStore-UHJEBLdn.cjs.map → LegacyStateStore-C2abV49N.cjs.map} +1 -1
- package/dist/{LegacyStateStore-A8d2GdT7.mjs → LegacyStateStore-DIgkGaUP.mjs} +2 -2
- package/dist/{LegacyStateStore-A8d2GdT7.mjs.map → LegacyStateStore-DIgkGaUP.mjs.map} +1 -1
- package/dist/{LocalStateStore-B51rnfgn.mjs → LocalStateStore-Cy1ZBW7U.mjs} +2 -2
- package/dist/{LocalStateStore-B51rnfgn.mjs.map → LocalStateStore-Cy1ZBW7U.mjs.map} +1 -1
- package/dist/{LocalStateStore-COW3Ldwa.cjs → LocalStateStore-DiJqKyPy.cjs} +2 -2
- package/dist/{LocalStateStore-COW3Ldwa.cjs.map → LocalStateStore-DiJqKyPy.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs → OpenApiTsGenerator-BWuDRHe9.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs.map → OpenApiTsGenerator-BWuDRHe9.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs → OpenApiTsGenerator-C6v-IeHt.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs.map → OpenApiTsGenerator-C6v-IeHt.mjs.map} +1 -1
- package/dist/{S3StateStore-CJewPhgz.mjs → S3StateStore-D3x6ivBL.mjs} +2 -2
- package/dist/{S3StateStore-CJewPhgz.mjs.map → S3StateStore-D3x6ivBL.mjs.map} +1 -1
- package/dist/{S3StateStore-WUJGdRNL.cjs → S3StateStore-Ds0V1Lgm.cjs} +2 -2
- package/dist/{S3StateStore-WUJGdRNL.cjs.map → S3StateStore-Ds0V1Lgm.cjs.map} +1 -1
- package/dist/{SSMStateStore-Zejt42V8.cjs → SSMStateStore-CLipvx47.cjs} +2 -2
- package/dist/{SSMStateStore-Zejt42V8.cjs.map → SSMStateStore-CLipvx47.cjs.map} +1 -1
- package/dist/{SSMStateStore-iK5UKp9d.mjs → SSMStateStore-DfF174xQ.mjs} +2 -2
- package/dist/{SSMStateStore-iK5UKp9d.mjs.map → SSMStateStore-DfF174xQ.mjs.map} +1 -1
- package/dist/{bundler-CfH9frOS.cjs → bundler-C8uJf324.cjs} +4 -4
- package/dist/{bundler-CfH9frOS.cjs.map → bundler-C8uJf324.cjs.map} +1 -1
- package/dist/{bundler-DN5r4x5b.mjs → bundler-DYgm9xsd.mjs} +3 -3
- package/dist/{bundler-DN5r4x5b.mjs.map → bundler-DYgm9xsd.mjs.map} +1 -1
- package/dist/{cli-DYwxmfsW.mjs → cli-Bogz-zEj.mjs} +5 -4
- package/dist/{cli-DYwxmfsW.mjs.map → cli-Bogz-zEj.mjs.map} +1 -1
- package/dist/{cli-DOAUp80L.cjs → cli-D3jofJ6j.cjs} +7 -6
- package/dist/{cli-DOAUp80L.cjs.map → cli-D3jofJ6j.cjs.map} +1 -1
- package/dist/config-Be-4_I6H.d.cts +256 -0
- package/dist/config-Be-4_I6H.d.cts.map +1 -0
- package/dist/config-DqNRiQOp.d.mts +256 -0
- package/dist/config-DqNRiQOp.d.mts.map +1 -0
- package/dist/config.cjs +416 -13
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +4 -211
- package/dist/config.d.mts +4 -211
- package/dist/config.mjs +402 -3
- package/dist/config.mjs.map +1 -0
- package/dist/credentials-B70vmLcm.cjs +125 -0
- package/dist/credentials-B70vmLcm.cjs.map +1 -0
- package/dist/credentials-s0wMeZBU.mjs +108 -0
- package/dist/credentials-s0wMeZBU.mjs.map +1 -0
- package/dist/{define-CHBIEc5j.mjs → define-CYs0PEfZ.mjs} +2 -3
- package/dist/define-CYs0PEfZ.mjs.map +1 -0
- package/dist/{define-Cv_QvDrg.cjs → define-zUsP72ym.cjs} +2 -3
- package/dist/define-zUsP72ym.cjs.map +1 -0
- package/dist/deploy/public.cjs +166 -14
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +224 -3
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +224 -3
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +141 -10
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/{deploy-DSaCYvcO.cjs → deploy-55rJkdKz.cjs} +17 -14
- package/dist/{deploy-DSaCYvcO.cjs.map → deploy-55rJkdKz.cjs.map} +1 -1
- package/dist/{deploy-Cg9fae7a.mjs → deploy-Dc2LBJaK.mjs} +13 -10
- package/dist/deploy-Dc2LBJaK.mjs.map +1 -0
- package/dist/{deploy-B7jvUORo.mjs → deploy-ZRXIPp1c.mjs} +11 -8
- package/dist/{deploy-B7jvUORo.mjs.map → deploy-ZRXIPp1c.mjs.map} +1 -1
- package/dist/{deploy-D8Qr-Xto.cjs → deploy-yUcR2OlW.cjs} +15 -12
- package/dist/deploy-yUcR2OlW.cjs.map +1 -0
- package/dist/derive-B4vDpzgP.mjs +150 -0
- package/dist/derive-B4vDpzgP.mjs.map +1 -0
- package/dist/derive-DAbo49sm.cjs +161 -0
- package/dist/derive-DAbo49sm.cjs.map +1 -0
- package/dist/discover-B6yPpvRV.d.mts +99 -0
- package/dist/discover-B6yPpvRV.d.mts.map +1 -0
- package/dist/discover-B_IkPukx.d.cts +99 -0
- package/dist/discover-B_IkPukx.d.cts.map +1 -0
- package/dist/{discover-Bc-4eA_p.cjs → discover-DHdECueV.cjs} +280 -1
- package/dist/discover-DHdECueV.cjs.map +1 -0
- package/dist/{discover-FrYvzkeC.mjs → discover-LMrqsWSU.mjs} +246 -3
- package/dist/discover-LMrqsWSU.mjs.map +1 -0
- package/dist/{dokploy-CD9PY-3D.mjs → dokploy-CepdXuMl.mjs} +3 -3
- package/dist/{dokploy-CD9PY-3D.mjs.map → dokploy-CepdXuMl.mjs.map} +1 -1
- package/dist/{dokploy-Ey2foJLv.cjs → dokploy-D1d37rvM.cjs} +3 -3
- package/dist/{dokploy-Ey2foJLv.cjs.map → dokploy-D1d37rvM.cjs.map} +1 -1
- package/dist/{encryption-ChBk3hTj.cjs → encryption-C9X98u2F.cjs} +5 -5
- package/dist/{encryption-ChBk3hTj.cjs.map → encryption-C9X98u2F.cjs.map} +1 -1
- package/dist/{encryption-CVwvGbsL.mjs → encryption-CKHjMpCr.mjs} +5 -5
- package/dist/{encryption-CVwvGbsL.mjs.map → encryption-CKHjMpCr.mjs.map} +1 -1
- package/dist/fakes-C9RiT6XG.mjs.map +1 -1
- package/dist/fakes-zW-jNAbQ.cjs.map +1 -1
- package/dist/{github-BCB3_LBX.mjs → github-D-byNI7T.mjs} +4 -4
- package/dist/{github-BCB3_LBX.mjs.map → github-D-byNI7T.mjs.map} +1 -1
- package/dist/{github-OUgPDlqg.cjs → github-Dd3tMa1u.cjs} +4 -4
- package/dist/{github-OUgPDlqg.cjs.map → github-Dd3tMa1u.cjs.map} +1 -1
- package/dist/{index-BtXDZQuF.d.cts → index-CJ2qsSpp.d.mts} +2 -2
- package/dist/{index-BtXDZQuF.d.cts.map → index-CJ2qsSpp.d.mts.map} +1 -1
- package/dist/{index-DrKzpHl-.d.mts → index-CfE9Y885.d.cts} +2 -2
- package/dist/{index-DrKzpHl-.d.mts.map → index-CfE9Y885.d.cts.map} +1 -1
- package/dist/index.cjs +111 -239
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +82 -210
- package/dist/index.mjs.map +1 -1
- package/dist/local-C7wnrcYK.cjs +586 -0
- package/dist/local-C7wnrcYK.cjs.map +1 -0
- package/dist/local-Cd8ZYQG3.mjs +473 -0
- package/dist/local-Cd8ZYQG3.mjs.map +1 -0
- package/dist/{migrate-BoHMqdCu.mjs → migrate-B4gngTLe.mjs} +6 -6
- package/dist/{migrate-BoHMqdCu.mjs.map → migrate-B4gngTLe.mjs.map} +1 -1
- package/dist/{migrate-dnaFMvOm.cjs → migrate-tx9-P9uz.cjs} +6 -6
- package/dist/{migrate-dnaFMvOm.cjs.map → migrate-tx9-P9uz.cjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/{ready-DQIy21W5.mjs → ready-bQfu9GES.mjs} +3 -3
- package/dist/{ready-DQIy21W5.mjs.map → ready-bQfu9GES.mjs.map} +1 -1
- package/dist/{ready-XlNx-Gbo.cjs → ready-brEhh68f.cjs} +3 -3
- package/dist/{ready-XlNx-Gbo.cjs.map → ready-brEhh68f.cjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +4 -77
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +4 -77
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-wbv66HjD.cjs → resolve-BXsNQjMR.cjs} +9 -6
- package/dist/resolve-BXsNQjMR.cjs.map +1 -0
- package/dist/{resolve-CFCIkm7m.mjs → resolve-DZ2IJ0qY.mjs} +9 -6
- package/dist/resolve-DZ2IJ0qY.mjs.map +1 -0
- package/dist/{runtime-CMwtq0AL.cjs → runtime-BGNDrHzh.cjs} +2 -2
- package/dist/{runtime-CMwtq0AL.cjs.map → runtime-BGNDrHzh.cjs.map} +1 -1
- package/dist/{runtime-Dn_n-29S.d.cts → runtime-CJEYK4Gz.d.mts} +2 -2
- package/dist/{runtime-CXPlkZzs.d.mts.map → runtime-CJEYK4Gz.d.mts.map} +1 -1
- package/dist/{runtime-CXPlkZzs.d.mts → runtime-Cjq1jlVX.d.cts} +2 -2
- package/dist/{runtime-Dn_n-29S.d.cts.map → runtime-Cjq1jlVX.d.cts.map} +1 -1
- package/dist/{runtime-DbakJS8u.mjs → runtime-Cmn-FeYO.mjs} +2 -2
- package/dist/{runtime-DbakJS8u.mjs.map → runtime-Cmn-FeYO.mjs.map} +1 -1
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +44 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +45 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox-CL--ZDui.cjs +164 -0
- package/dist/sandbox-CL--ZDui.cjs.map +1 -0
- package/dist/sandbox-Dm247NGx.mjs +117 -0
- package/dist/sandbox-Dm247NGx.mjs.map +1 -0
- package/dist/sandbox-M8UnLhXE.d.cts +126 -0
- package/dist/sandbox-M8UnLhXE.d.cts.map +1 -0
- package/dist/sandbox-M8UnLhXE.d.mts +126 -0
- package/dist/sandbox-M8UnLhXE.d.mts.map +1 -0
- package/dist/{workspace-BFe57es7.mjs → schemas-Ckm_aBnF.cjs} +71 -982
- package/dist/schemas-Ckm_aBnF.cjs.map +1 -0
- package/dist/{workspace-B6zQO6RY.cjs → schemas-D2LCF689.mjs} +2 -1168
- package/dist/schemas-D2LCF689.mjs.map +1 -0
- package/dist/{sniffer-DHE2Nafd.mjs → sniffer-49KPbDgq.mjs} +131 -444
- package/dist/sniffer-49KPbDgq.mjs.map +1 -0
- package/dist/{sniffer-BsfPa-GA.cjs → sniffer-ByhbEW5A.cjs} +145 -512
- package/dist/sniffer-ByhbEW5A.cjs.map +1 -0
- package/dist/sst-BdALKEas.cjs +453 -0
- package/dist/sst-BdALKEas.cjs.map +1 -0
- package/dist/sst-Cper040I.mjs +430 -0
- package/dist/sst-Cper040I.mjs.map +1 -0
- package/dist/{store-BS8A7NcA.mjs → store-BaaonhkJ.mjs} +2 -2
- package/dist/{store-BS8A7NcA.mjs.map → store-BaaonhkJ.mjs.map} +1 -1
- package/dist/{store-KvNQwYaB.cjs → store-D_2ByRtW.cjs} +4 -4
- package/dist/{store-KvNQwYaB.cjs.map → store-D_2ByRtW.cjs.map} +1 -1
- package/dist/target/public.cjs +3 -3
- package/dist/target/public.d.cts +3 -3
- package/dist/target/public.d.mts +3 -3
- package/dist/target/public.mjs +3 -3
- package/dist/{terminal-6oL0vANs.cjs → terminal-Bdv--jhY.cjs} +16 -111
- package/dist/terminal-Bdv--jhY.cjs.map +1 -0
- package/dist/{terminal-ByZNjuig.mjs → terminal-D7Ntz6WE.mjs} +13 -90
- package/dist/terminal-D7Ntz6WE.mjs.map +1 -0
- package/dist/{types-DIA7Li-J.d.cts → types-B_bEQvb9.d.mts} +42 -7
- package/dist/types-B_bEQvb9.d.mts.map +1 -0
- package/dist/{types-CfLKGfC_.d.mts → types-DkrDOMxw.d.cts} +43 -6
- package/dist/types-DkrDOMxw.d.cts.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +2 -2
- package/dist/vitest.mjs +2 -2
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- 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-BwgWJK7h.cjs +1196 -0
- package/dist/workspace-BwgWJK7h.cjs.map +1 -0
- package/dist/workspace-Bwit4q9O.mjs +1024 -0
- package/dist/workspace-Bwit4q9O.mjs.map +1 -0
- package/package.json +13 -13
- package/dist/config-BYh9S0cZ.cjs +0 -534
- package/dist/config-BYh9S0cZ.cjs.map +0 -1
- package/dist/config-Bf4-bROQ.mjs +0 -457
- package/dist/config-Bf4-bROQ.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/define-CHBIEc5j.mjs.map +0 -1
- package/dist/define-Cv_QvDrg.cjs.map +0 -1
- package/dist/deploy-Cg9fae7a.mjs.map +0 -1
- package/dist/deploy-D8Qr-Xto.cjs.map +0 -1
- package/dist/discover-Bc-4eA_p.cjs.map +0 -1
- package/dist/discover-FrYvzkeC.mjs.map +0 -1
- package/dist/home-DOzBaWaL.cjs +0 -33
- package/dist/home-DOzBaWaL.cjs.map +0 -1
- package/dist/home-GI7pJl1M.mjs +0 -22
- package/dist/home-GI7pJl1M.mjs.map +0 -1
- package/dist/resolve-CFCIkm7m.mjs.map +0 -1
- package/dist/resolve-wbv66HjD.cjs.map +0 -1
- package/dist/sniffer-BsfPa-GA.cjs.map +0 -1
- package/dist/sniffer-DHE2Nafd.mjs.map +0 -1
- package/dist/terminal-6oL0vANs.cjs.map +0 -1
- package/dist/terminal-ByZNjuig.mjs.map +0 -1
- package/dist/types-CfLKGfC_.d.mts.map +0 -1
- package/dist/types-DIA7Li-J.d.cts.map +0 -1
- package/dist/workspace-B6zQO6RY.cjs.map +0 -1
- package/dist/workspace-BFe57es7.mjs.map +0 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const require_define = require("./define-Cv_QvDrg.cjs");
|
|
2
|
-
let node_path = require("node:path");
|
|
3
1
|
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
|
|
4
2
|
function getEnumValues(entries) {
|
|
5
3
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
@@ -5756,1170 +5754,6 @@ function superRefine(fn, params) {
|
|
|
5756
5754
|
return /* @__PURE__ */ _superRefine(fn, params);
|
|
5757
5755
|
}
|
|
5758
5756
|
//#endregion
|
|
5759
|
-
|
|
5760
|
-
/**
|
|
5761
|
-
* What `gkm test` runs as. The CLI's own, so no project stage may take it:
|
|
5762
|
-
* its containers are torn down and rebuilt between runs.
|
|
5763
|
-
*/
|
|
5764
|
-
const TEST_STAGE = "test";
|
|
5765
|
-
/** A stage becomes part of every physical name, so it has to fit in one. */
|
|
5766
|
-
const STAGE_NAME = /^[a-z][a-z0-9-]*$/;
|
|
5767
|
-
/** Everything wrong with one stage name, or nothing. */
|
|
5768
|
-
function nameProblems(name) {
|
|
5769
|
-
const problems = [];
|
|
5770
|
-
if (!STAGE_NAME.test(name)) problems.push(`stage "${name}" must be lowercase letters, digits and hyphens, starting with a letter`);
|
|
5771
|
-
if (name === "test") problems.push(`stage "${TEST_STAGE}" is reserved for gkm test`);
|
|
5772
|
-
return problems;
|
|
5773
|
-
}
|
|
5774
|
-
/** Everything wrong with a list of deployed stages on its own. */
|
|
5775
|
-
function deployedProblems(deployed) {
|
|
5776
|
-
const problems = deployed.flatMap(nameProblems);
|
|
5777
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5778
|
-
for (const name of deployed) {
|
|
5779
|
-
if (seen.has(name)) problems.push(`stage "${name}" is listed twice`);
|
|
5780
|
-
seen.add(name);
|
|
5781
|
-
}
|
|
5782
|
-
return problems;
|
|
5783
|
-
}
|
|
5784
|
-
/** Everything wrong with a stages block, or nothing. */
|
|
5785
|
-
function stageProblems(stages) {
|
|
5786
|
-
if (!stages) return ["`stages` is required, e.g. stages: { local: 'dev', deployed: ['prod'] }"];
|
|
5787
|
-
const { local, deployed, protected: kept = [] } = stages;
|
|
5788
|
-
const problems = [...nameProblems(local), ...deployedProblems(deployed)];
|
|
5789
|
-
if (deployed.includes(local)) problems.push(`"${local}" is both the local stage and a deployed one; they would share secrets`);
|
|
5790
|
-
for (const name of kept) if (!deployed.includes(name)) problems.push(`protected stage "${name}" is not a deployed stage`);
|
|
5791
|
-
return problems;
|
|
5792
|
-
}
|
|
5793
|
-
/** The stages block, or an error naming everything wrong with it. */
|
|
5794
|
-
function validateStages(stages) {
|
|
5795
|
-
const problems = stageProblems(stages);
|
|
5796
|
-
if (problems.length) throw new InvalidStages(problems);
|
|
5797
|
-
return stages;
|
|
5798
|
-
}
|
|
5799
|
-
/** Refuses a stage the project does not deploy to. */
|
|
5800
|
-
function assertDeployedStage(stages, stage) {
|
|
5801
|
-
if (!stages.deployed.includes(stage)) throw new UndeclaredStage(stage, stages.deployed);
|
|
5802
|
-
}
|
|
5803
|
-
/** A stages block — in gkm.config.ts or from `gkm init`'s flags — that breaks a rule. */
|
|
5804
|
-
var InvalidStages = class extends Error {
|
|
5805
|
-
problems;
|
|
5806
|
-
constructor(problems) {
|
|
5807
|
-
super(`Invalid stages:\n ${problems.join("\n ")}`);
|
|
5808
|
-
this.problems = problems;
|
|
5809
|
-
this.name = "InvalidStages";
|
|
5810
|
-
}
|
|
5811
|
-
};
|
|
5812
|
-
/**
|
|
5813
|
-
* A stage the project does not deploy to. Refused before anything is
|
|
5814
|
-
* provisioned, so a typo does not become a second environment.
|
|
5815
|
-
*/
|
|
5816
|
-
var UndeclaredStage = class extends Error {
|
|
5817
|
-
stage;
|
|
5818
|
-
deployed;
|
|
5819
|
-
constructor(stage, deployed) {
|
|
5820
|
-
super(`"${stage}" is not a deployed stage. gkm.config.ts deploys to: ${deployed.join(", ") || "nothing yet"}.`);
|
|
5821
|
-
this.stage = stage;
|
|
5822
|
-
this.deployed = deployed;
|
|
5823
|
-
this.name = "UndeclaredStage";
|
|
5824
|
-
}
|
|
5825
|
-
};
|
|
5826
|
-
//#endregion
|
|
5827
|
-
//#region src/workspace/schema.ts
|
|
5828
|
-
/** Routes are a glob, or a list of them. */
|
|
5829
|
-
const RoutesSchema = union([string(), array(string())]);
|
|
5830
|
-
/**
|
|
5831
|
-
* Telescope configuration schema.
|
|
5832
|
-
*/
|
|
5833
|
-
const TelescopeConfigSchema = object({
|
|
5834
|
-
enabled: boolean().optional(),
|
|
5835
|
-
port: number().optional(),
|
|
5836
|
-
path: string().optional(),
|
|
5837
|
-
ignore: array(string()).optional(),
|
|
5838
|
-
recordBody: boolean().optional(),
|
|
5839
|
-
maxEntries: number().optional(),
|
|
5840
|
-
websocket: boolean().optional()
|
|
5841
|
-
});
|
|
5842
|
-
/**
|
|
5843
|
-
* OpenAPI configuration schema.
|
|
5844
|
-
*/
|
|
5845
|
-
const OpenApiConfigSchema = object({
|
|
5846
|
-
enabled: boolean().optional(),
|
|
5847
|
-
title: string().optional(),
|
|
5848
|
-
version: string().optional(),
|
|
5849
|
-
description: string().optional()
|
|
5850
|
-
});
|
|
5851
|
-
/**
|
|
5852
|
-
* Hooks configuration schema.
|
|
5853
|
-
*/
|
|
5854
|
-
const HooksConfigSchema = object({ server: string().optional() });
|
|
5855
|
-
/**
|
|
5856
|
-
* Combined framework schema (backend, frontend, or mobile).
|
|
5857
|
-
*/
|
|
5858
|
-
const FrameworkSchema = union([
|
|
5859
|
-
_enum([
|
|
5860
|
-
"hono",
|
|
5861
|
-
"better-auth",
|
|
5862
|
-
"express",
|
|
5863
|
-
"fastify"
|
|
5864
|
-
]),
|
|
5865
|
-
_enum([
|
|
5866
|
-
"nextjs",
|
|
5867
|
-
"remix",
|
|
5868
|
-
"vite",
|
|
5869
|
-
"tanstack-start"
|
|
5870
|
-
]),
|
|
5871
|
-
_enum(["expo"])
|
|
5872
|
-
]);
|
|
5873
|
-
/** Frontend framework values, kept in sync with FrontendFrameworkSchema. */
|
|
5874
|
-
const FRONTEND_FRAMEWORKS = [
|
|
5875
|
-
"nextjs",
|
|
5876
|
-
"remix",
|
|
5877
|
-
"vite",
|
|
5878
|
-
"tanstack-start"
|
|
5879
|
-
];
|
|
5880
|
-
/** Mobile framework values, kept in sync with MobileFrameworkSchema. */
|
|
5881
|
-
const MOBILE_FRAMEWORKS = ["expo"];
|
|
5882
|
-
/**
|
|
5883
|
-
* A deploy target's name. Which names exist is the workspace's to say — the
|
|
5884
|
-
* built-ins and its own `deploy.targets` — so it is checked against both
|
|
5885
|
-
* once the whole config is read.
|
|
5886
|
-
*/
|
|
5887
|
-
const DeployTargetSchema = string().min(1);
|
|
5888
|
-
/**
|
|
5889
|
-
* The built-in targets a config may name: `dokploy`, deployed by
|
|
5890
|
-
* `gkm deploy`, and `sst`, deployed by `sst deploy` from the manifest
|
|
5891
|
-
* `gkm build` writes.
|
|
5892
|
-
*/
|
|
5893
|
-
const SUPPORTED_DEPLOY_TARGETS = require_define.configurableBuiltins();
|
|
5894
|
-
/** Built-in names reserved for targets that do not exist yet. */
|
|
5895
|
-
const PHASE_2_DEPLOY_TARGETS = Object.entries(require_define.BUILTIN_TARGETS).filter(([, target]) => target.status === "planned").map(([name]) => name);
|
|
5896
|
-
/**
|
|
5897
|
-
* Whether a config may name `target`: a usable built-in, or one of its own
|
|
5898
|
-
* `deploy.targets`.
|
|
5899
|
-
*/
|
|
5900
|
-
function isDeployTargetSupported(target, targets = {}) {
|
|
5901
|
-
return SUPPORTED_DEPLOY_TARGETS.includes(target) || Object.hasOwn(targets, target);
|
|
5902
|
-
}
|
|
5903
|
-
/**
|
|
5904
|
-
* Check if a deploy target is planned for Phase 2.
|
|
5905
|
-
*/
|
|
5906
|
-
function isPhase2DeployTarget(target) {
|
|
5907
|
-
return PHASE_2_DEPLOY_TARGETS.includes(target);
|
|
5908
|
-
}
|
|
5909
|
-
/**
|
|
5910
|
-
* Get error message for unsupported deploy targets.
|
|
5911
|
-
*/
|
|
5912
|
-
function getDeployTargetError(target, appName) {
|
|
5913
|
-
if (isPhase2DeployTarget(target)) return `Deploy target "${target}"${appName ? ` for app "${appName}"` : ""} is coming in Phase 2. Currently "dokploy" and "sst" are supported.`;
|
|
5914
|
-
return `Unknown deploy target: ${target}. Built in: ${SUPPORTED_DEPLOY_TARGETS.join(", ")}; any other is named in deploy.targets with the package that provides it. Coming in Phase 2: ${PHASE_2_DEPLOY_TARGETS.join(", ")}.`;
|
|
5915
|
-
}
|
|
5916
|
-
/**
|
|
5917
|
-
* One `deploy.targets` entry: a package name, a target object, or either
|
|
5918
|
-
* with options.
|
|
5919
|
-
*/
|
|
5920
|
-
const DeployTargetEntrySchema = union([
|
|
5921
|
-
string().min(1, "A target package name cannot be empty"),
|
|
5922
|
-
custom((value) => require_define.isDeployTarget(value), { message: "Expected a package name, a target (defineTarget), or [package or target, options]" }),
|
|
5923
|
-
tuple([union([string().min(1), custom((value) => require_define.isDeployTarget(value), { message: "Expected a package name or a target (defineTarget)" })]), unknown()])
|
|
5924
|
-
]);
|
|
5925
|
-
/**
|
|
5926
|
-
* Dokploy workspace configuration schema.
|
|
5927
|
-
* Supports either a single endpoint or per-stage endpoints.
|
|
5928
|
-
*/
|
|
5929
|
-
const DokployWorkspaceConfigSchema = object({
|
|
5930
|
-
/** Single endpoint for all stages */
|
|
5931
|
-
endpoint: url("Dokploy endpoint must be a valid URL").optional(),
|
|
5932
|
-
/** Per-stage endpoints (stage name -> endpoint URL) */
|
|
5933
|
-
endpoints: record(string(), url("Endpoint must be a valid URL")).optional(),
|
|
5934
|
-
registry: string().optional(),
|
|
5935
|
-
registryId: string().optional()
|
|
5936
|
-
}).refine((data) => data.endpoint || data.endpoints, { message: "Either endpoint or endpoints must be provided" });
|
|
5937
|
-
/**
|
|
5938
|
-
* Valid AWS regions.
|
|
5939
|
-
*/
|
|
5940
|
-
const AwsRegionSchema = _enum([
|
|
5941
|
-
"us-east-1",
|
|
5942
|
-
"us-east-2",
|
|
5943
|
-
"us-west-1",
|
|
5944
|
-
"us-west-2",
|
|
5945
|
-
"af-south-1",
|
|
5946
|
-
"ap-east-1",
|
|
5947
|
-
"ap-south-1",
|
|
5948
|
-
"ap-south-2",
|
|
5949
|
-
"ap-southeast-1",
|
|
5950
|
-
"ap-southeast-2",
|
|
5951
|
-
"ap-southeast-3",
|
|
5952
|
-
"ap-southeast-4",
|
|
5953
|
-
"ap-northeast-1",
|
|
5954
|
-
"ap-northeast-2",
|
|
5955
|
-
"ap-northeast-3",
|
|
5956
|
-
"ca-central-1",
|
|
5957
|
-
"eu-central-1",
|
|
5958
|
-
"eu-central-2",
|
|
5959
|
-
"eu-west-1",
|
|
5960
|
-
"eu-west-2",
|
|
5961
|
-
"eu-west-3",
|
|
5962
|
-
"eu-south-1",
|
|
5963
|
-
"eu-south-2",
|
|
5964
|
-
"eu-north-1",
|
|
5965
|
-
"me-south-1",
|
|
5966
|
-
"me-central-1",
|
|
5967
|
-
"sa-east-1"
|
|
5968
|
-
]);
|
|
5969
|
-
/**
|
|
5970
|
-
* DNS record types supported across providers.
|
|
5971
|
-
*/
|
|
5972
|
-
const DnsRecordTypeSchema = _enum([
|
|
5973
|
-
"A",
|
|
5974
|
-
"AAAA",
|
|
5975
|
-
"CNAME",
|
|
5976
|
-
"MX",
|
|
5977
|
-
"TXT",
|
|
5978
|
-
"NS",
|
|
5979
|
-
"SRV",
|
|
5980
|
-
"CAA"
|
|
5981
|
-
]);
|
|
5982
|
-
object({
|
|
5983
|
-
/** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
|
|
5984
|
-
name: string(),
|
|
5985
|
-
/** Record type */
|
|
5986
|
-
type: DnsRecordTypeSchema,
|
|
5987
|
-
/** TTL in seconds */
|
|
5988
|
-
ttl: number().int().positive(),
|
|
5989
|
-
/** Record values */
|
|
5990
|
-
values: array(string())
|
|
5991
|
-
});
|
|
5992
|
-
object({
|
|
5993
|
-
/** The record that was upserted */
|
|
5994
|
-
record: object({
|
|
5995
|
-
/** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
|
|
5996
|
-
name: string(),
|
|
5997
|
-
/** Record type */
|
|
5998
|
-
type: DnsRecordTypeSchema,
|
|
5999
|
-
/** TTL in seconds */
|
|
6000
|
-
ttl: number().int().positive(),
|
|
6001
|
-
/** Record value (IP address, hostname, etc.) */
|
|
6002
|
-
value: string()
|
|
6003
|
-
}),
|
|
6004
|
-
/** Whether the record was created (true) or updated (false) */
|
|
6005
|
-
created: boolean(),
|
|
6006
|
-
/** Whether the record already existed with the same value */
|
|
6007
|
-
unchanged: boolean()
|
|
6008
|
-
});
|
|
6009
|
-
/**
|
|
6010
|
-
* Hostinger DNS provider config (without domain - domain is the record key).
|
|
6011
|
-
*/
|
|
6012
|
-
const HostingerDnsProviderSchema = object({
|
|
6013
|
-
provider: literal("hostinger"),
|
|
6014
|
-
/** TTL in seconds (default: 300) */
|
|
6015
|
-
ttl: number().int().positive().optional()
|
|
6016
|
-
});
|
|
6017
|
-
/**
|
|
6018
|
-
* Route53 DNS provider config (without domain - domain is the record key).
|
|
6019
|
-
*/
|
|
6020
|
-
const Route53DnsProviderSchema = object({
|
|
6021
|
-
provider: literal("route53"),
|
|
6022
|
-
/** AWS region (optional - uses AWS_REGION env var if not provided) */
|
|
6023
|
-
region: AwsRegionSchema.optional(),
|
|
6024
|
-
/** AWS profile name (optional - uses default credential chain if not provided) */
|
|
6025
|
-
profile: string().optional(),
|
|
6026
|
-
/** Hosted zone ID (optional - auto-detected from domain if not provided) */
|
|
6027
|
-
hostedZoneId: string().optional(),
|
|
6028
|
-
/** TTL in seconds (default: 300) */
|
|
6029
|
-
ttl: number().int().positive().optional()
|
|
6030
|
-
});
|
|
6031
|
-
/**
|
|
6032
|
-
* Cloudflare DNS provider config (placeholder for future).
|
|
6033
|
-
*/
|
|
6034
|
-
const CloudflareDnsProviderSchema = object({
|
|
6035
|
-
provider: literal("cloudflare"),
|
|
6036
|
-
/** TTL in seconds (default: 300) */
|
|
6037
|
-
ttl: number().int().positive().optional()
|
|
6038
|
-
});
|
|
6039
|
-
/**
|
|
6040
|
-
* Manual DNS configuration (user handles DNS themselves).
|
|
6041
|
-
*/
|
|
6042
|
-
const ManualDnsProviderSchema = object({ provider: literal("manual") });
|
|
6043
|
-
/**
|
|
6044
|
-
* Custom DNS provider config (user-provided implementation).
|
|
6045
|
-
*/
|
|
6046
|
-
const CustomDnsProviderSchema = object({
|
|
6047
|
-
/** Custom DnsProvider implementation */
|
|
6048
|
-
provider: custom((val) => typeof val === "object" && val !== null && typeof val.name === "string" && typeof val.getRecords === "function" && typeof val.upsertRecords === "function", { message: "Custom DNS provider must implement name, getRecords(), and upsertRecords() methods" }),
|
|
6049
|
-
/** TTL in seconds (default: 300) */
|
|
6050
|
-
ttl: number().int().positive().optional()
|
|
6051
|
-
});
|
|
6052
|
-
/**
|
|
6053
|
-
* Single DNS provider config (for one domain).
|
|
6054
|
-
*/
|
|
6055
|
-
const DnsProviderSchema = union([discriminatedUnion("provider", [
|
|
6056
|
-
HostingerDnsProviderSchema,
|
|
6057
|
-
Route53DnsProviderSchema,
|
|
6058
|
-
CloudflareDnsProviderSchema,
|
|
6059
|
-
ManualDnsProviderSchema
|
|
6060
|
-
]), CustomDnsProviderSchema]);
|
|
6061
|
-
/**
|
|
6062
|
-
* DNS configuration schema.
|
|
6063
|
-
*
|
|
6064
|
-
* Maps root domains to their DNS provider configuration.
|
|
6065
|
-
* Example:
|
|
6066
|
-
* ```
|
|
6067
|
-
* dns: {
|
|
6068
|
-
* 'geekmidas.dev': { provider: 'hostinger' },
|
|
6069
|
-
* 'geekmidas.com': { provider: 'route53' },
|
|
6070
|
-
* }
|
|
6071
|
-
* ```
|
|
6072
|
-
*
|
|
6073
|
-
* Supported providers:
|
|
6074
|
-
* - 'hostinger': Use Hostinger DNS API
|
|
6075
|
-
* - 'route53': Use AWS Route53
|
|
6076
|
-
* - 'cloudflare': Use Cloudflare DNS API (future)
|
|
6077
|
-
* - 'manual': Don't create records, just print required records
|
|
6078
|
-
* - Custom: Provide a DnsProvider implementation
|
|
6079
|
-
*/
|
|
6080
|
-
const DnsConfigSchema = record(string(), DnsProviderSchema);
|
|
6081
|
-
const HostingerDnsConfigSchema = HostingerDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
|
|
6082
|
-
const Route53DnsConfigSchema = Route53DnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
|
|
6083
|
-
const CloudflareDnsConfigSchema = CloudflareDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
|
|
6084
|
-
const ManualDnsConfigSchema = ManualDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
|
|
6085
|
-
const CustomDnsConfigSchema = CustomDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
|
|
6086
|
-
/**
|
|
6087
|
-
* Combined DNS config that supports both new multi-domain and legacy single-domain formats.
|
|
6088
|
-
*/
|
|
6089
|
-
const DnsConfigWithLegacySchema = union([DnsConfigSchema, union([discriminatedUnion("provider", [
|
|
6090
|
-
HostingerDnsConfigSchema,
|
|
6091
|
-
Route53DnsConfigSchema,
|
|
6092
|
-
CloudflareDnsConfigSchema,
|
|
6093
|
-
ManualDnsConfigSchema
|
|
6094
|
-
]), CustomDnsConfigSchema])]);
|
|
6095
|
-
/**
|
|
6096
|
-
* Backups configuration schema.
|
|
6097
|
-
*
|
|
6098
|
-
* Configures automatic backup destinations for database services.
|
|
6099
|
-
* On first deploy, creates S3 bucket with unique name and IAM credentials.
|
|
6100
|
-
*/
|
|
6101
|
-
const BackupsConfigSchema = object({
|
|
6102
|
-
/** Backup storage type (currently only 's3' supported) */
|
|
6103
|
-
type: literal("s3"),
|
|
6104
|
-
/** AWS profile name for creating bucket/IAM resources */
|
|
6105
|
-
profile: string().optional(),
|
|
6106
|
-
/** AWS region for the backup bucket */
|
|
6107
|
-
region: AwsRegionSchema,
|
|
6108
|
-
/** Cron schedule for backups (default: '0 2 * * *' = 2 AM daily) */
|
|
6109
|
-
schedule: string().optional(),
|
|
6110
|
-
/** Number of backups to retain (default: 30) */
|
|
6111
|
-
retention: number().optional()
|
|
6112
|
-
});
|
|
6113
|
-
/**
|
|
6114
|
-
* Deploy configuration schema.
|
|
6115
|
-
*/
|
|
6116
|
-
const DeployConfigSchema = object({
|
|
6117
|
-
default: DeployTargetSchema.optional(),
|
|
6118
|
-
targets: record(string(), DeployTargetEntrySchema).superRefine((targets, ctx) => {
|
|
6119
|
-
for (const name of Object.keys(targets)) if (require_define.builtinTarget(name)) ctx.addIssue({
|
|
6120
|
-
code: "custom",
|
|
6121
|
-
message: `"${name}" is a built-in target; give this one a name of its own`,
|
|
6122
|
-
path: [name]
|
|
6123
|
-
});
|
|
6124
|
-
}).optional(),
|
|
6125
|
-
/** Whose deploy this is, on a target shared with other workspaces. */
|
|
6126
|
-
namespace: string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "deploy.namespace must be lowercase letters and digits with single '-' between them").optional(),
|
|
6127
|
-
/** Each deployed stage's base domain (stage name -> domain). */
|
|
6128
|
-
domains: record(string(), string()).optional(),
|
|
6129
|
-
dokploy: DokployWorkspaceConfigSchema.optional(),
|
|
6130
|
-
dns: DnsConfigWithLegacySchema.optional(),
|
|
6131
|
-
backups: BackupsConfigSchema.optional()
|
|
6132
|
-
});
|
|
6133
|
-
/**
|
|
6134
|
-
* Models configuration schema.
|
|
6135
|
-
*/
|
|
6136
|
-
const ModelsConfigSchema = object({
|
|
6137
|
-
path: string().optional(),
|
|
6138
|
-
schema: _enum(["zod"]).optional()
|
|
6139
|
-
});
|
|
6140
|
-
/**
|
|
6141
|
-
* Shared configuration schema.
|
|
6142
|
-
*/
|
|
6143
|
-
const SharedConfigSchema = object({
|
|
6144
|
-
packages: array(string()).optional(),
|
|
6145
|
-
models: ModelsConfigSchema.optional()
|
|
6146
|
-
});
|
|
6147
|
-
/**
|
|
6148
|
-
* Secrets configuration schema.
|
|
6149
|
-
*/
|
|
6150
|
-
const StagesConfigSchema = object({
|
|
6151
|
-
local: string(),
|
|
6152
|
-
deployed: array(string()),
|
|
6153
|
-
protected: array(string()).optional()
|
|
6154
|
-
}).superRefine((stages, ctx) => {
|
|
6155
|
-
for (const message of stageProblems(stages)) ctx.addIssue({
|
|
6156
|
-
code: "custom",
|
|
6157
|
-
message
|
|
6158
|
-
});
|
|
6159
|
-
});
|
|
6160
|
-
const SecretsStoreSchema = union([
|
|
6161
|
-
literal("file"),
|
|
6162
|
-
object({
|
|
6163
|
-
provider: literal("ssm"),
|
|
6164
|
-
region: AwsRegionSchema
|
|
6165
|
-
}).strict(),
|
|
6166
|
-
object({
|
|
6167
|
-
/** Any backend: an object implementing SecretsStore */
|
|
6168
|
-
provider: custom((val) => typeof val === "object" && val !== null && typeof val.name === "string" && typeof val.read === "function" && typeof val.write === "function", { message: "a secrets store has a name, read() and write()" }) })
|
|
6169
|
-
]);
|
|
6170
|
-
const SecretsConfigSchema = object({
|
|
6171
|
-
enabled: boolean().optional(),
|
|
6172
|
-
store: SecretsStoreSchema.optional(),
|
|
6173
|
-
algorithm: string().optional(),
|
|
6174
|
-
kdf: _enum(["scrypt", "pbkdf2"]).optional()
|
|
6175
|
-
});
|
|
6176
|
-
/**
|
|
6177
|
-
* Local state provider config.
|
|
6178
|
-
*/
|
|
6179
|
-
const LocalStateConfigSchema = object({ provider: literal("local") });
|
|
6180
|
-
/**
|
|
6181
|
-
* SSM state provider config (requires region).
|
|
6182
|
-
*/
|
|
6183
|
-
const SSMStateConfigSchema = object({
|
|
6184
|
-
provider: literal("ssm"),
|
|
6185
|
-
/** AWS region (required for SSM provider) */
|
|
6186
|
-
region: AwsRegionSchema,
|
|
6187
|
-
/** AWS profile name (optional - uses default credential chain if not provided) */
|
|
6188
|
-
profile: string().optional()
|
|
6189
|
-
});
|
|
6190
|
-
/**
|
|
6191
|
-
* S3 state provider config: conditional writes and a lock object in a bucket.
|
|
6192
|
-
*/
|
|
6193
|
-
const S3StateConfigSchema = object({
|
|
6194
|
-
provider: literal("s3"),
|
|
6195
|
-
/** Bucket the state lives in (must already exist) */
|
|
6196
|
-
bucket: string().min(1),
|
|
6197
|
-
/** AWS region of the bucket */
|
|
6198
|
-
region: AwsRegionSchema,
|
|
6199
|
-
/** Key prefix inside the bucket (default: 'gkm') */
|
|
6200
|
-
prefix: string().optional(),
|
|
6201
|
-
/** AWS profile name (optional - uses default credential chain if not provided) */
|
|
6202
|
-
profile: string().optional()
|
|
6203
|
-
});
|
|
6204
|
-
/**
|
|
6205
|
-
* Custom state provider config (user-provided implementation).
|
|
6206
|
-
*/
|
|
6207
|
-
const CustomStateConfigSchema = object({
|
|
6208
|
-
/** Custom StateProvider implementation */
|
|
6209
|
-
provider: custom((val) => typeof val === "object" && val !== null && typeof val.read === "function" && typeof val.write === "function", { message: "Custom provider must implement read() and write() methods" }) });
|
|
6210
|
-
/**
|
|
6211
|
-
* State configuration schema.
|
|
6212
|
-
*
|
|
6213
|
-
* Configures how deployment state is stored.
|
|
6214
|
-
* - 'local': Store in .gkm/deploy-{stage}.json (default)
|
|
6215
|
-
* - 'ssm': Store in AWS SSM Parameter Store (requires region)
|
|
6216
|
-
* - 's3': Store in an S3 bucket with conditional writes (requires bucket, region)
|
|
6217
|
-
* - Custom: Provide a StateStore, or a StateProvider with read/write methods
|
|
6218
|
-
*/
|
|
6219
|
-
const StateConfigSchema = union([discriminatedUnion("provider", [
|
|
6220
|
-
LocalStateConfigSchema,
|
|
6221
|
-
SSMStateConfigSchema,
|
|
6222
|
-
S3StateConfigSchema
|
|
6223
|
-
]), CustomStateConfigSchema]);
|
|
6224
|
-
/**
|
|
6225
|
-
* App configuration schema.
|
|
6226
|
-
*/
|
|
6227
|
-
const AppConfigSchema = object({
|
|
6228
|
-
type: _enum([
|
|
6229
|
-
"backend",
|
|
6230
|
-
"web",
|
|
6231
|
-
"mobile"
|
|
6232
|
-
]).optional().default("backend"),
|
|
6233
|
-
path: string().min(1, "App path is required"),
|
|
6234
|
-
port: number().int().positive("Port must be a positive integer"),
|
|
6235
|
-
dependencies: array(string()).optional(),
|
|
6236
|
-
deploy: DeployTargetSchema.optional(),
|
|
6237
|
-
constructs: RoutesSchema.optional(),
|
|
6238
|
-
routes: RoutesSchema.optional(),
|
|
6239
|
-
functions: RoutesSchema.optional(),
|
|
6240
|
-
crons: RoutesSchema.optional(),
|
|
6241
|
-
queues: RoutesSchema.optional(),
|
|
6242
|
-
topics: RoutesSchema.optional(),
|
|
6243
|
-
subscribers: RoutesSchema.optional(),
|
|
6244
|
-
envParser: string().optional(),
|
|
6245
|
-
logger: string().optional(),
|
|
6246
|
-
hooks: HooksConfigSchema.optional(),
|
|
6247
|
-
telescope: union([
|
|
6248
|
-
string(),
|
|
6249
|
-
boolean(),
|
|
6250
|
-
TelescopeConfigSchema
|
|
6251
|
-
]).optional(),
|
|
6252
|
-
openapi: union([boolean(), OpenApiConfigSchema]).optional(),
|
|
6253
|
-
runtime: _enum(["node", "bun"]).optional(),
|
|
6254
|
-
env: union([string(), array(string())]).optional(),
|
|
6255
|
-
entry: string().optional(),
|
|
6256
|
-
framework: FrameworkSchema.optional(),
|
|
6257
|
-
config: object({
|
|
6258
|
-
client: string().optional(),
|
|
6259
|
-
server: string().optional()
|
|
6260
|
-
}).optional()
|
|
6261
|
-
}).refine((data) => {
|
|
6262
|
-
if (data.type === "web") {
|
|
6263
|
-
if (!data.framework || !FRONTEND_FRAMEWORKS.includes(data.framework)) return false;
|
|
6264
|
-
}
|
|
6265
|
-
return true;
|
|
6266
|
-
}, {
|
|
6267
|
-
message: `Web apps must have a valid web framework (${FRONTEND_FRAMEWORKS.join(", ")})`,
|
|
6268
|
-
path: ["framework"]
|
|
6269
|
-
}).refine((data) => {
|
|
6270
|
-
if (data.type === "mobile") {
|
|
6271
|
-
if (!data.framework || !MOBILE_FRAMEWORKS.includes(data.framework)) return false;
|
|
6272
|
-
}
|
|
6273
|
-
return true;
|
|
6274
|
-
}, {
|
|
6275
|
-
message: `Mobile apps must have a valid mobile framework (${MOBILE_FRAMEWORKS.join(", ")})`,
|
|
6276
|
-
path: ["framework"]
|
|
6277
|
-
});
|
|
6278
|
-
/** What `gkm test` hands a feature test. */
|
|
6279
|
-
const TestConfigSchema = object({
|
|
6280
|
-
/** The folder of per-database factories; `test/factories` by default. */
|
|
6281
|
-
factories: string().optional() }).strict();
|
|
6282
|
-
/** How `gkm dev` is reached from outside the apps it runs. */
|
|
6283
|
-
const DevConfigSchema = object({
|
|
6284
|
-
/** Browser origins that may read the discovery endpoint. */
|
|
6285
|
-
allowedOrigins: array(url().refine((value) => URL.canParse(value) && new URL(value).origin === value, { message: "An origin is a scheme, host and port only, e.g. https://console.example.com — no path or trailing slash" })).optional(),
|
|
6286
|
-
/** The discovery endpoint's loopback port; 4983 by default. */
|
|
6287
|
-
discoveryPort: number().int().min(0).max(65535).optional()
|
|
6288
|
-
}).strict();
|
|
6289
|
-
/**
|
|
6290
|
-
* Workspace configuration schema.
|
|
6291
|
-
*/
|
|
6292
|
-
const WorkspaceConfigSchema = object({
|
|
6293
|
-
name: string().optional(),
|
|
6294
|
-
/**
|
|
6295
|
-
* Where the workspace's own constructs live, relative to its root.
|
|
6296
|
-
*
|
|
6297
|
-
* Infrastructure is a fact about the product, not about the process that
|
|
6298
|
-
* happens to import it — so a database two apps share is declared once,
|
|
6299
|
-
* at the top, and both find it. An app-level glob still works and is
|
|
6300
|
-
* additive, for something only one app uses.
|
|
6301
|
-
*/
|
|
6302
|
-
constructs: RoutesSchema.optional(),
|
|
6303
|
-
/**
|
|
6304
|
-
* Apps that nothing declares.
|
|
6305
|
-
*
|
|
6306
|
-
* Optional, and normally absent: a `site` is an app and so is a
|
|
6307
|
-
* `rest-api` that named one, so the list is read off the graph. This is
|
|
6308
|
-
* the escape hatch for what no construct describes — a mobile app, a
|
|
6309
|
-
* process someone runs by hand — and for overriding one field of a
|
|
6310
|
-
* derived app without restating it.
|
|
6311
|
-
*/
|
|
6312
|
-
apps: record(string(), AppConfigSchema).optional(),
|
|
6313
|
-
shared: SharedConfigSchema.optional(),
|
|
6314
|
-
deploy: DeployConfigSchema.optional(),
|
|
6315
|
-
stages: StagesConfigSchema,
|
|
6316
|
-
secrets: SecretsConfigSchema.optional(),
|
|
6317
|
-
state: StateConfigSchema.optional(),
|
|
6318
|
-
test: TestConfigSchema.optional(),
|
|
6319
|
-
dev: DevConfigSchema.optional()
|
|
6320
|
-
}).strict().refine((data) => {
|
|
6321
|
-
const appNames = Object.keys(data.apps ?? {});
|
|
6322
|
-
for (const [appName, app] of Object.entries(data.apps ?? {})) for (const dep of app.dependencies ?? []) {
|
|
6323
|
-
if (!appNames.includes(dep)) return false;
|
|
6324
|
-
if (dep === appName) return false;
|
|
6325
|
-
}
|
|
6326
|
-
return true;
|
|
6327
|
-
}, { message: "App dependencies must reference existing apps and cannot be self-referential" }).refine((data) => {
|
|
6328
|
-
const appNames = Object.keys(data.apps ?? {});
|
|
6329
|
-
const visited = /* @__PURE__ */ new Set();
|
|
6330
|
-
const recStack = /* @__PURE__ */ new Set();
|
|
6331
|
-
function hasCycle(app) {
|
|
6332
|
-
if (recStack.has(app)) return true;
|
|
6333
|
-
if (visited.has(app)) return false;
|
|
6334
|
-
visited.add(app);
|
|
6335
|
-
recStack.add(app);
|
|
6336
|
-
const deps = data.apps?.[app]?.dependencies ?? [];
|
|
6337
|
-
for (const dep of deps) if (hasCycle(dep)) return true;
|
|
6338
|
-
recStack.delete(app);
|
|
6339
|
-
return false;
|
|
6340
|
-
}
|
|
6341
|
-
for (const app of appNames) {
|
|
6342
|
-
visited.clear();
|
|
6343
|
-
recStack.clear();
|
|
6344
|
-
if (hasCycle(app)) return false;
|
|
6345
|
-
}
|
|
6346
|
-
return true;
|
|
6347
|
-
}, { message: "Circular dependencies detected between apps" }).superRefine((data, ctx) => {
|
|
6348
|
-
const defaultTarget = data.deploy?.default;
|
|
6349
|
-
const ownTargets = data.deploy?.targets ?? {};
|
|
6350
|
-
if (defaultTarget && !isDeployTargetSupported(defaultTarget, ownTargets)) {
|
|
6351
|
-
ctx.addIssue({
|
|
6352
|
-
code: "custom",
|
|
6353
|
-
message: getDeployTargetError(defaultTarget),
|
|
6354
|
-
path: ["deploy", "default"]
|
|
6355
|
-
});
|
|
6356
|
-
return;
|
|
6357
|
-
}
|
|
6358
|
-
for (const [appName, app] of Object.entries(data.apps ?? {})) if (app.deploy && !isDeployTargetSupported(app.deploy, ownTargets)) {
|
|
6359
|
-
ctx.addIssue({
|
|
6360
|
-
code: "custom",
|
|
6361
|
-
message: getDeployTargetError(app.deploy, appName),
|
|
6362
|
-
path: [
|
|
6363
|
-
"apps",
|
|
6364
|
-
appName,
|
|
6365
|
-
"deploy"
|
|
6366
|
-
]
|
|
6367
|
-
});
|
|
6368
|
-
return;
|
|
6369
|
-
}
|
|
6370
|
-
if (data.state?.provider === "ssm" && !data.name) ctx.addIssue({
|
|
6371
|
-
code: "custom",
|
|
6372
|
-
message: "Workspace name is required when using SSM state provider. Add \"name\" to your gkm.config.ts.",
|
|
6373
|
-
path: ["name"]
|
|
6374
|
-
});
|
|
6375
|
-
});
|
|
6376
|
-
/**
|
|
6377
|
-
* Validate workspace configuration.
|
|
6378
|
-
* Throws ZodError with detailed messages on validation failure.
|
|
6379
|
-
*/
|
|
6380
|
-
function validateWorkspaceConfig(config) {
|
|
6381
|
-
return WorkspaceConfigSchema.parse(config);
|
|
6382
|
-
}
|
|
6383
|
-
/**
|
|
6384
|
-
* Safe validation that returns result instead of throwing.
|
|
6385
|
-
*/
|
|
6386
|
-
function safeValidateWorkspaceConfig(config) {
|
|
6387
|
-
const result = WorkspaceConfigSchema.safeParse(config);
|
|
6388
|
-
if (result.success) return {
|
|
6389
|
-
success: true,
|
|
6390
|
-
data: result.data
|
|
6391
|
-
};
|
|
6392
|
-
return {
|
|
6393
|
-
success: false,
|
|
6394
|
-
error: result.error
|
|
6395
|
-
};
|
|
6396
|
-
}
|
|
6397
|
-
/**
|
|
6398
|
-
* Format Zod errors into user-friendly messages.
|
|
6399
|
-
*/
|
|
6400
|
-
function formatValidationErrors(error) {
|
|
6401
|
-
return `Workspace configuration validation failed:\n${error.issues.map((issue) => {
|
|
6402
|
-
const path = issue.path.join(".");
|
|
6403
|
-
return path ? ` - ${path}: ${issue.message}` : ` - ${issue.message}`;
|
|
6404
|
-
}).join("\n")}`;
|
|
6405
|
-
}
|
|
6406
|
-
//#endregion
|
|
6407
|
-
//#region src/workspace/types.ts
|
|
6408
|
-
/**
|
|
6409
|
-
* Type guard to check if a config is a WorkspaceConfig.
|
|
6410
|
-
*
|
|
6411
|
-
* @example
|
|
6412
|
-
* ```ts
|
|
6413
|
-
* const config = await loadConfig();
|
|
6414
|
-
* if (isWorkspaceConfig(config)) {
|
|
6415
|
-
* // config.apps is available
|
|
6416
|
-
* console.log(Object.keys(config.apps));
|
|
6417
|
-
* }
|
|
6418
|
-
* ```
|
|
6419
|
-
*/
|
|
6420
|
-
function isWorkspaceConfig(config) {
|
|
6421
|
-
if (typeof config !== "object" || config === null) return false;
|
|
6422
|
-
if ("apps" in config && typeof config.apps === "object") return true;
|
|
6423
|
-
return "constructs" in config && Object.keys(config).every((key) => WORKSPACE_KEYS.has(key));
|
|
6424
|
-
}
|
|
6425
|
-
/** Every top-level key a workspace config has — see `WorkspaceConfigSchema`. */
|
|
6426
|
-
const WORKSPACE_KEYS = /* @__PURE__ */ new Set([
|
|
6427
|
-
"name",
|
|
6428
|
-
"constructs",
|
|
6429
|
-
"apps",
|
|
6430
|
-
"shared",
|
|
6431
|
-
"deploy",
|
|
6432
|
-
"stages",
|
|
6433
|
-
"secrets",
|
|
6434
|
-
"state"
|
|
6435
|
-
]);
|
|
6436
|
-
//#endregion
|
|
6437
|
-
//#region src/workspace/publicEnv.ts
|
|
6438
|
-
/**
|
|
6439
|
-
* All public env-var prefixes the toolbox understands.
|
|
6440
|
-
*
|
|
6441
|
-
* Used when resolving incoming var names back to a dependency
|
|
6442
|
-
* (e.g. `VITE_AUTH_URL` → `auth`). A var matching any of these
|
|
6443
|
-
* is considered safe to inline into a client bundle.
|
|
6444
|
-
*/
|
|
6445
|
-
const PUBLIC_ENV_PREFIXES = [
|
|
6446
|
-
"NEXT_PUBLIC_",
|
|
6447
|
-
"VITE_",
|
|
6448
|
-
"EXPO_PUBLIC_"
|
|
6449
|
-
];
|
|
6450
|
-
/**
|
|
6451
|
-
* Resolve the public env-var prefix that a frontend framework's bundler
|
|
6452
|
-
* inlines into client code at build time:
|
|
6453
|
-
*
|
|
6454
|
-
* - `nextjs` → `NEXT_PUBLIC_`
|
|
6455
|
-
* - `vite` → `VITE_`
|
|
6456
|
-
* - `tanstack-start` → `VITE_` (uses Vite under the hood)
|
|
6457
|
-
* - `expo` → `EXPO_PUBLIC_`
|
|
6458
|
-
* - `remix` → `''` (Remix exposes via loaders, no prefix convention)
|
|
6459
|
-
*
|
|
6460
|
-
* For backend frameworks or unspecified, falls back to `NEXT_PUBLIC_` to
|
|
6461
|
-
* preserve the historical default. Backend apps never read these vars
|
|
6462
|
-
* from a bundle, so the prefix only affects scaffolding/symmetry.
|
|
6463
|
-
*/
|
|
6464
|
-
function getPublicEnvPrefix(framework) {
|
|
6465
|
-
switch (framework) {
|
|
6466
|
-
case "vite":
|
|
6467
|
-
case "tanstack-start": return "VITE_";
|
|
6468
|
-
case "expo": return "EXPO_PUBLIC_";
|
|
6469
|
-
case "remix": return "";
|
|
6470
|
-
case "nextjs": return "NEXT_PUBLIC_";
|
|
6471
|
-
default: return "NEXT_PUBLIC_";
|
|
6472
|
-
}
|
|
6473
|
-
}
|
|
6474
|
-
/**
|
|
6475
|
-
* Strip a known public prefix from a var name.
|
|
6476
|
-
* Returns the un-prefixed name, or `null` if no prefix matched.
|
|
6477
|
-
*/
|
|
6478
|
-
function stripPublicPrefix(name) {
|
|
6479
|
-
for (const prefix of PUBLIC_ENV_PREFIXES) if (prefix && name.startsWith(prefix)) return name.slice(prefix.length);
|
|
6480
|
-
return null;
|
|
6481
|
-
}
|
|
6482
|
-
//#endregion
|
|
6483
|
-
//#region src/workspace/index.ts
|
|
6484
|
-
/**
|
|
6485
|
-
* Validate that all dependencies reference existing apps.
|
|
6486
|
-
* Returns the config if valid, throws otherwise.
|
|
6487
|
-
*/
|
|
6488
|
-
function validateDependencies(apps) {
|
|
6489
|
-
const appNames = new Set(Object.keys(apps));
|
|
6490
|
-
for (const [appName, app] of Object.entries(apps)) for (const dep of app.dependencies ?? []) {
|
|
6491
|
-
if (!appNames.has(dep)) throw new Error(`Invalid dependency: App "${appName}" depends on "${dep}" which does not exist. Valid apps are: ${[...appNames].join(", ")}`);
|
|
6492
|
-
if (dep === appName) throw new Error(`Invalid dependency: App "${appName}" cannot depend on itself.`);
|
|
6493
|
-
}
|
|
6494
|
-
}
|
|
6495
|
-
/**
|
|
6496
|
-
* Define workspace configuration with full TypeScript support and type inference.
|
|
6497
|
-
*
|
|
6498
|
-
* Uses `const` type parameter to infer literal app names, providing:
|
|
6499
|
-
* - Autocomplete for app names in dependencies
|
|
6500
|
-
* - Type errors for invalid dependency references
|
|
6501
|
-
* - Full type inference for the returned config
|
|
6502
|
-
*
|
|
6503
|
-
* @example
|
|
6504
|
-
* ```ts
|
|
6505
|
-
* // gkm.config.ts
|
|
6506
|
-
* import { defineWorkspace } from '@geekmidas/cli';
|
|
6507
|
-
*
|
|
6508
|
-
* export default defineWorkspace({
|
|
6509
|
-
* name: 'my-saas',
|
|
6510
|
-
* apps: {
|
|
6511
|
-
* api: {
|
|
6512
|
-
* type: 'backend',
|
|
6513
|
-
* path: 'apps/api',
|
|
6514
|
-
* port: 3000,
|
|
6515
|
-
* routes: './src/endpoints/**\/*.ts',
|
|
6516
|
-
* envParser: './src/config/env',
|
|
6517
|
-
* logger: './src/logger',
|
|
6518
|
-
* },
|
|
6519
|
-
* web: {
|
|
6520
|
-
* type: 'web',
|
|
6521
|
-
* framework: 'nextjs',
|
|
6522
|
-
* path: 'apps/web',
|
|
6523
|
-
* port: 3001,
|
|
6524
|
-
* dependencies: ['api'], // <- autocomplete shows 'api' | 'web'
|
|
6525
|
-
* },
|
|
6526
|
-
* },
|
|
6527
|
-
* });
|
|
6528
|
-
*
|
|
6529
|
-
* // config.apps.api <- full type inference
|
|
6530
|
-
* // config.apps.foo <- TypeScript error
|
|
6531
|
-
* ```
|
|
6532
|
-
*/
|
|
6533
|
-
function defineWorkspace(config) {
|
|
6534
|
-
if (config.apps) validateDependencies(config.apps);
|
|
6535
|
-
const result = safeValidateWorkspaceConfig(config);
|
|
6536
|
-
if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
|
|
6537
|
-
return config;
|
|
6538
|
-
}
|
|
6539
|
-
/**
|
|
6540
|
-
* Get the package name from package.json in the given directory.
|
|
6541
|
-
*/
|
|
6542
|
-
function getPackageName(cwd) {
|
|
6543
|
-
try {
|
|
6544
|
-
return require(`${cwd}/package.json`).name?.replace(/^@[^/]+\//, "");
|
|
6545
|
-
} catch {
|
|
6546
|
-
return;
|
|
6547
|
-
}
|
|
6548
|
-
}
|
|
6549
|
-
/**
|
|
6550
|
-
* Normalize a workspace configuration with resolved defaults.
|
|
6551
|
-
*/
|
|
6552
|
-
function normalizeWorkspace(config, cwd) {
|
|
6553
|
-
const name = config.name ?? getPackageName(cwd) ?? (0, node_path.basename)(cwd);
|
|
6554
|
-
const defaultTarget = config.deploy?.default ?? "dokploy";
|
|
6555
|
-
const normalizedApps = {};
|
|
6556
|
-
for (const [appName, app] of Object.entries(config.apps ?? {})) normalizedApps[appName] = normalizeAppConfig(app, defaultTarget);
|
|
6557
|
-
return {
|
|
6558
|
-
name,
|
|
6559
|
-
root: cwd,
|
|
6560
|
-
...config.constructs ? { constructs: config.constructs } : {},
|
|
6561
|
-
apps: normalizedApps,
|
|
6562
|
-
deploy: config.deploy ?? { default: "dokploy" },
|
|
6563
|
-
shared: config.shared ?? { packages: ["packages/*"] },
|
|
6564
|
-
stages: validateStages(config.stages),
|
|
6565
|
-
secrets: config.secrets ?? {},
|
|
6566
|
-
state: config.state,
|
|
6567
|
-
test: config.test ?? {},
|
|
6568
|
-
...config.dev ? { dev: config.dev } : {}
|
|
6569
|
-
};
|
|
6570
|
-
}
|
|
6571
|
-
/**
|
|
6572
|
-
* Normalize an app configuration with resolved defaults.
|
|
6573
|
-
* @param app - App configuration
|
|
6574
|
-
* @param defaultTarget - Default deploy target from workspace config
|
|
6575
|
-
*/
|
|
6576
|
-
function normalizeAppConfig(app, defaultTarget) {
|
|
6577
|
-
return {
|
|
6578
|
-
...app,
|
|
6579
|
-
type: app.type ?? "backend",
|
|
6580
|
-
port: app.port,
|
|
6581
|
-
path: app.path,
|
|
6582
|
-
dependencies: app.dependencies ?? [],
|
|
6583
|
-
resolvedDeployTarget: app.deploy ?? defaultTarget
|
|
6584
|
-
};
|
|
6585
|
-
}
|
|
6586
|
-
/**
|
|
6587
|
-
* Wrap a single-app GkmConfig as a workspace.
|
|
6588
|
-
* This allows existing single-app configs to work seamlessly.
|
|
6589
|
-
*/
|
|
6590
|
-
function wrapSingleAppAsWorkspace(config, cwd) {
|
|
6591
|
-
return {
|
|
6592
|
-
name: config.name ?? getPackageName(cwd) ?? (0, node_path.basename)(cwd),
|
|
6593
|
-
root: cwd,
|
|
6594
|
-
apps: { api: {
|
|
6595
|
-
type: "backend",
|
|
6596
|
-
path: ".",
|
|
6597
|
-
port: 3e3,
|
|
6598
|
-
dependencies: [],
|
|
6599
|
-
resolvedDeployTarget: config.deploy?.default ?? "dokploy",
|
|
6600
|
-
constructs: config.constructs,
|
|
6601
|
-
hooks: config.hooks,
|
|
6602
|
-
telescope: config.telescope,
|
|
6603
|
-
openapi: config.openapi,
|
|
6604
|
-
runtime: config.runtime,
|
|
6605
|
-
env: config.env
|
|
6606
|
-
} },
|
|
6607
|
-
deploy: {
|
|
6608
|
-
default: "dokploy",
|
|
6609
|
-
...config.deploy
|
|
6610
|
-
},
|
|
6611
|
-
shared: { packages: [] },
|
|
6612
|
-
stages: validateStages(config.stages),
|
|
6613
|
-
secrets: config.secrets ?? {},
|
|
6614
|
-
test: config.test ?? {},
|
|
6615
|
-
...config.dev ? { dev: config.dev } : {}
|
|
6616
|
-
};
|
|
6617
|
-
}
|
|
6618
|
-
/**
|
|
6619
|
-
* Process a loaded configuration (either single-app or workspace).
|
|
6620
|
-
* Returns a normalized workspace in both cases.
|
|
6621
|
-
*/
|
|
6622
|
-
function processConfig(config, cwd) {
|
|
6623
|
-
if (isWorkspaceConfig(config)) {
|
|
6624
|
-
const result = safeValidateWorkspaceConfig(config);
|
|
6625
|
-
if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
|
|
6626
|
-
return {
|
|
6627
|
-
type: "workspace",
|
|
6628
|
-
raw: config,
|
|
6629
|
-
workspace: normalizeWorkspace(config, cwd)
|
|
6630
|
-
};
|
|
6631
|
-
}
|
|
6632
|
-
return {
|
|
6633
|
-
type: "single",
|
|
6634
|
-
raw: config,
|
|
6635
|
-
workspace: wrapSingleAppAsWorkspace(config, cwd)
|
|
6636
|
-
};
|
|
6637
|
-
}
|
|
6638
|
-
/**
|
|
6639
|
-
* The workspace's own constructs globs, absolute.
|
|
6640
|
-
*
|
|
6641
|
-
* Infrastructure two apps share is a fact about the product, and declaring it
|
|
6642
|
-
* inside one of them makes moving that app a change to the other's database.
|
|
6643
|
-
*/
|
|
6644
|
-
function workspaceConstructGlobs(workspace) {
|
|
6645
|
-
return constructPatterns(workspace.constructs).map((pattern) => (0, node_path.isAbsolute)(pattern) ? pattern : (0, node_path.join)(workspace.root, pattern));
|
|
6646
|
-
}
|
|
6647
|
-
/**
|
|
6648
|
-
* Every constructs glob an app can see, absolute.
|
|
6649
|
-
*
|
|
6650
|
-
* The workspace's own first, then the app's. Absolute because the app builds
|
|
6651
|
-
* from its own directory while the workspace's constructs live above it —
|
|
6652
|
-
* a relative glob resolved from the app would look for the product's
|
|
6653
|
-
* infrastructure inside one of its consumers and find nothing.
|
|
6654
|
-
*
|
|
6655
|
-
* Additive, not overriding: an app that declares its own constructs still sees
|
|
6656
|
-
* the ones the workspace declared for everybody.
|
|
6657
|
-
*/
|
|
6658
|
-
function appConstructGlobs(workspace, appName) {
|
|
6659
|
-
const globs = workspaceConstructGlobs(workspace);
|
|
6660
|
-
const app = workspace.apps[appName];
|
|
6661
|
-
if (app) {
|
|
6662
|
-
const root = (0, node_path.isAbsolute)(app.path) ? app.path : (0, node_path.join)(workspace.root, app.path);
|
|
6663
|
-
for (const pattern of constructPatterns(app.constructs)) globs.push((0, node_path.isAbsolute)(pattern) ? pattern : (0, node_path.join)(root, pattern));
|
|
6664
|
-
}
|
|
6665
|
-
return globs;
|
|
6666
|
-
}
|
|
6667
|
-
/**
|
|
6668
|
-
* Every constructs glob in the workspace: its own, plus each app's.
|
|
6669
|
-
*
|
|
6670
|
-
* One list, so what a deploy provisions and what an app's entry point
|
|
6671
|
-
* registers drivers for are read off the same globs.
|
|
6672
|
-
*/
|
|
6673
|
-
function allConstructGlobs(workspace) {
|
|
6674
|
-
const globs = [...workspaceConstructGlobs(workspace), ...Object.keys(workspace.apps).flatMap((appName) => appConstructGlobs(workspace, appName))];
|
|
6675
|
-
return [...new Set(globs)];
|
|
6676
|
-
}
|
|
6677
|
-
/** A `Routes` in any of its accepted shapes, as a flat list of patterns. */
|
|
6678
|
-
function constructPatterns(routes) {
|
|
6679
|
-
if (!routes) return [];
|
|
6680
|
-
return typeof routes === "string" ? [routes] : routes;
|
|
6681
|
-
}
|
|
6682
|
-
/**
|
|
6683
|
-
* Get the GkmConfig for a specific app in a workspace.
|
|
6684
|
-
* Useful for running existing single-app commands on a specific app.
|
|
6685
|
-
*/
|
|
6686
|
-
function getAppGkmConfig(workspace, appName) {
|
|
6687
|
-
const app = workspace.apps[appName];
|
|
6688
|
-
if (!app || app.type !== "backend") return;
|
|
6689
|
-
return {
|
|
6690
|
-
...workspace.deploy ? { deploy: workspace.deploy } : {},
|
|
6691
|
-
stages: workspace.stages,
|
|
6692
|
-
constructs: appConstructGlobs(workspace, appName),
|
|
6693
|
-
hooks: app.hooks,
|
|
6694
|
-
telescope: app.telescope,
|
|
6695
|
-
openapi: app.openapi,
|
|
6696
|
-
runtime: app.runtime,
|
|
6697
|
-
env: app.env
|
|
6698
|
-
};
|
|
6699
|
-
}
|
|
6700
|
-
/**
|
|
6701
|
-
* Get topologically sorted app names based on dependencies.
|
|
6702
|
-
* Apps with no dependencies come first, then apps that depend on them.
|
|
6703
|
-
*/
|
|
6704
|
-
function getAppBuildOrder(workspace) {
|
|
6705
|
-
const appNames = Object.keys(workspace.apps);
|
|
6706
|
-
const visited = /* @__PURE__ */ new Set();
|
|
6707
|
-
const result = [];
|
|
6708
|
-
function visit(name) {
|
|
6709
|
-
if (visited.has(name)) return;
|
|
6710
|
-
visited.add(name);
|
|
6711
|
-
const app = workspace.apps[name];
|
|
6712
|
-
if (app) for (const dep of app.dependencies) visit(dep);
|
|
6713
|
-
result.push(name);
|
|
6714
|
-
}
|
|
6715
|
-
for (const name of appNames) visit(name);
|
|
6716
|
-
return result;
|
|
6717
|
-
}
|
|
6718
|
-
/**
|
|
6719
|
-
* Resolve the Dokploy endpoint for a specific stage.
|
|
6720
|
-
*
|
|
6721
|
-
* Uses per-stage endpoint from `endpoints` if available,
|
|
6722
|
-
* otherwise falls back to the global `endpoint`.
|
|
6723
|
-
*
|
|
6724
|
-
* @param dokployConfig - Dokploy workspace configuration
|
|
6725
|
-
* @param stage - Deployment stage (e.g., 'development', 'production')
|
|
6726
|
-
* @returns The endpoint URL for the stage, or undefined if not configured
|
|
6727
|
-
*
|
|
6728
|
-
* @example
|
|
6729
|
-
* ```ts
|
|
6730
|
-
* // With per-stage endpoints
|
|
6731
|
-
* const config = {
|
|
6732
|
-
* endpoints: {
|
|
6733
|
-
* development: 'https://dev.dokploy.example.com:3000',
|
|
6734
|
-
* production: 'https://prod.dokploy.example.com:3000',
|
|
6735
|
-
* },
|
|
6736
|
-
* };
|
|
6737
|
-
* getEndpointForStage(config, 'production'); // => 'https://prod.dokploy.example.com:3000'
|
|
6738
|
-
*
|
|
6739
|
-
* // With single endpoint
|
|
6740
|
-
* const config = { endpoint: 'https://dokploy.example.com:3000' };
|
|
6741
|
-
* getEndpointForStage(config, 'production'); // => 'https://dokploy.example.com:3000'
|
|
6742
|
-
* ```
|
|
6743
|
-
*/
|
|
6744
|
-
function getEndpointForStage(dokployConfig, stage) {
|
|
6745
|
-
if (!dokployConfig) return void 0;
|
|
6746
|
-
if (dokployConfig.endpoints?.[stage]) return dokployConfig.endpoints[stage];
|
|
6747
|
-
return dokployConfig.endpoint;
|
|
6748
|
-
}
|
|
6749
|
-
//#endregion
|
|
6750
|
-
Object.defineProperty(exports, "InvalidStages", {
|
|
6751
|
-
enumerable: true,
|
|
6752
|
-
get: function() {
|
|
6753
|
-
return InvalidStages;
|
|
6754
|
-
}
|
|
6755
|
-
});
|
|
6756
|
-
Object.defineProperty(exports, "PHASE_2_DEPLOY_TARGETS", {
|
|
6757
|
-
enumerable: true,
|
|
6758
|
-
get: function() {
|
|
6759
|
-
return PHASE_2_DEPLOY_TARGETS;
|
|
6760
|
-
}
|
|
6761
|
-
});
|
|
6762
|
-
Object.defineProperty(exports, "PUBLIC_ENV_PREFIXES", {
|
|
6763
|
-
enumerable: true,
|
|
6764
|
-
get: function() {
|
|
6765
|
-
return PUBLIC_ENV_PREFIXES;
|
|
6766
|
-
}
|
|
6767
|
-
});
|
|
6768
|
-
Object.defineProperty(exports, "SUPPORTED_DEPLOY_TARGETS", {
|
|
6769
|
-
enumerable: true,
|
|
6770
|
-
get: function() {
|
|
6771
|
-
return SUPPORTED_DEPLOY_TARGETS;
|
|
6772
|
-
}
|
|
6773
|
-
});
|
|
6774
|
-
Object.defineProperty(exports, "TEST_STAGE", {
|
|
6775
|
-
enumerable: true,
|
|
6776
|
-
get: function() {
|
|
6777
|
-
return TEST_STAGE;
|
|
6778
|
-
}
|
|
6779
|
-
});
|
|
6780
|
-
Object.defineProperty(exports, "WorkspaceConfigSchema", {
|
|
6781
|
-
enumerable: true,
|
|
6782
|
-
get: function() {
|
|
6783
|
-
return WorkspaceConfigSchema;
|
|
6784
|
-
}
|
|
6785
|
-
});
|
|
6786
|
-
Object.defineProperty(exports, "allConstructGlobs", {
|
|
6787
|
-
enumerable: true,
|
|
6788
|
-
get: function() {
|
|
6789
|
-
return allConstructGlobs;
|
|
6790
|
-
}
|
|
6791
|
-
});
|
|
6792
|
-
Object.defineProperty(exports, "appConstructGlobs", {
|
|
6793
|
-
enumerable: true,
|
|
6794
|
-
get: function() {
|
|
6795
|
-
return appConstructGlobs;
|
|
6796
|
-
}
|
|
6797
|
-
});
|
|
6798
|
-
Object.defineProperty(exports, "assertDeployedStage", {
|
|
6799
|
-
enumerable: true,
|
|
6800
|
-
get: function() {
|
|
6801
|
-
return assertDeployedStage;
|
|
6802
|
-
}
|
|
6803
|
-
});
|
|
6804
|
-
Object.defineProperty(exports, "constructPatterns", {
|
|
6805
|
-
enumerable: true,
|
|
6806
|
-
get: function() {
|
|
6807
|
-
return constructPatterns;
|
|
6808
|
-
}
|
|
6809
|
-
});
|
|
6810
|
-
Object.defineProperty(exports, "defineWorkspace", {
|
|
6811
|
-
enumerable: true,
|
|
6812
|
-
get: function() {
|
|
6813
|
-
return defineWorkspace;
|
|
6814
|
-
}
|
|
6815
|
-
});
|
|
6816
|
-
Object.defineProperty(exports, "deployedProblems", {
|
|
6817
|
-
enumerable: true,
|
|
6818
|
-
get: function() {
|
|
6819
|
-
return deployedProblems;
|
|
6820
|
-
}
|
|
6821
|
-
});
|
|
6822
|
-
Object.defineProperty(exports, "formatValidationErrors", {
|
|
6823
|
-
enumerable: true,
|
|
6824
|
-
get: function() {
|
|
6825
|
-
return formatValidationErrors;
|
|
6826
|
-
}
|
|
6827
|
-
});
|
|
6828
|
-
Object.defineProperty(exports, "getAppBuildOrder", {
|
|
6829
|
-
enumerable: true,
|
|
6830
|
-
get: function() {
|
|
6831
|
-
return getAppBuildOrder;
|
|
6832
|
-
}
|
|
6833
|
-
});
|
|
6834
|
-
Object.defineProperty(exports, "getAppGkmConfig", {
|
|
6835
|
-
enumerable: true,
|
|
6836
|
-
get: function() {
|
|
6837
|
-
return getAppGkmConfig;
|
|
6838
|
-
}
|
|
6839
|
-
});
|
|
6840
|
-
Object.defineProperty(exports, "getDeployTargetError", {
|
|
6841
|
-
enumerable: true,
|
|
6842
|
-
get: function() {
|
|
6843
|
-
return getDeployTargetError;
|
|
6844
|
-
}
|
|
6845
|
-
});
|
|
6846
|
-
Object.defineProperty(exports, "getEndpointForStage", {
|
|
6847
|
-
enumerable: true,
|
|
6848
|
-
get: function() {
|
|
6849
|
-
return getEndpointForStage;
|
|
6850
|
-
}
|
|
6851
|
-
});
|
|
6852
|
-
Object.defineProperty(exports, "getPublicEnvPrefix", {
|
|
6853
|
-
enumerable: true,
|
|
6854
|
-
get: function() {
|
|
6855
|
-
return getPublicEnvPrefix;
|
|
6856
|
-
}
|
|
6857
|
-
});
|
|
6858
|
-
Object.defineProperty(exports, "isDeployTargetSupported", {
|
|
6859
|
-
enumerable: true,
|
|
6860
|
-
get: function() {
|
|
6861
|
-
return isDeployTargetSupported;
|
|
6862
|
-
}
|
|
6863
|
-
});
|
|
6864
|
-
Object.defineProperty(exports, "isPhase2DeployTarget", {
|
|
6865
|
-
enumerable: true,
|
|
6866
|
-
get: function() {
|
|
6867
|
-
return isPhase2DeployTarget;
|
|
6868
|
-
}
|
|
6869
|
-
});
|
|
6870
|
-
Object.defineProperty(exports, "isWorkspaceConfig", {
|
|
6871
|
-
enumerable: true,
|
|
6872
|
-
get: function() {
|
|
6873
|
-
return isWorkspaceConfig;
|
|
6874
|
-
}
|
|
6875
|
-
});
|
|
6876
|
-
Object.defineProperty(exports, "normalizeWorkspace", {
|
|
6877
|
-
enumerable: true,
|
|
6878
|
-
get: function() {
|
|
6879
|
-
return normalizeWorkspace;
|
|
6880
|
-
}
|
|
6881
|
-
});
|
|
6882
|
-
Object.defineProperty(exports, "processConfig", {
|
|
6883
|
-
enumerable: true,
|
|
6884
|
-
get: function() {
|
|
6885
|
-
return processConfig;
|
|
6886
|
-
}
|
|
6887
|
-
});
|
|
6888
|
-
Object.defineProperty(exports, "safeValidateWorkspaceConfig", {
|
|
6889
|
-
enumerable: true,
|
|
6890
|
-
get: function() {
|
|
6891
|
-
return safeValidateWorkspaceConfig;
|
|
6892
|
-
}
|
|
6893
|
-
});
|
|
6894
|
-
Object.defineProperty(exports, "stageProblems", {
|
|
6895
|
-
enumerable: true,
|
|
6896
|
-
get: function() {
|
|
6897
|
-
return stageProblems;
|
|
6898
|
-
}
|
|
6899
|
-
});
|
|
6900
|
-
Object.defineProperty(exports, "stripPublicPrefix", {
|
|
6901
|
-
enumerable: true,
|
|
6902
|
-
get: function() {
|
|
6903
|
-
return stripPublicPrefix;
|
|
6904
|
-
}
|
|
6905
|
-
});
|
|
6906
|
-
Object.defineProperty(exports, "validateWorkspaceConfig", {
|
|
6907
|
-
enumerable: true,
|
|
6908
|
-
get: function() {
|
|
6909
|
-
return validateWorkspaceConfig;
|
|
6910
|
-
}
|
|
6911
|
-
});
|
|
6912
|
-
Object.defineProperty(exports, "workspaceConstructGlobs", {
|
|
6913
|
-
enumerable: true,
|
|
6914
|
-
get: function() {
|
|
6915
|
-
return workspaceConstructGlobs;
|
|
6916
|
-
}
|
|
6917
|
-
});
|
|
6918
|
-
Object.defineProperty(exports, "wrapSingleAppAsWorkspace", {
|
|
6919
|
-
enumerable: true,
|
|
6920
|
-
get: function() {
|
|
6921
|
-
return wrapSingleAppAsWorkspace;
|
|
6922
|
-
}
|
|
6923
|
-
});
|
|
5757
|
+
export { discriminatedUnion as a, object as c, tuple as d, union as f, custom as i, record as l, url as m, array as n, literal as o, unknown as p, boolean as r, number as s, _enum as t, string as u };
|
|
6924
5758
|
|
|
6925
|
-
//# sourceMappingURL=
|
|
5759
|
+
//# sourceMappingURL=schemas-D2LCF689.mjs.map
|