Skip to content

Conversation

schnecle
Copy link
Contributor

@schnecle schnecle commented Oct 2, 2025

Description

  • Augment app utils to look for app ids in google-services files
  • Augment get_environment to output app ids

Scenarios Tested

  • Added unit test coverage for get_environment as well as the new apputils
  • Testing e2e locally on several different apps

Sample Commands

gemini
/crashlytics:connect
gemini
"What's my firebase environment look like?"

@schnecle schnecle force-pushed the schnecle/get-mobile-environment branch 2 times, most recently from e951142 to d75b0a7 Compare October 2, 2025 20:05
@schnecle schnecle marked this pull request as ready for review October 2, 2025 20:06
@schnecle schnecle force-pushed the schnecle/get-mobile-environment branch 2 times, most recently from 0c515ca to a5bece4 Compare October 2, 2025 20:24
return {
platform: Platform.WEB,
directory: path.dirname(packageJsonFile),
frameworks: getFrameworksFromPackageJson(packageJson),
Copy link
Contributor

Choose a reason for hiding this comment

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

What about web? Do we want to call detectAppIdsForPlatform here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left web out because it's actually a little tricky. You can put the web configuration in any part of your code, so in the worst we would need to read through the entire code base. :/

If you've got ideas for how to do this more efficiently, I'm all ears!

Technically the same is true of flutter, but there is at least a convention around it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I at least left a comment to that effect in the code.

platform: Platform;
directory: string;
appId?: string;
bundleId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there ever be a case where an app directory found >1 appId / bundleId?

If the underlying detectAppIdsForPlatform could potentially return multiple? Maybe it's safer to include all responses in the App struct.

We can log those anomaly at a higher level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can and does happen. In this case, I create multiple app instances. They are unique by appId and bundleId but may have the same platform and directory.

@schnecle schnecle force-pushed the schnecle/get-mobile-environment branch from 2ea682b to 2add8f1 Compare October 6, 2025 18:45
${dump(getAllAccounts().map((account) => account.user.email)).trim()}
Detected App IDs: ${detectedAppsMap.size > 0 ? `\n\n${dump(Object.fromEntries(detectedAppsMap)).trim()}\n` : "<NONE>"}
Available Project Aliases (format: '[alias]: [projectId]'): ${Object.entries(rc.projects).length > 0 ? `\n\n${dump(rc.projects).trim()}\n` : "<NONE>"}
Available Accounts: ${hasOtherAccounts ? `\n\n${dump(allAccounts).trim()}` : "<NONE>"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we omit this header entirely if there are no other accounts logged in? Its a pretty rare use case in the first place.

If this project does not use Firebase tools that require a firebase.json file, no action is necessary.
It looks like the current directory is not initialized as a Firebase project. The user will most likely want to:
If this project uses Firebase tools that require a firebase.json file, the user will most likely want to:
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
If this project uses Firebase tools that require a firebase.json file, the user will most likely want to:
If this project uses Firebase services that require a firebase.json file, the user will most likely want to:

: `\n# Empty Environment
: `\nNo firebase.json file was found.
If this project does not use Firebase tools that require a firebase.json file, no action is necessary.
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
If this project does not use Firebase tools that require a firebase.json file, no action is necessary.
If this project does not use Firebase services that require a firebase.json file, no action is necessary.

const leanApp = Object.fromEntries(
Object.entries(app).filter((entry) => entry[1] !== undefined),
) as App;
console.log(`LEAN APP: ${JSON.stringify(leanApp)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove

App,
} from "./appUtils";

const FLUTTER_CONFIG = `
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than having these configs as constants and setting up new directories every time, we should just add the test directories to the src/test/fixtures directory

@@ -0,0 +1,314 @@
import * as fs from "fs-extra";
Copy link
Contributor

Choose a reason for hiding this comment

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

This file seems to duplicate a lot of what we've built in https://github.com/firebase/firebase-tools/blob/master/src/dataconnect/appFinder.ts - we really ought to unify the 2. I recall @fredzqm was looking at doing something like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have followup PR to do just that. I had some of that in here, but Fred recommended I take it out. See the conversation here: #9236 (comment)

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.

4 participants