nestjs-ddd-cli 2.2.1 → 3.2.2

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 (262) hide show
  1. package/README.md +247 -408
  2. package/ddd.schema.json +111 -0
  3. package/dist/commands/aggregate-validator.d.ts +9 -0
  4. package/dist/commands/aggregate-validator.js +953 -0
  5. package/dist/commands/aggregate-validator.js.map +1 -0
  6. package/dist/commands/ai-assist.d.ts +8 -0
  7. package/dist/commands/ai-assist.js +337 -0
  8. package/dist/commands/ai-assist.js.map +1 -0
  9. package/dist/commands/api-contracts.d.ts +9 -0
  10. package/dist/commands/api-contracts.js +1368 -0
  11. package/dist/commands/api-contracts.js.map +1 -0
  12. package/dist/commands/api-docs.d.ts +8 -0
  13. package/dist/commands/api-docs.js +408 -0
  14. package/dist/commands/api-docs.js.map +1 -0
  15. package/dist/commands/api-versioning.d.ts +11 -0
  16. package/dist/commands/api-versioning.js +643 -0
  17. package/dist/commands/api-versioning.js.map +1 -0
  18. package/dist/commands/audit-logging.d.ts +9 -0
  19. package/dist/commands/audit-logging.js +1129 -0
  20. package/dist/commands/audit-logging.js.map +1 -0
  21. package/dist/commands/batch-generate.d.ts +10 -0
  22. package/dist/commands/batch-generate.js +405 -0
  23. package/dist/commands/batch-generate.js.map +1 -0
  24. package/dist/commands/caching-strategies.d.ts +9 -0
  25. package/dist/commands/caching-strategies.js +874 -0
  26. package/dist/commands/caching-strategies.js.map +1 -0
  27. package/dist/commands/code-analyzer.d.ts +42 -0
  28. package/dist/commands/code-analyzer.js +474 -0
  29. package/dist/commands/code-analyzer.js.map +1 -0
  30. package/dist/commands/database-seeding.d.ts +6 -0
  31. package/dist/commands/database-seeding.js +621 -0
  32. package/dist/commands/database-seeding.js.map +1 -0
  33. package/dist/commands/db-optimization.d.ts +7 -0
  34. package/dist/commands/db-optimization.js +687 -0
  35. package/dist/commands/db-optimization.js.map +1 -0
  36. package/dist/commands/dependency-graph.d.ts +6 -0
  37. package/dist/commands/dependency-graph.js +329 -0
  38. package/dist/commands/dependency-graph.js.map +1 -0
  39. package/dist/commands/doctor-enhanced.d.ts +22 -0
  40. package/dist/commands/doctor-enhanced.js +543 -0
  41. package/dist/commands/doctor-enhanced.js.map +1 -0
  42. package/dist/commands/doctor.d.ts +4 -0
  43. package/dist/commands/doctor.js +151 -0
  44. package/dist/commands/doctor.js.map +1 -0
  45. package/dist/commands/env-manager.d.ts +6 -0
  46. package/dist/commands/env-manager.js +419 -0
  47. package/dist/commands/env-manager.js.map +1 -0
  48. package/dist/commands/event-sourcing-full.d.ts +10 -0
  49. package/dist/commands/event-sourcing-full.js +1107 -0
  50. package/dist/commands/event-sourcing-full.js.map +1 -0
  51. package/dist/commands/feature-flags.d.ts +9 -0
  52. package/dist/commands/feature-flags.js +824 -0
  53. package/dist/commands/feature-flags.js.map +1 -0
  54. package/dist/commands/filter-dsl.d.ts +10 -0
  55. package/dist/commands/filter-dsl.js +1407 -0
  56. package/dist/commands/filter-dsl.js.map +1 -0
  57. package/dist/commands/generate-all.js +525 -36
  58. package/dist/commands/generate-all.js.map +1 -1
  59. package/dist/commands/generate-deployment.d.ts +8 -0
  60. package/dist/commands/generate-deployment.js +746 -0
  61. package/dist/commands/generate-deployment.js.map +1 -0
  62. package/dist/commands/generate-domain-service.d.ts +14 -0
  63. package/dist/commands/generate-domain-service.js +796 -0
  64. package/dist/commands/generate-domain-service.js.map +1 -0
  65. package/dist/commands/generate-entity.js +87 -25
  66. package/dist/commands/generate-entity.js.map +1 -1
  67. package/dist/commands/generate-from-schema.d.ts +56 -0
  68. package/dist/commands/generate-from-schema.js +222 -0
  69. package/dist/commands/generate-from-schema.js.map +1 -0
  70. package/dist/commands/generate-module.js +37 -29
  71. package/dist/commands/generate-module.js.map +1 -1
  72. package/dist/commands/generate-orchestrator.d.ts +14 -0
  73. package/dist/commands/generate-orchestrator.js +887 -0
  74. package/dist/commands/generate-orchestrator.js.map +1 -0
  75. package/dist/commands/generate-repository.d.ts +14 -0
  76. package/dist/commands/generate-repository.js +1019 -0
  77. package/dist/commands/generate-repository.js.map +1 -0
  78. package/dist/commands/generate-shared.d.ts +4 -0
  79. package/dist/commands/generate-shared.js +388 -0
  80. package/dist/commands/generate-shared.js.map +1 -0
  81. package/dist/commands/generate-value-object.d.ts +32 -0
  82. package/dist/commands/generate-value-object.js +700 -0
  83. package/dist/commands/generate-value-object.js.map +1 -0
  84. package/dist/commands/graphql-subscriptions.d.ts +6 -0
  85. package/dist/commands/graphql-subscriptions.js +607 -0
  86. package/dist/commands/graphql-subscriptions.js.map +1 -0
  87. package/dist/commands/graphql-types.d.ts +5 -0
  88. package/dist/commands/graphql-types.js +423 -0
  89. package/dist/commands/graphql-types.js.map +1 -0
  90. package/dist/commands/health-probes-advanced.d.ts +6 -0
  91. package/dist/commands/health-probes-advanced.js +655 -0
  92. package/dist/commands/health-probes-advanced.js.map +1 -0
  93. package/dist/commands/i18n-setup.d.ts +10 -0
  94. package/dist/commands/i18n-setup.js +677 -0
  95. package/dist/commands/i18n-setup.js.map +1 -0
  96. package/dist/commands/init-config.d.ts +6 -0
  97. package/dist/commands/init-config.js +370 -0
  98. package/dist/commands/init-config.js.map +1 -0
  99. package/dist/commands/init-project.js +56 -6
  100. package/dist/commands/init-project.js.map +1 -1
  101. package/dist/commands/interactive-scaffold.d.ts +5 -0
  102. package/dist/commands/interactive-scaffold.js +271 -0
  103. package/dist/commands/interactive-scaffold.js.map +1 -0
  104. package/dist/commands/metrics-prometheus.d.ts +6 -0
  105. package/dist/commands/metrics-prometheus.js +681 -0
  106. package/dist/commands/metrics-prometheus.js.map +1 -0
  107. package/dist/commands/migration-engine.d.ts +6 -0
  108. package/dist/commands/migration-engine.js +446 -0
  109. package/dist/commands/migration-engine.js.map +1 -0
  110. package/dist/commands/migration.d.ts +12 -0
  111. package/dist/commands/migration.js +484 -0
  112. package/dist/commands/migration.js.map +1 -0
  113. package/dist/commands/monorepo.d.ts +8 -0
  114. package/dist/commands/monorepo.js +483 -0
  115. package/dist/commands/monorepo.js.map +1 -0
  116. package/dist/commands/multi-database.d.ts +5 -0
  117. package/dist/commands/multi-database.js +439 -0
  118. package/dist/commands/multi-database.js.map +1 -0
  119. package/dist/commands/observability-tracing.d.ts +10 -0
  120. package/dist/commands/observability-tracing.js +740 -0
  121. package/dist/commands/observability-tracing.js.map +1 -0
  122. package/dist/commands/openapi-export.d.ts +8 -0
  123. package/dist/commands/openapi-export.js +359 -0
  124. package/dist/commands/openapi-export.js.map +1 -0
  125. package/dist/commands/perf-analyzer.d.ts +8 -0
  126. package/dist/commands/perf-analyzer.js +423 -0
  127. package/dist/commands/perf-analyzer.js.map +1 -0
  128. package/dist/commands/rate-limiting.d.ts +10 -0
  129. package/dist/commands/rate-limiting.js +953 -0
  130. package/dist/commands/rate-limiting.js.map +1 -0
  131. package/dist/commands/recipe-plugin.d.ts +56 -0
  132. package/dist/commands/recipe-plugin.js +315 -0
  133. package/dist/commands/recipe-plugin.js.map +1 -0
  134. package/dist/commands/recipe.d.ts +6 -0
  135. package/dist/commands/recipe.js +3988 -0
  136. package/dist/commands/recipe.js.map +1 -0
  137. package/dist/commands/recipes/elasticsearch.recipe.d.ts +1 -0
  138. package/dist/commands/recipes/elasticsearch.recipe.js +761 -0
  139. package/dist/commands/recipes/elasticsearch.recipe.js.map +1 -0
  140. package/dist/commands/recipes/event-sourcing.recipe.d.ts +1 -0
  141. package/dist/commands/recipes/event-sourcing.recipe.js +889 -0
  142. package/dist/commands/recipes/event-sourcing.recipe.js.map +1 -0
  143. package/dist/commands/recipes/index.d.ts +8 -0
  144. package/dist/commands/recipes/index.js +25 -0
  145. package/dist/commands/recipes/index.js.map +1 -0
  146. package/dist/commands/recipes/joi-env.recipe.d.ts +1 -0
  147. package/dist/commands/recipes/joi-env.recipe.js +301 -0
  148. package/dist/commands/recipes/joi-env.recipe.js.map +1 -0
  149. package/dist/commands/recipes/message-queue.recipe.d.ts +1 -0
  150. package/dist/commands/recipes/message-queue.recipe.js +706 -0
  151. package/dist/commands/recipes/message-queue.recipe.js.map +1 -0
  152. package/dist/commands/recipes/middleware.recipe.d.ts +1 -0
  153. package/dist/commands/recipes/middleware.recipe.js +383 -0
  154. package/dist/commands/recipes/middleware.recipe.js.map +1 -0
  155. package/dist/commands/recipes/multi-tenancy.recipe.d.ts +1 -0
  156. package/dist/commands/recipes/multi-tenancy.recipe.js +520 -0
  157. package/dist/commands/recipes/multi-tenancy.recipe.js.map +1 -0
  158. package/dist/commands/recipes/oauth2.recipe.d.ts +1 -0
  159. package/dist/commands/recipes/oauth2.recipe.js +472 -0
  160. package/dist/commands/recipes/oauth2.recipe.js.map +1 -0
  161. package/dist/commands/recipes/websocket.recipe.d.ts +1 -0
  162. package/dist/commands/recipes/websocket.recipe.js +453 -0
  163. package/dist/commands/recipes/websocket.recipe.js.map +1 -0
  164. package/dist/commands/resilience-patterns.d.ts +13 -0
  165. package/dist/commands/resilience-patterns.js +1029 -0
  166. package/dist/commands/resilience-patterns.js.map +1 -0
  167. package/dist/commands/security-patterns.d.ts +11 -0
  168. package/dist/commands/security-patterns.js +2233 -0
  169. package/dist/commands/security-patterns.js.map +1 -0
  170. package/dist/commands/template-debug.d.ts +27 -0
  171. package/dist/commands/template-debug.js +388 -0
  172. package/dist/commands/template-debug.js.map +1 -0
  173. package/dist/commands/test-factory-full.d.ts +9 -0
  174. package/dist/commands/test-factory-full.js +1570 -0
  175. package/dist/commands/test-factory-full.js.map +1 -0
  176. package/dist/commands/test-scaffold.d.ts +7 -0
  177. package/dist/commands/test-scaffold.js +621 -0
  178. package/dist/commands/test-scaffold.js.map +1 -0
  179. package/dist/index.js +1092 -1
  180. package/dist/index.js.map +1 -1
  181. package/dist/templates/ai-context/CLAUDE.md.hbs +173 -0
  182. package/dist/templates/ai-context/conventions.md.hbs +161 -0
  183. package/dist/templates/command/create-command.hbs +6 -14
  184. package/dist/templates/command/delete-command.hbs +19 -0
  185. package/dist/templates/command/update-command.hbs +24 -0
  186. package/dist/templates/controller/controller.hbs +64 -17
  187. package/dist/templates/dto/create-dto.hbs +29 -5
  188. package/dist/templates/dto/filter-dto.hbs +52 -0
  189. package/dist/templates/dto/filter-query.dto.hbs +148 -0
  190. package/dist/templates/dto/paginated-response.dto.hbs +29 -0
  191. package/dist/templates/dto/pagination-query.dto.hbs +30 -0
  192. package/dist/templates/dto/response-dto.hbs +38 -0
  193. package/dist/templates/dto/update-dto.hbs +11 -0
  194. package/dist/templates/entity/entity.hbs +32 -1
  195. package/dist/templates/event/domain-event.hbs +33 -7
  196. package/dist/templates/event/event-handler.hbs +40 -0
  197. package/dist/templates/exception/base-exceptions.hbs +69 -0
  198. package/dist/templates/exception/entity-not-found.exception.hbs +7 -0
  199. package/dist/templates/mapper/mapper.hbs +49 -24
  200. package/dist/templates/module/module.hbs +34 -10
  201. package/dist/templates/orm-entity/orm-entity.hbs +63 -12
  202. package/dist/templates/prisma/prisma-mapper.hbs +71 -0
  203. package/dist/templates/prisma/prisma-repository.hbs +114 -0
  204. package/dist/templates/prisma/prisma-schema.hbs +20 -0
  205. package/dist/templates/prisma/prisma-service.hbs +51 -0
  206. package/dist/templates/query/get-all.query.hbs +50 -0
  207. package/dist/templates/query/get-by-id.query.hbs +31 -0
  208. package/dist/templates/repository/repository.hbs +56 -14
  209. package/dist/templates/resolver/graphql-input.hbs +54 -0
  210. package/dist/templates/resolver/graphql-type.hbs +58 -0
  211. package/dist/templates/resolver/pagination-args.hbs +33 -0
  212. package/dist/templates/resolver/resolver.hbs +62 -0
  213. package/dist/templates/shared/prisma-query-builder.util.hbs +189 -0
  214. package/dist/templates/shared/query-builder.util.hbs +218 -0
  215. package/dist/templates/test/controller.spec.hbs +124 -0
  216. package/dist/templates/test/repository.spec.hbs +158 -0
  217. package/dist/templates/test/usecase.spec.hbs +116 -0
  218. package/dist/templates/usecase/create-usecase.hbs +20 -8
  219. package/dist/templates/usecase/delete-usecase.hbs +17 -0
  220. package/dist/templates/usecase/update-usecase.hbs +31 -0
  221. package/dist/utils/config.utils.d.ts +45 -0
  222. package/dist/utils/config.utils.js +211 -0
  223. package/dist/utils/config.utils.js.map +1 -0
  224. package/dist/utils/dependency.utils.d.ts +2 -0
  225. package/dist/utils/dependency.utils.js +44 -3
  226. package/dist/utils/dependency.utils.js.map +1 -1
  227. package/dist/utils/error.utils.d.ts +145 -0
  228. package/dist/utils/error.utils.js +422 -0
  229. package/dist/utils/error.utils.js.map +1 -0
  230. package/dist/utils/field.utils.d.ts +54 -0
  231. package/dist/utils/field.utils.js +401 -0
  232. package/dist/utils/field.utils.js.map +1 -0
  233. package/dist/utils/file.utils.d.ts +33 -8
  234. package/dist/utils/file.utils.js +237 -5
  235. package/dist/utils/file.utils.js.map +1 -1
  236. package/dist/utils/idempotency.utils.d.ts +123 -0
  237. package/dist/utils/idempotency.utils.js +444 -0
  238. package/dist/utils/idempotency.utils.js.map +1 -0
  239. package/dist/utils/naming.utils.js +24 -5
  240. package/dist/utils/naming.utils.js.map +1 -1
  241. package/dist/utils/performance.utils.d.ts +37 -0
  242. package/dist/utils/performance.utils.js +158 -0
  243. package/dist/utils/performance.utils.js.map +1 -0
  244. package/dist/utils/relation.utils.d.ts +92 -0
  245. package/dist/utils/relation.utils.js +388 -0
  246. package/dist/utils/relation.utils.js.map +1 -0
  247. package/dist/utils/rollback.utils.d.ts +49 -0
  248. package/dist/utils/rollback.utils.js +306 -0
  249. package/dist/utils/rollback.utils.js.map +1 -0
  250. package/dist/utils/schema.utils.d.ts +123 -0
  251. package/dist/utils/schema.utils.js +419 -0
  252. package/dist/utils/schema.utils.js.map +1 -0
  253. package/dist/utils/security.utils.d.ts +57 -0
  254. package/dist/utils/security.utils.js +315 -0
  255. package/dist/utils/security.utils.js.map +1 -0
  256. package/dist/utils/template-engine.utils.d.ts +80 -0
  257. package/dist/utils/template-engine.utils.js +478 -0
  258. package/dist/utils/template-engine.utils.js.map +1 -0
  259. package/dist/utils/validation-registry.utils.d.ts +160 -0
  260. package/dist/utils/validation-registry.utils.js +526 -0
  261. package/dist/utils/validation-registry.utils.js.map +1 -0
  262. package/package.json +12 -8
package/dist/index.js CHANGED
@@ -16,7 +16,55 @@ const generate_all_1 = require("./commands/generate-all");
16
16
  const init_project_1 = require("./commands/init-project");
17
17
  const update_cli_1 = require("./commands/update-cli");
18
18
  const update_deps_1 = require("./commands/update-deps");
19
+ const recipe_1 = require("./commands/recipe");
20
+ const generate_shared_1 = require("./commands/generate-shared");
21
+ const doctor_1 = require("./commands/doctor");
22
+ const interactive_scaffold_1 = require("./commands/interactive-scaffold");
23
+ const generate_from_schema_1 = require("./commands/generate-from-schema");
24
+ const generate_deployment_1 = require("./commands/generate-deployment");
19
25
  const dependency_utils_1 = require("./utils/dependency.utils");
26
+ const init_config_1 = require("./commands/init-config");
27
+ const doctor_enhanced_1 = require("./commands/doctor-enhanced");
28
+ const openapi_export_1 = require("./commands/openapi-export");
29
+ const migration_1 = require("./commands/migration");
30
+ const graphql_types_1 = require("./commands/graphql-types");
31
+ const dependency_graph_1 = require("./commands/dependency-graph");
32
+ const recipe_plugin_1 = require("./commands/recipe-plugin");
33
+ const template_debug_1 = require("./commands/template-debug");
34
+ const performance_utils_1 = require("./utils/performance.utils");
35
+ const code_analyzer_1 = require("./commands/code-analyzer");
36
+ const batch_generate_1 = require("./commands/batch-generate");
37
+ const test_scaffold_1 = require("./commands/test-scaffold");
38
+ const multi_database_1 = require("./commands/multi-database");
39
+ const api_docs_1 = require("./commands/api-docs");
40
+ const env_manager_1 = require("./commands/env-manager");
41
+ const perf_analyzer_1 = require("./commands/perf-analyzer");
42
+ const monorepo_1 = require("./commands/monorepo");
43
+ const ai_assist_1 = require("./commands/ai-assist");
44
+ const migration_engine_1 = require("./commands/migration-engine");
45
+ const filter_dsl_1 = require("./commands/filter-dsl");
46
+ const event_sourcing_full_1 = require("./commands/event-sourcing-full");
47
+ const test_factory_full_1 = require("./commands/test-factory-full");
48
+ const generate_value_object_1 = require("./commands/generate-value-object");
49
+ const generate_repository_1 = require("./commands/generate-repository");
50
+ const generate_domain_service_1 = require("./commands/generate-domain-service");
51
+ const generate_orchestrator_1 = require("./commands/generate-orchestrator");
52
+ const api_versioning_1 = require("./commands/api-versioning");
53
+ const rate_limiting_1 = require("./commands/rate-limiting");
54
+ const audit_logging_1 = require("./commands/audit-logging");
55
+ const i18n_setup_1 = require("./commands/i18n-setup");
56
+ const aggregate_validator_1 = require("./commands/aggregate-validator");
57
+ const api_contracts_1 = require("./commands/api-contracts");
58
+ const resilience_patterns_1 = require("./commands/resilience-patterns");
59
+ const observability_tracing_1 = require("./commands/observability-tracing");
60
+ const feature_flags_1 = require("./commands/feature-flags");
61
+ const caching_strategies_1 = require("./commands/caching-strategies");
62
+ const security_patterns_1 = require("./commands/security-patterns");
63
+ const db_optimization_1 = require("./commands/db-optimization");
64
+ const database_seeding_1 = require("./commands/database-seeding");
65
+ const health_probes_advanced_1 = require("./commands/health-probes-advanced");
66
+ const metrics_prometheus_1 = require("./commands/metrics-prometheus");
67
+ const graphql_subscriptions_1 = require("./commands/graphql-subscriptions");
20
68
  const program = new commander_1.Command();
21
69
  program
22
70
  .name('ddd')
@@ -31,7 +79,7 @@ program
31
79
  console.log(chalk_1.default.yellow(`Run 'ddd update' to update to the latest version.`));
32
80
  }
33
81
  }
34
- catch (error) {
82
+ catch {
35
83
  // Silently ignore update check errors
36
84
  }
37
85
  })();
@@ -41,11 +89,13 @@ program
41
89
  .description('Generate boilerplate code (types: module, entity, usecase, service, event, query, all)')
42
90
  .option('-m, --module <module>', 'Module name')
43
91
  .option('-p, --path <path>', 'Base path for generation', process.cwd())
92
+ .option('-f, --fields <fields>', 'Entity fields (format: "name:type:modifier name2:type2")')
44
93
  .option('--skip-orm', 'Skip ORM entity generation')
45
94
  .option('--skip-mapper', 'Skip mapper generation')
46
95
  .option('--skip-repo', 'Skip repository generation')
47
96
  .option('--with-events', 'Include domain events')
48
97
  .option('--with-queries', 'Include query handlers')
98
+ .option('--with-graphql', 'Generate GraphQL resolvers and types')
49
99
  .option('--install-deps', 'Install required dependencies', false)
50
100
  .action(async (type, name, options) => {
51
101
  try {
@@ -89,6 +139,11 @@ program
89
139
  .description('Generate complete CRUD scaffolding for an entity')
90
140
  .option('-m, --module <module>', 'Module name (will be created if not exists)')
91
141
  .option('-p, --path <path>', 'Base path for generation', process.cwd())
142
+ .option('-f, --fields <fields>', 'Entity fields (format: "name:string email:string:unique age:number:optional")')
143
+ .option('-o, --orm <orm>', 'ORM to use (typeorm or prisma)', 'typeorm')
144
+ .option('--with-tests', 'Generate test files alongside the code', false)
145
+ .option('--with-graphql', 'Generate GraphQL resolvers and types', false)
146
+ .option('--dry-run', 'Preview files that would be generated without writing', false)
92
147
  .option('--install-deps', 'Install required dependencies', false)
93
148
  .action(async (entityName, options) => {
94
149
  try {
@@ -99,6 +154,52 @@ program
99
154
  process.exit(1);
100
155
  }
101
156
  });
157
+ // Interactive scaffold wizard
158
+ program
159
+ .command('wizard')
160
+ .alias('w')
161
+ .description('Interactive scaffold wizard - guided entity and module creation')
162
+ .option('-p, --path <path>', 'Base path for generation', process.cwd())
163
+ .action(async (options) => {
164
+ try {
165
+ await (0, interactive_scaffold_1.interactiveScaffold)(options);
166
+ }
167
+ catch (error) {
168
+ console.error(chalk_1.default.red('Error:'), error.message);
169
+ process.exit(1);
170
+ }
171
+ });
172
+ // Generate from schema file
173
+ program
174
+ .command('from-schema <schemaPath>')
175
+ .alias('fs')
176
+ .description('Generate entities from a JSON/YAML schema file')
177
+ .option('-p, --path <path>', 'Base path for generation', process.cwd())
178
+ .option('--with-tests', 'Generate test files', false)
179
+ .option('--install-deps', 'Install required dependencies', false)
180
+ .action(async (schemaPath, options) => {
181
+ try {
182
+ await (0, generate_from_schema_1.generateFromSchema)(schemaPath, options);
183
+ }
184
+ catch (error) {
185
+ console.error(chalk_1.default.red('Error:'), error.message);
186
+ process.exit(1);
187
+ }
188
+ });
189
+ // Create sample schema file
190
+ program
191
+ .command('schema-init [outputPath]')
192
+ .description('Create a sample schema file for reference')
193
+ .option('-p, --path <path>', 'Base path for the file', process.cwd())
194
+ .action(async (outputPath = 'ddd-schema.json', options) => {
195
+ try {
196
+ await (0, generate_from_schema_1.createSampleSchema)(outputPath, options);
197
+ }
198
+ catch (error) {
199
+ console.error(chalk_1.default.red('Error:'), error.message);
200
+ process.exit(1);
201
+ }
202
+ });
102
203
  // Initialize a new NestJS project with DDD structure
103
204
  program
104
205
  .command('init <projectName>')
@@ -145,5 +246,995 @@ program
145
246
  process.exit(1);
146
247
  }
147
248
  });
249
+ // Apply a recipe (common patterns)
250
+ program
251
+ .command('recipe [recipeName]')
252
+ .description('Apply a common pattern recipe (service-foundation, auth-jwt, pagination, joi-env, soft-delete, audit-log, caching)')
253
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
254
+ .option('--install-deps', 'Install required dependencies', false)
255
+ .action(async (recipeName, options) => {
256
+ try {
257
+ if (!recipeName) {
258
+ (0, recipe_1.listRecipes)();
259
+ }
260
+ else {
261
+ await (0, recipe_1.applyRecipe)(recipeName, options);
262
+ }
263
+ }
264
+ catch (error) {
265
+ console.error(chalk_1.default.red('Error:'), error.message);
266
+ process.exit(1);
267
+ }
268
+ });
269
+ // Generate shared module
270
+ program
271
+ .command('shared')
272
+ .description('Generate shared module with base classes, interceptors, filters, and utilities')
273
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
274
+ .action(async (options) => {
275
+ try {
276
+ await (0, generate_shared_1.generateShared)(options);
277
+ }
278
+ catch (error) {
279
+ console.error(chalk_1.default.red('Error:'), error.message);
280
+ process.exit(1);
281
+ }
282
+ });
283
+ // Generate deployment configurations
284
+ program
285
+ .command('deploy')
286
+ .description('Generate deployment configurations (Docker, CI/CD, Kubernetes)')
287
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
288
+ .option('--no-docker', 'Skip Dockerfile generation')
289
+ .option('--no-compose', 'Skip docker-compose.yml generation')
290
+ .option('--ci <type>', 'CI/CD pipeline type (github, gitlab, none)', 'github')
291
+ .option('--kubernetes', 'Generate Kubernetes manifests', false)
292
+ .action(async (options) => {
293
+ try {
294
+ await (0, generate_deployment_1.generateDeployment)(options);
295
+ }
296
+ catch (error) {
297
+ console.error(chalk_1.default.red('Error:'), error.message);
298
+ process.exit(1);
299
+ }
300
+ });
301
+ // Health check
302
+ program
303
+ .command('doctor')
304
+ .description('Check project health and validate DDD structure')
305
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
306
+ .option('--enhanced', 'Run enhanced doctor with DDD pattern checks', false)
307
+ .option('--fix', 'Auto-fix issues where possible', false)
308
+ .option('-v, --verbose', 'Show detailed output', false)
309
+ .action(async (options) => {
310
+ try {
311
+ if (options.enhanced) {
312
+ await (0, doctor_enhanced_1.runEnhancedDoctor)(options.path || process.cwd(), {
313
+ fix: options.fix,
314
+ verbose: options.verbose,
315
+ });
316
+ }
317
+ else {
318
+ await (0, doctor_1.runDoctor)(options);
319
+ }
320
+ }
321
+ catch (error) {
322
+ console.error(chalk_1.default.red('Error:'), error.message);
323
+ process.exit(1);
324
+ }
325
+ });
326
+ // Interactive config wizard
327
+ program
328
+ .command('config [action]')
329
+ .description('Initialize or manage .dddrc.json configuration')
330
+ .option('-p, --preset <preset>', 'Use a preset (minimal, standard, enterprise, prisma, graphql)')
331
+ .option('-f, --force', 'Overwrite existing config', false)
332
+ .action(async (action, options) => {
333
+ try {
334
+ if (action === 'list' || action === 'presets') {
335
+ (0, init_config_1.listPresets)();
336
+ }
337
+ else {
338
+ await (0, init_config_1.initConfig)({ preset: options.preset, force: options.force });
339
+ }
340
+ }
341
+ catch (error) {
342
+ console.error(chalk_1.default.red('Error:'), error.message);
343
+ process.exit(1);
344
+ }
345
+ });
346
+ // OpenAPI export
347
+ program
348
+ .command('openapi')
349
+ .description('Export OpenAPI specification and Postman collection')
350
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
351
+ .option('-o, --output <file>', 'Output file name', 'openapi.json')
352
+ .option('-f, --format <format>', 'Output format (json, yaml)', 'json')
353
+ .option('--postman', 'Also generate Postman collection', false)
354
+ .option('--title <title>', 'API title')
355
+ .option('--version <version>', 'API version', '1.0.0')
356
+ .action(async (options) => {
357
+ try {
358
+ await (0, openapi_export_1.exportOpenApi)(options.path || process.cwd(), options);
359
+ }
360
+ catch (error) {
361
+ console.error(chalk_1.default.red('Error:'), error.message);
362
+ process.exit(1);
363
+ }
364
+ });
365
+ // Migration generator
366
+ program
367
+ .command('migration <action> [name]')
368
+ .description('Generate database migrations (actions: create, generate)')
369
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
370
+ .option('-m, --module <module>', 'Module name (for generate action)')
371
+ .option('-o, --orm <orm>', 'ORM to use (typeorm, prisma)', 'typeorm')
372
+ .action(async (action, name, options) => {
373
+ try {
374
+ const basePath = options.path || process.cwd();
375
+ if (action === 'create') {
376
+ if (!name) {
377
+ console.error(chalk_1.default.red('Migration name is required'));
378
+ process.exit(1);
379
+ }
380
+ await (0, migration_1.createMigration)(basePath, { name, orm: options.orm, path: options.migrationPath });
381
+ }
382
+ else if (action === 'generate') {
383
+ if (!options.module) {
384
+ console.error(chalk_1.default.red('Module name is required (--module)'));
385
+ process.exit(1);
386
+ }
387
+ await (0, migration_1.generateMigrationFromEntity)(basePath, { module: options.module, orm: options.orm });
388
+ }
389
+ else {
390
+ console.error(chalk_1.default.red(`Unknown action: ${action}`));
391
+ console.log(chalk_1.default.yellow('Available actions: create, generate'));
392
+ }
393
+ }
394
+ catch (error) {
395
+ console.error(chalk_1.default.red('Error:'), error.message);
396
+ process.exit(1);
397
+ }
398
+ });
399
+ // GraphQL types generator
400
+ program
401
+ .command('graphql-types')
402
+ .description('Generate GraphQL input/output types from entities')
403
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
404
+ .option('-m, --module <module>', 'Specific module to generate types for')
405
+ .action(async (options) => {
406
+ try {
407
+ await (0, graphql_types_1.generateGraphQLTypes)(options.path || process.cwd(), { module: options.module });
408
+ }
409
+ catch (error) {
410
+ console.error(chalk_1.default.red('Error:'), error.message);
411
+ process.exit(1);
412
+ }
413
+ });
414
+ // Dependency graph analyzer
415
+ program
416
+ .command('deps')
417
+ .description('Analyze module dependencies and detect circular references')
418
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
419
+ .option('-f, --format <format>', 'Output format (text, json, mermaid, dot)', 'text')
420
+ .option('-o, --output <file>', 'Output file for graph export')
421
+ .option('--circular', 'Show circular dependencies only', false)
422
+ .action(async (options) => {
423
+ try {
424
+ await (0, dependency_graph_1.analyzeDependencies)(options.path || process.cwd(), {
425
+ format: options.format,
426
+ output: options.output,
427
+ showCircular: options.circular,
428
+ });
429
+ }
430
+ catch (error) {
431
+ console.error(chalk_1.default.red('Error:'), error.message);
432
+ process.exit(1);
433
+ }
434
+ });
435
+ // Plugin management
436
+ program
437
+ .command('plugin <action> [name]')
438
+ .description('Manage recipe plugins (actions: list, install, uninstall, run, create)')
439
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
440
+ .action(async (action, name, options) => {
441
+ try {
442
+ const basePath = options.path || process.cwd();
443
+ switch (action) {
444
+ case 'list':
445
+ await (0, recipe_plugin_1.listPlugins)(basePath);
446
+ break;
447
+ case 'install':
448
+ if (!name) {
449
+ console.error(chalk_1.default.red('Plugin source is required'));
450
+ process.exit(1);
451
+ }
452
+ await (0, recipe_plugin_1.installPluginCommand)(basePath, name);
453
+ break;
454
+ case 'uninstall':
455
+ if (!name) {
456
+ console.error(chalk_1.default.red('Plugin name is required'));
457
+ process.exit(1);
458
+ }
459
+ await (0, recipe_plugin_1.uninstallPluginCommand)(basePath, name);
460
+ break;
461
+ case 'run':
462
+ if (!name) {
463
+ console.error(chalk_1.default.red('Plugin name is required'));
464
+ process.exit(1);
465
+ }
466
+ await (0, recipe_plugin_1.runPluginCommand)(basePath, name);
467
+ break;
468
+ case 'create':
469
+ if (!name) {
470
+ console.error(chalk_1.default.red('Plugin name is required'));
471
+ process.exit(1);
472
+ }
473
+ await (0, recipe_plugin_1.scaffoldPlugin)(basePath, name);
474
+ break;
475
+ default:
476
+ console.error(chalk_1.default.red(`Unknown action: ${action}`));
477
+ console.log(chalk_1.default.yellow('Available actions: list, install, uninstall, run, create'));
478
+ }
479
+ }
480
+ catch (error) {
481
+ console.error(chalk_1.default.red('Error:'), error.message);
482
+ process.exit(1);
483
+ }
484
+ });
485
+ // Template debugger
486
+ program
487
+ .command('template [action]')
488
+ .description('Debug and validate Handlebars templates')
489
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
490
+ .option('-t, --template <file>', 'Template file to validate/preview')
491
+ .option('-d, --data <file>', 'JSON data file for preview')
492
+ .option('-o, --output <file>', 'Output file for preview result')
493
+ .option('--helpers', 'List available template helpers', false)
494
+ .action(async (action, options) => {
495
+ try {
496
+ await (0, template_debug_1.debugTemplate)(options.path || process.cwd(), {
497
+ template: options.template,
498
+ data: options.data,
499
+ output: options.output,
500
+ validate: action === 'validate',
501
+ listHelpers: options.helpers || action === 'helpers',
502
+ });
503
+ }
504
+ catch (error) {
505
+ console.error(chalk_1.default.red('Error:'), error.message);
506
+ process.exit(1);
507
+ }
508
+ });
509
+ // Code analyzer
510
+ program
511
+ .command('analyze')
512
+ .description('Run static code analysis for DDD violations')
513
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
514
+ .option('-r, --rules <rules>', 'Rules to check (comma-separated)', 'all')
515
+ .option('-o, --output <file>', 'Output file for report')
516
+ .option('-f, --format <format>', 'Output format (text, json, html)', 'text')
517
+ .action(async (options) => {
518
+ try {
519
+ await (0, code_analyzer_1.analyzeCode)(options.path || process.cwd(), {
520
+ rules: options.rules === 'all' ? undefined : options.rules.split(','),
521
+ output: options.output,
522
+ format: options.format,
523
+ });
524
+ }
525
+ catch (error) {
526
+ console.error(chalk_1.default.red('Error:'), error.message);
527
+ process.exit(1);
528
+ }
529
+ });
530
+ // Batch generation
531
+ program
532
+ .command('batch <scriptPath>')
533
+ .description('Generate multiple entities from a YAML/JSON script')
534
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
535
+ .option('--dry-run', 'Preview without generating files', false)
536
+ .action(async (scriptPath, options) => {
537
+ try {
538
+ await (0, batch_generate_1.batchGenerate)(scriptPath, {
539
+ path: options.path || process.cwd(),
540
+ dryRun: options.dryRun,
541
+ });
542
+ }
543
+ catch (error) {
544
+ console.error(chalk_1.default.red('Error:'), error.message);
545
+ process.exit(1);
546
+ }
547
+ });
548
+ // Batch script sample
549
+ program
550
+ .command('batch-init [outputPath]')
551
+ .description('Create a sample batch generation script')
552
+ .option('-p, --path <path>', 'Base path for the file', process.cwd())
553
+ .action(async (outputPath = 'ddd-batch.yaml', options) => {
554
+ try {
555
+ await (0, batch_generate_1.createBatchSchema)(outputPath, { path: options.path });
556
+ }
557
+ catch (error) {
558
+ console.error(chalk_1.default.red('Error:'), error.message);
559
+ process.exit(1);
560
+ }
561
+ });
562
+ // Test scaffold generator
563
+ program
564
+ .command('test-scaffold <entityName>')
565
+ .description('Generate test scaffolding with factories and fixtures')
566
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
567
+ .option('-m, --module <module>', 'Module name')
568
+ .option('-t, --type <type>', 'Test type (unit, integration, e2e, all)', 'all')
569
+ .action(async (entityName, options) => {
570
+ try {
571
+ await (0, test_scaffold_1.generateTestScaffold)(entityName, {
572
+ path: options.path || process.cwd(),
573
+ module: options.module,
574
+ type: options.type,
575
+ });
576
+ }
577
+ catch (error) {
578
+ console.error(chalk_1.default.red('Error:'), error.message);
579
+ process.exit(1);
580
+ }
581
+ });
582
+ // Multi-database setup
583
+ program
584
+ .command('multi-db')
585
+ .description('Set up multi-database support with connection manager')
586
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
587
+ .option('-d, --databases <databases>', 'Database names (comma-separated)', 'primary,replica')
588
+ .action(async (options) => {
589
+ try {
590
+ await (0, multi_database_1.setupMultiDatabase)(options.path || process.cwd(), {
591
+ databases: options.databases.split(','),
592
+ });
593
+ }
594
+ catch (error) {
595
+ console.error(chalk_1.default.red('Error:'), error.message);
596
+ process.exit(1);
597
+ }
598
+ });
599
+ // API documentation generator
600
+ program
601
+ .command('api-docs')
602
+ .description('Generate API documentation from source code')
603
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
604
+ .option('-o, --output <file>', 'Output directory', 'docs/api')
605
+ .option('-f, --format <format>', 'Output format (markdown, html, json)', 'markdown')
606
+ .option('--examples', 'Include example requests', false)
607
+ .option('--group-by-module', 'Group endpoints by module', true)
608
+ .action(async (options) => {
609
+ try {
610
+ await (0, api_docs_1.generateApiDocs)(options.path || process.cwd(), {
611
+ output: options.output,
612
+ format: options.format,
613
+ includeExamples: options.examples,
614
+ groupByModule: options.groupByModule,
615
+ });
616
+ }
617
+ catch (error) {
618
+ console.error(chalk_1.default.red('Error:'), error.message);
619
+ process.exit(1);
620
+ }
621
+ });
622
+ // Environment manager
623
+ program
624
+ .command('env <action>')
625
+ .description('Manage environment configuration (actions: init, validate)')
626
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
627
+ .action(async (action, options) => {
628
+ try {
629
+ const basePath = options.path || process.cwd();
630
+ if (action === 'init') {
631
+ await (0, env_manager_1.initEnvManager)(basePath);
632
+ }
633
+ else if (action === 'validate') {
634
+ await (0, env_manager_1.validateEnvCommand)(basePath);
635
+ }
636
+ else {
637
+ console.error(chalk_1.default.red(`Unknown action: ${action}`));
638
+ console.log(chalk_1.default.yellow('Available actions: init, validate'));
639
+ }
640
+ }
641
+ catch (error) {
642
+ console.error(chalk_1.default.red('Error:'), error.message);
643
+ process.exit(1);
644
+ }
645
+ });
646
+ // Performance analyzer
647
+ program
648
+ .command('perf')
649
+ .description('Analyze code for performance issues (N+1, memory leaks, etc.)')
650
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
651
+ .option('-o, --output <file>', 'Output file for report')
652
+ .action(async (options) => {
653
+ try {
654
+ await (0, perf_analyzer_1.analyzePerformance)(options.path || process.cwd(), {
655
+ output: options.output,
656
+ });
657
+ }
658
+ catch (error) {
659
+ console.error(chalk_1.default.red('Error:'), error.message);
660
+ process.exit(1);
661
+ }
662
+ });
663
+ // Monorepo initialization
664
+ program
665
+ .command('monorepo <action> [name]')
666
+ .description('Initialize or manage a monorepo workspace')
667
+ .option('-p, --path <path>', 'Path for the project')
668
+ .option('-m, --package-manager <pm>', 'Package manager (npm, yarn, pnpm)', 'npm')
669
+ .option('-t, --type <type>', 'Workspace type for add action (app, lib)', 'lib')
670
+ .action(async (action, name, options) => {
671
+ try {
672
+ if (action === 'init') {
673
+ if (!name) {
674
+ console.error(chalk_1.default.red('Project name is required'));
675
+ process.exit(1);
676
+ }
677
+ await (0, monorepo_1.initMonorepo)(name, {
678
+ path: options.path,
679
+ packageManager: options.packageManager,
680
+ });
681
+ }
682
+ else if (action === 'add') {
683
+ if (!name) {
684
+ console.error(chalk_1.default.red('Workspace name is required'));
685
+ process.exit(1);
686
+ }
687
+ await (0, monorepo_1.addWorkspace)(options.path || process.cwd(), options.type, name);
688
+ }
689
+ else {
690
+ console.error(chalk_1.default.red(`Unknown action: ${action}`));
691
+ console.log(chalk_1.default.yellow('Available actions: init, add'));
692
+ }
693
+ }
694
+ catch (error) {
695
+ console.error(chalk_1.default.red('Error:'), error.message);
696
+ process.exit(1);
697
+ }
698
+ });
699
+ // AI-assisted code generation
700
+ program
701
+ .command('ai <action>')
702
+ .description('AI-assisted code generation (actions: usecase, service, test, refactor, explain, config)')
703
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
704
+ .option('-k, --api-key <key>', 'API key for AI provider')
705
+ .option('-m, --model <model>', 'Model to use')
706
+ .option('--provider <provider>', 'AI provider (anthropic, openai)', 'anthropic')
707
+ .action(async (action, options) => {
708
+ try {
709
+ if (action === 'config') {
710
+ await (0, ai_assist_1.configureAiAssist)(options.path || process.cwd());
711
+ }
712
+ else {
713
+ await (0, ai_assist_1.aiAssist)(action, {
714
+ path: options.path,
715
+ apiKey: options.apiKey,
716
+ model: options.model,
717
+ provider: options.provider,
718
+ });
719
+ }
720
+ }
721
+ catch (error) {
722
+ console.error(chalk_1.default.red('Error:'), error.message);
723
+ process.exit(1);
724
+ }
725
+ });
726
+ // Diff-based migration
727
+ program
728
+ .command('migration-diff')
729
+ .description('Generate migration from schema differences')
730
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
731
+ .option('-o, --orm <orm>', 'ORM to use (typeorm, prisma)', 'typeorm')
732
+ .option('--dry-run', 'Preview without generating files', false)
733
+ .action(async (options) => {
734
+ try {
735
+ await (0, migration_engine_1.diffMigration)(options.path || process.cwd(), {
736
+ orm: options.orm,
737
+ dryRun: options.dryRun,
738
+ });
739
+ }
740
+ catch (error) {
741
+ console.error(chalk_1.default.red('Error:'), error.message);
742
+ process.exit(1);
743
+ }
744
+ });
745
+ // Filter DSL generator
746
+ program
747
+ .command('filter-dsl')
748
+ .description('Generate type-safe filter DSL with specification pattern')
749
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
750
+ .option('-m, --module <module>', 'Module name')
751
+ .option('-e, --entity <entity>', 'Entity name')
752
+ .action(async (options) => {
753
+ try {
754
+ await (0, filter_dsl_1.generateFilterDSL)(options.path || process.cwd(), {
755
+ module: options.module,
756
+ entity: options.entity,
757
+ });
758
+ }
759
+ catch (error) {
760
+ console.error(chalk_1.default.red('Error:'), error.message);
761
+ process.exit(1);
762
+ }
763
+ });
764
+ // Event sourcing framework
765
+ program
766
+ .command('event-sourcing')
767
+ .description('Set up event sourcing infrastructure with aggregates and projections')
768
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
769
+ .option('--store <store>', 'Event store type (memory, postgres, mongodb)', 'postgres')
770
+ .option('--snapshot-threshold <threshold>', 'Snapshot threshold', '100')
771
+ .action(async (options) => {
772
+ try {
773
+ await (0, event_sourcing_full_1.setupEventSourcingFramework)(options.path || process.cwd(), {
774
+ eventStore: options.store,
775
+ snapshotThreshold: parseInt(options.snapshotThreshold, 10),
776
+ });
777
+ }
778
+ catch (error) {
779
+ console.error(chalk_1.default.red('Error:'), error.message);
780
+ process.exit(1);
781
+ }
782
+ });
783
+ // Test infrastructure
784
+ program
785
+ .command('test-infra')
786
+ .description('Generate comprehensive test infrastructure with factories and fixtures')
787
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
788
+ .option('-o, --orm <orm>', 'ORM type (typeorm, prisma)', 'typeorm')
789
+ .action(async (options) => {
790
+ try {
791
+ await (0, test_factory_full_1.setupTestInfrastructure)(options.path || process.cwd(), {
792
+ orm: options.orm,
793
+ });
794
+ }
795
+ catch (error) {
796
+ console.error(chalk_1.default.red('Error:'), error.message);
797
+ process.exit(1);
798
+ }
799
+ });
800
+ // Value object generator
801
+ program
802
+ .command('value-object <name>')
803
+ .description('Generate a value object with validation')
804
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
805
+ .option('-m, --module <module>', 'Module name')
806
+ .option('-t, --type <type>', 'Value object type (simple, composite, primitive)', 'simple')
807
+ .action(async (name, options) => {
808
+ try {
809
+ await (0, generate_value_object_1.generateValueObject)(name, options.path || process.cwd(), {
810
+ module: options.module,
811
+ type: options.type,
812
+ });
813
+ }
814
+ catch (error) {
815
+ console.error(chalk_1.default.red('Error:'), error.message);
816
+ process.exit(1);
817
+ }
818
+ });
819
+ // Value objects infrastructure
820
+ program
821
+ .command('value-objects-infra')
822
+ .description('Set up value objects infrastructure with base classes')
823
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
824
+ .action(async (options) => {
825
+ try {
826
+ await (0, generate_value_object_1.setupValueObjects)(options.path || process.cwd());
827
+ }
828
+ catch (error) {
829
+ console.error(chalk_1.default.red('Error:'), error.message);
830
+ process.exit(1);
831
+ }
832
+ });
833
+ // Repository generator
834
+ program
835
+ .command('repository <entityName>')
836
+ .description('Generate repository with specification pattern')
837
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
838
+ .option('-m, --module <module>', 'Module name')
839
+ .option('-o, --orm <orm>', 'ORM type (typeorm, prisma)', 'typeorm')
840
+ .action(async (entityName, options) => {
841
+ try {
842
+ await (0, generate_repository_1.generateRepository)(entityName, options.path || process.cwd(), {
843
+ module: options.module,
844
+ orm: options.orm,
845
+ });
846
+ }
847
+ catch (error) {
848
+ console.error(chalk_1.default.red('Error:'), error.message);
849
+ process.exit(1);
850
+ }
851
+ });
852
+ // Repository infrastructure
853
+ program
854
+ .command('repository-infra')
855
+ .description('Set up repository infrastructure with specification pattern')
856
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
857
+ .action(async (options) => {
858
+ try {
859
+ await (0, generate_repository_1.setupRepositoryInfrastructure)(options.path || process.cwd());
860
+ }
861
+ catch (error) {
862
+ console.error(chalk_1.default.red('Error:'), error.message);
863
+ process.exit(1);
864
+ }
865
+ });
866
+ // Domain service generator
867
+ program
868
+ .command('domain-service <name>')
869
+ .description('Generate a domain service for cross-aggregate operations')
870
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
871
+ .option('-m, --module <module>', 'Module name')
872
+ .option('-t, --type <type>', 'Service type (simple, workflow, policy)', 'simple')
873
+ .action(async (name, options) => {
874
+ try {
875
+ await (0, generate_domain_service_1.generateDomainService)(name, options.path || process.cwd(), {
876
+ module: options.module,
877
+ type: options.type,
878
+ });
879
+ }
880
+ catch (error) {
881
+ console.error(chalk_1.default.red('Error:'), error.message);
882
+ process.exit(1);
883
+ }
884
+ });
885
+ // Domain service infrastructure
886
+ program
887
+ .command('domain-service-infra')
888
+ .description('Set up domain service infrastructure with saga pattern')
889
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
890
+ .action(async (options) => {
891
+ try {
892
+ await (0, generate_domain_service_1.setupDomainServiceInfrastructure)(options.path || process.cwd());
893
+ }
894
+ catch (error) {
895
+ console.error(chalk_1.default.red('Error:'), error.message);
896
+ process.exit(1);
897
+ }
898
+ });
899
+ // Orchestrator generator
900
+ program
901
+ .command('orchestrator <name>')
902
+ .description('Generate use case orchestrator with transaction management')
903
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
904
+ .option('-m, --module <module>', 'Module name')
905
+ .option('-t, --type <type>', 'Orchestrator type (command, query, saga)', 'command')
906
+ .action(async (name, options) => {
907
+ try {
908
+ await (0, generate_orchestrator_1.generateOrchestrator)(name, options.path || process.cwd(), {
909
+ module: options.module,
910
+ type: options.type,
911
+ });
912
+ }
913
+ catch (error) {
914
+ console.error(chalk_1.default.red('Error:'), error.message);
915
+ process.exit(1);
916
+ }
917
+ });
918
+ // API versioning
919
+ program
920
+ .command('api-versioning')
921
+ .description('Set up API versioning with deprecation handling')
922
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
923
+ .option('-s, --strategy <strategy>', 'Versioning strategy (uri, header, query)', 'uri')
924
+ .option('-v, --version <version>', 'Current API version', '1')
925
+ .action(async (options) => {
926
+ try {
927
+ await (0, api_versioning_1.setupApiVersioning)(options.path || process.cwd(), {
928
+ strategy: options.strategy,
929
+ currentVersion: options.version,
930
+ });
931
+ }
932
+ catch (error) {
933
+ console.error(chalk_1.default.red('Error:'), error.message);
934
+ process.exit(1);
935
+ }
936
+ });
937
+ // Rate limiting
938
+ program
939
+ .command('rate-limiting')
940
+ .description('Set up rate limiting and throttling framework')
941
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
942
+ .option('-s, --strategy <strategy>', 'Rate limiting strategy (token-bucket, sliding-window, fixed-window)', 'sliding-window')
943
+ .option('--storage <storage>', 'Storage type (memory, redis)', 'memory')
944
+ .action(async (options) => {
945
+ try {
946
+ await (0, rate_limiting_1.setupRateLimiting)(options.path || process.cwd(), {
947
+ strategy: options.strategy,
948
+ storage: options.storage,
949
+ });
950
+ }
951
+ catch (error) {
952
+ console.error(chalk_1.default.red('Error:'), error.message);
953
+ process.exit(1);
954
+ }
955
+ });
956
+ // Audit logging
957
+ program
958
+ .command('audit-logging')
959
+ .description('Set up audit logging and compliance framework')
960
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
961
+ .option('--storage <storage>', 'Storage type (database, file, elasticsearch)', 'database')
962
+ .action(async (options) => {
963
+ try {
964
+ await (0, audit_logging_1.setupAuditLogging)(options.path || process.cwd(), {
965
+ storage: options.storage,
966
+ });
967
+ }
968
+ catch (error) {
969
+ console.error(chalk_1.default.red('Error:'), error.message);
970
+ process.exit(1);
971
+ }
972
+ });
973
+ // i18n setup
974
+ program
975
+ .command('i18n')
976
+ .description('Set up internationalization infrastructure')
977
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
978
+ .option('-d, --default-locale <locale>', 'Default locale', 'en')
979
+ .option('-l, --locales <locales>', 'Supported locales (comma-separated)', 'en,fr,es')
980
+ .action(async (options) => {
981
+ try {
982
+ await (0, i18n_setup_1.setupI18n)(options.path || process.cwd(), {
983
+ defaultLocale: options.defaultLocale,
984
+ supportedLocales: options.locales.split(','),
985
+ });
986
+ }
987
+ catch (error) {
988
+ console.error(chalk_1.default.red('Error:'), error.message);
989
+ process.exit(1);
990
+ }
991
+ });
992
+ // Aggregate validator
993
+ program
994
+ .command('aggregate-validator')
995
+ .description('Set up aggregate validation framework with invariants')
996
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
997
+ .action(async (options) => {
998
+ try {
999
+ await (0, aggregate_validator_1.setupAggregateValidator)(options.path || process.cwd());
1000
+ }
1001
+ catch (error) {
1002
+ console.error(chalk_1.default.red('Error:'), error.message);
1003
+ process.exit(1);
1004
+ }
1005
+ });
1006
+ // API contracts
1007
+ program
1008
+ .command('api-contracts')
1009
+ .description('Set up API contract testing framework')
1010
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1011
+ .option('-f, --format <format>', 'Contract format (openapi, asyncapi)', 'openapi')
1012
+ .action(async (options) => {
1013
+ try {
1014
+ await (0, api_contracts_1.setupApiContracts)(options.path || process.cwd(), {
1015
+ format: options.format,
1016
+ });
1017
+ }
1018
+ catch (error) {
1019
+ console.error(chalk_1.default.red('Error:'), error.message);
1020
+ process.exit(1);
1021
+ }
1022
+ });
1023
+ // Resilience patterns
1024
+ program
1025
+ .command('resilience')
1026
+ .description('Set up resilience patterns (circuit breaker, retry, timeout, fallback)')
1027
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1028
+ .option('--circuit-breaker', 'Include circuit breaker', true)
1029
+ .option('--retry', 'Include retry strategy', true)
1030
+ .option('--timeout', 'Include timeout handling', true)
1031
+ .option('--fallback', 'Include fallback pattern', true)
1032
+ .option('--bulkhead', 'Include bulkhead pattern', true)
1033
+ .action(async (options) => {
1034
+ try {
1035
+ await (0, resilience_patterns_1.setupResiliencePatterns)(options.path || process.cwd(), {
1036
+ includeCircuitBreaker: options.circuitBreaker,
1037
+ includeRetry: options.retry,
1038
+ includeTimeout: options.timeout,
1039
+ includeFallback: options.fallback,
1040
+ includeBulkhead: options.bulkhead,
1041
+ });
1042
+ }
1043
+ catch (error) {
1044
+ console.error(chalk_1.default.red('Error:'), error.message);
1045
+ process.exit(1);
1046
+ }
1047
+ });
1048
+ // Observability tracing
1049
+ program
1050
+ .command('tracing')
1051
+ .description('Set up distributed tracing with OpenTelemetry')
1052
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1053
+ .option('--provider <provider>', 'Trace provider (jaeger, zipkin, datadog, otlp)', 'otlp')
1054
+ .option('--service-name <name>', 'Service name for traces')
1055
+ .action(async (options) => {
1056
+ try {
1057
+ await (0, observability_tracing_1.setupObservability)(options.path || process.cwd(), {
1058
+ provider: options.provider,
1059
+ serviceName: options.serviceName,
1060
+ });
1061
+ }
1062
+ catch (error) {
1063
+ console.error(chalk_1.default.red('Error:'), error.message);
1064
+ process.exit(1);
1065
+ }
1066
+ });
1067
+ // Feature flags
1068
+ program
1069
+ .command('feature-flags')
1070
+ .description('Set up feature flag management with A/B testing')
1071
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1072
+ .option('--provider <provider>', 'Flag provider (memory, database, redis, launchdarkly)', 'database')
1073
+ .action(async (options) => {
1074
+ try {
1075
+ await (0, feature_flags_1.setupFeatureFlags)(options.path || process.cwd(), {
1076
+ provider: options.provider,
1077
+ });
1078
+ }
1079
+ catch (error) {
1080
+ console.error(chalk_1.default.red('Error:'), error.message);
1081
+ process.exit(1);
1082
+ }
1083
+ });
1084
+ // Caching strategies
1085
+ program
1086
+ .command('caching')
1087
+ .description('Set up advanced caching strategies (cache-aside, write-through, etc.)')
1088
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1089
+ .option('--provider <provider>', 'Cache provider (memory, redis, memcached)', 'redis')
1090
+ .action(async (options) => {
1091
+ try {
1092
+ await (0, caching_strategies_1.setupCachingStrategies)(options.path || process.cwd(), {
1093
+ provider: options.provider,
1094
+ });
1095
+ }
1096
+ catch (error) {
1097
+ console.error(chalk_1.default.red('Error:'), error.message);
1098
+ process.exit(1);
1099
+ }
1100
+ });
1101
+ // Security patterns
1102
+ program
1103
+ .command('security')
1104
+ .description('Set up comprehensive security patterns (RBAC, ABAC, encryption, OWASP)')
1105
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1106
+ .option('--rbac', 'Include RBAC (role-based access control)', true)
1107
+ .option('--encryption', 'Include encryption service', true)
1108
+ .option('--owasp', 'Include OWASP protections', true)
1109
+ .action(async (options) => {
1110
+ try {
1111
+ await (0, security_patterns_1.setupSecurityPatterns)(options.path || process.cwd(), {
1112
+ includeRbac: options.rbac,
1113
+ includeEncryption: options.encryption,
1114
+ includeOwasp: options.owasp,
1115
+ });
1116
+ }
1117
+ catch (error) {
1118
+ console.error(chalk_1.default.red('Error:'), error.message);
1119
+ process.exit(1);
1120
+ }
1121
+ });
1122
+ // Database optimization
1123
+ program
1124
+ .command('db-optimize')
1125
+ .description('Set up database optimization (DataLoader, query analyzer, connection pool)')
1126
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1127
+ .option('-m, --module <module>', 'Module name', 'shared')
1128
+ .option('-o, --orm <orm>', 'ORM type (typeorm, prisma, mikro-orm)', 'typeorm')
1129
+ .option('--dataloader', 'Include DataLoader for N+1 prevention', true)
1130
+ .option('--analyzer', 'Include query analyzer', true)
1131
+ .action(async (options) => {
1132
+ try {
1133
+ await (0, db_optimization_1.setupDbOptimization)(options.path || process.cwd(), {
1134
+ module: options.module,
1135
+ orm: options.orm,
1136
+ includeDataLoader: options.dataloader,
1137
+ includeQueryAnalyzer: options.analyzer,
1138
+ });
1139
+ }
1140
+ catch (error) {
1141
+ console.error(chalk_1.default.red('Error:'), error.message);
1142
+ process.exit(1);
1143
+ }
1144
+ });
1145
+ // Database seeding
1146
+ program
1147
+ .command('seeding')
1148
+ .description('Set up database seeding infrastructure with fixtures')
1149
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1150
+ .option('-m, --module <module>', 'Module name', 'shared')
1151
+ .option('-o, --orm <orm>', 'ORM type (typeorm, prisma, mikro-orm)', 'typeorm')
1152
+ .option('-e, --entities <entities>', 'Entity names (comma-separated)')
1153
+ .action(async (options) => {
1154
+ try {
1155
+ await (0, database_seeding_1.setupDatabaseSeeding)(options.path || process.cwd(), {
1156
+ module: options.module,
1157
+ orm: options.orm,
1158
+ entities: options.entities ? options.entities.split(',') : undefined,
1159
+ });
1160
+ }
1161
+ catch (error) {
1162
+ console.error(chalk_1.default.red('Error:'), error.message);
1163
+ process.exit(1);
1164
+ }
1165
+ });
1166
+ // Advanced health probes
1167
+ program
1168
+ .command('health-probes')
1169
+ .description('Set up advanced health probes for Kubernetes')
1170
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1171
+ .option('-m, --module <module>', 'Module name', 'shared')
1172
+ .option('-d, --dependencies <deps>', 'Dependencies to check (comma-separated)', 'database,redis,external-api')
1173
+ .option('--k8s', 'Include Kubernetes configuration', true)
1174
+ .action(async (options) => {
1175
+ try {
1176
+ await (0, health_probes_advanced_1.setupHealthProbesAdvanced)(options.path || process.cwd(), {
1177
+ module: options.module,
1178
+ dependencies: options.dependencies.split(','),
1179
+ includeKubernetes: options.k8s,
1180
+ });
1181
+ }
1182
+ catch (error) {
1183
+ console.error(chalk_1.default.red('Error:'), error.message);
1184
+ process.exit(1);
1185
+ }
1186
+ });
1187
+ // Prometheus metrics
1188
+ program
1189
+ .command('metrics')
1190
+ .description('Set up Prometheus metrics with custom business metrics')
1191
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1192
+ .option('-m, --module <module>', 'Module name', 'shared')
1193
+ .option('--default-metrics', 'Include default Node.js metrics', true)
1194
+ .option('--custom <metrics>', 'Custom metrics to include (comma-separated)')
1195
+ .action(async (options) => {
1196
+ try {
1197
+ await (0, metrics_prometheus_1.setupMetricsPrometheus)(options.path || process.cwd(), {
1198
+ module: options.module,
1199
+ includeDefaultMetrics: options.defaultMetrics,
1200
+ customMetrics: options.custom ? options.custom.split(',') : undefined,
1201
+ });
1202
+ }
1203
+ catch (error) {
1204
+ console.error(chalk_1.default.red('Error:'), error.message);
1205
+ process.exit(1);
1206
+ }
1207
+ });
1208
+ // GraphQL subscriptions
1209
+ program
1210
+ .command('graphql-subscriptions')
1211
+ .description('Set up GraphQL subscriptions with real-time events')
1212
+ .option('-p, --path <path>', 'Path to the project', process.cwd())
1213
+ .option('-m, --module <module>', 'Module name', 'shared')
1214
+ .option('-e, --events <events>', 'Event types (comma-separated)', 'created,updated,deleted')
1215
+ .option('--redis', 'Use Redis for distributed pub/sub', true)
1216
+ .action(async (options) => {
1217
+ try {
1218
+ await (0, graphql_subscriptions_1.setupGraphQLSubscriptions)(options.path || process.cwd(), {
1219
+ module: options.module,
1220
+ events: options.events.split(','),
1221
+ useRedis: options.redis,
1222
+ });
1223
+ }
1224
+ catch (error) {
1225
+ console.error(chalk_1.default.red('Error:'), error.message);
1226
+ process.exit(1);
1227
+ }
1228
+ });
1229
+ // Performance profiling flag
1230
+ program.option('--profile', 'Enable performance profiling');
1231
+ // Enable profiling if requested
1232
+ if (process.argv.includes('--profile')) {
1233
+ performance_utils_1.perf.enable();
1234
+ }
148
1235
  program.parse();
1236
+ // Print performance report if profiling was enabled
1237
+ if (performance_utils_1.perf.isEnabled()) {
1238
+ performance_utils_1.perf.printReport();
1239
+ }
149
1240
  //# sourceMappingURL=index.js.map