Skip to content

Bump removes versionName identifier from build.gradle #2

@AlphaGit

Description

@AlphaGit

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions