Run next-version
in in directory containing package.json
file.
It will initialize npm to print next appropriate version.
It initializes npm, gets current package version from package.json
,
and requests published versions from npmjs.
If current package version patch or prerelease part ends with zero, it
will print result of semver.inc
on max published version having
same parts up to the last one.
Version in package.json | Published versions | Output of next-version |
---|---|---|
1.0.0 | none | 1.0.1 |
1.1.0 | 1.0.0, 1.0.1 | 1.1.1 |
1.1.0 | 1.0.0, 1.1.10 | 1.1.11 |
1.1.0-alpha | 1.1.0, 1.1.0-alpha.3 | 1.1.0-alpha.4 |
1.1.10 | 1.1.11, 1.1.10 | 1.1.11 |
Designed to be used during CI builds. Example package.json
"scripts": {
"bump": "npm version --no-git-tag-version $(next-version)"
}
npm run bump && npm publish