@tamyla/clodo-framework 4.0.13 → 4.0.14
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 +11 -0
- package/README.md +7 -0
- package/dist/cli/commands/create.js +2 -1
- package/dist/middleware/Composer.js +38 -0
- package/dist/middleware/Registry.js +14 -0
- package/dist/middleware/index.js +3 -0
- package/dist/middleware/shared/basicAuth.js +21 -0
- package/dist/middleware/shared/cors.js +28 -0
- package/dist/middleware/shared/index.js +3 -0
- package/dist/middleware/shared/logging.js +14 -0
- package/dist/service-management/GenerationEngine.js +13 -2
- package/dist/service-management/ServiceOrchestrator.js +6 -2
- package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +156 -10
- package/dist/service-management/generators/code/WorkerIndexGenerator.js +75 -9
- package/dist/simple-api.js +32 -1
- package/docs/MIDDLEWARE_MIGRATION_SUMMARY.md +121 -0
- package/package.json +4 -1
- package/scripts/DEPLOY_COMMAND_NEW.js +128 -0
- package/scripts/README-automated-testing-suite.md +356 -0
- package/scripts/README-test-clodo-deployment.md +157 -0
- package/scripts/README.md +50 -0
- package/scripts/analyze-imports.ps1 +104 -0
- package/scripts/analyze-mixed-code.js +163 -0
- package/scripts/analyze-mixed-rationale.js +149 -0
- package/scripts/automated-testing-suite.js +776 -0
- package/scripts/deployment/README.md +31 -0
- package/scripts/deployment/deploy-domain.ps1 +449 -0
- package/scripts/deployment/deploy-staging.js +120 -0
- package/scripts/deployment/validate-staging.js +166 -0
- package/scripts/diagnose-imports.js +362 -0
- package/scripts/framework-diagnostic.js +368 -0
- package/scripts/migration/migrate-middleware-legacy-to-contract.js +47 -0
- package/scripts/post-publish-test.js +663 -0
- package/scripts/scan-worker-issues.js +52 -0
- package/scripts/service-management/README.md +27 -0
- package/scripts/service-management/setup-interactive.ps1 +693 -0
- package/scripts/test-clodo-deployment.js +588 -0
- package/scripts/test-downstream-install.js +237 -0
- package/scripts/test-local-package.ps1 +126 -0
- package/scripts/test-local-package.sh +166 -0
- package/scripts/test-package.js +339 -0
- package/scripts/testing/README.md +49 -0
- package/scripts/testing/test-first.ps1 +0 -0
- package/scripts/testing/test-first50.ps1 +0 -0
- package/scripts/testing/test.ps1 +0 -0
- package/scripts/utilities/README.md +61 -0
- package/scripts/utilities/check-bin.js +8 -0
- package/scripts/utilities/check-bundle.js +23 -0
- package/scripts/utilities/check-dist-imports.js +65 -0
- package/scripts/utilities/check-import-paths.js +191 -0
- package/scripts/utilities/cleanup-cli.js +159 -0
- package/scripts/utilities/deployment-helpers.ps1 +199 -0
- package/scripts/utilities/fix-dist-imports.js +135 -0
- package/scripts/utilities/generate-secrets.js +159 -0
- package/scripts/utilities/safe-push.ps1 +51 -0
- package/scripts/utilities/setup-helpers.ps1 +206 -0
- package/scripts/utilities/test-packaged-artifact.js +92 -0
- package/scripts/utilities/validate-dist-imports.js +189 -0
- package/scripts/utilities/validate-schema.js +102 -0
- package/scripts/verify-exports.js +193 -0
- package/scripts/verify-worker-safety.js +73 -0
- package/types/middleware.d.ts +1 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Clodo Service Deployment Testing Script
|
|
2
|
+
|
|
3
|
+
A comprehensive local testing script for the clodo-service deployment process that safely simulates the information collection, consolidation, and deployment execution phases without making actual Cloudflare API calls.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This script tests the complete deployment workflow by:
|
|
8
|
+
1. **Information Collection**: Service detection and manifest parsing
|
|
9
|
+
2. **Consolidation**: Credential gathering and configuration validation
|
|
10
|
+
3. **Execution**: Simulated deployment with detailed phase-by-phase logging
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Basic test (recommended for development)
|
|
16
|
+
node scripts/test-clodo-deployment.js
|
|
17
|
+
|
|
18
|
+
# Test specific phase only
|
|
19
|
+
node scripts/test-clodo-deployment.js --test-phase collection
|
|
20
|
+
node scripts/test-clodo-deployment.js --test-phase consolidation
|
|
21
|
+
node scripts/test-clodo-deployment.js --test-phase execution
|
|
22
|
+
|
|
23
|
+
# Advanced options
|
|
24
|
+
node scripts/test-clodo-deployment.js --verbose --service-path ./my-service
|
|
25
|
+
node scripts/test-clodo-deployment.js --no-mock-credentials # Requires real credentials
|
|
26
|
+
node scripts/test-clodo-deployment.js --no-dry-run # Actually deploy (dangerous!)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Command Line Options
|
|
30
|
+
|
|
31
|
+
| Option | Description | Default |
|
|
32
|
+
|--------|-------------|---------|
|
|
33
|
+
| `--service-path <path>` | Path to service directory | Current directory |
|
|
34
|
+
| `--dry-run` | Simulate deployment without changes | `true` (safe) |
|
|
35
|
+
| `--no-dry-run` | Actually perform deployment | `false` |
|
|
36
|
+
| `--verbose` | Detailed logging output | `false` |
|
|
37
|
+
| `--mock-credentials` | Use mock credentials for testing | `true` (safe) |
|
|
38
|
+
| `--no-mock-credentials` | Require real Cloudflare credentials | `false` |
|
|
39
|
+
| `--test-phase <phase>` | Test specific phase: `all`, `collection`, `consolidation`, `execution` | `all` |
|
|
40
|
+
| `--help` | Show help message | - |
|
|
41
|
+
|
|
42
|
+
## Testing Phases
|
|
43
|
+
|
|
44
|
+
### Phase 1: Information Collection
|
|
45
|
+
- Detects if current directory is a Clodo service project
|
|
46
|
+
- Parses `clodo-service-manifest.json` for service configuration
|
|
47
|
+
- Validates project structure and required files
|
|
48
|
+
- Extracts service name, type, domain, and environment
|
|
49
|
+
|
|
50
|
+
### Phase 2: Consolidation
|
|
51
|
+
- Analyzes credential gathering strategy (flags → env vars → prompt)
|
|
52
|
+
- Consolidates deployment configuration from multiple sources
|
|
53
|
+
- Validates all required information is present
|
|
54
|
+
- Creates comprehensive deployment plan
|
|
55
|
+
|
|
56
|
+
### Phase 3: Execution
|
|
57
|
+
- Simulates complete deployment workflow
|
|
58
|
+
- Tests each deployment phase with realistic timing
|
|
59
|
+
- Validates post-deployment checks
|
|
60
|
+
- Generates mock deployment results
|
|
61
|
+
|
|
62
|
+
## Safety Features
|
|
63
|
+
|
|
64
|
+
- **Dry Run by Default**: No actual deployments or API calls by default
|
|
65
|
+
- **Mock Credentials**: Uses safe test credentials unless explicitly disabled
|
|
66
|
+
- **Comprehensive Validation**: Tests all validation logic without side effects
|
|
67
|
+
- **Detailed Logging**: Shows exactly what would happen in real deployment
|
|
68
|
+
|
|
69
|
+
## Example Output
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
[14:23:15] 🚀 Starting Clodo Service Deployment Testing
|
|
73
|
+
[14:23:15] 📋 Test Phase: all
|
|
74
|
+
[14:23:15] 📋 Service Path: C:\path\to\service
|
|
75
|
+
[14:23:15] 📋 Dry Run: true
|
|
76
|
+
|
|
77
|
+
[14:23:15] 🚀 Phase 1: Information Collection
|
|
78
|
+
[14:23:15] 📋 Step 1: Detecting service project...
|
|
79
|
+
[14:23:15] ✅ Found existing service manifest
|
|
80
|
+
[14:23:15] 📋 Step 2: Parsing service information...
|
|
81
|
+
[14:23:15] 📋 Service Name: my-test-service
|
|
82
|
+
[14:23:15] 📋 Service Type: data-service
|
|
83
|
+
[14:23:15] 📋 Domain: test-service.example.com
|
|
84
|
+
[14:23:15] ✅ Information collection completed in 45ms
|
|
85
|
+
|
|
86
|
+
[14:23:15] 🚀 Phase 2: Information Consolidation
|
|
87
|
+
[14:23:15] 📋 Step 1: Analyzing credential gathering strategy...
|
|
88
|
+
[14:23:15] 📋 Using mock credentials for testing
|
|
89
|
+
[14:23:15] 📋 Credential Sources:
|
|
90
|
+
[14:23:15] 📋 Environment Variables: ❌
|
|
91
|
+
[14:23:15] 📋 Mock Credentials: ✅
|
|
92
|
+
[14:23:15] ✅ Information consolidation completed in 23ms
|
|
93
|
+
|
|
94
|
+
[14:23:15] 🚀 Phase 3: Deployment Execution Simulation
|
|
95
|
+
[14:23:15] 📋 Step 2: Simulating deployment phases...
|
|
96
|
+
[14:23:15] 📋 Executing: Initialization...
|
|
97
|
+
[14:23:15] ✅ Initialization completed
|
|
98
|
+
[14:23:15] 📋 Executing: Configuration Validation...
|
|
99
|
+
[14:23:15] ✅ Configuration Validation completed
|
|
100
|
+
... (additional phases)
|
|
101
|
+
[14:23:16] ✅ Deployment execution simulation completed in 5423ms
|
|
102
|
+
|
|
103
|
+
[14:23:16] 🎉 Clodo Service Deployment Testing Complete
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Use Cases
|
|
107
|
+
|
|
108
|
+
### Development Testing
|
|
109
|
+
```bash
|
|
110
|
+
# Test deployment logic during development
|
|
111
|
+
node scripts/test-clodo-deployment.js --verbose
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### CI/CD Integration
|
|
115
|
+
```bash
|
|
116
|
+
# Validate deployment configuration in CI
|
|
117
|
+
node scripts/test-clodo-deployment.js --test-phase collection --test-phase consolidation
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Debugging
|
|
121
|
+
```bash
|
|
122
|
+
# Isolate specific deployment issues
|
|
123
|
+
node scripts/test-clodo-deployment.js --test-phase execution --verbose
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Service Validation
|
|
127
|
+
```bash
|
|
128
|
+
# Validate service configuration before deployment
|
|
129
|
+
node scripts/test-clodo-deployment.js --service-path ./my-service --test-phase collection
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Integration with Real Deployment
|
|
133
|
+
|
|
134
|
+
The testing script validates the same logic as the actual deployment:
|
|
135
|
+
|
|
136
|
+
1. **Manifest Parsing**: Same JSON parsing and validation as `deploy.js`
|
|
137
|
+
2. **Credential Logic**: Same priority order (flags → env → prompt) as real deployment
|
|
138
|
+
3. **Configuration Consolidation**: Same validation and consolidation logic
|
|
139
|
+
4. **Deployment Phases**: Simulates the same phases as `ModularEnterpriseDeployer`
|
|
140
|
+
|
|
141
|
+
## Troubleshooting
|
|
142
|
+
|
|
143
|
+
### "No manifest found" Error
|
|
144
|
+
The script will create a mock manifest for testing. For real services, ensure `clodo-service-manifest.json` exists.
|
|
145
|
+
|
|
146
|
+
### Credential Issues
|
|
147
|
+
Use `--mock-credentials` for testing, or provide real Cloudflare credentials via environment variables.
|
|
148
|
+
|
|
149
|
+
### Permission Errors
|
|
150
|
+
Ensure the script has read/write access to the service directory.
|
|
151
|
+
|
|
152
|
+
## Related Files
|
|
153
|
+
|
|
154
|
+
- `bin/commands/deploy.js` - Actual deployment command
|
|
155
|
+
- `bin/deployment/modular-enterprise-deploy.js` - Deployment orchestrator
|
|
156
|
+
- `clodo-service-manifest.json` - Service configuration file
|
|
157
|
+
- `README.md` - General framework documentation
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Clodo Framework Scripts
|
|
2
|
+
|
|
3
|
+
This directory contains organized scripts for the Clodo Framework, categorized by functionality.
|
|
4
|
+
|
|
5
|
+
## Categories
|
|
6
|
+
|
|
7
|
+
### service-management/
|
|
8
|
+
Scripts for creating and setting up new services.
|
|
9
|
+
|
|
10
|
+
- `setup-interactive.ps1` - Interactive service setup wizard
|
|
11
|
+
|
|
12
|
+
### deployment/
|
|
13
|
+
Scripts for deploying services to various environments.
|
|
14
|
+
|
|
15
|
+
- `deploy-domain.ps1` - Deploy services to specific domains
|
|
16
|
+
|
|
17
|
+
### testing/
|
|
18
|
+
Scripts for testing services and functionality.
|
|
19
|
+
|
|
20
|
+
- `test.ps1` - Basic test runner
|
|
21
|
+
- `test-first.ps1` - Test first service/item
|
|
22
|
+
- `test-first50.ps1` - Test first 50 services/items
|
|
23
|
+
|
|
24
|
+
### utilities/
|
|
25
|
+
General utility scripts for maintenance and operations.
|
|
26
|
+
|
|
27
|
+
- `check-bundle.js` - Bundle validation script
|
|
28
|
+
- `cleanup-cli.js` - CLI cleanup utilities
|
|
29
|
+
- `generate-secrets.js` - Secret generation utilities
|
|
30
|
+
- `validate-schema.js` - Schema validation tools
|
|
31
|
+
|
|
32
|
+
### database/
|
|
33
|
+
Database-related scripts and utilities.
|
|
34
|
+
|
|
35
|
+
*(Currently empty - database scripts are in bin/database/)*
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
Run scripts from the project root using relative paths:
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
# Service management
|
|
43
|
+
.\scripts\service-management\setup-interactive.ps1
|
|
44
|
+
|
|
45
|
+
# Deployment
|
|
46
|
+
.\scripts\deployment\deploy-domain.ps1 -DomainName example.com
|
|
47
|
+
|
|
48
|
+
# Testing
|
|
49
|
+
.\scripts\testing\test.ps1
|
|
50
|
+
```
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
# Script to extract all imports from documentation and templates
|
|
3
|
+
$results = @()
|
|
4
|
+
$symbolSet = @{}
|
|
5
|
+
|
|
6
|
+
function Extract-Imports {
|
|
7
|
+
param (
|
|
8
|
+
[string]$FilePath,
|
|
9
|
+
[string]$RelativePath
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
$content = Get-Content $FilePath -Raw
|
|
13
|
+
$pattern = "import\s+\{([^}]+)\}\s+from\s+['\`"](@tamyla/clodo-framework[^'\`"]*)['\`"]"
|
|
14
|
+
|
|
15
|
+
$matches = [regex]::Matches($content, $pattern)
|
|
16
|
+
|
|
17
|
+
foreach ($match in $matches) {
|
|
18
|
+
$symbolsString = $match.Groups[1].Value
|
|
19
|
+
$package = $match.Groups[2].Value
|
|
20
|
+
|
|
21
|
+
# Split symbols by comma and clean them
|
|
22
|
+
$symbols = $symbolsString -split ',' | ForEach-Object {
|
|
23
|
+
$_.Trim() -replace '\s+', ' '
|
|
24
|
+
} | Where-Object { $_ -ne '' }
|
|
25
|
+
|
|
26
|
+
foreach ($symbol in $symbols) {
|
|
27
|
+
$key = "$symbol|$package"
|
|
28
|
+
if (-not $symbolSet.ContainsKey($key)) {
|
|
29
|
+
$symbolSet[$key] = @()
|
|
30
|
+
}
|
|
31
|
+
$symbolSet[$key] += $RelativePath
|
|
32
|
+
|
|
33
|
+
$script:results += [PSCustomObject]@{
|
|
34
|
+
Symbol = $symbol
|
|
35
|
+
Package = $package
|
|
36
|
+
File = $RelativePath
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Process README.md
|
|
43
|
+
Write-Host "Processing README.md..."
|
|
44
|
+
Extract-Imports -FilePath "README.md" -RelativePath "README.md"
|
|
45
|
+
|
|
46
|
+
# Process docs/
|
|
47
|
+
Write-Host "Processing docs/..."
|
|
48
|
+
Get-ChildItem -Path "docs" -Filter "*.md" -Recurse | ForEach-Object {
|
|
49
|
+
$relativePath = $_.FullName -replace [regex]::Escape($PWD.Path + "\"), ""
|
|
50
|
+
Extract-Imports -FilePath $_.FullName -RelativePath $relativePath
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Process i-docs/
|
|
54
|
+
Write-Host "Processing i-docs/..."
|
|
55
|
+
Get-ChildItem -Path "i-docs" -Filter "*.md" -Recurse | ForEach-Object {
|
|
56
|
+
$relativePath = $_.FullName -replace [regex]::Escape($PWD.Path + "\"), ""
|
|
57
|
+
Extract-Imports -FilePath $_.FullName -RelativePath $relativePath
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Process templates/
|
|
61
|
+
Write-Host "Processing templates/..."
|
|
62
|
+
Get-ChildItem -Path "templates" -Recurse -Include "*.js","*.md" | ForEach-Object {
|
|
63
|
+
$relativePath = $_.FullName -replace [regex]::Escape($PWD.Path + "\"), ""
|
|
64
|
+
Extract-Imports -FilePath $_.FullName -RelativePath $relativePath
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# Create unique list with file references
|
|
68
|
+
$uniqueImports = @()
|
|
69
|
+
foreach ($key in $symbolSet.Keys) {
|
|
70
|
+
$parts = $key -split '\|'
|
|
71
|
+
$symbol = $parts[0]
|
|
72
|
+
$package = $parts[1]
|
|
73
|
+
$files = $symbolSet[$key] | Select-Object -Unique
|
|
74
|
+
|
|
75
|
+
$uniqueImports += [PSCustomObject]@{
|
|
76
|
+
symbol = $symbol
|
|
77
|
+
package = $package
|
|
78
|
+
foundIn = @($files)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Sort by symbol name
|
|
83
|
+
$uniqueImports = $uniqueImports | Sort-Object -Property symbol
|
|
84
|
+
|
|
85
|
+
# Convert to JSON
|
|
86
|
+
$json = $uniqueImports | ConvertTo-Json -Depth 10
|
|
87
|
+
|
|
88
|
+
# Save to file
|
|
89
|
+
$outputFile = "documented-imports.json"
|
|
90
|
+
$json | Out-File -FilePath $outputFile -Encoding UTF8
|
|
91
|
+
|
|
92
|
+
Write-Host "`nAnalysis complete!"
|
|
93
|
+
Write-Host "Total import statements found: $($results.Count)"
|
|
94
|
+
Write-Host "Unique symbols found: $($uniqueImports.Count)"
|
|
95
|
+
Write-Host "Output saved to: $outputFile"
|
|
96
|
+
|
|
97
|
+
# Display summary
|
|
98
|
+
Write-Host "`nUnique symbols by package:"
|
|
99
|
+
$uniqueImports | Group-Object -Property package | Sort-Object Count -Descending | ForEach-Object {
|
|
100
|
+
Write-Host " $($_.Name): $($_.Count) symbols"
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Return the JSON
|
|
104
|
+
Write-Output $json
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
const workerCompatiblePatterns = [
|
|
9
|
+
/fetch\(/,
|
|
10
|
+
/Response\(/,
|
|
11
|
+
/Request/,
|
|
12
|
+
/env\./,
|
|
13
|
+
/ctx\./,
|
|
14
|
+
/export.*default.*{.*fetch/,
|
|
15
|
+
/initializeService/,
|
|
16
|
+
/createFeatureGuard/,
|
|
17
|
+
/COMMON_FEATURES/,
|
|
18
|
+
/createDomainConfigSchema/,
|
|
19
|
+
/validateDomainConfig/,
|
|
20
|
+
/getDomainFromEnv/,
|
|
21
|
+
/createEnvironmentConfig/
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const nodeOnlyPatterns = [
|
|
25
|
+
/import.*from.*['"]fs['"]/,
|
|
26
|
+
/import.*from.*['"]path['"]/,
|
|
27
|
+
/import.*from.*['"]child_process['"]/,
|
|
28
|
+
/import.*from.*['"]os['"]/,
|
|
29
|
+
/import.*from.*['"]https['"]/,
|
|
30
|
+
/import.*from.*['"]http['"]/,
|
|
31
|
+
/readFileSync|writeFileSync|existsSync|mkdirSync|readdirSync|statSync/,
|
|
32
|
+
/spawn|execSync|exec\(/,
|
|
33
|
+
/process\.cwd\(\)/,
|
|
34
|
+
/__dirname(?!\s*=)/,
|
|
35
|
+
/__filename(?!\s*=)/
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function scanFile(filePath) {
|
|
39
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
40
|
+
const lines = content.split('\n');
|
|
41
|
+
|
|
42
|
+
const workerCode = [];
|
|
43
|
+
const nodeCode = [];
|
|
44
|
+
const potentialMixedLines = [];
|
|
45
|
+
|
|
46
|
+
lines.forEach((line, index) => {
|
|
47
|
+
const lineNum = index + 1;
|
|
48
|
+
const trimmedLine = line.trim();
|
|
49
|
+
|
|
50
|
+
if (trimmedLine.startsWith('//') || trimmedLine.startsWith('*')) return;
|
|
51
|
+
|
|
52
|
+
let hasWorker = false;
|
|
53
|
+
let hasNode = false;
|
|
54
|
+
|
|
55
|
+
for (const pattern of workerCompatiblePatterns) {
|
|
56
|
+
if (pattern.test(trimmedLine)) {
|
|
57
|
+
hasWorker = true;
|
|
58
|
+
workerCode.push({ line: lineNum, content: trimmedLine });
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const pattern of nodeOnlyPatterns) {
|
|
64
|
+
if (pattern.test(trimmedLine)) {
|
|
65
|
+
hasNode = true;
|
|
66
|
+
nodeCode.push({ line: lineNum, content: trimmedLine, pattern: pattern.toString() });
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (hasWorker && hasNode) {
|
|
72
|
+
potentialMixedLines.push({ line: lineNum, content: trimmedLine });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
hasWorkerCode: workerCode.length > 0,
|
|
78
|
+
hasNodeCode: nodeCode.length > 0,
|
|
79
|
+
isMixed: workerCode.length > 0 && nodeCode.length > 0,
|
|
80
|
+
workerCodeCount: workerCode.length,
|
|
81
|
+
nodeCodeCount: nodeCode.length,
|
|
82
|
+
workerCode,
|
|
83
|
+
nodeCode,
|
|
84
|
+
potentialMixedLines
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function scanDirectory(dir, results = []) {
|
|
89
|
+
try {
|
|
90
|
+
const items = fs.readdirSync(dir);
|
|
91
|
+
for (const item of items) {
|
|
92
|
+
const fullPath = path.join(dir, item);
|
|
93
|
+
const stat = fs.statSync(fullPath);
|
|
94
|
+
if (stat.isDirectory() && !item.startsWith('.') && item !== 'node_modules') {
|
|
95
|
+
scanDirectory(fullPath, results);
|
|
96
|
+
} else if (item.endsWith('.js')) {
|
|
97
|
+
const analysis = scanFile(fullPath);
|
|
98
|
+
if (analysis.hasWorkerCode || analysis.hasNodeCode) {
|
|
99
|
+
results.push({
|
|
100
|
+
file: fullPath.replace(process.cwd(), ''),
|
|
101
|
+
...analysis
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch (e) {}
|
|
107
|
+
return results;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log('╔════════════════════════════════════════════════════════════╗');
|
|
111
|
+
console.log('║ DEEP ANALYSIS: Worker vs Node.js Code in Framework ║');
|
|
112
|
+
console.log('╚════════════════════════════════════════════════════════════╝\n');
|
|
113
|
+
|
|
114
|
+
const results = scanDirectory('src');
|
|
115
|
+
|
|
116
|
+
// Categorize results
|
|
117
|
+
const pureNodeOnly = results.filter(r => !r.hasWorkerCode && r.hasNodeCode);
|
|
118
|
+
const pureWorkerCode = results.filter(r => r.hasWorkerCode && !r.hasNodeCode);
|
|
119
|
+
const mixedCode = results.filter(r => r.isMixed);
|
|
120
|
+
|
|
121
|
+
console.log(`📊 OVERALL SUMMARY:`);
|
|
122
|
+
console.log(` Total files analyzed: ${results.length}`);
|
|
123
|
+
console.log(` Pure Node.js only: ${pureNodeOnly.length}`);
|
|
124
|
+
console.log(` Pure Worker code: ${pureWorkerCode.length}`);
|
|
125
|
+
console.log(` MIXED code (both): ${mixedCode.length}\n`);
|
|
126
|
+
|
|
127
|
+
if (mixedCode.length > 0) {
|
|
128
|
+
console.log(`╔════════════════════════════════════════════════════════════╗`);
|
|
129
|
+
console.log(`║ ⚠️ FILES WITH MIXED CODE (Worker + Node.js) ║`);
|
|
130
|
+
console.log(`╚════════════════════════════════════════════════════════════╝\n`);
|
|
131
|
+
|
|
132
|
+
mixedCode.forEach(file => {
|
|
133
|
+
console.log(`\n📄 ${file.file}`);
|
|
134
|
+
console.log(` Worker code lines: ${file.workerCodeCount}`);
|
|
135
|
+
console.log(` Node.js code lines: ${file.nodeCodeCount}`);
|
|
136
|
+
console.log(` Worker patterns found:`);
|
|
137
|
+
file.workerCode.slice(0, 3).forEach(w => {
|
|
138
|
+
console.log(` • Line ${w.line}: ${w.content.substring(0, 60)}`);
|
|
139
|
+
});
|
|
140
|
+
console.log(` Node.js patterns found:`);
|
|
141
|
+
file.nodeCode.slice(0, 3).forEach(n => {
|
|
142
|
+
console.log(` • Line ${n.line}: ${n.content.substring(0, 60)}`);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
console.log(`\n╔════════════════════════════════════════════════════════════╗`);
|
|
148
|
+
console.log(`║ PURE NODE.JS FILES (No Worker Code) ║`);
|
|
149
|
+
console.log(`╚════════════════════════════════════════════════════════════╝\n`);
|
|
150
|
+
|
|
151
|
+
pureNodeOnly.forEach(file => {
|
|
152
|
+
console.log(`${file.file.substring(0, 80)}`);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
console.log(`\n╔════════════════════════════════════════════════════════════╗`);
|
|
156
|
+
console.log(`║ PURE WORKER CODE (No Node.js Dependencies) ║`);
|
|
157
|
+
console.log(`╚════════════════════════════════════════════════════════════╝\n`);
|
|
158
|
+
|
|
159
|
+
pureWorkerCode.forEach(file => {
|
|
160
|
+
console.log(`${file.file.substring(0, 80)}`);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
console.log(`\n\n═══════════════════════════════════════════════════════════\n`);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
const mixedFiles = [
|
|
5
|
+
'src/config/customers.js',
|
|
6
|
+
'src/database/database-orchestrator.js',
|
|
7
|
+
'src/deployment/wrangler-deployer.js',
|
|
8
|
+
'src/orchestration/multi-domain-orchestrator.js',
|
|
9
|
+
'src/service-management/GenerationEngine.js',
|
|
10
|
+
'src/service-management/generators/code/ServiceHandlersGenerator.js',
|
|
11
|
+
'src/service-management/generators/code/ServiceMiddlewareGenerator.js',
|
|
12
|
+
'src/service-management/generators/code/ServiceUtilsGenerator.js',
|
|
13
|
+
'src/service-management/generators/code/WorkerIndexGenerator.js',
|
|
14
|
+
'src/service-management/generators/config/DomainsConfigGenerator.js',
|
|
15
|
+
'src/service-management/generators/config/EnvExampleGenerator.js',
|
|
16
|
+
'src/service-management/generators/config/WranglerTomlGenerator.js',
|
|
17
|
+
'src/service-management/generators/documentation/ApiDocsGenerator.js',
|
|
18
|
+
'src/service-management/generators/documentation/ConfigurationDocsGenerator.js',
|
|
19
|
+
'src/service-management/generators/documentation/ReadmeGenerator.js',
|
|
20
|
+
'src/service-management/generators/schemas/ServiceSchemaGenerator.js',
|
|
21
|
+
'src/service-management/generators/scripts/HealthCheckScriptGenerator.js',
|
|
22
|
+
'src/service-management/generators/scripts/SetupScriptGenerator.js',
|
|
23
|
+
'src/service-management/generators/testing/EslintConfigGenerator.js',
|
|
24
|
+
'src/service-management/generators/testing/IntegrationTestsGenerator.js',
|
|
25
|
+
'src/service-management/generators/testing/UnitTestsGenerator.js',
|
|
26
|
+
'src/service-management/generators/tooling/GitignoreGenerator.js',
|
|
27
|
+
'src/service-management/handlers/ValidationHandler.js',
|
|
28
|
+
'src/service-management/ServiceOrchestrator.js',
|
|
29
|
+
'src/utils/config/unified-config-manager.js',
|
|
30
|
+
'src/utils/deployment/config-cache.js',
|
|
31
|
+
'src/utils/deployment/secret-generator.js',
|
|
32
|
+
'src/utils/deployment/wrangler-config-manager.js',
|
|
33
|
+
'src/utils/framework-config.js'
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
console.log('╔════════════════════════════════════════════════════════════╗');
|
|
37
|
+
console.log('║ ANALYSIS: Why These 29 Files Have Mixed Code ║');
|
|
38
|
+
console.log('╚════════════════════════════════════════════════════════════╝\n');
|
|
39
|
+
|
|
40
|
+
const categories = {
|
|
41
|
+
'GENERATORS THAT SCAFFOLD WORKER CODE': [
|
|
42
|
+
{
|
|
43
|
+
file: 'src/service-management/generators/code/ServiceHandlersGenerator.js',
|
|
44
|
+
reason: 'Writes template files (.js) to disk that contain Worker code (async fetch, Response, etc.). Node.js: fs, path for file writing. Worker: Content it generates has Request/Response.',
|
|
45
|
+
usesNodeFor: 'File generation',
|
|
46
|
+
workerConnection: 'Generates Worker handler files'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
file: 'src/service-management/generators/code/ServiceUtilsGenerator.js',
|
|
50
|
+
reason: 'Generates utility functions for Workers that use env.DB and Response objects. Node.js needed for file operations.',
|
|
51
|
+
usesNodeFor: 'File generation',
|
|
52
|
+
workerConnection: 'Generates utility library for Workers'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
file: 'src/service-management/generators/code/WorkerIndexGenerator.js',
|
|
56
|
+
reason: 'Generates the main Worker entry point file with async fetch() handler. Node.js for file I/O.',
|
|
57
|
+
usesNodeFor: 'File generation',
|
|
58
|
+
workerConnection: 'Generates actual Worker code'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
file: 'src/service-management/generators/testing/IntegrationTestsGenerator.js',
|
|
62
|
+
reason: 'Generates test files that use fetch() and Worker URLs. Node.js for file generation and test setup.',
|
|
63
|
+
usesNodeFor: 'File generation',
|
|
64
|
+
workerConnection: 'Generates tests that target Worker endpoints'
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
'CONFIG GENERATORS FOR WORKER ENVIRONMENTS': [
|
|
68
|
+
{
|
|
69
|
+
file: 'src/service-management/generators/config/WranglerTomlGenerator.js',
|
|
70
|
+
reason: 'Generates wrangler.toml with Worker configuration. References [env] sections for different Worker environments.',
|
|
71
|
+
usesNodeFor: 'File generation',
|
|
72
|
+
workerConnection: 'Generates Worker deployment config'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
file: 'src/service-management/generators/config/DomainsConfigGenerator.js',
|
|
76
|
+
reason: 'Generates domain config files that are used by Workers at runtime.',
|
|
77
|
+
usesNodeFor: 'File generation',
|
|
78
|
+
workerConnection: 'Generates config consumed by Workers'
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
'ORCHESTRATION THAT DEPLOYS TO WORKERS': [
|
|
82
|
+
{
|
|
83
|
+
file: 'src/deployment/wrangler-deployer.js',
|
|
84
|
+
reason: 'Orchestrates wrangler CLI to deploy Workers. Node.js: spawn/execSync for CLI. Worker references: environment detection, URL extraction.',
|
|
85
|
+
usesNodeFor: 'CLI execution for deployment',
|
|
86
|
+
workerConnection: 'Deploys code to Workers'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
file: 'src/orchestration/multi-domain-orchestrator.js',
|
|
90
|
+
reason: 'Coordinates deployments across multiple domains/Workers. Node.js: exec for CLI. Uses process.env to configure deployments.',
|
|
91
|
+
usesNodeFor: 'CLI execution, process.env setup',
|
|
92
|
+
workerConnection: 'Deploys multiple Workers'
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
'CONFIGURATION MANAGERS': [
|
|
96
|
+
{
|
|
97
|
+
file: 'src/config/customers.js',
|
|
98
|
+
reason: 'Loads customer domain configs used by Workers at runtime. Node.js: fs for file loading. Uses createDomainConfigSchema (Worker utility).',
|
|
99
|
+
usesNodeFor: 'File I/O',
|
|
100
|
+
workerConnection: 'Manages config for Worker environments'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
file: 'src/utils/framework-config.js',
|
|
104
|
+
reason: 'Central framework config with extensive environment variable setup for both CLI and Workers.',
|
|
105
|
+
usesNodeFor: 'Path resolution, __dirname setup',
|
|
106
|
+
workerConnection: 'Provides config used by Workers'
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
'PURE GENERATORS (No Worker Connection)': [
|
|
110
|
+
{
|
|
111
|
+
file: 'src/service-management/generators/cicd/DeployWorkflowGenerator.js',
|
|
112
|
+
reason: 'Generates CI/CD workflow files. Node.js for file I/O. No Worker code generated.',
|
|
113
|
+
usesNodeFor: 'File generation',
|
|
114
|
+
workerConnection: 'None - CI/CD automation only'
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
let totalAnalyzed = 0;
|
|
120
|
+
|
|
121
|
+
for (const [category, items] of Object.entries(categories)) {
|
|
122
|
+
console.log(`\n╔════════════════════════════════════════════════════════════╗`);
|
|
123
|
+
console.log(`║ ${category.padEnd(56)}║`);
|
|
124
|
+
console.log(`╚════════════════════════════════════════════════════════════╝\n`);
|
|
125
|
+
|
|
126
|
+
items.forEach(item => {
|
|
127
|
+
totalAnalyzed++;
|
|
128
|
+
console.log(`📄 ${item.file}`);
|
|
129
|
+
console.log(` Why mixed: ${item.reason}`);
|
|
130
|
+
console.log(` Node.js used for: ${item.usesNodeFor}`);
|
|
131
|
+
console.log(` Worker connection: ${item.workerConnection}`);
|
|
132
|
+
console.log();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
console.log(`\n╔════════════════════════════════════════════════════════════╗`);
|
|
137
|
+
console.log(`║ CRITICAL INSIGHT ║`);
|
|
138
|
+
console.log(`╚════════════════════════════════════════════════════════════╝\n`);
|
|
139
|
+
|
|
140
|
+
console.log(`These 29 files have mixed code for a GOOD REASON:\n`);
|
|
141
|
+
console.log(`✅ They generate, configure, or orchestrate Worker deployments`);
|
|
142
|
+
console.log(`✅ They use Node.js APIs for file I/O and CLI execution`);
|
|
143
|
+
console.log(`✅ They reference Worker code patterns as TEMPLATES or CONFIG`);
|
|
144
|
+
console.log(`✅ They never execute IN Workers - only generate for Workers\n`);
|
|
145
|
+
|
|
146
|
+
console.log(`CRITICAL: None of these 29 files should be imported by generated Workers`);
|
|
147
|
+
console.log(`Generated Workers only import from '@tamyla/clodo-framework/worker' path\n`);
|
|
148
|
+
|
|
149
|
+
console.log(`═══════════════════════════════════════════════════════════\n`);
|