Bump patch automatically increments SNAPSHOT to next patch version
Closed this issue · 11 comments
At the moment, gulp-bump automatically bumps SNAPSHOT to the next patch version. For example, commanding bump({type:'patch'})
for 1.0.0-SNAPSHOT is patch bumped to 1.0.1 . It would be really helpful if instead it matched what npm version patch
does, which is bump the snapshot to 1.0.0 instead:
package.json before version bump
{
...
"version": "1.0.0-SNAPSHOT"
...
}
Bump version:
npm version patch
package.json after version bump (Desired output)
{
...
"version": "1.0.0"
...
}
PR?
It seems the issue does not exist at all in gulp-bump 1.0.0
However in 2.1.0 it seems this issue only exist when you use a preid tag for your prerelease version.
The issue does not exist if you do not use a preid tag:
version: 1.0.0
bump({type:'prerelease'})
version: 1.0.1-0
bump({type:'patch'})
version: 1.0.1
The issue does not exist if you specify the current preid in your patch bump:
version: 1.0.0
bump({type:'prerelease', preid:'alpha'})
version: 1.0.1-alpha.0
bump({type:'patch', preid:'alpha'})
version: 1.0.1
Bug or feature? I hope it is a bug since it complicates things when you want to get rid of the prerelease tag if you must know what the current preid is before you bump.
FYI even though only the 'prerelease' type is described in the readme, a 'pre' type is also supported it seems.
However there is a difference whether you use bump({type:'prerelease'})
or bump({type:'pre'})
:
'prerelease' will also increment patch version if the current version is not a prerelease, but 'pre' will not do this.
Is the 'pre' type intended to be supported?
The pre
type is supported, as the type is eventually passed to semver, I can add docs for it soon.
Can you test with the latest changes to bump-regex
or the master branch of this plugin?
Thanks
Came here for exactly this (gotta love the internet). Had to ditch gulp-bump
completely in gulp-release because of this.
I'd like to comment that "semver": "^5.3.0",
does not have this problem with something like:
const semver = require('semver');
let ver = semver.inc('1.0.0-dev', 'patch');
console.log(ver);
// 1.0.0
@stevelacy Tried with latest master
and I'm seeing the same behaviour.
With a package.json
such as:
{
"name": "release-test",
"version": "1.0.12-dev",
}
I get:
OPTIONS { version: null, type: 'patch' }
[17:08:19] Bumped 1.0.12 to 1.0.13 with type: patch
Expected 1.0.12-dev to 1.0.12
.
Also, unless I'm doing something wrong, what was explained here before doesn't seem to hold true anymore:
version: 1.0.1-alpha.0
bump({type:'patch', preid:'alpha'})
version: 1.0.1
Setting preid
does nothing with a version number such as 1.0.12-dev
:
[17:14:06] Starting 'bump'...
OPTIONS { version: null, type: 'patch', preid: 'dev' }
[17:14:06] Bumped 1.0.12 to 1.0.13 with type: patch
@nfantone that is odd, this test passes: https://github.com/stevelacy/bump-regex/blob/master/test/index.js#L126
Can you verify that the log output is correct? I'm guessing that the parsed var is dumping the sufix (preid).
@stevelacy That logging is not mine. It's actually coming from gulp-bump
here: https://github.com/stevelacy/gulp-bump/blob/master/index.js#L36
@nfantone I am aware, as I mentioned it may be dropping the prefix/sufix
@stevelacy It does not matter, really, since it's doing evidently more than that. The ouput should be 1.0.12-dev to 1.0.12
, not 1.0.13
. It's not just a prefix being dropped.
@stevelacy Found the culprit. Opening an issue over at bump-regex.