I refactored the code so that concerns were separated for flutterfire configure.
Why
This makes the code easier to understand.
Inputs are now known ahead of time (rather than having prompts buried within the writes). This makes it clearer about the path (reduction in if branches) the code is taking.
Should make it easier to test when concerns are separated.
Four stages of flutterfire configure
1. Validation/prompts
Inputs are validated and if not correct, command line prompts ask the user for a new value. For example, you cannot have a build configuration and target setup for apple projects so the user is asked to specify one. Or if the service file is not correct, it will ask for the correct file name (You may also not specify the filename and it will automatically use the default service file name so if you add --ios-out=dev, it will automatically write the file as "dev/GoogleService-Info.plist").
2. Retrieve values from Firebase server
This stage was already setup.
3. Writes
As the inputs have been validated it just requires writes:
android
build.gradle write updates and google-services.json write in this class.
apple
target & default configuration: GoogleService-Info.plist target resource bundle and writing script to upload debug symbols (if Crashlytics plugin is a dependency - auto detected so no prompt) in this class.
build configuration: GoogleService-Info.plist script to bundle included in build phase script and writing script to upload debug symbols (if Crashlytics plugin is a dependency - auto detected so no prompt) in this class
Dart configuration file (Dart initialisation)
Just writes the configuration file from the values from flutterfire configure. in this class
4. Firebase JSON writes
Each one of the "Writes" noted above returns a FirebaseJsonWrites instance that are added to a List and written at the same time here. This just keep concerns separated and means only one file read for writing to "firebase.json" file.
Follow up
I have largely finished the feature for flutterfire reconfigure (This PR) which essentially uses the values from the "firebase.json" to retrieve the app's latest configuration values from the Firebase server and rewrites the values to the service files.
I have rewritten the tests to cover flutterfire configure for default, build configuration & target (Apple only) setup, but the validation stage needs to be tested.
Removing absolute values from the build phase scripts setup.
Type of Change
[ ] ✨ feat -- New feature (non-breaking change which adds functionality)
[ ] 🛠️ fix -- Bug fix (non-breaking change which fixes an issue)
[ ] ❌ ! -- Breaking change (fix or feature that would cause existing functionality to change)
Description
I refactored the code so that concerns were separated for
flutterfire configure
.Why
Four stages of
flutterfire configure
1. Validation/prompts
Inputs are validated and if not correct, command line prompts ask the user for a new value. For example, you cannot have a
build configuration
andtarget
setup for apple projects so the user is asked to specify one. Or if the service file is not correct, it will ask for the correct file name (You may also not specify the filename and it will automatically use the default service file name so if you add--ios-out=dev
, it will automatically write the file as "dev/GoogleService-Info.plist").2. Retrieve values from Firebase server
This stage was already setup.
3. Writes
As the inputs have been validated it just requires writes:
android
build.gradle
write updates andgoogle-services.json
write in this class.apple
target
&default configuration
:GoogleService-Info.plist
target resource bundle and writing script to upload debug symbols (if Crashlytics plugin is a dependency - auto detected so no prompt) in this class.build configuration
:GoogleService-Info.plist
script to bundle included in build phase script and writing script to upload debug symbols (if Crashlytics plugin is a dependency - auto detected so no prompt) in this classDart configuration file (Dart initialisation)
flutterfire configure
. in this class4. Firebase JSON writes
Each one of the "Writes" noted above returns a and written at the same time here. This just keep concerns separated and means only one file read for writing to "firebase.json" file.
FirebaseJsonWrites
instance that are added to a ListFollow up
flutterfire reconfigure
(This PR) which essentially uses the values from the "firebase.json" to retrieve the app's latest configuration values from the Firebase server and rewrites the values to the service files.flutterfire configure
for default, build configuration & target (Apple only) setup, but the validation stage needs to be tested.Type of Change
feat
-- New feature (non-breaking change which adds functionality)fix
-- Bug fix (non-breaking change which fixes an issue)!
-- Breaking change (fix or feature that would cause existing functionality to change)refactor
-- Code refactorci
-- Build configuration changedocs
-- Documentationchore
-- Chore