@tamyla/clodo-framework 3.1.21 → 3.1.22

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 (169) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +53 -0
  3. package/dist/bin/clodo-service.js +47 -15
  4. package/dist/bin/commands/deploy.js +115 -83
  5. package/dist/bin/commands/helpers/deployment-ui.js +138 -0
  6. package/dist/bin/commands/helpers/deployment-verification.js +251 -0
  7. package/dist/bin/commands/helpers/error-recovery.js +80 -0
  8. package/dist/bin/commands/helpers/resource-detection.js +113 -0
  9. package/dist/bin/commands/validate.js +1 -1
  10. package/dist/bin/security/security-cli.js +1 -1
  11. package/dist/bin/shared/cache/configuration-cache.js +82 -0
  12. package/dist/bin/shared/cloudflare/domain-manager.js +1 -1
  13. package/dist/bin/shared/cloudflare/index.js +1 -1
  14. package/dist/bin/shared/cloudflare/ops.js +6 -4
  15. package/dist/bin/shared/config/ConfigurationManager.js +23 -1
  16. package/dist/bin/shared/config/command-config-manager.js +19 -3
  17. package/dist/bin/shared/config/index.js +1 -1
  18. package/dist/bin/shared/deployment/credential-collector.js +30 -7
  19. package/dist/bin/shared/deployment/index.js +2 -2
  20. package/dist/bin/shared/deployment/rollback-manager.js +4 -520
  21. package/dist/bin/shared/deployment/utilities/d1-error-recovery.js +177 -0
  22. package/dist/bin/shared/deployment/validator.js +40 -10
  23. package/dist/bin/shared/deployment/workflows/deployment-summary.js +214 -0
  24. package/dist/bin/shared/deployment/workflows/interactive-confirmation.js +188 -0
  25. package/dist/bin/shared/deployment/workflows/interactive-database-workflow.js +234 -0
  26. package/dist/bin/shared/deployment/workflows/interactive-domain-info-gatherer.js +240 -0
  27. package/dist/bin/shared/deployment/workflows/interactive-secret-workflow.js +228 -0
  28. package/dist/bin/shared/deployment/workflows/interactive-testing-workflow.js +235 -0
  29. package/dist/bin/shared/deployment/workflows/interactive-validation.js +218 -0
  30. package/dist/bin/shared/error-handling/error-classifier.js +46 -0
  31. package/dist/bin/shared/monitoring/health-checker.js +129 -1
  32. package/dist/bin/shared/monitoring/memory-manager.js +17 -6
  33. package/dist/bin/shared/routing/domain-router.js +1 -1
  34. package/dist/bin/shared/utils/deployment-validator.js +97 -0
  35. package/dist/bin/shared/utils/formatters.js +10 -0
  36. package/dist/bin/shared/utils/index.js +13 -1
  37. package/dist/bin/shared/utils/interactive-prompts.js +34 -18
  38. package/dist/bin/shared/utils/progress-manager.js +2 -2
  39. package/dist/bin/shared/utils/progress-spinner.js +53 -0
  40. package/dist/bin/shared/utils/sensitive-redactor.js +91 -0
  41. package/dist/bin/shared/validation/ValidationRegistry.js +1 -1
  42. package/dist/security/index.js +1 -1
  43. package/dist/security/patterns/insecure-patterns.js +1 -1
  44. package/dist/utils/constants.js +102 -0
  45. package/dist/utils/deployment/wrangler-config-manager.js +215 -48
  46. package/dist/utils/framework-config.js +2 -2
  47. package/dist/utils/interactive-prompts.js +10 -59
  48. package/package.json +16 -8
  49. package/dist/bin/clodo-service-old.js +0 -868
  50. package/dist/bin/clodo-service-test.js +0 -10
  51. package/dist/bin/commands/assess.js +0 -91
  52. package/dist/bin/commands/create.js +0 -77
  53. package/dist/bin/commands/diagnose.js +0 -83
  54. package/dist/bin/commands/helpers.js +0 -138
  55. package/dist/bin/commands/update.js +0 -75
  56. package/dist/bin/database/deployment-db-manager.js +0 -423
  57. package/dist/bin/database/enterprise-db-manager.js +0 -457
  58. package/dist/bin/database/wrangler-d1-manager.js +0 -685
  59. package/dist/bin/deployment/enterprise-deploy.js +0 -877
  60. package/dist/bin/deployment/master-deploy.js +0 -1376
  61. package/dist/bin/deployment/modular-enterprise-deploy.js +0 -466
  62. package/dist/bin/deployment/modules/DeploymentConfiguration.js +0 -395
  63. package/dist/bin/deployment/modules/DeploymentOrchestrator.js +0 -492
  64. package/dist/bin/deployment/modules/EnvironmentManager.js +0 -517
  65. package/dist/bin/deployment/modules/MonitoringIntegration.js +0 -560
  66. package/dist/bin/deployment/modules/ValidationManager.js +0 -342
  67. package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
  68. package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
  69. package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +0 -273
  70. package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
  71. package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
  72. package/dist/bin/deployment/test-interactive-utils.js +0 -66
  73. package/dist/bin/portfolio/portfolio-manager.js +0 -487
  74. package/dist/bin/service-management/create-service.js +0 -122
  75. package/dist/bin/service-management/init-service.js +0 -79
  76. package/dist/config/customers.js +0 -623
  77. package/dist/config/domains.js +0 -186
  78. package/dist/config/index.js +0 -6
  79. package/dist/database/database-orchestrator.js +0 -795
  80. package/dist/database/index.js +0 -4
  81. package/dist/deployment/index.js +0 -11
  82. package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
  83. package/dist/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
  84. package/dist/deployment/orchestration/PortfolioOrchestrator.js +0 -273
  85. package/dist/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
  86. package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
  87. package/dist/deployment/orchestration/index.js +0 -17
  88. package/dist/deployment/rollback-manager.js +0 -36
  89. package/dist/deployment/wrangler-deployer.js +0 -640
  90. package/dist/handlers/GenericRouteHandler.js +0 -532
  91. package/dist/migration/MigrationAdapters.js +0 -562
  92. package/dist/modules/ModuleManager.js +0 -668
  93. package/dist/modules/security.js +0 -96
  94. package/dist/orchestration/cross-domain-coordinator.js +0 -1083
  95. package/dist/orchestration/index.js +0 -5
  96. package/dist/orchestration/modules/DeploymentCoordinator.js +0 -368
  97. package/dist/orchestration/modules/DomainResolver.js +0 -198
  98. package/dist/orchestration/modules/StateManager.js +0 -332
  99. package/dist/orchestration/multi-domain-orchestrator.js +0 -724
  100. package/dist/routing/EnhancedRouter.js +0 -158
  101. package/dist/schema/SchemaManager.js +0 -778
  102. package/dist/service-management/ConfirmationEngine.js +0 -412
  103. package/dist/service-management/ErrorTracker.js +0 -299
  104. package/dist/service-management/GenerationEngine.js +0 -447
  105. package/dist/service-management/InputCollector.js +0 -619
  106. package/dist/service-management/ServiceCreator.js +0 -265
  107. package/dist/service-management/ServiceInitializer.js +0 -453
  108. package/dist/service-management/ServiceOrchestrator.js +0 -633
  109. package/dist/service-management/generators/BaseGenerator.js +0 -233
  110. package/dist/service-management/generators/GeneratorRegistry.js +0 -254
  111. package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +0 -87
  112. package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +0 -106
  113. package/dist/service-management/generators/code/ServiceHandlersGenerator.js +0 -235
  114. package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +0 -116
  115. package/dist/service-management/generators/code/ServiceUtilsGenerator.js +0 -246
  116. package/dist/service-management/generators/code/WorkerIndexGenerator.js +0 -143
  117. package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +0 -101
  118. package/dist/service-management/generators/config/DomainsConfigGenerator.js +0 -175
  119. package/dist/service-management/generators/config/EnvExampleGenerator.js +0 -178
  120. package/dist/service-management/generators/config/ProductionEnvGenerator.js +0 -97
  121. package/dist/service-management/generators/config/StagingEnvGenerator.js +0 -97
  122. package/dist/service-management/generators/config/WranglerTomlGenerator.js +0 -238
  123. package/dist/service-management/generators/core/PackageJsonGenerator.js +0 -243
  124. package/dist/service-management/generators/core/SiteConfigGenerator.js +0 -115
  125. package/dist/service-management/generators/documentation/ApiDocsGenerator.js +0 -331
  126. package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +0 -294
  127. package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +0 -244
  128. package/dist/service-management/generators/documentation/ReadmeGenerator.js +0 -196
  129. package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +0 -190
  130. package/dist/service-management/generators/scripts/DeployScriptGenerator.js +0 -123
  131. package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +0 -101
  132. package/dist/service-management/generators/scripts/SetupScriptGenerator.js +0 -88
  133. package/dist/service-management/generators/service-types/StaticSiteGenerator.js +0 -342
  134. package/dist/service-management/generators/testing/EslintConfigGenerator.js +0 -85
  135. package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +0 -237
  136. package/dist/service-management/generators/testing/JestConfigGenerator.js +0 -72
  137. package/dist/service-management/generators/testing/UnitTestsGenerator.js +0 -277
  138. package/dist/service-management/generators/tooling/DockerComposeGenerator.js +0 -71
  139. package/dist/service-management/generators/tooling/GitignoreGenerator.js +0 -143
  140. package/dist/service-management/generators/utils/FileWriter.js +0 -179
  141. package/dist/service-management/generators/utils/PathResolver.js +0 -157
  142. package/dist/service-management/generators/utils/ServiceManifestGenerator.js +0 -111
  143. package/dist/service-management/generators/utils/TemplateEngine.js +0 -185
  144. package/dist/service-management/generators/utils/index.js +0 -18
  145. package/dist/service-management/handlers/ConfirmationHandler.js +0 -71
  146. package/dist/service-management/handlers/GenerationHandler.js +0 -80
  147. package/dist/service-management/handlers/InputHandler.js +0 -59
  148. package/dist/service-management/handlers/ValidationHandler.js +0 -203
  149. package/dist/service-management/index.js +0 -14
  150. package/dist/service-management/routing/DomainRouteMapper.js +0 -311
  151. package/dist/service-management/routing/RouteGenerator.js +0 -266
  152. package/dist/service-management/routing/WranglerRoutesBuilder.js +0 -273
  153. package/dist/service-management/routing/index.js +0 -14
  154. package/dist/service-management/services/DirectoryStructureService.js +0 -56
  155. package/dist/service-management/services/GenerationCoordinator.js +0 -208
  156. package/dist/service-management/services/GeneratorRegistry.js +0 -174
  157. package/dist/services/GenericDataService.js +0 -501
  158. package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +0 -286
  159. package/dist/ui-structures/concepts/service-lifecycle-management.md +0 -150
  160. package/dist/ui-structures/concepts/service-manifest-guide.md +0 -309
  161. package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +0 -231
  162. package/dist/ui-structures/creation/automated-generation-ui.json +0 -246
  163. package/dist/ui-structures/creation/core-inputs-ui.json +0 -217
  164. package/dist/ui-structures/creation/smart-confirmable-ui.json +0 -451
  165. package/dist/ui-structures/reference/absolutely-required-inputs.json +0 -315
  166. package/dist/ui-structures/reference/service-manifest-template.json +0 -342
  167. package/dist/version/VersionDetector.js +0 -723
  168. package/dist/worker/index.js +0 -4
  169. package/dist/worker/integration.js +0 -351
@@ -1,273 +0,0 @@
1
- /**
2
- * WranglerRoutesBuilder - Builds TOML [[routes]] sections
3
- *
4
- * Formats route patterns as valid TOML with proper syntax,
5
- * comments, and environment-specific sections.
6
- *
7
- * @module service-management/routing/WranglerRoutesBuilder
8
- */
9
-
10
- export class WranglerRoutesBuilder {
11
- constructor(options = {}) {
12
- this.options = options;
13
- }
14
-
15
- /**
16
- * Build TOML [[routes]] section
17
- *
18
- * @param {Array<string>} patterns - Array of route patterns
19
- * @param {string} environment - Target environment (production|staging|development)
20
- * @param {Object} options - Build options
21
- * @param {string} options.zoneId - Cloudflare zone ID (optional)
22
- * @param {boolean} options.includeComments - Include comments (default: true)
23
- * @param {string} options.domain - Domain name (for comments)
24
- * @param {string} options.serviceName - Service name (for comments)
25
- *
26
- * @returns {string} TOML-formatted routes section
27
- *
28
- * @example
29
- * const builder = new WranglerRoutesBuilder();
30
- * const toml = builder.buildRoutesSection(
31
- * ['api.example.com/*', 'example.com/api/*'],
32
- * 'production',
33
- * { zoneId: 'xyz789...', includeComments: true, domain: 'api.example.com' }
34
- * );
35
- */
36
- buildRoutesSection(patterns, environment, options = {}) {
37
- if (!patterns || patterns.length === 0) {
38
- return '';
39
- }
40
- const opts = {
41
- includeComments: options.includeComments !== false,
42
- ...options
43
- };
44
- let section = '';
45
-
46
- // Add environment comment
47
- if (opts.includeComments) {
48
- section += this.generateRouteComment(opts.domain || 'unknown', environment);
49
- section += '\n';
50
- }
51
-
52
- // Determine if routes should be nested under environment
53
- const isNested = environment === 'staging' || environment === 'development';
54
- const prefix = isNested ? `env.${environment}.` : '';
55
-
56
- // Build each route
57
- patterns.forEach((pattern, index) => {
58
- section += this.formatRoutePattern(pattern, opts.zoneId, prefix);
59
-
60
- // Add spacing between routes (but not after last one)
61
- if (index < patterns.length - 1) {
62
- section += '\n';
63
- }
64
- });
65
- return section;
66
- }
67
-
68
- /**
69
- * Format a single route pattern as TOML
70
- *
71
- * @param {string} pattern - Route pattern (e.g., api.example.com/*)
72
- * @param {string} zoneId - Cloudflare zone ID (optional)
73
- * @param {string} prefix - Environment prefix (e.g., 'env.staging.')
74
- * @returns {string} TOML-formatted route
75
- *
76
- * @example
77
- * formatRoutePattern('api.example.com/*', 'xyz789...')
78
- * // Returns:
79
- * // [[routes]]
80
- * // pattern = "api.example.com/*"
81
- * // zone_id = "xyz789..."
82
- */
83
- formatRoutePattern(pattern, zoneId = null, prefix = '') {
84
- let toml = `[[${prefix}routes]]\n`;
85
- toml += `pattern = "${this._escapeTomlString(pattern)}"\n`;
86
- if (zoneId) {
87
- toml += `zone_id = "${this._escapeTomlString(zoneId)}"\n`;
88
- }
89
- return toml;
90
- }
91
-
92
- /**
93
- * Generate descriptive comment for routes
94
- *
95
- * @param {string} domain - Domain name
96
- * @param {string} environment - Environment name
97
- * @returns {string} Comment text
98
- *
99
- * @example
100
- * generateRouteComment('api.example.com', 'production')
101
- * // Returns: "# Production environment routes\n# Domain: api.example.com"
102
- */
103
- generateRouteComment(domain, environment) {
104
- const envName = environment.charAt(0).toUpperCase() + environment.slice(1);
105
- let comment = `# ${envName} environment routes\n`;
106
- comment += `# Domain: ${domain}`;
107
- return comment;
108
- }
109
-
110
- /**
111
- * Generate development environment comment
112
- *
113
- * Used when development uses workers.dev subdomain (no routes needed)
114
- *
115
- * @param {string} workerName - Worker name
116
- * @returns {string} Comment explaining workers.dev usage
117
- */
118
- generateDevComment(workerName) {
119
- return `# Development environment\n` + `# Uses workers.dev subdomain: https://${workerName}-dev.<account>.workers.dev\n` + `# No custom domain routes needed for development\n`;
120
- }
121
-
122
- /**
123
- * Validate TOML syntax
124
- *
125
- * Basic validation to catch common TOML errors
126
- *
127
- * @param {string} tomlString - TOML string to validate
128
- * @returns {Object} Validation result
129
- * @returns {boolean} returns.valid - True if valid TOML syntax
130
- * @returns {Array<string>} returns.errors - Array of error messages
131
- *
132
- * @example
133
- * const result = builder.validateTomlSyntax('[[routes]]\npattern = "api.example.com/*"');
134
- * // Returns: { valid: true, errors: [] }
135
- */
136
- validateTomlSyntax(tomlString) {
137
- const errors = [];
138
- if (!tomlString || typeof tomlString !== 'string') {
139
- return {
140
- valid: false,
141
- errors: ['TOML string is required']
142
- };
143
- }
144
- const lines = tomlString.split('\n');
145
- lines.forEach((line, index) => {
146
- const lineNum = index + 1;
147
- const trimmed = line.trim();
148
-
149
- // Skip empty lines and comments
150
- if (!trimmed || trimmed.startsWith('#')) {
151
- return;
152
- }
153
-
154
- // Check [[array]] syntax
155
- if (trimmed.startsWith('[[')) {
156
- if (!trimmed.endsWith(']]')) {
157
- errors.push(`Line ${lineNum}: Invalid [[array]] syntax - missing closing ]]`);
158
- }
159
- const arrayName = trimmed.slice(2, -2);
160
- if (!arrayName) {
161
- errors.push(`Line ${lineNum}: Empty [[array]] name`);
162
- }
163
- }
164
-
165
- // Check [section] syntax
166
- else if (trimmed.startsWith('[') && !trimmed.startsWith('[[')) {
167
- if (!trimmed.endsWith(']')) {
168
- errors.push(`Line ${lineNum}: Invalid [section] syntax - missing closing ]`);
169
- }
170
- const sectionName = trimmed.slice(1, -1);
171
- if (!sectionName) {
172
- errors.push(`Line ${lineNum}: Empty [section] name`);
173
- }
174
- }
175
-
176
- // Check key = value syntax
177
- else if (trimmed.includes('=')) {
178
- const parts = trimmed.split('=');
179
- if (parts.length !== 2) {
180
- errors.push(`Line ${lineNum}: Invalid key = value syntax - multiple equals signs`);
181
- return;
182
- }
183
- const key = parts[0].trim();
184
- const value = parts[1].trim();
185
- if (!key) {
186
- errors.push(`Line ${lineNum}: Missing key before =`);
187
- }
188
- if (!value) {
189
- errors.push(`Line ${lineNum}: Missing value after =`);
190
- }
191
-
192
- // Check string values are quoted
193
- if (value && !value.startsWith('"') && !value.match(/^[0-9]+$/)) {
194
- // Not a number and not quoted
195
- if (!value.startsWith('[') && !value.match(/^(true|false)$/)) {
196
- errors.push(`Line ${lineNum}: String values must be quoted (key: ${key})`);
197
- }
198
- }
199
-
200
- // Check for unescaped quotes
201
- if (value.startsWith('"') && value.endsWith('"')) {
202
- const innerValue = value.slice(1, -1);
203
- if (innerValue.includes('"') && !innerValue.includes('\\"')) {
204
- errors.push(`Line ${lineNum}: Unescaped quote in string value (key: ${key})`);
205
- }
206
- }
207
- }
208
- });
209
- return {
210
- valid: errors.length === 0,
211
- errors
212
- };
213
- }
214
-
215
- /**
216
- * Escape special characters for TOML strings
217
- * @private
218
- *
219
- * @param {string} str - String to escape
220
- * @returns {string} Escaped string
221
- */
222
- _escapeTomlString(str) {
223
- if (!str) return '';
224
- return str.replace(/\\/g, '\\\\') // Escape backslashes
225
- .replace(/"/g, '\\"') // Escape quotes
226
- .replace(/\n/g, '\\n') // Escape newlines
227
- .replace(/\r/g, '\\r') // Escape carriage returns
228
- .replace(/\t/g, '\\t'); // Escape tabs
229
- }
230
-
231
- /**
232
- * Build complete wrangler.toml routes configuration
233
- *
234
- * High-level method that builds routes for all environments
235
- *
236
- * @param {Object} routesByEnvironment - Routes grouped by environment
237
- * @param {Array<string>} routesByEnvironment.production - Production routes
238
- * @param {Array<string>} routesByEnvironment.staging - Staging routes
239
- * @param {Array<string>} routesByEnvironment.development - Development routes
240
- * @param {Object} options - Build options
241
- *
242
- * @returns {string} Complete TOML routes configuration
243
- */
244
- buildCompleteRoutesConfig(routesByEnvironment, options = {}) {
245
- let config = '';
246
-
247
- // Add header
248
- if (options.includeComments !== false) {
249
- config += '# Cloudflare Workers Routes Configuration\n';
250
- config += '# Generated by Clodo Framework\n';
251
- config += `# Generated: ${new Date().toISOString()}\n\n`;
252
- }
253
-
254
- // Production routes (top-level)
255
- if (routesByEnvironment.production && routesByEnvironment.production.length > 0) {
256
- config += this.buildRoutesSection(routesByEnvironment.production, 'production', options);
257
- config += '\n\n';
258
- }
259
-
260
- // Staging routes
261
- if (routesByEnvironment.staging && routesByEnvironment.staging.length > 0) {
262
- config += this.buildRoutesSection(routesByEnvironment.staging, 'staging', options);
263
- config += '\n\n';
264
- }
265
-
266
- // Development routes
267
- if (routesByEnvironment.development && routesByEnvironment.development.length > 0) {
268
- config += this.buildRoutesSection(routesByEnvironment.development, 'development', options);
269
- config += '\n\n';
270
- }
271
- return config.trim() + '\n';
272
- }
273
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Routing module exports
3
- *
4
- * Provides automatic route generation for Cloudflare Workers
5
- * from domain configuration metadata.
6
- *
7
- * This is a CORE IDENTITY feature that completes multi-domain orchestration.
8
- *
9
- * @module service-management/routing
10
- */
11
-
12
- export { RouteGenerator } from './RouteGenerator.js';
13
- export { DomainRouteMapper } from './DomainRouteMapper.js';
14
- export { WranglerRoutesBuilder } from './WranglerRoutesBuilder.js';
@@ -1,56 +0,0 @@
1
- /**
2
- * DirectoryStructureService - Handles creation of directory structures for services
3
- *
4
- * Provides standardized directory layout creation for generated services,
5
- * ensuring consistent project structure across all service types.
6
- */
7
- import { existsSync, mkdirSync } from 'fs';
8
- import { join } from 'path';
9
- export class DirectoryStructureService {
10
- /**
11
- * Create the standard directory structure for a service
12
- * @param {string} servicePath - Root path of the service
13
- */
14
- createStandardStructure(servicePath) {
15
- const directories = ['src', 'src/config', 'src/worker', 'src/handlers', 'src/middleware', 'src/utils', 'src/schemas', 'scripts', 'test', 'test/unit', 'test/integration', 'docs', 'config', 'logs', '.github', '.github/workflows'];
16
- for (const dir of directories) {
17
- const fullPath = join(servicePath, dir);
18
- if (!existsSync(fullPath)) {
19
- mkdirSync(fullPath, {
20
- recursive: true
21
- });
22
- }
23
- }
24
- }
25
-
26
- /**
27
- * Create a custom directory structure
28
- * @param {string} servicePath - Root path of the service
29
- * @param {string[]} directories - Array of directory paths to create
30
- */
31
- createCustomStructure(servicePath, directories) {
32
- for (const dir of directories) {
33
- const fullPath = join(servicePath, dir);
34
- if (!existsSync(fullPath)) {
35
- mkdirSync(fullPath, {
36
- recursive: true
37
- });
38
- }
39
- }
40
- }
41
-
42
- /**
43
- * Ensure a single directory exists
44
- * @param {string} directoryPath - Full path to the directory
45
- * @returns {boolean} - True if directory was created, false if it already existed
46
- */
47
- ensureDirectory(directoryPath) {
48
- if (!existsSync(directoryPath)) {
49
- mkdirSync(directoryPath, {
50
- recursive: true
51
- });
52
- return true;
53
- }
54
- return false;
55
- }
56
- }
@@ -1,208 +0,0 @@
1
- /**
2
- * GenerationCoordinator - Coordinates multi-file generation across different phases
3
- *
4
- * Organizes generation into logical phases (core, service, environment, testing, docs, automation)
5
- * and coordinates the execution of multiple generators within each phase.
6
- */
7
- export class GenerationCoordinator {
8
- /**
9
- * Create a new coordinator
10
- * @param {Object} engine - GenerationEngine instance to delegate generator calls to
11
- */
12
- constructor(engine) {
13
- this.engine = engine;
14
- }
15
-
16
- /**
17
- * Generate all files in the correct order
18
- * @param {Object} coreInputs - Core service configuration
19
- * @param {Object} confirmedValues - User-confirmed values
20
- * @param {string} servicePath - Target service path
21
- * @returns {Promise<string[]>} - Array of generated file paths
22
- */
23
- async generateAllFiles(coreInputs, confirmedValues, servicePath) {
24
- const generatedFiles = [];
25
-
26
- // Core configuration files
27
- const coreFiles = await this.generateCoreFiles(coreInputs, confirmedValues, servicePath);
28
- generatedFiles.push(...coreFiles);
29
-
30
- // Service-specific configuration files
31
- generatedFiles.push(...(await this.generateServiceSpecificFiles(coreInputs, confirmedValues, servicePath)));
32
-
33
- // Environment and deployment files
34
- generatedFiles.push(...(await this.generateEnvironmentFiles(coreInputs, confirmedValues, servicePath)));
35
-
36
- // Testing and quality assurance files
37
- generatedFiles.push(...(await this.generateTestingFiles(coreInputs, confirmedValues, servicePath)));
38
-
39
- // Documentation files
40
- generatedFiles.push(...(await this.generateDocumentationFiles(coreInputs, confirmedValues, servicePath)));
41
-
42
- // CI/CD and automation files
43
- generatedFiles.push(...(await this.generateAutomationFiles(coreInputs, confirmedValues, servicePath)));
44
- return generatedFiles;
45
- }
46
-
47
- /**
48
- * Generate core configuration files (package.json, wrangler.toml, etc.)
49
- * @param {Object} coreInputs - Core service configuration
50
- * @param {Object} confirmedValues - User-confirmed values
51
- * @param {string} servicePath - Target service path
52
- * @returns {Promise<string[]>} - Array of generated file paths
53
- */
54
- async generateCoreFiles(coreInputs, confirmedValues, servicePath) {
55
- const files = [];
56
-
57
- // Generate package.json using PackageJsonGenerator (refactored)
58
- const packageJsonPath = await this.engine.generatePackageJson(coreInputs, confirmedValues, servicePath);
59
- files.push(packageJsonPath);
60
-
61
- // Generate wrangler.toml using WranglerTomlGenerator (refactored)
62
- const wranglerPath = await this.engine.generateWranglerToml(coreInputs, confirmedValues, servicePath);
63
- files.push(wranglerPath);
64
-
65
- // Generate domains.js using DomainsConfigGenerator (refactored)
66
- const domainsPath = await this.engine.generateDomainsConfig(coreInputs, confirmedValues, servicePath);
67
- files.push(domainsPath);
68
-
69
- // Generate worker index using WorkerIndexGenerator (refactored)
70
- const workerPath = await this.engine.generateWorkerIndex(coreInputs, confirmedValues, servicePath);
71
- files.push(workerPath);
72
-
73
- // Generate .env.example using EnvExampleGenerator (refactored)
74
- const envExamplePath = await this.engine.generateEnvExample(coreInputs, confirmedValues, servicePath);
75
- files.push(envExamplePath);
76
- return files;
77
- }
78
-
79
- /**
80
- * Generate service-specific configuration files
81
- * @param {Object} coreInputs - Core service configuration
82
- * @param {Object} confirmedValues - User-confirmed values
83
- * @param {string} servicePath - Target service path
84
- * @returns {Promise<string[]>} - Array of generated file paths
85
- */
86
- async generateServiceSpecificFiles(coreInputs, confirmedValues, servicePath) {
87
- const files = [];
88
-
89
- // Generate service schema
90
- const schemaPath = await this.engine.generateServiceSchema(coreInputs, confirmedValues, servicePath);
91
- files.push(schemaPath);
92
-
93
- // Generate service handlers
94
- const handlersPath = await this.engine.generateServiceHandlers(coreInputs, confirmedValues, servicePath);
95
- files.push(handlersPath);
96
-
97
- // Generate service middleware
98
- const middlewarePath = await this.engine.generateServiceMiddleware(coreInputs, confirmedValues, servicePath);
99
- files.push(middlewarePath);
100
-
101
- // Generate service utils
102
- const utilsPath = await this.engine.generateServiceUtils(coreInputs, confirmedValues, servicePath);
103
- files.push(utilsPath);
104
- return files;
105
- }
106
-
107
- /**
108
- * Generate environment and deployment files
109
- * @param {Object} coreInputs - Core service configuration
110
- * @param {Object} confirmedValues - User-confirmed values
111
- * @param {string} servicePath - Target service path
112
- * @returns {Promise<string[]>} - Array of generated file paths
113
- */
114
- async generateEnvironmentFiles(coreInputs, confirmedValues, servicePath) {
115
- const files = [];
116
-
117
- // scripts/deploy.ps1
118
- files.push(await this.engine.generateDeployScript(coreInputs, confirmedValues, servicePath));
119
-
120
- // scripts/setup.ps1
121
- files.push(await this.engine.generateSetupScript(coreInputs, confirmedValues, servicePath));
122
-
123
- // scripts/health-check.ps1
124
- files.push(await this.engine.generateHealthCheckScript(coreInputs, confirmedValues, servicePath));
125
-
126
- // config/production.env
127
- files.push(await this.engine.generateProductionEnv(coreInputs, confirmedValues, servicePath));
128
-
129
- // config/staging.env
130
- files.push(await this.engine.generateStagingEnv(coreInputs, confirmedValues, servicePath));
131
-
132
- // config/development.env
133
- files.push(await this.engine.generateDevelopmentEnv(coreInputs, confirmedValues, servicePath));
134
- return files;
135
- }
136
-
137
- /**
138
- * Generate testing and quality assurance files
139
- * @param {Object} coreInputs - Core service configuration
140
- * @param {Object} confirmedValues - User-confirmed values
141
- * @param {string} servicePath - Target service path
142
- * @returns {Promise<string[]>} - Array of generated file paths
143
- */
144
- async generateTestingFiles(coreInputs, confirmedValues, servicePath) {
145
- const files = [];
146
-
147
- // test/unit/service.test.js
148
- files.push(await this.engine.generateUnitTests(coreInputs, confirmedValues, servicePath));
149
-
150
- // test/integration/service.integration.test.js
151
- files.push(await this.engine.generateIntegrationTests(coreInputs, confirmedValues, servicePath));
152
-
153
- // jest.config.js
154
- files.push(await this.engine.generateJestConfig(coreInputs, confirmedValues, servicePath));
155
-
156
- // .eslintrc.js
157
- files.push(await this.engine.generateEslintConfig(coreInputs, confirmedValues, servicePath));
158
- return files;
159
- }
160
-
161
- /**
162
- * Generate documentation files
163
- * @param {Object} coreInputs - Core service configuration
164
- * @param {Object} confirmedValues - User-confirmed values
165
- * @param {string} servicePath - Target service path
166
- * @returns {Promise<string[]>} - Array of generated file paths
167
- */
168
- async generateDocumentationFiles(coreInputs, confirmedValues, servicePath) {
169
- const files = [];
170
-
171
- // README.md
172
- files.push(await this.engine.generateReadme(coreInputs, confirmedValues, servicePath));
173
-
174
- // docs/API.md
175
- files.push(await this.engine.generateApiDocs(coreInputs, confirmedValues, servicePath));
176
-
177
- // docs/DEPLOYMENT.md
178
- files.push(await this.engine.generateDeploymentDocs(coreInputs, confirmedValues, servicePath));
179
-
180
- // docs/CONFIGURATION.md
181
- files.push(await this.engine.generateConfigurationDocs(coreInputs, confirmedValues, servicePath));
182
- return files;
183
- }
184
-
185
- /**
186
- * Generate automation and CI/CD files
187
- * @param {Object} coreInputs - Core service configuration
188
- * @param {Object} confirmedValues - User-confirmed values
189
- * @param {string} servicePath - Target service path
190
- * @returns {Promise<string[]>} - Array of generated file paths
191
- */
192
- async generateAutomationFiles(coreInputs, confirmedValues, servicePath) {
193
- const files = [];
194
-
195
- // .github/workflows/ci.yml
196
- files.push(await this.engine.generateCiWorkflow(coreInputs, confirmedValues, servicePath));
197
-
198
- // .github/workflows/deploy.yml
199
- files.push(await this.engine.generateDeployWorkflow(coreInputs, confirmedValues, servicePath));
200
-
201
- // .gitignore
202
- files.push(await this.engine.generateGitignore(coreInputs, confirmedValues, servicePath));
203
-
204
- // docker-compose.yml (for local development)
205
- files.push(await this.engine.generateDockerCompose(coreInputs, confirmedValues, servicePath));
206
- return files;
207
- }
208
- }