zudojs-cli 2.0.1 → 2.1.1

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 (248) hide show
  1. package/README.md +59 -7
  2. package/dist/src/adapters/frontend/angular.adapter.d.ts +0 -1
  3. package/dist/src/adapters/frontend/angular.adapter.js +14 -97
  4. package/dist/src/adapters/frontend/astro.adapter.d.ts +0 -1
  5. package/dist/src/adapters/frontend/astro.adapter.js +4 -64
  6. package/dist/src/adapters/frontend/fallback/fallback.helper.d.ts +41 -0
  7. package/dist/src/adapters/frontend/fallback/fallback.helper.js +57 -0
  8. package/dist/src/adapters/frontend/fallback/framework/angular/angular.fallback.d.ts +18 -0
  9. package/dist/src/adapters/frontend/fallback/framework/angular/angular.fallback.js +107 -0
  10. package/dist/src/adapters/frontend/fallback/framework/angular/angularWorkspace.fallback.d.ts +23 -0
  11. package/dist/src/adapters/frontend/fallback/framework/angular/angularWorkspace.fallback.js +125 -0
  12. package/dist/src/adapters/frontend/fallback/framework/angular/index.d.ts +8 -0
  13. package/dist/src/adapters/frontend/fallback/framework/angular/index.js +8 -0
  14. package/dist/src/adapters/frontend/fallback/framework/astro.fallback.d.ts +14 -0
  15. package/dist/src/adapters/frontend/fallback/framework/astro.fallback.js +76 -0
  16. package/dist/src/adapters/frontend/fallback/framework/index.d.ts +13 -0
  17. package/dist/src/adapters/frontend/fallback/framework/index.js +13 -0
  18. package/dist/src/adapters/frontend/fallback/framework/next.fallback.d.ts +13 -0
  19. package/dist/src/adapters/frontend/fallback/framework/next.fallback.js +105 -0
  20. package/dist/src/adapters/frontend/fallback/framework/nuxt.fallback.d.ts +14 -0
  21. package/dist/src/adapters/frontend/fallback/framework/nuxt.fallback.js +56 -0
  22. package/dist/src/adapters/frontend/fallback/framework/sveltekit.fallback.d.ts +15 -0
  23. package/dist/src/adapters/frontend/fallback/framework/sveltekit.fallback.js +94 -0
  24. package/dist/src/adapters/frontend/fallback/index.d.ts +12 -0
  25. package/dist/src/adapters/frontend/fallback/index.js +12 -0
  26. package/dist/src/adapters/frontend/fallback/vite/index.d.ts +11 -0
  27. package/dist/src/adapters/frontend/fallback/vite/index.js +11 -0
  28. package/dist/src/adapters/frontend/fallback/vite/react.fallback.d.ts +13 -0
  29. package/dist/src/adapters/frontend/fallback/vite/react.fallback.js +77 -0
  30. package/dist/src/adapters/frontend/fallback/vite/svelte.fallback.d.ts +14 -0
  31. package/dist/src/adapters/frontend/fallback/vite/svelte.fallback.js +95 -0
  32. package/dist/src/adapters/frontend/fallback/vite/vanilla.fallback.d.ts +13 -0
  33. package/dist/src/adapters/frontend/fallback/vite/vanilla.fallback.js +71 -0
  34. package/dist/src/adapters/frontend/fallback/vite/vue.fallback.d.ts +14 -0
  35. package/dist/src/adapters/frontend/fallback/vite/vue.fallback.js +78 -0
  36. package/dist/src/adapters/frontend/next.adapter.d.ts +0 -1
  37. package/dist/src/adapters/frontend/next.adapter.js +16 -95
  38. package/dist/src/adapters/frontend/nuxt.adapter.d.ts +1 -2
  39. package/dist/src/adapters/frontend/nuxt.adapter.js +32 -43
  40. package/dist/src/adapters/frontend/react-native.adapter.js +1 -1
  41. package/dist/src/adapters/frontend/react.adapter.d.ts +0 -1
  42. package/dist/src/adapters/frontend/react.adapter.js +7 -89
  43. package/dist/src/adapters/frontend/svelte.adapter.d.ts +0 -1
  44. package/dist/src/adapters/frontend/svelte.adapter.js +4 -86
  45. package/dist/src/adapters/frontend/sveltekit.adapter.d.ts +0 -1
  46. package/dist/src/adapters/frontend/sveltekit.adapter.js +4 -57
  47. package/dist/src/adapters/frontend/vanilla.adapter.d.ts +0 -1
  48. package/dist/src/adapters/frontend/vanilla.adapter.js +4 -47
  49. package/dist/src/adapters/frontend/vue.adapter.d.ts +0 -1
  50. package/dist/src/adapters/frontend/vue.adapter.js +4 -76
  51. package/dist/src/bin/bin.menu.d.ts +22 -0
  52. package/dist/src/bin/bin.menu.js +40 -0
  53. package/dist/src/bin/bin.runner.d.ts +38 -0
  54. package/dist/src/bin/bin.runner.js +51 -0
  55. package/dist/src/bin/index.d.ts +9 -0
  56. package/dist/src/bin/index.js +9 -0
  57. package/dist/src/bin/zudojs.js +15 -4
  58. package/dist/src/cliApplication/cliApplication.core.d.ts +4 -2
  59. package/dist/src/cliApplication/cliApplication.core.js +48 -36
  60. package/dist/src/cliApplication/cliApplication.logger.d.ts +5 -0
  61. package/dist/src/cliApplication/cliApplication.logger.js +5 -3
  62. package/dist/src/cliApplication/invocation/index.d.ts +12 -0
  63. package/dist/src/cliApplication/invocation/index.js +12 -0
  64. package/dist/src/cliApplication/invocation/invocation.hint.d.ts +30 -0
  65. package/dist/src/cliApplication/invocation/invocation.hint.js +74 -0
  66. package/dist/src/cliApplication/invocation/invocation.locate.d.ts +34 -0
  67. package/dist/src/cliApplication/invocation/invocation.locate.js +53 -0
  68. package/dist/src/cliApplication/invocation/invocation.name.d.ts +37 -0
  69. package/dist/src/cliApplication/invocation/invocation.name.js +69 -0
  70. package/dist/src/cliApplication/invocation/invocation.sanitize.d.ts +19 -0
  71. package/dist/src/cliApplication/invocation/invocation.sanitize.js +32 -0
  72. package/dist/src/cliParser/cliParser.core.js +3 -1
  73. package/dist/src/cliParser/cliParser.helper.d.ts +7 -0
  74. package/dist/src/cliParser/cliParser.helper.js +19 -2
  75. package/dist/src/cliParser/cliParser.longOption.js +2 -2
  76. package/dist/src/commands/add.command.d.ts +7 -3
  77. package/dist/src/commands/add.command.js +96 -57
  78. package/dist/src/commands/create.command.js +29 -42
  79. package/dist/src/commands/doctor.command.d.ts +2 -1
  80. package/dist/src/commands/doctor.command.js +52 -4
  81. package/dist/src/commands/generate.command.js +31 -16
  82. package/dist/src/commands/info.command.js +11 -1
  83. package/dist/src/constants/index.d.ts +21 -3
  84. package/dist/src/constants/index.js +40 -5
  85. package/dist/src/constants/zudojsVersions.generated.d.ts +9 -0
  86. package/dist/src/constants/zudojsVersions.generated.js +48 -0
  87. package/dist/src/constants/zudojsVersions.helper.d.ts +21 -0
  88. package/dist/src/constants/zudojsVersions.helper.js +29 -0
  89. package/dist/src/generators/frontend/frontendGenerator.core.js +9 -10
  90. package/dist/src/generators/frontend/frontendPipeline.d.ts +6 -1
  91. package/dist/src/generators/frontend/frontendPipeline.js +9 -1
  92. package/dist/src/generators/fullstack/fullstackComposer.core.js +7 -1
  93. package/dist/src/generators/index.d.ts +1 -2
  94. package/dist/src/generators/index.js +1 -2
  95. package/dist/src/generators/infrastructure/infrastructure.generator.js +13 -5
  96. package/dist/src/generators/integration/integrationGenerator.core.d.ts +2 -0
  97. package/dist/src/generators/integration/integrationGenerator.core.js +31 -2
  98. package/dist/src/generators/module/module.generator.js +36 -4
  99. package/dist/src/generators/resource/index.d.ts +8 -0
  100. package/dist/src/generators/resource/index.js +8 -0
  101. package/dist/src/generators/resource/resource.generator.d.ts +27 -0
  102. package/dist/src/generators/resource/resource.generator.js +87 -0
  103. package/dist/src/generators/resource/resource.layout.d.ts +26 -0
  104. package/dist/src/generators/resource/resource.layout.js +46 -0
  105. package/dist/src/generators/resource/resource.plan.d.ts +27 -0
  106. package/dist/src/generators/resource/resource.plan.js +46 -0
  107. package/dist/src/generators/resource/resource.run.d.ts +25 -0
  108. package/dist/src/generators/resource/resource.run.js +52 -0
  109. package/dist/src/prompts/cancel.prompt.d.ts +5 -1
  110. package/dist/src/prompts/cancel.prompt.js +4 -0
  111. package/dist/src/prompts/menu/index.d.ts +13 -0
  112. package/dist/src/prompts/menu/index.js +13 -0
  113. package/dist/src/prompts/menu/menu.adapter.d.ts +16 -0
  114. package/dist/src/prompts/menu/menu.adapter.js +56 -0
  115. package/dist/src/prompts/menu/menu.constant.d.ts +20 -0
  116. package/dist/src/prompts/menu/menu.constant.js +29 -0
  117. package/dist/src/prompts/menu/menu.flow.d.ts +18 -0
  118. package/dist/src/prompts/menu/menu.flow.js +82 -0
  119. package/dist/src/prompts/menu/menu.select.d.ts +26 -0
  120. package/dist/src/prompts/menu/menu.select.js +118 -0
  121. package/dist/src/prompts/menu/menu.type.d.ts +66 -0
  122. package/dist/src/prompts/menu/menu.type.js +8 -0
  123. package/dist/src/recipes/apply/index.d.ts +9 -0
  124. package/dist/src/recipes/apply/index.js +9 -0
  125. package/dist/src/recipes/apply/recipeApply.app.d.ts +20 -0
  126. package/dist/src/recipes/apply/recipeApply.app.js +79 -0
  127. package/dist/src/recipes/apply/recipeApply.context.d.ts +14 -0
  128. package/dist/src/recipes/apply/recipeApply.context.js +76 -0
  129. package/dist/src/recipes/apply/recipeApply.files.d.ts +39 -0
  130. package/dist/src/recipes/apply/recipeApply.files.js +84 -0
  131. package/dist/src/recipes/apply/recipeApply.project.d.ts +11 -0
  132. package/dist/src/recipes/apply/recipeApply.project.js +50 -0
  133. package/dist/src/recipes/apply/recipeApply.report.d.ts +20 -0
  134. package/dist/src/recipes/apply/recipeApply.report.js +51 -0
  135. package/dist/src/recipes/catalog/database/database.files.d.ts +15 -0
  136. package/dist/src/recipes/catalog/database/database.files.js +98 -0
  137. package/dist/src/recipes/catalog/database/database.recipe.d.ts +9 -0
  138. package/dist/src/recipes/catalog/database/database.recipe.js +50 -0
  139. package/dist/src/recipes/catalog/database/index.d.ts +6 -0
  140. package/dist/src/recipes/catalog/database/index.js +6 -0
  141. package/dist/src/recipes/catalog/email.recipe.d.ts +9 -0
  142. package/dist/src/recipes/catalog/email.recipe.js +122 -0
  143. package/dist/src/recipes/catalog/index.d.ts +11 -0
  144. package/dist/src/recipes/catalog/index.js +11 -0
  145. package/dist/src/recipes/catalog/openapi.recipe.d.ts +8 -0
  146. package/dist/src/recipes/catalog/openapi.recipe.js +25 -0
  147. package/dist/src/recipes/catalog/platform/cache.recipe.d.ts +7 -0
  148. package/dist/src/recipes/catalog/platform/cache.recipe.js +55 -0
  149. package/dist/src/recipes/catalog/platform/index.d.ts +9 -0
  150. package/dist/src/recipes/catalog/platform/index.js +9 -0
  151. package/dist/src/recipes/catalog/platform/messaging.recipe.d.ts +7 -0
  152. package/dist/src/recipes/catalog/platform/messaging.recipe.js +46 -0
  153. package/dist/src/recipes/catalog/platform/observability.recipe.d.ts +8 -0
  154. package/dist/src/recipes/catalog/platform/observability.recipe.js +49 -0
  155. package/dist/src/recipes/catalog/platform/queue.recipe.d.ts +7 -0
  156. package/dist/src/recipes/catalog/platform/queue.recipe.js +61 -0
  157. package/dist/src/recipes/catalog/platform/scheduler.recipe.d.ts +7 -0
  158. package/dist/src/recipes/catalog/platform/scheduler.recipe.js +56 -0
  159. package/dist/src/recipes/catalog/redis.recipe.d.ts +8 -0
  160. package/dist/src/recipes/catalog/redis.recipe.js +79 -0
  161. package/dist/src/recipes/catalog/storage.recipe.d.ts +7 -0
  162. package/dist/src/recipes/catalog/storage.recipe.js +49 -0
  163. package/dist/src/recipes/catalog/websockets.recipe.d.ts +10 -0
  164. package/dist/src/recipes/catalog/websockets.recipe.js +84 -0
  165. package/dist/src/recipes/docker/docker.compose.d.ts +19 -0
  166. package/dist/src/recipes/docker/docker.compose.js +90 -0
  167. package/dist/src/recipes/docker/docker.recipe.d.ts +10 -0
  168. package/dist/src/recipes/docker/docker.recipe.js +51 -0
  169. package/dist/src/recipes/docker/docker.refresh.d.ts +13 -0
  170. package/dist/src/recipes/docker/docker.refresh.js +37 -0
  171. package/dist/src/recipes/docker/index.d.ts +7 -0
  172. package/dist/src/recipes/docker/index.js +7 -0
  173. package/dist/src/recipes/index.d.ts +8 -0
  174. package/dist/src/recipes/index.js +8 -0
  175. package/dist/src/recipes/recipe.registry.d.ts +17 -0
  176. package/dist/src/recipes/recipe.registry.js +46 -0
  177. package/dist/src/recipes/recipe.type.d.ts +93 -0
  178. package/dist/src/recipes/recipe.type.js +12 -0
  179. package/dist/src/resolvers/dependency/dependencyVersions.constant.d.ts +100 -5
  180. package/dist/src/resolvers/dependency/dependencyVersions.constant.js +103 -34
  181. package/dist/src/resolvers/dependency/index.d.ts +1 -1
  182. package/dist/src/resolvers/dependency/index.js +1 -1
  183. package/dist/src/resolvers/project.resolver.d.ts +14 -1
  184. package/dist/src/resolvers/project.resolver.js +11 -3
  185. package/dist/src/scaffolders/scaffolder.helper.js +12 -1
  186. package/dist/src/templates/backendApp/backendApp.core.d.ts +45 -0
  187. package/dist/src/templates/backendApp/backendApp.core.js +66 -0
  188. package/dist/src/templates/backendApp/backendApp.modules.d.ts +26 -0
  189. package/dist/src/templates/backendApp/backendApp.modules.js +25 -0
  190. package/dist/src/templates/backendApp/backendApp.project.d.ts +26 -0
  191. package/dist/src/templates/backendApp/backendApp.project.js +87 -0
  192. package/dist/src/templates/backendApp/index.d.ts +8 -0
  193. package/dist/src/templates/backendApp/index.js +8 -0
  194. package/dist/src/templates/backendApp/parts/config.template.d.ts +28 -0
  195. package/dist/src/templates/backendApp/parts/config.template.js +118 -0
  196. package/dist/src/templates/backendApp/parts/httpUtils.template.d.ts +10 -0
  197. package/dist/src/templates/backendApp/parts/httpUtils.template.js +103 -0
  198. package/dist/src/templates/backendApp/parts/index.d.ts +9 -0
  199. package/dist/src/templates/backendApp/parts/index.js +9 -0
  200. package/dist/src/templates/backendApp/parts/integrations.template.d.ts +16 -0
  201. package/dist/src/templates/backendApp/parts/integrations.template.js +115 -0
  202. package/dist/src/templates/backendApp/parts/wiring.template.d.ts +26 -0
  203. package/dist/src/templates/backendApp/parts/wiring.template.js +111 -0
  204. package/dist/src/templates/microservice/microservice.template.js +61 -87
  205. package/dist/src/templates/modular-monolith/modularMonolith.template.js +25 -77
  206. package/dist/src/templates/monolith/monolith.template.d.ts +11 -26
  207. package/dist/src/templates/monolith/monolith.template.js +49 -146
  208. package/dist/src/templates/resource/index.d.ts +9 -0
  209. package/dist/src/templates/resource/index.js +9 -0
  210. package/dist/src/templates/resource/layers/index.d.ts +9 -0
  211. package/dist/src/templates/resource/layers/index.js +9 -0
  212. package/dist/src/templates/resource/layers/resourceData.template.d.ts +9 -0
  213. package/dist/src/templates/resource/layers/resourceData.template.js +108 -0
  214. package/dist/src/templates/resource/layers/resourcePrisma.template.d.ts +15 -0
  215. package/dist/src/templates/resource/layers/resourcePrisma.template.js +89 -0
  216. package/dist/src/templates/resource/layers/resourceRoutes.template.d.ts +13 -0
  217. package/dist/src/templates/resource/layers/resourceRoutes.template.js +128 -0
  218. package/dist/src/templates/resource/layers/resourceService.template.d.ts +13 -0
  219. package/dist/src/templates/resource/layers/resourceService.template.js +95 -0
  220. package/dist/src/templates/resource/resource.files.d.ts +33 -0
  221. package/dist/src/templates/resource/resource.files.js +99 -0
  222. package/dist/src/templates/resource/resource.names.d.ts +38 -0
  223. package/dist/src/templates/resource/resource.names.js +60 -0
  224. package/dist/src/templates/resource/resource.type.d.ts +19 -0
  225. package/dist/src/templates/resource/resource.type.js +15 -0
  226. package/dist/src/templates/shared/appRuntime.template.js +28 -11
  227. package/dist/src/templates/shared/capability.template.d.ts +13 -4
  228. package/dist/src/templates/shared/capability.template.js +21 -5
  229. package/dist/src/templates/shared/dockerfile.template.d.ts +12 -4
  230. package/dist/src/templates/shared/dockerfile.template.js +68 -29
  231. package/dist/src/templates/shared/pnpm.template.d.ts +8 -2
  232. package/dist/src/templates/shared/pnpm.template.js +9 -1
  233. package/dist/src/templates/shared/server.template.d.ts +23 -22
  234. package/dist/src/templates/shared/server.template.js +79 -53
  235. package/dist/src/types/scaffold.type.d.ts +6 -0
  236. package/dist/src/types/scaffold.type.js +2 -1
  237. package/dist/src/utils/utils.name.js +6 -0
  238. package/dist/src/utils/utils.writeGuard.d.ts +5 -0
  239. package/dist/src/utils/utils.writeGuard.js +23 -0
  240. package/dist/src/wiring/index.d.ts +10 -0
  241. package/dist/src/wiring/index.js +10 -0
  242. package/dist/src/wiring/wiring.dependencies.d.ts +29 -0
  243. package/dist/src/wiring/wiring.dependencies.js +83 -0
  244. package/dist/src/wiring/wiring.edits.d.ts +51 -0
  245. package/dist/src/wiring/wiring.edits.js +90 -0
  246. package/dist/src/wiring/wiring.markers.d.ts +53 -0
  247. package/dist/src/wiring/wiring.markers.js +87 -0
  248. package/package.json +20 -15
@@ -21,9 +21,12 @@
21
21
  * └── README.md
22
22
  * ```
23
23
  */
24
- import { ZUDOJS_PACKAGES_VERSION } from "../../constants/index.js";
24
+ import { renderDatabaseEnv } from "../../adapters/databases/databaseAdapter.resolver.js";
25
+ import { zudojsDependencies } from "../../constants/index.js";
25
26
  import { normalizeName } from "../../utils/utils.name.js";
26
- import { RUNTIME_APP_DEPENDENCIES, capabilityPackages, moduleSpec, renderAppPackageDockerfile, renderAppFile, renderModuleFile, renderServerFile, renderPnpmWorkspaceFile, resolveProjectCapabilities, } from "../shared/index.js";
27
+ import { RUNTIME_APP_DEPENDENCIES, capabilityPackages, moduleSpec, renderAppPackageDockerfile, renderModuleFile, renderPnpmWorkspaceFile, resolveProjectCapabilities, } from "../shared/index.js";
28
+ import { DEPENDENCY_VERSION_RANGES, TYPESCRIPT_VERSION_RANGES, } from "../../resolvers/dependency/dependencyVersions.constant.js";
29
+ import { APP_SOURCE_DEPENDENCIES, APP_TEST_DEPENDENCIES, applyDatabaseSetting, backendDevDependencies, emptyBarrels, renderBackendAppSource, } from "../backendApp/index.js";
27
30
  /**
28
31
  * The gateway app is always generated at `apps/gateway`, so "gateway" is a
29
32
  * reserved name: a service called `gateway` would produce a second, competing
@@ -57,9 +60,9 @@ export function generateMicroserviceFiles(options) {
57
60
  .toLowerCase();
58
61
  const services = resolveMicroserviceServices(options.services);
59
62
  // The workspace root records the capabilities for the project as a whole
60
- // (`zudojs info` reads it when there is no manifest); the service apps
61
- // record them next to the dependencies that back them, which is where
62
- // `zudojs add` writes and `zudojs doctor` reads.
63
+ // alongside the manifest, and `zudojs add` keeps the two in step); the
64
+ // gateway and service apps record them next to the dependencies that back
65
+ // them, which is where `zudojs add` writes and `zudojs doctor` reads.
63
66
  const capabilities = resolveProjectCapabilities(options);
64
67
  const files = {};
65
68
  // Root package.json (workspace root)
@@ -85,6 +88,13 @@ export function generateMicroserviceFiles(options) {
85
88
  : options.packageManager === "bun"
86
89
  ? "bun run --filter '*' typecheck"
87
90
  : "pnpm -r run typecheck",
91
+ test: options.packageManager === "npm"
92
+ ? "npm run test --workspaces --if-present"
93
+ : options.packageManager === "yarn"
94
+ ? "yarn workspaces run test"
95
+ : options.packageManager === "bun"
96
+ ? "bun run --filter '*' test"
97
+ : "pnpm -r run test",
88
98
  };
89
99
  const workspaceGlobs = ["apps/gateway", "apps/services/*"];
90
100
  files["package.json"] =
@@ -104,8 +114,8 @@ export function generateMicroserviceFiles(options) {
104
114
  : { workspaces: workspaceGlobs }),
105
115
  scripts: rootScripts,
106
116
  devDependencies: {
107
- tsx: "^4.7.0",
108
- typescript: "^5.7.0",
117
+ tsx: DEPENDENCY_VERSION_RANGES.tsx,
118
+ typescript: TYPESCRIPT_VERSION_RANGES.backend,
109
119
  },
110
120
  }, null, 2) + "\n";
111
121
  if (options.packageManager === "pnpm") {
@@ -212,15 +222,45 @@ MIT
212
222
  }
213
223
  `;
214
224
  const appDevDeps = {
215
- tsx: "^4.7.0",
216
- typescript: "^5.7.0",
217
- "@types/node": "^24.0.0",
225
+ ...backendDevDependencies(),
226
+ ...zudojsDependencies(APP_TEST_DEPENDENCIES),
227
+ };
228
+ const appScripts = {
229
+ dev: "tsx watch src/server.ts",
230
+ start: "node dist/server.js",
231
+ build: "tsc",
232
+ typecheck: "tsc --noEmit",
233
+ test: "vitest run",
218
234
  };
219
- // Gateway service
235
+ /** The wired source tree of one app, plus its folder barrels. */
236
+ const appSource = (appName, port) => {
237
+ const spec = moduleSpec(appName, "./modules/index.js");
238
+ return {
239
+ ...emptyBarrels(),
240
+ ...applyDatabaseSetting(renderBackendAppSource({
241
+ applicationName: `${nameSlug}-${appName}`,
242
+ title: `${options.projectName} ${appName}`,
243
+ defaultPort: port,
244
+ openapi: options.enableOpenAPI === true,
245
+ modules: [spec],
246
+ port,
247
+ }), renderDatabaseEnv(options.database, `${nameSlug}-${appName}`)),
248
+ [`src/modules/${appName}.module.ts`]: renderModuleFile({ module: spec }),
249
+ "src/modules/index.ts": `export { ${spec.className} } from "./${appName}.module.js";\n`,
250
+ };
251
+ };
252
+ const prefixed = (prefix, tree) => {
253
+ for (const [path, content] of Object.entries(tree)) {
254
+ files[`${prefix}/${path}`] = content;
255
+ }
256
+ };
257
+ // Gateway service. It is a backend app like every service: `create` and
258
+ // `zudojs add` write capabilities to it and `zudojs doctor` checks it, so
259
+ // it declares and installs the same capabilities.
220
260
  const gatewayDeps = [
221
261
  ...RUNTIME_APP_DEPENDENCIES,
222
- "@zudojs/http",
223
- "@zudojs/config",
262
+ ...APP_SOURCE_DEPENDENCIES,
263
+ ...capabilityPackages(capabilities),
224
264
  ];
225
265
  files["apps/gateway/package.json"] =
226
266
  JSON.stringify({
@@ -228,13 +268,9 @@ MIT
228
268
  version: "0.1.0",
229
269
  private: true,
230
270
  type: "module",
231
- scripts: {
232
- dev: "tsx watch src/server.ts",
233
- start: "node dist/server.js",
234
- build: "tsc",
235
- typecheck: "tsc --noEmit",
236
- },
237
- dependencies: Object.fromEntries([...new Set(gatewayDeps)].map((d) => [d, ZUDOJS_PACKAGES_VERSION])),
271
+ zudojs: { features: capabilities },
272
+ scripts: appScripts,
273
+ dependencies: zudojsDependencies(gatewayDeps),
238
274
  devDependencies: appDevDeps,
239
275
  }, null, 2) + "\n";
240
276
  files["apps/gateway/tsconfig.json"] = appTsconfig;
@@ -243,27 +279,11 @@ MIT
243
279
  port: 3000,
244
280
  packageManager: options.packageManager,
245
281
  });
246
- files["apps/gateway/src/index.ts"] =
247
- `export { createApp } from "./app.js";
248
- `;
249
- const gatewayModule = moduleSpec("gateway", "./modules/index.js");
250
- files["apps/gateway/src/app.ts"] = renderAppFile({
251
- applicationName: `${nameSlug}-gateway`,
252
- modules: [gatewayModule],
253
- port: 3000,
254
- });
255
- files["apps/gateway/src/modules/gateway.module.ts"] = renderModuleFile({
256
- module: gatewayModule,
257
- });
258
- files["apps/gateway/src/modules/index.ts"] =
259
- `export { ${gatewayModule.className} } from "./gateway.module.js";\n`;
260
- files["apps/gateway/src/server.ts"] = renderServerFile();
282
+ prefixed("apps/gateway", appSource("gateway", 3000));
261
283
  // Generate each service
262
284
  const serviceDeps = [
263
285
  ...RUNTIME_APP_DEPENDENCIES,
264
- "@zudojs/config",
265
- "@zudojs/errors",
266
- "@zudojs/http",
286
+ ...APP_SOURCE_DEPENDENCIES,
267
287
  ...capabilityPackages(capabilities),
268
288
  ];
269
289
  for (const svc of services) {
@@ -277,13 +297,8 @@ MIT
277
297
  private: true,
278
298
  type: "module",
279
299
  zudojs: { features: capabilities },
280
- scripts: {
281
- dev: "tsx watch src/server.ts",
282
- start: "node dist/server.js",
283
- build: "tsc",
284
- typecheck: "tsc --noEmit",
285
- },
286
- dependencies: Object.fromEntries([...new Set(serviceDeps)].map((d) => [d, ZUDOJS_PACKAGES_VERSION])),
300
+ scripts: appScripts,
301
+ dependencies: zudojsDependencies(serviceDeps),
287
302
  devDependencies: appDevDeps,
288
303
  }, null, 2) + "\n";
289
304
  files[`apps/services/${svcName}/tsconfig.json`] = appTsconfig;
@@ -292,48 +307,7 @@ MIT
292
307
  port,
293
308
  packageManager: options.packageManager,
294
309
  });
295
- // Service structure (modular monolith per service)
296
- const svcDirs = [
297
- "configs",
298
- "constants",
299
- "controllers",
300
- "databases",
301
- "dtos",
302
- "enums",
303
- "errors",
304
- "events",
305
- "interfaces",
306
- "jobs",
307
- "loaders",
308
- "loggers",
309
- "middlewares",
310
- "models",
311
- "repositories",
312
- "routes",
313
- "services",
314
- "types",
315
- "utils",
316
- "validators",
317
- ];
318
- files[`apps/services/${svcName}/src/index.ts`] =
319
- `export { createApp } from "./app.js";
320
- `;
321
- const svcModule = moduleSpec(svcName, "./modules/index.js");
322
- files[`apps/services/${svcName}/src/app.ts`] = renderAppFile({
323
- applicationName: `${nameSlug}-${svcName}`,
324
- modules: [svcModule],
325
- port,
326
- });
327
- files[`apps/services/${svcName}/src/modules/${svcName}.module.ts`] =
328
- renderModuleFile({ module: svcModule });
329
- files[`apps/services/${svcName}/src/modules/index.ts`] =
330
- `export { ${svcModule.className} } from "./${svcName}.module.js";\n`;
331
- files[`apps/services/${svcName}/src/server.ts`] = renderServerFile("./app.js", {
332
- defaultPort: port,
333
- });
334
- for (const dir of svcDirs) {
335
- files[`apps/services/${svcName}/src/${dir}/index.ts`] = "";
336
- }
310
+ prefixed(`apps/services/${svcName}`, appSource(svcName, port));
337
311
  files[`apps/services/${svcName}/src/commands/index.ts`] = "";
338
312
  files[`apps/services/${svcName}/src/queries/index.ts`] = "";
339
313
  }
@@ -32,9 +32,10 @@
32
32
  * ```
33
33
  */
34
34
  import { renderDatabaseEnv } from "../../adapters/databases/databaseAdapter.resolver.js";
35
- import { ZUDOJS_PACKAGES_VERSION } from "../../constants/index.js";
35
+ import { zudojsDependencies } from "../../constants/index.js";
36
36
  import { normalizeName } from "../../utils/utils.name.js";
37
- import { RUNTIME_APP_DEPENDENCIES, capabilityPackages, moduleSpec, renderAppFile, renderModuleFile, renderServerFile, renderPnpmWorkspaceFile, resolveProjectCapabilities, } from "../shared/index.js";
37
+ import { RUNTIME_APP_DEPENDENCIES, capabilityPackages, moduleSpec, renderModuleFile, renderPnpmWorkspaceFile, resolveProjectCapabilities, } from "../shared/index.js";
38
+ import { APP_SOURCE_DEPENDENCIES, APP_TEST_DEPENDENCIES, applyDatabaseSetting, backendDevDependencies, backendTsconfig, emptyBarrels, renderBackendAppSource, runCommand, } from "../backendApp/index.js";
38
39
  export function generateModularMonolithFiles(options) {
39
40
  const nameSlug = options.projectName
40
41
  .replace(/[^a-z0-9-]+/gi, "-")
@@ -55,21 +56,13 @@ export function generateModularMonolithFiles(options) {
55
56
  const capabilities = resolveProjectCapabilities(options);
56
57
  const deps = [
57
58
  ...RUNTIME_APP_DEPENDENCIES,
58
- "@zudojs/config",
59
- "@zudojs/errors",
59
+ ...APP_SOURCE_DEPENDENCIES,
60
60
  "@zudojs/types",
61
61
  "@zudojs/validation",
62
62
  "@zudojs/cqrs",
63
63
  "@zudojs/messaging",
64
- "@zudojs/http",
65
64
  ...capabilityPackages(capabilities),
66
65
  ];
67
- const devDeps = {
68
- tsx: "^4.7.0",
69
- typescript: "^5.7.0",
70
- "@types/node": "^24.0.0",
71
- vitest: "^3.0.0",
72
- };
73
66
  const files = {};
74
67
  // package.json
75
68
  files["package.json"] =
@@ -91,34 +84,16 @@ export function generateModularMonolithFiles(options) {
91
84
  typecheck: "tsc --noEmit",
92
85
  test: "vitest run",
93
86
  },
94
- dependencies: Object.fromEntries([...new Set(deps)].map((d) => [d, ZUDOJS_PACKAGES_VERSION])),
95
- devDependencies: devDeps,
87
+ dependencies: zudojsDependencies(deps),
88
+ devDependencies: {
89
+ ...backendDevDependencies(),
90
+ ...zudojsDependencies(APP_TEST_DEPENDENCIES),
91
+ },
96
92
  }, null, 2) + "\n";
97
- files["tsconfig.json"] = `{
98
- "compilerOptions": {
99
- "target": "ES2024",
100
- "module": "Node16",
101
- "moduleResolution": "Node16",
102
- "outDir": "dist",
103
- "rootDir": "src",
104
- "strict": true,
105
- "skipLibCheck": true,
106
- "esModuleInterop": true,
107
- "resolveJsonModule": true,
108
- "lib": ["ES2024"],
109
- "types": ["node"]
110
- },
111
- "include": ["src/**/*"],
112
- "exclude": ["node_modules", "dist", "**/*.test.ts"]
113
- }
114
- `;
93
+ files["tsconfig.json"] = backendTsconfig();
115
94
  if (options.packageManager === "pnpm") {
116
95
  files["pnpm-workspace.yaml"] = renderPnpmWorkspaceFile();
117
96
  }
118
- files[".env.example"] = `NODE_ENV=development
119
- PORT=3000
120
- ${renderDatabaseEnv(options.database, nameSlug)}
121
- `;
122
97
  files[".gitignore"] = `node_modules/
123
98
  dist/
124
99
  .env
@@ -142,50 +117,33 @@ ${modules.map((m) => `- **${m}**`).join("\n")}`
142
117
  npx zudojs generate module <name>
143
118
  \`\`\``}
144
119
 
120
+ Each module owns \`src/modules/<name>/routes/index.ts\`, registered from
121
+ \`src/routes/index.ts\`. Add a resource to a module with:
122
+
123
+ \`\`\`bash
124
+ npx zudojs generate resource invoices --module <name>
125
+ \`\`\`
126
+
145
127
  ## Getting Started
146
128
 
147
129
  \`\`\`bash
148
- ${options.packageManager === "npm" ? "npm run dev" : options.packageManager === "yarn" ? "yarn dev" : options.packageManager === "bun" ? "bun run dev" : "pnpm run dev"}
130
+ cp .env.example .env
131
+ ${runCommand(options.packageManager, "dev")}
149
132
  \`\`\`
150
133
 
151
134
  ## License
152
135
 
153
136
  MIT
154
- `;
155
- // Shared source directories
156
- files["src/index.ts"] = `export { createApp } from "./app.js";
157
137
  `;
158
138
  const moduleSpecs = modules.map((m) => moduleSpec(m, `./modules/${m}/index.js`));
159
- files["src/app.ts"] = renderAppFile({
139
+ Object.assign(files, emptyBarrels(), applyDatabaseSetting(renderBackendAppSource({
160
140
  applicationName: nameSlug,
141
+ title: options.projectName,
142
+ defaultPort: 3000,
143
+ openapi: options.enableOpenAPI === true,
161
144
  modules: moduleSpecs,
162
- });
163
- files["src/server.ts"] = renderServerFile();
164
- const sharedDirs = [
165
- "configs",
166
- "constants",
167
- "controllers",
168
- "databases",
169
- "dtos",
170
- "enums",
171
- "errors",
172
- "events",
173
- "interfaces",
174
- "jobs",
175
- "loaders",
176
- "loggers",
177
- "middlewares",
178
- "models",
179
- "repositories",
180
- "routes",
181
- "services",
182
- "types",
183
- "utils",
184
- "validators",
185
- ];
186
- for (const dir of sharedDirs) {
187
- files[`src/${dir}/index.ts`] = "";
188
- }
145
+ routedModules: modules,
146
+ }), renderDatabaseEnv(options.database, nameSlug)));
189
147
  files["src/modules/index.ts"] =
190
148
  modules.map((m) => `export * from "./${m}/index.js";`).join("\n") + "\n";
191
149
  // Generate each module with CQRS structure
@@ -199,16 +157,6 @@ MIT
199
157
  files[`src/modules/${spec.name}/commands/index.ts`] = ``;
200
158
  files[`src/modules/${spec.name}/queries/index.ts`] = ``;
201
159
  }
202
- // The name must match vitest's default `include`
203
- // (`**/*.{test,spec}.?(c|m)[jt]s?(x)`); `tests/index.ts` did not.
204
- files["tests/app.test.ts"] = `import { describe, it, expect } from "vitest";
205
-
206
- describe("Application", () => {
207
- it("should bootstrap correctly", () => {
208
- expect(true).toBe(true);
209
- });
210
- });
211
- `;
212
160
  return files;
213
161
  }
214
162
  //# sourceMappingURL=modularMonolith.template.js.map
@@ -3,35 +3,20 @@
3
3
  *
4
4
  * Template file generators for monolith architecture projects.
5
5
  *
6
- * Generated structure:
6
+ * Generated structure (see `templates/backendApp` for the wired source):
7
7
  * ```
8
8
  * project/
9
9
  * ├── src/
10
- * │ ├── index.ts # exports only
11
- * │ ├── app.ts # application assembly
12
- * │ ├── server.ts # entry point
13
- * │ ├── configs/
14
- * │ ├── constants/
15
- * │ ├── controllers/
16
- * │ ├── databases/
17
- * │ ├── dtos/
18
- * │ ├── enums/
19
- * │ ├── errors/
20
- * │ ├── events/
21
- * │ ├── interfaces/
22
- * │ ├── jobs/
23
- * │ ├── loaders/
24
- * │ ├── loggers/
25
- * │ ├── middlewares/
26
- * │ ├── models/
27
- * │ ├── modules/
28
- * │ ├── repositories/
29
- * │ ├── routes/
30
- * │ ├── services/
31
- * │ ├── types/
32
- * │ ├── utils/
33
- * │ └── validators/
34
- * ├── tests/
10
+ * │ ├── index.ts # exports only
11
+ * │ ├── app.ts # runtime assembly (modules + integrations)
12
+ * │ ├── server.ts # config → router → registerRoutes → HTTP
13
+ * │ ├── container.ts # composition root
14
+ * │ ├── configs/ # typed configuration from the environment
15
+ * │ ├── controllers/ dtos/ repositories/ services/ routes/
16
+ * │ ├── integrations/ # lifecycle-managed clients (zudojs add)
17
+ * │ ├── modules/ # runtime modules
18
+ * │ └── utils/ # HTTP helpers
19
+ * ├── tests/examples.test.ts
35
20
  * ├── package.json
36
21
  * ├── tsconfig.json
37
22
  * └── README.md