-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathchangelog.config.js
More file actions
80 lines (68 loc) · 2.24 KB
/
Copy pathchangelog.config.js
File metadata and controls
80 lines (68 loc) · 2.24 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
'use strict'
// Custom conventional-changelog preset for LumenFlow.
// Groups: Features, Bug Fixes, Security, Performance, Breaking Changes.
// Covers all types required by acceptance criteria (#611).
module.exports = {
writerOpts: {
// Entries under these commit types are included in the changelog.
// "security" and "perf" are added on top of the angular defaults.
transform: (commit, context) => {
const issues = []
// Map type → section title
const TYPE_MAP = {
feat: '🚀 Features',
fix: '🐛 Bug Fixes',
security: '🔒 Security',
perf: '⚡ Performance',
revert: '⏪ Reverts',
docs: '📝 Documentation',
ci: '🤖 CI',
build: '🔧 Build'
}
if (!TYPE_MAP[commit.type]) {
return // skip types not in our map
}
commit.type = TYPE_MAP[commit.type]
// Detect BREAKING CHANGE notes and tag the entry
if (commit.notes) {
commit.notes.forEach(note => {
if (note.title === 'BREAKING CHANGE') {
note.title = '⚠ BREAKING CHANGES'
}
issues.push(note)
})
}
// Shorten commit hash for display
if (typeof commit.hash === 'string') {
commit.shortHash = commit.hash.substring(0, 7)
}
// Turn issue references (#N) into links
if (typeof commit.subject === 'string') {
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
issues.push(issue)
if (!context.repository) return `#${issue}`
return `[#${issue}](${context.host}/${context.owner}/${context.repository}/issues/${issue})`
})
}
return commit
},
// Group changelog sections by the mapped type string above
groupBy: 'type',
// Sort: breaking first, then features, fixes, security, perf, the rest
commitGroupsSort: (a, b) => {
const order = [
'⚠ BREAKING CHANGES',
'🚀 Features',
'🐛 Bug Fixes',
'🔒 Security',
'⚡ Performance',
'⏪ Reverts',
'📝 Documentation',
'🤖 CI',
'🔧 Build'
]
return order.indexOf(a.title) - order.indexOf(b.title)
},
commitsSort: ['scope', 'subject']
}
}