@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,517 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EnvironmentManager - Manages environment-specific deployment logic and domain orchestration
|
|
3
|
-
* Handles environment configuration, domain mapping, deployment mode selection, and cross-domain coordination
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { MultiDomainOrchestrator } from "../../../orchestration/multi-domain-orchestrator.js";
|
|
7
|
-
import { CrossDomainCoordinator } from "../../../orchestration/cross-domain-coordinator.js";
|
|
8
|
-
import { DomainDiscovery } from '../../shared/cloudflare/domain-discovery.js';
|
|
9
|
-
import { askChoice, askUser, askYesNo, DeploymentInteractiveUtils } from '../../shared/utils/interactive-utils.js';
|
|
10
|
-
export class EnvironmentManager {
|
|
11
|
-
constructor(config) {
|
|
12
|
-
this.config = config;
|
|
13
|
-
this.orchestrator = null;
|
|
14
|
-
this.coordinator = null;
|
|
15
|
-
this.domainDiscovery = null;
|
|
16
|
-
this.supportedEnvironments = ['production', 'staging', 'development', 'preview'];
|
|
17
|
-
this.deploymentModes = ['single', 'multi-domain', 'portfolio'];
|
|
18
|
-
|
|
19
|
-
// Enhanced interactive utilities
|
|
20
|
-
this.interactiveUtils = new DeploymentInteractiveUtils({
|
|
21
|
-
enableColors: true,
|
|
22
|
-
enableProgress: true,
|
|
23
|
-
validateInputs: true
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Initialize environment-specific components based on configuration
|
|
29
|
-
*/
|
|
30
|
-
async initializeEnvironment() {
|
|
31
|
-
console.log('\n🌍 Initializing Environment Manager');
|
|
32
|
-
console.log('===================================');
|
|
33
|
-
|
|
34
|
-
// Initialize multi-domain orchestrator if needed
|
|
35
|
-
if (this.config.deploymentMode !== 'single') {
|
|
36
|
-
this.orchestrator = new MultiDomainOrchestrator({
|
|
37
|
-
portfolioName: this.config.portfolioName || 'default-portfolio',
|
|
38
|
-
enableContinuousMonitoring: this.config.deployment?.enableMonitoring || false,
|
|
39
|
-
validationLevel: this.config.deployment?.validationLevel || 'standard',
|
|
40
|
-
environment: this.config.environment
|
|
41
|
-
});
|
|
42
|
-
console.log(' ✅ Multi-domain orchestrator initialized');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Initialize cross-domain coordinator for portfolio mode
|
|
46
|
-
if (this.config.deploymentMode === 'portfolio') {
|
|
47
|
-
this.coordinator = new CrossDomainCoordinator({
|
|
48
|
-
portfolioName: this.config.portfolioName || 'interactive-portfolio',
|
|
49
|
-
enableContinuousMonitoring: true,
|
|
50
|
-
crossDomainCoordination: this.config.secrets?.crossDomainSharing || false
|
|
51
|
-
});
|
|
52
|
-
console.log(' ✅ Cross-domain coordinator initialized');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Initialize domain discovery
|
|
56
|
-
this.domainDiscovery = new DomainDiscovery({
|
|
57
|
-
environment: this.config.environment,
|
|
58
|
-
enableConfigDiscovery: true
|
|
59
|
-
});
|
|
60
|
-
console.log(' ✅ Domain discovery service initialized');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Interactive deployment mode selection
|
|
65
|
-
*/
|
|
66
|
-
async selectDeploymentMode() {
|
|
67
|
-
console.log('\n🎯 Deployment Mode Selection');
|
|
68
|
-
console.log('============================');
|
|
69
|
-
console.log('');
|
|
70
|
-
console.log('The Enterprise Deployment System supports multiple deployment modes:');
|
|
71
|
-
console.log('');
|
|
72
|
-
console.log('📱 Single Domain - Deploy one domain with full enterprise features');
|
|
73
|
-
console.log('🌍 Multi-Domain - Deploy multiple domains with coordination');
|
|
74
|
-
console.log('📊 Portfolio Mode - Manage entire domain portfolio');
|
|
75
|
-
console.log('');
|
|
76
|
-
const modes = ['Single Domain (Recommended for first-time users)', 'Multi-Domain (Deploy multiple domains together)', 'Portfolio Mode (Advanced: Full portfolio management)'];
|
|
77
|
-
|
|
78
|
-
// Use enhanced deployment mode selector
|
|
79
|
-
const modeChoice = await this.interactiveUtils.askDeploymentMode(0);
|
|
80
|
-
switch (modeChoice) {
|
|
81
|
-
case 0:
|
|
82
|
-
this.config.deploymentMode = 'single';
|
|
83
|
-
console.log('\n✅ Selected: Single Domain Deployment');
|
|
84
|
-
break;
|
|
85
|
-
case 1:
|
|
86
|
-
this.config.deploymentMode = 'multi-domain';
|
|
87
|
-
this.config.enterprise = this.config.enterprise || {};
|
|
88
|
-
this.config.enterprise.enableCrossDomainCoordination = true;
|
|
89
|
-
console.log('\n✅ Selected: Multi-Domain Deployment');
|
|
90
|
-
break;
|
|
91
|
-
case 2:
|
|
92
|
-
this.config.deploymentMode = 'portfolio';
|
|
93
|
-
this.config.enterprise = this.config.enterprise || {};
|
|
94
|
-
this.config.enterprise.enableCrossDomainCoordination = true;
|
|
95
|
-
console.log('\n✅ Selected: Portfolio Mode');
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
return this.config.deploymentMode;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Gather configuration based on selected deployment mode
|
|
103
|
-
*/
|
|
104
|
-
async gatherEnvironmentConfiguration() {
|
|
105
|
-
console.log('\n📋 Environment Configuration');
|
|
106
|
-
console.log('============================');
|
|
107
|
-
switch (this.config.deploymentMode) {
|
|
108
|
-
case 'single':
|
|
109
|
-
return await this.gatherSingleDomainConfiguration();
|
|
110
|
-
case 'multi-domain':
|
|
111
|
-
return await this.gatherMultiDomainConfiguration();
|
|
112
|
-
case 'portfolio':
|
|
113
|
-
return await this.gatherPortfolioConfiguration();
|
|
114
|
-
default:
|
|
115
|
-
throw new Error(`Unsupported deployment mode: ${this.config.deploymentMode}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Gather single domain configuration
|
|
121
|
-
*/
|
|
122
|
-
async gatherSingleDomainConfiguration() {
|
|
123
|
-
console.log('\n📱 Single Domain Configuration');
|
|
124
|
-
console.log('------------------------------');
|
|
125
|
-
|
|
126
|
-
// Enhanced domain input with built-in validation
|
|
127
|
-
this.config.domain = await this.interactiveUtils.askDomain('Enter the domain name for deployment (e.g., "newclient", "democorp")');
|
|
128
|
-
console.log(`\n✅ Domain: ${this.config.domain}`);
|
|
129
|
-
|
|
130
|
-
// Configuration discovery
|
|
131
|
-
const tryDiscovery = await askYesNo('🔍 Try to discover existing configuration for this domain?', 'y');
|
|
132
|
-
if (tryDiscovery) {
|
|
133
|
-
await this.tryConfigurationDiscovery();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Environment selection
|
|
137
|
-
await this.selectEnvironment();
|
|
138
|
-
|
|
139
|
-
// Generate worker configuration
|
|
140
|
-
this.generateWorkerConfiguration();
|
|
141
|
-
|
|
142
|
-
// Validate configuration
|
|
143
|
-
const confirmConfig = await askYesNo('Is this configuration correct?', 'y');
|
|
144
|
-
if (!confirmConfig) {
|
|
145
|
-
throw new Error('Configuration cancelled by user');
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
domain: this.config.domain,
|
|
149
|
-
environment: this.config.environment,
|
|
150
|
-
worker: this.config.worker
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Gather multi-domain configuration
|
|
156
|
-
*/
|
|
157
|
-
async gatherMultiDomainConfiguration() {
|
|
158
|
-
console.log('\n🌍 Multi-Domain Configuration');
|
|
159
|
-
console.log('-----------------------------');
|
|
160
|
-
console.log('This feature allows coordinated deployment across multiple domains');
|
|
161
|
-
const domainCount = parseInt(await askUser('How many domains to deploy? (2-10)', '2'));
|
|
162
|
-
if (domainCount < 2 || domainCount > 10) {
|
|
163
|
-
throw new Error('Domain count must be between 2 and 10');
|
|
164
|
-
}
|
|
165
|
-
const domains = [];
|
|
166
|
-
for (let i = 0; i < domainCount; i++) {
|
|
167
|
-
const domain = await askUser(`Enter domain ${i + 1}:`);
|
|
168
|
-
if (!domain || !/^[a-z0-9-]+$/.test(domain)) {
|
|
169
|
-
throw new Error(`Invalid domain format for domain ${i + 1}`);
|
|
170
|
-
}
|
|
171
|
-
domains.push(domain);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Environment selection applies to all domains
|
|
175
|
-
await this.selectEnvironment();
|
|
176
|
-
|
|
177
|
-
// Configure coordination settings
|
|
178
|
-
const enableSharedSecrets = await askYesNo('Enable shared secrets across domains?', 'n');
|
|
179
|
-
this.config.domains = domains;
|
|
180
|
-
this.config.secrets = this.config.secrets || {};
|
|
181
|
-
this.config.secrets.crossDomainSharing = enableSharedSecrets;
|
|
182
|
-
console.log(`\n✅ Multi-domain mode: ${domainCount} domains configured`);
|
|
183
|
-
domains.forEach((domain, idx) => {
|
|
184
|
-
console.log(` ${idx + 1}. ${domain}`);
|
|
185
|
-
});
|
|
186
|
-
return {
|
|
187
|
-
domains: this.config.domains,
|
|
188
|
-
environment: this.config.environment,
|
|
189
|
-
coordination: {
|
|
190
|
-
crossDomainSharing: enableSharedSecrets
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Gather portfolio configuration
|
|
197
|
-
*/
|
|
198
|
-
async gatherPortfolioConfiguration() {
|
|
199
|
-
console.log('\n📊 Portfolio Management Configuration');
|
|
200
|
-
console.log('------------------------------------');
|
|
201
|
-
console.log('This feature provides advanced portfolio management capabilities');
|
|
202
|
-
const portfolioName = await askUser('Enter portfolio name (e.g., "enterprise-suite", "client-portfolio")', 'default-portfolio');
|
|
203
|
-
if (!/^[a-z0-9-]+$/.test(portfolioName)) {
|
|
204
|
-
throw new Error('Portfolio name must contain only lowercase letters, numbers, and hyphens');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Environment selection
|
|
208
|
-
await this.selectEnvironment();
|
|
209
|
-
|
|
210
|
-
// Portfolio-specific settings
|
|
211
|
-
const enableContinuousMonitoring = await askYesNo('Enable continuous monitoring for portfolio?', 'y');
|
|
212
|
-
const enableAutomaticScaling = await askYesNo('Enable automatic scaling across portfolio?', 'n');
|
|
213
|
-
this.config.portfolioName = portfolioName;
|
|
214
|
-
this.config.portfolio = {
|
|
215
|
-
enableContinuousMonitoring,
|
|
216
|
-
enableAutomaticScaling,
|
|
217
|
-
crossDomainCoordination: true
|
|
218
|
-
};
|
|
219
|
-
console.log('\n✅ Portfolio mode configured:');
|
|
220
|
-
console.log(` Portfolio: ${portfolioName}`);
|
|
221
|
-
console.log(` Environment: ${this.config.environment}`);
|
|
222
|
-
console.log(` Monitoring: ${enableContinuousMonitoring ? 'Enabled' : 'Disabled'}`);
|
|
223
|
-
return {
|
|
224
|
-
portfolioName: this.config.portfolioName,
|
|
225
|
-
environment: this.config.environment,
|
|
226
|
-
portfolio: this.config.portfolio
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Enhanced interactive environment selection
|
|
232
|
-
*/
|
|
233
|
-
async selectEnvironment() {
|
|
234
|
-
// Use enhanced environment selector with built-in warnings
|
|
235
|
-
const envChoice = await this.interactiveUtils.askEnvironment(0);
|
|
236
|
-
this.config.environment = this.supportedEnvironments[envChoice];
|
|
237
|
-
|
|
238
|
-
// Environment-specific warnings
|
|
239
|
-
if (this.config.environment === 'production') {
|
|
240
|
-
console.log('\n⚠️ Production Environment Selected:');
|
|
241
|
-
console.log(' - Enhanced security validation will be performed');
|
|
242
|
-
console.log(' - Backup and recovery mechanisms will be enabled');
|
|
243
|
-
console.log(' - Performance monitoring will be activated');
|
|
244
|
-
const confirmProd = await askYesNo('Continue with production deployment?', 'y');
|
|
245
|
-
if (!confirmProd) {
|
|
246
|
-
throw new Error('Production deployment cancelled');
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
console.log(`✅ Environment: ${this.config.environment}`);
|
|
250
|
-
return this.config.environment;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Generate worker configuration based on domain and environment
|
|
255
|
-
*/
|
|
256
|
-
generateWorkerConfiguration() {
|
|
257
|
-
if (!this.config.domain) {
|
|
258
|
-
throw new Error('Domain is required to generate worker configuration');
|
|
259
|
-
}
|
|
260
|
-
const baseName = `${this.config.domain}-data-service`;
|
|
261
|
-
const envSuffix = this.config.environment === 'production' ? '' : `-${this.config.environment}`;
|
|
262
|
-
this.config.worker = {
|
|
263
|
-
name: `${baseName}${envSuffix}`,
|
|
264
|
-
url: `https://${baseName}${envSuffix}.tamylatrading.workers.dev`,
|
|
265
|
-
environment: this.config.environment,
|
|
266
|
-
script: `src/workers/${this.config.domain}/index.js`
|
|
267
|
-
};
|
|
268
|
-
console.log(`\n🔧 Generated Worker Configuration:`);
|
|
269
|
-
console.log(` Name: ${this.config.worker.name}`);
|
|
270
|
-
console.log(` URL: ${this.config.worker.url}`);
|
|
271
|
-
console.log(` Script: ${this.config.worker.script}`);
|
|
272
|
-
return this.config.worker;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Try to discover existing configuration for the domain
|
|
277
|
-
*/
|
|
278
|
-
async tryConfigurationDiscovery() {
|
|
279
|
-
if (!this.domainDiscovery) {
|
|
280
|
-
console.log(' ⚠️ Domain discovery not available');
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
try {
|
|
284
|
-
console.log(' 🔍 Searching for existing configuration...');
|
|
285
|
-
const discoveredConfig = await this.domainDiscovery.discoverConfiguration(this.config.domain);
|
|
286
|
-
if (discoveredConfig) {
|
|
287
|
-
console.log(' ✅ Found existing configuration:');
|
|
288
|
-
console.log(` Worker: ${discoveredConfig.workerName}`);
|
|
289
|
-
console.log(` Database: ${discoveredConfig.databaseName}`);
|
|
290
|
-
const useDiscovered = await askYesNo('Use discovered configuration?', 'y');
|
|
291
|
-
if (useDiscovered) {
|
|
292
|
-
this.config.worker = {
|
|
293
|
-
...this.config.worker,
|
|
294
|
-
...discoveredConfig.worker
|
|
295
|
-
};
|
|
296
|
-
this.config.database = {
|
|
297
|
-
...this.config.database,
|
|
298
|
-
...discoveredConfig.database
|
|
299
|
-
};
|
|
300
|
-
console.log(' ✅ Using discovered configuration');
|
|
301
|
-
return discoveredConfig;
|
|
302
|
-
}
|
|
303
|
-
} else {
|
|
304
|
-
console.log(' ℹ️ No existing configuration found');
|
|
305
|
-
}
|
|
306
|
-
} catch (error) {
|
|
307
|
-
console.log(` ⚠️ Configuration discovery failed: ${error.message}`);
|
|
308
|
-
}
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Validate environment configuration
|
|
314
|
-
*/
|
|
315
|
-
validateEnvironmentConfiguration() {
|
|
316
|
-
const errors = [];
|
|
317
|
-
const warnings = [];
|
|
318
|
-
|
|
319
|
-
// Basic validation
|
|
320
|
-
if (!this.config.environment) {
|
|
321
|
-
errors.push('Environment not selected');
|
|
322
|
-
}
|
|
323
|
-
if (!this.supportedEnvironments.includes(this.config.environment)) {
|
|
324
|
-
errors.push(`Unsupported environment: ${this.config.environment}`);
|
|
325
|
-
}
|
|
326
|
-
if (!this.config.deploymentMode) {
|
|
327
|
-
errors.push('Deployment mode not selected');
|
|
328
|
-
}
|
|
329
|
-
if (!this.deploymentModes.includes(this.config.deploymentMode)) {
|
|
330
|
-
errors.push(`Unsupported deployment mode: ${this.config.deploymentMode}`);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Mode-specific validation
|
|
334
|
-
switch (this.config.deploymentMode) {
|
|
335
|
-
case 'single':
|
|
336
|
-
if (!this.config.domain) {
|
|
337
|
-
errors.push('Domain required for single-domain deployment');
|
|
338
|
-
}
|
|
339
|
-
break;
|
|
340
|
-
case 'multi-domain':
|
|
341
|
-
if (!this.config.domains || this.config.domains.length < 2) {
|
|
342
|
-
errors.push('At least 2 domains required for multi-domain deployment');
|
|
343
|
-
}
|
|
344
|
-
break;
|
|
345
|
-
case 'portfolio':
|
|
346
|
-
if (!this.config.portfolioName) {
|
|
347
|
-
errors.push('Portfolio name required for portfolio deployment');
|
|
348
|
-
}
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Environment-specific warnings
|
|
353
|
-
if (this.config.environment === 'production' && !this.config.database?.enableBackup) {
|
|
354
|
-
warnings.push('Database backup not enabled for production environment');
|
|
355
|
-
}
|
|
356
|
-
return {
|
|
357
|
-
valid: errors.length === 0,
|
|
358
|
-
errors,
|
|
359
|
-
warnings
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Get environment-specific configuration
|
|
365
|
-
*/
|
|
366
|
-
getEnvironmentConfig() {
|
|
367
|
-
return {
|
|
368
|
-
environment: this.config.environment,
|
|
369
|
-
deploymentMode: this.config.deploymentMode,
|
|
370
|
-
domain: this.config.domain,
|
|
371
|
-
domains: this.config.domains,
|
|
372
|
-
portfolioName: this.config.portfolioName,
|
|
373
|
-
worker: this.config.worker,
|
|
374
|
-
orchestrator: this.orchestrator,
|
|
375
|
-
coordinator: this.coordinator,
|
|
376
|
-
domainDiscovery: this.domainDiscovery
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Consolidated CLI option definitions from enterprise-deploy.js
|
|
382
|
-
* Replaces scattered -e, --env definitions across command handlers
|
|
383
|
-
*/
|
|
384
|
-
static getEnvironmentOption() {
|
|
385
|
-
return {
|
|
386
|
-
flag: '-e, --env',
|
|
387
|
-
description: 'deployment environment',
|
|
388
|
-
default: 'production',
|
|
389
|
-
validate: env => {
|
|
390
|
-
const valid = ['production', 'staging', 'development', 'preview'].includes(env);
|
|
391
|
-
if (!valid) throw new Error(`Invalid environment: ${env}. Must be one of: production, staging, development, preview`);
|
|
392
|
-
return env;
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Consolidated deployment mode option definition
|
|
399
|
-
*/
|
|
400
|
-
static getDeploymentModeOption() {
|
|
401
|
-
return {
|
|
402
|
-
flag: '--mode',
|
|
403
|
-
description: 'deployment mode',
|
|
404
|
-
default: 'single',
|
|
405
|
-
choices: ['single', 'multi-domain', 'portfolio'],
|
|
406
|
-
validate: mode => {
|
|
407
|
-
const valid = ['single', 'multi-domain', 'portfolio'].includes(mode);
|
|
408
|
-
if (!valid) throw new Error(`Invalid mode: ${mode}`);
|
|
409
|
-
return mode;
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Parse environment from CLI arguments
|
|
416
|
-
* Consolidates environment parsing from enterprise-deploy.js and master-deploy.js
|
|
417
|
-
*/
|
|
418
|
-
static parseEnvironmentFromArgs(options) {
|
|
419
|
-
let environment = options.env || options.environment || process.env.DEPLOY_ENV || 'production';
|
|
420
|
-
|
|
421
|
-
// Validate environment
|
|
422
|
-
const validEnvs = ['production', 'staging', 'development', 'preview'];
|
|
423
|
-
if (!validEnvs.includes(environment)) {
|
|
424
|
-
console.warn(`⚠️ Invalid environment '${environment}', defaulting to 'production'`);
|
|
425
|
-
environment = 'production';
|
|
426
|
-
}
|
|
427
|
-
return environment;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Parse deployment mode from CLI arguments
|
|
432
|
-
*/
|
|
433
|
-
static parseDeploymentModeFromArgs(options) {
|
|
434
|
-
let mode = options.mode || options.deploymentMode || 'single';
|
|
435
|
-
|
|
436
|
-
// Validate mode
|
|
437
|
-
const validModes = ['single', 'multi-domain', 'portfolio'];
|
|
438
|
-
if (!validModes.includes(mode)) {
|
|
439
|
-
console.warn(`⚠️ Invalid mode '${mode}', defaulting to 'single'`);
|
|
440
|
-
mode = 'single';
|
|
441
|
-
}
|
|
442
|
-
return mode;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Factory method to create EnvironmentManager from CLI arguments
|
|
447
|
-
* Consolidates initialization patterns from all three deployment systems
|
|
448
|
-
*/
|
|
449
|
-
static fromCLIArgs(options = {}) {
|
|
450
|
-
const config = {
|
|
451
|
-
environment: this.parseEnvironmentFromArgs(options),
|
|
452
|
-
deploymentMode: this.parseDeploymentModeFromArgs(options),
|
|
453
|
-
defaultEnvironment: options.defaultEnv || 'production',
|
|
454
|
-
validationLevel: options.validationLevel || 'comprehensive',
|
|
455
|
-
auditLevel: options.auditLevel || 'detailed',
|
|
456
|
-
enableRollback: options.enableRollback !== false,
|
|
457
|
-
enableTesting: options.enableTesting !== false,
|
|
458
|
-
...options
|
|
459
|
-
};
|
|
460
|
-
return new EnvironmentManager(config);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Confirm deployment mode before proceeding
|
|
465
|
-
* Consolidates confirmation logic from master-deploy.js
|
|
466
|
-
*/
|
|
467
|
-
async confirmDeploymentMode() {
|
|
468
|
-
console.log('\n🔍 Deployment Mode Confirmation');
|
|
469
|
-
console.log('================================');
|
|
470
|
-
console.log(`Selected Mode: ${this.config.deploymentMode.toUpperCase()}`);
|
|
471
|
-
let modeDescription = '';
|
|
472
|
-
switch (this.config.deploymentMode) {
|
|
473
|
-
case 'single':
|
|
474
|
-
modeDescription = 'Deploy a single domain with full enterprise features';
|
|
475
|
-
break;
|
|
476
|
-
case 'multi-domain':
|
|
477
|
-
modeDescription = 'Deploy multiple domains with cross-domain coordination';
|
|
478
|
-
break;
|
|
479
|
-
case 'portfolio':
|
|
480
|
-
modeDescription = 'Manage entire domain portfolio';
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
console.log(`Description: ${modeDescription}`);
|
|
484
|
-
const confirm = await askYesNo('Proceed with this deployment mode?', 'y');
|
|
485
|
-
if (!confirm) {
|
|
486
|
-
throw new Error('Deployment mode selection cancelled');
|
|
487
|
-
}
|
|
488
|
-
return true;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Get all supported environments
|
|
493
|
-
*/
|
|
494
|
-
getSupportedEnvironments() {
|
|
495
|
-
return this.supportedEnvironments;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Get all supported deployment modes
|
|
500
|
-
*/
|
|
501
|
-
getSupportedDeploymentModes() {
|
|
502
|
-
return this.deploymentModes;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Clean up environment resources
|
|
507
|
-
*/
|
|
508
|
-
async cleanup() {
|
|
509
|
-
if (this.coordinator) {
|
|
510
|
-
await this.coordinator.cleanup();
|
|
511
|
-
}
|
|
512
|
-
if (this.orchestrator) {
|
|
513
|
-
await this.orchestrator.cleanup();
|
|
514
|
-
}
|
|
515
|
-
console.log('✅ Environment manager cleanup completed');
|
|
516
|
-
}
|
|
517
|
-
}
|