-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only bump and create changelog if there ir a breaking change, feature or fix #99
base: master
Are you sure you want to change the base?
Changes from all commits
0ceea0c
4785715
8c9c5ce
e936987
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,8 +12,45 @@ | |||||||||||||||||||||||
const semver = require('semver') | ||||||||||||||||||||||||
const writeFile = require('../write-file') | ||||||||||||||||||||||||
const { resolveUpdaterObjectFromArgument } = require('../updaters') | ||||||||||||||||||||||||
const addBangNotes = require('conventional-changelog-conventionalcommits/add-bang-notes') | ||||||||||||||||||||||||
let configsToUpdate = {} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function _whatBump (config, commits) { | ||||||||||||||||||||||||
let level = 2 | ||||||||||||||||||||||||
let breakings = 0 | ||||||||||||||||||||||||
let features = 0 | ||||||||||||||||||||||||
let fix = 0 | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
commits.forEach(commit => { | ||||||||||||||||||||||||
addBangNotes(commit) | ||||||||||||||||||||||||
if (commit.notes.length > 0) { | ||||||||||||||||||||||||
breakings += commit.notes.length | ||||||||||||||||||||||||
level = 0 | ||||||||||||||||||||||||
} else if (commit.type === 'feat' || commit.type === 'feature') { | ||||||||||||||||||||||||
features += 1 | ||||||||||||||||||||||||
if (level === 2) { | ||||||||||||||||||||||||
level = 1 | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
if (commit.type === 'fix') { | ||||||||||||||||||||||||
fix += 1 | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
}) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if (config.preMajor && level < 2) { | ||||||||||||||||||||||||
level++ | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if (!breakings && !features && !fix) return {} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
return { | ||||||||||||||||||||||||
level, | ||||||||||||||||||||||||
reason: breakings === 1 | ||||||||||||||||||||||||
hazzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
? `There is ${breakings} BREAKING CHANGE and ${features} features` | ||||||||||||||||||||||||
: `There are ${breakings} BREAKING CHANGES and ${features} features` | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
async function Bump (args, version) { | ||||||||||||||||||||||||
// reset the cache of updated config files each | ||||||||||||||||||||||||
// time we perform the version bump step. | ||||||||||||||||||||||||
|
@@ -25,6 +62,14 @@ | |||||||||||||||||||||||
const stdout = await runLifecycleScript(args, 'prebump') | ||||||||||||||||||||||||
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim() | ||||||||||||||||||||||||
const release = await bumpVersion(args.releaseAs, version, args) | ||||||||||||||||||||||||
if (!Object.keys(release).length) { | ||||||||||||||||||||||||
checkpoint( | ||||||||||||||||||||||||
args, | ||||||||||||||||||||||||
'no commits found, so not bumping version', | ||||||||||||||||||||||||
[] | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
return null | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
if (!args.firstRelease) { | ||||||||||||||||||||||||
const releaseType = getReleaseType(args.prerelease, release.releaseType, version) | ||||||||||||||||||||||||
const releaseTypeAsVersion = releaseType === 'pre' + release.releaseType ? semver.valid(release.releaseType + '-' + args.prerelease + '.0') : semver.valid(releaseType) | ||||||||||||||||||||||||
|
@@ -108,7 +153,8 @@ | |||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function bumpVersion (releaseAs, currentVersion, args) { | ||||||||||||||||||||||||
return new Promise((resolve, reject) => { | ||||||||||||||||||||||||
// eslint-disable-next-line no-async-promise-executor | ||||||||||||||||||||||||
return new Promise(async (resolve, reject) => { | ||||||||||||||||||||||||
Comment on lines
+156
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Unless I'm missing something, you don't need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I'll remove it it's from an old implementation. |
||||||||||||||||||||||||
if (releaseAs) { | ||||||||||||||||||||||||
return resolve({ | ||||||||||||||||||||||||
releaseType: releaseAs | ||||||||||||||||||||||||
|
@@ -123,7 +169,12 @@ | |||||||||||||||||||||||
preset: presetOptions, | ||||||||||||||||||||||||
path: args.path, | ||||||||||||||||||||||||
tagPrefix: args.tagPrefix, | ||||||||||||||||||||||||
lernaPackage: args.lernaPackage | ||||||||||||||||||||||||
lernaPackage: args.lernaPackage, | ||||||||||||||||||||||||
...args.noBumpWhenEmptyChanges && { | ||||||||||||||||||||||||
whatBump (commits) { | ||||||||||||||||||||||||
return _whatBump(presetOptions, commits) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+173
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
^ I think this is a bit more idiomatic |
||||||||||||||||||||||||
} | ||||||||||||||||||||||||
}, args.parserOpts, function (err, release) { | ||||||||||||||||||||||||
if (err) return reject(err) | ||||||||||||||||||||||||
else return resolve(release) | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this perhaps be named
noBumpWhenEmptyChanges
?