@@ -44,7 +44,18 @@ let monopackages = new Set([
44
44
class VersionManager {
45
45
constructor ( ) {
46
46
// Get dependency tree from yarn workspaces
47
- this . workspacePackages = JSON . parse ( exec ( 'yarn workspaces info --json' ) . toString ( ) . split ( '\n' ) . slice ( 1 , - 2 ) . join ( '\n' ) ) ;
47
+ try {
48
+ // yarn 1.21 returns this structure
49
+ this . workspacePackages = JSON . parse ( JSON . parse ( exec ( 'yarn workspaces info --json' ) . toString ( ) ) . data ) ;
50
+ } catch ( e ) {
51
+ try {
52
+ // Unknown what versions of yarn return this, but it was the original implementation.
53
+ this . workspacePackages = JSON . parse ( exec ( 'yarn workspaces info --json' ) . toString ( ) . split ( '\n' ) . slice ( 1 , - 2 ) . join ( '\n' ) ) ;
54
+ } catch ( e ) {
55
+ // If that failed to parse, then it's because we have yarn 1.22 and this is how we need to parse it.
56
+ this . workspacePackages = JSON . parse ( exec ( 'yarn workspaces info --json' ) . toString ( ) ) ;
57
+ }
58
+ }
48
59
this . existingPackages = new Set ( ) ;
49
60
this . changedPackages = new Set ( ) ;
50
61
this . versionBumps = { } ;
@@ -135,6 +146,7 @@ class VersionManager {
135
146
return ;
136
147
}
137
148
149
+
138
150
// Diff each package individually. Some packages might have been skipped during last release,
139
151
// so we cannot simply look at the last tag on the whole repo.
140
152
for ( let name in this . workspacePackages ) {
@@ -144,7 +156,7 @@ class VersionManager {
144
156
// Diff this package since the last published version, according to the package.json.
145
157
// We create a git tag for each package version.
146
158
let tag = `${ pkg . name } @${ pkg . version } ` ;
147
- let res = spawn ( 'git' , [ 'diff' , '--exit-code' , tag + '..HEAD' , this . workspacePackages [ name ] . location , ':!**/docs/**' , ':!**/test/**' , ':!**/stories/**' , ':!**/chromatic/**' ] ) ;
159
+ let res = spawn ( 'git' , [ 'diff' , '--exit-code' , tag + '..HEAD' , this . workspacePackages [ name ] . location , ':!**/docs/**' , ':!**/test/**' , ':!**/test-utils/**' , ':!**/ stories/**', ':!**/chromatic/**' ] ) ;
148
160
if ( res . status !== 0 ) {
149
161
this . changedPackages . add ( name ) ;
150
162
}
@@ -271,22 +283,23 @@ class VersionManager {
271
283
272
284
// Bump anything that depends on this package if it's a prerelease
273
285
// because dependencies will be pinned rather than caret ranges.
274
- if ( status !== 'released' ) {
275
- for ( let p in this . workspacePackages ) {
276
- if ( this . releasedPackages . has ( p ) ) {
277
- continue ;
278
- }
286
+ // Bump anything that has this as a dep by a patch, all the way up the tree
287
+ for ( let p in this . workspacePackages ) {
288
+ if ( this . releasedPackages . has ( p ) ) {
289
+ continue ;
290
+ }
279
291
280
- if ( this . workspacePackages [ p ] . workspaceDependencies . includes ( pkg ) ) {
281
- if ( this . existingPackages . has ( p ) ) {
282
- // Bump a patch version of the dependent package if it's not also a prerelease.
283
- // Otherwise, bump to the next prerelease in the existing status.
284
- let filePath = this . workspacePackages [ p ] . location + '/package.json' ;
285
- let pkg = JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
286
- let prerelease = semver . parse ( pkg . version ) . prerelease ;
287
- let b = prerelease . length === 0 ? 'patch' : prerelease [ 0 ] ;
288
- this . addReleasedPackage ( p , b , true ) ;
289
- }
292
+ if ( this . workspacePackages [ p ] . workspaceDependencies . includes ( pkg ) ) {
293
+ let filePath = this . workspacePackages [ p ] . location + '/package.json' ;
294
+ let pkg = JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
295
+ let prerelease = semver . parse ( pkg . version ) . prerelease ;
296
+ let b = prerelease . length === 0 ? 'patch' : prerelease [ 0 ] ;
297
+ if ( this . existingPackages . has ( p ) && status !== 'released' ) {
298
+ // Bump a patch version of the dependent package if it's not also a prerelease.
299
+ // Otherwise, bump to the next prerelease in the existing status.
300
+ this . addReleasedPackage ( p , b , true ) ;
301
+ } else if ( this . existingPackages . has ( p ) && status === 'released' ) {
302
+ this . addReleasedPackage ( p , b ) ;
290
303
}
291
304
}
292
305
}
@@ -334,6 +347,8 @@ class VersionManager {
334
347
}
335
348
}
336
349
350
+
351
+
337
352
return versions ;
338
353
}
339
354
0 commit comments