@tamyla/clodo-framework 4.0.12 → 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 +708 -426
- package/README.md +7 -0
- package/dist/cli/commands/create.js +2 -1
- package/dist/deployment/wrangler-deployer.js +1 -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/service-management/generators/config/WranglerTomlGenerator.js +1 -1
- package/dist/simple-api.js +32 -1
- package/docs/MIDDLEWARE_MIGRATION_SUMMARY.md +121 -0
- package/package.json +7 -2
- 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,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DOWNSTREAM USER PACKAGE TEST
|
|
5
|
+
*
|
|
6
|
+
* Simulates exactly what a downstream user does:
|
|
7
|
+
* 1. Creates tarball via npm pack (exactly what npm publish does)
|
|
8
|
+
* 2. Creates fresh directory
|
|
9
|
+
* 3. Runs npm install with the tarball
|
|
10
|
+
* 4. Tests importing all exports
|
|
11
|
+
* 5. Tests CLI commands
|
|
12
|
+
*
|
|
13
|
+
* This catches issues that internal tests miss because it tests
|
|
14
|
+
* the actual packaged distribution, not source files.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import fs from 'fs';
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import { execSync } from 'child_process';
|
|
20
|
+
import { tmpdir } from 'os';
|
|
21
|
+
import { fileURLToPath } from 'url';
|
|
22
|
+
|
|
23
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
const projectRoot = path.join(__dirname, '..');
|
|
25
|
+
|
|
26
|
+
const colors = {
|
|
27
|
+
reset: '\x1b[0m',
|
|
28
|
+
green: '\x1b[32m',
|
|
29
|
+
red: '\x1b[31m',
|
|
30
|
+
yellow: '\x1b[33m',
|
|
31
|
+
blue: '\x1b[34m',
|
|
32
|
+
cyan: '\x1b[36m',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function log(color, text) {
|
|
36
|
+
console.log(`${color}${text}${colors.reset}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function testDownstreamInstall() {
|
|
40
|
+
log(colors.cyan, '\n╔═══════════════════════════════════════════════════════════════╗');
|
|
41
|
+
log(colors.cyan, '║ DOWNSTREAM USER PACKAGE TEST ║');
|
|
42
|
+
log(colors.cyan, '║ Testing tarball installation and imports ║');
|
|
43
|
+
log(colors.cyan, '╚═══════════════════════════════════════════════════════════════╝\n');
|
|
44
|
+
|
|
45
|
+
const testDir = path.join(tmpdir(), `clodo-user-test-${Date.now()}`);
|
|
46
|
+
let tarballPath = null;
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// Step 1: Create tarball
|
|
50
|
+
log(colors.blue, '📦 Step 1: Creating npm tarball');
|
|
51
|
+
log(colors.blue, '─'.repeat(60));
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const output = execSync('npm pack --silent', {
|
|
55
|
+
cwd: projectRoot,
|
|
56
|
+
encoding: 'utf8'
|
|
57
|
+
}).trim();
|
|
58
|
+
|
|
59
|
+
tarballPath = path.join(projectRoot, output);
|
|
60
|
+
if (!fs.existsSync(tarballPath)) {
|
|
61
|
+
throw new Error(`Tarball created but not found: ${tarballPath}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const size = (fs.statSync(tarballPath).size / 1024).toFixed(2);
|
|
65
|
+
log(colors.green, `✅ Created tarball: ${path.basename(tarballPath)} (${size} KB)\n`);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
throw new Error(`Failed to create tarball: ${e.message}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Step 2: Create fresh test directory
|
|
71
|
+
log(colors.blue, '📁 Step 2: Creating fresh test directory');
|
|
72
|
+
log(colors.blue, '─'.repeat(60));
|
|
73
|
+
|
|
74
|
+
if (fs.existsSync(testDir)) {
|
|
75
|
+
fs.rmSync(testDir, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
fs.mkdirSync(testDir, { recursive: true });
|
|
78
|
+
|
|
79
|
+
const packageJson = {
|
|
80
|
+
name: 'clodo-user-test',
|
|
81
|
+
version: '1.0.0',
|
|
82
|
+
type: 'module',
|
|
83
|
+
private: true,
|
|
84
|
+
dependencies: {
|
|
85
|
+
'@tamyla/clodo-framework': `file:${tarballPath}`
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
fs.writeFileSync(
|
|
90
|
+
path.join(testDir, 'package.json'),
|
|
91
|
+
JSON.stringify(packageJson, null, 2)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
log(colors.green, `✅ Created test directory: ${testDir}\n`);
|
|
95
|
+
|
|
96
|
+
// Step 3: Install from tarball
|
|
97
|
+
log(colors.blue, '⬇️ Step 3: Installing package from tarball');
|
|
98
|
+
log(colors.blue, '─'.repeat(60));
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
execSync('npm install --no-save', {
|
|
102
|
+
cwd: testDir,
|
|
103
|
+
stdio: 'pipe',
|
|
104
|
+
encoding: 'utf8'
|
|
105
|
+
});
|
|
106
|
+
log(colors.green, `✅ Installation successful\n`);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
throw new Error(`Failed to install from tarball: ${e.message}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Step 4: Test imports
|
|
112
|
+
log(colors.blue, '🧪 Step 4: Testing module imports');
|
|
113
|
+
log(colors.blue, '─'.repeat(60));
|
|
114
|
+
|
|
115
|
+
const testScript = `
|
|
116
|
+
import('@tamyla/clodo-framework')
|
|
117
|
+
.then(mod => {
|
|
118
|
+
const exports = Object.keys(mod);
|
|
119
|
+
console.log('Loaded exports: ' + exports.length);
|
|
120
|
+
if (exports.length < 20) throw new Error('Not enough exports: ' + exports.length);
|
|
121
|
+
|
|
122
|
+
// Test key exports
|
|
123
|
+
const required = [
|
|
124
|
+
'Clodo', 'SchemaManager', 'ModuleManager', 'initializeService',
|
|
125
|
+
'GenericDataService', 'EnhancedRouter', 'SecurityCLI',
|
|
126
|
+
'ServiceOrchestrator', 'DeploymentValidator'
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
const missing = required.filter(exp => !exports.includes(exp));
|
|
130
|
+
if (missing.length > 0) {
|
|
131
|
+
throw new Error('Missing key exports: ' + missing.join(', '));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
console.log('All key exports present');
|
|
135
|
+
process.exit(0);
|
|
136
|
+
})
|
|
137
|
+
.catch(err => {
|
|
138
|
+
console.error('Import failed: ' + err.message);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
});
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
const testFile = path.join(testDir, 'test-imports.mjs');
|
|
144
|
+
fs.writeFileSync(testFile, testScript);
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
const output = execSync('node test-imports.mjs', {
|
|
148
|
+
cwd: testDir,
|
|
149
|
+
encoding: 'utf8'
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
log(colors.green, `✅ ${output.trim()}\n`);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
throw new Error(`Import test failed: ${e.message}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Step 5: Test CLI commands with actual subcommands
|
|
158
|
+
log(colors.blue, '🛠️ Step 5: Testing CLI commands');
|
|
159
|
+
log(colors.blue, '─'.repeat(60));
|
|
160
|
+
|
|
161
|
+
// On Windows, npm bin shims are bash scripts. Use direct node execution instead
|
|
162
|
+
const cliTests = [
|
|
163
|
+
{
|
|
164
|
+
path: 'dist/cli/clodo-service.js',
|
|
165
|
+
args: '--version',
|
|
166
|
+
name: 'clodo-service --version'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
path: 'dist/cli/clodo-simple.js',
|
|
170
|
+
args: '--help',
|
|
171
|
+
name: 'clodo-simple --help'
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
path: 'dist/cli/security-cli.js',
|
|
175
|
+
args: '--help',
|
|
176
|
+
name: 'clodo-security --help'
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
for (const test of cliTests) {
|
|
181
|
+
try {
|
|
182
|
+
const cliPath = path.join(testDir, 'node_modules/@tamyla/clodo-framework', test.path);
|
|
183
|
+
|
|
184
|
+
if (!fs.existsSync(cliPath)) {
|
|
185
|
+
throw new Error(`CLI file not found: ${cliPath}`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const output = execSync(`node ${cliPath} ${test.args}`, {
|
|
189
|
+
cwd: testDir,
|
|
190
|
+
stdio: 'pipe',
|
|
191
|
+
encoding: 'utf8',
|
|
192
|
+
timeout: 5000
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Check that we got actual output
|
|
196
|
+
if (output && output.trim().length > 0) {
|
|
197
|
+
log(colors.green, `✅ ${test.name} executed successfully`);
|
|
198
|
+
} else {
|
|
199
|
+
throw new Error('No output from command');
|
|
200
|
+
}
|
|
201
|
+
} catch (e) {
|
|
202
|
+
throw new Error(`CLI test failed for ${test.name}: ${e.message}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
log(colors.green, '\n');
|
|
207
|
+
|
|
208
|
+
// Success
|
|
209
|
+
log(colors.cyan, '═'.repeat(60));
|
|
210
|
+
log(colors.green, '✅ ALL DOWNSTREAM USER TESTS PASSED!');
|
|
211
|
+
log(colors.cyan, '═'.repeat(60));
|
|
212
|
+
log(colors.green, `\n🎉 Package is safe for downstream users to install!\n`);
|
|
213
|
+
|
|
214
|
+
process.exit(0);
|
|
215
|
+
|
|
216
|
+
} catch (error) {
|
|
217
|
+
log(colors.red, '\n' + '═'.repeat(60));
|
|
218
|
+
log(colors.red, '❌ DOWNSTREAM USER TEST FAILED');
|
|
219
|
+
log(colors.red, '═'.repeat(60));
|
|
220
|
+
log(colors.red, `\nError: ${error.message}\n`);
|
|
221
|
+
process.exit(1);
|
|
222
|
+
|
|
223
|
+
} finally {
|
|
224
|
+
// Cleanup
|
|
225
|
+
if (fs.existsSync(testDir)) {
|
|
226
|
+
fs.rmSync(testDir, { recursive: true, force: true });
|
|
227
|
+
}
|
|
228
|
+
if (tarballPath && fs.existsSync(tarballPath)) {
|
|
229
|
+
fs.unlinkSync(tarballPath);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
testDownstreamInstall().catch(err => {
|
|
235
|
+
log(colors.red, `\n❌ Fatal error: ${err.message}\n`);
|
|
236
|
+
process.exit(1);
|
|
237
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# Local package testing script for Windows
|
|
3
|
+
|
|
4
|
+
$ErrorActionPreference = "Stop"
|
|
5
|
+
|
|
6
|
+
Write-Host ""
|
|
7
|
+
Write-Host "=========================================================" -ForegroundColor Cyan
|
|
8
|
+
Write-Host " LOCAL PACKAGE TESTING SCRIPT" -ForegroundColor Cyan
|
|
9
|
+
Write-Host "=========================================================" -ForegroundColor Cyan
|
|
10
|
+
Write-Host ""
|
|
11
|
+
|
|
12
|
+
$testsPassed = 0
|
|
13
|
+
$tempDir = Join-Path $env:TEMP "clodo-test-$(Get-Random)"
|
|
14
|
+
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
# Test 1: Build
|
|
18
|
+
Write-Host "[1] Building package..."
|
|
19
|
+
npm run build > $null 2>&1
|
|
20
|
+
Write-Host " OK - Build complete" -ForegroundColor Green
|
|
21
|
+
$testsPassed++
|
|
22
|
+
|
|
23
|
+
# Test 2: Create tarball
|
|
24
|
+
Write-Host "[2] Creating tarball..."
|
|
25
|
+
$tarball = npm pack --silent 2>$null
|
|
26
|
+
if ($tarball) {
|
|
27
|
+
Write-Host " OK - Created: $tarball" -ForegroundColor Green
|
|
28
|
+
$testsPassed++
|
|
29
|
+
} else {
|
|
30
|
+
throw "Failed to create package"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Test 3: Verify import paths in source
|
|
34
|
+
Write-Host "[3] Verifying import paths..."
|
|
35
|
+
$opsContent = Get-Content "dist/utils/cloudflare/ops.js" -Raw
|
|
36
|
+
if ($opsContent -match "from.*lib/shared/cloudflare/ops") {
|
|
37
|
+
Write-Host " OK - ops.js paths correct" -ForegroundColor Green
|
|
38
|
+
} else {
|
|
39
|
+
throw "ops.js has wrong import path"
|
|
40
|
+
}
|
|
41
|
+
$testsPassed++
|
|
42
|
+
|
|
43
|
+
# Test 4: Test CLI
|
|
44
|
+
Write-Host "[4] Testing CLI..."
|
|
45
|
+
$cliOutput = & node dist/cli/clodo-service.js --help 2>&1
|
|
46
|
+
if ($LASTEXITCODE -eq 0) {
|
|
47
|
+
Write-Host " OK - CLI functional" -ForegroundColor Green
|
|
48
|
+
$testsPassed++
|
|
49
|
+
} else {
|
|
50
|
+
throw "CLI test failed"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Test 5: Test module import
|
|
54
|
+
Write-Host "[5] Testing module imports..."
|
|
55
|
+
$testCode = @'
|
|
56
|
+
const mod = require('./dist/index.js');
|
|
57
|
+
if (Object.keys(mod).length > 20) {
|
|
58
|
+
console.log('Module loaded with ' + Object.keys(mod).length + ' exports');
|
|
59
|
+
} else {
|
|
60
|
+
throw 'Not enough exports';
|
|
61
|
+
}
|
|
62
|
+
'@
|
|
63
|
+
$testCode | & node 2>$null
|
|
64
|
+
if ($LASTEXITCODE -eq 0) {
|
|
65
|
+
Write-Host " OK - Module imports work" -ForegroundColor Green
|
|
66
|
+
$testsPassed++
|
|
67
|
+
} else {
|
|
68
|
+
throw "Module import failed"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Test 6: Verify tarball contents
|
|
72
|
+
Write-Host "[6] Verifying tarball structure..."
|
|
73
|
+
$tarballPath = Get-Item $tarball -ErrorAction Stop
|
|
74
|
+
Push-Location $tempDir
|
|
75
|
+
tar -xzf $tarballPath.FullName | Out-Null
|
|
76
|
+
$extractedDir = Get-ChildItem -Directory | Select-Object -First 1
|
|
77
|
+
|
|
78
|
+
if ((Test-Path "$($extractedDir.FullName)/package.json") -and
|
|
79
|
+
(Test-Path "$($extractedDir.FullName)/dist/index.js")) {
|
|
80
|
+
Write-Host " OK - Tarball structure valid" -ForegroundColor Green
|
|
81
|
+
$testsPassed++
|
|
82
|
+
} else {
|
|
83
|
+
throw "Tarball missing required files"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# Success!
|
|
87
|
+
Write-Host ""
|
|
88
|
+
Write-Host "=========================================================" -ForegroundColor Green
|
|
89
|
+
Write-Host "SUCCESS - ALL TESTS PASSED" -ForegroundColor Green
|
|
90
|
+
Write-Host "=========================================================" -ForegroundColor Green
|
|
91
|
+
Write-Host ""
|
|
92
|
+
|
|
93
|
+
$packageSize = "{0:N2} MB" -f ((Get-Item $tarball -ErrorAction SilentlyContinue).Length / 1MB)
|
|
94
|
+
Write-Host "SUMMARY:"
|
|
95
|
+
Write-Host " Package: $tarball"
|
|
96
|
+
Write-Host " Size: $packageSize"
|
|
97
|
+
Write-Host " Tests: $testsPassed/6 passed"
|
|
98
|
+
Write-Host ""
|
|
99
|
+
Write-Host "NEXT STEPS:"
|
|
100
|
+
Write-Host " 1. git add ."
|
|
101
|
+
Write-Host " 2. git commit -m 'fix: correct import paths'"
|
|
102
|
+
Write-Host " 3. git push origin main"
|
|
103
|
+
Write-Host " 4. GitHub Actions will run semantic-release"
|
|
104
|
+
Write-Host ""
|
|
105
|
+
|
|
106
|
+
} catch {
|
|
107
|
+
Write-Host ""
|
|
108
|
+
Write-Host "=========================================================" -ForegroundColor Red
|
|
109
|
+
Write-Host "FAILED - TESTS DID NOT PASS" -ForegroundColor Red
|
|
110
|
+
Write-Host "=========================================================" -ForegroundColor Red
|
|
111
|
+
Write-Host ""
|
|
112
|
+
Write-Host "Error: $_" -ForegroundColor Red
|
|
113
|
+
Write-Host ""
|
|
114
|
+
Write-Host "DO NOT PUSH - Fix issues first!" -ForegroundColor Yellow
|
|
115
|
+
Write-Host ""
|
|
116
|
+
exit 1
|
|
117
|
+
|
|
118
|
+
} finally {
|
|
119
|
+
Pop-Location -ErrorAction SilentlyContinue
|
|
120
|
+
Pop-Location -ErrorAction SilentlyContinue
|
|
121
|
+
Pop-Location -ErrorAction SilentlyContinue
|
|
122
|
+
|
|
123
|
+
if (Test-Path $tempDir) {
|
|
124
|
+
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# scripts/test-local-package.sh
|
|
3
|
+
#
|
|
4
|
+
# Local package testing before semantic release
|
|
5
|
+
# Simulates what npm will receive when published
|
|
6
|
+
#
|
|
7
|
+
# Usage: bash scripts/test-local-package.sh
|
|
8
|
+
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
echo "════════════════════════════════════════════════════════════"
|
|
12
|
+
echo " LOCAL PACKAGE TESTING SCRIPT"
|
|
13
|
+
echo "════════════════════════════════════════════════════════════"
|
|
14
|
+
echo ""
|
|
15
|
+
|
|
16
|
+
# Colors for output
|
|
17
|
+
GREEN='\033[0;32m'
|
|
18
|
+
RED='\033[0;31m'
|
|
19
|
+
YELLOW='\033[1;33m'
|
|
20
|
+
NC='\033[0m' # No Color
|
|
21
|
+
|
|
22
|
+
TEMP_DIR="/tmp/clodo-package-test-$$"
|
|
23
|
+
PACKAGE_NAME="clodo-framework-local.tgz"
|
|
24
|
+
|
|
25
|
+
cleanup() {
|
|
26
|
+
echo ""
|
|
27
|
+
echo "Cleaning up temporary directory: $TEMP_DIR"
|
|
28
|
+
rm -rf "$TEMP_DIR"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
trap cleanup EXIT
|
|
32
|
+
|
|
33
|
+
echo "1️⃣ BUILDING PACKAGE..."
|
|
34
|
+
echo " Running: npm run build"
|
|
35
|
+
npm run build > /dev/null 2>&1
|
|
36
|
+
echo -e " ${GREEN}✅ Build successful${NC}"
|
|
37
|
+
|
|
38
|
+
echo ""
|
|
39
|
+
echo "2️⃣ CREATING TARBALL..."
|
|
40
|
+
echo " Running: npm pack --dry-run"
|
|
41
|
+
if npm pack > /dev/null 2>&1; then
|
|
42
|
+
echo -e " ${GREEN}✅ Package dry-run successful${NC}"
|
|
43
|
+
else
|
|
44
|
+
echo -e " ${RED}❌ Package creation failed${NC}"
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
echo ""
|
|
49
|
+
echo "3️⃣ PACKAGING FOR REAL..."
|
|
50
|
+
TARBALL=$(npm pack --silent)
|
|
51
|
+
echo -e " ${GREEN}✅ Created: $TARBALL${NC}"
|
|
52
|
+
|
|
53
|
+
echo ""
|
|
54
|
+
echo "4️⃣ EXTRACTING PACKAGE..."
|
|
55
|
+
mkdir -p "$TEMP_DIR"
|
|
56
|
+
cd "$TEMP_DIR"
|
|
57
|
+
tar -xzf "../${TARBALL}"
|
|
58
|
+
EXTRACTED_DIR=$(ls -d */ | head -1)
|
|
59
|
+
cd "$EXTRACTED_DIR"
|
|
60
|
+
echo -e " ${GREEN}✅ Extracted to: $EXTRACTED_DIR${NC}"
|
|
61
|
+
|
|
62
|
+
echo ""
|
|
63
|
+
echo "5️⃣ CHECKING PACKAGE STRUCTURE..."
|
|
64
|
+
echo " Verifying critical files exist:"
|
|
65
|
+
|
|
66
|
+
FILES_TO_CHECK=(
|
|
67
|
+
"dist/index.js"
|
|
68
|
+
"dist/cli/clodo-service.js"
|
|
69
|
+
"dist/lib/shared/cloudflare/ops.js"
|
|
70
|
+
"dist/utils/cloudflare/ops.js"
|
|
71
|
+
"dist/simple-api.js"
|
|
72
|
+
"dist/config/validation-config.json"
|
|
73
|
+
"package.json"
|
|
74
|
+
"README.md"
|
|
75
|
+
"LICENSE"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
for file in "${FILES_TO_CHECK[@]}"; do
|
|
79
|
+
if [ -f "$file" ]; then
|
|
80
|
+
echo -e " ${GREEN}✅${NC} $file"
|
|
81
|
+
else
|
|
82
|
+
echo -e " ${RED}❌${NC} $file (MISSING!)"
|
|
83
|
+
exit 1
|
|
84
|
+
fi
|
|
85
|
+
done
|
|
86
|
+
|
|
87
|
+
echo ""
|
|
88
|
+
echo "6️⃣ VERIFYING IMPORT PATHS..."
|
|
89
|
+
echo " Checking dist/utils/cloudflare/ops.js"
|
|
90
|
+
if grep -q "from.*lib/shared/cloudflare/ops.js" "dist/utils/cloudflare/ops.js"; then
|
|
91
|
+
echo -e " ${GREEN}✅${NC} ops.js has correct import path"
|
|
92
|
+
else
|
|
93
|
+
echo -e " ${RED}❌${NC} ops.js has WRONG import path"
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
echo " Checking CLI command imports"
|
|
98
|
+
if grep -q "from '../../lib/shared/utils/cli-options.js'" "dist/cli/commands/create.js"; then
|
|
99
|
+
echo -e " ${GREEN}✅${NC} CLI commands have correct import paths"
|
|
100
|
+
else
|
|
101
|
+
echo -e " ${RED}❌${NC} CLI commands have WRONG import paths"
|
|
102
|
+
exit 1
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
echo ""
|
|
106
|
+
echo "7️⃣ TESTING CLI FROM PACKAGE..."
|
|
107
|
+
echo " Running: node dist/cli/clodo-service.js --help"
|
|
108
|
+
if node dist/cli/clodo-service.js --help > /dev/null 2>&1; then
|
|
109
|
+
echo -e " ${GREEN}✅ CLI works${NC}"
|
|
110
|
+
else
|
|
111
|
+
echo -e " ${RED}❌ CLI is broken${NC}"
|
|
112
|
+
exit 1
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
echo ""
|
|
116
|
+
echo "8️⃣ TESTING MODULE IMPORTS FROM PACKAGE..."
|
|
117
|
+
echo " Testing: require('./dist/index.js')"
|
|
118
|
+
if node -e "
|
|
119
|
+
try {
|
|
120
|
+
const mod = require('./dist/index.js');
|
|
121
|
+
console.log(' ✅ Module imports successfully');
|
|
122
|
+
console.log(' ✅ Found', Object.keys(mod).length, 'exports');
|
|
123
|
+
} catch (e) {
|
|
124
|
+
console.log(' ❌ Module import failed:', e.message);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
" 2>/dev/null; then
|
|
128
|
+
echo -e " ${GREEN}✅ Module imports work${NC}"
|
|
129
|
+
else
|
|
130
|
+
echo -e " ${RED}❌ Module import failed${NC}"
|
|
131
|
+
exit 1
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
echo ""
|
|
135
|
+
echo "9️⃣ TESTING SPECIFIC EXPORTS..."
|
|
136
|
+
node -e "
|
|
137
|
+
const mod = require('./dist/index.js');
|
|
138
|
+
const testExports = ['Clodo', 'ConfigurationManager', 'EnhancedRouter', 'ServiceOrchestrator'];
|
|
139
|
+
|
|
140
|
+
testExports.forEach(exp => {
|
|
141
|
+
if (mod[exp]) {
|
|
142
|
+
console.log(' ✅ ' + exp);
|
|
143
|
+
} else {
|
|
144
|
+
console.log(' ❌ ' + exp + ' NOT FOUND');
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
" 2>/dev/null || exit 1
|
|
149
|
+
|
|
150
|
+
echo ""
|
|
151
|
+
echo "════════════════════════════════════════════════════════════"
|
|
152
|
+
echo -e "${GREEN}✅ ALL LOCAL PACKAGE TESTS PASSED${NC}"
|
|
153
|
+
echo "════════════════════════════════════════════════════════════"
|
|
154
|
+
echo ""
|
|
155
|
+
echo "📦 SUMMARY:"
|
|
156
|
+
echo " Package file: $TARBALL"
|
|
157
|
+
echo " Package size: $(du -h ../"$TARBALL" | cut -f1)"
|
|
158
|
+
echo ""
|
|
159
|
+
echo "🚀 NEXT STEPS:"
|
|
160
|
+
echo " 1. Commit your changes: git add . && git commit -m 'fix: path issues'"
|
|
161
|
+
echo " 2. Push to main: git push origin main"
|
|
162
|
+
echo " 3. GitHub Actions will run semantic-release"
|
|
163
|
+
echo " 4. Package will be published to npm automatically"
|
|
164
|
+
echo ""
|
|
165
|
+
|
|
166
|
+
# Cleanup is automatic via trap
|