Skip to content
Permalink
Browse files
feat!: bump minor rather than major, if release is < 1.0.0 (#347)
BREAKING CHANGE: we now bump the minor rather than major if version < 1.0.0; --release-as can be used to bump to 1.0.0.
  • Loading branch information
bcoe committed May 5, 2019
1 parent 6718428 commit 5d972cf1fede448001e30283e3258d07bed41658
Showing with 31 additions and 14 deletions.
  1. +7 −3 lib/lifecycles/bump.js
  2. +24 −11 test.js
@@ -28,7 +28,7 @@ function Bump (args, version) {
.then(runLifecycleScript.bind(this, args, 'prebump'))
.then((stdout) => {
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim()
return bumpVersion(args.releaseAs, args)
return bumpVersion(args.releaseAs, version, args)
})
.then((release) => {
if (!args.firstRelease) {
@@ -129,16 +129,20 @@ function getTypePriority (type) {
return TypeList.indexOf(type)
}

function bumpVersion (releaseAs, args) {
function bumpVersion (releaseAs, currentVersion, args) {
return new Promise((resolve, reject) => {
if (releaseAs) {
return resolve({
releaseType: releaseAs
})
} else {
const presetOptions = presetLoader(args)
if (typeof presetOptions === 'object') {
if (semver.lt(currentVersion, '1.0.0')) presetOptions.preMajor = true
}
conventionalRecommendedBump({
debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'),
preset: presetLoader(args),
preset: presetOptions,
path: args.path
}, function (err, release) {
if (err) return reject(err)
35 test.js
@@ -1034,17 +1034,6 @@ describe('standard-version', function () {

describe('configuration', () => {
it('reads config from .versionrc', function () {
// we currently skip several replacments in CHANGELOG
// generation if repository URL isn't set.
//
// TODO: consider modifying this logic in conventional-commits
// perhaps we should only skip the replacement if we rely on
// the {{host}} field?
writePackageJson('1.0.0', {
repository: {
url: 'https://github.com/yargs/yargs.git'
}
})
// write configuration that overrides default issue
// URL format.
fs.writeFileSync('.versionrc', JSON.stringify({
@@ -1057,4 +1046,28 @@ describe('standard-version', function () {
content.should.include('http://www.foo.com/1')
})
})

describe('pre-major', () => {
it('bumps the minor rather than major, if version < 1.0.0', function () {
writePackageJson('0.5.0', {
repository: {
url: 'https://github.com/yargs/yargs.git'
}
})
commit('feat!: this is a breaking change')
execCli()
getPackageVersion().should.equal('0.6.0')
})

it('bumps major if --release-as=major specified, if version < 1.0.0', function () {
writePackageJson('0.5.0', {
repository: {
url: 'https://github.com/yargs/yargs.git'
}
})
commit('feat!: this is a breaking change')
execCli('-r major')
getPackageVersion().should.equal('1.0.0')
})
})
})

0 comments on commit 5d972cf

Please sign in to comment.