Skip to content
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

fix: be able to read more complex buildToolsVersion definitions #2531

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dloic
Copy link

@dloic dloic commented Oct 16, 2024

Summary:

As highlighted in #2221, the way some projects (like expo ones) define the buildToolsVersion is breaking react-native doctor.

buildscript {
    ext {
        buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
        minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
   ...

leads to buildToolsVersion => .b34.0.0.

The PR is slightly tweaking the parsing to account for those cases.

Test Plan:

  • A new test has been added to demonstrate code is now able to properly read the buildToolsVersion
  • Existing tests are already covering the basic buildToolsVersion = "a version" syntax

Checklist

  • [ ] Documentation is up to date to reflect these changes. NA
  • Follows commit message convention described in CONTRIBUTING.md

@dloic
Copy link
Author

dloic commented Nov 11, 2024

@cipolleschi friendly bump on this one ;) Any feedback?

@@ -50,8 +50,8 @@ const getBuildToolsVersion = (projectRoot = ''): string => {
.substring(buildToolsVersionIndex)
.split('\n')[0]
// Get only the the value of `buildToolsVersion`
.match(/\d|\../g) || []
).join('');
.match(/\d+/g) || []
Copy link
Contributor

Choose a reason for hiding this comment

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

if the version is always three parts, shouldn't we do /\d+\.\d+\.\d+/g? 🤔
This probably allow to drop the join below as well.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. Build tools versions are \d+\.\d+\.\d+. PR updated.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

If it works, it looks ok to me. I suggested a more precise approach, but I'm not super familiar on how the versioning of the Android build tool is defined.

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.

2 participants