@lmc-eu/conventional-changelog-lmc-bitbucket
Advanced tools
Comparing version 2.0.5 to 2.0.6
{ | ||
"name": "@lmc-eu/conventional-changelog-lmc-bitbucket", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "conventional-changelog LMC preset for BitBucket", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"dependencies": { | ||
"compare-func": "^2.0.0", | ||
"@lmc-eu/conventional-changelog-lmc": "^1.0.1", | ||
"q": "^1.5.1" | ||
@@ -41,4 +41,4 @@ }, | ||
"git-dummy-commit": "1.3.0", | ||
"jest": "27.5.1", | ||
"jest-extended": "2.0.0", | ||
"jest": "28.1.3", | ||
"jest-extended": "3.0.2", | ||
"shelljs": "0.8.5", | ||
@@ -56,3 +56,3 @@ "through2": "4.0.2" | ||
}, | ||
"gitHead": "bd5a5d83373884f2ae8a7284cd39b472fe7a214d" | ||
"gitHead": "9f12273b60c0a130cc9569fe19207a3b4dc39e35" | ||
} |
112
src/index.js
@@ -1,116 +0,6 @@ | ||
const compareFunc = require('compare-func'); | ||
const Q = require('q'); | ||
const readFile = Q.denodeify(require('fs').readFile); | ||
const { resolve } = require('path'); | ||
const { parserOpts, writerOpts } = require('@lmc-eu/conventional-changelog-lmc'); | ||
/** | ||
* Formats issues using the issueURL as the prefix of the complete issue URL | ||
* | ||
* @param {string} issueUrl - if the issueURL is falsy, then the issue will be printed as-is. | ||
* Otherwise, it will be printed as a link | ||
* @param {string} issue - the issue reference (without the # in-front of it) | ||
* @returns {string} - Either the issue or a Markdown-formatted link to the issue. | ||
*/ | ||
function formatIssue(issueUrl, issue) { | ||
if (issueUrl) { | ||
return `[#${issue}](${issueUrl}/${issue})`; | ||
} | ||
return `#${issue}`; | ||
} | ||
const parserOpts = { | ||
headerPattern: /^(?:Pull request #[0-9]+: )?(?:([a-zA-Z]*-[0-9_]*)(?: ))* ?([\w ]*)(?:\((.*)\))?: (.*)$/, | ||
headerCorrespondence: ['body', 'type', 'scope', 'subject'], | ||
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'], | ||
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
revertCorrespondence: ['header', 'hash'], | ||
}; | ||
const writerOpts = { | ||
transform: (commit, context) => { | ||
let discard = true; | ||
const issues = []; | ||
commit.notes.forEach((note) => { | ||
// eslint-disable-next-line no-param-reassign | ||
note.title = 'BREAKING CHANGES'; | ||
discard = false; | ||
}); | ||
const transformedCommit = commit; | ||
if (commit.type === 'BREAKING CHANGE' || commit.type === 'BREAKING CHANGES') { | ||
transformedCommit.type = 'BREAKING CHANGES'; | ||
} else if (commit.type === 'Feat') { | ||
transformedCommit.type = 'Features'; | ||
} else if (commit.type === 'Fix') { | ||
transformedCommit.type = 'Bug Fixes'; | ||
} else if (commit.type === 'Perf') { | ||
transformedCommit.type = 'Performance Improvements'; | ||
} else if (commit.type === 'Revert') { | ||
transformedCommit.type = 'Reverts'; | ||
} else if (commit.type === 'Docs') { | ||
transformedCommit.type = 'Documentation'; | ||
} else if (commit.type === 'Style') { | ||
transformedCommit.type = 'Styles'; | ||
} else if (commit.type === 'Refactor') { | ||
transformedCommit.type = 'Code Refactoring'; | ||
} else if (commit.type === 'Test') { | ||
transformedCommit.type = 'Tests'; | ||
} else if (commit.type === 'Chore') { | ||
transformedCommit.type = 'Chores'; | ||
} else if (commit.type === 'Deps') { | ||
transformedCommit.type = 'Dependencies'; | ||
} else if (discard) { | ||
return; | ||
} | ||
if (commit.scope === '*') { | ||
transformedCommit.scope = ''; | ||
} | ||
if (typeof commit.hash === 'string') { | ||
transformedCommit.hash = commit.hash.substring(0, 7); | ||
} | ||
// Remove port from host URI | ||
if (typeof context.host === 'string') { | ||
// eslint-disable-next-line no-param-reassign, prefer-destructuring | ||
context.host = context.host.match(/(^https?:\/\/[a-z.-]*)/)[0]; | ||
} | ||
// Take issue url from package.json | ||
const issueUrl = context.packageData.bugs && context.packageData.bugs.url; | ||
if (typeof transformedCommit.subject === 'string') { | ||
transformedCommit.subject = transformedCommit.subject.replace(/#([a-zA-Z0-9-]+)/g, (_, issue) => { | ||
issues.push(issue); | ||
return formatIssue(issueUrl, issue); | ||
}); | ||
} | ||
// remove references that already appear in the subject | ||
transformedCommit.references = commit.references | ||
.filter((reference) => { | ||
if (issues.indexOf(reference.issue) === -1) { | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.map((reference) => formatIssue(issueUrl, reference.issue)) | ||
.join(', '); | ||
// eslint-disable-next-line consistent-return | ||
return transformedCommit; | ||
}, | ||
groupBy: 'type', | ||
commitGroupsSort: 'title', | ||
commitsSort: ['scope', 'subject'], | ||
noteGroupsSort: 'title', | ||
notesSort: compareFunc, | ||
}; | ||
module.exports = Q.all([ | ||
@@ -117,0 +7,0 @@ readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
0
6202
19
1
+ Added@lmc-eu/conventional-changelog-lmc@1.3.2(transitive)
- Removedcompare-func@^2.0.0