Skip to content

Commit d7ec542

Browse files
Revert "chore(release): use default changelog content"
This reverts commit c678f63.
1 parent ed48fe9 commit d7ec542

File tree

1 file changed

+77
-1
lines changed

1 file changed

+77
-1
lines changed

.releaserc.js

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,75 @@
1+
/* eslint no-template-curly-in-string: 0 */
2+
const { env } = process
3+
4+
// https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/writer-opts.js
5+
const transformCommitType = type => {
6+
const commitTypeMapping = {
7+
feat: 'Features',
8+
fix: 'Bug Fixes',
9+
perf: 'Performance Improvements',
10+
revert: 'Reverts',
11+
docs: 'Documentation',
12+
style: 'Styles',
13+
refactor: 'Code Refactoring',
14+
test: 'Tests',
15+
build: 'Build System',
16+
ci: 'Continuous Integration',
17+
chore: 'Chores',
18+
default: 'Miscellaneous'
19+
}
20+
return commitTypeMapping[type] || commitTypeMapping.default
21+
}
22+
23+
const customTransform = (commit, context) => {
24+
const issues = []
25+
26+
commit.notes.forEach(note => {
27+
note.title = 'BREAKING CHANGES'
28+
})
29+
30+
commit.type = transformCommitType(commit.type)
31+
32+
if (commit.scope === '*') {
33+
commit.scope = ''
34+
}
35+
36+
if (typeof commit.hash === 'string') {
37+
commit.shortHash = commit.hash.substring(0, 7)
38+
}
39+
40+
if (typeof commit.subject === 'string') {
41+
let url = context.repository
42+
? `${context.host}/${context.owner}/${context.repository}`
43+
: context.repoUrl
44+
if (url) {
45+
url = `${url}/issues/`
46+
// Issue URLs.
47+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
48+
issues.push(issue)
49+
return `[#${issue}](${url}${issue})`
50+
})
51+
}
52+
if (context.host) {
53+
// User URLs.
54+
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
55+
if (username.includes('/')) {
56+
return `@${username}`
57+
}
58+
return `[@${username}](${context.host}/${username})`
59+
})
60+
}
61+
}
62+
63+
// remove references that already appear in the subject
64+
commit.references = commit.references.filter(reference => {
65+
if (issues.indexOf(reference.issue) === -1) {
66+
return true
67+
}
68+
return false
69+
})
70+
71+
return commit
72+
}
173

274
module.exports = {
375
branches: [
@@ -13,7 +85,11 @@ module.exports = {
1385
{ type: 'docs', scope: 'homepage', release: 'patch' }
1486
]
1587
}],
16-
['@semantic-release/release-notes-generator'],
88+
['@semantic-release/release-notes-generator', {
89+
writerOpts: {
90+
transform: customTransform
91+
}
92+
}],
1793
['@semantic-release/changelog', {
1894
changelogTitle: '# Changelog'
1995
}],

0 commit comments

Comments
 (0)