@tamyla/clodo-framework 3.1.8 → 3.1.9

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 (87) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bin/clodo-service-old.js +868 -0
  3. package/dist/bin/clodo-service-test.js +10 -0
  4. package/dist/bin/clodo-service.js +62 -0
  5. package/dist/bin/commands/assess.js +76 -0
  6. package/dist/bin/commands/create.js +56 -0
  7. package/dist/bin/commands/deploy.js +196 -0
  8. package/dist/bin/commands/diagnose.js +70 -0
  9. package/dist/bin/commands/helpers.js +138 -0
  10. package/dist/bin/commands/update.js +55 -0
  11. package/dist/bin/commands/validate.js +26 -0
  12. package/dist/bin/database/deployment-db-manager.js +423 -0
  13. package/dist/bin/database/enterprise-db-manager.js +457 -0
  14. package/dist/bin/database/wrangler-d1-manager.js +685 -0
  15. package/dist/bin/deployment/enterprise-deploy.js +877 -0
  16. package/dist/bin/deployment/master-deploy.js +1376 -0
  17. package/dist/bin/deployment/modular-enterprise-deploy.js +466 -0
  18. package/dist/bin/deployment/modules/DeploymentConfiguration.js +395 -0
  19. package/dist/bin/deployment/modules/DeploymentOrchestrator.js +492 -0
  20. package/dist/bin/deployment/modules/EnvironmentManager.js +517 -0
  21. package/dist/bin/deployment/modules/MonitoringIntegration.js +560 -0
  22. package/dist/bin/deployment/modules/ValidationManager.js +342 -0
  23. package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
  24. package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +401 -0
  25. package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +273 -0
  26. package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
  27. package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
  28. package/dist/bin/deployment/test-interactive-utils.js +66 -0
  29. package/dist/bin/portfolio/portfolio-manager.js +487 -0
  30. package/dist/bin/security/security-cli.js +108 -0
  31. package/dist/bin/service-management/create-service.js +122 -0
  32. package/dist/bin/service-management/init-service.js +79 -0
  33. package/dist/deployment/index.js +10 -9
  34. package/dist/deployment/rollback-manager.js +21 -508
  35. package/package.json +7 -7
  36. package/dist/shared/deployment/auditor.js +0 -986
  37. package/dist/shared/deployment/validator.js +0 -670
  38. package/dist/shared/production-tester/api-tester.js +0 -80
  39. package/dist/shared/production-tester/auth-tester.js +0 -129
  40. package/dist/shared/production-tester/core.js +0 -217
  41. package/dist/shared/production-tester/database-tester.js +0 -105
  42. package/dist/shared/production-tester/index.js +0 -74
  43. package/dist/shared/production-tester/load-tester.js +0 -120
  44. package/dist/shared/production-tester/performance-tester.js +0 -105
  45. /package/dist/{shared → bin/shared}/cloudflare/domain-discovery.js +0 -0
  46. /package/dist/{shared → bin/shared}/cloudflare/domain-manager.js +0 -0
  47. /package/dist/{shared → bin/shared}/cloudflare/index.js +0 -0
  48. /package/dist/{shared → bin/shared}/cloudflare/ops.js +0 -0
  49. /package/dist/{shared → bin/shared}/config/ConfigurationManager.js +0 -0
  50. /package/dist/{shared → bin/shared}/config/cache.js +0 -0
  51. /package/dist/{shared → bin/shared}/config/command-config-manager.js +0 -0
  52. /package/dist/{shared → bin/shared}/config/index.js +0 -0
  53. /package/dist/{shared → bin/shared}/config/manager.js +0 -0
  54. /package/dist/{shared → bin/shared}/database/connection-manager.js +0 -0
  55. /package/dist/{shared → bin/shared}/database/index.js +0 -0
  56. /package/dist/{shared → bin/shared}/database/orchestrator.js +0 -0
  57. /package/dist/{deployment → bin/shared/deployment}/auditor.js +0 -0
  58. /package/dist/{shared → bin/shared}/deployment/index.js +0 -0
  59. /package/dist/{shared → bin/shared}/deployment/rollback-manager.js +0 -0
  60. /package/dist/{deployment → bin/shared/deployment}/validator.js +0 -0
  61. /package/dist/{shared → bin/shared}/index.js +0 -0
  62. /package/dist/{shared → bin/shared}/logging/Logger.js +0 -0
  63. /package/dist/{shared → bin/shared}/monitoring/health-checker.js +0 -0
  64. /package/dist/{shared → bin/shared}/monitoring/index.js +0 -0
  65. /package/dist/{shared → bin/shared}/monitoring/memory-manager.js +0 -0
  66. /package/dist/{shared → bin/shared}/monitoring/production-monitor.js +0 -0
  67. /package/dist/{deployment/testers → bin/shared/production-tester}/api-tester.js +0 -0
  68. /package/dist/{deployment/testers → bin/shared/production-tester}/auth-tester.js +0 -0
  69. /package/dist/{deployment/testers → bin/shared/production-tester}/core.js +0 -0
  70. /package/dist/{deployment/testers → bin/shared/production-tester}/database-tester.js +0 -0
  71. /package/dist/{deployment/testers → bin/shared/production-tester}/index.js +0 -0
  72. /package/dist/{deployment/testers → bin/shared/production-tester}/load-tester.js +0 -0
  73. /package/dist/{deployment/testers → bin/shared/production-tester}/performance-tester.js +0 -0
  74. /package/dist/{shared → bin/shared}/security/api-token-manager.js +0 -0
  75. /package/dist/{shared → bin/shared}/security/index.js +0 -0
  76. /package/dist/{shared → bin/shared}/security/secret-generator.js +0 -0
  77. /package/dist/{shared → bin/shared}/security/secure-token-manager.js +0 -0
  78. /package/dist/{shared → bin/shared}/utils/ErrorHandler.js +0 -0
  79. /package/dist/{shared → bin/shared}/utils/error-recovery.js +0 -0
  80. /package/dist/{shared → bin/shared}/utils/file-manager.js +0 -0
  81. /package/dist/{shared → bin/shared}/utils/formatters.js +0 -0
  82. /package/dist/{shared → bin/shared}/utils/graceful-shutdown-manager.js +0 -0
  83. /package/dist/{shared → bin/shared}/utils/index.js +0 -0
  84. /package/dist/{shared → bin/shared}/utils/interactive-prompts.js +0 -0
  85. /package/dist/{shared → bin/shared}/utils/interactive-utils.js +0 -0
  86. /package/dist/{shared → bin/shared}/utils/rate-limiter.js +0 -0
  87. /package/dist/{shared → bin/shared}/validation/ValidationRegistry.js +0 -0
@@ -0,0 +1,342 @@
1
+ /**
2
+ * ValidationManager - Coordinates comprehensive validation phases for deployment readiness
3
+ * Provides unified validation orchestration across configuration, database, and deployment components
4
+ */
5
+
6
+ import { validatePrerequisites, checkAuth, authenticate, workerExists } from '../../shared/config/cloudflare-config.js';
7
+ import { askYesNo } from '../../shared/utils/interactive-utils.js';
8
+ export class ValidationManager {
9
+ constructor(config, enterpriseModules = null) {
10
+ this.config = config;
11
+ this.enterpriseModules = enterpriseModules;
12
+ this.validationResults = {
13
+ prerequisites: null,
14
+ authentication: null,
15
+ configuration: null,
16
+ database: null,
17
+ deployment: null,
18
+ comprehensive: null
19
+ };
20
+ }
21
+
22
+ /**
23
+ * Execute all validation phases with comprehensive reporting
24
+ */
25
+ async executeComprehensiveValidation() {
26
+ console.log('\n🔍 Comprehensive Validation Suite');
27
+ console.log('=================================');
28
+ const phases = [{
29
+ name: 'Prerequisites',
30
+ method: 'validatePrerequisites'
31
+ }, {
32
+ name: 'Authentication',
33
+ method: 'validateAuthentication'
34
+ }, {
35
+ name: 'Configuration',
36
+ method: 'validateConfiguration'
37
+ }, {
38
+ name: 'Database',
39
+ method: 'validateDatabase'
40
+ }, {
41
+ name: 'Deployment Readiness',
42
+ method: 'validateDeploymentReadiness'
43
+ }];
44
+ const results = {
45
+ passed: [],
46
+ failed: [],
47
+ warnings: []
48
+ };
49
+ for (const phase of phases) {
50
+ try {
51
+ console.log(`\n🔍 Validating ${phase.name}...`);
52
+ const result = await this[phase.method]();
53
+ if (result.valid) {
54
+ results.passed.push(phase.name);
55
+ console.log(` ✅ ${phase.name}: Passed`);
56
+ if (result.warnings?.length > 0) {
57
+ results.warnings.push(...result.warnings.map(w => `${phase.name}: ${w}`));
58
+ }
59
+ } else {
60
+ results.failed.push({
61
+ phase: phase.name,
62
+ errors: result.errors
63
+ });
64
+ console.log(` ❌ ${phase.name}: Failed`);
65
+ result.errors?.forEach(error => console.log(` - ${error}`));
66
+ }
67
+ } catch (error) {
68
+ results.failed.push({
69
+ phase: phase.name,
70
+ errors: [error.message]
71
+ });
72
+ console.log(` ❌ ${phase.name}: Error - ${error.message}`);
73
+ }
74
+ }
75
+
76
+ // Generate comprehensive report
77
+ return this.generateValidationReport(results);
78
+ }
79
+
80
+ /**
81
+ * Validate system prerequisites (Node.js, wrangler CLI, etc.)
82
+ */
83
+ async validatePrerequisites() {
84
+ try {
85
+ const prereqs = await validatePrerequisites();
86
+ const errors = [];
87
+ for (const prereq of prereqs) {
88
+ if (prereq.status !== 'ok') {
89
+ errors.push(`${prereq.name}: ${prereq.error}`);
90
+ }
91
+ }
92
+ this.validationResults.prerequisites = {
93
+ valid: errors.length === 0,
94
+ errors,
95
+ details: prereqs
96
+ };
97
+ return this.validationResults.prerequisites;
98
+ } catch (error) {
99
+ this.validationResults.prerequisites = {
100
+ valid: false,
101
+ errors: [`Prerequisites check failed: ${error.message}`]
102
+ };
103
+ return this.validationResults.prerequisites;
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Validate Cloudflare authentication
109
+ */
110
+ async validateAuthentication() {
111
+ try {
112
+ const isAuthenticated = await checkAuth();
113
+ if (!isAuthenticated) {
114
+ this.validationResults.authentication = {
115
+ valid: false,
116
+ errors: ['Cloudflare authentication required'],
117
+ canAutoFix: true
118
+ };
119
+ } else {
120
+ this.validationResults.authentication = {
121
+ valid: true,
122
+ errors: []
123
+ };
124
+ }
125
+ return this.validationResults.authentication;
126
+ } catch (error) {
127
+ this.validationResults.authentication = {
128
+ valid: false,
129
+ errors: [`Authentication check failed: ${error.message}`]
130
+ };
131
+ return this.validationResults.authentication;
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Validate deployment configuration completeness and correctness
137
+ */
138
+ async validateConfiguration() {
139
+ const errors = [];
140
+ const warnings = [];
141
+
142
+ // Validate required configuration fields
143
+ if (!this.config.domain) {
144
+ errors.push('Domain name is required');
145
+ }
146
+ if (!this.config.worker?.name) {
147
+ errors.push('Worker name is required');
148
+ }
149
+ if (!this.config.environment) {
150
+ errors.push('Environment specification is required');
151
+ }
152
+
153
+ // Validate domain format
154
+ if (this.config.domain && !/^[a-z0-9.-]+\.[a-z]{2,}$/.test(this.config.domain)) {
155
+ errors.push('Invalid domain format');
156
+ }
157
+
158
+ // Check for existing worker deployment
159
+ try {
160
+ if (this.config.worker?.name) {
161
+ const exists = await workerExists(this.config.worker.name);
162
+ if (exists) {
163
+ warnings.push(`Worker '${this.config.worker.name}' already exists - deployment will update existing worker`);
164
+ }
165
+ }
166
+ } catch (error) {
167
+ warnings.push(`Could not check existing worker: ${error.message}`);
168
+ }
169
+
170
+ // Validate environment-specific configuration
171
+ if (this.config.environment === 'production' && !this.config.database?.enableBackup) {
172
+ warnings.push('Database backup not enabled for production environment');
173
+ }
174
+ this.validationResults.configuration = {
175
+ valid: errors.length === 0,
176
+ errors,
177
+ warnings
178
+ };
179
+ return this.validationResults.configuration;
180
+ }
181
+
182
+ /**
183
+ * Validate database configuration and connectivity
184
+ */
185
+ async validateDatabase() {
186
+ const errors = [];
187
+ const warnings = [];
188
+ try {
189
+ // Basic database configuration validation
190
+ if (!this.config.database?.name) {
191
+ errors.push('Database name is required');
192
+ }
193
+ if (this.config.database?.enableMigrations && !this.config.database?.migrationsPath) {
194
+ warnings.push('Migrations enabled but no migrations path specified');
195
+ }
196
+
197
+ // Enterprise database validation if available
198
+ if (this.enterpriseModules?.databaseOrchestrator) {
199
+ try {
200
+ const dbValidation = await this.enterpriseModules.databaseOrchestrator.validateDatabaseSetup(this.config.domain, this.config.environment);
201
+ if (!dbValidation.valid) {
202
+ errors.push(...dbValidation.errors);
203
+ }
204
+ if (dbValidation.warnings) {
205
+ warnings.push(...dbValidation.warnings);
206
+ }
207
+ } catch (error) {
208
+ warnings.push(`Enterprise database validation failed: ${error.message}`);
209
+ }
210
+ }
211
+ this.validationResults.database = {
212
+ valid: errors.length === 0,
213
+ errors,
214
+ warnings
215
+ };
216
+ return this.validationResults.database;
217
+ } catch (error) {
218
+ this.validationResults.database = {
219
+ valid: false,
220
+ errors: [`Database validation failed: ${error.message}`]
221
+ };
222
+ return this.validationResults.database;
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Validate deployment readiness using enterprise validation if available
228
+ */
229
+ async validateDeploymentReadiness() {
230
+ try {
231
+ // Use enterprise validator if available
232
+ if (this.enterpriseModules?.validator) {
233
+ const validation = await this.enterpriseModules.validator.validateDeploymentReadiness(this.config.domain, {
234
+ environment: this.config.environment,
235
+ validationLevel: this.config.deployment?.validationLevel || 'standard',
236
+ interactiveMode: false // Non-interactive for validation reporting
237
+ });
238
+ this.validationResults.deployment = validation;
239
+ return validation;
240
+ }
241
+
242
+ // Fallback validation for non-enterprise deployments
243
+ const errors = [];
244
+ const warnings = [];
245
+
246
+ // Basic deployment readiness checks
247
+ if (!this.config.worker?.script) {
248
+ errors.push('Worker script path not specified');
249
+ }
250
+ if (!this.config.deployment?.environment) {
251
+ warnings.push('Deployment environment not specified, using default');
252
+ }
253
+ this.validationResults.deployment = {
254
+ valid: errors.length === 0,
255
+ errors,
256
+ warnings
257
+ };
258
+ return this.validationResults.deployment;
259
+ } catch (error) {
260
+ this.validationResults.deployment = {
261
+ valid: false,
262
+ errors: [`Deployment readiness check failed: ${error.message}`]
263
+ };
264
+ return this.validationResults.deployment;
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Auto-fix authentication issues by prompting for authentication
270
+ */
271
+ async autoFixAuthentication() {
272
+ if (!this.validationResults.authentication?.canAutoFix) {
273
+ return false;
274
+ }
275
+ const shouldAuthenticate = await askYesNo('Cloudflare authentication required. Run authentication now?', 'y');
276
+ if (shouldAuthenticate) {
277
+ console.log('\n🔑 Please complete Cloudflare authentication...');
278
+ await authenticate();
279
+
280
+ // Re-validate authentication
281
+ await this.validateAuthentication();
282
+ return this.validationResults.authentication.valid;
283
+ }
284
+ return false;
285
+ }
286
+
287
+ /**
288
+ * Generate comprehensive validation report
289
+ */
290
+ generateValidationReport(results) {
291
+ const report = {
292
+ valid: results.failed.length === 0,
293
+ summary: {
294
+ passed: results.passed.length,
295
+ failed: results.failed.length,
296
+ warnings: results.warnings.length
297
+ },
298
+ phases: {
299
+ passed: results.passed,
300
+ failed: results.failed,
301
+ warnings: results.warnings
302
+ },
303
+ recommendation: null
304
+ };
305
+
306
+ // Generate recommendation based on results
307
+ if (report.valid) {
308
+ if (results.warnings.length > 0) {
309
+ report.recommendation = 'Deployment ready with warnings - review warnings before proceeding';
310
+ } else {
311
+ report.recommendation = 'All validation checks passed - deployment ready';
312
+ }
313
+ } else {
314
+ report.recommendation = 'Fix validation errors before proceeding with deployment';
315
+ }
316
+ return report;
317
+ }
318
+
319
+ /**
320
+ * Get validation results for specific phase
321
+ */
322
+ getValidationResults(phase = null) {
323
+ if (phase) {
324
+ return this.validationResults[phase];
325
+ }
326
+ return this.validationResults;
327
+ }
328
+
329
+ /**
330
+ * Reset validation state for fresh validation run
331
+ */
332
+ resetValidationState() {
333
+ this.validationResults = {
334
+ prerequisites: null,
335
+ authentication: null,
336
+ configuration: null,
337
+ database: null,
338
+ deployment: null,
339
+ comprehensive: null
340
+ };
341
+ }
342
+ }