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

Bump removes versionName identifier from build.gradle #2

Closed
AlphaGit opened this issue Aug 6, 2020 · 6 comments
Closed

Bump removes versionName identifier from build.gradle #2

AlphaGit opened this issue Aug 6, 2020 · 6 comments

Comments

@AlphaGit
Copy link

AlphaGit commented Aug 6, 2020

Hi! First of all, thanks for this wonderful tool -- it really comes in handy!

I've noticed that after running a version bump, the versionName identifier is removed from the build.gradle file.

Say that these are my initial build.gradle contents:

    defaultConfig {
        applicationId "com.my.project"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 3
        versionName "0.3.0"
    }

I will run:

> λ npx react-native bump-version --type minor

iOS project.pbxproj code: 3 -> 4
Android build.gradle code: 3 -> 4
iOS project.pbxproj version: undefined -> 0.4.0
Android gradle.build version: "0.3.0" -> 0.4.0
package.json: 0.3.0 -> 0.4.0

This is the final build.gradle:

    defaultConfig {
        applicationId "com.my.project"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 4
        "0.4.0"
    }

Which in turns, makes the script fail on the next try, because it doesn't find the versionName identifier:

> λ npx react-native bump-version --type minor

iOS project.pbxproj code: 4 -> 5
Android build.gradle code: 4 -> 5
iOS project.pbxproj version: undefined -> 0.5.0
error Cannot read property 'replace' of undefined. Run CLI with --verbose flag for more details.
TypeError: Cannot read property 'replace' of undefined
    at BuildGradleManager.setVersionName (C:\MyProject\node_modules\react-native-cli-bump-version\lib\index.js:92:17)
    at ProjectFilesManager.syncSemver (C:\MyProject\node_modules\react-native-cli-bump-version\lib\index.js:139:83)
    at ProjectFilesManager.exec (C:\MyProject\node_modules\react-native-cli-bump-version\lib\index.js:167:18)
    at exports.versioner (C:\MyProject\node_modules\react-native-cli-bump-version\lib\index.js:176:38)
    at Object.func (C:\MyProject\node_modules\react-native-cli-bump-version\react-native.config.js:21:13)
    at Command.handleAction (C:\MyProject\node_modules\@react-native-community\cli\build\index.js:186:23)
    at Command.listener (C:\MyProject\node_modules\@react-native-community\cli\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:200:13)
    at Command.parseArgs (C:\MyProject\node_modules\@react-native-community\cli\node_modules\commander\index.js:651:12)
    at Command.parse (C:\MyProject\node_modules\@react-native-community\cli\node_modules\commander\index.js:474:21)

I think this might simply be a wrong replacement in the regex. (If there is a chance, I might come back myself with a PR for this issue.)

Thanks again!

@Grohden
Copy link
Owner

Grohden commented Aug 6, 2020

@AlphaGit thx for opening this issue

I'm gonna take a look into that as soon as I can!

@Grohden
Copy link
Owner

Grohden commented Aug 6, 2020

Oh, I think that I just have missed the versionName in the replace

this.content = currentFile.replace(
nameExp,
// Here we try to prevent quotes style...
// which may be unnecessary, but who knows?
current.replace(quotes, next)
)

Looking at the versionCode in comparison, I re-add it to the replace:

this.content = currentFile.replace(codeExp, `versionCode ${ next }`)

I'm using gradle to get version names directly from package.json so I've been always skipping semver for android..

Anyway, gonna fix that and also setup some tests

@Grohden Grohden closed this as completed in 41ba114 Aug 6, 2020
@Grohden
Copy link
Owner

Grohden commented Aug 6, 2020

Ops, wrongly closed

@Grohden Grohden reopened this Aug 6, 2020
@Grohden
Copy link
Owner

Grohden commented Aug 6, 2020

@AlphaGit 1.0.3 released, can you confirm that it works?

@AlphaGit
Copy link
Author

AlphaGit commented Aug 7, 2020

@Grohden I can confirm it's working perfectly. Thank you very much for such a quick turnaround!

@Grohden
Copy link
Owner

Grohden commented Aug 7, 2020

I'm gonna close it then, feel free to reopen if needed

@Grohden Grohden closed this as completed Aug 7, 2020
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

No branches or pull requests

2 participants