|
#!/bin/bash |
|
# =========================================== |
|
# π οΈ Flutter Team Utility Script |
|
# βοΈ Created by Mahmoud Alaa |
|
# π Automates common Flutter development tasks |
|
# =========================================== |
|
|
|
# π¨ Define colors for better output visibility |
|
GREEN='\033[0;32m' |
|
RED='\033[0;31m' |
|
YELLOW='\033[0;33m' |
|
NC='\033[0m' # No Color |
|
|
|
# π Display the menu |
|
echo -e "${YELLOW}π§ Flutter Team Utility Script - Created by Mahmoud Alaa${NC}" |
|
echo "1οΈβ£ π§Ή Clear Pods & Cache and Reinstall (iOS)" |
|
echo "2οΈβ£ π Generate Build Files (build_runner)" |
|
echo "3οΈβ£ π Update Localization (flutter_lokalise)" |
|
echo "4οΈβ£ π οΈ Flutter Clean & Pub Get" |
|
echo "5οΈβ£ π§ Reset Android Gradle" |
|
echo "6οΈβ£ π§ͺ Run Flutter Tests with Coverage" |
|
echo "7οΈβ£ β Exit" |
|
|
|
read -p "π Enter your choice: " choice |
|
|
|
case $choice in |
|
1) |
|
echo -e "${YELLOW}π§Ή Cleaning iOS Pods & Cache...${NC}" |
|
flutter clean && flutter pub get |
|
rm -rf ios/Pods ios/Flutter/Flutter.framework ios/Flutter/Flutter.podspec ios/Podfile.lock |
|
cd ios || { echo -e "${RED}β Failed to enter ios directory!${NC}"; exit 1; } |
|
pod deintegrate && pod install |
|
cd .. |
|
echo -e "${GREEN}β
iOS Cleanup Complete!${NC}" |
|
;; |
|
2) |
|
echo -e "${YELLOW}π Running Build Runner...${NC}" |
|
flutter pub run build_runner build --delete-conflicting-outputs |
|
echo -e "${GREEN}β
Build Files Generated Successfully!${NC}" |
|
;; |
|
3) |
|
echo -e "${YELLOW}π Updating Localization...${NC}" |
|
flutter pub run flutter_lokalise download --output lib/i18n |
|
echo -e "${GREEN}β
Localization Updated!${NC}" |
|
;; |
|
4) |
|
echo -e "${YELLOW}π οΈ Running Flutter Clean & Pub Get...${NC}" |
|
flutter clean && flutter pub get |
|
echo -e "${GREEN}β
Flutter Project Cleaned & Dependencies Installed!${NC}" |
|
;; |
|
5) |
|
echo -e "${YELLOW}π§ Resetting Android Gradle...${NC}" |
|
rm -rf android/.gradle android/app/build |
|
flutter clean && flutter pub get |
|
echo -e "${GREEN}β
Android Gradle Reset Complete!${NC}" |
|
;; |
|
6) |
|
echo -e "${YELLOW}π§ͺ Running Flutter Tests with Coverage...${NC}" |
|
flutter test --coverage |
|
if [ -f "coverage/lcov.info" ]; then |
|
echo -e "${YELLOW}π Generating HTML Report...${NC}" |
|
genhtml coverage/lcov.info -o coverage/html |
|
echo -e "${GREEN}β
Test Coverage Report Generated: coverage/html/index.html${NC}" |
|
else |
|
echo -e "${RED}β Coverage file not found. Make sure tests are running correctly.${NC}" |
|
fi |
|
;; |
|
7) |
|
echo -e "${YELLOW}β Exiting script.${NC}" |
|
exit 0 |
|
;; |
|
*) |
|
echo -e "${RED}β Invalid choice. Please select a valid option.${NC}" |
|
;; |
|
esac |