-
Notifications
You must be signed in to change notification settings - Fork 0
/
.release-it.js
82 lines (79 loc) · 2.19 KB
/
.release-it.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
81
82
module.exports = {
"git": {
"requireCleanWorkingDir": false,
"commit": false,
"pushArgs": ["--tags"]
},
"github": {
"release": true
},
"npm": {
"ignoreVersion": true,
"publish": true,
"skipChecks": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preMajor":true,
"whatBump": (commits, options) => {
let defaults = {
build: 'ignore',
chore: 'patch',
ci: 'ignore',
docs: 'ignore',
feat: 'minor',
fix: 'patch',
perf: 'patch',
refactor: 'patch',
style: 'ignore',
test: 'ignore'
}
let types = (options?.preset?.types || [])
.reduce((a, v) => {
return { ...a, [v.type]: v.release }
}, {})
types = Object.assign({}, defaults, types)
let breakings = 0
let features = 0
let levelSet = ['major', 'minor', 'patch', 'ignore']
let level = Math.min.apply(Math, commits.map(commit => {
let level = levelSet.indexOf(types[commit.type])
level = level < 0 ? 3 : level
if (commit.notes.length > 0){
breakings += commit.notes.length
level = 0
}
if (commit.type === 'feat') {
features += 1;
}
return options.preMajor && level<2 ? level+1 : level
}))
return {
level: level,
reason: breakings === 1
? `There is ${breakings} BREAKING CHANGE and ${features} features`
: `There are ${breakings} BREAKING CHANGES and ${features} features`
}
},
"preset": {
"name": "conventionalcommits",
"types": [
{
"type": "ci",
"release": "patch"
}
]
},
}
}
}
// }
// "config":{
// "parserOpts":
// {
// "headerPattern": "^(\\w*)(!?)(?:\\((.*)\\)(!?))?: (.*)$",
// "headerCorrespondence": ['type', 'firstBreak','scope', 'firstBreak', 'subject'],
// noteKeywords: ['BREAKING CHANGE'],
// revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
// revertCorrespondence: ['header', 'hash']
// },