@tamyla/clodo-framework 1.0.0
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 +564 -0
- package/LICENSE +21 -0
- package/README.md +1393 -0
- package/bin/README.md +71 -0
- package/bin/clodo-service.js +416 -0
- package/bin/security/security-cli.js +96 -0
- package/bin/service-management/README.md +74 -0
- package/bin/service-management/create-service.js +129 -0
- package/bin/service-management/init-service.js +102 -0
- package/bin/service-management/init-service.js.backup +889 -0
- package/bin/shared/config/customer-cli.js +293 -0
- package/dist/config/ConfigurationManager.js +159 -0
- package/dist/config/CustomerConfigCLI.js +220 -0
- package/dist/config/FeatureManager.js +426 -0
- package/dist/config/customers.js +441 -0
- package/dist/config/domains.js +180 -0
- package/dist/config/features.js +225 -0
- package/dist/config/index.js +6 -0
- package/dist/database/database-orchestrator.js +730 -0
- package/dist/database/index.js +4 -0
- package/dist/deployment/auditor.js +971 -0
- package/dist/deployment/index.js +10 -0
- package/dist/deployment/rollback-manager.js +523 -0
- package/dist/deployment/testers/api-tester.js +80 -0
- package/dist/deployment/testers/auth-tester.js +129 -0
- package/dist/deployment/testers/core.js +217 -0
- package/dist/deployment/testers/database-tester.js +105 -0
- package/dist/deployment/testers/index.js +74 -0
- package/dist/deployment/testers/load-tester.js +120 -0
- package/dist/deployment/testers/performance-tester.js +105 -0
- package/dist/deployment/validator.js +558 -0
- package/dist/deployment/wrangler-deployer.js +574 -0
- package/dist/handlers/GenericRouteHandler.js +532 -0
- package/dist/index.js +39 -0
- package/dist/migration/MigrationAdapters.js +562 -0
- package/dist/modules/ModuleManager.js +668 -0
- package/dist/modules/security.js +98 -0
- package/dist/orchestration/cross-domain-coordinator.js +1083 -0
- package/dist/orchestration/index.js +5 -0
- package/dist/orchestration/modules/DeploymentCoordinator.js +258 -0
- package/dist/orchestration/modules/DomainResolver.js +196 -0
- package/dist/orchestration/modules/StateManager.js +332 -0
- package/dist/orchestration/multi-domain-orchestrator.js +255 -0
- package/dist/routing/EnhancedRouter.js +158 -0
- package/dist/schema/SchemaManager.js +778 -0
- package/dist/security/ConfigurationValidator.js +490 -0
- package/dist/security/DeploymentManager.js +208 -0
- package/dist/security/SecretGenerator.js +142 -0
- package/dist/security/SecurityCLI.js +228 -0
- package/dist/security/index.js +51 -0
- package/dist/security/patterns/environment-rules.js +66 -0
- package/dist/security/patterns/insecure-patterns.js +21 -0
- package/dist/service-management/ConfirmationEngine.js +411 -0
- package/dist/service-management/ErrorTracker.js +294 -0
- package/dist/service-management/GenerationEngine.js +3109 -0
- package/dist/service-management/InputCollector.js +237 -0
- package/dist/service-management/ServiceCreator.js +229 -0
- package/dist/service-management/ServiceInitializer.js +448 -0
- package/dist/service-management/ServiceOrchestrator.js +638 -0
- package/dist/service-management/handlers/ConfigMutator.js +130 -0
- package/dist/service-management/handlers/ConfirmationHandler.js +71 -0
- package/dist/service-management/handlers/GenerationHandler.js +80 -0
- package/dist/service-management/handlers/InputHandler.js +59 -0
- package/dist/service-management/handlers/ValidationHandler.js +203 -0
- package/dist/service-management/index.js +7 -0
- package/dist/services/GenericDataService.js +488 -0
- package/dist/shared/cloudflare/domain-discovery.js +562 -0
- package/dist/shared/cloudflare/domain-manager.js +912 -0
- package/dist/shared/cloudflare/index.js +8 -0
- package/dist/shared/cloudflare/ops.js +387 -0
- package/dist/shared/config/cache.js +1167 -0
- package/dist/shared/config/command-config-manager.js +174 -0
- package/dist/shared/config/customer-cli.js +258 -0
- package/dist/shared/config/index.js +9 -0
- package/dist/shared/config/manager.js +289 -0
- package/dist/shared/database/connection-manager.js +338 -0
- package/dist/shared/database/index.js +7 -0
- package/dist/shared/database/orchestrator.js +632 -0
- package/dist/shared/deployment/auditor.js +971 -0
- package/dist/shared/deployment/index.js +10 -0
- package/dist/shared/deployment/rollback-manager.js +523 -0
- package/dist/shared/deployment/validator.js +558 -0
- package/dist/shared/index.js +32 -0
- package/dist/shared/monitoring/health-checker.js +250 -0
- package/dist/shared/monitoring/index.js +8 -0
- package/dist/shared/monitoring/memory-manager.js +382 -0
- package/dist/shared/monitoring/production-monitor.js +390 -0
- package/dist/shared/production-tester/api-tester.js +80 -0
- package/dist/shared/production-tester/auth-tester.js +129 -0
- package/dist/shared/production-tester/core.js +217 -0
- package/dist/shared/production-tester/database-tester.js +105 -0
- package/dist/shared/production-tester/index.js +74 -0
- package/dist/shared/production-tester/load-tester.js +120 -0
- package/dist/shared/production-tester/performance-tester.js +105 -0
- package/dist/shared/security/api-token-manager.js +296 -0
- package/dist/shared/security/index.js +8 -0
- package/dist/shared/security/secret-generator.js +918 -0
- package/dist/shared/security/secure-token-manager.js +379 -0
- package/dist/shared/utils/error-recovery.js +240 -0
- package/dist/shared/utils/graceful-shutdown-manager.js +380 -0
- package/dist/shared/utils/index.js +9 -0
- package/dist/shared/utils/interactive-prompts.js +134 -0
- package/dist/shared/utils/rate-limiter.js +249 -0
- package/dist/utils/ErrorHandler.js +173 -0
- package/dist/utils/deployment/config-cache.js +1160 -0
- package/dist/utils/deployment/index.js +6 -0
- package/dist/utils/deployment/interactive-prompts.js +97 -0
- package/dist/utils/deployment/secret-generator.js +896 -0
- package/dist/utils/dirname-helper.js +35 -0
- package/dist/utils/domain-config.js +159 -0
- package/dist/utils/error-recovery.js +240 -0
- package/dist/utils/esm-helper.js +52 -0
- package/dist/utils/framework-config.js +481 -0
- package/dist/utils/graceful-shutdown-manager.js +379 -0
- package/dist/utils/health-checker.js +114 -0
- package/dist/utils/index.js +36 -0
- package/dist/utils/prompt-handler.js +98 -0
- package/dist/utils/usage-tracker.js +252 -0
- package/dist/utils/validation.js +112 -0
- package/dist/version/VersionDetector.js +723 -0
- package/dist/worker/index.js +4 -0
- package/dist/worker/integration.js +332 -0
- package/docs/FRAMEWORK-ARCHITECTURE-OVERVIEW.md +206 -0
- package/docs/INTEGRATION_GUIDE.md +2045 -0
- package/docs/README.md +82 -0
- package/docs/SECURITY.md +242 -0
- package/docs/deployment/deployment-guide.md +540 -0
- package/docs/overview.md +280 -0
- package/package.json +176 -0
- package/types/index.d.ts +575 -0
package/bin/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Clodo Framework Binaries
|
|
2
|
+
|
|
3
|
+
This directory contains executable scripts and command-line tools for the Clodo Framework.
|
|
4
|
+
|
|
5
|
+
## Categories
|
|
6
|
+
|
|
7
|
+
### service-management/
|
|
8
|
+
Command-line tools for creating and initializing services.
|
|
9
|
+
|
|
10
|
+
- `create-service.js` - Create services from templates
|
|
11
|
+
- `init-service.js` - Initialize services with auto-generated configurations
|
|
12
|
+
|
|
13
|
+
### deployment/
|
|
14
|
+
Enterprise deployment and orchestration tools.
|
|
15
|
+
|
|
16
|
+
- `enterprise-deploy.js` - Advanced enterprise deployment CLI
|
|
17
|
+
- `master-deploy.js` - Master deployment orchestration
|
|
18
|
+
|
|
19
|
+
### database/
|
|
20
|
+
Database management and operations tools.
|
|
21
|
+
|
|
22
|
+
- `enterprise-db-manager.js` - Enterprise database management CLI
|
|
23
|
+
|
|
24
|
+
### portfolio/
|
|
25
|
+
Portfolio and multi-service management tools.
|
|
26
|
+
|
|
27
|
+
- `portfolio-manager.js` - Portfolio management and orchestration
|
|
28
|
+
|
|
29
|
+
### shared/
|
|
30
|
+
Shared utility modules used by other scripts.
|
|
31
|
+
|
|
32
|
+
Contains various utility modules for:
|
|
33
|
+
- Cloudflare operations
|
|
34
|
+
- Configuration management
|
|
35
|
+
- Database connections
|
|
36
|
+
- Deployment auditing
|
|
37
|
+
- Domain discovery
|
|
38
|
+
- Error recovery
|
|
39
|
+
- Health checking
|
|
40
|
+
- Multi-domain orchestration
|
|
41
|
+
- Production monitoring
|
|
42
|
+
- Rollback management
|
|
43
|
+
- Secret management
|
|
44
|
+
- And more...
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
Run scripts from the project root:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Service management
|
|
52
|
+
node bin/service-management/init-service.js my-service --type api-gateway
|
|
53
|
+
|
|
54
|
+
# Deployment
|
|
55
|
+
node bin/deployment/enterprise-deploy.js
|
|
56
|
+
|
|
57
|
+
# Database
|
|
58
|
+
node bin/database/enterprise-db-manager.js
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Global Installation
|
|
62
|
+
|
|
63
|
+
For global installation, you can create symlinks or add to PATH:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Create symlinks (Linux/Mac)
|
|
67
|
+
ln -s $(pwd)/bin/service-management/init-service.js /usr/local/bin/init-service
|
|
68
|
+
|
|
69
|
+
# Or add to PATH
|
|
70
|
+
export PATH="$PATH:$(pwd)/bin/service-management"
|
|
71
|
+
```
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Clodo Framework - Unified Three-Tier Service Management CLI
|
|
5
|
+
*
|
|
6
|
+
* This tool provides a conversational interface for complete service lifecycle management
|
|
7
|
+
* combining service creation, initialization, and deployment preparation.
|
|
8
|
+
*
|
|
9
|
+
* Three-Tier Architecture:
|
|
10
|
+
* 1. Core Input Collection (6 required inputs)
|
|
11
|
+
* 2. Smart Confirmations (15 derived values)
|
|
12
|
+
* 3. Automated Generation (67 configurations + service manifest)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Command } from 'commander';
|
|
16
|
+
import { createInterface } from 'readline';
|
|
17
|
+
import chalk from 'chalk';
|
|
18
|
+
import { ServiceOrchestrator } from '../src/service-management/ServiceOrchestrator.js';
|
|
19
|
+
import { InputCollector } from '../src/service-management/InputCollector.js';
|
|
20
|
+
|
|
21
|
+
const program = new Command();
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.name('clodo-service')
|
|
25
|
+
.description('Unified conversational CLI for Clodo Framework service lifecycle management')
|
|
26
|
+
.version('1.0.0');
|
|
27
|
+
|
|
28
|
+
// Main interactive command
|
|
29
|
+
program
|
|
30
|
+
.command('create')
|
|
31
|
+
.description('Create a new Clodo service with conversational setup')
|
|
32
|
+
.option('-n, --non-interactive', 'Run in non-interactive mode with all required parameters')
|
|
33
|
+
.option('--service-name <name>', 'Service name (required in non-interactive mode)')
|
|
34
|
+
.option('--service-type <type>', 'Service type: data-service, auth-service, content-service, api-gateway, generic', 'generic')
|
|
35
|
+
.option('--domain-name <domain>', 'Domain name (required in non-interactive mode)')
|
|
36
|
+
.option('--cloudflare-token <token>', 'Cloudflare API token (required in non-interactive mode)')
|
|
37
|
+
.option('--cloudflare-account-id <id>', 'Cloudflare account ID (required in non-interactive mode)')
|
|
38
|
+
.option('--cloudflare-zone-id <id>', 'Cloudflare zone ID (required in non-interactive mode)')
|
|
39
|
+
.option('--environment <env>', 'Target environment: development, staging, production', 'development')
|
|
40
|
+
.option('--output-path <path>', 'Output directory for generated service', '.')
|
|
41
|
+
.option('--template-path <path>', 'Path to service templates', './templates')
|
|
42
|
+
.action(async (options) => {
|
|
43
|
+
try {
|
|
44
|
+
const orchestrator = new ServiceOrchestrator({
|
|
45
|
+
interactive: !options.nonInteractive,
|
|
46
|
+
outputPath: options.outputPath,
|
|
47
|
+
templatePath: options.templatePath
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (options.nonInteractive) {
|
|
51
|
+
// Validate required parameters for non-interactive mode
|
|
52
|
+
const required = ['serviceName', 'domainName', 'cloudflareToken', 'cloudflareAccountId', 'cloudflareZoneId'];
|
|
53
|
+
const missing = required.filter(key => !options[key]);
|
|
54
|
+
|
|
55
|
+
if (missing.length > 0) {
|
|
56
|
+
console.error(chalk.red(`Missing required parameters: ${missing.join(', ')}`));
|
|
57
|
+
console.error(chalk.yellow('Use --help for parameter details'));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Convert CLI options to core inputs
|
|
62
|
+
const coreInputs = {
|
|
63
|
+
serviceName: options.serviceName,
|
|
64
|
+
serviceType: options.serviceType,
|
|
65
|
+
domainName: options.domainName,
|
|
66
|
+
cloudflareToken: options.cloudflareToken,
|
|
67
|
+
cloudflareAccountId: options.cloudflareAccountId,
|
|
68
|
+
cloudflareZoneId: options.cloudflareZoneId,
|
|
69
|
+
environment: options.environment
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
await orchestrator.runNonInteractive(coreInputs);
|
|
73
|
+
} else {
|
|
74
|
+
await orchestrator.runInteractive();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log(chalk.green('\n✓ Service creation completed successfully!'));
|
|
78
|
+
console.log(chalk.cyan('Next steps:'));
|
|
79
|
+
console.log(chalk.white(' 1. cd into your new service directory'));
|
|
80
|
+
console.log(chalk.white(' 2. Run npm install'));
|
|
81
|
+
console.log(chalk.white(' 3. Configure additional settings in src/config/domains.js'));
|
|
82
|
+
console.log(chalk.white(' 4. Run npm run deploy to deploy to Cloudflare'));
|
|
83
|
+
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(chalk.red(`\n✗ Service creation failed: ${error.message}`));
|
|
86
|
+
if (error.details) {
|
|
87
|
+
console.error(chalk.yellow(`Details: ${error.details}`));
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Legacy command aliases for backward compatibility
|
|
94
|
+
program
|
|
95
|
+
.command('create-service')
|
|
96
|
+
.description('Legacy alias for create command')
|
|
97
|
+
.action(async (options) => {
|
|
98
|
+
console.log(chalk.yellow('This command is deprecated. Use "clodo-service create" instead.'));
|
|
99
|
+
const createCommand = program.commands.find(cmd => cmd.name() === 'create');
|
|
100
|
+
if (createCommand && createCommand._actionHandler) {
|
|
101
|
+
await createCommand._actionHandler(options || {});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
program
|
|
106
|
+
.command('init-service')
|
|
107
|
+
.description('Legacy alias for create command')
|
|
108
|
+
.action(async (options) => {
|
|
109
|
+
console.log(chalk.yellow('This command is deprecated. Use "clodo-service create" instead.'));
|
|
110
|
+
const createCommand = program.commands.find(cmd => cmd.name() === 'create');
|
|
111
|
+
if (createCommand && createCommand._actionHandler) {
|
|
112
|
+
await createCommand._actionHandler(options || {});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// List available service types
|
|
117
|
+
program
|
|
118
|
+
.command('list-types')
|
|
119
|
+
.description('List available service types and their features')
|
|
120
|
+
.action(() => {
|
|
121
|
+
console.log(chalk.cyan('Available Clodo Framework Service Types:'));
|
|
122
|
+
console.log('');
|
|
123
|
+
|
|
124
|
+
const types = {
|
|
125
|
+
'data-service': ['Authentication', 'Authorization', 'File Storage', 'Search', 'Filtering', 'Pagination'],
|
|
126
|
+
'auth-service': ['Authentication', 'Authorization', 'User Profiles', 'Email Notifications', 'Magic Link Auth'],
|
|
127
|
+
'content-service': ['File Storage', 'Search', 'Filtering', 'Pagination', 'Caching'],
|
|
128
|
+
'api-gateway': ['Authentication', 'Authorization', 'Rate Limiting', 'Caching', 'Monitoring'],
|
|
129
|
+
'generic': ['Logging', 'Monitoring', 'Error Reporting']
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
Object.entries(types).forEach(([type, features]) => {
|
|
133
|
+
console.log(chalk.green(` ${type}`));
|
|
134
|
+
features.forEach(feature => {
|
|
135
|
+
console.log(chalk.white(` • ${feature}`));
|
|
136
|
+
});
|
|
137
|
+
console.log('');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Show usage statistics and plan information
|
|
142
|
+
/*
|
|
143
|
+
program
|
|
144
|
+
.command('usage')
|
|
145
|
+
.description('Show usage statistics and subscription information')
|
|
146
|
+
.action(() => {
|
|
147
|
+
const stats = usageTracker.getUsageStats();
|
|
148
|
+
const license = usageTracker.getLicense();
|
|
149
|
+
const plan = usageTracker.isPaidUser() ? 'Paid' : 'Free';
|
|
150
|
+
|
|
151
|
+
console.log(chalk.cyan('\n📊 Clodo Framework Usage Statistics'));
|
|
152
|
+
console.log('='.repeat(50));
|
|
153
|
+
|
|
154
|
+
if (license && (license.plan === 'founder' || license.plan === 'admin')) {
|
|
155
|
+
console.log(chalk.magenta(`👑 Plan: ${license.plan.charAt(0).toUpperCase() + license.plan.slice(1)} (Unlimited)`));
|
|
156
|
+
console.log(chalk.magenta(`👤 User: ${license.userName} <${license.userEmail}>`));
|
|
157
|
+
} else {
|
|
158
|
+
console.log(chalk.white(`Plan: ${plan}`));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
console.log(chalk.white(`Services Created: ${stats.currentUsage}${stats.limit !== -1 ? `/${stats.limit}` : ''}`));
|
|
162
|
+
console.log(chalk.white(`Environments: ${stats.environments.join(', ')}`));
|
|
163
|
+
console.log(chalk.white(`Premium Features: ${stats.premiumFeatures ? '✅' : '❌'}`));
|
|
164
|
+
|
|
165
|
+
if (stats.daysUntilExpiry && stats.daysUntilExpiry < 36500) { // Not showing expiry for founder licenses
|
|
166
|
+
console.log(chalk.white(`Days Until Expiry: ${stats.daysUntilExpiry}`));
|
|
167
|
+
} else if (license && (license.plan === 'founder' || license.plan === 'admin')) {
|
|
168
|
+
console.log(chalk.magenta(`⏰ Status: Never Expires`));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!usageTracker.isPaidUser()) {
|
|
172
|
+
console.log(chalk.yellow('\n🚀 Upgrade to unlock unlimited usage!'));
|
|
173
|
+
console.log(chalk.white('Visit: https://clodo-framework.com/pricing'));
|
|
174
|
+
} else if (license && (license.plan === 'founder' || license.plan === 'admin')) {
|
|
175
|
+
console.log(chalk.magenta('\n🎉 You have unlimited founder access!'));
|
|
176
|
+
console.log(chalk.white('Thank you for building Clodo Framework!'));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
console.log('');
|
|
180
|
+
});
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
// Upgrade to paid plan (simulated for now)
|
|
184
|
+
/*
|
|
185
|
+
program
|
|
186
|
+
.command('upgrade')
|
|
187
|
+
.description('Upgrade to a paid plan')
|
|
188
|
+
.option('--plan <plan>', 'Plan type: monthly, annual, lifetime', 'monthly')
|
|
189
|
+
.option('--simulate', 'Simulate upgrade without actual payment')
|
|
190
|
+
.action((options) => {
|
|
191
|
+
if (options.simulate) {
|
|
192
|
+
// Simulate license activation
|
|
193
|
+
const license = usageTracker.activateLicense(options.plan, 'simulated');
|
|
194
|
+
console.log(chalk.green('\n🎉 Successfully upgraded to Clodo Framework!'));
|
|
195
|
+
console.log('='.repeat(50));
|
|
196
|
+
console.log(chalk.white(`Plan: ${options.plan.charAt(0).toUpperCase() + options.plan.slice(1)}`));
|
|
197
|
+
console.log(chalk.white(`License ID: ${license.id}`));
|
|
198
|
+
console.log(chalk.white(`Expires: ${new Date(license.expiry).toLocaleDateString()}`));
|
|
199
|
+
console.log(chalk.green('\n✅ You now have unlimited access to all features!'));
|
|
200
|
+
console.log(chalk.cyan('Run "clodo-service usage" to see your new limits.'));
|
|
201
|
+
} else {
|
|
202
|
+
console.log(chalk.cyan('\n🚀 Ready to upgrade to Clodo Framework?'));
|
|
203
|
+
console.log('='.repeat(50));
|
|
204
|
+
console.log(chalk.white('Choose your plan:'));
|
|
205
|
+
console.log(chalk.white('• Monthly: $19/month'));
|
|
206
|
+
console.log(chalk.white('• Annual: $189/year (save 17%)'));
|
|
207
|
+
console.log(chalk.white('• Lifetime: $999 (one-time payment)'));
|
|
208
|
+
console.log('');
|
|
209
|
+
console.log(chalk.yellow('For testing, use: clodo-service upgrade --simulate --plan annual'));
|
|
210
|
+
console.log(chalk.cyan('Real payments coming soon at: https://clodo-framework.com/pricing'));
|
|
211
|
+
}
|
|
212
|
+
console.log('');
|
|
213
|
+
});
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
// Generate founder license (for framework builder and selected team)
|
|
217
|
+
/*
|
|
218
|
+
program
|
|
219
|
+
.command('generate-founder-license')
|
|
220
|
+
.description('Generate unlimited founder license (admin only)')
|
|
221
|
+
.option('--email <email>', 'User email address', 'founder@clodo-framework.com')
|
|
222
|
+
.option('--name <name>', 'User display name', 'Framework Builder')
|
|
223
|
+
.option('--admin', 'Generate admin license instead of founder')
|
|
224
|
+
.action((options) => {
|
|
225
|
+
try {
|
|
226
|
+
let license;
|
|
227
|
+
if (options.admin) {
|
|
228
|
+
license = usageTracker.generateAdminLicense(options.email, options.name);
|
|
229
|
+
console.log(chalk.green('\n🔑 Admin License Generated Successfully!'));
|
|
230
|
+
console.log('='.repeat(50));
|
|
231
|
+
console.log(chalk.white(`License Type: Admin (Unlimited Access)`));
|
|
232
|
+
} else {
|
|
233
|
+
license = usageTracker.generateFounderLicense(options.email, options.name);
|
|
234
|
+
console.log(chalk.green('\n👑 Founder License Generated Successfully!'));
|
|
235
|
+
console.log('='.repeat(50));
|
|
236
|
+
console.log(chalk.white(`License Type: Founder (Unlimited Access)`));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
console.log(chalk.white(`License ID: ${license.id}`));
|
|
240
|
+
console.log(chalk.white(`User: ${license.userName} <${license.userEmail}>`));
|
|
241
|
+
console.log(chalk.white(`Generated: ${new Date(license.generated).toLocaleString()}`));
|
|
242
|
+
console.log(chalk.green('\n✅ Unlimited access granted - never expires!'));
|
|
243
|
+
console.log(chalk.cyan('Run "clodo-service usage" to verify your access.'));
|
|
244
|
+
|
|
245
|
+
} catch (error) {
|
|
246
|
+
console.error(chalk.red(`\n❌ Error generating license: ${error.message}`));
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
console.log('');
|
|
250
|
+
});
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
// Validate service configuration
|
|
254
|
+
program
|
|
255
|
+
.command('validate <service-path>')
|
|
256
|
+
.description('Validate an existing service configuration')
|
|
257
|
+
.action(async (servicePath) => {
|
|
258
|
+
try {
|
|
259
|
+
const orchestrator = new ServiceOrchestrator();
|
|
260
|
+
const result = await orchestrator.validateService(servicePath);
|
|
261
|
+
|
|
262
|
+
if (result.valid) {
|
|
263
|
+
console.log(chalk.green('✓ Service configuration is valid'));
|
|
264
|
+
} else {
|
|
265
|
+
console.log(chalk.red('✗ Service configuration has issues:'));
|
|
266
|
+
result.issues.forEach(issue => {
|
|
267
|
+
console.log(chalk.yellow(` • ${issue}`));
|
|
268
|
+
});
|
|
269
|
+
process.exit(1);
|
|
270
|
+
}
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.error(chalk.red(`Validation failed: ${error.message}`));
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// Update existing service
|
|
278
|
+
program
|
|
279
|
+
.command('update [service-path]')
|
|
280
|
+
.description('Update an existing service configuration')
|
|
281
|
+
.option('-i, --interactive', 'Run in interactive mode to select what to update')
|
|
282
|
+
.option('--domain-name <domain>', 'Update domain name')
|
|
283
|
+
.option('--cloudflare-token <token>', 'Update Cloudflare API token')
|
|
284
|
+
.option('--cloudflare-account-id <id>', 'Update Cloudflare account ID')
|
|
285
|
+
.option('--cloudflare-zone-id <id>', 'Update Cloudflare zone ID')
|
|
286
|
+
.option('--environment <env>', 'Update target environment: development, staging, production')
|
|
287
|
+
.option('--add-feature <feature>', 'Add a feature flag')
|
|
288
|
+
.option('--remove-feature <feature>', 'Remove a feature flag')
|
|
289
|
+
.option('--regenerate-configs', 'Regenerate all configuration files')
|
|
290
|
+
.option('--fix-errors', 'Attempt to fix common configuration errors')
|
|
291
|
+
.action(async (servicePath, options) => {
|
|
292
|
+
try {
|
|
293
|
+
const orchestrator = new ServiceOrchestrator();
|
|
294
|
+
|
|
295
|
+
// Auto-detect service path if not provided
|
|
296
|
+
if (!servicePath) {
|
|
297
|
+
servicePath = await orchestrator.detectServicePath();
|
|
298
|
+
if (!servicePath) {
|
|
299
|
+
console.error(chalk.red('No service path provided and could not auto-detect service directory'));
|
|
300
|
+
console.log(chalk.white('Please run this command from within a service directory or specify the path'));
|
|
301
|
+
process.exit(1);
|
|
302
|
+
}
|
|
303
|
+
console.log(chalk.cyan(`Auto-detected service at: ${servicePath}`));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Validate it's a service directory
|
|
307
|
+
const isValid = await orchestrator.validateService(servicePath);
|
|
308
|
+
if (!isValid.valid) {
|
|
309
|
+
console.log(chalk.yellow('⚠️ Service has configuration issues. Use --fix-errors to attempt automatic fixes.'));
|
|
310
|
+
if (!options.fixErrors) {
|
|
311
|
+
console.log(chalk.white('Issues found:'));
|
|
312
|
+
isValid.issues.forEach(issue => {
|
|
313
|
+
console.log(chalk.yellow(` • ${issue}`));
|
|
314
|
+
});
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (options.interactive) {
|
|
320
|
+
await orchestrator.runInteractiveUpdate(servicePath);
|
|
321
|
+
} else {
|
|
322
|
+
await orchestrator.runNonInteractiveUpdate(servicePath, options);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
console.log(chalk.green('\n✓ Service update completed successfully!'));
|
|
326
|
+
|
|
327
|
+
} catch (error) {
|
|
328
|
+
console.error(chalk.red(`\n✗ Service update failed: ${error.message}`));
|
|
329
|
+
if (error.details) {
|
|
330
|
+
console.error(chalk.yellow(`Details: ${error.details}`));
|
|
331
|
+
}
|
|
332
|
+
if (error.recovery) {
|
|
333
|
+
console.log(chalk.cyan('\n💡 Recovery suggestions:'));
|
|
334
|
+
error.recovery.forEach(suggestion => {
|
|
335
|
+
console.log(chalk.white(` • ${suggestion}`));
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// Diagnose service issues
|
|
343
|
+
program
|
|
344
|
+
.command('diagnose [service-path]')
|
|
345
|
+
.description('Diagnose and report issues with an existing service')
|
|
346
|
+
.option('--deep-scan', 'Perform deep analysis including dependencies and deployment readiness')
|
|
347
|
+
.option('--export-report <file>', 'Export diagnostic report to file')
|
|
348
|
+
.action(async (servicePath, options) => {
|
|
349
|
+
try {
|
|
350
|
+
const orchestrator = new ServiceOrchestrator();
|
|
351
|
+
|
|
352
|
+
// Auto-detect service path if not provided
|
|
353
|
+
if (!servicePath) {
|
|
354
|
+
servicePath = await orchestrator.detectServicePath();
|
|
355
|
+
if (!servicePath) {
|
|
356
|
+
console.error(chalk.red('No service path provided and could not auto-detect service directory'));
|
|
357
|
+
process.exit(1);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
console.log(chalk.cyan('🔍 Diagnosing service...'));
|
|
362
|
+
const diagnosis = await orchestrator.diagnoseService(servicePath, options);
|
|
363
|
+
|
|
364
|
+
// Display results
|
|
365
|
+
console.log(chalk.cyan('\n📋 Diagnostic Report'));
|
|
366
|
+
console.log(chalk.white(`Service: ${diagnosis.serviceName || 'Unknown'}`));
|
|
367
|
+
console.log(chalk.white(`Path: ${servicePath}`));
|
|
368
|
+
|
|
369
|
+
if (diagnosis.errors.length > 0) {
|
|
370
|
+
console.log(chalk.red('\n❌ Critical Errors:'));
|
|
371
|
+
diagnosis.errors.forEach(error => {
|
|
372
|
+
console.log(chalk.red(` • ${error.message}`));
|
|
373
|
+
if (error.location) {
|
|
374
|
+
console.log(chalk.gray(` Location: ${error.location}`));
|
|
375
|
+
}
|
|
376
|
+
if (error.suggestion) {
|
|
377
|
+
console.log(chalk.cyan(` 💡 ${error.suggestion}`));
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (diagnosis.warnings.length > 0) {
|
|
383
|
+
console.log(chalk.yellow('\n⚠️ Warnings:'));
|
|
384
|
+
diagnosis.warnings.forEach(warning => {
|
|
385
|
+
console.log(chalk.yellow(` • ${warning.message}`));
|
|
386
|
+
if (warning.suggestion) {
|
|
387
|
+
console.log(chalk.cyan(` 💡 ${warning.suggestion}`));
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (diagnosis.recommendations.length > 0) {
|
|
393
|
+
console.log(chalk.cyan('\n💡 Recommendations:'));
|
|
394
|
+
diagnosis.recommendations.forEach(rec => {
|
|
395
|
+
console.log(chalk.white(` • ${rec}`));
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Export report if requested
|
|
400
|
+
if (options.exportReport) {
|
|
401
|
+
await orchestrator.exportDiagnosticReport(diagnosis, options.exportReport);
|
|
402
|
+
console.log(chalk.green(`\n📄 Report exported to: ${options.exportReport}`));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Exit with error code if critical issues found
|
|
406
|
+
if (diagnosis.errors.length > 0) {
|
|
407
|
+
process.exit(1);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
} catch (error) {
|
|
411
|
+
console.error(chalk.red(`Diagnosis failed: ${error.message}`));
|
|
412
|
+
process.exit(1);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
program.parse();
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { SecurityCLI } from '../../src/security/SecurityCLI.js';
|
|
4
|
+
|
|
5
|
+
const command = process.argv[2];
|
|
6
|
+
const args = process.argv.slice(3);
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const cli = new SecurityCLI();
|
|
10
|
+
|
|
11
|
+
switch (command) {
|
|
12
|
+
case 'validate':
|
|
13
|
+
const [customer, environment] = args;
|
|
14
|
+
const result = await cli.validateConfiguration(customer, environment);
|
|
15
|
+
if (result.valid) {
|
|
16
|
+
console.log('✅ Security validation passed');
|
|
17
|
+
} else {
|
|
18
|
+
console.log('❌ Security issues found');
|
|
19
|
+
result.securityIssues.forEach(issue => {
|
|
20
|
+
console.log(` ${issue.severity.toUpperCase()}: ${issue.message}`);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
process.exit(result.valid ? 0 : 1);
|
|
24
|
+
break;
|
|
25
|
+
|
|
26
|
+
case 'generate-key':
|
|
27
|
+
const [type, lengthStr] = args;
|
|
28
|
+
const length = lengthStr ? parseInt(lengthStr) : undefined;
|
|
29
|
+
const keyResult = cli.generateKey(type, length);
|
|
30
|
+
if (keyResult.success) {
|
|
31
|
+
console.log(`Generated ${keyResult.type}: ${keyResult.key}`);
|
|
32
|
+
} else {
|
|
33
|
+
console.error(`Key generation failed: ${keyResult.error}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case 'deploy':
|
|
39
|
+
const [deployCustomer, deployEnvironment] = args;
|
|
40
|
+
const dryRun = args.includes('--dry-run');
|
|
41
|
+
const deployResult = await cli.deployWithSecurity(deployCustomer, deployEnvironment, { dryRun });
|
|
42
|
+
if (deployResult.success) {
|
|
43
|
+
console.log(`✅ Deployment ${dryRun ? 'validation' : 'completed'} successfully`);
|
|
44
|
+
} else {
|
|
45
|
+
console.error(`Deployment failed: ${deployResult.error}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case 'generate-config':
|
|
51
|
+
const [configCustomer, configEnvironment] = args;
|
|
52
|
+
const configResult = cli.generateSecureConfig(configCustomer, configEnvironment);
|
|
53
|
+
if (configResult.success) {
|
|
54
|
+
console.log('Generated secure configuration:');
|
|
55
|
+
console.log(JSON.stringify(configResult.config, null, 2));
|
|
56
|
+
} else {
|
|
57
|
+
console.error(`Config generation failed: ${configResult.error}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case 'check-readiness':
|
|
63
|
+
const [readyCustomer, readyEnvironment] = args;
|
|
64
|
+
const readinessResult = cli.checkDeploymentReadiness(readyCustomer, readyEnvironment);
|
|
65
|
+
if (readinessResult.ready) {
|
|
66
|
+
console.log('✅ Deployment ready');
|
|
67
|
+
} else {
|
|
68
|
+
console.log('❌ Deployment not ready:');
|
|
69
|
+
readinessResult.issues.forEach(issue => console.log(` - ${issue}`));
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
default:
|
|
75
|
+
console.log('Clodo Framework Security CLI');
|
|
76
|
+
console.log('');
|
|
77
|
+
console.log('Commands:');
|
|
78
|
+
console.log(' validate <customer> <environment> - Validate configuration security');
|
|
79
|
+
console.log(' generate-key [type] [length] - Generate secure key (api/jwt)');
|
|
80
|
+
console.log(' deploy <customer> <environment> - Deploy with security validation');
|
|
81
|
+
console.log(' generate-config <customer> <env> - Generate secure configuration');
|
|
82
|
+
console.log(' check-readiness <customer> <env> - Check deployment readiness');
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log('Examples:');
|
|
85
|
+
console.log(' clodo-security validate tamyla production');
|
|
86
|
+
console.log(' clodo-security generate-key jwt 64');
|
|
87
|
+
console.log(' clodo-security generate-key content-skimmer');
|
|
88
|
+
console.log(' clodo-security deploy tamyla staging --dry-run');
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
main().catch(error => {
|
|
94
|
+
console.error(`Unexpected error: ${error.message}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Service Management Tools
|
|
2
|
+
|
|
3
|
+
Command-line tools for creating and initializing Clodo Framework services.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
### create-service.js
|
|
8
|
+
Create new services from predefined templates.
|
|
9
|
+
|
|
10
|
+
**Features:**
|
|
11
|
+
- Multiple service types (data-service, auth-service, content-service, api-gateway, generic)
|
|
12
|
+
- Template-based service generation
|
|
13
|
+
- Customizable service configurations
|
|
14
|
+
- Automatic directory structure creation
|
|
15
|
+
|
|
16
|
+
**Usage:**
|
|
17
|
+
```bash
|
|
18
|
+
node bin/service-management/create-service.js my-service --type api-gateway --output ./services
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Options:**
|
|
22
|
+
- `-t, --type <type>` - Service type (default: generic)
|
|
23
|
+
- `-o, --output <path>` - Output directory (default: current directory)
|
|
24
|
+
- `-f, --force` - Overwrite existing service directory
|
|
25
|
+
- `-h, --help` - Show help message
|
|
26
|
+
|
|
27
|
+
### init-service.js
|
|
28
|
+
Initialize services with auto-generated configurations and multi-domain support.
|
|
29
|
+
|
|
30
|
+
**Features:**
|
|
31
|
+
- Auto-generated wrangler.toml configurations
|
|
32
|
+
- Domain-specific settings for multiple domains
|
|
33
|
+
- Service type detection and optimization
|
|
34
|
+
- Cloudflare account and zone integration
|
|
35
|
+
- Multi-domain deployment support
|
|
36
|
+
|
|
37
|
+
**Usage:**
|
|
38
|
+
```bash
|
|
39
|
+
# Single domain
|
|
40
|
+
node bin/service-management/init-service.js my-service --type api-gateway --domains api.example.com
|
|
41
|
+
|
|
42
|
+
# Multiple domains with account/zone info
|
|
43
|
+
node bin/service-management/init-service.js my-service --type api-gateway \
|
|
44
|
+
--domains "api.example.com:account1:zone1,staging.example.com:account2:zone2"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Options:**
|
|
48
|
+
- `-t, --type <type>` - Service type (default: generic)
|
|
49
|
+
- `-d, --domains <domains>` - Comma-separated domains (can include account:zone)
|
|
50
|
+
- `-e, --env <environment>` - Target environment (default: development)
|
|
51
|
+
- `--api-token <token>` - Cloudflare API token for domain discovery
|
|
52
|
+
- `--account-id <id>` - Default Cloudflare account ID
|
|
53
|
+
- `--zone-id <id>` - Default Cloudflare zone ID
|
|
54
|
+
- `-o, --output <path>` - Output directory (services created in services/ subdirectory)
|
|
55
|
+
- `-f, --force` - Overwrite existing service directory
|
|
56
|
+
- `--dry-run` - Show what would be created without creating files
|
|
57
|
+
- `--multi-domain` - Generate configurations for multiple domains
|
|
58
|
+
|
|
59
|
+
## Directory Structure
|
|
60
|
+
|
|
61
|
+
Services are automatically organized as:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
your-project/
|
|
65
|
+
├── services/ # Auto-created services directory
|
|
66
|
+
│ ├── my-api-service/ # Individual service directories
|
|
67
|
+
│ │ ├── wrangler.toml # Cloudflare config
|
|
68
|
+
│ │ ├── src/config/domains.js # Domain configurations
|
|
69
|
+
│ │ ├── src/worker/index.js # Service worker
|
|
70
|
+
│ │ └── package.json # Dependencies
|
|
71
|
+
│ ├── auth-service/ # Another service
|
|
72
|
+
│ └── data-service/ # Another service
|
|
73
|
+
└── other-project-files/
|
|
74
|
+
```
|