Some checks failed
Deploy to GitHub Pages / build-and-deploy (push) Has been cancelled
29 lines
926 B
Bash
Executable File
29 lines
926 B
Bash
Executable File
#!/bin/bash
|
|
# Size validation script for Geek Calculator
|
|
# Checks if total bundle size is under 50KB as required
|
|
|
|
echo "Checking Geek Calculator bundle size..."
|
|
|
|
# Define the maximum allowed size in KB
|
|
MAX_SIZE_KB=50
|
|
|
|
# Use wc to calculate total size
|
|
total_size=0
|
|
for file in $(find . -type f \( -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.webmanifest" \)); do
|
|
file_size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
|
|
total_size=$((total_size + file_size))
|
|
done
|
|
|
|
# Convert bytes to KB (with rounding up)
|
|
total_size_kb=$(( (total_size + 1023) / 1024 ))
|
|
|
|
echo "Total bundle size: $total_size_kb KB"
|
|
echo "Maximum allowed size: $MAX_SIZE_KB KB"
|
|
|
|
if [ $total_size_kb -le $MAX_SIZE_KB ]; then
|
|
echo "✅ Size validation PASSED: Bundle size is under limit"
|
|
exit 0
|
|
else
|
|
echo "❌ Size validation FAILED: Bundle size exceeds limit by $((total_size_kb - MAX_SIZE_KB)) KB"
|
|
exit 1
|
|
fi |