nestjs-ddd-cli 2.2.0 → 3.2.1

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