-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-setup.js
More file actions
120 lines (107 loc) · 3.71 KB
/
Copy pathcheck-setup.js
File metadata and controls
120 lines (107 loc) · 3.71 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
/**
* CHAD Setup Checker
*
* Run this to verify your CHAD installation is complete.
* Usage: node check-setup.js
*/
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
console.log('CHAD Setup Checker\n' + '='.repeat(50) + '\n');
let hasErrors = false;
let hasWarnings = false;
// Check 1: Node.js version
console.log('✓ Checking Node.js version...');
try {
const nodeVersion = process.version;
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
if (majorVersion >= 18) {
console.log(` ✓ Node.js ${nodeVersion} (OK)\n`);
} else {
console.log(` ✗ Node.js ${nodeVersion} (Need v18 or higher)\n`);
hasErrors = true;
}
} catch (err) {
console.log(' ✗ Failed to check Node.js version\n');
hasErrors = true;
}
// Check 2: CHAD dist folder
console.log('✓ Checking CHAD build...');
const distPath = path.join(__dirname, 'dist');
if (fs.existsSync(distPath)) {
const requiredFiles = ['main.js', 'preload.js', 'loading.html'];
const missingFiles = requiredFiles.filter(f => !fs.existsSync(path.join(distPath, f)));
if (missingFiles.length === 0) {
console.log(' ✓ CHAD is built (dist/ folder contains required files)\n');
} else {
console.log(' ✗ Missing files in dist/:', missingFiles.join(', '));
console.log(' → Run: npm run build\n');
hasErrors = true;
}
} else {
console.log(' ✗ dist/ folder not found');
console.log(' → Run: npm run build\n');
hasErrors = true;
}
// Check 3: CHAD UI (Next.js export)
console.log('✓ Checking CHAD UI...');
const uiPath = path.join(__dirname, 'ui');
const uiOutIndex = path.join(uiPath, 'out', 'index.html');
if (fs.existsSync(uiPath)) {
console.log(' ✓ ui/ directory exists');
if (fs.existsSync(uiOutIndex)) {
console.log(' ✓ ui/out/index.html exists (UI exported)\n');
} else {
console.log(' ✗ ui/out/index.html not found');
console.log(' → Run: npm --prefix ui install && npm --prefix ui run build\n');
hasErrors = true;
}
} else {
console.log(' ✗ ui/ directory not found');
console.log(' → This is a critical error. The UI is missing.\n');
hasErrors = true;
}
// Check 4: Ollama
console.log('✓ Checking Ollama...');
try {
const http = require('http');
const req = http.get('http://localhost:11434/api/tags', (res) => {
if (res.statusCode === 200) {
console.log(' ✓ Ollama is running on localhost:11434\n');
} else {
console.log(' ⚠ Ollama responded but with status:', res.statusCode);
console.log(' → Ollama may not be configured correctly.\n');
hasWarnings = true;
}
});
req.on('error', () => {
console.log(' ✗ Cannot connect to Ollama on localhost:11434');
console.log(' → Make sure Ollama is installed and running');
console.log(' → Start with: ollama serve\n');
hasWarnings = true;
});
req.setTimeout(2000);
req.on('timeout', () => {
req.destroy();
console.log(' ✗ Ollama connection timeout');
console.log(' → Make sure Ollama is running\n');
hasWarnings = true;
});
} catch (err) {
console.log(' ✗ Failed to check Ollama\n');
hasWarnings = true;
}
// Wait a moment for async checks
setTimeout(() => {
console.log('='.repeat(50));
if (!hasErrors && !hasWarnings) {
console.log('✓ All checks passed! CHAD is ready to run.');
console.log('\nRun: npm start');
} else if (hasErrors) {
console.log('✗ Setup incomplete. Fix the errors above and run this script again.');
} else if (hasWarnings) {
console.log('⚠ Setup mostly complete, but there are warnings.');
console.log(' You can try running CHAD, but some features may not work.');
}
console.log('\n' + '='.repeat(50));
}, 2500);