Skip to content

Commit a1d375f

Browse files
isaacsruyadorno
authored andcommitted
Add --strict-peer-deps option
This is the CLI portion of npm/arborist#136 PR-URL: #1819 Credit: @isaacs Close: #1819 Reviewed-by: @ruyadorno
1 parent b3a50d2 commit a1d375f

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

docs/content/using-npm/config.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,24 @@ should be polled while the user is completing authentication.
11611161

11621162
If `--auth-type=sso`, the type of SSO type to use.
11631163

1164+
#### strict-peer-deps
1165+
1166+
* Default: false
1167+
* Type: Boolean
1168+
1169+
If set to `true`, and `--legacy-peer-deps` is not set, then _any_
1170+
conflicting `peerDependencies` will be treated as an install failure, even
1171+
if npm could reasonably guess the appropriate resolution based on non-peer
1172+
dependency relationships.
1173+
1174+
By default, conflicting `peerDependencies` in the dependency graph will be
1175+
resolved using the nearest non-peer dependency specification, even if doing
1176+
so will result in some packages receiving a peer dependency outside the
1177+
range set in their package's `peerDependencies` object. When such and
1178+
override is performed, a warning is printed, explaining the conflict and
1179+
the packages involved. If `--strict-peer-deps` is set, then the warning is
1180+
treated as a failure.
1181+
11641182
#### strict-ssl
11651183

11661184
* Default: true

lib/utils/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const defaults = {
111111
key: null,
112112
'legacy-bundling': false,
113113
'legacy-peer-deps': false,
114+
'strict-peer-deps': false,
114115
link: false,
115116
'local-address': undefined,
116117
loglevel: 'notice',
@@ -229,7 +230,6 @@ const types = {
229230
group: [Number, String],
230231
'https-proxy': [null, url],
231232
'user-agent': String,
232-
'ham-it-up': Boolean,
233233
heading: String,
234234
'if-present': Boolean,
235235
include: [Array, 'prod', 'dev', 'optional', 'peer'],
@@ -246,6 +246,7 @@ const types = {
246246
key: [null, String],
247247
'legacy-bundling': Boolean,
248248
'legacy-peer-deps': Boolean,
249+
'strict-peer-deps': Boolean,
249250
link: Boolean,
250251
'local-address': getLocalAddresses(),
251252
loglevel: [

lib/utils/flat-options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
170170
shell: npm.config.get('shell'),
171171
omit: buildOmitList(npm),
172172
legacyPeerDeps: npm.config.get('legacy-peer-deps'),
173+
strictPeerDeps: npm.config.get('strict-peer-deps'),
173174

174175
// npx stuff
175176
call: npm.config.get('call'),

tap-snapshots/test-lib-utils-config.js-TAP.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Object {
117117
"sign-git-tag": false,
118118
"sso-poll-frequency": 500,
119119
"sso-type": "oauth",
120+
"strict-peer-deps": false,
120121
"strict-ssl": true,
121122
"tag": "latest",
122123
"tag-version-prefix": "v",
@@ -347,7 +348,6 @@ Object {
347348
"{Number TYPE}",
348349
"{String TYPE}",
349350
],
350-
"ham-it-up": "{Boolean TYPE}",
351351
"heading": "{String TYPE}",
352352
"https-proxy": Array [
353353
null,
@@ -495,6 +495,7 @@ Object {
495495
"oauth",
496496
"saml",
497497
],
498+
"strict-peer-deps": "{Boolean TYPE}",
498499
"strict-ssl": "{Boolean TYPE}",
499500
"tag": "{String TYPE}",
500501
"tag-version-prefix": "{String TYPE}",
@@ -625,6 +626,7 @@ Object {
625626
"sign-git-tag": false,
626627
"sso-poll-frequency": 500,
627628
"sso-type": "oauth",
629+
"strict-peer-deps": false,
628630
"strict-ssl": true,
629631
"tag": "latest",
630632
"tag-version-prefix": "v",
@@ -855,7 +857,6 @@ Object {
855857
"{Number TYPE}",
856858
"{String TYPE}",
857859
],
858-
"ham-it-up": "{Boolean TYPE}",
859860
"heading": "{String TYPE}",
860861
"https-proxy": Array [
861862
null,
@@ -1003,6 +1004,7 @@ Object {
10031004
"oauth",
10041005
"saml",
10051006
],
1007+
"strict-peer-deps": "{Boolean TYPE}",
10061008
"strict-ssl": "{Boolean TYPE}",
10071009
"tag": "{String TYPE}",
10081010
"tag-version-prefix": "{String TYPE}",
@@ -1133,6 +1135,7 @@ Object {
11331135
"sign-git-tag": false,
11341136
"sso-poll-frequency": 500,
11351137
"sso-type": "oauth",
1138+
"strict-peer-deps": false,
11361139
"strict-ssl": true,
11371140
"tag": "latest",
11381141
"tag-version-prefix": "v",
@@ -1363,7 +1366,6 @@ Object {
13631366
"{Number TYPE}",
13641367
"{String TYPE}",
13651368
],
1366-
"ham-it-up": "{Boolean TYPE}",
13671369
"heading": "{String TYPE}",
13681370
"https-proxy": Array [
13691371
null,
@@ -1513,6 +1515,7 @@ Object {
15131515
"oauth",
15141516
"saml",
15151517
],
1518+
"strict-peer-deps": "{Boolean TYPE}",
15161519
"strict-ssl": "{Boolean TYPE}",
15171520
"tag": "{String TYPE}",
15181521
"tag-version-prefix": "{String TYPE}",

tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Object {
111111
"signGitTag": "sign-git-tag",
112112
"ssoPollFrequency": undefined,
113113
"ssoType": undefined,
114+
"strictPeerDeps": undefined,
114115
"strictSSL": "strict-ssl",
115116
"tag": "tag",
116117
"tagVersionPrefix": "tag-version-prefix",

0 commit comments

Comments
 (0)