@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,265 +0,0 @@
1
- /**
2
- * Clodo Framework - Service Creator
3
- * Programmatic API for creating services from templates
4
- */
5
-
6
- import { readdirSync, statSync, cpSync, rmSync } from 'fs';
7
- import { join, dirname, resolve } from 'path';
8
- import { fileURLToPath } from 'url';
9
- import { FrameworkConfig } from '../utils/framework-config.js';
10
- import { FileManager } from "../../dist/bin/shared/utils/file-manager.js";
11
- const SERVICE_TYPES = ['data-service', 'auth-service', 'content-service', 'api-gateway', 'generic'];
12
- export class ServiceCreator {
13
- constructor(options = {}) {
14
- this.fileManager = new FileManager({
15
- enableCache: true
16
- });
17
- const templatesDir = (() => {
18
- try {
19
- return join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'templates');
20
- } catch (error) {
21
- // Fallback for test environments - use current working directory
22
- return join(process.cwd(), 'templates');
23
- }
24
- })();
25
- this.templatesDir = options.templatesDir || templatesDir;
26
- this.serviceTypes = options.serviceTypes || SERVICE_TYPES;
27
-
28
- // Load framework configuration
29
- this.frameworkConfig = options.frameworkConfig || new FrameworkConfig();
30
- }
31
-
32
- /**
33
- * Validate service name according to framework conventions
34
- * @param {string} name - Service name to validate
35
- * @throws {Error} If validation fails
36
- */
37
- validateServiceName(name) {
38
- if (!/^[a-z0-9-]+$/.test(name)) {
39
- throw new Error('Service name must contain only lowercase letters, numbers, and hyphens');
40
- }
41
- if (name.length < 3) {
42
- throw new Error('Service name must be at least 3 characters long');
43
- }
44
- if (name.length > 50) {
45
- throw new Error('Service name must be no more than 50 characters long');
46
- }
47
- }
48
-
49
- /**
50
- * Validate service type
51
- * @param {string} type - Service type to validate
52
- * @throws {Error} If type is invalid
53
- */
54
- validateServiceType(type) {
55
- if (!this.serviceTypes.includes(type)) {
56
- throw new Error(`Invalid service type. Must be one of: ${this.serviceTypes.join(', ')}`);
57
- }
58
- }
59
-
60
- /**
61
- * Create a service from a template
62
- * @param {string} serviceName - Name of the service to create
63
- * @param {Object} options - Creation options
64
- * @param {string} options.type - Service type (default: 'generic')
65
- * @param {string} options.output - Output directory (default: current directory)
66
- * @param {boolean} options.force - Overwrite existing directory (default: false)
67
- * @param {Object} options.variables - Additional template variables
68
- * @returns {Object} Creation result with success status and metadata
69
- */
70
- async createService(serviceName, options = {}) {
71
- const config = {
72
- type: 'generic',
73
- output: process.cwd(),
74
- force: false,
75
- variables: {},
76
- ...options
77
- };
78
- try {
79
- // Validate inputs
80
- this.validateServiceName(serviceName);
81
- this.validateServiceType(config.type);
82
- const templateDir = join(this.templatesDir, config.type);
83
- const serviceDir = join(config.output, serviceName);
84
-
85
- // Check if template exists, fall back to generic if not
86
- let actualTemplateDir = templateDir;
87
- if (!this.fileManager.exists(templateDir)) {
88
- const genericTemplate = join(this.templatesDir, 'generic');
89
- if (this.fileManager.exists(genericTemplate)) {
90
- console.log(`⚠️ Template for '${config.type}' not found, using 'generic' template as fallback`);
91
- actualTemplateDir = genericTemplate;
92
- } else {
93
- throw new Error(`Template not found: ${templateDir}. Available templates: ${this.serviceTypes.join(', ')}`);
94
- }
95
- }
96
-
97
- // Check if service directory already exists
98
- if (this.fileManager.exists(serviceDir) && !config.force) {
99
- throw new Error(`Service directory already exists: ${serviceDir}. Use force option to overwrite.`);
100
- }
101
-
102
- // Create service directory and copy template
103
- this.fileManager.ensureDir(dirname(serviceDir));
104
-
105
- // If service directory exists (force mode), remove it first
106
- if (this.fileManager.exists(serviceDir) && config.force) {
107
- rmSync(serviceDir, {
108
- recursive: true,
109
- force: true
110
- });
111
- }
112
-
113
- // Copy template to service directory
114
- cpSync(actualTemplateDir, serviceDir, {
115
- recursive: true
116
- });
117
-
118
- // Load template defaults from config
119
- const templateDefaults = this.frameworkConfig.config?.templates?.defaults || {};
120
-
121
- // Prepare template variables
122
- const defaultVariables = {
123
- '{{SERVICE_NAME}}': serviceName,
124
- '{{SERVICE_TYPE}}': config.type,
125
- '{{SERVICE_DISPLAY_NAME}}': this.toTitleCase(serviceName.replace(/-/g, ' ')),
126
- '{{DOMAIN_NAME}}': config.domain || templateDefaults.DOMAIN_NAME || 'example.com',
127
- '{{WORKERS_DEV_DOMAIN}}': templateDefaults.WORKERS_DEV_DOMAIN || 'workers.dev',
128
- '{{CURRENT_DATE}}': new Date().toISOString().split('T')[0],
129
- '{{CURRENT_YEAR}}': new Date().getFullYear().toString(),
130
- '{{FRAMEWORK_VERSION}}': this.getFrameworkVersion()
131
- };
132
- const allVariables = {
133
- ...defaultVariables,
134
- ...config.variables
135
- };
136
-
137
- // Replace template variables
138
- this.replaceTemplateVariables(serviceDir, allVariables);
139
- return {
140
- success: true,
141
- serviceName,
142
- serviceType: config.type,
143
- serviceDir,
144
- templateDir,
145
- variables: allVariables
146
- };
147
- } catch (error) {
148
- return {
149
- success: false,
150
- serviceName,
151
- error: error.message
152
- };
153
- }
154
- }
155
-
156
- /**
157
- * Replace template variables in all files within a directory
158
- * @param {string} dir - Directory to process
159
- * @param {Object} variables - Variable mappings
160
- */
161
- replaceTemplateVariables(dir, variables) {
162
- const files = this.getAllFiles(dir);
163
- for (const file of files) {
164
- try {
165
- let content = this.fileManager.readFile(file, 'utf8');
166
- let modified = false;
167
- for (const [placeholder, value] of Object.entries(variables)) {
168
- if (content.includes(placeholder)) {
169
- content = content.replace(new RegExp(this.escapeRegExp(placeholder), 'g'), value);
170
- modified = true;
171
- }
172
- }
173
- if (modified) {
174
- this.fileManager.writeFile(file, content, 'utf8');
175
- }
176
- } catch (error) {
177
- // Skip binary files or files that can't be read
178
- if (error.code !== 'EISDIR') {
179
- // In programmatic usage, we might want to collect warnings
180
- // For now, we'll silently skip problematic files
181
- }
182
- }
183
- }
184
- }
185
-
186
- /**
187
- * Get all files in a directory recursively
188
- * @param {string} dir - Directory to traverse
189
- * @returns {string[]} Array of file paths
190
- */
191
- getAllFiles(dir) {
192
- const files = [];
193
- function traverse(currentDir) {
194
- const items = readdirSync(currentDir);
195
- for (const item of items) {
196
- const fullPath = join(currentDir, item);
197
- const stat = statSync(fullPath);
198
- if (stat.isDirectory()) {
199
- // Skip node_modules and other unwanted directories
200
- if (!['node_modules', '.git', 'dist', 'build'].includes(item)) {
201
- traverse(fullPath);
202
- }
203
- } else {
204
- files.push(fullPath);
205
- }
206
- }
207
- }
208
- traverse(dir);
209
- return files;
210
- }
211
-
212
- /**
213
- * Escape special regex characters
214
- * @param {string} string - String to escape
215
- * @returns {string} Escaped string
216
- */
217
- escapeRegExp(string) {
218
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
219
- }
220
-
221
- /**
222
- * Convert string to title case
223
- * @param {string} str - String to convert
224
- * @returns {string} Title case string
225
- */
226
- toTitleCase(str) {
227
- return str.split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ');
228
- }
229
-
230
- /**
231
- * Get framework version from package.json
232
- * @returns {string} Framework version
233
- */
234
- getFrameworkVersion() {
235
- try {
236
- const packageJson = JSON.parse(this.fileManager.readFile(join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json'), 'utf8'));
237
- return packageJson.version;
238
- } catch {
239
- return '1.0.0';
240
- }
241
- }
242
-
243
- /**
244
- * Get available service types
245
- * @returns {string[]} Array of available service types
246
- */
247
- getServiceTypes() {
248
- return [...this.serviceTypes];
249
- }
250
-
251
- /**
252
- * Check if a service type is available
253
- * @param {string} type - Service type to check
254
- * @returns {boolean} True if type is available
255
- */
256
- isServiceTypeAvailable(type) {
257
- return this.serviceTypes.includes(type);
258
- }
259
- }
260
-
261
- // Convenience function for quick service creation
262
- export async function createService(serviceName, options = {}) {
263
- const creator = new ServiceCreator();
264
- return await creator.createService(serviceName, options);
265
- }