From f618516146527ea864d1ebc842eaa0f93aa4e293 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:01:03 +0200 Subject: [PATCH 01/13] Use a loop to execute commands on every folder In stead of having to repeat the command for every folder, we can iterate over a list of them and execute the same command over and over again. This also fixes the SC2164 warning that was present. --- tool/analyze.sh | 27 ++++++++++++++------------- tool/format.sh | 27 ++++++++++++++------------- tool/get.sh | 27 ++++++++++++++------------- tool/upgrade.sh | 31 ++++++++++++++----------------- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/tool/analyze.sh b/tool/analyze.sh index 6825b9c0..42045519 100644 --- a/tool/analyze.sh +++ b/tool/analyze.sh @@ -1,18 +1,19 @@ #!/bin/bash -cd .. - -cd floor -flutter analyze -cd .. - -cd floor_annotation -dart analyze --fatal-infos --fatal-warnings . -cd .. +folders=( + example + floor + floor_annotation + floor_common + floor_ffi + floor_generator +) -cd floor_generator -dart analyze --fatal-infos --fatal-warnings . cd .. -cd example -flutter analyze +for folder in "${folders[@]}" +do + cd "$folder" || exit; + dart analyze . + cd .. +done diff --git a/tool/format.sh b/tool/format.sh index 89fd28f9..f19b6917 100644 --- a/tool/format.sh +++ b/tool/format.sh @@ -1,18 +1,19 @@ #!/bin/bash -cd .. - -cd floor -dart format . -cd .. - -cd floor_annotation -dart format . -cd .. +folders=( + example + floor + floor_annotation + floor_common + floor_ffi + floor_generator +) -cd floor_generator -dart format . cd .. -cd example -dart format . +for folder in "${folders[@]}" +do + cd "$folder" || exit; + dart format . + cd .. +done diff --git a/tool/get.sh b/tool/get.sh index 684381bd..fc8e076e 100644 --- a/tool/get.sh +++ b/tool/get.sh @@ -1,18 +1,19 @@ #!/bin/bash -cd .. - -cd floor -flutter packages pub get -cd .. - -cd floor_annotation -flutter packages pub get -cd .. +folders=( + example + floor + floor_annotation + floor_common + floor_ffi + floor_generator +) -cd floor_generator -flutter packages pub get cd .. -cd example -flutter packages pub get +for folder in "${folders[@]}" +do + cd "$folder" || exit; + flutter packages pub get + cd .. +done diff --git a/tool/upgrade.sh b/tool/upgrade.sh index c9f9edd7..d5228295 100644 --- a/tool/upgrade.sh +++ b/tool/upgrade.sh @@ -1,22 +1,19 @@ #!/bin/bash -cd .. - -cd floor -flutter packages pub upgrade -cd .. - -cd floor_common -flutter packages pub upgrade -cd .. - -cd floor_annotation -flutter packages pub upgrade -cd .. +folders=( + example + floor + floor_annotation + floor_common + floor_ffi + floor_generator +) -cd floor_generator -flutter packages pub upgrade cd .. -cd example -flutter packages pub upgrade +for folder in "${folders[@]}" +do + cd "$folder" || exit; + flutter packages pub upgrade + cd .. +done From bc91c54ed79f1b6df935e09f39932ce05a36ced1 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:06:55 +0200 Subject: [PATCH 02/13] Introduce a script that iterates over every folder --- tool/foreach_module.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 tool/foreach_module.sh diff --git a/tool/foreach_module.sh b/tool/foreach_module.sh new file mode 100755 index 00000000..f2fb5156 --- /dev/null +++ b/tool/foreach_module.sh @@ -0,0 +1,28 @@ +#!/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. + +# 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 From 12420b5492e5b039d38ca70a878c3653d0ca877b Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:14:35 +0200 Subject: [PATCH 03/13] Reformat file --- tool/foreach_module.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tool/foreach_module.sh b/tool/foreach_module.sh index f2fb5156..75da8405 100755 --- a/tool/foreach_module.sh +++ b/tool/foreach_module.sh @@ -17,8 +17,7 @@ folders=( cd .. # Iterate over the modules -for folder in "${folders[@]}" -do +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 From 9f7457ebf286e9d703846f798e2cfde71800bca5 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:14:56 +0200 Subject: [PATCH 04/13] Add example usage to top comment --- tool/foreach_module.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tool/foreach_module.sh b/tool/foreach_module.sh index 75da8405..e27cf9b1 100755 --- a/tool/foreach_module.sh +++ b/tool/foreach_module.sh @@ -2,6 +2,7 @@ # 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 .' # All Flutter module folders folders=( From a1e4318a11bf9f846c9f060b47b6e11609a9d077 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:15:41 +0200 Subject: [PATCH 05/13] Exit with a clear message when no input argument --- tool/foreach_module.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tool/foreach_module.sh b/tool/foreach_module.sh index e27cf9b1..abba7b4d 100755 --- a/tool/foreach_module.sh +++ b/tool/foreach_module.sh @@ -4,6 +4,11 @@ # 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 From 788502ed680b4465bb810c28605f673519712983 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:16:32 +0200 Subject: [PATCH 06/13] Run analyse using foreach_module script --- tool/analyze.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tool/analyze.sh b/tool/analyze.sh index 42045519..10f6ffd0 100644 --- a/tool/analyze.sh +++ b/tool/analyze.sh @@ -1,19 +1,3 @@ #!/bin/bash -folders=( - example - floor - floor_annotation - floor_common - floor_ffi - floor_generator -) - -cd .. - -for folder in "${folders[@]}" -do - cd "$folder" || exit; - dart analyze . - cd .. -done +./foreach_module.sh 'dart analyze .' From 8f081e22cace3cc9dbf4d2f826fefee59781dbcd Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:19:10 +0200 Subject: [PATCH 07/13] Make script executable before executing In case it was not yet executable. It makes it only executable on user level --- tool/analyze.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tool/analyze.sh b/tool/analyze.sh index 10f6ffd0..58857ce7 100644 --- a/tool/analyze.sh +++ b/tool/analyze.sh @@ -1,3 +1,5 @@ #!/bin/bash +# Make foreach_module script executable, in case it isn't yet +chmod u+x foreach_module.sh ./foreach_module.sh 'dart analyze .' From 1b91eb84e36c8af9b21858ad3577aa8ae7c28084 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:19:38 +0200 Subject: [PATCH 08/13] Add comment --- tool/analyze.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tool/analyze.sh b/tool/analyze.sh index 58857ce7..591aa411 100644 --- a/tool/analyze.sh +++ b/tool/analyze.sh @@ -2,4 +2,6 @@ # Make foreach_module script executable, in case it isn't yet chmod u+x foreach_module.sh + +# Run dart analyze . on every module ./foreach_module.sh 'dart analyze .' From 4106dd212b88602acacf97bcb688850eba5732da Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:21:02 +0200 Subject: [PATCH 09/13] Run formatter using foreach_module script too --- tool/format.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tool/format.sh b/tool/format.sh index f19b6917..d9e6d817 100644 --- a/tool/format.sh +++ b/tool/format.sh @@ -1,19 +1,7 @@ #!/bin/bash -folders=( - example - floor - floor_annotation - floor_common - floor_ffi - floor_generator -) +# Make foreach_module script executable, in case it isn't yet +chmod u+x foreach_module.sh -cd .. - -for folder in "${folders[@]}" -do - cd "$folder" || exit; - dart format . - cd .. -done +# Run dart format . on every module +./foreach_module.sh 'dart format .' From 68eab3d7f764b51f7c6a7e0710e3a530644edfb5 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:26:56 +0200 Subject: [PATCH 10/13] Run pub get in loop too --- tool/get.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tool/get.sh b/tool/get.sh index fc8e076e..52bd0a9b 100644 --- a/tool/get.sh +++ b/tool/get.sh @@ -1,19 +1,7 @@ #!/bin/bash -folders=( - example - floor - floor_annotation - floor_common - floor_ffi - floor_generator -) +# Make foreach_module script executable, in case it isn't yet +chmod u+x foreach_module.sh -cd .. - -for folder in "${folders[@]}" -do - cd "$folder" || exit; - flutter packages pub get - cd .. -done +# Run flutter packages pub get on every module +./foreach_module.sh 'flutter packages pub get' From 463aa128fd0223d51770328103171838e509b672 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:29:44 +0200 Subject: [PATCH 11/13] Add generate tool script Running the build_runner on every module. This replaces the existing individual generation scripts. Those modules without anything to generate will just output "Could not find package `build_runner` or file `build_runner`" and continue to the next, which is fine. --- tool/generate.sh | 7 +++++++ tool/generate_example_database.sh | 4 ---- tool/generate_test_database.sh | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 tool/generate.sh delete mode 100644 tool/generate_example_database.sh delete mode 100644 tool/generate_test_database.sh diff --git a/tool/generate.sh b/tool/generate.sh new file mode 100644 index 00000000..33b67633 --- /dev/null +++ b/tool/generate.sh @@ -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' diff --git a/tool/generate_example_database.sh b/tool/generate_example_database.sh deleted file mode 100644 index 61b39cf6..00000000 --- a/tool/generate_example_database.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cd ../example -flutter packages pub run build_runner build --delete-conflicting-outputs diff --git a/tool/generate_test_database.sh b/tool/generate_test_database.sh deleted file mode 100644 index 82efa5cb..00000000 --- a/tool/generate_test_database.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cd ../floor_common -flutter packages pub run build_runner build --delete-conflicting-outputs From a5225f38aa66dcf1ec094729a6cb6333ef20f3a4 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:32:36 +0200 Subject: [PATCH 12/13] Reuse foreach_module for upgrade too --- tool/upgrade.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tool/upgrade.sh b/tool/upgrade.sh index d5228295..76ad6f8b 100644 --- a/tool/upgrade.sh +++ b/tool/upgrade.sh @@ -1,19 +1,7 @@ #!/bin/bash -folders=( - example - floor - floor_annotation - floor_common - floor_ffi - floor_generator -) +# Make foreach_module script executable, in case it isn't yet +chmod u+x foreach_module.sh -cd .. - -for folder in "${folders[@]}" -do - cd "$folder" || exit; - flutter packages pub upgrade - cd .. -done +# Run flutter packages pub upgrade on every module +./foreach_module.sh 'flutter packages pub upgrade' From bcf02e3b0ba8936633555fce182fb9759bf69fe3 Mon Sep 17 00:00:00 2001 From: Stephan Mantel Date: Fri, 24 May 2024 13:34:41 +0200 Subject: [PATCH 13/13] Make warnings and info's fatal again In every module this time, no discrimination --- tool/analyze.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/analyze.sh b/tool/analyze.sh index 591aa411..1294b78c 100644 --- a/tool/analyze.sh +++ b/tool/analyze.sh @@ -4,4 +4,4 @@ chmod u+x foreach_module.sh # Run dart analyze . on every module -./foreach_module.sh 'dart analyze .' +./foreach_module.sh 'dart analyze --fatal-infos --fatal-warnings .'