-
Notifications
You must be signed in to change notification settings - Fork 71
fix: flutterfire configure command when existing firebase_options.dart has a wrong format
#424
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
Merged
russellwheatley
merged 4 commits into
invertase:main
from
nilsreichardt:fix-error-for-broken-files
Mar 31, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5dbe977
Fix `flutterfire configure` command when existing `firebase_options.d…
nilsreichardt fdb2467
Merge branch 'main' into fix-error-for-broken-files
nilsreichardt 6cfd1c6
Merge branch 'main' into fix-error-for-broken-files
russellwheatley b5031c0
fix: code suggestion to normalise blank lines
russellwheatley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/flutterfire_cli/test/firebase_dart_configuration_write_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:flutterfire_cli/src/firebase/firebase_dart_configuration_write.dart'; | ||
| import 'package:flutterfire_cli/src/firebase/firebase_options.dart'; | ||
| import 'package:path/path.dart' as p; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| group('FirebaseDartConfigurationWrite', () { | ||
| // Regression test for | ||
| // https://github.com/invertase/flutterfire_cli/issues/422 | ||
| test( | ||
| 'replaces placeholder firebase_options.dart with generated output', | ||
| () { | ||
| final tempDir = Directory.systemTemp.createTempSync(); | ||
| addTearDown(() => tempDir.deleteSync(recursive: true)); | ||
|
|
||
| final filePath = p.join(tempDir.path, 'lib', 'firebase_options.dart'); | ||
| File(filePath) | ||
| ..createSync(recursive: true) | ||
| ..writeAsStringSync(''' | ||
| // File normally generated by FlutterFire CLI. This is a stand-in. | ||
| // See README.md for details. | ||
| import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; | ||
|
|
||
| class DefaultFirebaseOptions { | ||
| // TODO: Remove this file and run `flutterfire config` for Firebase options | ||
| static FirebaseOptions get currentPlatform { | ||
| throw UnimplementedError( | ||
| 'Generate this file by running `flutterfire configure`. ' | ||
| 'See README.md for details.', | ||
| ); | ||
| } | ||
| } | ||
| '''); | ||
|
|
||
| final writer = FirebaseDartConfigurationWrite( | ||
| configurationFilePath: filePath, | ||
| flutterAppPath: tempDir.path, | ||
| firebaseProjectId: 'test-project-id', | ||
| webOptions: const FirebaseOptions( | ||
| optionsSourceContent: '{}', | ||
| optionsSourceFileName: 'firebase-config.json', | ||
| apiKey: 'api-key', | ||
| appId: 'app-id', | ||
| messagingSenderId: 'sender-id', | ||
| projectId: 'test-project-id', | ||
| measurementId: 'measurement-id', | ||
| ), | ||
| ); | ||
|
|
||
| writer.write(); | ||
|
|
||
| final updatedContent = File(filePath).readAsStringSync(); | ||
| expect(updatedContent, contains('if (kIsWeb) {')); | ||
| expect(updatedContent, contains('return web;')); | ||
| expect(updatedContent, contains('static const FirebaseOptions web')); | ||
| expect(updatedContent, isNot(contains('UnimplementedError'))); | ||
| }, | ||
| ); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.