Skip to content

Commit 56ef581

Browse files
committed
build: Try building patch objects.
1 parent a465470 commit 56ef581

File tree

1 file changed

+101
-94
lines changed

1 file changed

+101
-94
lines changed

.releaserc.js

Lines changed: 101 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -28,100 +28,107 @@ module.exports = {
2828
prepareCmd: 'git commit -am "release(v${nextVersion.release}: Prepare Release" && git push'
2929
}],
3030
["@semantic-release/release-notes-generator", {
31-
// "parserOpts": {
32-
// "headerPattern": /^(\w*)(?:\((.*)\))?!?: (.*)$/,
33-
// "breakingHeaderPattern": /^(\w*)(?:\((.*)\))?!: (.*)$/
34-
// },
35-
// "writerOpts": {
36-
// "transform": (commit, context) => {
37-
// let discard = false
38-
// const issues = []
39-
//
40-
// if (commit.type === 'chore'){
41-
// discard = true
42-
// }
43-
//
44-
// commit.notes.forEach(note => {
45-
// note.title = 'BREAKING CHANGES'
46-
// discard = false
47-
// })
48-
//
49-
// if (commit.type === 'feat') {
50-
// commit.type = 'Features'
51-
// } else if (commit.type === 'fix') {
52-
// commit.type = 'Bug Fixes'
53-
// } else if (commit.type === 'perf') {
54-
// commit.type = 'Performance Improvements'
55-
// } else if (commit.type === 'revert' || commit.revert) {
56-
// commit.type = 'Reverts'
57-
// } else if (discard) {
58-
// return
59-
// } else if (commit.type === 'docs') {
60-
// commit.type = 'Documentation'
61-
// } else if (commit.type === 'style') {
62-
// commit.type = 'Styles'
63-
// } else if (commit.type === 'refactor') {
64-
// commit.type = 'Code Refactoring'
65-
// } else if (commit.type === 'test' || commit.type === 'tests') {
66-
// commit.type = 'Tests'
67-
// } else if (commit.type === 'build') {
68-
// if (commit.scope === 'dep' || commit.scope === 'deps'){
69-
// commit.type = 'Dependencies'
70-
// commit.scope = ''
71-
// } else if (commit.scope === 'dev-dep' || commit.scope === 'dev-deps'){
72-
// commit.type = 'Dependencies'
73-
// commit.scope = 'development'
74-
// } else {
75-
// commit.type = 'Build System'
76-
// }
77-
// } else if (commit.type === 'ci') {
78-
// commit.type = 'Continuous Integration'
79-
// }
80-
//
81-
// if (commit.scope === '*') {
82-
// commit.scope = ''
83-
// }
84-
//
85-
// if (typeof commit.hash === 'string') {
86-
// commit.shortHash = commit.hash.substring(0, 7)
87-
// }
88-
//
89-
// if (typeof commit.subject === 'string') {
90-
// let url = context.repository
91-
// ? `${context.host}/${context.owner}/${context.repository}`
92-
// : context.repoUrl
93-
// if (url) {
94-
// url = `${url}/issues/`
95-
// // Issue URLs.
96-
// commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
97-
// issues.push(issue)
98-
// return `[#${issue}](${url}${issue})`
99-
// })
100-
// }
101-
// if (context.host) {
102-
// // User URLs.
103-
// commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
104-
// if (username.includes('/')) {
105-
// return `@${username}`
106-
// }
107-
//
108-
// return `[@${username}](${context.host}/${username})`
109-
// })
110-
// }
111-
// }
112-
//
113-
// // remove references that already appear in the subject
114-
// commit.references = commit.references.filter(reference => {
115-
// if (issues.indexOf(reference.issue) === -1) {
116-
// return true
117-
// }
118-
//
119-
// return false
120-
// })
121-
//
122-
// return commit
123-
// },
124-
// }
31+
"parserOpts": {
32+
"headerPattern": /^(\w*)(?:\((.*)\))?!?: (.*)$/,
33+
"breakingHeaderPattern": /^(\w*)(?:\((.*)\))?!: (.*)$/
34+
},
35+
"writerOpts": {
36+
"transform": (commit, context) => {
37+
let discard = false
38+
const issues = []
39+
let patch = {
40+
type: commit.type,
41+
}
42+
43+
if (commit.type === 'chore'){
44+
discard = true
45+
}
46+
47+
patch.notes = commit.notes.map(note => {
48+
let out = {...note}
49+
out.title = 'BREAKING CHANGES'
50+
discard = false
51+
return out
52+
})
53+
54+
if (patch.type === 'feat') {
55+
patch.type = 'Features'
56+
} else if (patch.type === 'fix') {
57+
patch.type = 'Bug Fixes'
58+
} else if (patch.type === 'perf') {
59+
patch.type = 'Performance Improvements'
60+
} else if (patch.type === 'revert' || commit.revert) {
61+
patch.type = 'Reverts'
62+
} else if (discard) {
63+
return
64+
} else if (patch.type === 'docs') {
65+
patch.type = 'Documentation'
66+
} else if (patch.type === 'style') {
67+
patch.type = 'Styles'
68+
} else if (patch.type === 'refactor') {
69+
patch.type = 'Code Refactoring'
70+
} else if (patch.type === 'test' || patch.type === 'tests') {
71+
patch.type = 'Tests'
72+
} else if (patch.type === 'build') {
73+
if (commit.scope === 'dep' || commit.scope === 'deps'){
74+
patch.type = 'Dependencies'
75+
patch.scope = ''
76+
} else if (commit.scope === 'dev-dep' || commit.scope === 'dev-deps'){
77+
patch.type = 'Dependencies'
78+
patch.scope = 'development'
79+
} else {
80+
patch.type = 'Build System'
81+
}
82+
} else if (patch.type === 'ci') {
83+
patch.type = 'Continuous Integration'
84+
}
85+
86+
if (commit.scope === '*') {
87+
commit.scope = ''
88+
}
89+
90+
if (typeof commit.hash === 'string') {
91+
patch.shortHash = commit.hash.substring(0, 7)
92+
}
93+
94+
if (typeof commit.subject === 'string') {
95+
patch.subject = commit.subject
96+
97+
let url = context.repository
98+
? `${context.host}/${context.owner}/${context.repository}`
99+
: context.repoUrl
100+
if (url) {
101+
url = `${url}/issues/`
102+
// Issue URLs.
103+
patch.subject = patch.subject.replace(/#([0-9]+)/g, (_, issue) => {
104+
issues.push(issue)
105+
return `[#${issue}](${url}${issue})`
106+
})
107+
}
108+
if (context.host) {
109+
// User URLs.
110+
patch.subject = patch.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
111+
if (username.includes('/')) {
112+
return `@${username}`
113+
}
114+
115+
return `[@${username}](${context.host}/${username})`
116+
})
117+
}
118+
}
119+
120+
// remove references that already appear in the subject
121+
patch.references = commit.references.filter(reference => {
122+
if (issues.indexOf(reference.issue) === -1) {
123+
return true
124+
}
125+
126+
return false
127+
})
128+
129+
return patch
130+
},
131+
}
125132
}],
126133
["@semantic-release/github", {
127134
"successComment": false

0 commit comments

Comments
 (0)