-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog.config.js
80 lines (74 loc) · 1.53 KB
/
changelog.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const fs = require('fs');
const customTransform = (commit, context) => {
const transformedCommit = { ...commit };
switch (transformedCommit.type) {
case 'feat':
transformedCommit.customGroup = 'Features';
break;
case 'feature':
transformedCommit.customGroup = 'Features';
break;
case 'fix':
transformedCommit.customGroup = 'Bug Fixes';
break;
case 'docs':
transformedCommit.customGroup = 'Documentation';
break;
default:
transformedCommit.customGroup = null;
}
return transformedCommit;
};
module.exports = {
writerOpts: {
transform: customTransform,
groupBy: 'customGroup',
commitGroupsSort: 'title',
commitsSort: ['scope', 'subject'],
mainTemplate: `{{> header}}
{{#each commitGroups}}
{{#if title}}
### {{title}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}
{{/if}}
{{/each}}
{{> footer}}
`,
headerPartial: `{{#if isPatch~}}
##
{{~else~}}
#
{{~/if}} {{#if @root.linkCompare~}}
[{{version}}](
{{~#if @root.repository~}}
{{~#if @root.host}}
{{[email protected]}}/
{{~/if}}
{{~#if @root.owner}}
{{[email protected]}}/
{{~/if}}
{{~else}}
{{~/if~}}
/compare/{{previousTag}}...{{currentTag}})
{{~else}}
{{~version}}
{{~/if}}
{{~#if title}} "{{title}}"
{{~/if}}
{{~#if date}} ({{date}})
{{/if}}
`,
},
hooks: {
postbump: () => {
const path = 'CHANGELOG.md';
if (!fs.existsSync(path)) {
fs.writeFileSync(path, '', 'utf8');
}
},
},
};