-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchangelog.config.js
More file actions
104 lines (90 loc) · 3.63 KB
/
changelog.config.js
File metadata and controls
104 lines (90 loc) · 3.63 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* Conventional Changelog configuration
* Used by conventional-changelog-cli to generate CHANGELOG.md
*
* Strategy: Relaxed validation with intelligent categorization
* - Accept any commit type (commitlint allows all types)
* - Map custom types (imp, deps) to display in appropriate sections
* - Display important changes (feat, fix, imp->refactor, deps->chore, refactor, docs)
* - Hide internal changes (test, ci, build, style)
*/
const typeMapping = {
// Standard types
'feat': { section: 'Features', hidden: false },
'feature': { section: 'Features', hidden: false },
'fix': { section: 'Bug Fixes', hidden: false },
'ifx': { section: 'Bug Fixes', hidden: false },
// Custom types mapped to Improvements (shown as refactor internally)
'imp': { section: 'Improvements', hidden: false, mapTo: 'refactor' },
'improve': { section: 'Improvements', hidden: false, mapTo: 'refactor' },
'improvement': { section: 'Improvements', hidden: false, mapTo: 'refactor' },
// Dependency types mapped to Dependencies (shown as docs internally to get visible)
'deps': { section: 'Dependencies', hidden: false, mapTo: 'docs' },
'dep': { section: 'Dependencies', hidden: false, mapTo: 'docs' },
'dependencies': { section: 'Dependencies', hidden: false, mapTo: 'docs' },
'dependency': { section: 'Dependencies', hidden: false, mapTo: 'docs' },
// Standard visible types
'refactor': { section: 'Code Refactoring', hidden: false },
'perf': { section: 'Performance Improvements', hidden: false },
'performance': { section: 'Performance Improvements', hidden: false },
'docs': { section: 'Documentation', hidden: false },
'doc': { section: 'Documentation', hidden: false },
'revert': { section: 'Reverts', hidden: false },
// Hidden types
'chore': { section: 'Miscellaneous Chores', hidden: true },
'test': { section: 'Tests', hidden: true },
'tests': { section: 'Tests', hidden: true },
'ci': { section: 'Continuous Integration', hidden: true },
'build': { section: 'Build System', hidden: true },
'style': { section: 'Styles', hidden: true },
};
module.exports = {
// Define types with friendly section names
types: [
{ type: 'feat', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' },
{ type: 'perf', section: 'Performance Improvements' },
{ type: 'revert', section: 'Reverts' },
{ type: 'docs', section: 'Documentation' },
{ type: 'refactor', section: 'Code Refactoring' },
{ type: 'test', hidden: true },
{ type: 'build', hidden: true },
{ type: 'ci', hidden: true },
{ type: 'chore', hidden: true },
{ type: 'style', hidden: true },
],
writerOpts: {
transform: (commit, context) => {
const mapping = typeMapping[commit.type];
// Hide commits based on mapping
if (mapping && mapping.hidden) {
return;
}
// Create a new commit object (avoid mutating immutable object)
const newCommit = { ...commit };
if (mapping) {
// Map custom types to standard types
if (mapping.mapTo) {
newCommit.type = mapping.mapTo;
}
} else {
// Unknown types go to refactor (will be shown)
newCommit.type = 'refactor';
}
// Standard transformations
if (newCommit.scope === '*') {
newCommit.scope = '';
}
if (typeof newCommit.hash === 'string') {
newCommit.shortHash = newCommit.hash.substring(0, 7);
}
if (typeof newCommit.subject === 'string') {
newCommit.subject = newCommit.subject.substring(0, 80);
}
return newCommit;
},
groupBy: 'type',
commitGroupsSort: 'title',
commitsSort: ['scope', 'subject'],
},
};