@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.
- package/CHANGELOG.md +9 -0
- package/README.md +53 -0
- package/dist/bin/clodo-service.js +47 -15
- package/dist/bin/commands/deploy.js +115 -83
- package/dist/bin/commands/helpers/deployment-ui.js +138 -0
- package/dist/bin/commands/helpers/deployment-verification.js +251 -0
- package/dist/bin/commands/helpers/error-recovery.js +80 -0
- package/dist/bin/commands/helpers/resource-detection.js +113 -0
- package/dist/bin/commands/validate.js +1 -1
- package/dist/bin/security/security-cli.js +1 -1
- package/dist/bin/shared/cache/configuration-cache.js +82 -0
- package/dist/bin/shared/cloudflare/domain-manager.js +1 -1
- package/dist/bin/shared/cloudflare/index.js +1 -1
- package/dist/bin/shared/cloudflare/ops.js +6 -4
- package/dist/bin/shared/config/ConfigurationManager.js +23 -1
- package/dist/bin/shared/config/command-config-manager.js +19 -3
- package/dist/bin/shared/config/index.js +1 -1
- package/dist/bin/shared/deployment/credential-collector.js +30 -7
- package/dist/bin/shared/deployment/index.js +2 -2
- package/dist/bin/shared/deployment/rollback-manager.js +4 -520
- package/dist/bin/shared/deployment/utilities/d1-error-recovery.js +177 -0
- package/dist/bin/shared/deployment/validator.js +40 -10
- package/dist/bin/shared/deployment/workflows/deployment-summary.js +214 -0
- package/dist/bin/shared/deployment/workflows/interactive-confirmation.js +188 -0
- package/dist/bin/shared/deployment/workflows/interactive-database-workflow.js +234 -0
- package/dist/bin/shared/deployment/workflows/interactive-domain-info-gatherer.js +240 -0
- package/dist/bin/shared/deployment/workflows/interactive-secret-workflow.js +228 -0
- package/dist/bin/shared/deployment/workflows/interactive-testing-workflow.js +235 -0
- package/dist/bin/shared/deployment/workflows/interactive-validation.js +218 -0
- package/dist/bin/shared/error-handling/error-classifier.js +46 -0
- package/dist/bin/shared/monitoring/health-checker.js +129 -1
- package/dist/bin/shared/monitoring/memory-manager.js +17 -6
- package/dist/bin/shared/routing/domain-router.js +1 -1
- package/dist/bin/shared/utils/deployment-validator.js +97 -0
- package/dist/bin/shared/utils/formatters.js +10 -0
- package/dist/bin/shared/utils/index.js +13 -1
- package/dist/bin/shared/utils/interactive-prompts.js +34 -18
- package/dist/bin/shared/utils/progress-manager.js +2 -2
- package/dist/bin/shared/utils/progress-spinner.js +53 -0
- package/dist/bin/shared/utils/sensitive-redactor.js +91 -0
- package/dist/bin/shared/validation/ValidationRegistry.js +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/patterns/insecure-patterns.js +1 -1
- package/dist/utils/constants.js +102 -0
- package/dist/utils/deployment/wrangler-config-manager.js +215 -48
- package/dist/utils/framework-config.js +2 -2
- package/dist/utils/interactive-prompts.js +10 -59
- package/package.json +16 -8
- package/dist/bin/clodo-service-old.js +0 -868
- package/dist/bin/clodo-service-test.js +0 -10
- package/dist/bin/commands/assess.js +0 -91
- package/dist/bin/commands/create.js +0 -77
- package/dist/bin/commands/diagnose.js +0 -83
- package/dist/bin/commands/helpers.js +0 -138
- package/dist/bin/commands/update.js +0 -75
- package/dist/bin/database/deployment-db-manager.js +0 -423
- package/dist/bin/database/enterprise-db-manager.js +0 -457
- package/dist/bin/database/wrangler-d1-manager.js +0 -685
- package/dist/bin/deployment/enterprise-deploy.js +0 -877
- package/dist/bin/deployment/master-deploy.js +0 -1376
- package/dist/bin/deployment/modular-enterprise-deploy.js +0 -466
- package/dist/bin/deployment/modules/DeploymentConfiguration.js +0 -395
- package/dist/bin/deployment/modules/DeploymentOrchestrator.js +0 -492
- package/dist/bin/deployment/modules/EnvironmentManager.js +0 -517
- package/dist/bin/deployment/modules/MonitoringIntegration.js +0 -560
- package/dist/bin/deployment/modules/ValidationManager.js +0 -342
- package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
- package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
- package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +0 -273
- package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
- package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
- package/dist/bin/deployment/test-interactive-utils.js +0 -66
- package/dist/bin/portfolio/portfolio-manager.js +0 -487
- package/dist/bin/service-management/create-service.js +0 -122
- package/dist/bin/service-management/init-service.js +0 -79
- package/dist/config/customers.js +0 -623
- package/dist/config/domains.js +0 -186
- package/dist/config/index.js +0 -6
- package/dist/database/database-orchestrator.js +0 -795
- package/dist/database/index.js +0 -4
- package/dist/deployment/index.js +0 -11
- package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
- package/dist/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
- package/dist/deployment/orchestration/PortfolioOrchestrator.js +0 -273
- package/dist/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
- package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
- package/dist/deployment/orchestration/index.js +0 -17
- package/dist/deployment/rollback-manager.js +0 -36
- package/dist/deployment/wrangler-deployer.js +0 -640
- package/dist/handlers/GenericRouteHandler.js +0 -532
- package/dist/migration/MigrationAdapters.js +0 -562
- package/dist/modules/ModuleManager.js +0 -668
- package/dist/modules/security.js +0 -96
- package/dist/orchestration/cross-domain-coordinator.js +0 -1083
- package/dist/orchestration/index.js +0 -5
- package/dist/orchestration/modules/DeploymentCoordinator.js +0 -368
- package/dist/orchestration/modules/DomainResolver.js +0 -198
- package/dist/orchestration/modules/StateManager.js +0 -332
- package/dist/orchestration/multi-domain-orchestrator.js +0 -724
- package/dist/routing/EnhancedRouter.js +0 -158
- package/dist/schema/SchemaManager.js +0 -778
- package/dist/service-management/ConfirmationEngine.js +0 -412
- package/dist/service-management/ErrorTracker.js +0 -299
- package/dist/service-management/GenerationEngine.js +0 -447
- package/dist/service-management/InputCollector.js +0 -619
- package/dist/service-management/ServiceCreator.js +0 -265
- package/dist/service-management/ServiceInitializer.js +0 -453
- package/dist/service-management/ServiceOrchestrator.js +0 -633
- package/dist/service-management/generators/BaseGenerator.js +0 -233
- package/dist/service-management/generators/GeneratorRegistry.js +0 -254
- package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +0 -87
- package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +0 -106
- package/dist/service-management/generators/code/ServiceHandlersGenerator.js +0 -235
- package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +0 -116
- package/dist/service-management/generators/code/ServiceUtilsGenerator.js +0 -246
- package/dist/service-management/generators/code/WorkerIndexGenerator.js +0 -143
- package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +0 -101
- package/dist/service-management/generators/config/DomainsConfigGenerator.js +0 -175
- package/dist/service-management/generators/config/EnvExampleGenerator.js +0 -178
- package/dist/service-management/generators/config/ProductionEnvGenerator.js +0 -97
- package/dist/service-management/generators/config/StagingEnvGenerator.js +0 -97
- package/dist/service-management/generators/config/WranglerTomlGenerator.js +0 -238
- package/dist/service-management/generators/core/PackageJsonGenerator.js +0 -243
- package/dist/service-management/generators/core/SiteConfigGenerator.js +0 -115
- package/dist/service-management/generators/documentation/ApiDocsGenerator.js +0 -331
- package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +0 -294
- package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +0 -244
- package/dist/service-management/generators/documentation/ReadmeGenerator.js +0 -196
- package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +0 -190
- package/dist/service-management/generators/scripts/DeployScriptGenerator.js +0 -123
- package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +0 -101
- package/dist/service-management/generators/scripts/SetupScriptGenerator.js +0 -88
- package/dist/service-management/generators/service-types/StaticSiteGenerator.js +0 -342
- package/dist/service-management/generators/testing/EslintConfigGenerator.js +0 -85
- package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +0 -237
- package/dist/service-management/generators/testing/JestConfigGenerator.js +0 -72
- package/dist/service-management/generators/testing/UnitTestsGenerator.js +0 -277
- package/dist/service-management/generators/tooling/DockerComposeGenerator.js +0 -71
- package/dist/service-management/generators/tooling/GitignoreGenerator.js +0 -143
- package/dist/service-management/generators/utils/FileWriter.js +0 -179
- package/dist/service-management/generators/utils/PathResolver.js +0 -157
- package/dist/service-management/generators/utils/ServiceManifestGenerator.js +0 -111
- package/dist/service-management/generators/utils/TemplateEngine.js +0 -185
- package/dist/service-management/generators/utils/index.js +0 -18
- package/dist/service-management/handlers/ConfirmationHandler.js +0 -71
- package/dist/service-management/handlers/GenerationHandler.js +0 -80
- package/dist/service-management/handlers/InputHandler.js +0 -59
- package/dist/service-management/handlers/ValidationHandler.js +0 -203
- package/dist/service-management/index.js +0 -14
- package/dist/service-management/routing/DomainRouteMapper.js +0 -311
- package/dist/service-management/routing/RouteGenerator.js +0 -266
- package/dist/service-management/routing/WranglerRoutesBuilder.js +0 -273
- package/dist/service-management/routing/index.js +0 -14
- package/dist/service-management/services/DirectoryStructureService.js +0 -56
- package/dist/service-management/services/GenerationCoordinator.js +0 -208
- package/dist/service-management/services/GeneratorRegistry.js +0 -174
- package/dist/services/GenericDataService.js +0 -501
- package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +0 -286
- package/dist/ui-structures/concepts/service-lifecycle-management.md +0 -150
- package/dist/ui-structures/concepts/service-manifest-guide.md +0 -309
- package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +0 -231
- package/dist/ui-structures/creation/automated-generation-ui.json +0 -246
- package/dist/ui-structures/creation/core-inputs-ui.json +0 -217
- package/dist/ui-structures/creation/smart-confirmable-ui.json +0 -451
- package/dist/ui-structures/reference/absolutely-required-inputs.json +0 -315
- package/dist/ui-structures/reference/service-manifest-template.json +0 -342
- package/dist/version/VersionDetector.js +0 -723
- package/dist/worker/index.js +0 -4
- package/dist/worker/integration.js +0 -351
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deployment Configuration Module
|
|
3
|
-
* Centralized configuration management for enterprise deployments
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
7
|
-
import { join } from 'path';
|
|
8
|
-
import { askUser, askYesNo, askChoice } from '../../shared/utils/interactive-prompts.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Manages all deployment configuration including domain setup,
|
|
12
|
-
* worker configuration, database config, and secrets management
|
|
13
|
-
*/
|
|
14
|
-
export class DeploymentConfiguration {
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.config = this.initializeDefaultConfig();
|
|
18
|
-
this.state = {
|
|
19
|
-
configurationId: this.generateConfigId(),
|
|
20
|
-
configDiscovered: false,
|
|
21
|
-
secretsGenerated: false,
|
|
22
|
-
validated: false
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Generate unique configuration ID
|
|
28
|
-
*/
|
|
29
|
-
generateConfigId() {
|
|
30
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
31
|
-
const random = Math.random().toString(36).substr(2, 9);
|
|
32
|
-
return `config-${timestamp}-${random}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Initialize default configuration structure
|
|
37
|
-
*/
|
|
38
|
-
initializeDefaultConfig() {
|
|
39
|
-
return {
|
|
40
|
-
// Domain and service configuration
|
|
41
|
-
domain: null,
|
|
42
|
-
environment: 'production',
|
|
43
|
-
deploymentMode: 'single',
|
|
44
|
-
// Worker configuration
|
|
45
|
-
worker: {
|
|
46
|
-
name: null,
|
|
47
|
-
url: null,
|
|
48
|
-
routes: []
|
|
49
|
-
},
|
|
50
|
-
// Database configuration
|
|
51
|
-
database: {
|
|
52
|
-
name: null,
|
|
53
|
-
id: null,
|
|
54
|
-
createNew: true,
|
|
55
|
-
enableMigrations: true
|
|
56
|
-
},
|
|
57
|
-
// Secrets management
|
|
58
|
-
secrets: {
|
|
59
|
-
generateNew: true,
|
|
60
|
-
keys: {},
|
|
61
|
-
distributionMethod: 'individual'
|
|
62
|
-
},
|
|
63
|
-
// Enterprise features
|
|
64
|
-
enterprise: {
|
|
65
|
-
enableOrchestration: true,
|
|
66
|
-
enableCrossDomainCoordination: false,
|
|
67
|
-
enableAdvancedValidation: true,
|
|
68
|
-
enableProductionTesting: true,
|
|
69
|
-
enableConfigCaching: true,
|
|
70
|
-
enableAuditLogging: true
|
|
71
|
-
},
|
|
72
|
-
// Deployment options
|
|
73
|
-
deployment: {
|
|
74
|
-
runTests: true,
|
|
75
|
-
skipExisting: false,
|
|
76
|
-
enableRollback: true,
|
|
77
|
-
validationLevel: 'comprehensive',
|
|
78
|
-
auditLevel: 'detailed'
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Gather single domain configuration information
|
|
85
|
-
*/
|
|
86
|
-
async gatherSingleDomainInfo() {
|
|
87
|
-
console.log('\nš Step 1: Domain Configuration');
|
|
88
|
-
console.log('===============================');
|
|
89
|
-
this.config.domain = await askUser('Enter the domain name (e.g., example.com)', this.config.domain);
|
|
90
|
-
const envChoice = await askChoice('Select deployment environment', ['production', 'staging', 'development'], 0);
|
|
91
|
-
this.config.environment = ['production', 'staging', 'development'][envChoice];
|
|
92
|
-
|
|
93
|
-
// Generate worker name and URL
|
|
94
|
-
const domainPrefix = this.config.domain.replace(/\./g, '-');
|
|
95
|
-
this.config.worker.name = `${domainPrefix}-${this.config.environment}`;
|
|
96
|
-
this.config.worker.url = this.config.environment === 'production' ? `https://${this.config.domain}` : `https://${this.config.environment}.${this.config.domain}`;
|
|
97
|
-
console.log(`\nš Configuration Summary:`);
|
|
98
|
-
console.log(` š Domain: ${this.config.domain}`);
|
|
99
|
-
console.log(` š·ļø Environment: ${this.config.environment}`);
|
|
100
|
-
console.log(` š· Worker: ${this.config.worker.name}`);
|
|
101
|
-
console.log(` š URL: ${this.config.worker.url}`);
|
|
102
|
-
const confirmConfig = await askYesNo('Is this configuration correct?', true);
|
|
103
|
-
if (!confirmConfig) {
|
|
104
|
-
return await this.gatherSingleDomainInfo();
|
|
105
|
-
}
|
|
106
|
-
return this.config;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Configure database settings
|
|
111
|
-
*/
|
|
112
|
-
async configureDatabaseSettings() {
|
|
113
|
-
console.log('\nšļø Database Configuration');
|
|
114
|
-
console.log('=========================');
|
|
115
|
-
this.config.database.name = `${this.config.domain}-auth-db`;
|
|
116
|
-
console.log(`\nš Generated database name: ${this.config.database.name}`);
|
|
117
|
-
const useGeneratedName = await askYesNo('Use this database name?', true);
|
|
118
|
-
if (!useGeneratedName) {
|
|
119
|
-
this.config.database.name = await askUser('Enter custom database name', this.config.database.name);
|
|
120
|
-
}
|
|
121
|
-
const enableMigrations = await askYesNo('Enable automatic database migrations?', true);
|
|
122
|
-
this.config.database.enableMigrations = enableMigrations;
|
|
123
|
-
return this.config.database;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Configure secrets management
|
|
128
|
-
*/
|
|
129
|
-
async configureSecretsManagement() {
|
|
130
|
-
console.log('\nš Secrets Management Configuration');
|
|
131
|
-
console.log('==================================');
|
|
132
|
-
|
|
133
|
-
// Check for existing secrets file
|
|
134
|
-
const secretsFile = join('secrets', `${this.config.domain}-secrets.json`);
|
|
135
|
-
let existingSecrets = {};
|
|
136
|
-
try {
|
|
137
|
-
const secretsData = JSON.parse(readFileSync(secretsFile, 'utf8'));
|
|
138
|
-
const {
|
|
139
|
-
domain,
|
|
140
|
-
environment,
|
|
141
|
-
generated,
|
|
142
|
-
note,
|
|
143
|
-
...secrets
|
|
144
|
-
} = secretsData;
|
|
145
|
-
existingSecrets = secrets;
|
|
146
|
-
console.log(`\nš Found existing secrets file: ${secretsFile}`);
|
|
147
|
-
console.log(` š Contains ${Object.keys(secrets).length} secrets`);
|
|
148
|
-
console.log(` š
Generated: ${generated}`);
|
|
149
|
-
const reuseSecrets = await askYesNo('Do you want to reuse these existing secrets? (Recommended for consistency)', true);
|
|
150
|
-
if (reuseSecrets) {
|
|
151
|
-
this.config.secrets.keys = existingSecrets;
|
|
152
|
-
this.config.secrets.generateNew = false;
|
|
153
|
-
this.state.secretsGenerated = true;
|
|
154
|
-
console.log(' ā
Will reuse existing secrets');
|
|
155
|
-
return this.config.secrets;
|
|
156
|
-
}
|
|
157
|
-
} catch (error) {
|
|
158
|
-
console.log(' ā ļø No existing secrets found or file unreadable');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Configure new secrets generation
|
|
162
|
-
const confirmGenerate = await askYesNo('Generate new cryptographic secrets? (Required for first deployment)', true);
|
|
163
|
-
if (!confirmGenerate) {
|
|
164
|
-
throw new Error('Secret generation is required for deployment');
|
|
165
|
-
}
|
|
166
|
-
this.config.secrets.generateNew = true;
|
|
167
|
-
|
|
168
|
-
// Select distribution method
|
|
169
|
-
const distributionChoice = await askChoice('Choose secret distribution method', ['Individual secrets (Recommended)', 'Batch deployment (Faster)', 'Manual distribution (Advanced)'], 0);
|
|
170
|
-
this.config.secrets.distributionMethod = ['individual', 'batch', 'manual'][distributionChoice];
|
|
171
|
-
return this.config.secrets;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Configure enterprise features
|
|
176
|
-
*/
|
|
177
|
-
async configureEnterpriseFeatures() {
|
|
178
|
-
console.log('\nš¢ Enterprise Features Configuration');
|
|
179
|
-
console.log('===================================');
|
|
180
|
-
const features = [{
|
|
181
|
-
key: 'enableOrchestration',
|
|
182
|
-
name: 'Multi-Domain Orchestration',
|
|
183
|
-
description: 'Advanced deployment coordination across multiple domains',
|
|
184
|
-
default: true
|
|
185
|
-
}, {
|
|
186
|
-
key: 'enableAdvancedValidation',
|
|
187
|
-
name: 'Advanced Validation',
|
|
188
|
-
description: 'Comprehensive pre-deployment validation and testing',
|
|
189
|
-
default: true
|
|
190
|
-
}, {
|
|
191
|
-
key: 'enableProductionTesting',
|
|
192
|
-
name: 'Production Testing',
|
|
193
|
-
description: 'Automated post-deployment testing and validation',
|
|
194
|
-
default: true
|
|
195
|
-
}, {
|
|
196
|
-
key: 'enableConfigCaching',
|
|
197
|
-
name: 'Configuration Caching',
|
|
198
|
-
description: 'High-performance configuration caching and optimization',
|
|
199
|
-
default: true
|
|
200
|
-
}, {
|
|
201
|
-
key: 'enableAuditLogging',
|
|
202
|
-
name: 'Audit Logging',
|
|
203
|
-
description: 'Detailed audit trails and compliance reporting',
|
|
204
|
-
default: true
|
|
205
|
-
}];
|
|
206
|
-
for (const feature of features) {
|
|
207
|
-
console.log(`\nš§ ${feature.name}`);
|
|
208
|
-
console.log(` ${feature.description}`);
|
|
209
|
-
const enable = await askYesNo(`Enable ${feature.name}?`, feature.default);
|
|
210
|
-
this.config.enterprise[feature.key] = enable;
|
|
211
|
-
}
|
|
212
|
-
return this.config.enterprise;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Update wrangler.toml configuration
|
|
217
|
-
*/
|
|
218
|
-
async updateWranglerConfig() {
|
|
219
|
-
console.log('\nāļø Updating wrangler.toml configuration...');
|
|
220
|
-
try {
|
|
221
|
-
let config = readFileSync('wrangler.toml', 'utf8');
|
|
222
|
-
|
|
223
|
-
// Update worker name
|
|
224
|
-
config = config.replace(/^name = "[^"]*"/m, `name = "${this.config.worker.name}"`);
|
|
225
|
-
|
|
226
|
-
// Update production environment name
|
|
227
|
-
config = config.replace(/^\[env\.production\]\s*\nname = "[^"]*"/m, `[env.production]\nname = "${this.config.worker.name}"`);
|
|
228
|
-
|
|
229
|
-
// Update database configuration if database is configured
|
|
230
|
-
if (this.config.database.name && this.config.database.id) {
|
|
231
|
-
config = config.replace(/database_name = "[^"]*"/g, `database_name = "${this.config.database.name}"`);
|
|
232
|
-
config = config.replace(/database_id = "[^"]*"/g, `database_id = "${this.config.database.id}"`);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Update SERVICE_DOMAIN
|
|
236
|
-
config = config.replace(/SERVICE_DOMAIN = "[^"]*"/g, `SERVICE_DOMAIN = "${this.config.domain}"`);
|
|
237
|
-
|
|
238
|
-
// Write updated configuration
|
|
239
|
-
writeFileSync('wrangler.toml', config);
|
|
240
|
-
console.log(' ā
wrangler.toml updated successfully');
|
|
241
|
-
return {
|
|
242
|
-
success: true,
|
|
243
|
-
config
|
|
244
|
-
};
|
|
245
|
-
} catch (error) {
|
|
246
|
-
console.log(` ā Failed to update wrangler.toml: ${error.message}`);
|
|
247
|
-
throw new Error(`wrangler.toml update failed: ${error.message}`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Try to discover existing configuration
|
|
253
|
-
*/
|
|
254
|
-
async tryConfigurationDiscovery() {
|
|
255
|
-
console.log('\nš Attempting configuration discovery...');
|
|
256
|
-
const discoveries = [];
|
|
257
|
-
try {
|
|
258
|
-
// Try to discover from wrangler.toml
|
|
259
|
-
const wranglerConfig = readFileSync('wrangler.toml', 'utf8');
|
|
260
|
-
const nameMatch = wranglerConfig.match(/^name = "([^"]+)"/m);
|
|
261
|
-
if (nameMatch) {
|
|
262
|
-
discoveries.push({
|
|
263
|
-
source: 'wrangler.toml',
|
|
264
|
-
key: 'worker.name',
|
|
265
|
-
value: nameMatch[1]
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
const domainMatch = wranglerConfig.match(/SERVICE_DOMAIN = "([^"]+)"/);
|
|
269
|
-
if (domainMatch) {
|
|
270
|
-
discoveries.push({
|
|
271
|
-
source: 'wrangler.toml',
|
|
272
|
-
key: 'domain',
|
|
273
|
-
value: domainMatch[1]
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
} catch (error) {
|
|
277
|
-
console.log(' ā ļø No wrangler.toml found for discovery');
|
|
278
|
-
}
|
|
279
|
-
try {
|
|
280
|
-
// Try to discover from package.json
|
|
281
|
-
const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
|
|
282
|
-
if (packageJson.name) {
|
|
283
|
-
discoveries.push({
|
|
284
|
-
source: 'package.json',
|
|
285
|
-
key: 'project.name',
|
|
286
|
-
value: packageJson.name
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
} catch (error) {
|
|
290
|
-
console.log(' ā ļø No package.json found for discovery');
|
|
291
|
-
}
|
|
292
|
-
if (discoveries.length > 0) {
|
|
293
|
-
console.log('\nš Discovered configuration:');
|
|
294
|
-
discoveries.forEach(discovery => {
|
|
295
|
-
console.log(` ${discovery.source}: ${discovery.key} = ${discovery.value}`);
|
|
296
|
-
});
|
|
297
|
-
const useDiscovered = await askYesNo('Use discovered configuration as starting point?', true);
|
|
298
|
-
if (useDiscovered) {
|
|
299
|
-
// Apply discoveries to config
|
|
300
|
-
discoveries.forEach(discovery => {
|
|
301
|
-
const keys = discovery.key.split('.');
|
|
302
|
-
let target = this.config;
|
|
303
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
304
|
-
if (!target[keys[i]]) target[keys[i]] = {};
|
|
305
|
-
target = target[keys[i]];
|
|
306
|
-
}
|
|
307
|
-
target[keys[keys.length - 1]] = discovery.value;
|
|
308
|
-
});
|
|
309
|
-
this.state.configDiscovered = true;
|
|
310
|
-
console.log(' ā
Configuration discovery applied');
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
console.log(' ā¹ļø No configuration discovered, will use interactive setup');
|
|
314
|
-
}
|
|
315
|
-
return this.state.configDiscovered;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Validate configuration completeness
|
|
320
|
-
*/
|
|
321
|
-
validateConfiguration() {
|
|
322
|
-
const issues = [];
|
|
323
|
-
|
|
324
|
-
// Check required fields
|
|
325
|
-
if (!this.config.domain) {
|
|
326
|
-
issues.push('Domain is required');
|
|
327
|
-
}
|
|
328
|
-
if (!this.config.worker.name) {
|
|
329
|
-
issues.push('Worker name is required');
|
|
330
|
-
}
|
|
331
|
-
if (!this.config.environment) {
|
|
332
|
-
issues.push('Environment is required');
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Validate domain format
|
|
336
|
-
if (this.config.domain && !/^[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z]{2,}$/.test(this.config.domain)) {
|
|
337
|
-
issues.push('Invalid domain format');
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Check database configuration if enabled
|
|
341
|
-
if (this.config.database.enableMigrations && !this.config.database.name) {
|
|
342
|
-
issues.push('Database name is required when migrations are enabled');
|
|
343
|
-
}
|
|
344
|
-
this.state.validated = issues.length === 0;
|
|
345
|
-
return {
|
|
346
|
-
valid: this.state.validated,
|
|
347
|
-
issues
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Get configuration summary for display
|
|
353
|
-
*/
|
|
354
|
-
getConfigurationSummary() {
|
|
355
|
-
return {
|
|
356
|
-
domain: this.config.domain,
|
|
357
|
-
environment: this.config.environment,
|
|
358
|
-
worker: this.config.worker.name,
|
|
359
|
-
database: this.config.database.name,
|
|
360
|
-
secretsConfigured: this.state.secretsGenerated,
|
|
361
|
-
enterpriseFeatures: Object.entries(this.config.enterprise).filter(([key, value]) => value).map(([key]) => key),
|
|
362
|
-
validated: this.state.validated
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Export configuration for other modules
|
|
368
|
-
*/
|
|
369
|
-
exportConfiguration() {
|
|
370
|
-
return {
|
|
371
|
-
...this.config,
|
|
372
|
-
state: {
|
|
373
|
-
...this.state
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Import configuration from external source
|
|
380
|
-
*/
|
|
381
|
-
importConfiguration(externalConfig) {
|
|
382
|
-
if (externalConfig.state) {
|
|
383
|
-
this.state = {
|
|
384
|
-
...this.state,
|
|
385
|
-
...externalConfig.state
|
|
386
|
-
};
|
|
387
|
-
delete externalConfig.state;
|
|
388
|
-
}
|
|
389
|
-
this.config = {
|
|
390
|
-
...this.config,
|
|
391
|
-
...externalConfig
|
|
392
|
-
};
|
|
393
|
-
return this.config;
|
|
394
|
-
}
|
|
395
|
-
}
|