-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-site.js
More file actions
executable file
·107 lines (95 loc) · 3.01 KB
/
Copy pathtest-site.js
File metadata and controls
executable file
·107 lines (95 loc) · 3.01 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
#!/usr/bin/env node
const { execSync } = require('child_process');
const http = require('http');
console.log('🧪 Testing bodal.dev site...\n');
// Test 1: Check dependencies
console.log('1️⃣ Checking dependencies...');
try {
execSync('bun pm ls --all', { stdio: 'pipe' });
console.log('✅ All dependencies installed\n');
} catch (error) {
console.log('❌ Missing dependencies. Run: bun install\n');
process.exit(1);
}
// Test 2: TypeScript check
console.log('2️⃣ Running TypeScript checks...');
try {
execSync('bun run typecheck', { stdio: 'pipe' });
console.log('✅ TypeScript checks passed\n');
} catch (error) {
console.log('❌ TypeScript errors found\n');
console.log(error.stdout?.toString());
process.exit(1);
}
// Test 3: Build test
console.log('3️⃣ Testing production build...');
try {
console.log(' Building... (this may take a moment)');
execSync('bun run build', { stdio: 'pipe' });
console.log('✅ Build completed successfully\n');
} catch (error) {
console.log('❌ Build failed\n');
console.log(error.stdout?.toString());
process.exit(1);
}
// Test 4: Start dev server and check if it's running
console.log('4️⃣ Testing development server...');
const { spawn } = require('child_process');
const devServer = spawn('bun', ['run', 'dev'], {
detached: false,
stdio: 'pipe'
});
let serverStarted = false;
let output = '';
devServer.stdout.on('data', (data) => {
output += data.toString();
if (data.toString().includes('Ready in') && !serverStarted) {
serverStarted = true;
console.log('✅ Dev server started successfully');
// Test if server responds
setTimeout(() => {
http.get('http://localhost:3000', (res) => {
if (res.statusCode === 200) {
console.log('✅ Server responding on http://localhost:3000\n');
console.log('🎉 All tests passed! Your site is ready.\n');
console.log('📝 Next steps:');
console.log(' 1. Run: bun run dev');
console.log(' 2. Open: http://localhost:3000');
console.log(' 3. Try typing "help" in the terminal!\n');
devServer.kill();
process.exit(0);
} else {
console.log('❌ Server not responding properly\n');
devServer.kill();
process.exit(1);
}
}).on('error', (err) => {
console.log('❌ Could not connect to server\n');
devServer.kill();
process.exit(1);
});
}, 2000);
}
});
devServer.stderr.on('data', (data) => {
const error = data.toString();
if (error.includes('Error') || error.includes('error')) {
console.log('❌ Dev server error:\n');
console.log(error);
}
});
// Timeout after 10 seconds
setTimeout(() => {
if (!serverStarted) {
console.log('❌ Dev server failed to start within 10 seconds\n');
console.log('Output:', output);
devServer.kill();
process.exit(1);
}
}, 10000);
// Handle Ctrl+C
process.on('SIGINT', () => {
console.log('\n\n⚠️ Test interrupted');
devServer.kill();
process.exit(0);
});