135 lines
3.6 KiB
Bash
135 lines
3.6 KiB
Bash
#!/bin/bash
|
|
|
|
# Quick Fix Script for Common Build Issues
|
|
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
print_status() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Fix missing translations by copying from default
|
|
fix_translations() {
|
|
print_status "Checking for missing translations..."
|
|
|
|
# Find all string resource files
|
|
find app/src/main/res -name "strings.xml" | while read -r file; do
|
|
if [[ $file != *"values/strings.xml" ]]; then
|
|
# For each non-default strings.xml, check if all strings from default are present
|
|
default_strings="app/src/main/res/values/strings.xml"
|
|
|
|
if [ -f "$default_strings" ]; then
|
|
# Extract string names from default
|
|
grep 'name="' "$default_strings" | sed 's/.*name="\([^"]*\)".*/\1/' | while read -r string_name; do
|
|
if ! grep -q "name=\"$string_name\"" "$file"; then
|
|
print_warning "Missing translation for '$string_name' in $file"
|
|
# Automatically add placeholder translation
|
|
sed -i "/<\/resources>/i\ <string name=\"$string_name\">[TRANSLATE: $string_name]</string>" "$file"
|
|
print_status "Added placeholder for '$string_name' in $file"
|
|
fi
|
|
done
|
|
fi
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Fix common dependency issues
|
|
fix_dependencies() {
|
|
print_status "Checking for common dependency issues..."
|
|
|
|
# Check if buildSrc is properly configured
|
|
if [ ! -f "buildSrc/build.gradle.kts" ]; then
|
|
print_error "buildSrc not found - cannot fix dependency issues"
|
|
return 1
|
|
fi
|
|
|
|
# Sync Gradle to refresh dependencies
|
|
print_status "Refreshing Gradle dependencies..."
|
|
./gradlew --refresh-dependencies --quiet
|
|
}
|
|
|
|
# Clean and rebuild
|
|
clean_rebuild() {
|
|
print_status "Performing clean rebuild..."
|
|
./gradlew clean build --parallel --quiet
|
|
}
|
|
|
|
# Fix lint issues
|
|
fix_lint() {
|
|
print_status "Running lint fix..."
|
|
if command -v ./gradlew &> /dev/null; then
|
|
./gradlew lintFix --quiet
|
|
else
|
|
print_warning "Gradle not found, skipping lint fix"
|
|
fi
|
|
}
|
|
|
|
# Main menu
|
|
show_menu() {
|
|
echo "========================================"
|
|
echo " HomeboxLens Quick Fix System"
|
|
echo "========================================"
|
|
echo "1. Fix missing translations"
|
|
echo "2. Fix dependencies"
|
|
echo "3. Clean rebuild"
|
|
echo "4. Fix lint issues"
|
|
echo "5. Run all fixes"
|
|
echo "6. Exit"
|
|
echo "========================================"
|
|
}
|
|
|
|
main() {
|
|
while true; do
|
|
show_menu
|
|
read -p "Choose option (1-6): " choice
|
|
|
|
case $choice in
|
|
1)
|
|
fix_translations
|
|
;;
|
|
2)
|
|
fix_dependencies
|
|
;;
|
|
3)
|
|
clean_rebuild
|
|
;;
|
|
4)
|
|
fix_lint
|
|
;;
|
|
5)
|
|
print_status "Running all fixes..."
|
|
fix_translations
|
|
fix_dependencies
|
|
fix_lint
|
|
clean_rebuild
|
|
;;
|
|
6)
|
|
print_status "Exiting..."
|
|
exit 0
|
|
;;
|
|
*)
|
|
print_error "Invalid option. Please choose 1-6."
|
|
;;
|
|
esac
|
|
|
|
read -p "Press Enter to continue..."
|
|
done
|
|
}
|
|
|
|
# Run main function
|
|
main "$@" |