@tamyla/clodo-framework 3.1.22 → 3.1.23
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.
- package/CHANGELOG.md +8 -0
- package/README.md +230 -1
- package/dist/cli/commands/assess.js +183 -0
- package/dist/cli/commands/create.js +77 -0
- package/dist/{bin → cli}/commands/deploy.js +8 -8
- package/dist/cli/commands/diagnose.js +83 -0
- package/dist/{bin → cli}/commands/helpers/deployment-verification.js +2 -3
- package/dist/{bin → cli}/commands/helpers/error-recovery.js +1 -1
- package/dist/{bin → cli}/commands/helpers/resource-detection.js +1 -1
- package/dist/cli/commands/helpers.js +110 -0
- package/dist/cli/commands/init-config.js +57 -0
- package/dist/cli/commands/update.js +75 -0
- package/dist/{bin → cli}/commands/validate.js +5 -5
- package/dist/cli/security-cli.js +118 -0
- package/dist/config/FeatureManager.js +6 -0
- package/dist/config/clodo-create.example.json +26 -0
- package/dist/config/clodo-deploy.example.json +41 -0
- package/dist/config/clodo-update.example.json +46 -0
- package/dist/config/clodo-validate.example.json +41 -0
- package/dist/config/customers/template/development.env.template +37 -0
- package/dist/config/customers/template/production.env.template +39 -0
- package/dist/config/customers/template/staging.env.template +37 -0
- package/dist/config/customers.js +625 -0
- package/dist/config/domain-examples/README.md +464 -0
- package/dist/config/domain-examples/environment-mapped.json +168 -0
- package/dist/config/domain-examples/multi-domain.json +144 -0
- package/dist/config/domain-examples/single-domain.json +50 -0
- package/dist/config/domains.js +186 -0
- package/dist/config/examples +12 -0
- package/dist/config/features.js +61 -0
- package/dist/config/index.js +6 -0
- package/dist/config/staging-deployment.json +60 -0
- package/dist/config/validation-config.json +347 -0
- package/dist/database/database-orchestrator.js +795 -0
- package/dist/database/index.js +4 -0
- package/dist/deployment/index.js +11 -0
- package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
- package/dist/deployment/orchestration/PortfolioOrchestrator.js +273 -0
- package/dist/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
- package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
- package/dist/deployment/orchestration/index.js +17 -0
- package/dist/deployment/rollback-manager.js +36 -0
- package/dist/deployment/wrangler-deployer.js +640 -0
- package/dist/handlers/GenericRouteHandler.js +532 -0
- package/dist/lib/database/deployment-db-manager.js +423 -0
- package/dist/lib/database/wrangler-d1-manager.js +685 -0
- package/dist/lib/deployment/modules/DeploymentConfiguration.js +395 -0
- package/dist/lib/deployment/modules/DeploymentOrchestrator.js +492 -0
- package/dist/lib/deployment/modules/EnvironmentManager.js +517 -0
- package/dist/lib/deployment/modules/MonitoringIntegration.js +560 -0
- package/dist/lib/deployment/modules/ValidationManager.js +342 -0
- package/dist/lib/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
- package/dist/lib/deployment/orchestration/EnterpriseOrchestrator.js +21 -0
- package/dist/lib/deployment/orchestration/PortfolioOrchestrator.js +273 -0
- package/dist/lib/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
- package/dist/lib/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
- package/dist/{bin → lib}/shared/cloudflare/domain-discovery.js +1 -1
- package/dist/{bin → lib}/shared/cloudflare/domain-manager.js +1 -1
- package/dist/{bin → lib}/shared/cloudflare/ops.js +4 -4
- package/dist/{bin → lib}/shared/config/command-config-manager.js +1 -1
- package/dist/{bin → lib}/shared/config/index.js +1 -1
- package/dist/{bin → lib}/shared/deployment/credential-collector.js +1 -1
- package/dist/lib/shared/deployment/index.js +10 -0
- package/dist/{bin → lib}/shared/deployment/rollback-manager.js +1 -1
- package/dist/{bin → lib}/shared/deployment/utilities/d1-error-recovery.js +1 -1
- package/dist/{bin → lib}/shared/deployment/validator.js +1 -1
- package/dist/{bin → lib}/shared/deployment/workflows/interactive-database-workflow.js +1 -1
- package/dist/{bin → lib}/shared/monitoring/health-checker.js +2 -2
- package/dist/{bin → lib}/shared/routing/domain-router.js +1 -1
- package/dist/{bin → lib}/shared/validation/ValidationRegistry.js +1 -1
- package/dist/migration/MigrationAdapters.js +608 -0
- package/dist/modules/ModuleManager.js +668 -0
- package/dist/modules/security.js +96 -0
- package/dist/orchestration/cross-domain-coordinator.js +1083 -0
- package/dist/orchestration/index.js +5 -0
- package/dist/orchestration/modules/DeploymentCoordinator.js +368 -0
- package/dist/orchestration/modules/DomainResolver.js +198 -0
- package/dist/orchestration/modules/StateManager.js +332 -0
- package/dist/orchestration/multi-domain-orchestrator.js +765 -0
- package/dist/routing/EnhancedRouter.js +158 -0
- package/dist/schema/SchemaManager.js +778 -0
- package/dist/security/index.js +2 -2
- package/dist/service-management/ConfirmationEngine.js +412 -0
- package/dist/service-management/ErrorTracker.js +299 -0
- package/dist/service-management/GenerationEngine.js +447 -0
- package/dist/service-management/InputCollector.js +619 -0
- package/dist/service-management/ServiceCreator.js +21 -0
- package/dist/service-management/ServiceOrchestrator.js +631 -0
- package/dist/service-management/generators/BaseGenerator.js +233 -0
- package/dist/service-management/generators/GeneratorRegistry.js +254 -0
- package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +87 -0
- package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +106 -0
- package/dist/service-management/generators/code/ServiceHandlersGenerator.js +235 -0
- package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +116 -0
- package/dist/service-management/generators/code/ServiceUtilsGenerator.js +246 -0
- package/dist/service-management/generators/code/WorkerIndexGenerator.js +143 -0
- package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +101 -0
- package/dist/service-management/generators/config/DomainsConfigGenerator.js +175 -0
- package/dist/service-management/generators/config/EnvExampleGenerator.js +178 -0
- package/dist/service-management/generators/config/ProductionEnvGenerator.js +97 -0
- package/dist/service-management/generators/config/StagingEnvGenerator.js +97 -0
- package/dist/service-management/generators/config/WranglerTomlGenerator.js +238 -0
- package/dist/service-management/generators/core/PackageJsonGenerator.js +243 -0
- package/dist/service-management/generators/core/SiteConfigGenerator.js +115 -0
- package/dist/service-management/generators/documentation/ApiDocsGenerator.js +331 -0
- package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +294 -0
- package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +244 -0
- package/dist/service-management/generators/documentation/ReadmeGenerator.js +196 -0
- package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +190 -0
- package/dist/service-management/generators/scripts/DeployScriptGenerator.js +123 -0
- package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +101 -0
- package/dist/service-management/generators/scripts/SetupScriptGenerator.js +88 -0
- package/dist/service-management/generators/service-types/StaticSiteGenerator.js +342 -0
- package/dist/service-management/generators/testing/EslintConfigGenerator.js +85 -0
- package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +237 -0
- package/dist/service-management/generators/testing/JestConfigGenerator.js +72 -0
- package/dist/service-management/generators/testing/UnitTestsGenerator.js +277 -0
- package/dist/service-management/generators/tooling/DockerComposeGenerator.js +71 -0
- package/dist/service-management/generators/tooling/GitignoreGenerator.js +143 -0
- package/dist/service-management/generators/utils/FileWriter.js +179 -0
- package/dist/service-management/generators/utils/PathResolver.js +157 -0
- package/dist/service-management/generators/utils/ServiceManifestGenerator.js +111 -0
- package/dist/service-management/generators/utils/TemplateEngine.js +185 -0
- package/dist/service-management/generators/utils/index.js +18 -0
- package/dist/service-management/handlers/ConfirmationHandler.js +71 -0
- package/dist/service-management/handlers/GenerationHandler.js +80 -0
- package/dist/service-management/handlers/InputHandler.js +59 -0
- package/dist/service-management/handlers/ValidationHandler.js +203 -0
- package/dist/service-management/index.js +14 -0
- package/dist/service-management/routing/DomainRouteMapper.js +311 -0
- package/dist/service-management/routing/RouteGenerator.js +266 -0
- package/dist/service-management/routing/WranglerRoutesBuilder.js +273 -0
- package/dist/service-management/routing/index.js +14 -0
- package/dist/service-management/services/DirectoryStructureService.js +56 -0
- package/dist/service-management/services/GenerationCoordinator.js +208 -0
- package/dist/service-management/services/GeneratorRegistry.js +174 -0
- package/dist/services/GenericDataService.js +501 -0
- package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +286 -0
- package/dist/ui-structures/concepts/service-lifecycle-management.md +150 -0
- package/dist/ui-structures/concepts/service-manifest-guide.md +309 -0
- package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +231 -0
- package/dist/ui-structures/creation/automated-generation-ui.json +246 -0
- package/dist/ui-structures/creation/core-inputs-ui.json +217 -0
- package/dist/ui-structures/creation/smart-confirmable-ui.json +451 -0
- package/dist/ui-structures/reference/absolutely-required-inputs.json +315 -0
- package/dist/ui-structures/reference/service-manifest-template.json +342 -0
- package/dist/utils/cloudflare/ops.js +1 -1
- package/dist/utils/file-manager.js +1 -1
- package/dist/utils/formatters.js +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/version/VersionDetector.js +813 -0
- package/dist/worker/index.js +4 -0
- package/dist/worker/integration.js +351 -0
- package/package.json +7 -15
- package/dist/bin/security/security-cli.js +0 -108
- package/dist/bin/shared/deployment/index.js +0 -10
- /package/dist/{bin → cli}/clodo-service.js +0 -0
- /package/dist/{bin → cli}/commands/helpers/deployment-ui.js +0 -0
- /package/dist/{bin → lib}/shared/cache/configuration-cache.js +0 -0
- /package/dist/{bin → lib}/shared/cloudflare/index.js +0 -0
- /package/dist/{bin → lib}/shared/config/ConfigurationManager.js +0 -0
- /package/dist/{bin → lib}/shared/config/cache.js +0 -0
- /package/dist/{bin → lib}/shared/config/cloudflare-service-validator.js +0 -0
- /package/dist/{bin → lib}/shared/config/manager.js +0 -0
- /package/dist/{bin → lib}/shared/config/manifest-loader.js +0 -0
- /package/dist/{bin → lib}/shared/database/connection-manager.js +0 -0
- /package/dist/{bin → lib}/shared/database/index.js +0 -0
- /package/dist/{bin → lib}/shared/database/orchestrator.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/auditor.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/deployment-summary.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-confirmation.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-domain-info-gatherer.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-secret-workflow.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-testing-workflow.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-validation.js +0 -0
- /package/dist/{bin → lib}/shared/error-handling/error-classifier.js +0 -0
- /package/dist/{bin → lib}/shared/index.js +0 -0
- /package/dist/{bin → lib}/shared/logging/Logger.js +0 -0
- /package/dist/{bin → lib}/shared/monitoring/index.js +0 -0
- /package/dist/{bin → lib}/shared/monitoring/memory-manager.js +0 -0
- /package/dist/{bin → lib}/shared/monitoring/production-monitor.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/api-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/auth-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/core.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/database-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/index.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/load-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/performance-tester.js +0 -0
- /package/dist/{bin → lib}/shared/security/api-token-manager.js +0 -0
- /package/dist/{bin → lib}/shared/security/index.js +0 -0
- /package/dist/{bin → lib}/shared/security/secret-generator.js +0 -0
- /package/dist/{bin → lib}/shared/security/secure-token-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/ErrorHandler.js +0 -0
- /package/dist/{bin → lib}/shared/utils/cli-options.js +0 -0
- /package/dist/{bin → lib}/shared/utils/config-loader.js +0 -0
- /package/dist/{bin → lib}/shared/utils/deployment-validator.js +0 -0
- /package/dist/{bin → lib}/shared/utils/error-recovery.js +0 -0
- /package/dist/{bin → lib}/shared/utils/file-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/formatters.js +0 -0
- /package/dist/{bin → lib}/shared/utils/graceful-shutdown-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/index.js +0 -0
- /package/dist/{bin → lib}/shared/utils/interactive-prompts.js +0 -0
- /package/dist/{bin → lib}/shared/utils/interactive-utils.js +0 -0
- /package/dist/{bin → lib}/shared/utils/output-formatter.js +0 -0
- /package/dist/{bin → lib}/shared/utils/progress-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/progress-spinner.js +0 -0
- /package/dist/{bin → lib}/shared/utils/rate-limiter.js +0 -0
- /package/dist/{bin → lib}/shared/utils/sensitive-redactor.js +0 -0
package/dist/security/index.js
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
import { ConfigurationValidator } from './ConfigurationValidator.js';
|
|
7
7
|
// DeploymentManager removed - replaced by MultiDomainOrchestrator + WranglerConfigManager
|
|
8
8
|
import { SecretGenerator } from './SecretGenerator.js';
|
|
9
|
-
import { ErrorHandler } from '
|
|
9
|
+
import { ErrorHandler } from '../lib/shared/utils/index.js';
|
|
10
10
|
// InteractiveDeploymentConfigurator removed - replaced by InputCollector
|
|
11
11
|
|
|
12
12
|
export { ConfigurationValidator } from './ConfigurationValidator.js';
|
|
13
13
|
// export { DeploymentManager } - DEPRECATED: Use MultiDomainOrchestrator instead
|
|
14
14
|
export { SecretGenerator } from './SecretGenerator.js';
|
|
15
|
-
export { ErrorHandler } from '
|
|
15
|
+
export { ErrorHandler } from '../lib/shared/utils/index.js';
|
|
16
16
|
// export { InteractiveDeploymentConfigurator } - DEPRECATED: Use InputCollector instead
|
|
17
17
|
|
|
18
18
|
// Re-export patterns and rules for advanced usage
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmationEngine - Tier 2: Smart Confirmations
|
|
3
|
+
*
|
|
4
|
+
* Takes the 6 core inputs and generates 15 derived confirmation values
|
|
5
|
+
* that users can review and modify before service generation.
|
|
6
|
+
*
|
|
7
|
+
* Core Inputs (6):
|
|
8
|
+
* 1. Service Name
|
|
9
|
+
* 2. Service Type
|
|
10
|
+
* 3. Domain Name
|
|
11
|
+
* 4. Cloudflare Token
|
|
12
|
+
* 5. Cloudflare Account ID
|
|
13
|
+
* 6. Cloudflare Zone ID
|
|
14
|
+
* 7. Environment
|
|
15
|
+
*
|
|
16
|
+
* Derived Confirmations (15):
|
|
17
|
+
* 1. Display Name
|
|
18
|
+
* 2. Description
|
|
19
|
+
* 3. Version
|
|
20
|
+
* 4. Author
|
|
21
|
+
* 5. Production URL
|
|
22
|
+
* 6. Staging URL
|
|
23
|
+
* 7. Development URL
|
|
24
|
+
* 8. Features Configuration
|
|
25
|
+
* 9. Database Name
|
|
26
|
+
* 10. Worker Name
|
|
27
|
+
* 11. Package Name
|
|
28
|
+
* 12. Git Repository URL
|
|
29
|
+
* 13. Documentation URL
|
|
30
|
+
* 14. Health Check Path
|
|
31
|
+
* 15. API Base Path
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { createInterface } from 'readline';
|
|
35
|
+
import chalk from 'chalk';
|
|
36
|
+
import { validateServiceName, validateDomainName } from '../utils/validation.js';
|
|
37
|
+
import { NameFormatters, UrlFormatters, ResourceFormatters } from '../lib/shared/utils/formatters.js';
|
|
38
|
+
export class ConfirmationEngine {
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
this.interactive = options.interactive !== false;
|
|
41
|
+
this.rl = this.interactive ? createInterface({
|
|
42
|
+
input: process.stdin,
|
|
43
|
+
output: process.stdout
|
|
44
|
+
}) : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generate and confirm all derived values from core inputs
|
|
49
|
+
*/
|
|
50
|
+
async generateAndConfirm(coreInputs) {
|
|
51
|
+
console.log(chalk.cyan('\n🔍 Tier 2: Smart Confirmations'));
|
|
52
|
+
console.log(chalk.white('Reviewing and confirming 15 derived configuration values...\n'));
|
|
53
|
+
|
|
54
|
+
// Generate smart defaults
|
|
55
|
+
const derivedValues = this.generateSmartDefaults(coreInputs);
|
|
56
|
+
|
|
57
|
+
// Interactive confirmation if enabled
|
|
58
|
+
if (this.interactive) {
|
|
59
|
+
return await this.interactiveConfirmation(derivedValues, coreInputs);
|
|
60
|
+
} else {
|
|
61
|
+
console.log(chalk.gray('⚠️ Non-interactive mode: Using generated defaults'));
|
|
62
|
+
return derivedValues;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Generate smart defaults for all 15 confirmation values
|
|
68
|
+
*/
|
|
69
|
+
generateSmartDefaults(coreInputs) {
|
|
70
|
+
const {
|
|
71
|
+
serviceName,
|
|
72
|
+
serviceType,
|
|
73
|
+
domainName,
|
|
74
|
+
environment
|
|
75
|
+
} = coreInputs;
|
|
76
|
+
return {
|
|
77
|
+
// 1. Display Name - Convert kebab-case to Title Case
|
|
78
|
+
displayName: this.generateDisplayName(serviceName),
|
|
79
|
+
// 2. Description - Based on service type
|
|
80
|
+
description: this.generateDescription(serviceType),
|
|
81
|
+
// 3. Version - Standard semantic versioning
|
|
82
|
+
version: '1.0.0',
|
|
83
|
+
// 4. Author - Default framework author
|
|
84
|
+
author: 'Clodo Framework',
|
|
85
|
+
// 5-7. URLs - Derived from domain and service name
|
|
86
|
+
productionUrl: UrlFormatters.buildProductionUrl(serviceName, domainName),
|
|
87
|
+
stagingUrl: UrlFormatters.buildStagingUrl(serviceName, domainName),
|
|
88
|
+
developmentUrl: UrlFormatters.buildDevUrl(serviceName, domainName),
|
|
89
|
+
// 8. Features - Based on service type
|
|
90
|
+
features: this.generateFeaturesForType(serviceType),
|
|
91
|
+
// 9. Database Name - Cloudflare D1 naming
|
|
92
|
+
databaseName: ResourceFormatters.databaseName(serviceName),
|
|
93
|
+
// 10. Worker Name - Cloudflare Worker naming
|
|
94
|
+
workerName: ResourceFormatters.workerName(serviceName),
|
|
95
|
+
// 11. Package Name - NPM package naming
|
|
96
|
+
packageName: ResourceFormatters.packageName(serviceName),
|
|
97
|
+
// 12. Git Repository URL - GitHub naming
|
|
98
|
+
gitRepositoryUrl: `https://github.com/tamylaa/${serviceName}`,
|
|
99
|
+
// 13. Documentation URL - Based on domain
|
|
100
|
+
documentationUrl: `https://docs.${domainName}`,
|
|
101
|
+
// 14. Health Check Path - Standard health endpoint
|
|
102
|
+
healthCheckPath: '/health',
|
|
103
|
+
// 15. API Base Path - Service-specific API path
|
|
104
|
+
apiBasePath: `/api/v1/${serviceName.replace('-', '/')}`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Interactive confirmation process
|
|
110
|
+
*/
|
|
111
|
+
async interactiveConfirmation(derivedValues, coreInputs) {
|
|
112
|
+
console.log(chalk.cyan('Please review and confirm the following derived values:'));
|
|
113
|
+
console.log(chalk.gray('Press Enter to accept default, or type new value to modify.\n'));
|
|
114
|
+
const confirmed = {
|
|
115
|
+
...derivedValues
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Group confirmations for better UX
|
|
119
|
+
const confirmationGroups = [{
|
|
120
|
+
title: '📋 Basic Information',
|
|
121
|
+
items: [{
|
|
122
|
+
key: 'displayName',
|
|
123
|
+
label: 'Display Name',
|
|
124
|
+
description: 'Human-readable service name'
|
|
125
|
+
}, {
|
|
126
|
+
key: 'description',
|
|
127
|
+
label: 'Description',
|
|
128
|
+
description: 'Service description'
|
|
129
|
+
}, {
|
|
130
|
+
key: 'version',
|
|
131
|
+
label: 'Version',
|
|
132
|
+
description: 'Initial version number'
|
|
133
|
+
}, {
|
|
134
|
+
key: 'author',
|
|
135
|
+
label: 'Author',
|
|
136
|
+
description: 'Service author/maintainer'
|
|
137
|
+
}]
|
|
138
|
+
}, {
|
|
139
|
+
title: '🌐 URLs & Endpoints',
|
|
140
|
+
items: [{
|
|
141
|
+
key: 'productionUrl',
|
|
142
|
+
label: 'Production URL',
|
|
143
|
+
description: 'Live production endpoint'
|
|
144
|
+
}, {
|
|
145
|
+
key: 'stagingUrl',
|
|
146
|
+
label: 'Staging URL',
|
|
147
|
+
description: 'Staging environment endpoint'
|
|
148
|
+
}, {
|
|
149
|
+
key: 'developmentUrl',
|
|
150
|
+
label: 'Development URL',
|
|
151
|
+
description: 'Development environment endpoint'
|
|
152
|
+
}, {
|
|
153
|
+
key: 'documentationUrl',
|
|
154
|
+
label: 'Documentation URL',
|
|
155
|
+
description: 'API documentation location'
|
|
156
|
+
}]
|
|
157
|
+
}, {
|
|
158
|
+
title: '⚙️ Service Configuration',
|
|
159
|
+
items: [{
|
|
160
|
+
key: 'databaseName',
|
|
161
|
+
label: 'Database Name',
|
|
162
|
+
description: 'Cloudflare D1 database name'
|
|
163
|
+
}, {
|
|
164
|
+
key: 'workerName',
|
|
165
|
+
label: 'Worker Name',
|
|
166
|
+
description: 'Cloudflare Worker script name'
|
|
167
|
+
}, {
|
|
168
|
+
key: 'packageName',
|
|
169
|
+
label: 'Package Name',
|
|
170
|
+
description: 'NPM package identifier'
|
|
171
|
+
}, {
|
|
172
|
+
key: 'healthCheckPath',
|
|
173
|
+
label: 'Health Check Path',
|
|
174
|
+
description: 'Health endpoint path'
|
|
175
|
+
}, {
|
|
176
|
+
key: 'apiBasePath',
|
|
177
|
+
label: 'API Base Path',
|
|
178
|
+
description: 'Base path for API endpoints'
|
|
179
|
+
}]
|
|
180
|
+
}];
|
|
181
|
+
for (const group of confirmationGroups) {
|
|
182
|
+
console.log(chalk.yellow(`\n${group.title}`));
|
|
183
|
+
console.log(chalk.gray('─'.repeat(50)));
|
|
184
|
+
for (const item of group.items) {
|
|
185
|
+
const currentValue = confirmed[item.key];
|
|
186
|
+
const newValue = await this.confirmValue(`${item.label} (${item.description})`, currentValue);
|
|
187
|
+
if (newValue !== null && newValue !== currentValue) {
|
|
188
|
+
// Validate the new value if it's a URL or name
|
|
189
|
+
if (this.validateConfirmationValue(item.key, newValue)) {
|
|
190
|
+
confirmed[item.key] = newValue;
|
|
191
|
+
console.log(chalk.green(`✓ Updated: ${newValue}`));
|
|
192
|
+
} else {
|
|
193
|
+
console.log(chalk.red(`✗ Invalid value, keeping: ${currentValue}`));
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
console.log(chalk.gray(`✓ Keeping: ${currentValue}`));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Special handling for features
|
|
202
|
+
console.log(chalk.yellow('\n🔧 Feature Configuration'));
|
|
203
|
+
console.log(chalk.gray('─'.repeat(50)));
|
|
204
|
+
console.log(chalk.white('Current features for service type:'), chalk.cyan(coreInputs.serviceType));
|
|
205
|
+
this.displayFeatures(confirmed.features);
|
|
206
|
+
const modifyFeatures = await this.confirmYesNo('\nWould you like to modify feature flags?', false);
|
|
207
|
+
if (modifyFeatures) {
|
|
208
|
+
confirmed.features = await this.interactiveFeatureConfiguration(confirmed.features, coreInputs.serviceType);
|
|
209
|
+
}
|
|
210
|
+
return confirmed;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Confirm a single value with user
|
|
215
|
+
*/
|
|
216
|
+
async confirmValue(prompt, currentValue) {
|
|
217
|
+
return new Promise(resolve => {
|
|
218
|
+
const displayValue = typeof currentValue === 'object' ? JSON.stringify(currentValue, null, 2) : String(currentValue);
|
|
219
|
+
this.rl.question(`${prompt} [${displayValue}]: `, answer => {
|
|
220
|
+
resolve(answer.trim() || null);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Confirm yes/no question
|
|
227
|
+
*/
|
|
228
|
+
async confirmYesNo(question, defaultValue = true) {
|
|
229
|
+
return new Promise(resolve => {
|
|
230
|
+
const defaultText = defaultValue ? '[Y/n]' : '[y/N]';
|
|
231
|
+
this.rl.question(`${question} ${defaultText}: `, answer => {
|
|
232
|
+
const normalized = answer.toLowerCase().trim();
|
|
233
|
+
if (normalized === '') {
|
|
234
|
+
resolve(defaultValue);
|
|
235
|
+
} else if (normalized === 'y' || normalized === 'yes') {
|
|
236
|
+
resolve(true);
|
|
237
|
+
} else if (normalized === 'n' || normalized === 'no') {
|
|
238
|
+
resolve(false);
|
|
239
|
+
} else {
|
|
240
|
+
resolve(defaultValue);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Interactive feature configuration
|
|
248
|
+
*/
|
|
249
|
+
async interactiveFeatureConfiguration(currentFeatures, serviceType) {
|
|
250
|
+
console.log(chalk.cyan('\nFeature Configuration:'));
|
|
251
|
+
console.log(chalk.white('Type feature name to toggle, or "done" to finish'));
|
|
252
|
+
const features = {
|
|
253
|
+
...currentFeatures
|
|
254
|
+
};
|
|
255
|
+
for (;;) {
|
|
256
|
+
console.log(chalk.gray('\nCurrent features:'));
|
|
257
|
+
this.displayFeatures(features);
|
|
258
|
+
const input = await new Promise(resolve => {
|
|
259
|
+
this.rl.question('Feature to toggle (or "done"): ', resolve);
|
|
260
|
+
});
|
|
261
|
+
const feature = input.trim().toLowerCase();
|
|
262
|
+
if (feature === 'done' || feature === '') {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
if (Object.prototype.hasOwnProperty.call(features, feature)) {
|
|
266
|
+
features[feature] = !features[feature];
|
|
267
|
+
console.log(chalk.green(`✓ ${feature}: ${features[feature] ? 'ENABLED' : 'DISABLED'}`));
|
|
268
|
+
} else {
|
|
269
|
+
console.log(chalk.red(`✗ Unknown feature: ${feature}`));
|
|
270
|
+
console.log(chalk.gray('Available features:'), Object.keys(features).join(', '));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return features;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Display features in a nice format
|
|
278
|
+
*/
|
|
279
|
+
displayFeatures(features) {
|
|
280
|
+
const enabled = Object.entries(features).filter(([, enabled]) => enabled).map(([name]) => name);
|
|
281
|
+
const disabled = Object.entries(features).filter(([, enabled]) => !enabled).map(([name]) => name);
|
|
282
|
+
if (enabled.length > 0) {
|
|
283
|
+
console.log(chalk.green(' Enabled:'), enabled.join(', '));
|
|
284
|
+
}
|
|
285
|
+
if (disabled.length > 0) {
|
|
286
|
+
console.log(chalk.gray(' Disabled:'), disabled.join(', '));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Validate confirmation value based on type
|
|
292
|
+
*/
|
|
293
|
+
validateConfirmationValue(key, value) {
|
|
294
|
+
switch (key) {
|
|
295
|
+
case 'displayName':
|
|
296
|
+
return value.length > 0 && value.length <= 100;
|
|
297
|
+
case 'description':
|
|
298
|
+
return value.length > 0 && value.length <= 500;
|
|
299
|
+
case 'version':
|
|
300
|
+
return /^\d+\.\d+\.\d+$/.test(value);
|
|
301
|
+
case 'productionUrl':
|
|
302
|
+
case 'stagingUrl':
|
|
303
|
+
case 'developmentUrl':
|
|
304
|
+
case 'documentationUrl':
|
|
305
|
+
return /^https?:\/\/.+/.test(value);
|
|
306
|
+
case 'databaseName':
|
|
307
|
+
case 'workerName':
|
|
308
|
+
return validateServiceName(value);
|
|
309
|
+
case 'packageName':
|
|
310
|
+
return /^@?[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/.test(value);
|
|
311
|
+
case 'healthCheckPath':
|
|
312
|
+
case 'apiBasePath':
|
|
313
|
+
return value.startsWith('/');
|
|
314
|
+
default:
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Generate display name from service name
|
|
321
|
+
*/
|
|
322
|
+
generateDisplayName(serviceName) {
|
|
323
|
+
return NameFormatters.toDisplayName(serviceName);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Generate description based on service type
|
|
328
|
+
*/
|
|
329
|
+
generateDescription(serviceType) {
|
|
330
|
+
const descriptions = {
|
|
331
|
+
'data-service': 'A comprehensive data service providing CRUD operations, search, filtering, and pagination capabilities',
|
|
332
|
+
'auth-service': 'Authentication and authorization service with user management and security features',
|
|
333
|
+
'content-service': 'Content management service with file storage, search, and delivery capabilities',
|
|
334
|
+
'api-gateway': 'API gateway providing routing, rate limiting, authentication, and monitoring',
|
|
335
|
+
'generic': 'A Clodo Framework service providing core functionality and extensibility'
|
|
336
|
+
};
|
|
337
|
+
return descriptions[serviceType] || descriptions.generic;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Generate features based on service type
|
|
342
|
+
*/
|
|
343
|
+
generateFeaturesForType(serviceType) {
|
|
344
|
+
const baseFeatures = {
|
|
345
|
+
logging: true,
|
|
346
|
+
monitoring: true,
|
|
347
|
+
errorReporting: true,
|
|
348
|
+
metrics: true,
|
|
349
|
+
healthChecks: true
|
|
350
|
+
};
|
|
351
|
+
const typeSpecificFeatures = {
|
|
352
|
+
'data-service': {
|
|
353
|
+
authentication: true,
|
|
354
|
+
authorization: true,
|
|
355
|
+
database: true,
|
|
356
|
+
search: true,
|
|
357
|
+
filtering: true,
|
|
358
|
+
pagination: true,
|
|
359
|
+
caching: true,
|
|
360
|
+
backup: true
|
|
361
|
+
},
|
|
362
|
+
'auth-service': {
|
|
363
|
+
authentication: true,
|
|
364
|
+
authorization: true,
|
|
365
|
+
userProfiles: true,
|
|
366
|
+
emailNotifications: true,
|
|
367
|
+
magicLinkAuth: true,
|
|
368
|
+
passwordReset: true,
|
|
369
|
+
sessionManagement: true,
|
|
370
|
+
rateLimiting: true
|
|
371
|
+
},
|
|
372
|
+
'content-service': {
|
|
373
|
+
fileStorage: true,
|
|
374
|
+
search: true,
|
|
375
|
+
filtering: true,
|
|
376
|
+
pagination: true,
|
|
377
|
+
caching: true,
|
|
378
|
+
cdn: true,
|
|
379
|
+
imageProcessing: true,
|
|
380
|
+
metadata: true
|
|
381
|
+
},
|
|
382
|
+
'api-gateway': {
|
|
383
|
+
authentication: true,
|
|
384
|
+
authorization: true,
|
|
385
|
+
rateLimiting: true,
|
|
386
|
+
caching: true,
|
|
387
|
+
monitoring: true,
|
|
388
|
+
loadBalancing: true,
|
|
389
|
+
requestRouting: true,
|
|
390
|
+
responseTransformation: true
|
|
391
|
+
},
|
|
392
|
+
'generic': {
|
|
393
|
+
extensibility: true,
|
|
394
|
+
configuration: true,
|
|
395
|
+
deployment: true
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
return {
|
|
399
|
+
...baseFeatures,
|
|
400
|
+
...(typeSpecificFeatures[serviceType] || typeSpecificFeatures.generic)
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Close readline interface
|
|
406
|
+
*/
|
|
407
|
+
close() {
|
|
408
|
+
if (this.rl) {
|
|
409
|
+
this.rl.close();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|