-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.release-it.js
83 lines (81 loc) · 2.05 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
83
module.exports = {
"git":{
"requireCleanWorkingDir": false,
"commit": false,
"pushArgs": ["--tags"]
},
"github": {
"release": true
},
"npm": {
"ignoreVersion": true,
"publish": true,
"skipChecks": true
},
"plugins": {
"@release-it/conventional-changelog": {
"whatBump": (commits,options)=>{
let defaults = {
build: 'ignore',
ci: 'ignore',
docs: 'ignore',
feat: 'minor',
fix: 'patch',
perf: 'patch',
refactor: '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
}
if(commit.type === 'feat'){
features += 1;
}
return 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": "angular",
"types": [
{
"type": "refactor",
"release": "patch"
},
{
"type": "style",
"release": "patch"
},
{
"type": "perf",
"release": "patch"
},
{
"type": "chore",
"release": "patch"
},
{
"type": "ci",
"release": "patch"
}
]
}
}
}
}