Skip to content

Commit bfb8bcc

Browse files
fritzyeverett1992
andauthored
feat: add flag --omit-lockfile-registry-resolved (#4874)
* feat(arborist): added flag to omit lockfile resolved * feat: add flag --omit-lockfile-registry-resolved Co-authored-by: Caleb ツ Everett <calebev@amazon.com>
1 parent c024e90 commit bfb8bcc

File tree

13 files changed

+216
-7
lines changed

13 files changed

+216
-7
lines changed

docs/content/using-npm/config.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,19 @@ variable will be set to `'production'` for all lifecycle scripts.
11781178
<!-- automatically generated, do not edit manually -->
11791179
<!-- see lib/utils/config/definitions.js -->
11801180

1181+
#### `omit-lockfile-registry-resolved`
1182+
1183+
* Default: false
1184+
* Type: Boolean
1185+
1186+
This option causes npm to create lock files without a `resolved` key for
1187+
registry dependencies. Subsequent installs will need to resolve tarball
1188+
endpoints with the configured registry, likely resulting in a longer install
1189+
time.
1190+
1191+
<!-- automatically generated, do not edit manually -->
1192+
<!-- see lib/utils/config/definitions.js -->
1193+
11811194
#### `otp`
11821195

11831196
* Default: null

lib/utils/config/definitions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,18 @@ define('omit', {
13851385
},
13861386
})
13871387

1388+
define('omit-lockfile-registry-resolved', {
1389+
default: false,
1390+
type: Boolean,
1391+
description: `
1392+
This option causes npm to create lock files without a \`resolved\` key for
1393+
registry dependencies. Subsequent installs will need to resolve tarball
1394+
endpoints with the configured registry, likely resulting in a longer install
1395+
time.
1396+
`,
1397+
flatten,
1398+
})
1399+
13881400
define('only', {
13891401
default: null,
13901402
type: [null, 'prod', 'production'],

tap-snapshots/test/lib/commands/config.js.test.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
103103
"npm-version": "{NPM-VERSION}",
104104
"offline": false,
105105
"omit": [],
106+
"omit-lockfile-registry-resolved": false,
106107
"only": null,
107108
"optional": null,
108109
"otp": null,
@@ -257,6 +258,7 @@ noproxy = [""]
257258
npm-version = "{NPM-VERSION}"
258259
offline = false
259260
omit = []
261+
omit-lockfile-registry-resolved = false
260262
only = null
261263
optional = null
262264
otp = null

tap-snapshots/test/lib/utils/config/definitions.js.test.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Array [
9797
"npm-version",
9898
"offline",
9999
"omit",
100+
"omit-lockfile-registry-resolved",
100101
"only",
101102
"optional",
102103
"otp",
@@ -1239,6 +1240,18 @@ If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\` environment
12391240
variable will be set to \`'production'\` for all lifecycle scripts.
12401241
`
12411242

1243+
exports[`test/lib/utils/config/definitions.js TAP > config description for omit-lockfile-registry-resolved 1`] = `
1244+
#### \`omit-lockfile-registry-resolved\`
1245+
1246+
* Default: false
1247+
* Type: Boolean
1248+
1249+
This option causes npm to create lock files without a \`resolved\` key for
1250+
registry dependencies. Subsequent installs will need to resolve tarball
1251+
endpoints with the configured registry, likely resulting in a longer install
1252+
time.
1253+
`
1254+
12421255
exports[`test/lib/utils/config/definitions.js TAP > config description for only 1`] = `
12431256
#### \`only\`
12441257

tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,19 @@ variable will be set to \`'production'\` for all lifecycle scripts.
10511051
<!-- automatically generated, do not edit manually -->
10521052
<!-- see lib/utils/config/definitions.js -->
10531053
1054+
#### \`omit-lockfile-registry-resolved\`
1055+
1056+
* Default: false
1057+
* Type: Boolean
1058+
1059+
This option causes npm to create lock files without a \`resolved\` key for
1060+
registry dependencies. Subsequent installs will need to resolve tarball
1061+
endpoints with the configured registry, likely resulting in a longer install
1062+
time.
1063+
1064+
<!-- automatically generated, do not edit manually -->
1065+
<!-- see lib/utils/config/definitions.js -->
1066+
10541067
#### \`otp\`
10551068
10561069
* Default: null

workspaces/arborist/lib/arborist/build-ideal-tree.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Try using the package name instead, e.g:
329329
? Shrinkwrap.reset({
330330
path: this.path,
331331
lockfileVersion: this.options.lockfileVersion,
332+
resolveOptions: this.options,
332333
}).then(meta => Object.assign(root, { meta }))
333334
: this.loadVirtual({ root }))
334335

@@ -388,6 +389,7 @@ Try using the package name instead, e.g:
388389
const meta = new Shrinkwrap({
389390
path: this.path,
390391
lockfileVersion: this.options.lockfileVersion,
392+
resolveOptions: this.options,
391393
})
392394
meta.reset()
393395
root.meta = meta

workspaces/arborist/lib/arborist/load-actual.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ module.exports = cls => class ActualLoader extends cls {
147147
const meta = await Shrinkwrap.load({
148148
path: this[_actualTree].path,
149149
hiddenLockfile: true,
150+
resolveOptions: this.options,
150151
})
151152
if (meta.loadedFromDisk) {
152153
this[_actualTree].meta = meta
@@ -155,6 +156,7 @@ module.exports = cls => class ActualLoader extends cls {
155156
const meta = await Shrinkwrap.load({
156157
path: this[_actualTree].path,
157158
lockfileVersion: this.options.lockfileVersion,
159+
resolveOptions: this.options,
158160
})
159161
this[_actualTree].meta = meta
160162
return this[_loadActualActually]({ root, ignoreMissing })

workspaces/arborist/lib/arborist/load-virtual.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module.exports = cls => class VirtualLoader extends cls {
5757
const s = await Shrinkwrap.load({
5858
path: this.path,
5959
lockfileVersion: this.options.lockfileVersion,
60+
resolveOptions: this.options,
6061
})
6162
if (!s.loadedFromDisk && !options.root) {
6263
const er = new Error('loadVirtual requires existing shrinkwrap file')

workspaces/arborist/lib/node.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,18 @@ class Node {
524524
return this === this.root || this === this.root.target
525525
}
526526

527+
get isRegistryDependency () {
528+
if (this.edgesIn.size === 0) {
529+
return false
530+
}
531+
for (const edge of this.edgesIn) {
532+
if (!npa(edge.spec).registry) {
533+
return false
534+
}
535+
}
536+
return true
537+
}
538+
527539
* ancestry () {
528540
for (let anc = this; anc; anc = anc.resolveParent) {
529541
yield anc
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function overrideResolves (resolved, opts = {}) {
2+
const { omitLockfileRegistryResolved = false } = opts
3+
4+
if (omitLockfileRegistryResolved) {
5+
return undefined
6+
}
7+
8+
return resolved
9+
}
10+
11+
module.exports = { overrideResolves }

0 commit comments

Comments
 (0)