-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriter-opts.js
56 lines (48 loc) · 1.07 KB
/
writer-opts.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
/* eslint-disable unicorn/prevent-abbreviations */
const isEmpty = require('lodash/fp/isEmpty')
const types = require('./types')
const ORDER = [
'breaking',
'feat',
'security',
'fix',
'perf',
'docs',
'chore',
'refactor',
'test',
'style',
'build',
'ci',
'deps',
'metadata',
'revert',
'release',
'wip',
]
const expandedTypes = {
...types,
}
Object.values(types).forEach((type) => {
if (Array.isArray(type.aliases)) {
type.aliases.forEach((alias) => {
expandedTypes[alias] = { ...type, aliases: undefined }
})
}
})
function getTitle(type) {
const { emoji, title } = expandedTypes[type] || {
emoji: '❓',
title: 'Unknown changes',
}
return `${isEmpty(emoji) ? '' : `${emoji} `}${title}`
}
const commitGroupOrder = ORDER.map((type) => getTitle(type))
module.exports = {
commitGroupsSort: (commitGroup, otherCommitGroup) =>
commitGroupOrder.indexOf(commitGroup.title) -
commitGroupOrder.indexOf(otherCommitGroup.title),
commitsSort: ['scope', 'subject'],
groupBy: 'groupType',
noteGroupsSort: 'title',
}