-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-deployment.js
More file actions
89 lines (74 loc) · 2.56 KB
/
check-deployment.js
File metadata and controls
89 lines (74 loc) · 2.56 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
#!/usr/bin/env node
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import process from 'process';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log('🚀 Checking deployment readiness...\n');
let errors = [];
let warnings = [];
try {
// Check main package.json
const mainPackage = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'));
console.log('✅ Main package.json found');
// Check server package.json
const serverPackage = JSON.parse(readFileSync(join(__dirname, 'server', 'package.json'), 'utf8'));
console.log('✅ Server package.json found');
// Check for required scripts
if (!mainPackage.scripts.build) {
errors.push('❌ Missing "build" script in main package.json');
} else {
console.log('✅ Build script found');
}
if (!serverPackage.scripts.start) {
errors.push('❌ Missing "start" script in server package.json');
} else {
console.log('✅ Server start script found');
}
// Check for render.yaml
try {
readFileSync(join(__dirname, 'render.yaml'), 'utf8');
console.log('✅ render.yaml found');
} catch {
warnings.push('⚠️ render.yaml not found (optional for manual deployment)');
}
// Check for environment file
try {
readFileSync(join(__dirname, '.env.production'), 'utf8');
console.log('✅ .env.production found');
} catch {
warnings.push('⚠️ .env.production not found');
}
// Check for gitignore
try {
readFileSync(join(__dirname, '.gitignore'), 'utf8');
console.log('✅ .gitignore found');
} catch {
errors.push('❌ .gitignore not found');
}
console.log('\n📋 Summary:');
if (errors.length > 0) {
console.log('\n❌ Errors that must be fixed:');
errors.forEach((error) => console.log(error));
}
if (warnings.length > 0) {
console.log('\n⚠️ Warnings:');
warnings.forEach((warning) => console.log(warning));
}
if (errors.length === 0) {
console.log('\n🎉 Project is ready for deployment!');
console.log('\nNext steps:');
console.log('1. Push your code to GitHub');
console.log('2. Connect your repository to Render.com');
console.log('3. Set up MongoDB Atlas database');
console.log('4. Configure environment variables');
console.log('5. Deploy!');
} else {
console.log('\n🔧 Please fix the errors above before deploying.');
process.exit(1);
}
} catch (error) {
console.error('❌ Error checking deployment readiness:', error.message);
process.exit(1);
}