Skip to content

Conversation

@thymikee
Copy link
Member

@thymikee thymikee commented Oct 14, 2019

Summary:

Defer reading as much as possible from the shared config.
Details:

  • removed root option in favor of deriving it from config.
  • (possibly breaking) changed sourceDir to only look for android/ directory, which is a Gradle root project – this aligns sourceDir to iOS and allows for greater flexibility, because android/app was a hardcoded name for a default appFolder, which would likely break stuff when somebody started using appFolder flag
  • remove --appFolder and --appId flags
  • add android.project.appName to compensate for appFolder
  • fix running app with appIdSuffix, when app uses flavors

Fixes #781.

Test Plan:

Updated tests.

@grabbou grabbou mentioned this pull request Oct 15, 2019
@thymikee thymikee force-pushed the feat/android-use-config branch from 9a64c8a to 9479050 Compare October 17, 2019 19:07
@thymikee thymikee changed the base branch from master to next October 17, 2019 19:07
@thymikee thymikee force-pushed the feat/android-use-config branch from 9479050 to 6787e3e Compare October 17, 2019 19:50
@thymikee thymikee changed the title WIP: feat: use config inside run-android feat: use config inside run-android Oct 17, 2019
Copy link
Member

@grabbou grabbou left a 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}`,
Copy link
Member

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.

Copy link
Member

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];
Copy link
Member

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.

Copy link
Member

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 AndroidProjectParams accept appFolder with default value being app
  • here, in this code, check if args.appFolder is provided and then, call projectConfig with {...androidProjectConfig, appFolder: args.appFolder} to get a "refreshed" configuration.

Would keep this unified I think. What you think?

Copy link
Member Author

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.

@thymikee thymikee force-pushed the feat/android-use-config branch from 489cae3 to 455dcbd Compare October 18, 2019 22:19
@grabbou
Copy link
Member

grabbou commented Nov 15, 2019

Any update on this PR? The tests are failing, not reviewing at this point.

@thymikee
Copy link
Member Author

Didn't have time to revisit yet

@thymikee thymikee force-pushed the feat/android-use-config branch from d5a5757 to 0901b2e Compare November 20, 2019 10:43
@thymikee
Copy link
Member Author

thymikee commented Mar 3, 2020

Superseded by #1029

@thymikee thymikee closed this Mar 9, 2020
@thymikee thymikee deleted the feat/android-use-config branch March 9, 2020 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants