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

Update shell scripts to have more reuse #830

Merged
merged 13 commits into from
May 27, 2024
19 changes: 4 additions & 15 deletions tool/analyze.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/bin/bash

cd ..
# Make foreach_module script executable, in case it isn't yet
chmod u+x foreach_module.sh

cd floor
flutter analyze
cd ..

cd floor_annotation
dart analyze --fatal-infos --fatal-warnings .
cd ..

cd floor_generator
dart analyze --fatal-infos --fatal-warnings .
cd ..

cd example
flutter analyze
# Run dart analyze . on every module
./foreach_module.sh 'dart analyze --fatal-infos --fatal-warnings .'
33 changes: 33 additions & 0 deletions tool/foreach_module.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# This script lists all Flutter module folders in this project. Next it iterates over them
# and runs the passed in command in every one of those folders.
# Example usage: ./foreach_module.sh 'dart analyze .'

if [ $# -eq 0 ]; then
echo "No arguments supplied. Pass the desired command as a string argument.
For example: ./foreach_module.sh 'dart analyze .'"
fi

# All Flutter module folders
folders=(
example
floor
floor_annotation
floor_common
floor_ffi
floor_generator
)

# Navigate up one level from where this script lives
cd ..

# Iterate over the modules
for folder in "${folders[@]}"; do
# Navigate to the module folder, or continue to the next one if that fails
cd "$folder" || continue;
# Run the passed in command
$1
# Navigate back up to the root
cd ..
done
19 changes: 4 additions & 15 deletions tool/format.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/bin/bash

cd ..
# Make foreach_module script executable, in case it isn't yet
chmod u+x foreach_module.sh

cd floor
dart format .
cd ..

cd floor_annotation
dart format .
cd ..

cd floor_generator
dart format .
cd ..

cd example
dart format .
# Run dart format . on every module
./foreach_module.sh 'dart format .'
7 changes: 7 additions & 0 deletions tool/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Make foreach_module script executable, in case it isn't yet
chmod u+x foreach_module.sh

# Run build_runner on every module
./foreach_module.sh 'dart run build_runner build --delete-conflicting-outputs'
4 changes: 0 additions & 4 deletions tool/generate_example_database.sh

This file was deleted.

4 changes: 0 additions & 4 deletions tool/generate_test_database.sh

This file was deleted.

19 changes: 4 additions & 15 deletions tool/get.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/bin/bash

cd ..
# Make foreach_module script executable, in case it isn't yet
chmod u+x foreach_module.sh

cd floor
flutter packages pub get
cd ..

cd floor_annotation
flutter packages pub get
cd ..

cd floor_generator
flutter packages pub get
cd ..

cd example
flutter packages pub get
# Run flutter packages pub get on every module
./foreach_module.sh 'flutter packages pub get'
23 changes: 4 additions & 19 deletions tool/upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
#!/bin/bash

cd ..
# Make foreach_module script executable, in case it isn't yet
chmod u+x foreach_module.sh

cd floor
flutter packages pub upgrade
cd ..

cd floor_common
flutter packages pub upgrade
cd ..

cd floor_annotation
flutter packages pub upgrade
cd ..

cd floor_generator
flutter packages pub upgrade
cd ..

cd example
flutter packages pub upgrade
# Run flutter packages pub upgrade on every module
./foreach_module.sh 'flutter packages pub upgrade'
Loading