zudojs-cli 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -9
- package/dist/src/adapters/frontend/angular.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/angular.adapter.js +14 -97
- package/dist/src/adapters/frontend/astro.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/astro.adapter.js +4 -64
- package/dist/src/adapters/frontend/fallback/fallback.helper.d.ts +41 -0
- package/dist/src/adapters/frontend/fallback/fallback.helper.js +57 -0
- package/dist/src/adapters/frontend/fallback/framework/angular/angular.fallback.d.ts +18 -0
- package/dist/src/adapters/frontend/fallback/framework/angular/angular.fallback.js +107 -0
- package/dist/src/adapters/frontend/fallback/framework/angular/angularWorkspace.fallback.d.ts +23 -0
- package/dist/src/adapters/frontend/fallback/framework/angular/angularWorkspace.fallback.js +125 -0
- package/dist/src/adapters/frontend/fallback/framework/angular/index.d.ts +8 -0
- package/dist/src/adapters/frontend/fallback/framework/angular/index.js +8 -0
- package/dist/src/adapters/frontend/fallback/framework/astro.fallback.d.ts +14 -0
- package/dist/src/adapters/frontend/fallback/framework/astro.fallback.js +76 -0
- package/dist/src/adapters/frontend/fallback/framework/index.d.ts +13 -0
- package/dist/src/adapters/frontend/fallback/framework/index.js +13 -0
- package/dist/src/adapters/frontend/fallback/framework/next.fallback.d.ts +13 -0
- package/dist/src/adapters/frontend/fallback/framework/next.fallback.js +105 -0
- package/dist/src/adapters/frontend/fallback/framework/nuxt.fallback.d.ts +14 -0
- package/dist/src/adapters/frontend/fallback/framework/nuxt.fallback.js +56 -0
- package/dist/src/adapters/frontend/fallback/framework/sveltekit.fallback.d.ts +15 -0
- package/dist/src/adapters/frontend/fallback/framework/sveltekit.fallback.js +94 -0
- package/dist/src/adapters/frontend/fallback/index.d.ts +12 -0
- package/dist/src/adapters/frontend/fallback/index.js +12 -0
- package/dist/src/adapters/frontend/fallback/vite/index.d.ts +11 -0
- package/dist/src/adapters/frontend/fallback/vite/index.js +11 -0
- package/dist/src/adapters/frontend/fallback/vite/react.fallback.d.ts +13 -0
- package/dist/src/adapters/frontend/fallback/vite/react.fallback.js +77 -0
- package/dist/src/adapters/frontend/fallback/vite/svelte.fallback.d.ts +14 -0
- package/dist/src/adapters/frontend/fallback/vite/svelte.fallback.js +95 -0
- package/dist/src/adapters/frontend/fallback/vite/vanilla.fallback.d.ts +13 -0
- package/dist/src/adapters/frontend/fallback/vite/vanilla.fallback.js +71 -0
- package/dist/src/adapters/frontend/fallback/vite/vue.fallback.d.ts +14 -0
- package/dist/src/adapters/frontend/fallback/vite/vue.fallback.js +78 -0
- package/dist/src/adapters/frontend/next.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/next.adapter.js +16 -95
- package/dist/src/adapters/frontend/nuxt.adapter.d.ts +1 -2
- package/dist/src/adapters/frontend/nuxt.adapter.js +32 -43
- package/dist/src/adapters/frontend/react-native.adapter.js +1 -1
- package/dist/src/adapters/frontend/react.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/react.adapter.js +7 -89
- package/dist/src/adapters/frontend/svelte.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/svelte.adapter.js +4 -86
- package/dist/src/adapters/frontend/sveltekit.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/sveltekit.adapter.js +4 -57
- package/dist/src/adapters/frontend/vanilla.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/vanilla.adapter.js +4 -47
- package/dist/src/adapters/frontend/vue.adapter.d.ts +0 -1
- package/dist/src/adapters/frontend/vue.adapter.js +4 -76
- package/dist/src/bin/bin.menu.d.ts +22 -0
- package/dist/src/bin/bin.menu.js +40 -0
- package/dist/src/bin/bin.runner.d.ts +38 -0
- package/dist/src/bin/bin.runner.js +51 -0
- package/dist/src/bin/index.d.ts +9 -0
- package/dist/src/bin/index.js +9 -0
- package/dist/src/bin/zudojs.js +15 -4
- package/dist/src/cliApplication/cliApplication.core.d.ts +4 -2
- package/dist/src/cliApplication/cliApplication.core.js +48 -36
- package/dist/src/cliApplication/cliApplication.logger.d.ts +5 -0
- package/dist/src/cliApplication/cliApplication.logger.js +5 -3
- package/dist/src/cliApplication/invocation/index.d.ts +12 -0
- package/dist/src/cliApplication/invocation/index.js +12 -0
- package/dist/src/cliApplication/invocation/invocation.hint.d.ts +30 -0
- package/dist/src/cliApplication/invocation/invocation.hint.js +74 -0
- package/dist/src/cliApplication/invocation/invocation.locate.d.ts +34 -0
- package/dist/src/cliApplication/invocation/invocation.locate.js +53 -0
- package/dist/src/cliApplication/invocation/invocation.name.d.ts +37 -0
- package/dist/src/cliApplication/invocation/invocation.name.js +69 -0
- package/dist/src/cliApplication/invocation/invocation.sanitize.d.ts +19 -0
- package/dist/src/cliApplication/invocation/invocation.sanitize.js +32 -0
- package/dist/src/cliParser/cliParser.core.js +3 -1
- package/dist/src/cliParser/cliParser.helper.d.ts +7 -0
- package/dist/src/cliParser/cliParser.helper.js +19 -2
- package/dist/src/cliParser/cliParser.longOption.js +2 -2
- package/dist/src/commands/add.command.d.ts +7 -3
- package/dist/src/commands/add.command.js +96 -57
- package/dist/src/commands/create.command.js +29 -42
- package/dist/src/commands/doctor.command.d.ts +2 -1
- package/dist/src/commands/doctor.command.js +52 -4
- package/dist/src/commands/generate.command.js +31 -16
- package/dist/src/commands/info.command.js +11 -1
- package/dist/src/constants/index.d.ts +21 -3
- package/dist/src/constants/index.js +40 -5
- package/dist/src/constants/zudojsVersions.generated.d.ts +9 -0
- package/dist/src/constants/zudojsVersions.generated.js +48 -0
- package/dist/src/constants/zudojsVersions.helper.d.ts +21 -0
- package/dist/src/constants/zudojsVersions.helper.js +29 -0
- package/dist/src/generators/frontend/frontendGenerator.core.js +9 -10
- package/dist/src/generators/frontend/frontendPipeline.d.ts +6 -1
- package/dist/src/generators/frontend/frontendPipeline.js +9 -1
- package/dist/src/generators/fullstack/fullstackComposer.core.js +7 -1
- package/dist/src/generators/index.d.ts +1 -2
- package/dist/src/generators/index.js +1 -2
- package/dist/src/generators/infrastructure/infrastructure.generator.js +13 -5
- package/dist/src/generators/integration/integrationGenerator.core.d.ts +2 -0
- package/dist/src/generators/integration/integrationGenerator.core.js +31 -2
- package/dist/src/generators/module/module.generator.js +36 -4
- package/dist/src/generators/resource/index.d.ts +8 -0
- package/dist/src/generators/resource/index.js +8 -0
- package/dist/src/generators/resource/resource.generator.d.ts +27 -0
- package/dist/src/generators/resource/resource.generator.js +87 -0
- package/dist/src/generators/resource/resource.layout.d.ts +26 -0
- package/dist/src/generators/resource/resource.layout.js +46 -0
- package/dist/src/generators/resource/resource.plan.d.ts +27 -0
- package/dist/src/generators/resource/resource.plan.js +46 -0
- package/dist/src/generators/resource/resource.run.d.ts +25 -0
- package/dist/src/generators/resource/resource.run.js +52 -0
- package/dist/src/prompts/cancel.prompt.d.ts +5 -1
- package/dist/src/prompts/cancel.prompt.js +4 -0
- package/dist/src/prompts/menu/index.d.ts +13 -0
- package/dist/src/prompts/menu/index.js +13 -0
- package/dist/src/prompts/menu/menu.adapter.d.ts +16 -0
- package/dist/src/prompts/menu/menu.adapter.js +56 -0
- package/dist/src/prompts/menu/menu.constant.d.ts +20 -0
- package/dist/src/prompts/menu/menu.constant.js +29 -0
- package/dist/src/prompts/menu/menu.flow.d.ts +18 -0
- package/dist/src/prompts/menu/menu.flow.js +82 -0
- package/dist/src/prompts/menu/menu.select.d.ts +26 -0
- package/dist/src/prompts/menu/menu.select.js +118 -0
- package/dist/src/prompts/menu/menu.type.d.ts +66 -0
- package/dist/src/prompts/menu/menu.type.js +8 -0
- package/dist/src/recipes/apply/index.d.ts +9 -0
- package/dist/src/recipes/apply/index.js +9 -0
- package/dist/src/recipes/apply/recipeApply.app.d.ts +20 -0
- package/dist/src/recipes/apply/recipeApply.app.js +79 -0
- package/dist/src/recipes/apply/recipeApply.context.d.ts +14 -0
- package/dist/src/recipes/apply/recipeApply.context.js +76 -0
- package/dist/src/recipes/apply/recipeApply.files.d.ts +39 -0
- package/dist/src/recipes/apply/recipeApply.files.js +84 -0
- package/dist/src/recipes/apply/recipeApply.project.d.ts +11 -0
- package/dist/src/recipes/apply/recipeApply.project.js +50 -0
- package/dist/src/recipes/apply/recipeApply.report.d.ts +20 -0
- package/dist/src/recipes/apply/recipeApply.report.js +51 -0
- package/dist/src/recipes/catalog/database/database.files.d.ts +15 -0
- package/dist/src/recipes/catalog/database/database.files.js +98 -0
- package/dist/src/recipes/catalog/database/database.recipe.d.ts +9 -0
- package/dist/src/recipes/catalog/database/database.recipe.js +50 -0
- package/dist/src/recipes/catalog/database/index.d.ts +6 -0
- package/dist/src/recipes/catalog/database/index.js +6 -0
- package/dist/src/recipes/catalog/email.recipe.d.ts +9 -0
- package/dist/src/recipes/catalog/email.recipe.js +122 -0
- package/dist/src/recipes/catalog/index.d.ts +11 -0
- package/dist/src/recipes/catalog/index.js +11 -0
- package/dist/src/recipes/catalog/openapi.recipe.d.ts +8 -0
- package/dist/src/recipes/catalog/openapi.recipe.js +25 -0
- package/dist/src/recipes/catalog/platform/cache.recipe.d.ts +7 -0
- package/dist/src/recipes/catalog/platform/cache.recipe.js +55 -0
- package/dist/src/recipes/catalog/platform/index.d.ts +9 -0
- package/dist/src/recipes/catalog/platform/index.js +9 -0
- package/dist/src/recipes/catalog/platform/messaging.recipe.d.ts +7 -0
- package/dist/src/recipes/catalog/platform/messaging.recipe.js +46 -0
- package/dist/src/recipes/catalog/platform/observability.recipe.d.ts +8 -0
- package/dist/src/recipes/catalog/platform/observability.recipe.js +49 -0
- package/dist/src/recipes/catalog/platform/queue.recipe.d.ts +7 -0
- package/dist/src/recipes/catalog/platform/queue.recipe.js +61 -0
- package/dist/src/recipes/catalog/platform/scheduler.recipe.d.ts +7 -0
- package/dist/src/recipes/catalog/platform/scheduler.recipe.js +56 -0
- package/dist/src/recipes/catalog/redis.recipe.d.ts +8 -0
- package/dist/src/recipes/catalog/redis.recipe.js +79 -0
- package/dist/src/recipes/catalog/storage.recipe.d.ts +7 -0
- package/dist/src/recipes/catalog/storage.recipe.js +49 -0
- package/dist/src/recipes/catalog/websockets.recipe.d.ts +10 -0
- package/dist/src/recipes/catalog/websockets.recipe.js +84 -0
- package/dist/src/recipes/docker/docker.compose.d.ts +19 -0
- package/dist/src/recipes/docker/docker.compose.js +90 -0
- package/dist/src/recipes/docker/docker.recipe.d.ts +10 -0
- package/dist/src/recipes/docker/docker.recipe.js +51 -0
- package/dist/src/recipes/docker/docker.refresh.d.ts +13 -0
- package/dist/src/recipes/docker/docker.refresh.js +37 -0
- package/dist/src/recipes/docker/index.d.ts +7 -0
- package/dist/src/recipes/docker/index.js +7 -0
- package/dist/src/recipes/index.d.ts +8 -0
- package/dist/src/recipes/index.js +8 -0
- package/dist/src/recipes/recipe.registry.d.ts +17 -0
- package/dist/src/recipes/recipe.registry.js +46 -0
- package/dist/src/recipes/recipe.type.d.ts +93 -0
- package/dist/src/recipes/recipe.type.js +12 -0
- package/dist/src/resolvers/dependency/dependencyVersions.constant.d.ts +100 -5
- package/dist/src/resolvers/dependency/dependencyVersions.constant.js +103 -34
- package/dist/src/resolvers/dependency/index.d.ts +1 -1
- package/dist/src/resolvers/dependency/index.js +1 -1
- package/dist/src/resolvers/project.resolver.d.ts +14 -1
- package/dist/src/resolvers/project.resolver.js +11 -3
- package/dist/src/scaffolders/scaffolder.helper.js +12 -1
- package/dist/src/templates/backendApp/backendApp.core.d.ts +45 -0
- package/dist/src/templates/backendApp/backendApp.core.js +66 -0
- package/dist/src/templates/backendApp/backendApp.modules.d.ts +26 -0
- package/dist/src/templates/backendApp/backendApp.modules.js +25 -0
- package/dist/src/templates/backendApp/backendApp.project.d.ts +26 -0
- package/dist/src/templates/backendApp/backendApp.project.js +87 -0
- package/dist/src/templates/backendApp/index.d.ts +8 -0
- package/dist/src/templates/backendApp/index.js +8 -0
- package/dist/src/templates/backendApp/parts/config.template.d.ts +28 -0
- package/dist/src/templates/backendApp/parts/config.template.js +118 -0
- package/dist/src/templates/backendApp/parts/httpUtils.template.d.ts +10 -0
- package/dist/src/templates/backendApp/parts/httpUtils.template.js +103 -0
- package/dist/src/templates/backendApp/parts/index.d.ts +9 -0
- package/dist/src/templates/backendApp/parts/index.js +9 -0
- package/dist/src/templates/backendApp/parts/integrations.template.d.ts +16 -0
- package/dist/src/templates/backendApp/parts/integrations.template.js +115 -0
- package/dist/src/templates/backendApp/parts/wiring.template.d.ts +26 -0
- package/dist/src/templates/backendApp/parts/wiring.template.js +111 -0
- package/dist/src/templates/microservice/microservice.template.d.ts +4 -1
- package/dist/src/templates/microservice/microservice.template.js +74 -90
- package/dist/src/templates/modular-monolith/modularMonolith.template.js +25 -77
- package/dist/src/templates/monolith/monolith.template.d.ts +11 -26
- package/dist/src/templates/monolith/monolith.template.js +49 -146
- package/dist/src/templates/resource/index.d.ts +9 -0
- package/dist/src/templates/resource/index.js +9 -0
- package/dist/src/templates/resource/layers/index.d.ts +9 -0
- package/dist/src/templates/resource/layers/index.js +9 -0
- package/dist/src/templates/resource/layers/resourceData.template.d.ts +9 -0
- package/dist/src/templates/resource/layers/resourceData.template.js +108 -0
- package/dist/src/templates/resource/layers/resourcePrisma.template.d.ts +15 -0
- package/dist/src/templates/resource/layers/resourcePrisma.template.js +89 -0
- package/dist/src/templates/resource/layers/resourceRoutes.template.d.ts +13 -0
- package/dist/src/templates/resource/layers/resourceRoutes.template.js +128 -0
- package/dist/src/templates/resource/layers/resourceService.template.d.ts +13 -0
- package/dist/src/templates/resource/layers/resourceService.template.js +95 -0
- package/dist/src/templates/resource/resource.files.d.ts +33 -0
- package/dist/src/templates/resource/resource.files.js +99 -0
- package/dist/src/templates/resource/resource.names.d.ts +38 -0
- package/dist/src/templates/resource/resource.names.js +60 -0
- package/dist/src/templates/resource/resource.type.d.ts +19 -0
- package/dist/src/templates/resource/resource.type.js +15 -0
- package/dist/src/templates/shared/appRuntime.template.js +28 -11
- package/dist/src/templates/shared/capability.template.d.ts +13 -4
- package/dist/src/templates/shared/capability.template.js +21 -5
- package/dist/src/templates/shared/dockerfile.template.d.ts +12 -4
- package/dist/src/templates/shared/dockerfile.template.js +68 -29
- package/dist/src/templates/shared/pnpm.template.d.ts +8 -2
- package/dist/src/templates/shared/pnpm.template.js +9 -1
- package/dist/src/templates/shared/server.template.d.ts +23 -22
- package/dist/src/templates/shared/server.template.js +79 -53
- package/dist/src/types/scaffold.type.d.ts +6 -0
- package/dist/src/types/scaffold.type.js +2 -1
- package/dist/src/utils/utils.name.js +6 -0
- package/dist/src/utils/utils.writeGuard.d.ts +5 -0
- package/dist/src/utils/utils.writeGuard.js +23 -0
- package/dist/src/wiring/index.d.ts +10 -0
- package/dist/src/wiring/index.js +10 -0
- package/dist/src/wiring/wiring.dependencies.d.ts +29 -0
- package/dist/src/wiring/wiring.dependencies.js +83 -0
- package/dist/src/wiring/wiring.edits.d.ts +51 -0
- package/dist/src/wiring/wiring.edits.js +90 -0
- package/dist/src/wiring/wiring.markers.d.ts +53 -0
- package/dist/src/wiring/wiring.markers.js +87 -0
- package/package.json +20 -15
|
@@ -21,9 +21,12 @@
|
|
|
21
21
|
* └── README.md
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
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,
|
|
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
|
|
@@ -39,7 +42,10 @@ export const RESERVED_MICROSERVICE_APP_NAMES = ["gateway"];
|
|
|
39
42
|
* (`identity`, `enrollment`, `assessment`, `notification`), which put four
|
|
40
43
|
* domains nobody asked for into every microservice project and left the
|
|
41
44
|
* author deleting them before they could start. Services are created when
|
|
42
|
-
* they are named — here, or
|
|
45
|
+
* they are named — here, or in another `create` run. `generate service` is
|
|
46
|
+
* refused in a microservice project, because a service is a whole workspace
|
|
47
|
+
* app (package.json, tsconfig, Dockerfile, port) that the schematic does not
|
|
48
|
+
* produce; `generate module --service <name>` adds to an existing app.
|
|
43
49
|
*/
|
|
44
50
|
export function resolveMicroserviceServices(requested) {
|
|
45
51
|
const normalized = requested
|
|
@@ -54,9 +60,9 @@ export function generateMicroserviceFiles(options) {
|
|
|
54
60
|
.toLowerCase();
|
|
55
61
|
const services = resolveMicroserviceServices(options.services);
|
|
56
62
|
// The workspace root records the capabilities for the project as a whole
|
|
57
|
-
//
|
|
58
|
-
// record them next to the dependencies that back
|
|
59
|
-
// `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.
|
|
60
66
|
const capabilities = resolveProjectCapabilities(options);
|
|
61
67
|
const files = {};
|
|
62
68
|
// Root package.json (workspace root)
|
|
@@ -82,6 +88,13 @@ export function generateMicroserviceFiles(options) {
|
|
|
82
88
|
: options.packageManager === "bun"
|
|
83
89
|
? "bun run --filter '*' typecheck"
|
|
84
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",
|
|
85
98
|
};
|
|
86
99
|
const workspaceGlobs = ["apps/gateway", "apps/services/*"];
|
|
87
100
|
files["package.json"] =
|
|
@@ -101,8 +114,8 @@ export function generateMicroserviceFiles(options) {
|
|
|
101
114
|
: { workspaces: workspaceGlobs }),
|
|
102
115
|
scripts: rootScripts,
|
|
103
116
|
devDependencies: {
|
|
104
|
-
tsx:
|
|
105
|
-
typescript:
|
|
117
|
+
tsx: DEPENDENCY_VERSION_RANGES.tsx,
|
|
118
|
+
typescript: TYPESCRIPT_VERSION_RANGES.backend,
|
|
106
119
|
},
|
|
107
120
|
}, null, 2) + "\n";
|
|
108
121
|
if (options.packageManager === "pnpm") {
|
|
@@ -158,10 +171,17 @@ A microservice architecture built with the Zudojs framework.
|
|
|
158
171
|
${services.length > 0
|
|
159
172
|
? services.map((s, i) => `- **${s}** - Port ${3001 + i}`).join("\n")
|
|
160
173
|
: `
|
|
161
|
-
No services yet.
|
|
174
|
+
No services yet. A service is a whole workspace app, so it is created with
|
|
175
|
+
\`create\` rather than by a schematic:
|
|
176
|
+
|
|
177
|
+
\`\`\`bash
|
|
178
|
+
npx zudojs create <project> --architecture microservice --services <name>
|
|
179
|
+
\`\`\`
|
|
180
|
+
|
|
181
|
+
To add domain logic to an app that already exists, generate a module into it:
|
|
162
182
|
|
|
163
183
|
\`\`\`bash
|
|
164
|
-
npx zudojs generate
|
|
184
|
+
npx zudojs generate module <name> --service <existing-service>
|
|
165
185
|
\`\`\``}
|
|
166
186
|
|
|
167
187
|
## Getting Started
|
|
@@ -202,15 +222,45 @@ MIT
|
|
|
202
222
|
}
|
|
203
223
|
`;
|
|
204
224
|
const appDevDeps = {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"@types/node": "^24.0.0",
|
|
225
|
+
...backendDevDependencies(),
|
|
226
|
+
...zudojsDependencies(APP_TEST_DEPENDENCIES),
|
|
208
227
|
};
|
|
209
|
-
|
|
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",
|
|
234
|
+
};
|
|
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.
|
|
210
260
|
const gatewayDeps = [
|
|
211
261
|
...RUNTIME_APP_DEPENDENCIES,
|
|
212
|
-
|
|
213
|
-
|
|
262
|
+
...APP_SOURCE_DEPENDENCIES,
|
|
263
|
+
...capabilityPackages(capabilities),
|
|
214
264
|
];
|
|
215
265
|
files["apps/gateway/package.json"] =
|
|
216
266
|
JSON.stringify({
|
|
@@ -218,13 +268,9 @@ MIT
|
|
|
218
268
|
version: "0.1.0",
|
|
219
269
|
private: true,
|
|
220
270
|
type: "module",
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
build: "tsc",
|
|
225
|
-
typecheck: "tsc --noEmit",
|
|
226
|
-
},
|
|
227
|
-
dependencies: Object.fromEntries([...new Set(gatewayDeps)].map((d) => [d, ZUDOJS_PACKAGES_VERSION])),
|
|
271
|
+
zudojs: { features: capabilities },
|
|
272
|
+
scripts: appScripts,
|
|
273
|
+
dependencies: zudojsDependencies(gatewayDeps),
|
|
228
274
|
devDependencies: appDevDeps,
|
|
229
275
|
}, null, 2) + "\n";
|
|
230
276
|
files["apps/gateway/tsconfig.json"] = appTsconfig;
|
|
@@ -233,27 +279,11 @@ MIT
|
|
|
233
279
|
port: 3000,
|
|
234
280
|
packageManager: options.packageManager,
|
|
235
281
|
});
|
|
236
|
-
|
|
237
|
-
`export { createApp } from "./app.js";
|
|
238
|
-
`;
|
|
239
|
-
const gatewayModule = moduleSpec("gateway", "./modules/index.js");
|
|
240
|
-
files["apps/gateway/src/app.ts"] = renderAppFile({
|
|
241
|
-
applicationName: `${nameSlug}-gateway`,
|
|
242
|
-
modules: [gatewayModule],
|
|
243
|
-
port: 3000,
|
|
244
|
-
});
|
|
245
|
-
files["apps/gateway/src/modules/gateway.module.ts"] = renderModuleFile({
|
|
246
|
-
module: gatewayModule,
|
|
247
|
-
});
|
|
248
|
-
files["apps/gateway/src/modules/index.ts"] =
|
|
249
|
-
`export { ${gatewayModule.className} } from "./gateway.module.js";\n`;
|
|
250
|
-
files["apps/gateway/src/server.ts"] = renderServerFile();
|
|
282
|
+
prefixed("apps/gateway", appSource("gateway", 3000));
|
|
251
283
|
// Generate each service
|
|
252
284
|
const serviceDeps = [
|
|
253
285
|
...RUNTIME_APP_DEPENDENCIES,
|
|
254
|
-
|
|
255
|
-
"@zudojs/errors",
|
|
256
|
-
"@zudojs/http",
|
|
286
|
+
...APP_SOURCE_DEPENDENCIES,
|
|
257
287
|
...capabilityPackages(capabilities),
|
|
258
288
|
];
|
|
259
289
|
for (const svc of services) {
|
|
@@ -267,13 +297,8 @@ MIT
|
|
|
267
297
|
private: true,
|
|
268
298
|
type: "module",
|
|
269
299
|
zudojs: { features: capabilities },
|
|
270
|
-
scripts:
|
|
271
|
-
|
|
272
|
-
start: "node dist/server.js",
|
|
273
|
-
build: "tsc",
|
|
274
|
-
typecheck: "tsc --noEmit",
|
|
275
|
-
},
|
|
276
|
-
dependencies: Object.fromEntries([...new Set(serviceDeps)].map((d) => [d, ZUDOJS_PACKAGES_VERSION])),
|
|
300
|
+
scripts: appScripts,
|
|
301
|
+
dependencies: zudojsDependencies(serviceDeps),
|
|
277
302
|
devDependencies: appDevDeps,
|
|
278
303
|
}, null, 2) + "\n";
|
|
279
304
|
files[`apps/services/${svcName}/tsconfig.json`] = appTsconfig;
|
|
@@ -282,48 +307,7 @@ MIT
|
|
|
282
307
|
port,
|
|
283
308
|
packageManager: options.packageManager,
|
|
284
309
|
});
|
|
285
|
-
|
|
286
|
-
const svcDirs = [
|
|
287
|
-
"configs",
|
|
288
|
-
"constants",
|
|
289
|
-
"controllers",
|
|
290
|
-
"databases",
|
|
291
|
-
"dtos",
|
|
292
|
-
"enums",
|
|
293
|
-
"errors",
|
|
294
|
-
"events",
|
|
295
|
-
"interfaces",
|
|
296
|
-
"jobs",
|
|
297
|
-
"loaders",
|
|
298
|
-
"loggers",
|
|
299
|
-
"middlewares",
|
|
300
|
-
"models",
|
|
301
|
-
"repositories",
|
|
302
|
-
"routes",
|
|
303
|
-
"services",
|
|
304
|
-
"types",
|
|
305
|
-
"utils",
|
|
306
|
-
"validators",
|
|
307
|
-
];
|
|
308
|
-
files[`apps/services/${svcName}/src/index.ts`] =
|
|
309
|
-
`export { createApp } from "./app.js";
|
|
310
|
-
`;
|
|
311
|
-
const svcModule = moduleSpec(svcName, "./modules/index.js");
|
|
312
|
-
files[`apps/services/${svcName}/src/app.ts`] = renderAppFile({
|
|
313
|
-
applicationName: `${nameSlug}-${svcName}`,
|
|
314
|
-
modules: [svcModule],
|
|
315
|
-
port,
|
|
316
|
-
});
|
|
317
|
-
files[`apps/services/${svcName}/src/modules/${svcName}.module.ts`] =
|
|
318
|
-
renderModuleFile({ module: svcModule });
|
|
319
|
-
files[`apps/services/${svcName}/src/modules/index.ts`] =
|
|
320
|
-
`export { ${svcModule.className} } from "./${svcName}.module.js";\n`;
|
|
321
|
-
files[`apps/services/${svcName}/src/server.ts`] = renderServerFile("./app.js", {
|
|
322
|
-
defaultPort: port,
|
|
323
|
-
});
|
|
324
|
-
for (const dir of svcDirs) {
|
|
325
|
-
files[`apps/services/${svcName}/src/${dir}/index.ts`] = "";
|
|
326
|
-
}
|
|
310
|
+
prefixed(`apps/services/${svcName}`, appSource(svcName, port));
|
|
327
311
|
files[`apps/services/${svcName}/src/commands/index.ts`] = "";
|
|
328
312
|
files[`apps/services/${svcName}/src/queries/index.ts`] = "";
|
|
329
313
|
}
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
import { renderDatabaseEnv } from "../../adapters/databases/databaseAdapter.resolver.js";
|
|
35
|
-
import {
|
|
35
|
+
import { zudojsDependencies } from "../../constants/index.js";
|
|
36
36
|
import { normalizeName } from "../../utils/utils.name.js";
|
|
37
|
-
import { RUNTIME_APP_DEPENDENCIES, capabilityPackages, moduleSpec,
|
|
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
|
-
|
|
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:
|
|
95
|
-
devDependencies:
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
11
|
-
* │ ├── app.ts
|
|
12
|
-
* │ ├── server.ts
|
|
13
|
-
* │ ├──
|
|
14
|
-
* │ ├──
|
|
15
|
-
* │ ├── controllers/
|
|
16
|
-
* │ ├──
|
|
17
|
-
* │ ├──
|
|
18
|
-
* │
|
|
19
|
-
*
|
|
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
|