Skip to content

Commit e32d8ae

Browse files
fviernausschuberth
authored andcommitted
feat(node): Support virtual dependencies with Yarn2
Use the `--virtuals` option with `yarn info` to make the returned list of `PackageInfo`'s include also the virtual dependencies. Enhance the functional test to cover this case which runs into `NoSuchElementException` at [1] when `--virtuals` is not provided. Note: This commit originally intended to fix [2]. The functional test shows that it works for Yarn version 3.2.1 and experiments on a development machine have shown that it also works after migrating that `project-with-lockfile` to Yarn version 4.0.2 which is the version [2] targets. However, the new behavior has not yet been verified with using Corepack to bootstrap Yarn, which is the setup of [2], which is why the issue is left open. [1]: https://github.com/oss-review-toolkit/ort/blob/2a31f79c600b9f0429ae23755149c32fd939526b/plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt#L136 [2]: #8058 Signed-off-by: Frank Viernau <[email protected]>
1 parent db7473e commit e32d8ae

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed

plugins/package-managers/node/src/funTest/assets/projects/synthetic/yarn2/project-with-lockfile-expected-output.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ project:
7676
- id: "NPM::promise:7.3.1"
7777
dependencies:
7878
- id: "NPM::asap:2.0.6"
79+
- id: "NPM:@react-native-community:netinfo:11.2.1"
7980
- name: "devDependencies"
8081
dependencies:
8182
- id: "NPM::cson:4.1.0"
@@ -1265,6 +1266,36 @@ packages:
12651266
url: "https://github.com/TooTallNate/util-deprecate.git"
12661267
revision: "475fb6857cd23fafff20c1be846c1350abf8e6d4"
12671268
path: ""
1269+
- id: "NPM:@react-native-community:netinfo:11.2.1"
1270+
purl: "pkg:npm/%40react-native-community/[email protected]"
1271+
authors:
1272+
- "Matt Oakes"
1273+
declared_licenses:
1274+
- "MIT"
1275+
declared_licenses_processed:
1276+
spdx_expression: "MIT"
1277+
description: "React Native Network Info API for iOS & Android"
1278+
homepage_url: "https://github.com/react-native-netinfo/react-native-netinfo#readme"
1279+
binary_artifact:
1280+
url: ""
1281+
hash:
1282+
value: ""
1283+
algorithm: ""
1284+
source_artifact:
1285+
url: "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-11.2.1.tgz"
1286+
hash:
1287+
value: "177f5409f2ac41fd51ede6e4994307bb0edb2178"
1288+
algorithm: "SHA-1"
1289+
vcs:
1290+
type: "Git"
1291+
url: "https://github.com/react-native-netinfo/react-native-netinfo.git"
1292+
revision: "736138c36eeebb0a320f8eccd263f909855f5c75"
1293+
path: ""
1294+
vcs_processed:
1295+
type: "Git"
1296+
url: "https://github.com/react-native-netinfo/react-native-netinfo.git"
1297+
revision: "736138c36eeebb0a320f8eccd263f909855f5c75"
1298+
path: ""
12681299
- id: "NPM:@types:node:22.9.0"
12691300
purl: "pkg:npm/%40types/[email protected]"
12701301
declared_licenses:

plugins/package-managers/node/src/funTest/assets/projects/synthetic/yarn2/project-with-lockfile-skip-excluded-scopes-expected-output.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ project:
7676
- id: "NPM::promise:7.3.1"
7777
dependencies:
7878
- id: "NPM::asap:2.0.6"
79+
- id: "NPM:@react-native-community:netinfo:11.2.1"
7980
packages:
8081
- id: "NPM::asap:2.0.6"
8182
purl: "pkg:npm/[email protected]"
@@ -850,6 +851,36 @@ packages:
850851
url: "https://github.com/TooTallNate/util-deprecate.git"
851852
revision: "475fb6857cd23fafff20c1be846c1350abf8e6d4"
852853
path: ""
854+
- id: "NPM:@react-native-community:netinfo:11.2.1"
855+
purl: "pkg:npm/%40react-native-community/[email protected]"
856+
authors:
857+
- "Matt Oakes"
858+
declared_licenses:
859+
- "MIT"
860+
declared_licenses_processed:
861+
spdx_expression: "MIT"
862+
description: "React Native Network Info API for iOS & Android"
863+
homepage_url: "https://github.com/react-native-netinfo/react-native-netinfo#readme"
864+
binary_artifact:
865+
url: ""
866+
hash:
867+
value: ""
868+
algorithm: ""
869+
source_artifact:
870+
url: "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-11.2.1.tgz"
871+
hash:
872+
value: "177f5409f2ac41fd51ede6e4994307bb0edb2178"
873+
algorithm: "SHA-1"
874+
vcs:
875+
type: "Git"
876+
url: "https://github.com/react-native-netinfo/react-native-netinfo.git"
877+
revision: "736138c36eeebb0a320f8eccd263f909855f5c75"
878+
path: ""
879+
vcs_processed:
880+
type: "Git"
881+
url: "https://github.com/react-native-netinfo/react-native-netinfo.git"
882+
revision: "736138c36eeebb0a320f8eccd263f909855f5c75"
883+
path: ""
853884
- id: "NPM:@types:node:22.9.0"
854885
purl: "pkg:npm/%40types/[email protected]"
855886
declared_licenses:

plugins/package-managers/node/src/funTest/assets/projects/synthetic/yarn2/project-with-lockfile/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"author": "The Author <[email protected]> (https://www.the.author.example/index.html)",
1111
"private": true,
1212
"dependencies": {
13+
"@react-native-community/netinfo": "11.2.1",
1314
"cheerio": "1.0.0-rc.1",
1415
"long": "^3.2.0"
1516
},

plugins/package-managers/node/src/funTest/assets/projects/synthetic/yarn2/project-with-lockfile/yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ __metadata:
55
version: 6
66
cacheKey: 8
77

8+
"@react-native-community/netinfo@npm:11.2.1":
9+
version: 11.2.1
10+
resolution: "@react-native-community/netinfo@npm:11.2.1"
11+
peerDependencies:
12+
react-native: ">=0.59"
13+
checksum: d54b75c6dc6d7a8cbb054d84ed9326e1715259137e333f26cd801c6b820996cacceb5a1cf3ee94b91866361c040b7a12eb78db3695b076e8f30c3403985f98d5
14+
languageName: node
15+
linkType: hard
16+
817
"@types/node@npm:*":
918
version: 22.9.0
1019
resolution: "@types/node@npm:22.9.0"
@@ -362,6 +371,7 @@ __metadata:
362371
version: 0.0.0-use.local
363372
resolution: "yarn2-package-with-lockfile@workspace:."
364373
dependencies:
374+
"@react-native-community/netinfo": 11.2.1
365375
cheerio: 1.0.0-rc.1
366376
cson: ~4.1.0
367377
long: ^3.2.0

plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class Yarn2(override val descriptor: PluginDescriptor = Yarn2Factory.descriptor,
157157
"--all",
158158
"--recursive",
159159
"--manifest",
160+
"--virtuals",
160161
"--json",
161162
workingDir = workingDir,
162163
environment = mapOf("YARN_NODE_LINKER" to "pnp")

0 commit comments

Comments
 (0)