-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(preset): add recommended-bump opts into presets
Move `conventional-recommended-bump` options from the built-in presets into the individual `conventional-changelog-*` presets so that the same preset packages may be used between `conventional-recommended-bump` and `conventional-changelog`. Related to #241
- Loading branch information
Showing
76 changed files
with
1,329 additions
and
789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
packages/conventional-changelog-angular/conventional-changelog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
const Q = require(`q`); | ||
const parserOpts = require(`./parser-opts`); | ||
const writerOpts = require(`./writer-opts`); | ||
|
||
module.exports = Q.all([parserOpts, writerOpts]) | ||
.spread((parserOpts, writerOpts) => { | ||
return {parserOpts, writerOpts}; | ||
}); |
38 changes: 38 additions & 0 deletions
38
packages/conventional-changelog-angular/conventional-recommended-bump.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
whatBump: (commits) => { | ||
let level = 2; | ||
let breakings = 0; | ||
let features = 0; | ||
|
||
commits.forEach(commit => { | ||
if (commit.notes.length > 0) { | ||
breakings += commit.notes.length; | ||
level = 0; | ||
} else if (commit.type === `feat`) { | ||
features += 1; | ||
if (level === 2) { | ||
level = 1; | ||
} | ||
} | ||
}); | ||
|
||
return { | ||
level: level, | ||
reason: `There are ${breakings} BREAKING CHANGES and ${features} features` | ||
}; | ||
}, | ||
|
||
parserOpts: { | ||
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/, | ||
headerCorrespondence: [ | ||
`type`, | ||
`scope`, | ||
`subject` | ||
], | ||
noteKeywords: `BREAKING CHANGE`, | ||
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
revertCorrespondence: [`header`, `hash`] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,12 @@ | ||
'use strict'; | ||
var compareFunc = require('compare-func'); | ||
var Q = require('q'); | ||
var readFile = Q.denodeify(require('fs').readFile); | ||
var resolve = require('path').resolve; | ||
|
||
var parserOpts = { | ||
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/, | ||
headerCorrespondence: [ | ||
'type', | ||
'scope', | ||
'subject' | ||
], | ||
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'], | ||
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
revertCorrespondence: ['header', 'hash'] | ||
}; | ||
const Q = require(`q`); | ||
const conventionalChangelog = require(`./conventional-changelog`); | ||
const parserOpts = require(`./parser-opts`); | ||
const recommendedBumpOpts = require(`./conventional-recommended-bump`); | ||
const writerOpts = require(`./writer-opts`); | ||
|
||
var writerOpts = { | ||
transform: function(commit, context) { | ||
var discard = true; | ||
var issues = []; | ||
|
||
commit.notes.forEach(function(note) { | ||
note.title = 'BREAKING CHANGES'; | ||
discard = false; | ||
}); | ||
|
||
if (commit.type === 'feat') { | ||
commit.type = 'Features'; | ||
} else if (commit.type === 'fix') { | ||
commit.type = 'Bug Fixes'; | ||
} else if (commit.type === 'perf') { | ||
commit.type = 'Performance Improvements'; | ||
} else if (commit.type === 'revert') { | ||
commit.type = 'Reverts'; | ||
} else if (discard) { | ||
return; | ||
} else if (commit.type === 'docs') { | ||
commit.type = 'Documentation'; | ||
} else if (commit.type === 'style') { | ||
commit.type = 'Styles'; | ||
} else if (commit.type === 'refactor') { | ||
commit.type = 'Code Refactoring'; | ||
} else if (commit.type === 'test') { | ||
commit.type = 'Tests'; | ||
} else if (commit.type === 'chore') { | ||
commit.type = 'Chores'; | ||
} | ||
|
||
if (commit.scope === '*') { | ||
commit.scope = ''; | ||
} | ||
|
||
if (typeof commit.hash === 'string') { | ||
commit.hash = commit.hash.substring(0, 7); | ||
} | ||
|
||
if (typeof commit.subject === 'string') { | ||
var url = context.repository ? | ||
context.host + '/' + context.owner + '/' + context.repository : | ||
context.repoUrl; | ||
if (url) { | ||
url = url + '/issues/'; | ||
// Issue URLs. | ||
commit.subject = commit.subject.replace(/#([0-9]+)/g, function(_, issue) { | ||
issues.push(issue); | ||
return '[#' + issue + '](' + url + issue + ')'; | ||
}); | ||
} | ||
if (context.host) { | ||
// User URLs. | ||
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g, '[@$1](' + context.host + '/$1)'); | ||
} | ||
} | ||
|
||
// remove references that already appear in the subject | ||
commit.references = commit.references.filter(function(reference) { | ||
if (issues.indexOf(reference.issue) === -1) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
return commit; | ||
}, | ||
groupBy: 'type', | ||
commitGroupsSort: 'title', | ||
commitsSort: ['scope', 'subject'], | ||
noteGroupsSort: 'title', | ||
notesSort: compareFunc | ||
}; | ||
|
||
module.exports = Q.all([ | ||
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8') | ||
]) | ||
.spread(function(template, header, commit, footer) { | ||
|
||
writerOpts.mainTemplate = template; | ||
writerOpts.headerPartial = header; | ||
writerOpts.commitPartial = commit; | ||
writerOpts.footerPartial = footer; | ||
|
||
return { | ||
parserOpts: parserOpts, | ||
writerOpts: writerOpts | ||
}; | ||
module.exports = Q.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]) | ||
.spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => { | ||
return {conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
headerPattern: /^(\w*)(?:\((.*)\))?\: (.*)$/, | ||
headerCorrespondence: [ | ||
`type`, | ||
`scope`, | ||
`subject` | ||
], | ||
noteKeywords: [`BREAKING CHANGE`, `BREAKING CHANGES`], | ||
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
revertCorrespondence: [`header`, `hash`] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.