invertase / flutterfire_cli

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

feat(cli): command line arguments for different environments #138

Closed russellwheatley closed 1 year ago

russellwheatley commented 1 year ago

Description

Created command line arguments which negate the need to use the command prompts. The following command line arguments have been added:

  1. ios-scheme - pass in the name of the scheme you wish to use for your iOS project.
  2. macos-scheme - pass in the name of the scheme you wish to use for your macOS project.
  3. ios-target- - pass in the name of the target you wish to use for your iOS project.
  4. macos-target- - pass in the name of the target you wish to use for your macOS project.
  5. debug-symbols-ios - This is a command line flag. It will add an upload debug symbols script to your iOS target or scheme (depending on whether you used ios-scheme or ios-target). This replaces debug-symbols-script which was a hidden flag in the last dev release. If you choose to negate the script (i.e. no-debug-symbol-ios), you will not be prompted asking if you wish to write it.
  6. debug-symbols-macos - This is a command line flag. It will add an upload debug symbols script to your macOS target or scheme (depending on whether you used macos-scheme or macos-target). If you choose to negate the script (i.e. no-debug-symbol-macos), you will not be prompted asking if you wish to write it.
  7. overwrite-firebase-options - This is a command line flag. This allows you to overwrite/not overwrite the current firebase_options.dart if you're running flutterfire configure again. If you choose to negate it (i.e. no-overwrite-firebase-options), you will not be prompted asking if you wish to write it.

Notes

  1. You can only set either ios-scheme OR ios-target. If you try to set both, the script will throw an error.
  2. You can only set either macos-scheme OR macos-target. If you try to set both, the script will throw an error.
  3. If you choose ios-scheme or macos-scheme setup, you have to specify a path for ios-out or macos-out. If you don't, you will be prompted by the CLI for a path. This is because it is included in the app bundle at build time, and there needs to be a "GoogleService-Info.plist" in the project directory to use. If you choose the "target" method (i.e. ios-target or macos-target), you do not have to specify a path for "GoogleService-Info.plist" file if you wish (i.e. ios-out or macos-out). This is because the CLI will add the "GoogleService-Info.plist" file to the bundle resources, and it will automatically place the file under the target (e.g. Runner/GoogleService-Info.plist).
  4. I have fixed the conditions used on Bash scripts for build run phases.

Examples of commands that completely negate any user input from prompts:

Note, it is required to specify the Firebase project via --project argument. You also need to include the --yes flag which does a few things. It will automatically choose all platforms on your project (e.g. iOS, macOS, android & web), will overwrite firebase_options.dart (can also use --overwrite-firebase-options for this specific task), it will also force write necessary updates to android build.gradle's for FlutterFire configuration.

flutterfire configure --ios-target=Runner  --android-out=/android/app/src/debug/google-services.json --debug-symbols-ios --debug-symbols-macos  --macos-target=Runner --yes --project=firebase-project

Note, the debug symbols scripts are not being written, nor is firebase_options.dart being overwritten. I also removed android-out argument to demonstrate that by default, it will write to android/app/google-services.json as usual.

flutterfire configure --ios-target=Runner --no-debug-symbols-ios --no-debug-symbols-macos  --macos-target=Runner --no-overwrite-firebase-options --yes --project=firebase-project

Note, I was using VGV's CLI to create a project for testing as it has different schemes setup from the beginning (i.e. development, staging, production). macOS schemes will be fixed in a future release, so we use the target again here.

flutterfire configure --ios-scheme=development --ios-out=ios/dev/GoogleService-Info.plist --debug-symbols-ios --debug-symbols-macos  --macos-target=Runner --no-overwrite-firebase-options --yes --project=firebase-project

To use this dev release:

dart pub global activate flutterfire_cli 0.3.0-dev.14 --overwrite

Related issues

Part of: https://github.com/invertase/flutterfire_cli/issues/14

Type of Change