@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,457 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Enterprise Database Manager CLI
|
|
5
|
-
*
|
|
6
|
-
* Advanced database operations and management system for multi-environment
|
|
7
|
-
* database coordination across the entire portfolio using database orchestrator.
|
|
8
|
-
*
|
|
9
|
-
* Database Features:
|
|
10
|
-
* - Multi-environment database operations and coordination
|
|
11
|
-
* - Safe migration execution with rollback capabilities
|
|
12
|
-
* - Cross-domain database synchronization
|
|
13
|
-
* - Advanced backup and restore operations
|
|
14
|
-
* - Database health monitoring and performance tracking
|
|
15
|
-
* - Schema validation and consistency checks
|
|
16
|
-
* - Data integrity verification and repair
|
|
17
|
-
* - Automated maintenance and optimization
|
|
18
|
-
* - Comprehensive audit and compliance reporting
|
|
19
|
-
* - Database disaster recovery management
|
|
20
|
-
*
|
|
21
|
-
* @version 2.0.0 - Enterprise Edition
|
|
22
|
-
*/
|
|
23
|
-
import { program } from 'commander';
|
|
24
|
-
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
25
|
-
import { join } from 'path';
|
|
26
|
-
|
|
27
|
-
// Enterprise module imports - from src/ (framework source)
|
|
28
|
-
import { DatabaseOrchestrator } from "../../database/database-orchestrator.js";
|
|
29
|
-
import { DeploymentAuditor } from "../../deployment/deployment-auditor.js";
|
|
30
|
-
import { CrossDomainCoordinator } from "../../orchestration/cross-domain-coordinator.js";
|
|
31
|
-
|
|
32
|
-
// Shared utilities from bin/shared/
|
|
33
|
-
import { ConfigurationCacheManager } from '../shared/config/cache.js';
|
|
34
|
-
class EnterpriseDatabaseManagerCLI {
|
|
35
|
-
constructor() {
|
|
36
|
-
this.version = '2.0.0';
|
|
37
|
-
this.modules = {};
|
|
38
|
-
this.dbConfig = this.loadDatabaseConfig();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Initialize the CLI asynchronously
|
|
43
|
-
*/
|
|
44
|
-
async initialize() {
|
|
45
|
-
await this.initializeModules();
|
|
46
|
-
this.setupCommands();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Load database configuration
|
|
51
|
-
*/
|
|
52
|
-
loadDatabaseConfig() {
|
|
53
|
-
const configPath = join(process.cwd(), 'database.config.json');
|
|
54
|
-
if (existsSync(configPath)) {
|
|
55
|
-
try {
|
|
56
|
-
return JSON.parse(readFileSync(configPath, 'utf8'));
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.warn('โ ๏ธ Failed to load database config, using defaults');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
environments: ['development', 'staging', 'production'],
|
|
63
|
-
defaultEnvironment: 'production',
|
|
64
|
-
safeMode: true,
|
|
65
|
-
backupBeforeMigration: true,
|
|
66
|
-
maxConcurrentOperations: 3,
|
|
67
|
-
migrationTimeout: 300000,
|
|
68
|
-
// 5 minutes
|
|
69
|
-
healthCheckInterval: 60000,
|
|
70
|
-
// 1 minute
|
|
71
|
-
retentionPeriod: 90,
|
|
72
|
-
// days
|
|
73
|
-
auditLevel: 'detailed',
|
|
74
|
-
complianceMode: false
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Initialize enterprise modules
|
|
80
|
-
*/
|
|
81
|
-
async initializeModules() {
|
|
82
|
-
this.modules = {
|
|
83
|
-
databaseOrchestrator: new DatabaseOrchestrator({
|
|
84
|
-
enableSafeMode: this.dbConfig.safeMode,
|
|
85
|
-
portfolioMode: true,
|
|
86
|
-
maxConcurrentOperations: this.dbConfig.maxConcurrentOperations,
|
|
87
|
-
migrationTimeout: this.dbConfig.migrationTimeout
|
|
88
|
-
}),
|
|
89
|
-
auditor: new DeploymentAuditor({
|
|
90
|
-
auditLevel: this.dbConfig.auditLevel,
|
|
91
|
-
databaseAudit: true
|
|
92
|
-
}),
|
|
93
|
-
coordinator: new CrossDomainCoordinator({
|
|
94
|
-
portfolioName: 'database-portfolio'
|
|
95
|
-
}),
|
|
96
|
-
configCache: new ConfigurationCacheManager({
|
|
97
|
-
enableRuntimeDiscovery: true,
|
|
98
|
-
databaseTemplates: true
|
|
99
|
-
})
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// Initialize async components
|
|
103
|
-
await this.modules.auditor.initialize();
|
|
104
|
-
await this.modules.configCache.initialize();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Setup CLI commands
|
|
109
|
-
*/
|
|
110
|
-
setupCommands() {
|
|
111
|
-
program.name('enterprise-db-manager').description('Enterprise Database Management System - Advanced multi-environment database operations').version(this.version);
|
|
112
|
-
|
|
113
|
-
// Migration commands
|
|
114
|
-
program.command('migrate <domain>').description('Run database migrations for specific domain').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--create-db', 'create database if it doesn\'t exist').option('--backup', 'create backup before migration').option('--dry-run', 'show migrations without executing').option('--force', 'force migration even with validation failures').option('--rollback', 'rollback previous migration').option('--target <version>', 'migrate to specific version').action((domain, options) => this.migrateDomain(domain, options));
|
|
115
|
-
program.command('migrate-all').description('Run database migrations across entire portfolio').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('-f, --filter <pattern>', 'filter domains by pattern').option('--exclude <pattern>', 'exclude domains matching pattern').option('--parallel', 'run migrations in parallel').option('--batch-size <size>', 'batch size for parallel operations', '3').option('--safe-mode', 'enable extra safety checks').option('--dry-run', 'show migrations without executing').option('--rollback', 'rollback all migrations').action(options => this.migrateAll(options));
|
|
116
|
-
program.command('migration-status [domain]').description('Check migration status for domain or entire portfolio').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--format <format>', 'output format (table|json|yaml)', 'table').option('--pending', 'show only pending migrations').action((domain, options) => this.migrationStatus(domain, options));
|
|
117
|
-
|
|
118
|
-
// Schema management
|
|
119
|
-
program.command('schema-validate <domain>').description('Validate database schema for domain').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--fix', 'attempt to fix schema issues').option('--compare <env>', 'compare schema with another environment').option('--report <format>', 'generate validation report (json|html)', 'json').action((domain, options) => this.validateSchema(domain, options));
|
|
120
|
-
program.command('schema-sync').description('Synchronize database schemas across environments').option('--source <env>', 'source environment', 'production').option('--target <env>', 'target environment for sync').option('-f, --filter <pattern>', 'filter domains by pattern').option('--schema-only', 'sync schema only, not data').option('--dry-run', 'show sync plan without executing').option('--force', 'force sync even with conflicts').action(options => this.syncSchemas(options));
|
|
121
|
-
program.command('schema-diff').description('Compare database schemas between environments').option('--source <env>', 'source environment', 'production').option('--target <env>', 'target environment', 'staging').option('-d, --domain <domain>', 'specific domain to compare').option('--format <format>', 'output format (text|json|html)', 'text').action(options => this.schemaDiff(options));
|
|
122
|
-
|
|
123
|
-
// Backup and restore
|
|
124
|
-
program.command('backup <domain>').description('Create database backup for domain').option('-e, --env <environment>', 'source environment', this.dbConfig.defaultEnvironment).option('--compress', 'compress backup files').option('--encrypt', 'encrypt backup data').option('--remote', 'store backup remotely').option('--type <type>', 'backup type (full|schema|data)', 'full').action((domain, options) => this.backupDomain(domain, options));
|
|
125
|
-
program.command('backup-all').description('Create backups for entire portfolio').option('-e, --env <environment>', 'source environment', this.dbConfig.defaultEnvironment).option('-f, --filter <pattern>', 'filter domains by pattern').option('--parallel', 'run backups in parallel').option('--compress', 'compress backup files').option('--encrypt', 'encrypt backup data').option('--type <type>', 'backup type (full|schema|data)', 'full').action(options => this.backupAll(options));
|
|
126
|
-
program.command('restore <domain>').description('Restore database from backup for domain').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--backup-id <id>', 'specific backup ID to restore').option('--backup-file <file>', 'backup file to restore from').option('--type <type>', 'restore type (full|schema|data)', 'full').option('--force', 'force restore without confirmation').action((domain, options) => this.restoreDomain(domain, options));
|
|
127
|
-
program.command('list-backups [domain]').description('List available backups for domain or entire portfolio').option('-e, --env <environment>', 'environment filter').option('--format <format>', 'output format (table|json)', 'table').option('--days <days>', 'show backups from last N days', '30').action((domain, options) => this.listBackups(domain, options));
|
|
128
|
-
|
|
129
|
-
// Health and monitoring
|
|
130
|
-
program.command('health [domain]').description('Check database health for domain or entire portfolio').option('-e, --env <environment>', 'environment to check', this.dbConfig.defaultEnvironment).option('--detailed', 'show detailed health information').option('--format <format>', 'output format (table|json|yaml)', 'table').option('--performance', 'include performance metrics').action((domain, options) => this.checkHealth(domain, options));
|
|
131
|
-
program.command('monitor').description('Start continuous database monitoring').option('-e, --env <environment>', 'environment to monitor', this.dbConfig.defaultEnvironment).option('--interval <ms>', 'monitoring interval', this.dbConfig.healthCheckInterval.toString()).option('--alert-webhook <url>', 'webhook URL for alerts').option('--log-file <path>', 'log monitoring results to file').option('--performance', 'include performance monitoring').action(options => this.startMonitoring(options));
|
|
132
|
-
program.command('stats [domain]').description('Get database statistics and metrics').option('-e, --env <environment>', 'environment to analyze', this.dbConfig.defaultEnvironment).option('--period <days>', 'analysis period in days', '7').option('--format <format>', 'output format (table|json|html)', 'table').option('--export <file>', 'export statistics to file').action((domain, options) => this.getStats(domain, options));
|
|
133
|
-
|
|
134
|
-
// Data management
|
|
135
|
-
program.command('cleanup <domain>').description('Clean up old data from domain database').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--days <days>', 'retention period in days', this.dbConfig.retentionPeriod.toString()).option('--table <table>', 'specific table to clean').option('--dry-run', 'show what would be cleaned').option('--backup', 'create backup before cleanup').action((domain, options) => this.cleanupDomain(domain, options));
|
|
136
|
-
program.command('cleanup-all').description('Clean up old data across entire portfolio').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--days <days>', 'retention period in days', this.dbConfig.retentionPeriod.toString()).option('-f, --filter <pattern>', 'filter domains by pattern').option('--parallel', 'run cleanup in parallel').option('--dry-run', 'show what would be cleaned').action(options => this.cleanupAll(options));
|
|
137
|
-
program.command('optimize <domain>').description('Optimize database performance for domain').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--analyze', 'analyze query performance').option('--reindex', 'rebuild indexes').option('--vacuum', 'vacuum database').option('--dry-run', 'show optimization plan').action((domain, options) => this.optimizeDomain(domain, options));
|
|
138
|
-
|
|
139
|
-
// Data integrity and validation
|
|
140
|
-
program.command('validate <domain>').description('Validate data integrity for domain').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--fix', 'attempt to fix data integrity issues').option('--report <format>', 'generate validation report (json|html)', 'json').option('--deep', 'perform deep validation checks').action((domain, options) => this.validateData(domain, options));
|
|
141
|
-
program.command('validate-all').description('Validate data integrity across entire portfolio').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('-f, --filter <pattern>', 'filter domains by pattern').option('--parallel', 'run validation in parallel').option('--report <format>', 'generate consolidated report (json|html)', 'html').action(options => this.validateAll(options));
|
|
142
|
-
|
|
143
|
-
// Connection and access management
|
|
144
|
-
program.command('connections [domain]').description('Manage database connections for domain or portfolio').option('-e, --env <environment>', 'environment', this.dbConfig.defaultEnvironment).option('--show', 'show active connections').option('--kill <connection-id>', 'kill specific connection').option('--format <format>', 'output format (table|json)', 'table').action((domain, options) => this.manageConnections(domain, options));
|
|
145
|
-
program.command('access').description('Manage database access and permissions').option('--grant <user>', 'grant access to user').option('--revoke <user>', 'revoke access from user').option('--list-users', 'list database users').option('--audit', 'audit access permissions').action(options => this.manageAccess(options));
|
|
146
|
-
|
|
147
|
-
// Disaster recovery
|
|
148
|
-
program.command('disaster-recovery').description('Execute disaster recovery procedures').option('--mode <mode>', 'recovery mode (full|partial|test)', 'test').option('--backup-id <id>', 'backup ID for recovery').option('--target-env <env>', 'target environment for recovery').option('--force', 'force recovery without confirmation').action(options => this.disasterRecovery(options));
|
|
149
|
-
|
|
150
|
-
// Audit and compliance
|
|
151
|
-
program.command('audit [domain]').description('Generate database audit report').option('-e, --env <environment>', 'environment to audit', this.dbConfig.defaultEnvironment).option('--period <days>', 'audit period in days', '30').option('--format <format>', 'report format (json|html|csv)', 'html').option('--compliance', 'include compliance checks').option('--operations', 'include operation history').action((domain, options) => this.generateAudit(domain, options));
|
|
152
|
-
program.command('compliance').description('Run compliance checks on database portfolio').option('--standard <standard>', 'compliance standard (gdpr|hipaa|sox)', 'gdpr').option('--format <format>', 'report format (json|html|pdf)', 'html').option('--fix', 'attempt to fix compliance issues').action(options => this.complianceCheck(options));
|
|
153
|
-
|
|
154
|
-
// Configuration and setup
|
|
155
|
-
program.command('config').description('Manage database configuration').option('--show', 'show current configuration').option('--edit', 'edit configuration interactively').option('--validate', 'validate configuration').option('--template <name>', 'apply configuration template').action(options => this.manageConfig(options));
|
|
156
|
-
program.command('init <domain>').description('Initialize database for new domain').option('-e, --env <environment>', 'target environment', this.dbConfig.defaultEnvironment).option('--template <template>', 'database template to use').option('--seed', 'seed with sample data').option('--force', 'force initialization even if database exists').action((domain, options) => this.initializeDomain(domain, options));
|
|
157
|
-
|
|
158
|
-
// Information and status
|
|
159
|
-
program.command('list').description('List all database domains and their status').option('-e, --env <environment>', 'environment filter').option('--format <format>', 'output format (table|json|yaml)', 'table').option('--show-size', 'include database sizes').option('--show-health', 'include health status').action(options => this.listDomains(options));
|
|
160
|
-
program.command('info <domain>').description('Get detailed information about domain database').option('-e, --env <environment>', 'environment', this.dbConfig.defaultEnvironment).option('--format <format>', 'output format (table|json|yaml)', 'table').option('--schema', 'include schema information').option('--connections', 'include connection information').action((domain, options) => this.getDomainInfo(domain, options));
|
|
161
|
-
|
|
162
|
-
// Global options
|
|
163
|
-
program.option('--verbose', 'verbose output').option('--quiet', 'quiet mode - minimal output').option('--no-color', 'disable colored output').option('--config <file>', 'custom database configuration file');
|
|
164
|
-
|
|
165
|
-
// Parse CLI arguments
|
|
166
|
-
program.parse();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Migrate specific domain
|
|
171
|
-
*/
|
|
172
|
-
async migrateDomain(domain, options) {
|
|
173
|
-
try {
|
|
174
|
-
this.logOutput(`๐๏ธ Running database migration: ${domain}`, 'info');
|
|
175
|
-
const migrationId = this.generateOperationId('migration');
|
|
176
|
-
|
|
177
|
-
// Start audit
|
|
178
|
-
const auditContext = this.modules.auditor.startDeploymentAudit(migrationId, domain, {
|
|
179
|
-
operation: 'database_migration',
|
|
180
|
-
environment: options.env,
|
|
181
|
-
options
|
|
182
|
-
});
|
|
183
|
-
const migrationOptions = {
|
|
184
|
-
environment: options.env,
|
|
185
|
-
createDatabase: options.createDb,
|
|
186
|
-
backupBeforeMigration: options.backup !== false,
|
|
187
|
-
dryRun: options.dryRun,
|
|
188
|
-
force: options.force,
|
|
189
|
-
rollback: options.rollback,
|
|
190
|
-
targetVersion: options.target
|
|
191
|
-
};
|
|
192
|
-
const result = await this.modules.databaseOrchestrator.executeMigration(domain, migrationOptions);
|
|
193
|
-
this.modules.auditor.endDeploymentAudit(migrationId, 'success', {
|
|
194
|
-
migrationsApplied: result.migrationsApplied,
|
|
195
|
-
duration: result.duration
|
|
196
|
-
});
|
|
197
|
-
this.logOutput(`โ
Migration completed: ${result.migrationsApplied} migrations applied`, 'success');
|
|
198
|
-
if (result.warnings?.length > 0) {
|
|
199
|
-
this.logOutput('โ ๏ธ Migration warnings:', 'warn');
|
|
200
|
-
result.warnings.forEach(warning => this.logOutput(` - ${warning}`, 'warn'));
|
|
201
|
-
}
|
|
202
|
-
} catch (error) {
|
|
203
|
-
this.logOutput(`โ Migration failed: ${error.message}`, 'error');
|
|
204
|
-
process.exit(1);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Migrate all domains
|
|
210
|
-
*/
|
|
211
|
-
async migrateAll(options) {
|
|
212
|
-
try {
|
|
213
|
-
this.logOutput('๐ Running portfolio-wide database migrations...', 'info');
|
|
214
|
-
|
|
215
|
-
// Discover portfolio
|
|
216
|
-
const portfolio = await this.modules.coordinator.discoverPortfolio();
|
|
217
|
-
let domains = portfolio.domains.map(d => d.name || d.domain);
|
|
218
|
-
|
|
219
|
-
// Apply filters
|
|
220
|
-
if (options.filter) {
|
|
221
|
-
const filterRegex = new RegExp(options.filter);
|
|
222
|
-
domains = domains.filter(domain => filterRegex.test(domain));
|
|
223
|
-
}
|
|
224
|
-
if (options.exclude) {
|
|
225
|
-
const excludeRegex = new RegExp(options.exclude);
|
|
226
|
-
domains = domains.filter(domain => !excludeRegex.test(domain));
|
|
227
|
-
}
|
|
228
|
-
this.logOutput(`๐ Migrating ${domains.length} domains`, 'info');
|
|
229
|
-
const migrationOptions = {
|
|
230
|
-
environment: options.env,
|
|
231
|
-
parallel: options.parallel,
|
|
232
|
-
batchSize: parseInt(options.batchSize || '3'),
|
|
233
|
-
safeMode: options.safeMode !== false,
|
|
234
|
-
dryRun: options.dryRun,
|
|
235
|
-
rollback: options.rollback
|
|
236
|
-
};
|
|
237
|
-
const results = await this.modules.databaseOrchestrator.coordinateMigrations(domains, migrationOptions);
|
|
238
|
-
this.logOutput('โ
Portfolio migration completed', 'success');
|
|
239
|
-
console.log(` โ
Successful: ${results.successful.length}`);
|
|
240
|
-
console.log(` โ Failed: ${results.failed.length}`);
|
|
241
|
-
console.log(` โฑ๏ธ Total Duration: ${results.totalDuration}s`);
|
|
242
|
-
if (results.failed.length > 0) {
|
|
243
|
-
console.log('\\nโ Failed Migrations:');
|
|
244
|
-
results.failed.forEach(failure => {
|
|
245
|
-
console.log(` - ${failure.domain}: ${failure.error}`);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
} catch (error) {
|
|
249
|
-
this.logOutput(`โ Portfolio migration failed: ${error.message}`, 'error');
|
|
250
|
-
process.exit(1);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Check database health
|
|
256
|
-
*/
|
|
257
|
-
async checkHealth(domain, options) {
|
|
258
|
-
try {
|
|
259
|
-
if (domain) {
|
|
260
|
-
this.logOutput(`โค๏ธ Checking database health: ${domain}`, 'info');
|
|
261
|
-
const health = await this.modules.databaseOrchestrator.checkDatabaseHealth(domain, {
|
|
262
|
-
environment: options.env,
|
|
263
|
-
detailed: options.detailed,
|
|
264
|
-
includePerformance: options.performance
|
|
265
|
-
});
|
|
266
|
-
this.displayHealthResults(health, options);
|
|
267
|
-
} else {
|
|
268
|
-
this.logOutput('โค๏ธ Checking portfolio database health...', 'info');
|
|
269
|
-
const portfolioHealth = await this.modules.databaseOrchestrator.checkPortfolioHealth({
|
|
270
|
-
environment: options.env,
|
|
271
|
-
detailed: options.detailed,
|
|
272
|
-
includePerformance: options.performance
|
|
273
|
-
});
|
|
274
|
-
this.displayPortfolioHealthResults(portfolioHealth, options);
|
|
275
|
-
}
|
|
276
|
-
} catch (error) {
|
|
277
|
-
this.logOutput(`โ Health check failed: ${error.message}`, 'error');
|
|
278
|
-
process.exit(1);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Display health results
|
|
284
|
-
*/
|
|
285
|
-
displayHealthResults(health, options) {
|
|
286
|
-
if (options.format === 'table') {
|
|
287
|
-
console.log(`\\n๐ Database Health: ${health.status}`);
|
|
288
|
-
console.log(` ๐ Connection: ${health.connection ? 'โ
' : 'โ'}`);
|
|
289
|
-
console.log(` ๐ Size: ${health.size || 'N/A'}`);
|
|
290
|
-
console.log(` ๐ข Tables: ${health.tableCount || 'N/A'}`);
|
|
291
|
-
if (options.detailed && health.details) {
|
|
292
|
-
console.log('\\n๐ Detailed Information:');
|
|
293
|
-
Object.entries(health.details).forEach(([key, value]) => {
|
|
294
|
-
console.log(` ${key}: ${value}`);
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
if (options.performance && health.performance) {
|
|
298
|
-
console.log('\\nโก Performance Metrics:');
|
|
299
|
-
Object.entries(health.performance).forEach(([key, value]) => {
|
|
300
|
-
console.log(` ${key}: ${value}`);
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
} else {
|
|
304
|
-
console.log(JSON.stringify(health, null, 2));
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Display portfolio health results
|
|
310
|
-
*/
|
|
311
|
-
displayPortfolioHealthResults(portfolioHealth, options) {
|
|
312
|
-
if (options.format === 'table') {
|
|
313
|
-
console.log('\\n๐ Portfolio Database Health Summary:');
|
|
314
|
-
console.log(` ๐ Total Databases: ${portfolioHealth.summary.total}`);
|
|
315
|
-
console.log(` โ
Healthy: ${portfolioHealth.summary.healthy}`);
|
|
316
|
-
console.log(` โ ๏ธ Warnings: ${portfolioHealth.summary.warnings || 0}`);
|
|
317
|
-
console.log(` โ Unhealthy: ${portfolioHealth.summary.unhealthy}`);
|
|
318
|
-
if (options.detailed) {
|
|
319
|
-
console.log('\\n๐ Database Details:');
|
|
320
|
-
portfolioHealth.databases.forEach(db => {
|
|
321
|
-
const status = db.healthy ? 'โ
' : 'โ';
|
|
322
|
-
console.log(` ${status} ${db.domain} (${db.environment})`);
|
|
323
|
-
if (db.issues?.length > 0) {
|
|
324
|
-
db.issues.forEach(issue => console.log(` - ${issue}`));
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
} else {
|
|
329
|
-
console.log(JSON.stringify(portfolioHealth, null, 2));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Generate operation ID
|
|
335
|
-
*/
|
|
336
|
-
generateOperationId(operation) {
|
|
337
|
-
const timestamp = Date.now().toString(36);
|
|
338
|
-
const random = Math.random().toString(36).substr(2, 9);
|
|
339
|
-
return `${operation}_${timestamp}_${random}`;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Log output with different levels
|
|
344
|
-
*/
|
|
345
|
-
logOutput(message, level = 'info') {
|
|
346
|
-
if (program.opts().quiet && level !== 'error') return;
|
|
347
|
-
const colors = {
|
|
348
|
-
info: '\\x1b[36m',
|
|
349
|
-
// Cyan
|
|
350
|
-
success: '\\x1b[32m',
|
|
351
|
-
// Green
|
|
352
|
-
warn: '\\x1b[33m',
|
|
353
|
-
// Yellow
|
|
354
|
-
error: '\\x1b[31m',
|
|
355
|
-
// Red
|
|
356
|
-
reset: '\\x1b[0m' // Reset
|
|
357
|
-
};
|
|
358
|
-
const useColor = !program.opts().noColor;
|
|
359
|
-
const colorCode = useColor ? colors[level] || colors.info : '';
|
|
360
|
-
const resetCode = useColor ? colors.reset : '';
|
|
361
|
-
console.log(`${colorCode}${message}${resetCode}`);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Placeholder implementations for remaining methods
|
|
366
|
-
*/
|
|
367
|
-
async migrationStatus(domain, options) {
|
|
368
|
-
this.logOutput(`๐ Migration status for ${domain || 'portfolio'} not yet implemented`, 'warn');
|
|
369
|
-
}
|
|
370
|
-
async validateSchema(domain, options) {
|
|
371
|
-
this.logOutput(`๐ Schema validation for ${domain} not yet implemented`, 'warn');
|
|
372
|
-
}
|
|
373
|
-
async syncSchemas(options) {
|
|
374
|
-
this.logOutput(`๐ Schema synchronization not yet implemented`, 'warn');
|
|
375
|
-
}
|
|
376
|
-
async schemaDiff(options) {
|
|
377
|
-
this.logOutput(`๐ Schema diff between ${options.source} and ${options.target} not yet implemented`, 'warn');
|
|
378
|
-
}
|
|
379
|
-
async backupDomain(domain, options) {
|
|
380
|
-
this.logOutput(`๐พ Database backup for ${domain} not yet implemented`, 'warn');
|
|
381
|
-
}
|
|
382
|
-
async backupAll(options) {
|
|
383
|
-
this.logOutput(`๐พ Portfolio backup not yet implemented`, 'warn');
|
|
384
|
-
}
|
|
385
|
-
async restoreDomain(domain, options) {
|
|
386
|
-
this.logOutput(`๐ Database restore for ${domain} not yet implemented`, 'warn');
|
|
387
|
-
}
|
|
388
|
-
async listBackups(domain, options) {
|
|
389
|
-
this.logOutput(`๐ Backup listing for ${domain || 'portfolio'} not yet implemented`, 'warn');
|
|
390
|
-
}
|
|
391
|
-
async startMonitoring(options) {
|
|
392
|
-
this.logOutput(`๐ Database monitoring not yet implemented`, 'warn');
|
|
393
|
-
}
|
|
394
|
-
async getStats(domain, options) {
|
|
395
|
-
this.logOutput(`๐ Database statistics for ${domain || 'portfolio'} not yet implemented`, 'warn');
|
|
396
|
-
}
|
|
397
|
-
async cleanupDomain(domain, options) {
|
|
398
|
-
this.logOutput(`๐งน Database cleanup for ${domain} not yet implemented`, 'warn');
|
|
399
|
-
}
|
|
400
|
-
async cleanupAll(options) {
|
|
401
|
-
this.logOutput(`๐งน Portfolio database cleanup not yet implemented`, 'warn');
|
|
402
|
-
}
|
|
403
|
-
async optimizeDomain(domain, options) {
|
|
404
|
-
this.logOutput(`โก Database optimization for ${domain} not yet implemented`, 'warn');
|
|
405
|
-
}
|
|
406
|
-
async validateData(domain, options) {
|
|
407
|
-
this.logOutput(`๐ Data validation for ${domain} not yet implemented`, 'warn');
|
|
408
|
-
}
|
|
409
|
-
async validateAll(options) {
|
|
410
|
-
this.logOutput(`๐ Portfolio data validation not yet implemented`, 'warn');
|
|
411
|
-
}
|
|
412
|
-
async manageConnections(domain, options) {
|
|
413
|
-
this.logOutput(`๐ Connection management for ${domain || 'portfolio'} not yet implemented`, 'warn');
|
|
414
|
-
}
|
|
415
|
-
async manageAccess(options) {
|
|
416
|
-
this.logOutput(`๐ Access management not yet implemented`, 'warn');
|
|
417
|
-
}
|
|
418
|
-
async disasterRecovery(options) {
|
|
419
|
-
this.logOutput(`๐จ Disaster recovery (${options.mode} mode) not yet implemented`, 'warn');
|
|
420
|
-
}
|
|
421
|
-
async generateAudit(domain, options) {
|
|
422
|
-
this.logOutput(`๐ Database audit for ${domain || 'portfolio'} not yet implemented`, 'warn');
|
|
423
|
-
}
|
|
424
|
-
async complianceCheck(options) {
|
|
425
|
-
this.logOutput(`๐ Compliance check (${options.standard}) not yet implemented`, 'warn');
|
|
426
|
-
}
|
|
427
|
-
async manageConfig(options) {
|
|
428
|
-
this.logOutput(`โ๏ธ Configuration management not yet implemented`, 'warn');
|
|
429
|
-
}
|
|
430
|
-
async initializeDomain(domain, options) {
|
|
431
|
-
this.logOutput(`๐ Database initialization for ${domain} not yet implemented`, 'warn');
|
|
432
|
-
}
|
|
433
|
-
async listDomains(options) {
|
|
434
|
-
this.logOutput(`๐ Database domain listing not yet implemented`, 'warn');
|
|
435
|
-
}
|
|
436
|
-
async getDomainInfo(domain, options) {
|
|
437
|
-
this.logOutput(`๐ Domain information for ${domain} not yet implemented`, 'warn');
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
// Initialize and run CLI
|
|
442
|
-
const cli = new EnterpriseDatabaseManagerCLI();
|
|
443
|
-
cli.initialize().catch(error => {
|
|
444
|
-
console.error('โ Failed to initialize CLI:', error.message);
|
|
445
|
-
process.exit(1);
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
// Handle unhandled errors
|
|
449
|
-
process.on('uncaughtException', error => {
|
|
450
|
-
console.error('โ Uncaught Exception:', error.message);
|
|
451
|
-
process.exit(1);
|
|
452
|
-
});
|
|
453
|
-
process.on('unhandledRejection', (reason, promise) => {
|
|
454
|
-
console.error('โ Unhandled Rejection at:', promise, 'reason:', reason);
|
|
455
|
-
process.exit(1);
|
|
456
|
-
});
|
|
457
|
-
export { EnterpriseDatabaseManagerCLI };
|