File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export interface MultiProjectOptions {
9
9
inferTsconfig : boolean
10
10
progressBar : boolean
11
11
yarnWorkspaces : boolean
12
+ yarnBerryWorkspaces : boolean
12
13
cwd : string
13
14
output : string
14
15
indexedProjects : Set < string >
@@ -35,6 +36,11 @@ export function mainCommand(
35
36
. command ( 'index' )
36
37
. option ( '--cwd <path>' , 'the working directory' , process . cwd ( ) )
37
38
. option ( '--yarn-workspaces' , 'whether to index all yarn workspaces' , false )
39
+ . option (
40
+ '--yarn-berry-workspaces' ,
41
+ 'whether to index all yarn v3 workspaces' ,
42
+ false
43
+ )
38
44
. option (
39
45
'--infer-tsconfig' ,
40
46
"whether to infer the tsconfig.json file, if it's missing" ,
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ for (const snapshotDirectory of snapshotDirectories) {
51
51
inferTsconfig,
52
52
output,
53
53
yarnWorkspaces : Boolean ( packageJson . workspaces ) ,
54
+ yarnBerryWorkspaces : false ,
54
55
progressBar : false ,
55
56
indexedProjects : new Set ( ) ,
56
57
} )
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ export function indexCommand(
32
32
) : void {
33
33
if ( options . yarnWorkspaces ) {
34
34
projects . push ( ...listYarnWorkspaces ( options . cwd ) )
35
+ } else if ( options . yarnBerryWorkspaces ) {
36
+ projects . push ( ...listYarnBerryWorkspaces ( options . cwd ) )
35
37
} else if ( projects . length === 0 ) {
36
38
projects . push ( options . cwd )
37
39
}
@@ -198,6 +200,28 @@ function defaultCompilerOptions(configFileName?: string): ts.CompilerOptions {
198
200
return options
199
201
}
200
202
203
+ function listYarnBerryWorkspaces ( directory : string ) : string [ ] {
204
+ const result : string [ ] = [ ]
205
+ const lines = child_process
206
+ . execSync ( 'yarn workspaces list --json' , {
207
+ cwd : directory ,
208
+ encoding : 'utf-8' ,
209
+ } )
210
+ . split ( '\n' )
211
+ for ( const line of lines ) {
212
+ if ( ! line ) {
213
+ continue
214
+ }
215
+ const location = 'location'
216
+ const json = JSON . parse ( line )
217
+ if ( json [ location ] !== undefined ) {
218
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
219
+ result. push ( path . join ( directory , json [ location ] ) )
220
+ }
221
+ }
222
+ return result
223
+ }
224
+
201
225
function listYarnWorkspaces ( directory : string ) : string [ ] {
202
226
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
203
227
const json = JSON . parse (
You can’t perform that action at this time.
0 commit comments