Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Flavour Scripts #22

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ This project contains 3 flavors:
- staging
- production

For your convenience, a single script has been written inside the 'scripts' package (buildPraxisFlutter.sh).

To run it, simply use the following 2 commands :
1. `cd scripts`
2. On Windows:
`buildPraxisFlutter.sh`
On Mac/Linux:
`bash buildPraxisFlutter.sh`
and Press Enter/Return

Also, please make sure that you have your device selected in the Flutter Device Selection window before running the script(s).

```sh
To generate code for injectable
Expand Down
52 changes: 52 additions & 0 deletions scripts/buildPraxisFlutter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Create an array of all the available flavours
declare -a praxisFlavours=(development staging production)

# Size of array
praxisFlavoursLength=${#praxisFlavours[@]}

# Ask the user to select a flavour first
echo "Select one of the flavours to build 🔥:"
select flavour in "${praxisFlavours[@]}"; do
if [ "$REPLY" -gt "$praxisFlavoursLength" ] || [ "$REPLY" -lt 1 ]; then
echo "<---Please select a valid option (1-$praxisFlavoursLength)--->"
else
echo "<---'$flavour' flavour selected for building PraxisFlutter ✅--->"
break
fi
done

# Go to root dir from the current scripts dir
echo "<---Going to root directory--->"
cd ..

# Go to data layer (package)
echo "<---Going to data layer--->"
cd praxis_data || return

# Use pub get to fix pubspec.lock error
flutter pub get

# Generate config files for the data layer
echo "<---Generating config files for the data layer--->"
flutter packages pub run build_runner build --delete-conflicting-outputs

#Go back to root dir
echo "<---Going back to root dir--->"
cd ..

# Use pub get to fix pubspec.lock error
flutter pub get

# Generate config files for the presentation layer
echo "<---Generating config files for the presentation layer--->"
flutter packages pub run build_runner build --delete-conflicting-outputs

# Generate translation files
echo "<---Generating translation files--->"
flutter gen-l10n --template-arb-file=arb/app_en.arb

# Build user-selected flavor and run it
echo "<---Building $flavour flavor and running it--->"
flutter run --flavor "$flavour" --target lib/main_"$flavour".dart
echo "<---Press any key to exit--->"
read -r