Skip to content

Conversation

@joehan
Copy link
Contributor

@joehan joehan commented Aug 2, 2024

Description

Asking users to type in paths is the worst. Just knowing is better.

Still have a few more things to test here:

  • Test iOS autodetection
  • Test Android autodetect
  • Test out the total fail case where we cannot detect at all

Scenarios Tested

Tested auto-detection of a web app, from the firebase.json directory and from the app directory
Screenshot 2024-08-01 at 5 07 13 PM
Screenshot 2024-08-01 at 5 06 54 PM
IOS (tested with friendlyeats-ios app)
Screenshot 2024-08-02 at 11 53 09 AM
Android (tested with friendlyeats-android app)
Screenshot 2024-08-02 at 11 48 16 AM

@joehan joehan requested a review from maneesht August 2, 2024 00:13
Copy link
Contributor

@maneesht maneesht left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me! I have a few discussion points, but I'll post them in chat rather than leave them here

@joehan joehan requested review from hlshen and maneesht August 2, 2024 16:48
@joehan joehan marked this pull request as ready for review August 2, 2024 19:38
Copy link
Member

@yuchenshi yuchenshi left a comment

Choose a reason for hiding this comment

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

Edge case: If both web and Android indicators are present in the same directory, do we want to treat it as web (as implemented right now) or undetermined? If the former, what is the best order of priority?

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Two random comments:

  1. An irrelevant message about adding the project to Xcode is emitted when initializing the Kotlin SDK. Consider only emitting this message when configuring the Swift SDK:
i  Generated SDK code for foo
i  Please follow the instructions here to add your generated sdk to your XCode project:
        https://firebase.google.com/docs/data-connect/gp/ios-sdk#set-client
  1. Any comments in the yaml file are discarded. I would expect comments to remain after "editing" the yaml file to add the new information.

newConnectorYaml.generate.kotlinSdk?.outputDir ||
path.relative(
connectorInfo.directory,
path.join(appDir, `generated/${newConnectorYaml.connectorId}`),
Copy link
Contributor

Choose a reason for hiding this comment

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

Omit ${newConnectorYaml.connectorId} from the output dir as the kotlin codegen will automatically append directories corresponding to the "package", which usually incorporates the connector name.

For example, I tested this out on a connector named "foo". The code was then generated into generated/foo/connectors/foo/ when it should have gone into generated/connectors/foo/.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

newConnectorYaml.generate.kotlinSdk?.outputDir ||
path.relative(
connectorInfo.directory,
path.join(appDir, `generated/${newConnectorYaml.connectorId}`),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good start, but for the vast majority of Android projects this output directory will be nonsensical. For small, single-module Android projects that use the conventional directory structure, a better output directory would be app/src/main. However, app is only a convention, and it can be named anything. Maybe consider looking for app/src/main and using that directory if it exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea - added a check for that directory. If its not found, should fall back to the appDir (the current behavior), or are there other structure we ought to try?

@joehan
Copy link
Contributor Author

joehan commented Aug 6, 2024

Two random comments:

  1. An irrelevant message about adding the project to Xcode is emitted when initializing the Kotlin SDK. Consider only emitting this message when configuring the Swift SDK:
i  Generated SDK code for foo
i  Please follow the instructions here to add your generated sdk to your XCode project:
        https://firebase.google.com/docs/data-connect/gp/ios-sdk#set-client

Good catch, will refactor to avoid that.

  1. Any comments in the yaml file are discarded. I would expect comments to remain after "editing" the yaml file to add the new information.

This one is an unfortunate side effect of us marshalling + unmarshalling the YAML to edit it. I think the effort required to avoid this is not worth the time ATM. Adding a TODO to remember this tho

@joehan joehan requested a review from dconeybe August 6, 2024 17:08
@joehan joehan enabled auto-merge (squash) August 6, 2024 18:05
connectorInfo.directory,
path.join(appDir, `generated/${newConnectorYaml.connectorId}`),
);
path.relative(connectorInfo.directory, path.join(baseDir, `generated`));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not add generated if app/src/main is used above. Only add generated if appDir is used above.

// app/src/main is a common practice for Andorid, but not explicitly required.
// If it is present, we'll use it. Otherwise, we fall back to the app directory.
const baseDir = fs.existsSync(path.join(appDir, "app/src/main"))
? path.join(appDir, "app/src/main")
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized, this should be app/src/main/java, not app/src/main.

// If it is present, we'll use it. Otherwise, we fall back to the app directory.
const baseDir = fs.existsSync(path.join(appDir, "app/src/main"))
? path.join(appDir, "app/src/main")
: appDir;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest path.join(appDir, "generated") instead of appDir, then remove the logic to append "generated" from line 158 below.

@joehan joehan merged commit 0354ae6 into master Aug 6, 2024
@joehan joehan deleted the jh-auto-app branch August 6, 2024 18:31
@dconeybe
Copy link
Contributor

dconeybe commented Aug 6, 2024

My final comments were not addressed. Please fix as the output is suboptimal.

Specifically, use app/src/main/java instead of app/src/main and only append generated if not using app/src/main/java.

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