@@ -29,14 +29,18 @@ async function main(logger) {
29
29
currentVersion ,
30
30
) ;
31
31
32
- const commits = combineCommits (
33
- commitsSinceLastVersion . filter ( ( it ) => {
34
- return (
35
- ! it . title . includes ( "@types/node" ) &&
36
- ! it . title . includes ( "sync generated doc files" )
37
- ) ;
38
- } ) ,
39
- ) ;
32
+ const relevantCommits = commitsSinceLastVersion . filter ( ( it ) => {
33
+ return (
34
+ ! it . title . includes ( "build(deps-dev)" ) &&
35
+ ! it . title . includes ( "@types/node" ) &&
36
+ ! it . title . includes ( "typescript-types group" ) &&
37
+ ! it . title . includes ( "sync generated doc files" )
38
+ ) ;
39
+ } ) ;
40
+
41
+ const splitCommits = splitGroupedDependencyBumps ( relevantCommits ) ;
42
+ const commits = combineCommits ( splitCommits ) ;
43
+
40
44
decorateCommits ( commits ) ;
41
45
42
46
const proposedVersion = proposeVersionBump ( currentVersion , commits ) ;
@@ -104,6 +108,75 @@ function getChangelogHeaderAndSource(changelog) {
104
108
} ;
105
109
}
106
110
111
+ /**
112
+ * Split grouped dependency updates.
113
+ *
114
+ * @param {ChangelogCommit[] } commits
115
+ * @returns {ChangelogCommit[] }
116
+ */
117
+ function splitGroupedDependencyBumps ( commits ) {
118
+ const result = [ ] ;
119
+
120
+ // Updates `@aws-sdk/client-s3` from 3.369.0 to 3.370.0
121
+ // Updates `@babel/eslint-parser` from 7.22.7 to 7.22.9
122
+ const subDepStartMatch =
123
+ / U p d a t e s ` ( [ \w \- @ / ] + ) ` f r o m ( \d + \. \d + \. \d + ) t o ( \d + \. \d + \. \d + ) $ / g;
124
+
125
+ for ( const commit of commits ) {
126
+ if (
127
+ commit . title . includes ( "bump the" ) &&
128
+ commit . title . includes ( "group with" )
129
+ ) {
130
+ // Grouped commit
131
+ const [ , pr ] = commit . title . match ( / \( # ( \d + ) \) ? / ) ?? [ ] ;
132
+ const lines = commit . body . split ( "\n" ) ;
133
+
134
+ let dependency ;
135
+ let fromVersion ;
136
+ let toVersion ;
137
+ let body = "" ;
138
+
139
+ const finishCommit = ( ) => {
140
+ if ( dependency && body ) {
141
+ result . push ( {
142
+ title : `build(deps): bump ${ dependency } from ${ fromVersion } to ${ toVersion } (#${ pr } )` ,
143
+ hash : commit . hash ,
144
+ body,
145
+ notes : [ ] ,
146
+ } ) ;
147
+ }
148
+
149
+ dependency = undefined ;
150
+ fromVersion = undefined ;
151
+ toVersion = undefined ;
152
+ body = "" ;
153
+ } ;
154
+
155
+ for ( const line of lines ) {
156
+ subDepStartMatch . lastIndex = - 1 ;
157
+ const [ , dep , from , to ] = subDepStartMatch . exec ( line . trim ( ) ) ?? [ ] ;
158
+
159
+ if ( dep ) {
160
+ finishCommit ( ) ;
161
+
162
+ dependency = dep ;
163
+ fromVersion = from ;
164
+ toVersion = to ;
165
+ } else if ( dependency ) {
166
+ body += `${ line } \n` ;
167
+ }
168
+ }
169
+
170
+ finishCommit ( ) ;
171
+ } else {
172
+ // Any other commit
173
+ result . push ( commit ) ;
174
+ }
175
+ }
176
+
177
+ return result ;
178
+ }
179
+
107
180
/**
108
181
* Tries to combine the dependency bump commits. This is useful for things like aws-sdk
109
182
* which can have 10 bumps in a single Compas release.
@@ -115,7 +188,7 @@ function combineCommits(commits) {
115
188
// build(deps): bump @types/node from 14.6.2 to 14.6.3
116
189
// build(deps-dev): bump react-query from 2.12.1 to 2.13.0 (#234)
117
190
const depRegex =
118
- / ^ b u i l d \( ( d e p s | d e p s - d e v ) \) : b u m p ( [ \w \- @ / ] + ) f r o m ( \d + \. \d + \. \d + ) t o ( \d + \. \d + \. \d + ) (?: \s \( # ( \d + ) \) ) ? $ / g;
191
+ / ^ b u i l d \( ( d e p s ) \) : b u m p ( [ \w \- @ / ] + ) f r o m ( \d + \. \d + \. \d + ) t o ( \d + \. \d + \. \d + ) (?: \s \( # ( \d + ) \) ) ? $ / g;
119
192
120
193
const combinable = { } ;
121
194
const result = [ ] ;
@@ -156,11 +229,6 @@ function combineCommits(commits) {
156
229
for ( const pkg of Object . keys ( combinable ) ) {
157
230
const { buildType, prs, fromVersion, toVersion, body } = combinable [ pkg ] ;
158
231
159
- if ( buildType === "deps-dev" ) {
160
- // We don't need development dependency updates in the changelog
161
- continue ;
162
- }
163
-
164
232
// Format PR numbers so the writer can create correct urls
165
233
const finalPrs =
166
234
prs . length > 0 ? ` (${ prs . map ( ( it ) => `#${ it } ` ) . join ( ", " ) } )` : "" ;
@@ -201,7 +269,7 @@ function decorateCommits(commits) {
201
269
// build(deps): bump @types/node from 14.6.2 to 14.6.3
202
270
// build(deps-dev): bump react-query from 2.12.1 to 2.13.0 (#234)
203
271
const depsCommitMatch = commit . title . match (
204
- / ^ b u i l d \( ( d e p s | d e p s - d e v ) \) : b u m p ( [ \w \- @ / ] + ) f r o m ( \d + \. \d + \. \d + ) t o ( \d + \. \d + \. \d + ) / i,
272
+ / ^ b u i l d \( ( d e p s ) \) : b u m p ( [ \w \- @ / ] + ) f r o m ( \d + \. \d + \. \d + ) t o ( \d + \. \d + \. \d + ) / i,
205
273
) ;
206
274
207
275
// depsCommitMatch[3] is the first mentioned version, if that one exists, we also
@@ -429,7 +497,11 @@ function formatHash(commit) {
429
497
* @returns {string }
430
498
*/
431
499
function proposeVersionBump ( version , commits ) {
432
- const hasBreakingChanges = commits . find ( ( it ) => it . breakingChange ) ;
500
+ const hasBreakingChanges = commits . find (
501
+ ( it ) =>
502
+ it . breakingChange ||
503
+ it . notes . find ( ( note ) => note === "- Major version bump" ) ,
504
+ ) ;
433
505
const hasFeat = commits . find ( ( it ) => it . title . startsWith ( "feat" ) ) ;
434
506
435
507
const type = hasBreakingChanges ? "major" : hasFeat ? "minor" : "patch" ;
0 commit comments