vojtajina / grunt-bump

Grunt.js plugin - Increment package version.
MIT License
651 stars 122 forks source link

Multiple types of versions #195

Open yosiat opened 7 years ago

yosiat commented 7 years ago

Hi,

First of all, grunt-bump is totally amazing! In my app we have both production and staging, we want to use grunt-bump to manage versions in both environments.

Currently I see that grunt-bump support only one environment, how can I overcome this?

Another question: I see that grunt-bump takes the latest version from package.json, If I have no version their, it doesn't work and I expect grunt-bump to take latest version from latest git tag.

mojoaxel commented 7 years ago

@yosiat Could you please describe in more detail what you would expect from grunt-bump in your case. Maybe you also could explain your development process step by step. How a software can have multiple version at one time is not clear to me.

Trying to get a semver number from the last git tag is a nice idea for an enhancement.

edthorne commented 7 years ago

I think you're encountering the same issue that I am. When matching the version number, if the prereleaseName value does NOT appear in the version string, it won't match a prerelease version and will increment only the version. Here's an example of what happens currently:

1.0.0-dev.0 bump:prerelease (prereleaseName = dev) 1.0.0-dev.1 bump:prerelease (prereleaseName = rc) 1.0.1-rc.0 bump (prereleaseName != rc) 1.0.2

The reason for this is the inclusion of the prereleaseName option value in the regular expression rather than generically matching any prereleaseName value found in a semantic version string.

My desired behavior, and what I think you're asking for, should be as follows:

1.0.0-dev.0 bump:prerelease (prereleaseName = dev) 1.0.0-dev.1 bump:prerelease (prereleaseName = rc) 1.0.0-rc.0 bump (prereleaseName = dev) 1.0.0

You can work around the final bump by ensuring the prereleaseName matches 'rc' for final builds. The dev to rc transition has to be done by hand when branching for the release build.

OR

Use a custom regExp setting to avoid the exact matching of prereleaseName:


regExp: new RegExp('([\'|\"]?version[\'|\"]?[ ]*:[ ]*[\'|\"]?)(\\d+\\.\\d+\\.\\d+(-[\\w\\d\\-\\.]+\\.\\d+)?(-\\d+)?)[\\d||A-a|.|-]*([\'|\"]?)')

I think the default behavior should not include the prereleaseName in the regular expression allowing version matching to match any prerelease version. The semver API call handles transitions from dev to rc without incrementing any of the major, minor, patch values.

Here's an example project: bump.zip