-
Notifications
You must be signed in to change notification settings - Fork 1k
[FDC] Detect all apps during init dataconnect
#9026
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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: Thefirebase init dataconnect
command now utilizes a newdetectApps
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
-
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. ↩
There was a problem hiding this 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.
- 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.
}); | ||
|
||
it("should return WEB if package.json exists", async () => { | ||
fs.outputFileSync(`${testDir}/package.json`, "{}"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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/"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Co-authored-by: Maneesh Tewani <[email protected]>
/** 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
From empty folder
From folder with existing apps
https://screencast.googleplex.com/cast/NTU0MDY1NzYzOTcxODkxMnw2YWEyNzNjMi1hYg