-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-setup.js
More file actions
124 lines (101 loc) Β· 4.27 KB
/
verify-setup.js
File metadata and controls
124 lines (101 loc) Β· 4.27 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
#!/usr/bin/env node
/**
* ClickShield Setup Verification Script
* Run this to verify your local development environment is configured correctly
*/
const fs = require('fs');
const path = require('path');
console.log('\nπ‘οΈ ClickShield Setup Verification\n');
console.log('='.repeat(50));
let errors = [];
let warnings = [];
let success = [];
// Check 1: Node.js version
console.log('\nβ Checking Node.js version...');
const nodeVersion = process.version;
const majorVersion = parseInt(nodeVersion.split('.')[0].replace('v', ''));
if (majorVersion >= 18) {
success.push(`Node.js ${nodeVersion} β`);
} else {
errors.push(`Node.js version ${nodeVersion} is too old. Need v18+`);
}
// Check 2: .env file exists
console.log('β Checking .env file...');
const envPath = path.join(process.cwd(), '.env');
if (fs.existsSync(envPath)) {
success.push('.env file exists β');
// Check 3: .env contents
const envContent = fs.readFileSync(envPath, 'utf8');
// Check API key
if (envContent.includes('GOOGLE_SAFE_BROWSING_API_KEY=') &&
!envContent.includes('GOOGLE_SAFE_BROWSING_API_KEY=your_api_key_here') &&
!envContent.match(/GOOGLE_SAFE_BROWSING_API_KEY=\s*$/m)) {
success.push('Google Safe Browsing API key configured β');
} else {
errors.push('Google Safe Browsing API key is missing or not configured in .env');
}
// Check VITE_BACKEND_API_URL for local dev
if (envContent.includes('VITE_BACKEND_API_URL=http://localhost:8001')) {
success.push('VITE_BACKEND_API_URL configured for local development β');
} else if (envContent.includes('# VITE_BACKEND_API_URL=http://localhost:8001')) {
errors.push('VITE_BACKEND_API_URL is commented out! Uncomment it for local development.');
} else {
warnings.push('VITE_BACKEND_API_URL may not be configured correctly for local dev');
}
} else {
errors.push('.env file not found! Copy .env.example to .env');
}
// Check 4: package.json files
console.log('β Checking project structure...');
const rootPackage = path.join(process.cwd(), 'package.json');
const backendPackage = path.join(process.cwd(), 'backend', 'package.json');
const frontendPackage = path.join(process.cwd(), 'frontend', 'package.json');
if (fs.existsSync(rootPackage)) success.push('Root package.json exists β');
else errors.push('Root package.json not found');
if (fs.existsSync(backendPackage)) success.push('Backend package.json exists β');
else errors.push('Backend package.json not found');
if (fs.existsSync(frontendPackage)) success.push('Frontend package.json exists β');
else errors.push('Frontend package.json not found');
// Check 5: node_modules
console.log('β Checking dependencies...');
const rootModules = path.join(process.cwd(), 'node_modules');
const backendModules = path.join(process.cwd(), 'backend', 'node_modules');
const frontendModules = path.join(process.cwd(), 'frontend', 'node_modules');
if (!fs.existsSync(rootModules)) {
warnings.push('Root node_modules not found - run: npm install');
}
if (!fs.existsSync(backendModules)) {
warnings.push('Backend node_modules not found - run: cd backend && npm install');
}
if (!fs.existsSync(frontendModules)) {
warnings.push('Frontend node_modules not found - run: cd frontend && npm install');
}
if (fs.existsSync(rootModules) && fs.existsSync(backendModules) && fs.existsSync(frontendModules)) {
success.push('All dependencies installed β');
}
// Print Results
console.log('\n' + '='.repeat(50));
console.log('\nπ Results:\n');
if (success.length > 0) {
console.log('β
Success (' + success.length + '):');
success.forEach(msg => console.log(' ' + msg));
}
if (warnings.length > 0) {
console.log('\nβ οΈ Warnings (' + warnings.length + '):');
warnings.forEach(msg => console.log(' ' + msg));
}
if (errors.length > 0) {
console.log('\nβ Errors (' + errors.length + '):');
errors.forEach(msg => console.log(' ' + msg));
}
console.log('\n' + '='.repeat(50));
// Final verdict
if (errors.length === 0) {
console.log('\nπ All checks passed! You\'re ready to start development.\n');
console.log('Run: npm start\n');
process.exit(0);
} else {
console.log('\nβ οΈ Please fix the errors above before running npm start.\n');
console.log('π See the Troubleshooting section in README.md for detailed solutions.\n');
process.exit(1);
}