@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,185 +0,0 @@
1
- /**
2
- * TemplateEngine - Handles template loading and rendering
3
- *
4
- * Provides centralized template management with variable replacement,
5
- * partial support, and future support for conditionals and loops.
6
- *
7
- * NOTE: This class uses Node.js filesystem APIs and is designed for
8
- * build-time usage during service generation, not runtime in Cloudflare Workers.
9
- */
10
- import { promises as fs } from 'fs';
11
- import path from 'path';
12
- export class TemplateEngine {
13
- /**
14
- * Create a new template engine instance
15
- * @param {Object} options - Configuration options
16
- * @param {string} options.templatesPath - Root path to templates directory
17
- * @param {string} options.partialsPath - Path to partials directory (optional)
18
- */
19
- constructor(options = {}) {
20
- this.templatesPath = options.templatesPath;
21
- this.partialsPath = options.partialsPath || (this.templatesPath ? path.join(this.templatesPath, 'partials') : null);
22
- this.cache = new Map();
23
- this.cacheEnabled = options.cache !== false; // Default to true
24
- }
25
-
26
- /**
27
- * Load a template file from the templates directory
28
- * @param {string} templateName - Template filename or path relative to templatesPath
29
- * @returns {Promise<string>} - Template content
30
- */
31
- async loadTemplate(templateName) {
32
- if (!this.templatesPath) {
33
- throw new Error('templatesPath not configured');
34
- }
35
-
36
- // Check cache first
37
- if (this.cacheEnabled && this.cache.has(templateName)) {
38
- return this.cache.get(templateName);
39
- }
40
- const templatePath = path.join(this.templatesPath, templateName);
41
- try {
42
- const content = await fs.readFile(templatePath, 'utf8');
43
-
44
- // Cache the template
45
- if (this.cacheEnabled) {
46
- this.cache.set(templateName, content);
47
- }
48
- return content;
49
- } catch (error) {
50
- if (error.code === 'ENOENT') {
51
- throw new Error(`Template not found: ${templateName} (looked in ${templatePath})`);
52
- }
53
- const errorMessage = error instanceof Error ? error.message : String(error);
54
- throw new Error(`Failed to load template '${templateName}': ${errorMessage}`);
55
- }
56
- }
57
-
58
- /**
59
- * Load a partial template
60
- * @param {string} partialName - Partial filename or path relative to partialsPath
61
- * @returns {Promise<string>} - Partial content
62
- */
63
- async loadPartial(partialName) {
64
- if (!this.partialsPath) {
65
- throw new Error('partialsPath not configured');
66
- }
67
- const cacheKey = `partial:${partialName}`;
68
-
69
- // Check cache first
70
- if (this.cacheEnabled && this.cache.has(cacheKey)) {
71
- return this.cache.get(cacheKey);
72
- }
73
- const partialPath = path.join(this.partialsPath, partialName);
74
- try {
75
- const content = await fs.readFile(partialPath, 'utf8');
76
-
77
- // Cache the partial
78
- if (this.cacheEnabled) {
79
- this.cache.set(cacheKey, content);
80
- }
81
- return content;
82
- } catch (error) {
83
- if (error.code === 'ENOENT') {
84
- throw new Error(`Partial not found: ${partialName} (looked in ${partialPath})`);
85
- }
86
- throw new Error(`Failed to load partial '${partialName}': ${error.message}`);
87
- }
88
- }
89
-
90
- /**
91
- * Render a template with variables
92
- * Replaces {{variable}} placeholders with values from the variables object
93
- * Supports dot notation: {{config.name}}
94
- * @param {string} template - Template string with {{placeholders}}
95
- * @param {Object} variables - Variable values to replace
96
- * @param {Object} options - Rendering options
97
- * @param {boolean} options.strict - Throw error on missing variables (default: false)
98
- * @returns {string} - Rendered template
99
- */
100
- render(template, variables = {}, options = {}) {
101
- if (typeof template !== 'string') {
102
- throw new Error('Template must be a string');
103
- }
104
- const strict = options.strict === true;
105
-
106
- // Replace {{variable}} placeholders
107
- let result = template.replace(/\{\{([^}]+)\}\}/g, (match, key) => {
108
- const trimmedKey = key.trim();
109
-
110
- // Get value using dot notation
111
- const value = this.getNestedValue(variables, trimmedKey);
112
- if (value === undefined || value === null) {
113
- if (strict) {
114
- throw new Error(`Missing variable: ${trimmedKey}`);
115
- }
116
- return match; // Keep placeholder if variable not found
117
- }
118
- return String(value);
119
- });
120
- return result;
121
- }
122
-
123
- /**
124
- * Render a template with partial support
125
- * Replaces {{> partialName}} with the content of the partial
126
- * @param {string} template - Template string
127
- * @param {Object} variables - Variable values
128
- * @param {Object} options - Rendering options
129
- * @returns {Promise<string>} - Rendered template
130
- */
131
- async renderWithPartials(template, variables = {}, options = {}) {
132
- // First, replace partials
133
- const partialRegex = /\{\{>\s*([^}]+)\}\}/g;
134
- const partialMatches = [...template.matchAll(partialRegex)];
135
- let result = template;
136
- for (const match of partialMatches) {
137
- const partialName = match[1].trim();
138
- const partial = await this.loadPartial(partialName);
139
- result = result.replace(match[0], partial);
140
- }
141
-
142
- // Then render variables
143
- return this.render(result, variables, options);
144
- }
145
-
146
- /**
147
- * Get a nested value from an object using dot notation
148
- * @param {Object} obj - Object to search
149
- * @param {string} path - Dot-notation path (e.g., 'config.server.port')
150
- * @returns {*} - Value or undefined
151
- */
152
- getNestedValue(obj, path) {
153
- if (!path) return obj;
154
- const keys = path.split('.');
155
- let value = obj;
156
- for (const key of keys) {
157
- if (value && typeof value === 'object' && key in value) {
158
- value = value[key];
159
- } else {
160
- return undefined;
161
- }
162
- }
163
- return value;
164
- }
165
-
166
- /**
167
- * Clear the template cache
168
- */
169
- clearCache() {
170
- this.cache.clear();
171
- }
172
-
173
- /**
174
- * Get cache statistics
175
- * @returns {Object} - Cache stats
176
- */
177
- getCacheStats() {
178
- return {
179
- size: this.cache.size,
180
- enabled: this.cacheEnabled,
181
- keys: Array.from(this.cache.keys())
182
- };
183
- }
184
- }
185
- export default TemplateEngine;
@@ -1,18 +0,0 @@
1
- /**
2
- * Generator Utilities - Centralized exports
3
- *
4
- * Provides template engine, file writer, and path resolver utilities
5
- * for use by all generators.
6
- */
7
-
8
- import { TemplateEngine } from './TemplateEngine.js';
9
- import { FileWriter } from './FileWriter.js';
10
- import { PathResolver } from './PathResolver.js';
11
- export { TemplateEngine } from './TemplateEngine.js';
12
- export { FileWriter } from './FileWriter.js';
13
- export { PathResolver } from './PathResolver.js';
14
- export default {
15
- TemplateEngine,
16
- FileWriter,
17
- PathResolver
18
- };
@@ -1,71 +0,0 @@
1
- /**
2
- * Confirmation Handler Module
3
- * Focused module for handling smart confirmations and derived values
4
- */
5
-
6
- import { ConfirmationEngine } from '../ConfirmationEngine.js';
7
- import { createPromptHandler } from '../../utils/prompt-handler.js';
8
- export class ConfirmationHandler {
9
- constructor(options = {}) {
10
- this.interactive = options.interactive !== false;
11
- this.promptHandler = createPromptHandler({
12
- interactive: this.interactive
13
- });
14
- this.confirmationEngine = new ConfirmationEngine({
15
- interactive: this.interactive
16
- });
17
- }
18
-
19
- /**
20
- * Generate and confirm derived values from core inputs
21
- */
22
- async generateAndConfirm(coreInputs) {
23
- return await this.confirmationEngine.generateAndConfirm(coreInputs);
24
- }
25
-
26
- /**
27
- * Generate smart defaults without interaction
28
- */
29
- generateSmartDefaults(coreInputs) {
30
- return this.confirmationEngine.generateSmartDefaults(coreInputs);
31
- }
32
-
33
- /**
34
- * Interactive confirmation of specific values
35
- */
36
- async confirmValue(field, currentValue, question) {
37
- if (!this.interactive) {
38
- return currentValue;
39
- }
40
- const confirmed = await this.promptHandler.confirm(`${question}\nCurrent value: ${currentValue}\nKeep this value?`, true);
41
- if (!confirmed) {
42
- return await this.promptHandler.prompt('Enter new value: ');
43
- }
44
- return currentValue;
45
- }
46
-
47
- /**
48
- * Confirm entire configuration
49
- */
50
- async confirmConfiguration(config) {
51
- if (!this.interactive) {
52
- return true;
53
- }
54
- console.log('\n📋 Configuration Summary:');
55
- Object.entries(config).forEach(([key, value]) => {
56
- // Mask sensitive values
57
- if (key.toLowerCase().includes('token') || key.toLowerCase().includes('secret')) {
58
- value = '*'.repeat(8) + value.slice(-4);
59
- }
60
- console.log(` ${key}: ${value}`);
61
- });
62
- return await this.promptHandler.confirm('\nProceed with this configuration?', true);
63
- }
64
-
65
- /**
66
- * Cleanup resources
67
- */
68
- async cleanup() {
69
- await this.promptHandler.close();
70
- }
71
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Generation Handler Module
3
- * Focused module for service generation and file creation
4
- */
5
-
6
- import { GenerationEngine } from '../GenerationEngine.js';
7
- export class GenerationHandler {
8
- constructor(options = {}) {
9
- this.outputPath = options.outputPath || '.';
10
- this.templatePath = options.templatePath || './templates';
11
- this.generationEngine = new GenerationEngine({
12
- outputDir: this.outputPath,
13
- templatesDir: this.templatePath
14
- });
15
- }
16
-
17
- /**
18
- * Generate complete service from inputs and confirmed values
19
- */
20
- async generateService(coreInputs, confirmedValues, options = {}) {
21
- const config = {
22
- outputPath: this.outputPath,
23
- ...options
24
- };
25
- return await this.generationEngine.generateService(coreInputs, confirmedValues, config);
26
- }
27
-
28
- /**
29
- * Generate specific component
30
- */
31
- async generateComponent(componentType, config, outputPath) {
32
- // Delegate to generation engine's specific methods
33
- switch (componentType) {
34
- case 'manifest':
35
- return this.generationEngine.createServiceManifest(config.coreInputs, config.confirmedValues, config.generatedFiles || []);
36
- case 'directory':
37
- return this.generationEngine.createDirectoryStructure(outputPath);
38
- default:
39
- throw new Error(`Unknown component type: ${componentType}`);
40
- }
41
- }
42
-
43
- /**
44
- * Validate generation prerequisites
45
- */
46
- async validatePrerequisites(coreInputs, confirmedValues) {
47
- const issues = [];
48
-
49
- // Check required inputs
50
- if (!coreInputs.serviceName) {
51
- issues.push('Service name is required');
52
- }
53
- if (!coreInputs.serviceType) {
54
- issues.push('Service type is required');
55
- }
56
-
57
- // Check output path permissions
58
- try {
59
- const fs = await import('fs/promises');
60
- await fs.access(this.outputPath);
61
- } catch (error) {
62
- issues.push(`Output path not accessible: ${this.outputPath}`);
63
- }
64
- return {
65
- valid: issues.length === 0,
66
- issues
67
- };
68
- }
69
-
70
- /**
71
- * Get generation progress information
72
- */
73
- getGenerationStatus() {
74
- return {
75
- outputPath: this.outputPath,
76
- templatePath: this.templatePath,
77
- ready: true
78
- };
79
- }
80
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * Input Handler Module
3
- * Focused module for collecting core service inputs
4
- */
5
-
6
- import { InputCollector } from '../InputCollector.js';
7
- import { createPromptHandler } from '../../utils/prompt-handler.js';
8
- export class InputHandler {
9
- constructor(options = {}) {
10
- this.interactive = options.interactive !== false;
11
- this.promptHandler = createPromptHandler({
12
- interactive: this.interactive
13
- });
14
- this.inputCollector = new InputCollector({
15
- interactive: this.interactive
16
- });
17
- }
18
-
19
- /**
20
- * Collect the 6 core inputs required for service creation
21
- */
22
- async collectCoreInputs() {
23
- return await this.inputCollector.collectCoreInputs();
24
- }
25
-
26
- /**
27
- * Validate core inputs without prompting
28
- */
29
- async validateCoreInputs(inputs) {
30
- return await this.inputCollector.validateCoreInputs(inputs);
31
- }
32
-
33
- /**
34
- * Interactive input collection with custom prompts
35
- */
36
- async promptForInput(field, question, defaultValue = '', required = false) {
37
- if (!this.interactive) {
38
- return defaultValue;
39
- }
40
- let answer;
41
- do {
42
- answer = await this.promptHandler.prompt(question);
43
- if (!answer && defaultValue) {
44
- answer = defaultValue;
45
- }
46
- if (required && !answer) {
47
- console.log('This field is required. Please provide a value.');
48
- }
49
- } while (required && !answer);
50
- return answer;
51
- }
52
-
53
- /**
54
- * Cleanup resources
55
- */
56
- async cleanup() {
57
- await this.promptHandler.close();
58
- }
59
- }
@@ -1,203 +0,0 @@
1
- /**
2
- * Validation Handler Module
3
- * Focused module for service validation and health checks
4
- */
5
-
6
- import fs from 'fs/promises';
7
- import path from 'path';
8
- export class ValidationHandler {
9
- constructor(options = {}) {
10
- this.strict = options.strict || false;
11
- }
12
-
13
- /**
14
- * Validate complete service configuration
15
- */
16
- async validateService(servicePath) {
17
- const issues = [];
18
-
19
- // Check for required files
20
- const requiredFiles = ['package.json', 'src/config/domains.js', 'src/worker/index.js', 'wrangler.toml'];
21
- for (const file of requiredFiles) {
22
- const filePath = path.join(servicePath, file);
23
- try {
24
- await fs.access(filePath);
25
- } catch {
26
- issues.push(`Missing required file: ${file}`);
27
- }
28
- }
29
-
30
- // Validate package.json
31
- const packageValidation = await this.validatePackageJson(servicePath);
32
- issues.push(...packageValidation.issues);
33
-
34
- // Validate domain configuration
35
- const domainValidation = await this.validateDomainConfig(servicePath);
36
- issues.push(...domainValidation.issues);
37
-
38
- // Validate wrangler configuration
39
- const wranglerValidation = await this.validateWranglerConfig(servicePath);
40
- issues.push(...wranglerValidation.issues);
41
- return {
42
- valid: issues.length === 0,
43
- issues,
44
- servicePath
45
- };
46
- }
47
-
48
- /**
49
- * Validate package.json structure
50
- */
51
- async validatePackageJson(servicePath) {
52
- const issues = [];
53
- const packageJsonPath = path.join(servicePath, 'package.json');
54
- try {
55
- const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
56
- if (!packageJson.name) {
57
- issues.push('package.json: Missing name field');
58
- }
59
- if (!packageJson.version) {
60
- issues.push('package.json: Missing version field');
61
- }
62
- if (!packageJson.type || packageJson.type !== 'module') {
63
- issues.push('package.json: Should use "type": "module" for ES modules');
64
- }
65
-
66
- // Check for required dependencies
67
- const requiredDeps = ['@tamyla/clodo-framework'];
68
- const deps = {
69
- ...packageJson.dependencies,
70
- ...packageJson.devDependencies
71
- };
72
- requiredDeps.forEach(dep => {
73
- if (!deps[dep]) {
74
- issues.push(`package.json: Missing required dependency: ${dep}`);
75
- }
76
- });
77
- } catch (error) {
78
- issues.push(`package.json: Invalid JSON format - ${error.message}`);
79
- }
80
- return {
81
- issues
82
- };
83
- }
84
-
85
- /**
86
- * Validate domain configuration
87
- */
88
- async validateDomainConfig(servicePath) {
89
- const issues = [];
90
- const domainConfigPath = path.join(servicePath, 'src/config/domains.js');
91
- try {
92
- const domainConfig = await fs.readFile(domainConfigPath, 'utf8');
93
-
94
- // Check for Clodo Framework integration
95
- if (!domainConfig.includes('createDomainConfigSchema')) {
96
- issues.push('Domain configuration missing Clodo Framework integration');
97
- }
98
-
99
- // Check for required exports
100
- if (!domainConfig.includes('export const domains')) {
101
- issues.push('Domain configuration missing domains export');
102
- }
103
-
104
- // Basic domain format validation
105
- const domainMatches = domainConfig.match(/domain:\s*['"]([^'"]+)['"]/g);
106
- if (domainMatches) {
107
- domainMatches.forEach(match => {
108
- const domain = match.match(/domain:\s*['"]([^'"]+)['"]/)[1];
109
- if (!/^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.[a-zA-Z]{2,}$/.test(domain)) {
110
- issues.push(`Invalid domain format: ${domain}`);
111
- }
112
- });
113
- }
114
- } catch (error) {
115
- issues.push(`Domain configuration: Cannot read file - ${error.message}`);
116
- }
117
- return {
118
- issues
119
- };
120
- }
121
-
122
- /**
123
- * Validate wrangler configuration
124
- */
125
- async validateWranglerConfig(servicePath) {
126
- const issues = [];
127
- const wranglerConfigPath = path.join(servicePath, 'wrangler.toml');
128
- try {
129
- const wranglerConfig = await fs.readFile(wranglerConfigPath, 'utf8');
130
-
131
- // Check for required fields
132
- if (!wranglerConfig.includes('name =')) {
133
- issues.push('wrangler.toml: Missing name field');
134
- }
135
- if (!wranglerConfig.includes('main =')) {
136
- issues.push('wrangler.toml: Missing main field');
137
- }
138
- if (!wranglerConfig.includes('compatibility_date =')) {
139
- issues.push('wrangler.toml: Missing compatibility_date');
140
- }
141
- } catch (error) {
142
- issues.push(`wrangler.toml: Cannot read file - ${error.message}`);
143
- }
144
- return {
145
- issues
146
- };
147
- }
148
-
149
- /**
150
- * Run comprehensive service diagnostics
151
- */
152
- async diagnoseService(servicePath) {
153
- const diagnosis = {
154
- errors: [],
155
- warnings: [],
156
- recommendations: []
157
- };
158
-
159
- // Basic validation
160
- const validation = await this.validateService(servicePath);
161
- validation.issues.forEach(issue => {
162
- if (issue.includes('Missing required')) {
163
- diagnosis.errors.push({
164
- message: issue,
165
- severity: 'high',
166
- suggestion: 'Run service initialization to create missing files'
167
- });
168
- } else if (issue.includes('Invalid')) {
169
- diagnosis.errors.push({
170
- message: issue,
171
- severity: 'medium',
172
- suggestion: 'Review and correct the configuration'
173
- });
174
- } else {
175
- diagnosis.warnings.push({
176
- message: issue,
177
- suggestion: 'Consider updating for better compatibility'
178
- });
179
- }
180
- });
181
-
182
- // Additional recommendations
183
- try {
184
- const packageJson = JSON.parse(await fs.readFile(path.join(servicePath, 'package.json'), 'utf8'));
185
- if (!packageJson.scripts || !packageJson.scripts.dev) {
186
- diagnosis.recommendations.push('Add development scripts for easier testing');
187
- }
188
- if (!packageJson.scripts || !packageJson.scripts.deploy) {
189
- diagnosis.recommendations.push('Add deployment scripts for easier publishing');
190
- }
191
- } catch (error) {
192
- // Package.json validation already handled above
193
- }
194
- return diagnosis;
195
- }
196
-
197
- /**
198
- * Set validation strictness
199
- */
200
- setStrict(enabled) {
201
- this.strict = enabled;
202
- }
203
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Clodo Framework - Service Management Module
3
- * Programmatic APIs for service creation and initialization
4
- */
5
-
6
- export { ServiceCreator, createService } from './ServiceCreator.js';
7
- export { ServiceInitializer, initializeService } from './ServiceInitializer.js';
8
-
9
- // Assessment capabilities moved to @tamyla/clodo-orchestration
10
- // - AssessmentCache
11
- // - CapabilityAssessmentEngine
12
- // - ServiceAutoDiscovery
13
- // - Data-bridge components
14
- // These are only available in the professional edition (clodo-orchestration)