Repository navigation
Expand file tree
/
Copy pathtest-plugin-architecture.js
More file actions
executable file
Β·164 lines (141 loc) Β· 5.2 KB
/
Copy pathtest-plugin-architecture.js
File metadata and controls
executable file
Β·164 lines (141 loc) Β· 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env node
/**
* Test script to verify plugin architecture works
*/
console.log('\nπ Testing REFLUX Plugin Architecture\n');
console.log('=' .repeat(60));
// Test 1: Core package should NOT have n8n dependencies
console.log('\n[Test 1] Checking @reflux/core is n8n-free...');
try {
const corePackage = require('./packages/core/package.json');
const hasTn8n = Object.keys(corePackage.dependencies || {}).some(dep => dep.includes('n8n'));
if (hasTn8n) {
console.log('β FAILED: Core package has n8n dependencies');
process.exit(1);
}
console.log('β
PASSED: Core package is n8n-free');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 2: Adapter package SHOULD have n8n dependencies
console.log('\n[Test 2] Checking @reflux/adapter-n8n has n8n...');
try {
const adapterPackage = require('./packages/adapter-n8n/package.json');
const hasN8n = Object.keys(adapterPackage.dependencies || {}).some(dep => dep.includes('n8n'));
if (!hasN8n) {
console.log('β FAILED: Adapter package missing n8n dependencies');
process.exit(1);
}
console.log('β
PASSED: Adapter package has n8n dependencies');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 3: Check adapter exports loadN8nNode
console.log('\n[Test 3] Checking adapter exports loadN8nNode...');
try {
const fs = require('fs');
const adapterDts = fs.readFileSync('./packages/adapter-n8n/dist/adapter.d.ts', 'utf8');
if (!adapterDts.includes('loadN8nNode')) {
console.log('β FAILED: Adapter does not export loadN8nNode');
process.exit(1);
}
console.log('β
PASSED: Adapter exports loadN8nNode');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 4: Check core dist exists
console.log('\n[Test 4] Checking core build output...');
try {
const fs = require('fs');
const coreDistExists = fs.existsSync('./packages/core/dist/index.js');
if (!coreDistExists) {
console.log('β FAILED: Core dist/index.js not found');
process.exit(1);
}
console.log('β
PASSED: Core build output exists');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 5: Check adapter dist exists
console.log('\n[Test 5] Checking adapter build output...');
try {
const fs = require('fs');
const adapterDistExists = fs.existsSync('./packages/adapter-n8n/dist/index.js');
if (!adapterDistExists) {
console.log('β FAILED: Adapter dist/index.js not found');
process.exit(1);
}
console.log('β
PASSED: Adapter build output exists');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 6: Check LICENSE files
console.log('\n[Test 6] Checking LICENSE files...');
try {
const fs = require('fs');
// Check core LICENSE (should be MIT) - skip if not exists, not critical for test
try {
const rootLicense = fs.readFileSync('./LICENSE', 'utf8');
if (!rootLicense.includes('MIT')) {
console.log('β οΈ WARNING: Root LICENSE is not MIT');
}
} catch {
console.log('β οΈ WARNING: Root LICENSE not found (expected for fresh setup)');
}
// Check adapter LICENSE (should mention Sustainable Use)
const adapterLicense = fs.readFileSync('./packages/adapter-n8n/LICENSE.md', 'utf8');
if (!adapterLicense.includes('Sustainable Use')) {
console.log('β FAILED: Adapter LICENSE missing Sustainable Use');
process.exit(1);
}
console.log('β
PASSED: LICENSE files correct');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 7: Check API has optional import
console.log('\n[Test 7] Checking API has optional import...');
try {
const fs = require('fs');
const apiRoutes = fs.readFileSync('./packages/api/src/routes/nodes.ts', 'utf8');
if (!apiRoutes.includes('@ts-ignore')) {
console.log('β FAILED: API missing @ts-ignore for optional import');
process.exit(1);
}
if (!apiRoutes.includes('n8nAdapterAvailable')) {
console.log('β FAILED: API missing n8nAdapterAvailable flag');
process.exit(1);
}
console.log('β
PASSED: API has optional import logic');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
// Test 8: Check no old imports remain
console.log('\n[Test 8] Checking no old imports remain...');
try {
const fs = require('fs');
const coreIndex = fs.readFileSync('./packages/core/src/index.ts', 'utf8');
if (coreIndex.includes('n8n-node-adapter') || coreIndex.includes('n8n-node-cache')) {
console.log('β FAILED: Core still has old n8n adapter imports');
process.exit(1);
}
console.log('β
PASSED: No old imports in core');
} catch (err) {
console.log('β FAILED:', err.message);
process.exit(1);
}
console.log('\n' + '='.repeat(60));
console.log('\nβ
All tests passed! Plugin architecture is working correctly.\n');
console.log('Summary:');
console.log(' - Core: MIT licensed, n8n-free β');
console.log(' - Adapter: Sustainable Use License, optional β');
console.log(' - API: Optional import with graceful degradation β');
console.log(' - Builds: All packages compile successfully β');
console.log(' - Licenses: Correctly documented β');
console.log('\nπ Plugin architecture verification complete!\n');