@geekmidas/cli 10.0.0-alpha.3 → 10.0.0-alpha.31

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 (255) hide show
  1. package/README.md +25 -48
  2. package/bin/adjacent-tsconfig.mjs +97 -0
  3. package/bin/gkm.mjs +7 -1
  4. package/dist/{HostingerProvider-h3EbEp-Z.cjs → HostingerProvider-BZFGYYVA.cjs} +21 -22
  5. package/dist/HostingerProvider-BZFGYYVA.cjs.map +1 -0
  6. package/dist/{HostingerProvider-Cft7lEYr.mjs → HostingerProvider-GF6NAZAK.mjs} +20 -21
  7. package/dist/HostingerProvider-GF6NAZAK.mjs.map +1 -0
  8. package/dist/{LocalStateProvider-Db9SEjyH.cjs → LocalStateProvider-7HR6SS2t.cjs} +11 -6
  9. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +1 -0
  10. package/dist/{LocalStateProvider-Bn6tS-oL.mjs → LocalStateProvider-D7QyJoLM.mjs} +10 -4
  11. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +1 -0
  12. package/dist/{openapi-c9bpieI5.cjs → OpenApiTsGenerator-D1nhN98m.cjs} +135 -298
  13. package/dist/OpenApiTsGenerator-D1nhN98m.cjs.map +1 -0
  14. package/dist/{openapi-CY9xFkTH.mjs → OpenApiTsGenerator-hDINScnz.mjs} +106 -250
  15. package/dist/OpenApiTsGenerator-hDINScnz.mjs.map +1 -0
  16. package/dist/{Route53Provider-RdpUDJQk.mjs → Route53Provider-Cvj40A8I.mjs} +12 -12
  17. package/dist/Route53Provider-Cvj40A8I.mjs.map +1 -0
  18. package/dist/{Route53Provider-di2fMM5N.cjs → Route53Provider-DVILBsvV.cjs} +20 -21
  19. package/dist/Route53Provider-DVILBsvV.cjs.map +1 -0
  20. package/dist/{SSMStateProvider-BRt2py-A.mjs → SSMStateProvider-B0Hu1MKZ.mjs} +13 -4
  21. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +1 -0
  22. package/dist/{SSMStateProvider-DyX8s9HI.cjs → SSMStateProvider-VrQ-yeqd.cjs} +17 -9
  23. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +1 -0
  24. package/dist/{backup-provisioner-BrsHwYG0.cjs → backup-provisioner-BmhIO_Yr.cjs} +21 -19
  25. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +1 -0
  26. package/dist/{backup-provisioner-Bgj5Vi_L.mjs → backup-provisioner-DIVCbfee.mjs} +10 -7
  27. package/dist/backup-provisioner-DIVCbfee.mjs.map +1 -0
  28. package/dist/{bundler-BY1OmV1e.cjs → bundler-CYF5mWi9.cjs} +10 -28
  29. package/dist/bundler-CYF5mWi9.cjs.map +1 -0
  30. package/dist/{bundler-Be8Zg4Wd.mjs → bundler-D9IPNvDt.mjs} +9 -26
  31. package/dist/bundler-D9IPNvDt.mjs.map +1 -0
  32. package/dist/{config-CzWnfcXM.mjs → config-BH3Ki69F.mjs} +49 -89
  33. package/dist/config-BH3Ki69F.mjs.map +1 -0
  34. package/dist/{config-BholeD-0.cjs → config-URVD4bTj.cjs} +101 -148
  35. package/dist/config-URVD4bTj.cjs.map +1 -0
  36. package/dist/config.cjs +5 -5
  37. package/dist/config.d.cts +25 -17
  38. package/dist/config.d.cts.map +1 -1
  39. package/dist/config.d.mts +25 -17
  40. package/dist/config.d.mts.map +1 -1
  41. package/dist/config.mjs +3 -5
  42. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  43. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  44. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  45. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  46. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  47. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  48. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  49. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  50. package/dist/deploy/sniffer-hooks.cjs +13 -7
  51. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  52. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  53. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  54. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  55. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  56. package/dist/deploy/sniffer-hooks.mjs +9 -2
  57. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  58. package/dist/deploy/sniffer-loader.cjs +16 -7
  59. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  60. package/dist/deploy/sniffer-loader.d.cts +1 -1
  61. package/dist/deploy/sniffer-loader.d.mts +1 -1
  62. package/dist/deploy/sniffer-loader.mjs +13 -2
  63. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  64. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  65. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  66. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  67. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  68. package/dist/deploy/sniffer-routes-worker.mjs +3 -3
  69. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  70. package/dist/deploy/sniffer-worker.cjs +15 -6
  71. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  72. package/dist/deploy/sniffer-worker.d.cts +1 -3
  73. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  74. package/dist/deploy/sniffer-worker.d.mts +1 -3
  75. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  76. package/dist/deploy/sniffer-worker.mjs +15 -4
  77. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  78. package/dist/{discover-CAlFgYec.mjs → discover-CMxesskG.mjs} +66 -22
  79. package/dist/discover-CMxesskG.mjs.map +1 -0
  80. package/dist/{discover-DTmFeloL.cjs → discover-CroTIm0K.cjs} +117 -66
  81. package/dist/discover-CroTIm0K.cjs.map +1 -0
  82. package/dist/{emit-CbcRolsa.cjs → emit-BdoPFjZf.cjs} +53 -36
  83. package/dist/emit-BdoPFjZf.cjs.map +1 -0
  84. package/dist/{emit-CiZS_5Ub.mjs → emit-Bzq7JsMP.mjs} +24 -6
  85. package/dist/emit-Bzq7JsMP.mjs.map +1 -0
  86. package/dist/github-B2fis34P.cjs +216 -0
  87. package/dist/github-B2fis34P.cjs.map +1 -0
  88. package/dist/github-BrDmlm1x.mjs +216 -0
  89. package/dist/github-BrDmlm1x.mjs.map +1 -0
  90. package/dist/{index-CHB4tSzX.d.cts → index-p89EzILa.d.mts} +4 -23
  91. package/dist/index-p89EzILa.d.mts.map +1 -0
  92. package/dist/{index-BThUzEIp.d.mts → index-rU9u761a.d.cts} +4 -23
  93. package/dist/index-rU9u761a.d.cts.map +1 -0
  94. package/dist/index.cjs +6028 -4452
  95. package/dist/index.cjs.map +1 -1
  96. package/dist/index.d.cts +1 -1
  97. package/dist/index.d.mts +1 -1
  98. package/dist/index.mjs +5922 -4367
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/migrate-BuCx7tIv.cjs +498 -0
  101. package/dist/migrate-BuCx7tIv.cjs.map +1 -0
  102. package/dist/migrate-CBICVMAi.mjs +493 -0
  103. package/dist/migrate-CBICVMAi.mjs.map +1 -0
  104. package/dist/openapi.cjs +197 -8
  105. package/dist/openapi.cjs.map +1 -0
  106. package/dist/openapi.d.cts +47 -14
  107. package/dist/openapi.d.cts.map +1 -1
  108. package/dist/openapi.d.mts +47 -14
  109. package/dist/openapi.d.mts.map +1 -1
  110. package/dist/openapi.mjs +191 -5
  111. package/dist/openapi.mjs.map +1 -0
  112. package/dist/ready-CvP3JVEw.mjs +355 -0
  113. package/dist/ready-CvP3JVEw.mjs.map +1 -0
  114. package/dist/ready-DXtNfk7v.cjs +390 -0
  115. package/dist/ready-DXtNfk7v.cjs.map +1 -0
  116. package/dist/reconcile/public.cjs +4 -4
  117. package/dist/reconcile/public.d.cts +27 -26
  118. package/dist/reconcile/public.d.cts.map +1 -1
  119. package/dist/reconcile/public.d.mts +27 -26
  120. package/dist/reconcile/public.d.mts.map +1 -1
  121. package/dist/reconcile/public.mjs +3 -4
  122. package/dist/reconcile-BxZTV2vl.cjs +332 -0
  123. package/dist/reconcile-BxZTV2vl.cjs.map +1 -0
  124. package/dist/reconcile-yNq6Shau.mjs +279 -0
  125. package/dist/reconcile-yNq6Shau.mjs.map +1 -0
  126. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  127. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  128. package/dist/ssm-BKN1Cg4z.mjs +60 -0
  129. package/dist/ssm-BKN1Cg4z.mjs.map +1 -0
  130. package/dist/ssm-FxeSAt35.cjs +60 -0
  131. package/dist/ssm-FxeSAt35.cjs.map +1 -0
  132. package/dist/{storage-Bi24WfoW.mjs → storage-BjTLjDDp.mjs} +22 -22
  133. package/dist/storage-BjTLjDDp.mjs.map +1 -0
  134. package/dist/{storage-BJmzYxt8.cjs → storage-C2JC31V9.cjs} +65 -84
  135. package/dist/storage-C2JC31V9.cjs.map +1 -0
  136. package/dist/types-CzK6hsXP.d.mts +6286 -0
  137. package/dist/types-CzK6hsXP.d.mts.map +1 -0
  138. package/dist/types-DOOAevjG.d.cts +6287 -0
  139. package/dist/types-DOOAevjG.d.cts.map +1 -0
  140. package/dist/vitest.cjs +61 -0
  141. package/dist/vitest.cjs.map +1 -0
  142. package/dist/vitest.d.cts +28 -0
  143. package/dist/vitest.d.cts.map +1 -0
  144. package/dist/vitest.d.mts +28 -0
  145. package/dist/vitest.d.mts.map +1 -0
  146. package/dist/vitest.mjs +61 -0
  147. package/dist/vitest.mjs.map +1 -0
  148. package/dist/workspace/index.cjs +3 -4
  149. package/dist/workspace/index.d.cts +3 -3
  150. package/dist/workspace/index.d.mts +3 -3
  151. package/dist/workspace/index.mjs +2 -3
  152. package/dist/workspace-Bav3TVrP.cjs +6710 -0
  153. package/dist/workspace-Bav3TVrP.cjs.map +1 -0
  154. package/dist/{credentials-DQmbRnr1.cjs → workspace-BhiMkRuA.cjs} +2076 -1963
  155. package/dist/workspace-BhiMkRuA.cjs.map +1 -0
  156. package/dist/{credentials-BZcp3CGx.mjs → workspace-C97QUCIf.mjs} +1957 -1837
  157. package/dist/workspace-C97QUCIf.mjs.map +1 -0
  158. package/dist/workspace-T4IVGSoB.mjs +6538 -0
  159. package/dist/workspace-T4IVGSoB.mjs.map +1 -0
  160. package/package.json +45 -38
  161. package/dist/CachedStateProvider-BLo7zv7S.cjs +0 -3
  162. package/dist/CachedStateProvider-BxoAm-B2.mjs +0 -3
  163. package/dist/CachedStateProvider-CqPdW7CB.cjs +0 -60
  164. package/dist/CachedStateProvider-CqPdW7CB.cjs.map +0 -1
  165. package/dist/CachedStateProvider-DTniehMP.mjs +0 -54
  166. package/dist/CachedStateProvider-DTniehMP.mjs.map +0 -1
  167. package/dist/HostingerProvider-Cft7lEYr.mjs.map +0 -1
  168. package/dist/HostingerProvider-h3EbEp-Z.cjs.map +0 -1
  169. package/dist/LocalStateProvider-Bn6tS-oL.mjs.map +0 -1
  170. package/dist/LocalStateProvider-Db9SEjyH.cjs.map +0 -1
  171. package/dist/Route53Provider-RdpUDJQk.mjs.map +0 -1
  172. package/dist/Route53Provider-di2fMM5N.cjs.map +0 -1
  173. package/dist/SSMStateProvider-BRt2py-A.mjs.map +0 -1
  174. package/dist/SSMStateProvider-DyX8s9HI.cjs.map +0 -1
  175. package/dist/backup-provisioner-Bgj5Vi_L.mjs.map +0 -1
  176. package/dist/backup-provisioner-BrsHwYG0.cjs.map +0 -1
  177. package/dist/bundler-BY1OmV1e.cjs.map +0 -1
  178. package/dist/bundler-Be8Zg4Wd.mjs.map +0 -1
  179. package/dist/chunk-Duj1WY3L.mjs +0 -7
  180. package/dist/config-BholeD-0.cjs.map +0 -1
  181. package/dist/config-CzWnfcXM.mjs.map +0 -1
  182. package/dist/credentials-B5zRHdAl.mjs +0 -141
  183. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  184. package/dist/credentials-BZcp3CGx.mjs.map +0 -1
  185. package/dist/credentials-BapzjyV5.cjs +0 -195
  186. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  187. package/dist/credentials-DQmbRnr1.cjs.map +0 -1
  188. package/dist/discover-CAlFgYec.mjs.map +0 -1
  189. package/dist/discover-DTmFeloL.cjs.map +0 -1
  190. package/dist/dokploy-api-BS2xnJLZ.mjs +0 -3
  191. package/dist/dokploy-api-BsVH0y_s.cjs +0 -718
  192. package/dist/dokploy-api-BsVH0y_s.cjs.map +0 -1
  193. package/dist/dokploy-api-BuxDRo3l.cjs +0 -3
  194. package/dist/dokploy-api-aTFPz7_4.mjs +0 -706
  195. package/dist/dokploy-api-aTFPz7_4.mjs.map +0 -1
  196. package/dist/emit-CbcRolsa.cjs.map +0 -1
  197. package/dist/emit-CiZS_5Ub.mjs.map +0 -1
  198. package/dist/encryption-C6jaU0hE.cjs +0 -54
  199. package/dist/encryption-C6jaU0hE.cjs.map +0 -1
  200. package/dist/encryption-CHzzeR8a.cjs +0 -4
  201. package/dist/encryption-CQUncu7v.mjs +0 -3
  202. package/dist/encryption-D-abyhZx.mjs +0 -42
  203. package/dist/encryption-D-abyhZx.mjs.map +0 -1
  204. package/dist/fullstack-secrets-C-GGohke.cjs +0 -111
  205. package/dist/fullstack-secrets-C-GGohke.cjs.map +0 -1
  206. package/dist/fullstack-secrets-D1o9-G5l.mjs +0 -87
  207. package/dist/fullstack-secrets-D1o9-G5l.mjs.map +0 -1
  208. package/dist/generator-CNzBw7g5.cjs +0 -289
  209. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  210. package/dist/generator-VE2JrFlY.mjs +0 -253
  211. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  212. package/dist/index-BThUzEIp.d.mts.map +0 -1
  213. package/dist/index-CHB4tSzX.d.cts.map +0 -1
  214. package/dist/openapi-CY9xFkTH.mjs.map +0 -1
  215. package/dist/openapi-c9bpieI5.cjs.map +0 -1
  216. package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
  217. package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
  218. package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
  219. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
  220. package/dist/openapi-react-query.cjs +0 -4
  221. package/dist/openapi-react-query.d.cts +0 -11
  222. package/dist/openapi-react-query.d.cts.map +0 -1
  223. package/dist/openapi-react-query.d.mts +0 -11
  224. package/dist/openapi-react-query.d.mts.map +0 -1
  225. package/dist/openapi-react-query.mjs +0 -4
  226. package/dist/reconcile-CFs8C_1a.mjs +0 -37
  227. package/dist/reconcile-CFs8C_1a.mjs.map +0 -1
  228. package/dist/reconcile-D0pimNiy.cjs +0 -37
  229. package/dist/reconcile-D0pimNiy.cjs.map +0 -1
  230. package/dist/setup-Bc73t0ve.mjs +0 -443
  231. package/dist/setup-Bc73t0ve.mjs.map +0 -1
  232. package/dist/setup-C48C9hto.cjs +0 -473
  233. package/dist/setup-C48C9hto.cjs.map +0 -1
  234. package/dist/setup-DCuudnCl.mjs +0 -11
  235. package/dist/setup-fG_ivuxO.cjs +0 -11
  236. package/dist/storage-BJmzYxt8.cjs.map +0 -1
  237. package/dist/storage-BM9hGpgv.cjs +0 -7
  238. package/dist/storage-Bi24WfoW.mjs.map +0 -1
  239. package/dist/storage-CYlGwWTj.mjs +0 -3
  240. package/dist/sync-CmEuNZsB.mjs +0 -76
  241. package/dist/sync-CmEuNZsB.mjs.map +0 -1
  242. package/dist/sync-D306yOWu.cjs +0 -4
  243. package/dist/sync-SizaChmC.cjs +0 -93
  244. package/dist/sync-SizaChmC.cjs.map +0 -1
  245. package/dist/sync-hOqAWHR6.mjs +0 -3
  246. package/dist/types-C-arnQ1r.d.mts +0 -2184
  247. package/dist/types-C-arnQ1r.d.mts.map +0 -1
  248. package/dist/types-abJQuk7m.d.cts +0 -2184
  249. package/dist/types-abJQuk7m.d.cts.map +0 -1
  250. package/dist/workspace-7FqprxuJ.mjs +0 -4323
  251. package/dist/workspace-7FqprxuJ.mjs.map +0 -1
  252. package/dist/workspace-BO_KWohI.cjs +0 -9
  253. package/dist/workspace-DK4WWJIn.mjs +0 -8
  254. package/dist/workspace-XvqO9jIv.cjs +0 -4472
  255. package/dist/workspace-XvqO9jIv.cjs.map +0 -1
@@ -1,10 +1,26 @@
1
- import { discover } from "./discover-CAlFgYec.mjs";
2
- import { allConstructGlobs, getAppGkmConfig, isWorkspaceConfig, processConfig } from "./workspace-7FqprxuJ.mjs";
1
+ import { t as discover } from "./discover-CMxesskG.mjs";
2
+ import { h as isWorkspaceConfig, l as processConfig, o as getAppGkmConfig, t as allConstructGlobs } from "./workspace-T4IVGSoB.mjs";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { dirname, join, parse } from "node:path";
5
- import { DEFAULT_APP_CODE, kebabCase } from "@geekmidas/manifest";
6
-
5
+ import { kebabCase } from "@geekmidas/manifest";
7
6
  //#region src/workspace/derive.ts
7
+ /**
8
+ * The apps a manifest implies.
9
+ *
10
+ * `gkm.config.ts` used to carry an `apps` block naming every app: its type, its
11
+ * path, its port, its framework, which other apps it depended on. Every one of
12
+ * those facts was already declared. A `StaticSite('Web', { path: 'apps/web' })`
13
+ * and an `apps.web = { type: 'web', path: 'apps/web', framework: 'vite',
14
+ * dependencies: ['api'] }` are the same statement written twice, and only one of
15
+ * them was checked against anything — so the copy in config was free to drift,
16
+ * and a surface config had no entry for simply never deployed.
17
+ *
18
+ * So the list comes from the graph. A `site` is an app, and so is every
19
+ * `rest-api` — one surface, one container, at the `path` it declared.
20
+ *
21
+ * What config still supplies is what no graph can answer: the backends a cache
22
+ * and a mailer resolve to, the deploy endpoint, the stage's domain.
23
+ */
8
24
  /** Which frontend framework builds each site variant. */
9
25
  const FRAMEWORKS = {
10
26
  static: "vite",
@@ -76,66 +92,15 @@ function markRoot(apps) {
76
92
  const chosen = sites.find(([name]) => name === "web") ?? (sites.length === 1 ? sites[0] : void 0);
77
93
  if (chosen) chosen[1].root = true;
78
94
  }
79
- /**
80
- * What `app: true` means, and what the object form leaves out.
81
- *
82
- * Both fields follow from the construct's own id, so neither was worth making
83
- * someone write down:
84
- *
85
- * - `path` is `apps/<kebab-id>` where that directory exists, and the workspace
86
- * root otherwise. `Api` means `apps/api` in a monorepo and `.` in a
87
- * single-app project, and which of the two you are in is answerable by
88
- * looking.
89
- * - `code` is the conventional directories under `path`. A glob is worth
90
- * writing only when the code is somewhere else, which is the case the field
91
- * still exists for.
92
- *
93
- * A site takes no `code`: its build is its framework's, not ours.
94
- */
95
- /**
96
- * Where an app lives when it did not say.
97
- *
98
- * `apps/<kebab-id>`, which is what the id already said — or the project root
99
- * when there is no `apps/` at all, because then there is one app and it is the
100
- * project.
101
- *
102
- * In between, it refuses. A workspace *with* an `apps/` directory and no
103
- * `apps/<key>` in it is a construct naming a directory nobody wrote, and
104
- * quietly answering `.` there makes the app the whole repository: the build
105
- * filters turbo on the root `package.json` and builds the wrong thing, or
106
- * itself. A missing directory is a typo or an unconventional layout, and both
107
- * want saying out loud.
108
- */
109
- function conventionalPath(id, workspaceRoot) {
110
- const conventional = join("apps", appKey(id));
111
- if (existsSync(join(workspaceRoot, conventional))) return conventional;
112
- if (!existsSync(join(workspaceRoot, "apps"))) return ".";
113
- throw new MisplacedApp(id, conventional);
114
- }
115
- /** A construct whose directory is not where its id says it is. */
116
- var MisplacedApp = class extends Error {
117
- constructor(construct, expected) {
118
- super(`"${construct}" has no directory at ${expected}.\nCreate it, or say where it lives:\n new StaticSite('${construct}', { path: 'sites/${appKey(construct)}' })\n new RestApi('${construct}', { …, app: { path: 'services/${appKey(construct)}' } })`);
119
- this.construct = construct;
120
- this.expected = expected;
121
- this.name = "MisplacedApp";
122
- }
123
- };
124
- function resolveAppSpec(id, spec, workspaceRoot, kind) {
125
- const path = spec.path ?? conventionalPath(id, workspaceRoot);
126
- const givenAGlob = spec.code !== void 0 || spec.routes !== void 0 || spec.functions !== void 0 || spec.crons !== void 0 || spec.queues !== void 0 || spec.topics !== void 0 || spec.subscribers !== void 0;
127
- return {
128
- ...spec,
129
- path,
130
- ...kind !== "site" && !givenAGlob ? { code: DEFAULT_APP_CODE } : {}
131
- };
132
- }
133
95
  function derivedApps(manifest, workspace) {
134
96
  const apps = {};
135
97
  const defaultTarget = workspace.deploy?.default ?? "dokploy";
136
98
  for (const [id, declaration] of Object.entries(manifest)) {
137
- if (declaration.kind !== "site" && declaration.kind !== "rest-api" && declaration.kind !== "worker") continue;
138
- const spec = resolveAppSpec(id, declaration.app ?? {}, workspace.root, declaration.kind);
99
+ if (declaration.kind !== "site" && declaration.kind !== "rest-api") continue;
100
+ const spec = declaration.kind === "site" ? declaration.app : {
101
+ path: declaration.path,
102
+ ...declaration.telescope ? { telescope: true } : {}
103
+ };
139
104
  const name = appKey(id);
140
105
  const configured = workspace.apps[name];
141
106
  apps[name] = {
@@ -150,22 +115,6 @@ function derivedApps(manifest, workspace) {
150
115
  ...declaration.root ? { root: true } : {},
151
116
  ...spec.config ? { config: spec.config } : {}
152
117
  } : {},
153
- ...spec.code !== void 0 ? {
154
- routes: spec.code,
155
- functions: spec.code,
156
- crons: spec.code,
157
- queues: spec.code,
158
- topics: spec.code,
159
- subscribers: spec.code
160
- } : {},
161
- ...spec.routes !== void 0 ? { routes: spec.routes } : {},
162
- ...spec.functions !== void 0 ? { functions: spec.functions } : {},
163
- ...spec.crons !== void 0 ? { crons: spec.crons } : {},
164
- ...spec.queues !== void 0 ? { queues: spec.queues } : {},
165
- ...spec.topics !== void 0 ? { topics: spec.topics } : {},
166
- ...spec.subscribers !== void 0 ? { subscribers: spec.subscribers } : {},
167
- ...spec.envParser !== void 0 ? { envParser: spec.envParser } : {},
168
- ...spec.logger !== void 0 ? { logger: spec.logger } : {},
169
118
  ...spec.telescope !== void 0 ? { telescope: spec.telescope } : {},
170
119
  ...spec.studio !== void 0 ? { studio: spec.studio } : {},
171
120
  ...spec.openapi !== void 0 ? { openapi: spec.openapi } : {},
@@ -176,7 +125,7 @@ function derivedApps(manifest, workspace) {
176
125
  };
177
126
  }
178
127
  for (const [id, declaration] of Object.entries(manifest)) {
179
- if (declaration.kind !== "site" && declaration.kind !== "rest-api" && declaration.kind !== "worker") continue;
128
+ if (declaration.kind !== "site" && declaration.kind !== "rest-api") continue;
180
129
  const app = apps[appKey(id)];
181
130
  if (!app) continue;
182
131
  const edges = declaration.kind === "rest-api" ? declaration.calls ?? [] : declaration.dependencies ?? [];
@@ -195,7 +144,6 @@ function derivedApps(manifest, workspace) {
195
144
  for (const [name, app] of Object.entries(workspace.apps)) if (!apps[name]) apps[name] = app;
196
145
  return apps;
197
146
  }
198
-
199
147
  //#endregion
200
148
  //#region src/config.ts
201
149
  /**
@@ -239,10 +187,9 @@ function parseModuleConfig(configString, defaultAlias) {
239
187
  const parts = configString.split("#");
240
188
  const path = parts[0] ?? configString;
241
189
  const exportName = parts[1];
242
- const importPattern = !exportName ? defaultAlias : exportName === defaultAlias ? `{ ${defaultAlias} }` : `{ ${exportName} as ${defaultAlias} }`;
243
190
  return {
244
191
  path,
245
- importPattern
192
+ importPattern: !exportName ? defaultAlias : exportName === defaultAlias ? `{ ${defaultAlias} }` : `{ ${exportName} as ${defaultAlias} }`
246
193
  };
247
194
  }
248
195
  /**
@@ -290,8 +237,7 @@ function getAppNameFromCwd(cwd = process.cwd()) {
290
237
  const packageJsonPath = join(cwd, "package.json");
291
238
  if (!existsSync(packageJsonPath)) return null;
292
239
  try {
293
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
294
- const name = packageJson.name;
240
+ const name = JSON.parse(readFileSync(packageJsonPath, "utf-8")).name;
295
241
  if (!name) return null;
296
242
  if (name.startsWith("@") && name.includes("/")) return name.split("/")[1] ?? null;
297
243
  return name;
@@ -305,9 +251,8 @@ function getAppNameFromCwd(cwd = process.cwd()) {
305
251
  async function loadRawConfig(cwd) {
306
252
  const { configPath, workspaceRoot } = findConfigPath(cwd);
307
253
  try {
308
- const config = await import(configPath);
309
254
  return {
310
- config: config.default,
255
+ config: (await import(configPath)).default,
311
256
  workspaceRoot
312
257
  };
313
258
  } catch (error) {
@@ -367,7 +312,7 @@ async function loadWorkspaceConfig(cwd = process.cwd()) {
367
312
  */
368
313
  async function withDerivedApps(loaded) {
369
314
  const globs = allConstructGlobs(loaded.workspace);
370
- if (globs.length === 0) return loaded;
315
+ if (globs.length === 0) throw new WorkspaceDeclaresNoConstructs(loaded.workspace.root);
371
316
  try {
372
317
  const manifest = await discover({
373
318
  patterns: globs,
@@ -388,6 +333,21 @@ async function withDerivedApps(loaded) {
388
333
  }
389
334
  }
390
335
  /**
336
+ * A workspace with no `constructs` glob.
337
+ *
338
+ * In v10 every address, container and app comes from what the workspace
339
+ * declares — there is no second path that reads a hand-written compose file or
340
+ * an `apps` block's ports. A config that declares nothing has nothing to run.
341
+ */
342
+ var WorkspaceDeclaresNoConstructs = class extends Error {
343
+ root;
344
+ constructor(root) {
345
+ super(`The workspace at ${root} declares no constructs. Every workspace names where its constructs live — \`constructs: ['./constructs/**/*.ts', './apps/*/endpoints/**/*.ts']\` in gkm.config.ts — and its apps, containers and URLs are derived from them.`);
346
+ this.root = root;
347
+ this.name = "WorkspaceDeclaresNoConstructs";
348
+ }
349
+ };
350
+ /**
391
351
  * The app a package directory refers to, and what the workspace calls it.
392
352
  *
393
353
  * A single-app config is wrapped as a one-app workspace keyed `api`, which is
@@ -404,7 +364,7 @@ function resolveWorkspaceApp(loadedConfig, appName) {
404
364
  };
405
365
  const names = Object.keys(apps);
406
366
  const only = names[0];
407
- if (loadedConfig.type !== "single" || names.length !== 1 || !only) return void 0;
367
+ if (loadedConfig.type !== "single" || names.length !== 1 || !only) return;
408
368
  const app = apps[only];
409
369
  return app ? {
410
370
  key: only,
@@ -463,7 +423,7 @@ async function loadWorkspaceAppInfo(cwd = process.cwd()) {
463
423
  workspaceRoot
464
424
  };
465
425
  }
466
-
467
426
  //#endregion
468
- export { appKey, defineConfig, derivedApps, getAppNameFromCwd, hostOf, loadAppConfig, loadConfig, loadWorkspaceAppInfo, loadWorkspaceConfig, parseModuleConfig, resolveAppSpec };
469
- //# sourceMappingURL=config-CzWnfcXM.mjs.map
427
+ export { loadConfig as a, parseModuleConfig as c, loadAppConfig as i, appKey as l, defineConfig as n, loadWorkspaceAppInfo as o, getAppNameFromCwd as r, loadWorkspaceConfig as s, WorkspaceDeclaresNoConstructs as t, derivedApps as u };
428
+
429
+ //# sourceMappingURL=config-BH3Ki69F.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-BH3Ki69F.mjs","names":[],"sources":["../src/workspace/derive.ts","../src/config.ts"],"sourcesContent":["/**\n * The apps a manifest implies.\n *\n * `gkm.config.ts` used to carry an `apps` block naming every app: its type, its\n * path, its port, its framework, which other apps it depended on. Every one of\n * those facts was already declared. A `StaticSite('Web', { path: 'apps/web' })`\n * and an `apps.web = { type: 'web', path: 'apps/web', framework: 'vite',\n * dependencies: ['api'] }` are the same statement written twice, and only one of\n * them was checked against anything — so the copy in config was free to drift,\n * and a surface config had no entry for simply never deployed.\n *\n * So the list comes from the graph. A `site` is an app, and so is every\n * `rest-api` — one surface, one container, at the `path` it declared.\n *\n * What config still supplies is what no graph can answer: the backends a cache\n * and a mailer resolve to, the deploy endpoint, the stage's domain.\n */\n\nimport {\n\ttype AppSpec,\n\ttype ConstructManifest,\n\tkebabCase,\n} from '@geekmidas/manifest';\nimport type {\n\tAppDomainConfig,\n\tDeployTarget,\n\tFramework,\n\tNormalizedAppConfig,\n\tNormalizedWorkspace,\n} from './types.js';\n\n/** Which frontend framework builds each site variant. */\nconst FRAMEWORKS: Record<string, Framework> = {\n\tstatic: 'vite',\n\tnext: 'nextjs',\n\ttanstack: 'tanstack-start',\n};\n\n/**\n * The app key a construct id becomes.\n *\n * The same kebab form every physical name is built from, so `Api` is `api` in\n * the config, `production-kitchen-sink-api` on Dokploy, and `API_URL` in an\n * environment — one id, three renderings, no second list.\n */\nexport function appKey(id: string): string {\n\treturn kebabCase(id);\n}\n\n/**\n * The app serving a surface: its own, always.\n *\n * Every surface gets a container. There is no arrangement in which one runs\n * inside another — two surfaces in a process share a filesystem, an\n * environment, and every credential either was granted, so an auth server\n * beside an API is one bug in the API away from being read by it.\n */\nexport function hostOf(\n\tmanifest: ConstructManifest,\n\tid: string,\n): string | undefined {\n\tconst declaration = manifest[id];\n\tif (!declaration || declaration.kind !== 'rest-api') return undefined;\n\n\treturn id;\n}\n\n/**\n * Local ports, assigned so that adding a site does not renumber the others.\n *\n * Backends first, then the site holding the base domain, then the rest\n * alphabetically. The ordering is arbitrary but it is *fixed*, which is the\n * property that matters: a port that moves when an unrelated app is added is a\n * port nobody can put in a bookmark. A construct that names its own port keeps\n * it, and is skipped here.\n */\nfunction assignPorts(apps: Record<string, NormalizedAppConfig>): void {\n\tconst rank = (\n\t\tname: string,\n\t\tapp: NormalizedAppConfig,\n\t): [number, number, string] => [\n\t\tapp.type === 'backend' ? 0 : app.type === 'web' ? 1 : 2,\n\t\tapp.root ? 0 : 1,\n\t\tname,\n\t];\n\n\tconst ordered = Object.entries(apps).sort(([aName, a], [bName, b]) => {\n\t\tconst [at, ar, an] = rank(aName, a);\n\t\tconst [bt, br, bn] = rank(bName, b);\n\t\treturn at - bt || ar - br || an.localeCompare(bn);\n\t});\n\n\tconst taken = new Set(\n\t\tordered.map(([, app]) => app.port).filter((p): p is number => !!p),\n\t);\n\n\tlet next = 3000;\n\tfor (const [, app] of ordered) {\n\t\tif (app.port) continue;\n\t\twhile (taken.has(next)) next += 1;\n\t\tapp.port = next;\n\t\ttaken.add(next);\n\t}\n}\n\n/**\n * Whichever site holds the base domain.\n *\n * The convention first — a site named `web` — because it is one people already\n * rely on. Then an explicit `root: true`. A project with one site needs neither.\n */\nfunction markRoot(apps: Record<string, NormalizedAppConfig>): void {\n\tconst sites = Object.entries(apps).filter(([, a]) => a.type === 'web');\n\tif (sites.length === 0) return;\n\tif (sites.some(([, a]) => a.root)) return;\n\n\tconst chosen =\n\t\tsites.find(([name]) => name === 'web') ??\n\t\t(sites.length === 1 ? sites[0] : undefined);\n\tif (chosen) chosen[1].root = true;\n}\n\nexport function derivedApps(\n\tmanifest: ConstructManifest,\n\tworkspace: NormalizedWorkspace,\n): Record<string, NormalizedAppConfig> {\n\tconst apps: Record<string, NormalizedAppConfig> = {};\n\tconst defaultTarget: DeployTarget = workspace.deploy?.default ?? 'dokploy';\n\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\t// Two kinds are apps: a site and an HTTP surface. A worker is not one —\n\t\t// it names the process that runs a cron or a subscriber, and that process\n\t\t// is the app's server, which already exists. Everything else is a\n\t\t// resource one of them uses.\n\t\tif (declaration.kind !== 'site' && declaration.kind !== 'rest-api')\n\t\t\tcontinue;\n\n\t\t// No opt-in to be had. A site is an app and so is a surface, and each\n\t\t// says where it lives.\n\t\tconst spec: AppSpec =\n\t\t\tdeclaration.kind === 'site'\n\t\t\t\t? declaration.app\n\t\t\t\t: {\n\t\t\t\t\t\tpath: declaration.path,\n\t\t\t\t\t\t...(declaration.telescope ? { telescope: true } : {}),\n\t\t\t\t\t};\n\n\t\tconst name = appKey(id);\n\t\t// A config entry of the same name still wins, so a workspace can override\n\t\t// one field without restating the app. Nothing in this repo needs to.\n\t\tconst configured = workspace.apps[name];\n\n\t\tapps[name] = {\n\t\t\t...configured,\n\t\t\ttype: declaration.kind === 'site' ? 'web' : 'backend',\n\t\t\tpath: spec.path,\n\t\t\tport: spec.port ?? configured?.port ?? 0,\n\t\t\tdependencies: [],\n\t\t\tresolvedDeployTarget: configured?.resolvedDeployTarget ?? defaultTarget,\n\t\t\t...(declaration.kind === 'site'\n\t\t\t\t? {\n\t\t\t\t\t\tframework: configured?.framework ?? FRAMEWORKS[declaration.variant],\n\t\t\t\t\t\t...(declaration.root ? { root: true } : {}),\n\t\t\t\t\t\t...(spec.config ? { config: spec.config } : {}),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t// One glob fans out to the six the build reads, because each generator\n\t\t\t// already inspects every export and keeps what it recognises. A\n\t\t\t// per-kind field still wins where one was given.\n\t\t\t...(spec.telescope !== undefined ? { telescope: spec.telescope } : {}),\n\t\t\t...(spec.studio !== undefined ? { studio: spec.studio } : {}),\n\t\t\t...(spec.openapi !== undefined ? { openapi: spec.openapi } : {}),\n\t\t\t...(spec.runtime !== undefined ? { runtime: spec.runtime } : {}),\n\t\t\t...(spec.env !== undefined ? { env: spec.env } : {}),\n\t\t\t...(spec.entry !== undefined ? { entry: spec.entry } : {}),\n\t\t\t...(configured?.domain\n\t\t\t\t? { domain: configured.domain as AppDomainConfig }\n\t\t\t\t: {}),\n\t\t} as NormalizedAppConfig;\n\t}\n\n\t// Build order, from the edges rather than from a hand-kept list. A site that\n\t// depends on a surface depends on the app that serves it — which for a\n\t// mounted auth server is its host, not a container that does not exist.\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\t// Two kinds are apps: a site and an HTTP surface. A worker is not one —\n\t\t// it names the process that runs a cron or a subscriber, and that process\n\t\t// is the app's server, which already exists. Everything else is a\n\t\t// resource one of them uses.\n\t\tif (declaration.kind !== 'site' && declaration.kind !== 'rest-api')\n\t\t\tcontinue;\n\n\t\tconst app = apps[appKey(id)];\n\t\tif (!app) continue;\n\n\t\t// A site names its edges `dependencies`; a surface names them `calls`.\n\t\tconst edges =\n\t\t\tdeclaration.kind === 'rest-api'\n\t\t\t\t? (declaration.calls ?? [])\n\t\t\t\t: (declaration.dependencies ?? []);\n\n\t\tconst names = new Set<string>();\n\t\tfor (const edge of edges) {\n\t\t\tif (edge.kind !== 'rest-api') continue;\n\t\t\tconst host = hostOf(manifest, edge.target);\n\t\t\tif (!host) continue;\n\t\t\tconst key = appKey(host);\n\t\t\tif (key !== appKey(id) && apps[key]) names.add(key);\n\t\t}\n\n\t\tapp.dependencies = [...names].sort();\n\t}\n\n\tmarkRoot(apps);\n\tassignPorts(apps);\n\n\t// Apps config declared that the graph knows nothing about — a `type: 'mobile'`\n\t// entry, or a hand-run process. Kept rather than dropped: config is still the\n\t// escape hatch for what nothing declares.\n\tfor (const [name, app] of Object.entries(workspace.apps)) {\n\t\tif (!apps[name]) apps[name] = app;\n\t}\n\n\treturn apps;\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, parse } from 'node:path';\nimport { discover } from './reconcile/discover.js';\nimport type { GkmConfig } from './types.js';\nimport { derivedApps } from './workspace/derive.js';\nimport {\n\tallConstructGlobs,\n\tgetAppGkmConfig,\n\tisWorkspaceConfig,\n\ttype LoadedConfig,\n\ttype NormalizedAppConfig,\n\ttype NormalizedWorkspace,\n\tprocessConfig,\n\ttype WorkspaceConfig,\n} from './workspace/index.js';\n\nexport type { GkmConfig } from './types.js';\nexport type { LoadedConfig, WorkspaceConfig } from './workspace/index.js';\nexport { defineWorkspace } from './workspace/index.js';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n\treturn config;\n}\n\nexport interface ParsedModuleConfig {\n\tpath: string;\n\timportPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n\tconfigString: string,\n\tdefaultAlias: string,\n): ParsedModuleConfig {\n\tconst parts = configString.split('#');\n\tconst path = parts[0] ?? configString;\n\tconst exportName = parts[1];\n\tconst importPattern = !exportName\n\t\t? defaultAlias\n\t\t: exportName === defaultAlias\n\t\t\t? `{ ${defaultAlias} }`\n\t\t\t: `{ ${exportName} as ${defaultAlias} }`;\n\n\treturn { path, importPattern };\n}\n\nexport interface ConfigDiscoveryResult {\n\tconfigPath: string;\n\tworkspaceRoot: string;\n}\n\n/**\n * Find and return the path to the config file.\n *\n * Resolution order:\n * 1. GKM_CONFIG_PATH env var (set by workspace dev command)\n * 2. Walk up directory tree from cwd\n */\nfunction findConfigPath(cwd: string): ConfigDiscoveryResult {\n\tconst files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n\n\t// Check GKM_CONFIG_PATH env var first (set by workspace dev command)\n\tconst envConfigPath = process.env.GKM_CONFIG_PATH;\n\tif (envConfigPath && existsSync(envConfigPath)) {\n\t\treturn {\n\t\t\tconfigPath: envConfigPath,\n\t\t\tworkspaceRoot: dirname(envConfigPath),\n\t\t};\n\t}\n\n\t// Walk up directory tree to find config\n\tlet currentDir = cwd;\n\tconst { root } = parse(currentDir);\n\n\twhile (currentDir !== root) {\n\t\tfor (const file of files) {\n\t\t\tconst configPath = join(currentDir, file);\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn {\n\t\t\t\t\tconfigPath,\n\t\t\t\t\tworkspaceRoot: currentDir,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\tcurrentDir = dirname(currentDir);\n\t}\n\n\tthrow new Error(\n\t\t'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n\t);\n}\n\n/**\n * Get app name from package.json in the given directory.\n * Handles scoped packages by extracting the name after the scope.\n *\n * @example\n * getAppNameFromCwd('/path/to/apps/api')\n * // package.json: { \"name\": \"@myorg/api\" }\n * // Returns: 'api'\n */\nexport function getAppNameFromCwd(cwd: string = process.cwd()): string | null {\n\tconst packageJsonPath = join(cwd, 'package.json');\n\n\tif (!existsSync(packageJsonPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n\t\tconst name = packageJson.name as string | undefined;\n\n\t\tif (!name) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Handle scoped packages: @scope/name -> name\n\t\tif (name.startsWith('@') && name.includes('/')) {\n\t\t\treturn name.split('/')[1] ?? null;\n\t\t}\n\n\t\treturn name;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\ninterface RawConfigResult {\n\tconfig: GkmConfig | WorkspaceConfig;\n\tworkspaceRoot: string;\n}\n\n/**\n * Load raw configuration from file.\n */\nasync function loadRawConfig(cwd: string): Promise<RawConfigResult> {\n\tconst { configPath, workspaceRoot } = findConfigPath(cwd);\n\n\ttry {\n\t\tconst config = await import(configPath);\n\t\treturn {\n\t\t\tconfig: config.default,\n\t\t\tworkspaceRoot,\n\t\t};\n\t} catch (error) {\n\t\tthrow new Error(`Failed to load config: ${(error as Error).message}`);\n\t}\n}\n\n/**\n * Load configuration file (single-app format).\n * For backwards compatibility with existing code.\n *\n * @deprecated Use loadWorkspaceConfig for new code\n */\nexport async function loadConfig(\n\tcwd: string = process.cwd(),\n): Promise<GkmConfig> {\n\tconst { config } = await loadRawConfig(cwd);\n\n\t// If it's a workspace config, throw an error\n\tif (isWorkspaceConfig(config)) {\n\t\tthrow new Error(\n\t\t\t'Workspace configuration detected. Use loadWorkspaceConfig() instead.',\n\t\t);\n\t}\n\n\treturn config;\n}\n\n/**\n * Load configuration file and process it as a workspace.\n * Works with both single-app and workspace configurations.\n *\n * Single-app configs are automatically wrapped as a workspace with one app.\n *\n * @example\n * ```ts\n * const { type, workspace } = await loadWorkspaceConfig();\n *\n * if (type === 'workspace') {\n * console.log('Multi-app workspace:', workspace.apps);\n * } else {\n * console.log('Single app wrapped as workspace');\n * }\n * ```\n */\nexport async function loadWorkspaceConfig(\n\tcwd: string = process.cwd(),\n): Promise<LoadedConfig> {\n\tconst { config, workspaceRoot } = await loadRawConfig(cwd);\n\treturn withDerivedApps(processConfig(config, workspaceRoot));\n}\n\n/**\n * The loaded config, with its apps read off the graph.\n *\n * Here rather than at each call site because every command needs the same\n * answer, and the ones that forgot to ask were exactly the bugs: a site that\n * never deployed, a surface that could not be its own process. `gkm dev`,\n * `gkm build`, `gkm docker` and `gkm deploy` now all see the same apps without\n * any of them knowing a derivation happened.\n *\n * Discovery imports the construct modules — declarations only, not endpoints —\n * which is the same import the reconciler and the build already do. A workspace\n * with no `constructs` glob discovers nothing and keeps whatever its config\n * said, so nothing that worked before changes.\n *\n * A construct file that throws is reported and skipped rather than taking the\n * command down: `gkm dev` failing to start because a half-written declaration\n * cannot be imported is a worse failure than starting with the app it does not\n * describe yet.\n */\nasync function withDerivedApps(loaded: LoadedConfig): Promise<LoadedConfig> {\n\tconst globs = allConstructGlobs(loaded.workspace);\n\tif (globs.length === 0) {\n\t\tthrow new WorkspaceDeclaresNoConstructs(loaded.workspace.root);\n\t}\n\n\ttry {\n\t\tconst manifest = await discover({\n\t\t\tpatterns: globs,\n\t\t\tcwd: loaded.workspace.root,\n\t\t});\n\n\t\treturn {\n\t\t\t...loaded,\n\t\t\tmanifest,\n\t\t\tworkspace: {\n\t\t\t\t...loaded.workspace,\n\t\t\t\tapps: derivedApps(manifest, loaded.workspace),\n\t\t\t},\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconsole.warn(\n\t\t\t`⚠️ Could not read constructs, so apps come from config alone: ${message}`,\n\t\t);\n\t\treturn loaded;\n\t}\n}\n\n/**\n * A workspace with no `constructs` glob.\n *\n * In v10 every address, container and app comes from what the workspace\n * declares — there is no second path that reads a hand-written compose file or\n * an `apps` block's ports. A config that declares nothing has nothing to run.\n */\nexport class WorkspaceDeclaresNoConstructs extends Error {\n\tconstructor(readonly root: string) {\n\t\tsuper(\n\t\t\t`The workspace at ${root} declares no constructs. Every workspace names ` +\n\t\t\t\t\"where its constructs live — `constructs: ['./constructs/**/*.ts', \" +\n\t\t\t\t\"'./apps/*/endpoints/**/*.ts']` in gkm.config.ts — and its apps, \" +\n\t\t\t\t'containers and URLs are derived from them.',\n\t\t);\n\t\tthis.name = 'WorkspaceDeclaresNoConstructs';\n\t}\n}\n\nexport interface AppConfigResult {\n\tappName: string;\n\tapp: NormalizedAppConfig;\n\tgkmConfig: GkmConfig;\n\tworkspace: NormalizedWorkspace;\n\tworkspaceRoot: string;\n\tappRoot: string;\n}\n\n/**\n * The app a package directory refers to, and what the workspace calls it.\n *\n * A single-app config is wrapped as a one-app workspace keyed `api`, which is\n * almost never the package name. Matching on the key alone means an app like\n * `@geekmidas/example` resolves to nothing and silently loses everything that\n * comes from the workspace — including the URLs its constructs declare.\n */\nfunction resolveWorkspaceApp(\n\tloadedConfig: LoadedConfig,\n\tappName: string,\n): { key: string; app: NormalizedAppConfig } | undefined {\n\tconst apps = loadedConfig.workspace.apps;\n\n\tconst named = apps[appName];\n\tif (named) return { key: appName, app: named };\n\n\tconst names = Object.keys(apps);\n\tconst only = names[0];\n\tif (loadedConfig.type !== 'single' || names.length !== 1 || !only) {\n\t\treturn undefined;\n\t}\n\n\tconst app = apps[only];\n\n\treturn app ? { key: only, app } : undefined;\n}\n\n/**\n * Load app-specific configuration from workspace.\n * Uses the app name from package.json to find the correct app config.\n *\n * @example\n * ```ts\n * // From apps/api directory with package.json: { \"name\": \"@myorg/api\" }\n * const { app, workspace, workspaceRoot } = await loadAppConfig();\n * console.log(app.routes); // './src/endpoints/**\\/*.ts'\n * ```\n */\nexport async function loadAppConfig(\n\tcwd: string = process.cwd(),\n): Promise<AppConfigResult> {\n\tconst appName = getAppNameFromCwd(cwd);\n\n\tif (!appName) {\n\t\tthrow new Error(\n\t\t\t'Could not determine app name. Ensure package.json exists with a \"name\" field.',\n\t\t);\n\t}\n\n\tconst { config, workspaceRoot } = await loadRawConfig(cwd);\n\tconst loadedConfig = await withDerivedApps(\n\t\tprocessConfig(config, workspaceRoot),\n\t);\n\n\tconst resolved = resolveWorkspaceApp(loadedConfig, appName);\n\n\tif (!resolved) {\n\t\tthrow new Error(\n\t\t\t`App \"${appName}\" not found in workspace config. Available apps: ${Object.keys(\n\t\t\t\tloadedConfig.workspace.apps,\n\t\t\t).join(', ')}. ` +\n\t\t\t\t`Ensure the package.json name matches the app key in gkm.config.ts.`,\n\t\t);\n\t}\n\n\tconst { key, app } = resolved;\n\n\t// Keyed by what the workspace calls the app, not by the package name — for a\n\t// single-app config those differ.\n\tconst gkmConfig = getAppGkmConfig(loadedConfig.workspace, key);\n\n\tif (!gkmConfig) {\n\t\tthrow new Error(\n\t\t\t`App \"${appName}\" is not a backend app and cannot be run with gkm dev.`,\n\t\t);\n\t}\n\n\treturn {\n\t\tappName,\n\t\tapp,\n\t\tgkmConfig,\n\t\tworkspace: loadedConfig.workspace,\n\t\tworkspaceRoot,\n\t\tappRoot: join(workspaceRoot, app.path),\n\t};\n}\n\nexport interface WorkspaceAppInfo {\n\tappName: string;\n\tapp: NormalizedAppConfig;\n\tworkspace: NormalizedWorkspace;\n\tworkspaceRoot: string;\n}\n\n/**\n * Load workspace info for any app (frontend or backend).\n * Unlike loadAppConfig, this does NOT require the app to have a gkm config\n * (routes, entry, etc.), making it suitable for gkm exec/test from frontend apps.\n */\nexport async function loadWorkspaceAppInfo(\n\tcwd: string = process.cwd(),\n): Promise<WorkspaceAppInfo> {\n\tconst appName = getAppNameFromCwd(cwd);\n\n\tif (!appName) {\n\t\tthrow new Error(\n\t\t\t'Could not determine app name. Ensure package.json exists with a \"name\" field.',\n\t\t);\n\t}\n\n\tconst { config, workspaceRoot } = await loadRawConfig(cwd);\n\tconst loadedConfig = await withDerivedApps(\n\t\tprocessConfig(config, workspaceRoot),\n\t);\n\n\tconst resolved = resolveWorkspaceApp(loadedConfig, appName);\n\n\tif (!resolved) {\n\t\tconst availableApps = Object.keys(loadedConfig.workspace.apps).join(', ');\n\t\tthrow new Error(\n\t\t\t`App \"${appName}\" not found in workspace config. Available apps: ${availableApps}. ` +\n\t\t\t\t`Ensure the package.json name matches the app key in gkm.config.ts.`,\n\t\t);\n\t}\n\n\treturn {\n\t\tappName,\n\t\tapp: resolved.app,\n\t\tworkspace: loadedConfig.workspace,\n\t\tworkspaceRoot,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,aAAwC;CAC7C,QAAQ;CACR,MAAM;CACN,UAAU;AACX;;;;;;;;AASA,SAAgB,OAAO,IAAoB;CAC1C,OAAO,UAAU,EAAE;AACpB;;;;;;;;;AAUA,SAAgB,OACf,UACA,IACqB;CACrB,MAAM,cAAc,SAAS;CAC7B,IAAI,CAAC,eAAe,YAAY,SAAS,YAAY,OAAO,KAAA;CAE5D,OAAO;AACR;;;;;;;;;;AAWA,SAAS,YAAY,MAAiD;CACrE,MAAM,QACL,MACA,QAC8B;EAC9B,IAAI,SAAS,YAAY,IAAI,IAAI,SAAS,QAAQ,IAAI;EACtD,IAAI,OAAO,IAAI;EACf;CACD;CAEA,MAAM,UAAU,OAAO,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,OAAO,OAAO;EACrE,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,OAAO,CAAC;EAClC,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,OAAO,CAAC;EAClC,OAAO,KAAK,MAAM,KAAK,MAAM,GAAG,cAAc,EAAE;CACjD,CAAC;CAED,MAAM,QAAQ,IAAI,IACjB,QAAQ,KAAK,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,QAAQ,MAAmB,CAAC,CAAC,CAAC,CAClE;CAEA,IAAI,OAAO;CACX,KAAK,MAAM,GAAG,QAAQ,SAAS;EAC9B,IAAI,IAAI,MAAM;EACd,OAAO,MAAM,IAAI,IAAI,GAAG,QAAQ;EAChC,IAAI,OAAO;EACX,MAAM,IAAI,IAAI;CACf;AACD;;;;;;;AAQA,SAAS,SAAS,MAAiD;CAClE,MAAM,QAAQ,OA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A,OAAO;EACN;EACA,KAAK,SAAS;EACd,WAAW,aAAa;EACxB;CACD;AACD"}
@@ -1,11 +1,26 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_discover = require('./discover-DTmFeloL.cjs');
3
- const require_workspace = require('./workspace-XvqO9jIv.cjs');
4
- const node_fs = require_chunk.__toESM(require("node:fs"));
5
- const node_path = require_chunk.__toESM(require("node:path"));
6
- const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
7
-
1
+ const require_discover = require("./discover-CroTIm0K.cjs");
2
+ const require_workspace = require("./workspace-Bav3TVrP.cjs");
3
+ let node_fs = require("node:fs");
4
+ let node_path = require("node:path");
5
+ let _geekmidas_manifest = require("@geekmidas/manifest");
8
6
  //#region src/workspace/derive.ts
7
+ /**
8
+ * The apps a manifest implies.
9
+ *
10
+ * `gkm.config.ts` used to carry an `apps` block naming every app: its type, its
11
+ * path, its port, its framework, which other apps it depended on. Every one of
12
+ * those facts was already declared. A `StaticSite('Web', { path: 'apps/web' })`
13
+ * and an `apps.web = { type: 'web', path: 'apps/web', framework: 'vite',
14
+ * dependencies: ['api'] }` are the same statement written twice, and only one of
15
+ * them was checked against anything — so the copy in config was free to drift,
16
+ * and a surface config had no entry for simply never deployed.
17
+ *
18
+ * So the list comes from the graph. A `site` is an app, and so is every
19
+ * `rest-api` — one surface, one container, at the `path` it declared.
20
+ *
21
+ * What config still supplies is what no graph can answer: the backends a cache
22
+ * and a mailer resolve to, the deploy endpoint, the stage's domain.
23
+ */
9
24
  /** Which frontend framework builds each site variant. */
10
25
  const FRAMEWORKS = {
11
26
  static: "vite",
@@ -20,7 +35,7 @@ const FRAMEWORKS = {
20
35
  * environment — one id, three renderings, no second list.
21
36
  */
22
37
  function appKey(id) {
23
- return (0, __geekmidas_manifest.kebabCase)(id);
38
+ return (0, _geekmidas_manifest.kebabCase)(id);
24
39
  }
25
40
  /**
26
41
  * The app serving a surface: its own, always.
@@ -77,66 +92,15 @@ function markRoot(apps) {
77
92
  const chosen = sites.find(([name]) => name === "web") ?? (sites.length === 1 ? sites[0] : void 0);
78
93
  if (chosen) chosen[1].root = true;
79
94
  }
80
- /**
81
- * What `app: true` means, and what the object form leaves out.
82
- *
83
- * Both fields follow from the construct's own id, so neither was worth making
84
- * someone write down:
85
- *
86
- * - `path` is `apps/<kebab-id>` where that directory exists, and the workspace
87
- * root otherwise. `Api` means `apps/api` in a monorepo and `.` in a
88
- * single-app project, and which of the two you are in is answerable by
89
- * looking.
90
- * - `code` is the conventional directories under `path`. A glob is worth
91
- * writing only when the code is somewhere else, which is the case the field
92
- * still exists for.
93
- *
94
- * A site takes no `code`: its build is its framework's, not ours.
95
- */
96
- /**
97
- * Where an app lives when it did not say.
98
- *
99
- * `apps/<kebab-id>`, which is what the id already said — or the project root
100
- * when there is no `apps/` at all, because then there is one app and it is the
101
- * project.
102
- *
103
- * In between, it refuses. A workspace *with* an `apps/` directory and no
104
- * `apps/<key>` in it is a construct naming a directory nobody wrote, and
105
- * quietly answering `.` there makes the app the whole repository: the build
106
- * filters turbo on the root `package.json` and builds the wrong thing, or
107
- * itself. A missing directory is a typo or an unconventional layout, and both
108
- * want saying out loud.
109
- */
110
- function conventionalPath(id, workspaceRoot) {
111
- const conventional = (0, node_path.join)("apps", appKey(id));
112
- if ((0, node_fs.existsSync)((0, node_path.join)(workspaceRoot, conventional))) return conventional;
113
- if (!(0, node_fs.existsSync)((0, node_path.join)(workspaceRoot, "apps"))) return ".";
114
- throw new MisplacedApp(id, conventional);
115
- }
116
- /** A construct whose directory is not where its id says it is. */
117
- var MisplacedApp = class extends Error {
118
- constructor(construct, expected) {
119
- super(`"${construct}" has no directory at ${expected}.\nCreate it, or say where it lives:\n new StaticSite('${construct}', { path: 'sites/${appKey(construct)}' })\n new RestApi('${construct}', { …, app: { path: 'services/${appKey(construct)}' } })`);
120
- this.construct = construct;
121
- this.expected = expected;
122
- this.name = "MisplacedApp";
123
- }
124
- };
125
- function resolveAppSpec(id, spec, workspaceRoot, kind) {
126
- const path = spec.path ?? conventionalPath(id, workspaceRoot);
127
- const givenAGlob = spec.code !== void 0 || spec.routes !== void 0 || spec.functions !== void 0 || spec.crons !== void 0 || spec.queues !== void 0 || spec.topics !== void 0 || spec.subscribers !== void 0;
128
- return {
129
- ...spec,
130
- path,
131
- ...kind !== "site" && !givenAGlob ? { code: __geekmidas_manifest.DEFAULT_APP_CODE } : {}
132
- };
133
- }
134
95
  function derivedApps(manifest, workspace) {
135
96
  const apps = {};
136
97
  const defaultTarget = workspace.deploy?.default ?? "dokploy";
137
98
  for (const [id, declaration] of Object.entries(manifest)) {
138
- if (declaration.kind !== "site" && declaration.kind !== "rest-api" && declaration.kind !== "worker") continue;
139
- const spec = resolveAppSpec(id, declaration.app ?? {}, workspace.root, declaration.kind);
99
+ if (declaration.kind !== "site" && declaration.kind !== "rest-api") continue;
100
+ const spec = declaration.kind === "site" ? declaration.app : {
101
+ path: declaration.path,
102
+ ...declaration.telescope ? { telescope: true } : {}
103
+ };
140
104
  const name = appKey(id);
141
105
  const configured = workspace.apps[name];
142
106
  apps[name] = {
@@ -151,22 +115,6 @@ function derivedApps(manifest, workspace) {
151
115
  ...declaration.root ? { root: true } : {},
152
116
  ...spec.config ? { config: spec.config } : {}
153
117
  } : {},
154
- ...spec.code !== void 0 ? {
155
- routes: spec.code,
156
- functions: spec.code,
157
- crons: spec.code,
158
- queues: spec.code,
159
- topics: spec.code,
160
- subscribers: spec.code
161
- } : {},
162
- ...spec.routes !== void 0 ? { routes: spec.routes } : {},
163
- ...spec.functions !== void 0 ? { functions: spec.functions } : {},
164
- ...spec.crons !== void 0 ? { crons: spec.crons } : {},
165
- ...spec.queues !== void 0 ? { queues: spec.queues } : {},
166
- ...spec.topics !== void 0 ? { topics: spec.topics } : {},
167
- ...spec.subscribers !== void 0 ? { subscribers: spec.subscribers } : {},
168
- ...spec.envParser !== void 0 ? { envParser: spec.envParser } : {},
169
- ...spec.logger !== void 0 ? { logger: spec.logger } : {},
170
118
  ...spec.telescope !== void 0 ? { telescope: spec.telescope } : {},
171
119
  ...spec.studio !== void 0 ? { studio: spec.studio } : {},
172
120
  ...spec.openapi !== void 0 ? { openapi: spec.openapi } : {},
@@ -177,7 +125,7 @@ function derivedApps(manifest, workspace) {
177
125
  };
178
126
  }
179
127
  for (const [id, declaration] of Object.entries(manifest)) {
180
- if (declaration.kind !== "site" && declaration.kind !== "rest-api" && declaration.kind !== "worker") continue;
128
+ if (declaration.kind !== "site" && declaration.kind !== "rest-api") continue;
181
129
  const app = apps[appKey(id)];
182
130
  if (!app) continue;
183
131
  const edges = declaration.kind === "rest-api" ? declaration.calls ?? [] : declaration.dependencies ?? [];
@@ -196,7 +144,6 @@ function derivedApps(manifest, workspace) {
196
144
  for (const [name, app] of Object.entries(workspace.apps)) if (!apps[name]) apps[name] = app;
197
145
  return apps;
198
146
  }
199
-
200
147
  //#endregion
201
148
  //#region src/config.ts
202
149
  /**
@@ -240,10 +187,9 @@ function parseModuleConfig(configString, defaultAlias) {
240
187
  const parts = configString.split("#");
241
188
  const path = parts[0] ?? configString;
242
189
  const exportName = parts[1];
243
- const importPattern = !exportName ? defaultAlias : exportName === defaultAlias ? `{ ${defaultAlias} }` : `{ ${exportName} as ${defaultAlias} }`;
244
190
  return {
245
191
  path,
246
- importPattern
192
+ importPattern: !exportName ? defaultAlias : exportName === defaultAlias ? `{ ${defaultAlias} }` : `{ ${exportName} as ${defaultAlias} }`
247
193
  };
248
194
  }
249
195
  /**
@@ -291,8 +237,7 @@ function getAppNameFromCwd(cwd = process.cwd()) {
291
237
  const packageJsonPath = (0, node_path.join)(cwd, "package.json");
292
238
  if (!(0, node_fs.existsSync)(packageJsonPath)) return null;
293
239
  try {
294
- const packageJson = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8"));
295
- const name = packageJson.name;
240
+ const name = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8")).name;
296
241
  if (!name) return null;
297
242
  if (name.startsWith("@") && name.includes("/")) return name.split("/")[1] ?? null;
298
243
  return name;
@@ -306,9 +251,8 @@ function getAppNameFromCwd(cwd = process.cwd()) {
306
251
  async function loadRawConfig(cwd) {
307
252
  const { configPath, workspaceRoot } = findConfigPath(cwd);
308
253
  try {
309
- const config = await import(configPath);
310
254
  return {
311
- config: config.default,
255
+ config: (await import(configPath)).default,
312
256
  workspaceRoot
313
257
  };
314
258
  } catch (error) {
@@ -368,7 +312,7 @@ async function loadWorkspaceConfig(cwd = process.cwd()) {
368
312
  */
369
313
  async function withDerivedApps(loaded) {
370
314
  const globs = require_workspace.allConstructGlobs(loaded.workspace);
371
- if (globs.length === 0) return loaded;
315
+ if (globs.length === 0) throw new WorkspaceDeclaresNoConstructs(loaded.workspace.root);
372
316
  try {
373
317
  const manifest = await require_discover.discover({
374
318
  patterns: globs,
@@ -389,6 +333,21 @@ async function withDerivedApps(loaded) {
389
333
  }
390
334
  }
391
335
  /**
336
+ * A workspace with no `constructs` glob.
337
+ *
338
+ * In v10 every address, container and app comes from what the workspace
339
+ * declares — there is no second path that reads a hand-written compose file or
340
+ * an `apps` block's ports. A config that declares nothing has nothing to run.
341
+ */
342
+ var WorkspaceDeclaresNoConstructs = class extends Error {
343
+ root;
344
+ constructor(root) {
345
+ super(`The workspace at ${root} declares no constructs. Every workspace names where its constructs live — \`constructs: ['./constructs/**/*.ts', './apps/*/endpoints/**/*.ts']\` in gkm.config.ts — and its apps, containers and URLs are derived from them.`);
346
+ this.root = root;
347
+ this.name = "WorkspaceDeclaresNoConstructs";
348
+ }
349
+ };
350
+ /**
392
351
  * The app a package directory refers to, and what the workspace calls it.
393
352
  *
394
353
  * A single-app config is wrapped as a one-app workspace keyed `api`, which is
@@ -405,7 +364,7 @@ function resolveWorkspaceApp(loadedConfig, appName) {
405
364
  };
406
365
  const names = Object.keys(apps);
407
366
  const only = names[0];
408
- if (loadedConfig.type !== "single" || names.length !== 1 || !only) return void 0;
367
+ if (loadedConfig.type !== "single" || names.length !== 1 || !only) return;
409
368
  const app = apps[only];
410
369
  return app ? {
411
370
  key: only,
@@ -464,72 +423,66 @@ async function loadWorkspaceAppInfo(cwd = process.cwd()) {
464
423
  workspaceRoot
465
424
  };
466
425
  }
467
-
468
426
  //#endregion
469
- Object.defineProperty(exports, 'appKey', {
470
- enumerable: true,
471
- get: function () {
472
- return appKey;
473
- }
474
- });
475
- Object.defineProperty(exports, 'defineConfig', {
476
- enumerable: true,
477
- get: function () {
478
- return defineConfig;
479
- }
427
+ Object.defineProperty(exports, "WorkspaceDeclaresNoConstructs", {
428
+ enumerable: true,
429
+ get: function() {
430
+ return WorkspaceDeclaresNoConstructs;
431
+ }
480
432
  });
481
- Object.defineProperty(exports, 'derivedApps', {
482
- enumerable: true,
483
- get: function () {
484
- return derivedApps;
485
- }
433
+ Object.defineProperty(exports, "appKey", {
434
+ enumerable: true,
435
+ get: function() {
436
+ return appKey;
437
+ }
486
438
  });
487
- Object.defineProperty(exports, 'getAppNameFromCwd', {
488
- enumerable: true,
489
- get: function () {
490
- return getAppNameFromCwd;
491
- }
439
+ Object.defineProperty(exports, "defineConfig", {
440
+ enumerable: true,
441
+ get: function() {
442
+ return defineConfig;
443
+ }
492
444
  });
493
- Object.defineProperty(exports, 'hostOf', {
494
- enumerable: true,
495
- get: function () {
496
- return hostOf;
497
- }
445
+ Object.defineProperty(exports, "derivedApps", {
446
+ enumerable: true,
447
+ get: function() {
448
+ return derivedApps;
449
+ }
498
450
  });
499
- Object.defineProperty(exports, 'loadAppConfig', {
500
- enumerable: true,
501
- get: function () {
502
- return loadAppConfig;
503
- }
451
+ Object.defineProperty(exports, "getAppNameFromCwd", {
452
+ enumerable: true,
453
+ get: function() {
454
+ return getAppNameFromCwd;
455
+ }
504
456
  });
505
- Object.defineProperty(exports, 'loadConfig', {
506
- enumerable: true,
507
- get: function () {
508
- return loadConfig;
509
- }
457
+ Object.defineProperty(exports, "loadAppConfig", {
458
+ enumerable: true,
459
+ get: function() {
460
+ return loadAppConfig;
461
+ }
510
462
  });
511
- Object.defineProperty(exports, 'loadWorkspaceAppInfo', {
512
- enumerable: true,
513
- get: function () {
514
- return loadWorkspaceAppInfo;
515
- }
463
+ Object.defineProperty(exports, "loadConfig", {
464
+ enumerable: true,
465
+ get: function() {
466
+ return loadConfig;
467
+ }
516
468
  });
517
- Object.defineProperty(exports, 'loadWorkspaceConfig', {
518
- enumerable: true,
519
- get: function () {
520
- return loadWorkspaceConfig;
521
- }
469
+ Object.defineProperty(exports, "loadWorkspaceAppInfo", {
470
+ enumerable: true,
471
+ get: function() {
472
+ return loadWorkspaceAppInfo;
473
+ }
522
474
  });
523
- Object.defineProperty(exports, 'parseModuleConfig', {
524
- enumerable: true,
525
- get: function () {
526
- return parseModuleConfig;
527
- }
475
+ Object.defineProperty(exports, "loadWorkspaceConfig", {
476
+ enumerable: true,
477
+ get: function() {
478
+ return loadWorkspaceConfig;
479
+ }
528
480
  });
529
- Object.defineProperty(exports, 'resolveAppSpec', {
530
- enumerable: true,
531
- get: function () {
532
- return resolveAppSpec;
533
- }
481
+ Object.defineProperty(exports, "parseModuleConfig", {
482
+ enumerable: true,
483
+ get: function() {
484
+ return parseModuleConfig;
485
+ }
534
486
  });
535
- //# sourceMappingURL=config-BholeD-0.cjs.map
487
+
488
+ //# sourceMappingURL=config-URVD4bTj.cjs.map