Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache manifests not promises #7494

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tap-snapshots/test/lib/commands/config.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
exports[`test/lib/commands/config.js TAP config list --json > output matches snapshot 1`] = `
{
"cache": "{CACHE}",
"color": {COLOR},
"json": true,
"projectloaded": "yes",
"userloaded": "yes",
Expand All @@ -29,7 +30,6 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"call": "",
"cert": null,
"cidr": null,
"color": {COLOR},
"commit-hooks": true,
"cpu": null,
"depth": null,
Expand Down Expand Up @@ -192,7 +192,7 @@ cafile = null
call = ""
cert = null
cidr = null
color = {COLOR}
; color = {COLOR}
commit-hooks = true
cpu = null
depth = null
Expand Down Expand Up @@ -345,6 +345,7 @@ projectloaded = "yes"
; "cli" config from command line options

cache = "{CACHE}"
color = {COLOR}
long = true
`

Expand All @@ -364,6 +365,7 @@ projectloaded = "yes"
; "cli" config from command line options

cache = "{CACHE}"
color = {COLOR}

; node bin location = {NODE-BIN-LOCATION}
; node version = {NODE-VERSION}
Expand All @@ -378,6 +380,7 @@ exports[`test/lib/commands/config.js TAP config list with publishConfig global >
; "cli" config from command line options

cache = "{CACHE}"
color = {COLOR}
global = true

; node bin location = {NODE-BIN-LOCATION}
Expand All @@ -393,6 +396,7 @@ exports[`test/lib/commands/config.js TAP config list with publishConfig local >
; "cli" config from command line options

cache = "{CACHE}"
color = {COLOR}

; node bin location = {NODE-BIN-LOCATION}
; node version = {NODE-VERSION}
Expand Down
1 change: 1 addition & 0 deletions test/lib/cli/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ t.test('do no fancy handling for shellouts', async t => {
argv: ['-c', 'exit'],
config: {
timing: false,
progress: false,
...opts.config,
},
...opts,
Expand Down
2 changes: 1 addition & 1 deletion test/lib/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const loadMockNpm = (t, opts = {}) => _loadMockNpm(t, {
// Reset configs that mock npm sets by default
'fetch-retries': undefined,
loglevel: undefined,
color: undefined,
color: false,
},
})

Expand Down
5 changes: 4 additions & 1 deletion test/lib/commands/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ t.test('should log scoped package output as valid json', async t => {
},
}),
},
config: { json: true },
config: {
json: true,
progress: false,
},
})
await npm.exec('pack', [])
const filename = 'myscope-test-package-1.0.0.tgz'
Expand Down
22 changes: 9 additions & 13 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,10 @@ This is a one-time fix-up, please be patient...
// may well be an optional dep that has gone missing. it'll
// fail later anyway.
for (const e of this.#problemEdges(placed)) {
// XXX This is somehow load bearing. This makes tests that print
// the ideal tree of a tree with tarball dependencies fail. This
// can't be changed or removed till we figure out why
// The test is named "tarball deps with transitive tarball deps"
promises.push(() =>
this.#fetchManifest(npa.resolve(e.name, e.spec, fromPath(placed, e)))
.catch(() => null)
Expand Down Expand Up @@ -1204,6 +1208,7 @@ This is a one-time fix-up, please be patient...
const options = {
...this.options,
avoid: this.#avoidRange(spec.name),
fullMetadata: true,
}
// get the intended spec and stored metadata from yarn.lock file,
// if available and valid.
Expand All @@ -1212,19 +1217,10 @@ This is a one-time fix-up, please be patient...
if (this.#manifests.has(spec.raw)) {
return this.#manifests.get(spec.raw)
} else {
const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
fullMetadata: true,
}
const p = pacote.manifest(spec, o)
.then((mani) => {
this.#manifests.set(spec.raw, mani)
return mani
})
this.#manifests.set(spec.raw, p)
return p
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, redact(spec.rawSpec)))
const mani = await pacote.manifest(spec, options)
this.#manifests.set(spec.raw, mani)
return mani
}
}

Expand Down
Loading