Skip to content

Commit cf7e6ea

Browse files
refactor(releaserc): simplificar o mapeamento de commit para melhor manutenibilidade
Também foi incluído o mapeamento do tipo 'chores'
1 parent 8d26e45 commit cf7e6ea

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

.releaserc.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
/* eslint no-template-curly-in-string: 0 */
22

33
// https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/writer-opts.js
4-
customTransform = (commit, context) => {
4+
const transformCommitType = type => {
5+
const commitTypeMapping = {
6+
feat: 'Features',
7+
fix: 'Bug Fixes',
8+
perf: 'Performance Improvements',
9+
revert: 'Reverts',
10+
docs: 'Documentation',
11+
style: 'Styles',
12+
refactor: 'Code Refactoring',
13+
test: 'Tests',
14+
build: 'Build System',
15+
ci: 'Continuous Integration',
16+
chore: 'Chores',
17+
default: 'Miscellaneous'
18+
}
19+
return commitTypeMapping[type] || commitTypeMapping.default
20+
}
21+
22+
const customTransform = (commit, context) => {
523
const issues = []
624

725
commit.notes.forEach(note => {
826
note.title = 'BREAKING CHANGES'
927
})
1028

11-
if (commit.type === 'feat') {
12-
commit.type = 'Features'
13-
} else if (commit.type === 'fix') {
14-
commit.type = 'Bug Fixes'
15-
} else if (commit.type === 'perf') {
16-
commit.type = 'Performance Improvements'
17-
} else if (commit.type === 'revert' || commit.revert) {
18-
commit.type = 'Reverts'
19-
} else if (commit.type === 'docs') {
20-
commit.type = 'Documentation'
21-
} else if (commit.type === 'style') {
22-
commit.type = 'Styles'
23-
} else if (commit.type === 'refactor') {
24-
commit.type = 'Code Refactoring'
25-
} else if (commit.type === 'test') {
26-
commit.type = 'Tests'
27-
} else if (commit.type === 'build') {
28-
commit.type = 'Build System'
29-
} else if (commit.type === 'ci') {
30-
commit.type = 'Continuous Integration'
31-
} else {
32-
return
33-
}
29+
commit.type = transformCommitType(commit.type)
3430

3531
if (commit.scope === '*') {
3632
commit.scope = ''
@@ -77,8 +73,8 @@ customTransform = (commit, context) => {
7773
module.exports = {
7874
branches: [
7975
// https://github.com/semantic-release/semantic-release/blob/master/docs/usage/workflow-configuration.md#workflow-configuration
80-
{name: 'trunk', channel: 'latest'},
81-
{name: 'beta', channel: 'beta', prerelease: 'beta'}
76+
{ name: 'trunk', channel: 'latest' },
77+
{ name: 'beta', channel: 'beta', prerelease: 'beta' }
8278
],
8379
plugins: [
8480
['@semantic-release/commit-analyzer', {

0 commit comments

Comments
 (0)