-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimize.js
More file actions
73 lines (61 loc) · 1.69 KB
/
optimize.js
File metadata and controls
73 lines (61 loc) · 1.69 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
#!/usr/bin/env node
/**
* Portfolio Project Optimization Script
* Runs all quality checks and improvements
*
* Usage: node optimize.js
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const colors = {
reset: '\x1b[0m',
green: '\x1b[32m',
yellow: '\x1b[33m',
red: '\x1b[31m',
cyan: '\x1b[36m',
};
const log = (msg, color = 'reset') => {
console.log(`${colors[color]}${msg}${colors.reset}`);
};
const runCommand = (cmd, label) => {
log(`\n📦 ${label}...`, 'cyan');
try {
execSync(cmd, { stdio: 'inherit' });
log(`✅ ${label} complete!`, 'green');
return true;
} catch (err) {
log(`❌ ${label} failed!`, 'red');
return false;
}
};
const main = async () => {
log('\n🚀 Portfolio Project Optimization Suite', 'cyan');
log('=====================================\n', 'cyan');
const checks = [
{ cmd: 'npm run lint', label: 'ESLint - Code Quality Check' },
{ cmd: 'npm audit', label: 'npm Audit - Security Check' },
{ cmd: 'npm run build', label: 'Build - Production Optimization' },
];
let passed = 0;
let failed = 0;
for (const check of checks) {
if (runCommand(check.cmd, check.label)) {
passed++;
} else {
failed++;
}
}
log('\n=====================================', 'cyan');
log(`\n📊 Summary: ${passed} passed, ${failed} failed\n`,
failed === 0 ? 'green' : 'yellow');
if (failed === 0) {
log('🎉 All checks passed! Your project is optimized and secure!', 'green');
} else {
log('⚠️ Some checks failed. Review the output above.', 'yellow');
}
};
main().catch(err => {
log(`Error: ${err.message}`, 'red');
process.exit(1);
});