-
Notifications
You must be signed in to change notification settings - Fork 932
feat: use config inside run-android #791
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
Conversation
9a64c8a to
9479050
Compare
9479050 to
6787e3e
Compare
grabbou
left a comment
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.
LGTM. Left some commends and ideas, open to discussions :) Good job!
| }); | ||
| } | ||
| logger.error( | ||
| `Cannot start the packager. Unknown platform ${process.platform}`, |
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.
Shouldn't we throw here?
TIP: This codeebase hasn't been touched in a while, I am pretty sure it has some wild logger.error instead of CLIError in few places.
Good opportunity to update.
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.
It's not related to the PR, we can take it separately under "improving error messags and handling inside run-android". Whatever makes more sense!
| const packageMatch = manifestContent.match(/package="(.+?)"/); | ||
|
|
||
| if (packageMatch) { | ||
| packageName = packageMatch[1]; |
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.
One more thing, don't we already have a packageName in the configuration?
I would also consider returning manifestPath from the configuration as well, as we already use it to derive packageName.
Otherwise, we risk using two different AndroidManifests which might be dangerous.
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 see we load AndroidManifest here based on args.appFolder, which by default is "app" (that's what configuration uses here https://github.com/react-native-community/cli/blob/next/packages/platform-android/src/config/findAndroidAppFolder.ts).
My proposal:
- make
AndroidProjectParamsacceptappFolderwith default value beingapp - here, in this code, check if
args.appFolderis provided and then, callprojectConfigwith{...androidProjectConfig, appFolder: args.appFolder}to get a "refreshed" configuration.
Would keep this unified I think. What you think?
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.
Yes we have, but the tricky thing is the appFolder. Gradle has a concept of root project (where root build.gradle is) and sub projects (e.g. app, core, ui). In a typical RN app, in settings.gradle we only include app project. But technically, in an Android-first project, there could be many gradle sub projects – and hence appFolder. Our configuration doesn't have this as an option. We could add it, but even when overwritten through a flag, the npx react-native config won't know about it. This is likely a super edge-case or even not happening, but we still support it.
That's why I can't really use the packageName or even appId from the configuration – because they only refer to a single project.
489cae3 to
455dcbd
Compare
|
Any update on this PR? The tests are failing, not reviewing at this point. |
|
Didn't have time to revisit yet |
455dcbd to
1d74191
Compare
d5a5757 to
0901b2e
Compare
|
Superseded by #1029 |
Summary:
Defer reading as much as possible from the shared config.
Details:
rootoption in favor of deriving it from config.sourceDirto only look forandroid/directory, which is a Gradle root project – this alignssourceDirto iOS and allows for greater flexibility, becauseandroid/appwas a hardcoded name for a defaultappFolder, which would likely break stuff when somebody started usingappFolderflag--appFolderand--appIdflagsandroid.project.appNameto compensate forappFolderappIdSuffix, when app uses flavorsFixes #781.
Test Plan:
Updated tests.