forked from mehatab/fettle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-build.sh
More file actions
executable file
·95 lines (82 loc) · 2.22 KB
/
test-build.sh
File metadata and controls
executable file
·95 lines (82 loc) · 2.22 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
#!/bin/bash
# Script to simulate GitHub Actions workflow locally
set -e # Exit on error
echo "=== Simulating GitHub Actions workflow ==="
echo ""
# Step 1: Detect package manager (similar to workflow)
echo "Step 1: Detecting package manager..."
if [ -f "yarn.lock" ] && command -v yarn &> /dev/null; then
MANAGER="yarn"
COMMAND="install"
RUNNER="yarn"
echo "Detected: yarn"
elif [ -f "package.json" ]; then
MANAGER="npm"
COMMAND="ci"
RUNNER="npx --no-install"
echo "Detected: npm (yarn.lock exists but yarn not installed, using npm)"
else
echo "Error: Unable to determine package manager"
exit 1
fi
# Step 2: Install dependencies
echo ""
echo "Step 2: Installing dependencies..."
$MANAGER $COMMAND
# Step 3: Verify next.config.js
echo ""
echo "Step 3: Verifying next.config.js..."
if [ -f "next.config.js" ]; then
echo "Current next.config.js:"
cat next.config.js
echo ""
# Check if output: 'export' is present
if grep -q "output.*export" next.config.js; then
echo "✓ output: 'export' is configured"
else
echo "⚠ Warning: output: 'export' not found in config"
fi
else
echo "Error: next.config.js not found"
exit 1
fi
# Step 4: Build with Next.js
echo ""
echo "Step 4: Building with Next.js..."
$RUNNER next build
# Step 4b: Export static site (required for Next.js 12)
echo ""
echo "Step 4b: Exporting static site..."
$RUNNER next export
# Step 5: Check build output
echo ""
echo "Step 5: Checking build output..."
echo "Current directory contents:"
ls -la
echo ""
echo "Checking .next directory:"
if [ -d ".next" ]; then
ls -la .next | head -10
else
echo ".next directory not found"
fi
echo ""
echo "Checking for 'out' directory:"
if [ -d "./out" ]; then
echo "✓ Found 'out' directory!"
echo "Contents:"
ls -la ./out | head -20
echo ""
echo "Total files in 'out':"
find ./out -type f | wc -l
else
echo "✗ 'out' directory NOT found!"
echo ""
echo "This means the static export did not work."
echo "Please check:"
echo " 1. Is 'output: export' configured in next.config.js?"
echo " 2. Are there any build errors above?"
exit 1
fi
echo ""
echo "=== Build simulation completed successfully! ==="