@geekmidas/cli 10.0.0-alpha.62 → 10.0.0-alpha.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +2 -0
  2. package/dist/{HostingerProvider-B92qH4dC.mjs → HostingerProvider-DBBwpDjn.mjs} +2 -2
  3. package/dist/{HostingerProvider-B92qH4dC.mjs.map → HostingerProvider-DBBwpDjn.mjs.map} +1 -1
  4. package/dist/{HostingerProvider-DyD1Hin8.cjs → HostingerProvider-mJ7YruxH.cjs} +2 -2
  5. package/dist/{HostingerProvider-DyD1Hin8.cjs.map → HostingerProvider-mJ7YruxH.cjs.map} +1 -1
  6. package/dist/{LegacyStateStore-UHJEBLdn.cjs → LegacyStateStore-CP7SZwTP.cjs} +2 -2
  7. package/dist/{LegacyStateStore-UHJEBLdn.cjs.map → LegacyStateStore-CP7SZwTP.cjs.map} +1 -1
  8. package/dist/{LegacyStateStore-A8d2GdT7.mjs → LegacyStateStore-Q3GmKOdw.mjs} +2 -2
  9. package/dist/{LegacyStateStore-A8d2GdT7.mjs.map → LegacyStateStore-Q3GmKOdw.mjs.map} +1 -1
  10. package/dist/{LocalStateStore-B51rnfgn.mjs → LocalStateStore-BGIXcrvX.mjs} +2 -2
  11. package/dist/{LocalStateStore-B51rnfgn.mjs.map → LocalStateStore-BGIXcrvX.mjs.map} +1 -1
  12. package/dist/{LocalStateStore-COW3Ldwa.cjs → LocalStateStore-sS8mvLeq.cjs} +2 -2
  13. package/dist/{LocalStateStore-COW3Ldwa.cjs.map → LocalStateStore-sS8mvLeq.cjs.map} +1 -1
  14. package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs → OpenApiTsGenerator-CjHWFRDd.cjs} +2 -2
  15. package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs.map → OpenApiTsGenerator-CjHWFRDd.cjs.map} +1 -1
  16. package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs → OpenApiTsGenerator-CnAwhGxi.mjs} +2 -2
  17. package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs.map → OpenApiTsGenerator-CnAwhGxi.mjs.map} +1 -1
  18. package/dist/{S3StateStore-WUJGdRNL.cjs → S3StateStore-6jqITH2F.cjs} +2 -2
  19. package/dist/{S3StateStore-WUJGdRNL.cjs.map → S3StateStore-6jqITH2F.cjs.map} +1 -1
  20. package/dist/{S3StateStore-CJewPhgz.mjs → S3StateStore-D7l_lWJ3.mjs} +2 -2
  21. package/dist/{S3StateStore-CJewPhgz.mjs.map → S3StateStore-D7l_lWJ3.mjs.map} +1 -1
  22. package/dist/{SSMStateStore-Zejt42V8.cjs → SSMStateStore-B__F7IJa.cjs} +2 -2
  23. package/dist/{SSMStateStore-Zejt42V8.cjs.map → SSMStateStore-B__F7IJa.cjs.map} +1 -1
  24. package/dist/{SSMStateStore-iK5UKp9d.mjs → SSMStateStore-CAQDVpoc.mjs} +2 -2
  25. package/dist/{SSMStateStore-iK5UKp9d.mjs.map → SSMStateStore-CAQDVpoc.mjs.map} +1 -1
  26. package/dist/{bundler-CfH9frOS.cjs → bundler-DLfOn0ls.cjs} +3 -3
  27. package/dist/{bundler-CfH9frOS.cjs.map → bundler-DLfOn0ls.cjs.map} +1 -1
  28. package/dist/{bundler-DN5r4x5b.mjs → bundler-DyWI41Iy.mjs} +2 -2
  29. package/dist/{bundler-DN5r4x5b.mjs.map → bundler-DyWI41Iy.mjs.map} +1 -1
  30. package/dist/{cli-DOAUp80L.cjs → cli-D-ZM-X2s.cjs} +4 -4
  31. package/dist/{cli-DOAUp80L.cjs.map → cli-D-ZM-X2s.cjs.map} +1 -1
  32. package/dist/{cli-DYwxmfsW.mjs → cli-PkVF28LM.mjs} +4 -4
  33. package/dist/{cli-DYwxmfsW.mjs.map → cli-PkVF28LM.mjs.map} +1 -1
  34. package/dist/{config-BYh9S0cZ.cjs → config-BEJYKd4s.cjs} +132 -18
  35. package/dist/config-BEJYKd4s.cjs.map +1 -0
  36. package/dist/config-C2BUosLm.d.mts +256 -0
  37. package/dist/config-C2BUosLm.d.mts.map +1 -0
  38. package/dist/config-CemHVcIr.d.cts +256 -0
  39. package/dist/config-CemHVcIr.d.cts.map +1 -0
  40. package/dist/{config-Bf4-bROQ.mjs → config-LKKCVCnC.mjs} +109 -19
  41. package/dist/config-LKKCVCnC.mjs.map +1 -0
  42. package/dist/config.cjs +6 -2
  43. package/dist/config.d.cts +3 -210
  44. package/dist/config.d.mts +3 -210
  45. package/dist/config.mjs +3 -3
  46. package/dist/deploy/public.cjs +151 -5
  47. package/dist/deploy/public.cjs.map +1 -0
  48. package/dist/deploy/public.d.cts +186 -1
  49. package/dist/deploy/public.d.cts.map +1 -1
  50. package/dist/deploy/public.d.mts +186 -1
  51. package/dist/deploy/public.d.mts.map +1 -1
  52. package/dist/deploy/public.mjs +134 -6
  53. package/dist/deploy/public.mjs.map +1 -0
  54. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  55. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  56. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  57. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  58. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  59. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  60. package/dist/{deploy-DSaCYvcO.cjs → deploy-ABBI0lf1.cjs} +7 -7
  61. package/dist/{deploy-DSaCYvcO.cjs.map → deploy-ABBI0lf1.cjs.map} +1 -1
  62. package/dist/{deploy-D8Qr-Xto.cjs → deploy-BiMrP9i7.cjs} +11 -9
  63. package/dist/deploy-BiMrP9i7.cjs.map +1 -0
  64. package/dist/{deploy-B7jvUORo.mjs → deploy-CG8bfFij.mjs} +7 -7
  65. package/dist/{deploy-B7jvUORo.mjs.map → deploy-CG8bfFij.mjs.map} +1 -1
  66. package/dist/{deploy-Cg9fae7a.mjs → deploy-CGW-QY9D.mjs} +11 -9
  67. package/dist/deploy-CGW-QY9D.mjs.map +1 -0
  68. package/dist/discover-B6yPpvRV.d.mts +99 -0
  69. package/dist/discover-B6yPpvRV.d.mts.map +1 -0
  70. package/dist/discover-B_IkPukx.d.cts +99 -0
  71. package/dist/discover-B_IkPukx.d.cts.map +1 -0
  72. package/dist/discover-BaT6bpnA.mjs +614 -0
  73. package/dist/discover-BaT6bpnA.mjs.map +1 -0
  74. package/dist/discover-C_6COHEv.cjs +729 -0
  75. package/dist/discover-C_6COHEv.cjs.map +1 -0
  76. package/dist/{dokploy-CD9PY-3D.mjs → dokploy-CwdmlyQL.mjs} +2 -2
  77. package/dist/{dokploy-CD9PY-3D.mjs.map → dokploy-CwdmlyQL.mjs.map} +1 -1
  78. package/dist/{dokploy-Ey2foJLv.cjs → dokploy-QJxMhxdf.cjs} +2 -2
  79. package/dist/{dokploy-Ey2foJLv.cjs.map → dokploy-QJxMhxdf.cjs.map} +1 -1
  80. package/dist/{encryption-CVwvGbsL.mjs → encryption-CbQG_ayW.mjs} +4 -4
  81. package/dist/{encryption-CVwvGbsL.mjs.map → encryption-CbQG_ayW.mjs.map} +1 -1
  82. package/dist/{encryption-ChBk3hTj.cjs → encryption-DXw3jj0c.cjs} +4 -4
  83. package/dist/{encryption-ChBk3hTj.cjs.map → encryption-DXw3jj0c.cjs.map} +1 -1
  84. package/dist/fakes-C9RiT6XG.mjs.map +1 -1
  85. package/dist/fakes-zW-jNAbQ.cjs.map +1 -1
  86. package/dist/{github-OUgPDlqg.cjs → github-BH_mETav.cjs} +3 -3
  87. package/dist/{github-OUgPDlqg.cjs.map → github-BH_mETav.cjs.map} +1 -1
  88. package/dist/{github-BCB3_LBX.mjs → github-ciwbIwVa.mjs} +3 -3
  89. package/dist/{github-BCB3_LBX.mjs.map → github-ciwbIwVa.mjs.map} +1 -1
  90. package/dist/index.cjs +55 -48
  91. package/dist/index.cjs.map +1 -1
  92. package/dist/index.mjs +52 -45
  93. package/dist/index.mjs.map +1 -1
  94. package/dist/{migrate-dnaFMvOm.cjs → migrate-6oa9y_f2.cjs} +5 -5
  95. package/dist/{migrate-dnaFMvOm.cjs.map → migrate-6oa9y_f2.cjs.map} +1 -1
  96. package/dist/{migrate-BoHMqdCu.mjs → migrate-ImBKTBcW.mjs} +5 -5
  97. package/dist/{migrate-BoHMqdCu.mjs.map → migrate-ImBKTBcW.mjs.map} +1 -1
  98. package/dist/openapi.cjs +3 -3
  99. package/dist/openapi.mjs +3 -3
  100. package/dist/{ready-XlNx-Gbo.cjs → ready-BiG0rt4h.cjs} +3 -3
  101. package/dist/{ready-XlNx-Gbo.cjs.map → ready-BiG0rt4h.cjs.map} +1 -1
  102. package/dist/{ready-DQIy21W5.mjs → ready-Bpdnn2ON.mjs} +3 -3
  103. package/dist/{ready-DQIy21W5.mjs.map → ready-Bpdnn2ON.mjs.map} +1 -1
  104. package/dist/reconcile/public.cjs +1 -1
  105. package/dist/reconcile/public.d.cts +3 -76
  106. package/dist/reconcile/public.d.cts.map +1 -1
  107. package/dist/reconcile/public.d.mts +3 -76
  108. package/dist/reconcile/public.d.mts.map +1 -1
  109. package/dist/reconcile/public.mjs +1 -1
  110. package/dist/{resolve-CFCIkm7m.mjs → resolve-B1T0hUaR.mjs} +2 -2
  111. package/dist/{resolve-CFCIkm7m.mjs.map → resolve-B1T0hUaR.mjs.map} +1 -1
  112. package/dist/{resolve-wbv66HjD.cjs → resolve-xytBTtG4.cjs} +2 -2
  113. package/dist/{resolve-wbv66HjD.cjs.map → resolve-xytBTtG4.cjs.map} +1 -1
  114. package/dist/sandbox/config-worker.cjs +43 -0
  115. package/dist/sandbox/config-worker.cjs.map +1 -0
  116. package/dist/sandbox/config-worker.d.cts +1 -0
  117. package/dist/sandbox/config-worker.d.mts +1 -0
  118. package/dist/sandbox/config-worker.mjs +44 -0
  119. package/dist/sandbox/config-worker.mjs.map +1 -0
  120. package/dist/sandbox/discover-worker.cjs +44 -0
  121. package/dist/sandbox/discover-worker.cjs.map +1 -0
  122. package/dist/sandbox/discover-worker.d.cts +1 -0
  123. package/dist/sandbox/discover-worker.d.mts +1 -0
  124. package/dist/sandbox/discover-worker.mjs +45 -0
  125. package/dist/sandbox/discover-worker.mjs.map +1 -0
  126. package/dist/sandbox-M8UnLhXE.d.cts +126 -0
  127. package/dist/sandbox-M8UnLhXE.d.cts.map +1 -0
  128. package/dist/sandbox-M8UnLhXE.d.mts +126 -0
  129. package/dist/sandbox-M8UnLhXE.d.mts.map +1 -0
  130. package/dist/{workspace-BFe57es7.mjs → schemas-Ckm_aBnF.cjs} +71 -982
  131. package/dist/schemas-Ckm_aBnF.cjs.map +1 -0
  132. package/dist/{workspace-B6zQO6RY.cjs → schemas-D2LCF689.mjs} +2 -1168
  133. package/dist/schemas-D2LCF689.mjs.map +1 -0
  134. package/dist/{sniffer-BsfPa-GA.cjs → sniffer-D_SYc_pO.cjs} +369 -207
  135. package/dist/sniffer-D_SYc_pO.cjs.map +1 -0
  136. package/dist/{sniffer-DHE2Nafd.mjs → sniffer-aO_-s5vq.mjs} +336 -204
  137. package/dist/sniffer-aO_-s5vq.mjs.map +1 -0
  138. package/dist/target/public.cjs +1 -1
  139. package/dist/target/public.mjs +1 -1
  140. package/dist/{terminal-6oL0vANs.cjs → terminal-D0f1u0LG.cjs} +6 -6
  141. package/dist/{terminal-6oL0vANs.cjs.map → terminal-D0f1u0LG.cjs.map} +1 -1
  142. package/dist/{terminal-ByZNjuig.mjs → terminal-gMxAo9Dj.mjs} +6 -6
  143. package/dist/{terminal-ByZNjuig.mjs.map → terminal-gMxAo9Dj.mjs.map} +1 -1
  144. package/dist/vitest.cjs +2 -2
  145. package/dist/vitest.mjs +2 -2
  146. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  147. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  148. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  149. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  150. package/dist/workspace/index.cjs +1 -1
  151. package/dist/workspace/index.mjs +1 -1
  152. package/dist/workspace-Dh7rr7l4.mjs +1024 -0
  153. package/dist/workspace-Dh7rr7l4.mjs.map +1 -0
  154. package/dist/workspace-Kl4NG9IH.cjs +1196 -0
  155. package/dist/workspace-Kl4NG9IH.cjs.map +1 -0
  156. package/package.json +13 -13
  157. package/dist/config-BYh9S0cZ.cjs.map +0 -1
  158. package/dist/config-Bf4-bROQ.mjs.map +0 -1
  159. package/dist/config.d.cts.map +0 -1
  160. package/dist/config.d.mts.map +0 -1
  161. package/dist/deploy-Cg9fae7a.mjs.map +0 -1
  162. package/dist/deploy-D8Qr-Xto.cjs.map +0 -1
  163. package/dist/discover-Bc-4eA_p.cjs +0 -299
  164. package/dist/discover-Bc-4eA_p.cjs.map +0 -1
  165. package/dist/discover-FrYvzkeC.mjs +0 -262
  166. package/dist/discover-FrYvzkeC.mjs.map +0 -1
  167. package/dist/sniffer-BsfPa-GA.cjs.map +0 -1
  168. package/dist/sniffer-DHE2Nafd.mjs.map +0 -1
  169. package/dist/workspace-B6zQO6RY.cjs.map +0 -1
  170. package/dist/workspace-BFe57es7.mjs.map +0 -1
@@ -1,6 +1,3 @@
1
- import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import { n as isDeployTarget, o as builtinTarget, r as BUILTIN_TARGETS, s as configurableBuiltins } from "./define-CHBIEc5j.mjs";
3
- import { basename, isAbsolute, join } from "node:path";
4
1
  //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
5
2
  function getEnumValues(entries) {
6
3
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
@@ -4823,7 +4820,7 @@ const initializer = (inst, issues) => {
4823
4820
  const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
4824
4821
  //#endregion
4825
4822
  //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/parse.js
4826
- const parse$1 = /* @__PURE__ */ _parse(ZodRealError);
4823
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
4827
4824
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
4828
4825
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
4829
4826
  const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
@@ -4955,7 +4952,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4955
4952
  own(this, "~standard", value);
4956
4953
  },
4957
4954
  parse: function _parse(data, params) {
4958
- return parse$1(this, data, params, { callee: _parse });
4955
+ return parse(this, data, params, { callee: _parse });
4959
4956
  },
4960
4957
  parseAsync: async function _parseAsync(data, params) {
4961
4958
  return await parseAsync(this, data, params, { callee: _parseAsync });
@@ -5757,997 +5754,89 @@ function superRefine(fn, params) {
5757
5754
  return /* @__PURE__ */ _superRefine(fn, params);
5758
5755
  }
5759
5756
  //#endregion
5760
- //#region src/workspace/stages.ts
5761
- /**
5762
- * What `gkm test` runs as. The CLI's own, so no project stage may take it:
5763
- * its containers are torn down and rebuilt between runs.
5764
- */
5765
- const TEST_STAGE = "test";
5766
- /** A stage becomes part of every physical name, so it has to fit in one. */
5767
- const STAGE_NAME = /^[a-z][a-z0-9-]*$/;
5768
- /** Everything wrong with one stage name, or nothing. */
5769
- function nameProblems(name) {
5770
- const problems = [];
5771
- if (!STAGE_NAME.test(name)) problems.push(`stage "${name}" must be lowercase letters, digits and hyphens, starting with a letter`);
5772
- if (name === "test") problems.push(`stage "${TEST_STAGE}" is reserved for gkm test`);
5773
- return problems;
5774
- }
5775
- /** Everything wrong with a list of deployed stages on its own. */
5776
- function deployedProblems(deployed) {
5777
- const problems = deployed.flatMap(nameProblems);
5778
- const seen = /* @__PURE__ */ new Set();
5779
- for (const name of deployed) {
5780
- if (seen.has(name)) problems.push(`stage "${name}" is listed twice`);
5781
- seen.add(name);
5782
- }
5783
- return problems;
5784
- }
5785
- /** Everything wrong with a stages block, or nothing. */
5786
- function stageProblems(stages) {
5787
- if (!stages) return ["`stages` is required, e.g. stages: { local: 'dev', deployed: ['prod'] }"];
5788
- const { local, deployed, protected: kept = [] } = stages;
5789
- const problems = [...nameProblems(local), ...deployedProblems(deployed)];
5790
- if (deployed.includes(local)) problems.push(`"${local}" is both the local stage and a deployed one; they would share secrets`);
5791
- for (const name of kept) if (!deployed.includes(name)) problems.push(`protected stage "${name}" is not a deployed stage`);
5792
- return problems;
5793
- }
5794
- /** The stages block, or an error naming everything wrong with it. */
5795
- function validateStages(stages) {
5796
- const problems = stageProblems(stages);
5797
- if (problems.length) throw new InvalidStages(problems);
5798
- return stages;
5799
- }
5800
- /** Refuses a stage the project does not deploy to. */
5801
- function assertDeployedStage(stages, stage) {
5802
- if (!stages.deployed.includes(stage)) throw new UndeclaredStage(stage, stages.deployed);
5803
- }
5804
- /** A stages block — in gkm.config.ts or from `gkm init`'s flags — that breaks a rule. */
5805
- var InvalidStages = class extends Error {
5806
- problems;
5807
- constructor(problems) {
5808
- super(`Invalid stages:\n ${problems.join("\n ")}`);
5809
- this.problems = problems;
5810
- this.name = "InvalidStages";
5811
- }
5812
- };
5813
- /**
5814
- * A stage the project does not deploy to. Refused before anything is
5815
- * provisioned, so a typo does not become a second environment.
5816
- */
5817
- var UndeclaredStage = class extends Error {
5818
- stage;
5819
- deployed;
5820
- constructor(stage, deployed) {
5821
- super(`"${stage}" is not a deployed stage. gkm.config.ts deploys to: ${deployed.join(", ") || "nothing yet"}.`);
5822
- this.stage = stage;
5823
- this.deployed = deployed;
5824
- this.name = "UndeclaredStage";
5757
+ Object.defineProperty(exports, "_enum", {
5758
+ enumerable: true,
5759
+ get: function() {
5760
+ return _enum;
5825
5761
  }
5826
- };
5827
- //#endregion
5828
- //#region src/workspace/schema.ts
5829
- /** Routes are a glob, or a list of them. */
5830
- const RoutesSchema = union([string(), array(string())]);
5831
- /**
5832
- * Telescope configuration schema.
5833
- */
5834
- const TelescopeConfigSchema = object({
5835
- enabled: boolean().optional(),
5836
- port: number().optional(),
5837
- path: string().optional(),
5838
- ignore: array(string()).optional(),
5839
- recordBody: boolean().optional(),
5840
- maxEntries: number().optional(),
5841
- websocket: boolean().optional()
5842
- });
5843
- /**
5844
- * OpenAPI configuration schema.
5845
- */
5846
- const OpenApiConfigSchema = object({
5847
- enabled: boolean().optional(),
5848
- title: string().optional(),
5849
- version: string().optional(),
5850
- description: string().optional()
5851
- });
5852
- /**
5853
- * Hooks configuration schema.
5854
- */
5855
- const HooksConfigSchema = object({ server: string().optional() });
5856
- /**
5857
- * Combined framework schema (backend, frontend, or mobile).
5858
- */
5859
- const FrameworkSchema = union([
5860
- _enum([
5861
- "hono",
5862
- "better-auth",
5863
- "express",
5864
- "fastify"
5865
- ]),
5866
- _enum([
5867
- "nextjs",
5868
- "remix",
5869
- "vite",
5870
- "tanstack-start"
5871
- ]),
5872
- _enum(["expo"])
5873
- ]);
5874
- /** Frontend framework values, kept in sync with FrontendFrameworkSchema. */
5875
- const FRONTEND_FRAMEWORKS = [
5876
- "nextjs",
5877
- "remix",
5878
- "vite",
5879
- "tanstack-start"
5880
- ];
5881
- /** Mobile framework values, kept in sync with MobileFrameworkSchema. */
5882
- const MOBILE_FRAMEWORKS = ["expo"];
5883
- /**
5884
- * A deploy target's name. Which names exist is the workspace's to say — the
5885
- * built-ins and its own `deploy.targets` — so it is checked against both
5886
- * once the whole config is read.
5887
- */
5888
- const DeployTargetSchema = string().min(1);
5889
- /**
5890
- * The built-in targets a config may name: `dokploy`, deployed by
5891
- * `gkm deploy`, and `sst`, deployed by `sst deploy` from the manifest
5892
- * `gkm build` writes.
5893
- */
5894
- const SUPPORTED_DEPLOY_TARGETS = configurableBuiltins();
5895
- /** Built-in names reserved for targets that do not exist yet. */
5896
- const PHASE_2_DEPLOY_TARGETS = Object.entries(BUILTIN_TARGETS).filter(([, target]) => target.status === "planned").map(([name]) => name);
5897
- /**
5898
- * Whether a config may name `target`: a usable built-in, or one of its own
5899
- * `deploy.targets`.
5900
- */
5901
- function isDeployTargetSupported(target, targets = {}) {
5902
- return SUPPORTED_DEPLOY_TARGETS.includes(target) || Object.hasOwn(targets, target);
5903
- }
5904
- /**
5905
- * Check if a deploy target is planned for Phase 2.
5906
- */
5907
- function isPhase2DeployTarget(target) {
5908
- return PHASE_2_DEPLOY_TARGETS.includes(target);
5909
- }
5910
- /**
5911
- * Get error message for unsupported deploy targets.
5912
- */
5913
- function getDeployTargetError(target, appName) {
5914
- if (isPhase2DeployTarget(target)) return `Deploy target "${target}"${appName ? ` for app "${appName}"` : ""} is coming in Phase 2. Currently "dokploy" and "sst" are supported.`;
5915
- 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(", ")}.`;
5916
- }
5917
- /**
5918
- * One `deploy.targets` entry: a package name, a target object, or either
5919
- * with options.
5920
- */
5921
- const DeployTargetEntrySchema = union([
5922
- string().min(1, "A target package name cannot be empty"),
5923
- custom((value) => isDeployTarget(value), { message: "Expected a package name, a target (defineTarget), or [package or target, options]" }),
5924
- tuple([union([string().min(1), custom((value) => isDeployTarget(value), { message: "Expected a package name or a target (defineTarget)" })]), unknown()])
5925
- ]);
5926
- /**
5927
- * Dokploy workspace configuration schema.
5928
- * Supports either a single endpoint or per-stage endpoints.
5929
- */
5930
- const DokployWorkspaceConfigSchema = object({
5931
- /** Single endpoint for all stages */
5932
- endpoint: url("Dokploy endpoint must be a valid URL").optional(),
5933
- /** Per-stage endpoints (stage name -> endpoint URL) */
5934
- endpoints: record(string(), url("Endpoint must be a valid URL")).optional(),
5935
- registry: string().optional(),
5936
- registryId: string().optional()
5937
- }).refine((data) => data.endpoint || data.endpoints, { message: "Either endpoint or endpoints must be provided" });
5938
- /**
5939
- * Valid AWS regions.
5940
- */
5941
- const AwsRegionSchema = _enum([
5942
- "us-east-1",
5943
- "us-east-2",
5944
- "us-west-1",
5945
- "us-west-2",
5946
- "af-south-1",
5947
- "ap-east-1",
5948
- "ap-south-1",
5949
- "ap-south-2",
5950
- "ap-southeast-1",
5951
- "ap-southeast-2",
5952
- "ap-southeast-3",
5953
- "ap-southeast-4",
5954
- "ap-northeast-1",
5955
- "ap-northeast-2",
5956
- "ap-northeast-3",
5957
- "ca-central-1",
5958
- "eu-central-1",
5959
- "eu-central-2",
5960
- "eu-west-1",
5961
- "eu-west-2",
5962
- "eu-west-3",
5963
- "eu-south-1",
5964
- "eu-south-2",
5965
- "eu-north-1",
5966
- "me-south-1",
5967
- "me-central-1",
5968
- "sa-east-1"
5969
- ]);
5970
- /**
5971
- * DNS record types supported across providers.
5972
- */
5973
- const DnsRecordTypeSchema = _enum([
5974
- "A",
5975
- "AAAA",
5976
- "CNAME",
5977
- "MX",
5978
- "TXT",
5979
- "NS",
5980
- "SRV",
5981
- "CAA"
5982
- ]);
5983
- object({
5984
- /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
5985
- name: string(),
5986
- /** Record type */
5987
- type: DnsRecordTypeSchema,
5988
- /** TTL in seconds */
5989
- ttl: number().int().positive(),
5990
- /** Record values */
5991
- values: array(string())
5992
- });
5993
- object({
5994
- /** The record that was upserted */
5995
- record: object({
5996
- /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
5997
- name: string(),
5998
- /** Record type */
5999
- type: DnsRecordTypeSchema,
6000
- /** TTL in seconds */
6001
- ttl: number().int().positive(),
6002
- /** Record value (IP address, hostname, etc.) */
6003
- value: string()
6004
- }),
6005
- /** Whether the record was created (true) or updated (false) */
6006
- created: boolean(),
6007
- /** Whether the record already existed with the same value */
6008
- unchanged: boolean()
6009
- });
6010
- /**
6011
- * Hostinger DNS provider config (without domain - domain is the record key).
6012
- */
6013
- const HostingerDnsProviderSchema = object({
6014
- provider: literal("hostinger"),
6015
- /** TTL in seconds (default: 300) */
6016
- ttl: number().int().positive().optional()
6017
- });
6018
- /**
6019
- * Route53 DNS provider config (without domain - domain is the record key).
6020
- */
6021
- const Route53DnsProviderSchema = object({
6022
- provider: literal("route53"),
6023
- /** AWS region (optional - uses AWS_REGION env var if not provided) */
6024
- region: AwsRegionSchema.optional(),
6025
- /** AWS profile name (optional - uses default credential chain if not provided) */
6026
- profile: string().optional(),
6027
- /** Hosted zone ID (optional - auto-detected from domain if not provided) */
6028
- hostedZoneId: string().optional(),
6029
- /** TTL in seconds (default: 300) */
6030
- ttl: number().int().positive().optional()
6031
- });
6032
- /**
6033
- * Cloudflare DNS provider config (placeholder for future).
6034
- */
6035
- const CloudflareDnsProviderSchema = object({
6036
- provider: literal("cloudflare"),
6037
- /** TTL in seconds (default: 300) */
6038
- ttl: number().int().positive().optional()
6039
- });
6040
- /**
6041
- * Manual DNS configuration (user handles DNS themselves).
6042
- */
6043
- const ManualDnsProviderSchema = object({ provider: literal("manual") });
6044
- /**
6045
- * Custom DNS provider config (user-provided implementation).
6046
- */
6047
- const CustomDnsProviderSchema = object({
6048
- /** Custom DnsProvider implementation */
6049
- 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" }),
6050
- /** TTL in seconds (default: 300) */
6051
- ttl: number().int().positive().optional()
6052
- });
6053
- /**
6054
- * Single DNS provider config (for one domain).
6055
- */
6056
- const DnsProviderSchema = union([discriminatedUnion("provider", [
6057
- HostingerDnsProviderSchema,
6058
- Route53DnsProviderSchema,
6059
- CloudflareDnsProviderSchema,
6060
- ManualDnsProviderSchema
6061
- ]), CustomDnsProviderSchema]);
6062
- /**
6063
- * DNS configuration schema.
6064
- *
6065
- * Maps root domains to their DNS provider configuration.
6066
- * Example:
6067
- * ```
6068
- * dns: {
6069
- * 'geekmidas.dev': { provider: 'hostinger' },
6070
- * 'geekmidas.com': { provider: 'route53' },
6071
- * }
6072
- * ```
6073
- *
6074
- * Supported providers:
6075
- * - 'hostinger': Use Hostinger DNS API
6076
- * - 'route53': Use AWS Route53
6077
- * - 'cloudflare': Use Cloudflare DNS API (future)
6078
- * - 'manual': Don't create records, just print required records
6079
- * - Custom: Provide a DnsProvider implementation
6080
- */
6081
- const DnsConfigSchema = record(string(), DnsProviderSchema);
6082
- const HostingerDnsConfigSchema = HostingerDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
6083
- const Route53DnsConfigSchema = Route53DnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
6084
- const CloudflareDnsConfigSchema = CloudflareDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
6085
- const ManualDnsConfigSchema = ManualDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
6086
- const CustomDnsConfigSchema = CustomDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
6087
- /**
6088
- * Combined DNS config that supports both new multi-domain and legacy single-domain formats.
6089
- */
6090
- const DnsConfigWithLegacySchema = union([DnsConfigSchema, union([discriminatedUnion("provider", [
6091
- HostingerDnsConfigSchema,
6092
- Route53DnsConfigSchema,
6093
- CloudflareDnsConfigSchema,
6094
- ManualDnsConfigSchema
6095
- ]), CustomDnsConfigSchema])]);
6096
- /**
6097
- * Backups configuration schema.
6098
- *
6099
- * Configures automatic backup destinations for database services.
6100
- * On first deploy, creates S3 bucket with unique name and IAM credentials.
6101
- */
6102
- const BackupsConfigSchema = object({
6103
- /** Backup storage type (currently only 's3' supported) */
6104
- type: literal("s3"),
6105
- /** AWS profile name for creating bucket/IAM resources */
6106
- profile: string().optional(),
6107
- /** AWS region for the backup bucket */
6108
- region: AwsRegionSchema,
6109
- /** Cron schedule for backups (default: '0 2 * * *' = 2 AM daily) */
6110
- schedule: string().optional(),
6111
- /** Number of backups to retain (default: 30) */
6112
- retention: number().optional()
6113
- });
6114
- /**
6115
- * Deploy configuration schema.
6116
- */
6117
- const DeployConfigSchema = object({
6118
- default: DeployTargetSchema.optional(),
6119
- targets: record(string(), DeployTargetEntrySchema).superRefine((targets, ctx) => {
6120
- for (const name of Object.keys(targets)) if (builtinTarget(name)) ctx.addIssue({
6121
- code: "custom",
6122
- message: `"${name}" is a built-in target; give this one a name of its own`,
6123
- path: [name]
6124
- });
6125
- }).optional(),
6126
- /** Whose deploy this is, on a target shared with other workspaces. */
6127
- namespace: string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "deploy.namespace must be lowercase letters and digits with single '-' between them").optional(),
6128
- /** Each deployed stage's base domain (stage name -> domain). */
6129
- domains: record(string(), string()).optional(),
6130
- dokploy: DokployWorkspaceConfigSchema.optional(),
6131
- dns: DnsConfigWithLegacySchema.optional(),
6132
- backups: BackupsConfigSchema.optional()
6133
- });
6134
- /**
6135
- * Models configuration schema.
6136
- */
6137
- const ModelsConfigSchema = object({
6138
- path: string().optional(),
6139
- schema: _enum(["zod"]).optional()
6140
- });
6141
- /**
6142
- * Shared configuration schema.
6143
- */
6144
- const SharedConfigSchema = object({
6145
- packages: array(string()).optional(),
6146
- models: ModelsConfigSchema.optional()
6147
- });
6148
- /**
6149
- * Secrets configuration schema.
6150
- */
6151
- const StagesConfigSchema = object({
6152
- local: string(),
6153
- deployed: array(string()),
6154
- protected: array(string()).optional()
6155
- }).superRefine((stages, ctx) => {
6156
- for (const message of stageProblems(stages)) ctx.addIssue({
6157
- code: "custom",
6158
- message
6159
- });
6160
- });
6161
- const SecretsStoreSchema = union([
6162
- literal("file"),
6163
- object({
6164
- provider: literal("ssm"),
6165
- region: AwsRegionSchema
6166
- }).strict(),
6167
- object({
6168
- /** Any backend: an object implementing SecretsStore */
6169
- 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()" }) })
6170
- ]);
6171
- const SecretsConfigSchema = object({
6172
- enabled: boolean().optional(),
6173
- store: SecretsStoreSchema.optional(),
6174
- algorithm: string().optional(),
6175
- kdf: _enum(["scrypt", "pbkdf2"]).optional()
6176
- });
6177
- /**
6178
- * Local state provider config.
6179
- */
6180
- const LocalStateConfigSchema = object({ provider: literal("local") });
6181
- /**
6182
- * SSM state provider config (requires region).
6183
- */
6184
- const SSMStateConfigSchema = object({
6185
- provider: literal("ssm"),
6186
- /** AWS region (required for SSM provider) */
6187
- region: AwsRegionSchema,
6188
- /** AWS profile name (optional - uses default credential chain if not provided) */
6189
- profile: string().optional()
6190
5762
  });
6191
- /**
6192
- * S3 state provider config: conditional writes and a lock object in a bucket.
6193
- */
6194
- const S3StateConfigSchema = object({
6195
- provider: literal("s3"),
6196
- /** Bucket the state lives in (must already exist) */
6197
- bucket: string().min(1),
6198
- /** AWS region of the bucket */
6199
- region: AwsRegionSchema,
6200
- /** Key prefix inside the bucket (default: 'gkm') */
6201
- prefix: string().optional(),
6202
- /** AWS profile name (optional - uses default credential chain if not provided) */
6203
- profile: string().optional()
6204
- });
6205
- /**
6206
- * Custom state provider config (user-provided implementation).
6207
- */
6208
- const CustomStateConfigSchema = object({
6209
- /** Custom StateProvider implementation */
6210
- 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" }) });
6211
- /**
6212
- * State configuration schema.
6213
- *
6214
- * Configures how deployment state is stored.
6215
- * - 'local': Store in .gkm/deploy-{stage}.json (default)
6216
- * - 'ssm': Store in AWS SSM Parameter Store (requires region)
6217
- * - 's3': Store in an S3 bucket with conditional writes (requires bucket, region)
6218
- * - Custom: Provide a StateStore, or a StateProvider with read/write methods
6219
- */
6220
- const StateConfigSchema = union([discriminatedUnion("provider", [
6221
- LocalStateConfigSchema,
6222
- SSMStateConfigSchema,
6223
- S3StateConfigSchema
6224
- ]), CustomStateConfigSchema]);
6225
- /**
6226
- * App configuration schema.
6227
- */
6228
- const AppConfigSchema = object({
6229
- type: _enum([
6230
- "backend",
6231
- "web",
6232
- "mobile"
6233
- ]).optional().default("backend"),
6234
- path: string().min(1, "App path is required"),
6235
- port: number().int().positive("Port must be a positive integer"),
6236
- dependencies: array(string()).optional(),
6237
- deploy: DeployTargetSchema.optional(),
6238
- constructs: RoutesSchema.optional(),
6239
- routes: RoutesSchema.optional(),
6240
- functions: RoutesSchema.optional(),
6241
- crons: RoutesSchema.optional(),
6242
- queues: RoutesSchema.optional(),
6243
- topics: RoutesSchema.optional(),
6244
- subscribers: RoutesSchema.optional(),
6245
- envParser: string().optional(),
6246
- logger: string().optional(),
6247
- hooks: HooksConfigSchema.optional(),
6248
- telescope: union([
6249
- string(),
6250
- boolean(),
6251
- TelescopeConfigSchema
6252
- ]).optional(),
6253
- openapi: union([boolean(), OpenApiConfigSchema]).optional(),
6254
- runtime: _enum(["node", "bun"]).optional(),
6255
- env: union([string(), array(string())]).optional(),
6256
- entry: string().optional(),
6257
- framework: FrameworkSchema.optional(),
6258
- config: object({
6259
- client: string().optional(),
6260
- server: string().optional()
6261
- }).optional()
6262
- }).refine((data) => {
6263
- if (data.type === "web") {
6264
- if (!data.framework || !FRONTEND_FRAMEWORKS.includes(data.framework)) return false;
5763
+ Object.defineProperty(exports, "array", {
5764
+ enumerable: true,
5765
+ get: function() {
5766
+ return array;
6265
5767
  }
6266
- return true;
6267
- }, {
6268
- message: `Web apps must have a valid web framework (${FRONTEND_FRAMEWORKS.join(", ")})`,
6269
- path: ["framework"]
6270
- }).refine((data) => {
6271
- if (data.type === "mobile") {
6272
- if (!data.framework || !MOBILE_FRAMEWORKS.includes(data.framework)) return false;
5768
+ });
5769
+ Object.defineProperty(exports, "boolean", {
5770
+ enumerable: true,
5771
+ get: function() {
5772
+ return boolean;
6273
5773
  }
6274
- return true;
6275
- }, {
6276
- message: `Mobile apps must have a valid mobile framework (${MOBILE_FRAMEWORKS.join(", ")})`,
6277
- path: ["framework"]
6278
- });
6279
- /** What `gkm test` hands a feature test. */
6280
- const TestConfigSchema = object({
6281
- /** The folder of per-database factories; `test/factories` by default. */
6282
- factories: string().optional() }).strict();
6283
- /** How `gkm dev` is reached from outside the apps it runs. */
6284
- const DevConfigSchema = object({
6285
- /** Browser origins that may read the discovery endpoint. */
6286
- 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(),
6287
- /** The discovery endpoint's loopback port; 4983 by default. */
6288
- discoveryPort: number().int().min(0).max(65535).optional()
6289
- }).strict();
6290
- /**
6291
- * Workspace configuration schema.
6292
- */
6293
- const WorkspaceConfigSchema = object({
6294
- name: string().optional(),
6295
- /**
6296
- * Where the workspace's own constructs live, relative to its root.
6297
- *
6298
- * Infrastructure is a fact about the product, not about the process that
6299
- * happens to import it — so a database two apps share is declared once,
6300
- * at the top, and both find it. An app-level glob still works and is
6301
- * additive, for something only one app uses.
6302
- */
6303
- constructs: RoutesSchema.optional(),
6304
- /**
6305
- * Apps that nothing declares.
6306
- *
6307
- * Optional, and normally absent: a `site` is an app and so is a
6308
- * `rest-api` that named one, so the list is read off the graph. This is
6309
- * the escape hatch for what no construct describes — a mobile app, a
6310
- * process someone runs by hand — and for overriding one field of a
6311
- * derived app without restating it.
6312
- */
6313
- apps: record(string(), AppConfigSchema).optional(),
6314
- shared: SharedConfigSchema.optional(),
6315
- deploy: DeployConfigSchema.optional(),
6316
- stages: StagesConfigSchema,
6317
- secrets: SecretsConfigSchema.optional(),
6318
- state: StateConfigSchema.optional(),
6319
- test: TestConfigSchema.optional(),
6320
- dev: DevConfigSchema.optional()
6321
- }).strict().refine((data) => {
6322
- const appNames = Object.keys(data.apps ?? {});
6323
- for (const [appName, app] of Object.entries(data.apps ?? {})) for (const dep of app.dependencies ?? []) {
6324
- if (!appNames.includes(dep)) return false;
6325
- if (dep === appName) return false;
5774
+ });
5775
+ Object.defineProperty(exports, "custom", {
5776
+ enumerable: true,
5777
+ get: function() {
5778
+ return custom;
6326
5779
  }
6327
- return true;
6328
- }, { message: "App dependencies must reference existing apps and cannot be self-referential" }).refine((data) => {
6329
- const appNames = Object.keys(data.apps ?? {});
6330
- const visited = /* @__PURE__ */ new Set();
6331
- const recStack = /* @__PURE__ */ new Set();
6332
- function hasCycle(app) {
6333
- if (recStack.has(app)) return true;
6334
- if (visited.has(app)) return false;
6335
- visited.add(app);
6336
- recStack.add(app);
6337
- const deps = data.apps?.[app]?.dependencies ?? [];
6338
- for (const dep of deps) if (hasCycle(dep)) return true;
6339
- recStack.delete(app);
6340
- return false;
5780
+ });
5781
+ Object.defineProperty(exports, "discriminatedUnion", {
5782
+ enumerable: true,
5783
+ get: function() {
5784
+ return discriminatedUnion;
6341
5785
  }
6342
- for (const app of appNames) {
6343
- visited.clear();
6344
- recStack.clear();
6345
- if (hasCycle(app)) return false;
5786
+ });
5787
+ Object.defineProperty(exports, "literal", {
5788
+ enumerable: true,
5789
+ get: function() {
5790
+ return literal;
6346
5791
  }
6347
- return true;
6348
- }, { message: "Circular dependencies detected between apps" }).superRefine((data, ctx) => {
6349
- const defaultTarget = data.deploy?.default;
6350
- const ownTargets = data.deploy?.targets ?? {};
6351
- if (defaultTarget && !isDeployTargetSupported(defaultTarget, ownTargets)) {
6352
- ctx.addIssue({
6353
- code: "custom",
6354
- message: getDeployTargetError(defaultTarget),
6355
- path: ["deploy", "default"]
6356
- });
6357
- return;
5792
+ });
5793
+ Object.defineProperty(exports, "number", {
5794
+ enumerable: true,
5795
+ get: function() {
5796
+ return number;
6358
5797
  }
6359
- for (const [appName, app] of Object.entries(data.apps ?? {})) if (app.deploy && !isDeployTargetSupported(app.deploy, ownTargets)) {
6360
- ctx.addIssue({
6361
- code: "custom",
6362
- message: getDeployTargetError(app.deploy, appName),
6363
- path: [
6364
- "apps",
6365
- appName,
6366
- "deploy"
6367
- ]
6368
- });
6369
- return;
5798
+ });
5799
+ Object.defineProperty(exports, "object", {
5800
+ enumerable: true,
5801
+ get: function() {
5802
+ return object;
6370
5803
  }
6371
- if (data.state?.provider === "ssm" && !data.name) ctx.addIssue({
6372
- code: "custom",
6373
- message: "Workspace name is required when using SSM state provider. Add \"name\" to your gkm.config.ts.",
6374
- path: ["name"]
6375
- });
6376
5804
  });
6377
- /**
6378
- * Validate workspace configuration.
6379
- * Throws ZodError with detailed messages on validation failure.
6380
- */
6381
- function validateWorkspaceConfig(config) {
6382
- return WorkspaceConfigSchema.parse(config);
6383
- }
6384
- /**
6385
- * Safe validation that returns result instead of throwing.
6386
- */
6387
- function safeValidateWorkspaceConfig(config) {
6388
- const result = WorkspaceConfigSchema.safeParse(config);
6389
- if (result.success) return {
6390
- success: true,
6391
- data: result.data
6392
- };
6393
- return {
6394
- success: false,
6395
- error: result.error
6396
- };
6397
- }
6398
- /**
6399
- * Format Zod errors into user-friendly messages.
6400
- */
6401
- function formatValidationErrors(error) {
6402
- return `Workspace configuration validation failed:\n${error.issues.map((issue) => {
6403
- const path = issue.path.join(".");
6404
- return path ? ` - ${path}: ${issue.message}` : ` - ${issue.message}`;
6405
- }).join("\n")}`;
6406
- }
6407
- //#endregion
6408
- //#region src/workspace/types.ts
6409
- /**
6410
- * Type guard to check if a config is a WorkspaceConfig.
6411
- *
6412
- * @example
6413
- * ```ts
6414
- * const config = await loadConfig();
6415
- * if (isWorkspaceConfig(config)) {
6416
- * // config.apps is available
6417
- * console.log(Object.keys(config.apps));
6418
- * }
6419
- * ```
6420
- */
6421
- function isWorkspaceConfig(config) {
6422
- if (typeof config !== "object" || config === null) return false;
6423
- if ("apps" in config && typeof config.apps === "object") return true;
6424
- return "constructs" in config && Object.keys(config).every((key) => WORKSPACE_KEYS.has(key));
6425
- }
6426
- /** Every top-level key a workspace config has — see `WorkspaceConfigSchema`. */
6427
- const WORKSPACE_KEYS = /* @__PURE__ */ new Set([
6428
- "name",
6429
- "constructs",
6430
- "apps",
6431
- "shared",
6432
- "deploy",
6433
- "stages",
6434
- "secrets",
6435
- "state"
6436
- ]);
6437
- //#endregion
6438
- //#region src/workspace/publicEnv.ts
6439
- /**
6440
- * All public env-var prefixes the toolbox understands.
6441
- *
6442
- * Used when resolving incoming var names back to a dependency
6443
- * (e.g. `VITE_AUTH_URL` → `auth`). A var matching any of these
6444
- * is considered safe to inline into a client bundle.
6445
- */
6446
- const PUBLIC_ENV_PREFIXES = [
6447
- "NEXT_PUBLIC_",
6448
- "VITE_",
6449
- "EXPO_PUBLIC_"
6450
- ];
6451
- /**
6452
- * Resolve the public env-var prefix that a frontend framework's bundler
6453
- * inlines into client code at build time:
6454
- *
6455
- * - `nextjs` → `NEXT_PUBLIC_`
6456
- * - `vite` → `VITE_`
6457
- * - `tanstack-start` → `VITE_` (uses Vite under the hood)
6458
- * - `expo` → `EXPO_PUBLIC_`
6459
- * - `remix` → `''` (Remix exposes via loaders, no prefix convention)
6460
- *
6461
- * For backend frameworks or unspecified, falls back to `NEXT_PUBLIC_` to
6462
- * preserve the historical default. Backend apps never read these vars
6463
- * from a bundle, so the prefix only affects scaffolding/symmetry.
6464
- */
6465
- function getPublicEnvPrefix(framework) {
6466
- switch (framework) {
6467
- case "vite":
6468
- case "tanstack-start": return "VITE_";
6469
- case "expo": return "EXPO_PUBLIC_";
6470
- case "remix": return "";
6471
- case "nextjs": return "NEXT_PUBLIC_";
6472
- default: return "NEXT_PUBLIC_";
5805
+ Object.defineProperty(exports, "record", {
5806
+ enumerable: true,
5807
+ get: function() {
5808
+ return record;
6473
5809
  }
6474
- }
6475
- /**
6476
- * Strip a known public prefix from a var name.
6477
- * Returns the un-prefixed name, or `null` if no prefix matched.
6478
- */
6479
- function stripPublicPrefix(name) {
6480
- for (const prefix of PUBLIC_ENV_PREFIXES) if (prefix && name.startsWith(prefix)) return name.slice(prefix.length);
6481
- return null;
6482
- }
6483
- //#endregion
6484
- //#region src/workspace/index.ts
6485
- /**
6486
- * Validate that all dependencies reference existing apps.
6487
- * Returns the config if valid, throws otherwise.
6488
- */
6489
- function validateDependencies(apps) {
6490
- const appNames = new Set(Object.keys(apps));
6491
- for (const [appName, app] of Object.entries(apps)) for (const dep of app.dependencies ?? []) {
6492
- if (!appNames.has(dep)) throw new Error(`Invalid dependency: App "${appName}" depends on "${dep}" which does not exist. Valid apps are: ${[...appNames].join(", ")}`);
6493
- if (dep === appName) throw new Error(`Invalid dependency: App "${appName}" cannot depend on itself.`);
5810
+ });
5811
+ Object.defineProperty(exports, "string", {
5812
+ enumerable: true,
5813
+ get: function() {
5814
+ return string;
6494
5815
  }
6495
- }
6496
- /**
6497
- * Define workspace configuration with full TypeScript support and type inference.
6498
- *
6499
- * Uses `const` type parameter to infer literal app names, providing:
6500
- * - Autocomplete for app names in dependencies
6501
- * - Type errors for invalid dependency references
6502
- * - Full type inference for the returned config
6503
- *
6504
- * @example
6505
- * ```ts
6506
- * // gkm.config.ts
6507
- * import { defineWorkspace } from '@geekmidas/cli';
6508
- *
6509
- * export default defineWorkspace({
6510
- * name: 'my-saas',
6511
- * apps: {
6512
- * api: {
6513
- * type: 'backend',
6514
- * path: 'apps/api',
6515
- * port: 3000,
6516
- * routes: './src/endpoints/**\/*.ts',
6517
- * envParser: './src/config/env',
6518
- * logger: './src/logger',
6519
- * },
6520
- * web: {
6521
- * type: 'web',
6522
- * framework: 'nextjs',
6523
- * path: 'apps/web',
6524
- * port: 3001,
6525
- * dependencies: ['api'], // <- autocomplete shows 'api' | 'web'
6526
- * },
6527
- * },
6528
- * });
6529
- *
6530
- * // config.apps.api <- full type inference
6531
- * // config.apps.foo <- TypeScript error
6532
- * ```
6533
- */
6534
- function defineWorkspace(config) {
6535
- if (config.apps) validateDependencies(config.apps);
6536
- const result = safeValidateWorkspaceConfig(config);
6537
- if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
6538
- return config;
6539
- }
6540
- /**
6541
- * Get the package name from package.json in the given directory.
6542
- */
6543
- function getPackageName(cwd) {
6544
- try {
6545
- return __require(`${cwd}/package.json`).name?.replace(/^@[^/]+\//, "");
6546
- } catch {
6547
- return;
5816
+ });
5817
+ Object.defineProperty(exports, "tuple", {
5818
+ enumerable: true,
5819
+ get: function() {
5820
+ return tuple;
6548
5821
  }
6549
- }
6550
- /**
6551
- * Normalize a workspace configuration with resolved defaults.
6552
- */
6553
- function normalizeWorkspace(config, cwd) {
6554
- const name = config.name ?? getPackageName(cwd) ?? basename(cwd);
6555
- const defaultTarget = config.deploy?.default ?? "dokploy";
6556
- const normalizedApps = {};
6557
- for (const [appName, app] of Object.entries(config.apps ?? {})) normalizedApps[appName] = normalizeAppConfig(app, defaultTarget);
6558
- return {
6559
- name,
6560
- root: cwd,
6561
- ...config.constructs ? { constructs: config.constructs } : {},
6562
- apps: normalizedApps,
6563
- deploy: config.deploy ?? { default: "dokploy" },
6564
- shared: config.shared ?? { packages: ["packages/*"] },
6565
- stages: validateStages(config.stages),
6566
- secrets: config.secrets ?? {},
6567
- state: config.state,
6568
- test: config.test ?? {},
6569
- ...config.dev ? { dev: config.dev } : {}
6570
- };
6571
- }
6572
- /**
6573
- * Normalize an app configuration with resolved defaults.
6574
- * @param app - App configuration
6575
- * @param defaultTarget - Default deploy target from workspace config
6576
- */
6577
- function normalizeAppConfig(app, defaultTarget) {
6578
- return {
6579
- ...app,
6580
- type: app.type ?? "backend",
6581
- port: app.port,
6582
- path: app.path,
6583
- dependencies: app.dependencies ?? [],
6584
- resolvedDeployTarget: app.deploy ?? defaultTarget
6585
- };
6586
- }
6587
- /**
6588
- * Wrap a single-app GkmConfig as a workspace.
6589
- * This allows existing single-app configs to work seamlessly.
6590
- */
6591
- function wrapSingleAppAsWorkspace(config, cwd) {
6592
- return {
6593
- name: config.name ?? getPackageName(cwd) ?? basename(cwd),
6594
- root: cwd,
6595
- apps: { api: {
6596
- type: "backend",
6597
- path: ".",
6598
- port: 3e3,
6599
- dependencies: [],
6600
- resolvedDeployTarget: config.deploy?.default ?? "dokploy",
6601
- constructs: config.constructs,
6602
- hooks: config.hooks,
6603
- telescope: config.telescope,
6604
- openapi: config.openapi,
6605
- runtime: config.runtime,
6606
- env: config.env
6607
- } },
6608
- deploy: {
6609
- default: "dokploy",
6610
- ...config.deploy
6611
- },
6612
- shared: { packages: [] },
6613
- stages: validateStages(config.stages),
6614
- secrets: config.secrets ?? {},
6615
- test: config.test ?? {},
6616
- ...config.dev ? { dev: config.dev } : {}
6617
- };
6618
- }
6619
- /**
6620
- * Process a loaded configuration (either single-app or workspace).
6621
- * Returns a normalized workspace in both cases.
6622
- */
6623
- function processConfig(config, cwd) {
6624
- if (isWorkspaceConfig(config)) {
6625
- const result = safeValidateWorkspaceConfig(config);
6626
- if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
6627
- return {
6628
- type: "workspace",
6629
- raw: config,
6630
- workspace: normalizeWorkspace(config, cwd)
6631
- };
5822
+ });
5823
+ Object.defineProperty(exports, "union", {
5824
+ enumerable: true,
5825
+ get: function() {
5826
+ return union;
6632
5827
  }
6633
- return {
6634
- type: "single",
6635
- raw: config,
6636
- workspace: wrapSingleAppAsWorkspace(config, cwd)
6637
- };
6638
- }
6639
- /**
6640
- * The workspace's own constructs globs, absolute.
6641
- *
6642
- * Infrastructure two apps share is a fact about the product, and declaring it
6643
- * inside one of them makes moving that app a change to the other's database.
6644
- */
6645
- function workspaceConstructGlobs(workspace) {
6646
- return constructPatterns(workspace.constructs).map((pattern) => isAbsolute(pattern) ? pattern : join(workspace.root, pattern));
6647
- }
6648
- /**
6649
- * Every constructs glob an app can see, absolute.
6650
- *
6651
- * The workspace's own first, then the app's. Absolute because the app builds
6652
- * from its own directory while the workspace's constructs live above it —
6653
- * a relative glob resolved from the app would look for the product's
6654
- * infrastructure inside one of its consumers and find nothing.
6655
- *
6656
- * Additive, not overriding: an app that declares its own constructs still sees
6657
- * the ones the workspace declared for everybody.
6658
- */
6659
- function appConstructGlobs(workspace, appName) {
6660
- const globs = workspaceConstructGlobs(workspace);
6661
- const app = workspace.apps[appName];
6662
- if (app) {
6663
- const root = isAbsolute(app.path) ? app.path : join(workspace.root, app.path);
6664
- for (const pattern of constructPatterns(app.constructs)) globs.push(isAbsolute(pattern) ? pattern : join(root, pattern));
5828
+ });
5829
+ Object.defineProperty(exports, "unknown", {
5830
+ enumerable: true,
5831
+ get: function() {
5832
+ return unknown;
6665
5833
  }
6666
- return globs;
6667
- }
6668
- /**
6669
- * Every constructs glob in the workspace: its own, plus each app's.
6670
- *
6671
- * One list, so what a deploy provisions and what an app's entry point
6672
- * registers drivers for are read off the same globs.
6673
- */
6674
- function allConstructGlobs(workspace) {
6675
- const globs = [...workspaceConstructGlobs(workspace), ...Object.keys(workspace.apps).flatMap((appName) => appConstructGlobs(workspace, appName))];
6676
- return [...new Set(globs)];
6677
- }
6678
- /** A `Routes` in any of its accepted shapes, as a flat list of patterns. */
6679
- function constructPatterns(routes) {
6680
- if (!routes) return [];
6681
- return typeof routes === "string" ? [routes] : routes;
6682
- }
6683
- /**
6684
- * Get the GkmConfig for a specific app in a workspace.
6685
- * Useful for running existing single-app commands on a specific app.
6686
- */
6687
- function getAppGkmConfig(workspace, appName) {
6688
- const app = workspace.apps[appName];
6689
- if (!app || app.type !== "backend") return;
6690
- return {
6691
- ...workspace.deploy ? { deploy: workspace.deploy } : {},
6692
- stages: workspace.stages,
6693
- constructs: appConstructGlobs(workspace, appName),
6694
- hooks: app.hooks,
6695
- telescope: app.telescope,
6696
- openapi: app.openapi,
6697
- runtime: app.runtime,
6698
- env: app.env
6699
- };
6700
- }
6701
- /**
6702
- * Get topologically sorted app names based on dependencies.
6703
- * Apps with no dependencies come first, then apps that depend on them.
6704
- */
6705
- function getAppBuildOrder(workspace) {
6706
- const appNames = Object.keys(workspace.apps);
6707
- const visited = /* @__PURE__ */ new Set();
6708
- const result = [];
6709
- function visit(name) {
6710
- if (visited.has(name)) return;
6711
- visited.add(name);
6712
- const app = workspace.apps[name];
6713
- if (app) for (const dep of app.dependencies) visit(dep);
6714
- result.push(name);
5834
+ });
5835
+ Object.defineProperty(exports, "url", {
5836
+ enumerable: true,
5837
+ get: function() {
5838
+ return url;
6715
5839
  }
6716
- for (const name of appNames) visit(name);
6717
- return result;
6718
- }
6719
- /**
6720
- * Resolve the Dokploy endpoint for a specific stage.
6721
- *
6722
- * Uses per-stage endpoint from `endpoints` if available,
6723
- * otherwise falls back to the global `endpoint`.
6724
- *
6725
- * @param dokployConfig - Dokploy workspace configuration
6726
- * @param stage - Deployment stage (e.g., 'development', 'production')
6727
- * @returns The endpoint URL for the stage, or undefined if not configured
6728
- *
6729
- * @example
6730
- * ```ts
6731
- * // With per-stage endpoints
6732
- * const config = {
6733
- * endpoints: {
6734
- * development: 'https://dev.dokploy.example.com:3000',
6735
- * production: 'https://prod.dokploy.example.com:3000',
6736
- * },
6737
- * };
6738
- * getEndpointForStage(config, 'production'); // => 'https://prod.dokploy.example.com:3000'
6739
- *
6740
- * // With single endpoint
6741
- * const config = { endpoint: 'https://dokploy.example.com:3000' };
6742
- * getEndpointForStage(config, 'production'); // => 'https://dokploy.example.com:3000'
6743
- * ```
6744
- */
6745
- function getEndpointForStage(dokployConfig, stage) {
6746
- if (!dokployConfig) return void 0;
6747
- if (dokployConfig.endpoints?.[stage]) return dokployConfig.endpoints[stage];
6748
- return dokployConfig.endpoint;
6749
- }
6750
- //#endregion
6751
- export { safeValidateWorkspaceConfig as C, assertDeployedStage as D, TEST_STAGE as E, deployedProblems as O, isPhase2DeployTarget as S, InvalidStages as T, SUPPORTED_DEPLOY_TARGETS as _, getAppBuildOrder as a, getDeployTargetError as b, normalizeWorkspace as c, wrapSingleAppAsWorkspace as d, PUBLIC_ENV_PREFIXES as f, PHASE_2_DEPLOY_TARGETS as g, isWorkspaceConfig as h, defineWorkspace as i, stageProblems as k, processConfig as l, stripPublicPrefix as m, appConstructGlobs as n, getAppGkmConfig as o, getPublicEnvPrefix as p, constructPatterns as r, getEndpointForStage as s, allConstructGlobs as t, workspaceConstructGlobs as u, WorkspaceConfigSchema as v, validateWorkspaceConfig as w, isDeployTargetSupported as x, formatValidationErrors as y };
5840
+ });
6752
5841
 
6753
- //# sourceMappingURL=workspace-BFe57es7.mjs.map
5842
+ //# sourceMappingURL=schemas-Ckm_aBnF.cjs.map