Skip to content

Conversation

fredzqm
Copy link
Contributor

@fredzqm fredzqm commented Aug 21, 2025

Copy link
Contributor

@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.

Summary of Changes

Hello @fredzqm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the application detection logic within the firebase init dataconnect command. It moves the platform detection utilities to a new appFinder module and introduces a more comprehensive detectApps function. This change aims to improve the initial setup experience by accurately identifying all applications in a project directory, ensuring appropriate SDK generation.

Highlights

  • Refactored app detection: Core logic for identifying application platforms (web, Android, iOS, Flutter) has been extracted from src/dataconnect/fileUtils.ts into a new dedicated module, src/dataconnect/appFinder.ts, promoting better organization and reusability.
  • Enhanced init dataconnect app discovery: The firebase init dataconnect command now utilizes a new detectApps function to identify all applications present in the current working directory, replacing the previous single-platform detection.
  • Streamlined SDK setup conditions: The condition for triggering SDK generation during init dataconnect has been updated to check for the presence of any detected web applications, making the process more precise.
  • Temporary suspension of framework-specific SDK detection: The automatic detection and enablement of framework-specific (e.g., React, Angular) JavaScript SDKs based on package.json analysis has been temporarily commented out in the SDK generation process.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@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 refactors the application detection logic into a new appFinder.ts module, which is a good structural improvement. However, the changes introduce a couple of functional regressions. The automatic SDK setup now only triggers for web applications, whereas it previously triggered for any detected platform. Additionally, the logic to detect web frameworks like React and Angular has been commented out, removing the automatic configuration for their specific SDKs. These regressions should be addressed to ensure existing functionality is not lost.

fredzqm and others added 11 commits August 22, 2025 14:27
- Fixed failing tests in `src/dataconnect/appFinder.spec.ts` by replacing `mock-fs` with `fs-extra` and rewriting the tests.
- Added a new file `src/dataconnect/fileUtils.ts` and a corresponding test file `src/dataconnect/fileUtils.spec.ts` to improve test coverage.
@fredzqm fredzqm requested a review from maneesht August 22, 2025 22:54
});

it("should return WEB if package.json exists", async () => {
fs.outputFileSync(`${testDir}/package.json`, "{}");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think down the line we should add helper functions here, but I'm fine with leaving this as-is until we increase the complexity of these tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😄 All of those tests are generated by Gemini Code Assist or Jules~

} else {
logSuccess(`Detected multiple app platforms in directory ${appDir}`);
// Can only setup one platform at a time, just ask the user
void trackGA4("dataconnect_init", {
Copy link
Contributor

Choose a reason for hiding this comment

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

When would fdcInfo be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone run firebase init dataconnect:sdk, it won't have fdcInfo set.

If someone run firebase init dataconnect or firebase init dataconnect dataconnect:init, the dataconnect feature is processed, so will set fdcInfo here.

The MCP firebase_init tool always set both.

Copy link
Contributor

Choose a reason for hiding this comment

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

That should definitely be added as a comment in this block

logBullet(
"Run `npm i --save @angular/fire @tanstack-query-firebase/angular @tanstack/angular-query-experimental` to install angular sdk dependencies.\nVisit https://github.com/invertase/tanstack-query-firebase/tree/main/packages/angular for more information on how to set up Angular Generated SDKs for Firebase Data Connect",
);
case Platform.IOS: {
Copy link
Contributor

Choose a reason for hiding this comment

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

@aashishpatil-g to check these defaults

const packageJsonFiles = await detectFiles(dirPath, "package.json");
const pubSpecYamlFiles = await detectFiles(dirPath, "pubspec.yaml");
const srcMainFolders = await detectFiles(dirPath, "src/main/");
const xCodeProjects = await detectFiles(dirPath, "*.xcodeproj/");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this and line 45 are definitive in detecting whether the directory is for android/iOS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested this out with local Android & iOS app as well.

In http://shortn/_UksVreexKl, I defined the requirement of app.directory~ Will be sure need to document this clearly.

For now, this is still part of connector.yaml, we can refactor later.

/** Given a directory, determine the platform type */
export async function getPlatformFromFolder(dirPath: string): Promise<Platform> {
const apps = await detectApps(dirPath);
const hasWeb = apps.some((app) => app.platform === Platform.WEB);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider, instead, creating a set with all discovered platform values. If the set's size is 0 then return NONE. If its size is 1 then return that platform. Otherwise return multiple. That will be more maintainable as well for when new platforms are added.

Copy link
Contributor Author

@fredzqm fredzqm Aug 26, 2025

Choose a reason for hiding this comment

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

getPlatformFromFolder can go away soon.

Only kept it because management/apps.ts still use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

"can go away soon" -> famous last words for code that will still exist in 10 years

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.

3 participants