From 5de692c048c655b92843417dafcd85c4e1461b36 Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 19 Apr 2022 17:59:53 +0100 Subject: [PATCH] feat: add hidden flag to allow opting out of app id json file generation --- .../lib/src/commands/config.dart | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/packages/flutterfire_cli/lib/src/commands/config.dart b/packages/flutterfire_cli/lib/src/commands/config.dart index 7f01d7ef..b3756097 100644 --- a/packages/flutterfire_cli/lib/src/commands/config.dart +++ b/packages/flutterfire_cli/lib/src/commands/config.dart @@ -111,6 +111,15 @@ class ConfigCommand extends FlutterFireCommand { "Whether to add the Firebase Gradle plugin to your Android app's build.gradle files " 'and create the google-services.json file in your ./android/app folder. ', ); + + argParser.addFlag( + 'app-id-json', + defaultsTo: true, + hide: true, + abbr: 'j', + help: + 'Whether to generate the firebase_app_id.json files used by native iOS and Android builds. ', + ); } @override @@ -135,6 +144,10 @@ class ConfigCommand extends FlutterFireCommand { return argResults!['apply-gradle-plugin'] as bool; } + bool get generateAppIdJson { + return argResults!['app-id-json'] as bool; + } + String? get androidApplicationId { final value = argResults!['android-package-name'] as String?; final deprecatedValue = argResults!['android-app-id'] as String?; @@ -488,22 +501,28 @@ class ConfigCommand extends FlutterFireCommand { ); futures.add(configFile.write()); - if (iosOptions != null) { - final appIDFile = FirebaseAppIDFile( - iosAppIDOutputFilePrefix, - options: iosOptions, - force: isCI || yes, - ); - futures.add(appIDFile.write()); - } + if (generateAppIdJson) { + if (iosOptions != null) { + final appIDFile = FirebaseAppIDFile( + iosAppIDOutputFilePrefix, + options: iosOptions, + force: isCI || yes, + ); + futures.add(appIDFile.write()); + } - if (macosOptions != null) { - final appIDFile = FirebaseAppIDFile( - macosAppIDOutputFilePrefix, - options: macosOptions, - force: isCI || yes, + if (macosOptions != null) { + final appIDFile = FirebaseAppIDFile( + macosAppIDOutputFilePrefix, + options: macosOptions, + force: isCI || yes, + ); + futures.add(appIDFile.write()); + } + } else { + logger.stdout( + 'Skipping `firebase_app_id_file.json` generation. Note: this is not recommended as it can cause configuration issues with some FlutterFire plugins such as Crashlytics.', ); - futures.add(appIDFile.write()); } if (androidOptions != null && applyGradlePlugin) {