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

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

Merged
merged 10 commits into from
Jan 5, 2023

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Dec 29, 2022

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: #14

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 refactor
  • ci -- Build configuration change
  • 📝 docs -- Documentation
  • 🗑️ chore -- Chore

@russellwheatley russellwheatley marked this pull request as ready for review January 4, 2023 11:27
Comment on lines +120 to +121
'debug-symbols-ios',
abbr: 'r',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'debug-symbols-ios',
abbr: 'r',
'debug-symbols-ios',
abbr: 'dsi',

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we cannot change abbreviations to anything more than single characters 😓, @Lyokone

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a shame :/

Comment on lines +128 to +129
'debug-symbols-macos',
abbr: 's',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'debug-symbols-macos',
abbr: 's',
'debug-symbols-macos',
abbr: 'dsm',


argParser.addFlag(
'overwrite-firebase-options',
abbr: 'f',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
abbr: 'f',
abbr: 'ow',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants