forked from bluewave-labs/Checkmate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-build.sh
More file actions
98 lines (88 loc) · 3.04 KB
/
Copy pathverify-build.sh
File metadata and controls
98 lines (88 loc) · 3.04 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
#!/bin/bash
# Pre-Commit Verification Script for Linux/macOS
# Run this before committing to ensure everything works
echo -e "\033[36mCheckmateX Pre-Commit Verification\033[0m"
echo -e "\033[36m===================================\n\033[0m"
errors=0
# Test 1: Check if Docker is running
echo -e "\033[33m[1/6] Checking Docker...\033[0m"
if docker info &> /dev/null; then
echo -e " \033[32m✓ Docker is running\033[0m"
else
echo -e " \033[31m✗ Docker is not running or not installed\033[0m"
((errors++))
fi
# Test 2: Check if pnpm is installed
echo -e "\n\033[33m[2/6] Checking pnpm...\033[0m"
if command -v pnpm &> /dev/null; then
echo -e " \033[32m✓ pnpm is installed\033[0m"
else
echo -e " \033[31m✗ pnpm is not installed\033[0m"
echo -e " \033[33mInstall with: npm install -g pnpm\033[0m"
((errors++))
fi
# Test 3: Check Node.js version
echo -e "\n\033[33m[3/6] Checking Node.js version...\033[0m"
if command -v node &> /dev/null; then
node_version=$(node --version)
major_version=$(echo $node_version | sed 's/v\([0-9]*\).*/\1/')
if [ "$major_version" -ge 18 ]; then
echo -e " \033[32m✓ Node.js $node_version (meets requirement: >= 18)\033[0m"
else
echo -e " \033[31m✗ Node.js $node_version (requires >= 18)\033[0m"
((errors++))
fi
else
echo -e " \033[31m✗ Node.js not installed\033[0m"
((errors++))
fi
# Test 4: Build client
echo -e "\n\033[33m[4/6] Building client...\033[0m"
cd client
pnpm install --silent > /dev/null 2>&1
if pnpm build > /dev/null 2>&1; then
echo -e " \033[32m✓ Client builds successfully\033[0m"
else
echo -e " \033[31m✗ Client build failed\033[0m"
((errors++))
fi
cd ..
# Test 5: Build server
echo -e "\n\033[33m[5/6] Building server...\033[0m"
cd server
pnpm install --silent > /dev/null 2>&1
if pnpm build > /dev/null 2>&1; then
echo -e " \033[32m✓ Server builds successfully\033[0m"
else
echo -e " \033[31m✗ Server build failed\033[0m"
((errors++))
fi
cd ..
# Test 6: Verify Docker build script exists
echo -e "\n\033[33m[6/6] Verifying Docker build scripts...\033[0m"
bash_script="docker/dev/build_images.sh"
ps_script="docker/dev/build_images.ps1"
if [ -f "$bash_script" ] && [ -f "$ps_script" ]; then
echo -e " \033[32m✓ Both bash and PowerShell build scripts exist\033[0m"
else
if [ ! -f "$bash_script" ]; then
echo -e " \033[31m✗ docker/dev/build_images.sh not found\033[0m"
((errors++))
fi
if [ ! -f "$ps_script" ]; then
echo -e " \033[31m✗ docker/dev/build_images.ps1 not found\033[0m"
((errors++))
fi
fi
# Summary
echo -e "\n\033[36m========================================\033[0m"
if [ $errors -eq 0 ]; then
echo -e "\033[32m✓ All checks passed! Ready to commit.\033[0m"
echo -e "\n\033[36mOptional: Test Docker build (takes ~5-10 minutes):\033[0m"
echo -e " cd docker/dev"
echo -e " chmod +x build_images.sh"
echo -e " ./build_images.sh"
else
echo -e "\033[31m✗ $errors check(s) failed. Fix issues before committing.\033[0m"
exit 1
fi