invertase / flutterfire_cli

A CLI to help with using FlutterFire in your Flutter applications.
Apache License 2.0
164 stars 47 forks source link

refactor: update implementation to make it more modular and easier to understand #167

Closed russellwheatley closed 1 year ago

russellwheatley commented 1 year ago

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 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

apple

Dart configuration file (Dart initialisation)

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

  1. 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.
  2. 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.
  3. Removing absolute values from the build phase scripts setup.

Type of Change

Salakar commented 1 year ago

Thoughts on 'reconfigure' for the command name? 🤔