-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-build.sh
More file actions
executable file
·77 lines (66 loc) · 2.04 KB
/
test-build.sh
File metadata and controls
executable file
·77 lines (66 loc) · 2.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
#!/bin/bash
# Test script to verify GitHub Actions build locally
# This mimics the build job from .github/workflows/pages.yml
set -e # Exit on error
echo "🧪 Testing GitHub Actions build locally..."
echo ""
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
echo -e "${RED}❌ Error: package.json not found. Please run this script from the personal-website directory.${NC}"
exit 1
fi
# Step 1: Install dependencies (mimics: npm ci)
echo -e "${YELLOW}📦 Step 1: Installing dependencies (npm ci)...${NC}"
if npm ci; then
echo -e "${GREEN}✅ Dependencies installed successfully${NC}"
else
echo -e "${RED}❌ Failed to install dependencies${NC}"
exit 1
fi
echo ""
# Step 2: Build with Vite (mimics: npm run build with NODE_ENV=production)
echo -e "${YELLOW}🔨 Step 2: Building with Vite (production mode)...${NC}"
if NODE_ENV=production npm run build; then
echo -e "${GREEN}✅ Build completed successfully${NC}"
else
echo -e "${RED}❌ Build failed${NC}"
exit 1
fi
echo ""
# Step 3: Verify dist directory exists and has content
echo -e "${YELLOW}🔍 Step 3: Verifying build output...${NC}"
if [ -d "dist" ] && [ "$(ls -A dist)" ]; then
echo -e "${GREEN}✅ dist/ directory exists and contains files${NC}"
echo ""
echo "Build output summary:"
du -sh dist/
echo ""
echo "Files in dist/:"
find dist -type f | head -10
if [ $(find dist -type f | wc -l) -gt 10 ]; then
echo "... and more"
fi
else
echo -e "${RED}❌ dist/ directory is missing or empty${NC}"
exit 1
fi
echo ""
# Step 4: Check for index.html
if [ -f "dist/index.html" ]; then
echo -e "${GREEN}✅ index.html found${NC}"
else
echo -e "${RED}❌ index.html not found in dist/${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}🎉 All tests passed! Build is ready for GitHub Pages deployment.${NC}"
echo ""
echo "To preview the build locally, run:"
echo " npm run preview"
echo " or"
echo " make preview"