Skip to content

feat(cli): add --firebase-out flag for custom firebase.json path#435

Open
kevmoo wants to merge 3 commits intoinvertase:mainfrom
kevmoo:i277_firebase_json_output
Open

feat(cli): add --firebase-out flag for custom firebase.json path#435
kevmoo wants to merge 3 commits intoinvertase:mainfrom
kevmoo:i277_firebase_json_output

Conversation

@kevmoo
Copy link
Copy Markdown
Contributor

@kevmoo kevmoo commented Apr 16, 2026

Fixes #277

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a --firebase-out flag to the configure and reconfigure commands, allowing users to specify a custom path for the firebase.json file. The changes involve updating argument parsing, path resolution logic, and adding a corresponding test case. Reviewer feedback suggests that custom paths should be resolved relative to the project root to ensure consistent behavior across different execution environments.

Comment thread packages/flutterfire_cli/lib/src/commands/config.dart
Comment thread packages/flutterfire_cli/lib/src/commands/reconfigure.dart Outdated
@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Apr 16, 2026

/gemini review

@github-actions github-actions Bot added the Needs Attention OP created or responded to issue and it needs attention. label Apr 16, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new --firebase-out flag to the configure and reconfigure commands, enabling users to specify a custom path for the firebase.json file. The path resolution logic is now centralized in the FlutterFireCommand base class, and the changes are verified with new integration tests. Feedback highlights the need for defensive programming to handle cases where the Flutter app context might be null and recommends consistent help text for the new flag across different commands.

Comment on lines +51 to +63
String resolveFirebaseJsonPath(String? customPath) {
if (customPath != null) {
// If a custom path was provided, check if it is relative.
if (path.isRelative(customPath)) {
// Resolve relative paths relative to the project root to ensure consistent behavior.
return path.join(flutterApp!.package.path, customPath);
}
// Use absolute paths as provided.
return customPath;
}
// Default to the standard firebase.json in the project root if no custom path is specified.
return path.join(flutterApp!.package.path, 'firebase.json');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The resolveFirebaseJsonPath method uses the null-check operator (!) on flutterApp multiple times. While most commands in this CLI require a Flutter app, FlutterFireCommand allows flutterApp to be null. If this method is called when flutterApp is null, it will throw a runtime error. Consider adding a defensive check or using a fallback like Directory.current.path to determine the project root.

Suggested change
String resolveFirebaseJsonPath(String? customPath) {
if (customPath != null) {
// If a custom path was provided, check if it is relative.
if (path.isRelative(customPath)) {
// Resolve relative paths relative to the project root to ensure consistent behavior.
return path.join(flutterApp!.package.path, customPath);
}
// Use absolute paths as provided.
return customPath;
}
// Default to the standard firebase.json in the project root if no custom path is specified.
return path.join(flutterApp!.package.path, 'firebase.json');
}
String resolveFirebaseJsonPath(String? customPath) {
final projectRoot = flutterApp?.package.path ?? Directory.current.path;
if (customPath != null) {
// If a custom path was provided, check if it is relative.
if (path.isRelative(customPath)) {
// Resolve relative paths relative to the project root to ensure consistent behavior.
return path.join(projectRoot, customPath);
}
// Use absolute paths as provided.
return customPath;
}
// Default to the standard firebase.json in the project root if no custom path is specified.
return path.join(projectRoot, 'firebase.json');
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might need further investigating.

Comment thread packages/flutterfire_cli/lib/src/commands/reconfigure.dart
@karnemanideep
Copy link
Copy Markdown

"Hi! I noticed the CI tests are failing.
I'd love to help fix them if you need
an extra hand!"

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Member

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

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

Yep, I don't have an issue with this PR, FlutterFire CLI is meant to be highly configurable to an extent.

There's a CI test(s) failing for linux (probably macos once finished) that needs to be resolved. You also need to update the README.md documentation with the new flag.

Comment on lines +390 to +393
final customPath =
argResults != null ? argResults![kFirebaseOutFlag] as String? : null;
// Determine the raw path, prioritizing the programmatic path passed from the configure command.
final rawPath = _firebaseJsonPath ?? customPath;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

think we can use similar getter used in config command:

String get firebaseJsonPath {
    return resolveFirebaseJsonPath(argResults![kFirebaseOutFlag] as String?);
  }

Comment on lines +1746 to +1759
final installDevDependency = Process.runSync(
'flutter',
[
'pub',
'add',
'--dev',
'flutterfire_cli',
'--path=${Directory.current.path}',
],
workingDirectory: projectPath,
);

if (installDevDependency.exitCode != 0) {
fail(installDevDependency.stderr as String);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't need to install dev, it should be available already. See other tests.

Comment on lines +1763 to +1776
final result = Process.runSync(
'dart',
[
'run',
'flutterfire_cli:flutterfire',
'configure',
'--yes',
'--project=$firebaseProjectId',
'--platforms=android',
'--firebase-out=$customFirebaseJsonPath',
],
workingDirectory: projectPath,
runInShell: true,
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

using dev dependency again, see other tests.

Comment on lines +401 to +412
final scriptPath = p.join(Directory.current.path, 'bin', 'flutterfire.dart');

// 1. Run "flutterfire configure" with custom output path
final result = Process.runSync(
'dart',
[
scriptPath,
'configure',
'--yes',
'--platforms=android',
'--project=$firebaseProjectId',
'--firebase-out=$customFirebaseJsonPath',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same again

final result2 = Process.runSync(
'dart',
[
scriptPath,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Attention OP created or responded to issue and it needs attention.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request: Configurable firebase.json output directory ("--firebase-out=<PATH>")

3 participants