Skip to content

Commit ea0b07d

Browse files
lukekarryswraithgar
authored andcommitted
1 parent 8d161a4 commit ea0b07d

File tree

16 files changed

+70
-76
lines changed

16 files changed

+70
-76
lines changed

mock-registry/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"json-stringify-safe": "^5.0.1",
5252
"nock": "^13.3.3",
5353
"npm-package-arg": "^11.0.2",
54-
"pacote": "^18.0.5",
54+
"pacote": "^18.0.6",
5555
"tap": "^16.3.8"
5656
}
5757
}

node_modules/pacote/lib/dir.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const Fetcher = require('./fetcher.js')
2-
const FileFetcher = require('./file.js')
3-
const { Minipass } = require('minipass')
4-
const tarCreateOptions = require('./util/tar-create-options.js')
1+
const { resolve } = require('node:path')
52
const packlist = require('npm-packlist')
6-
const tar = require('tar')
7-
const { resolve } = require('path')
83
const runScript = require('@npmcli/run-script')
4+
const tar = require('tar')
5+
const { Minipass } = require('minipass')
6+
const Fetcher = require('./fetcher.js')
7+
const FileFetcher = require('./file.js')
98
const _ = require('./util/protected.js')
9+
const tarCreateOptions = require('./util/tar-create-options.js')
1010

1111
class DirFetcher extends Fetcher {
1212
constructor (spec, opts) {
@@ -27,7 +27,7 @@ class DirFetcher extends Fetcher {
2727
return ['directory']
2828
}
2929

30-
[_.prepareDir] () {
30+
#prepareDir () {
3131
return this.manifest().then(mani => {
3232
if (!mani.scripts || !mani.scripts.prepare) {
3333
return
@@ -65,7 +65,7 @@ class DirFetcher extends Fetcher {
6565

6666
// run the prepare script, get the list of files, and tar it up
6767
// pipe to the stream, and proxy errors the chain.
68-
this[_.prepareDir]()
68+
this.#prepareDir()
6969
.then(async () => {
7070
if (!this.tree) {
7171
const arb = new this.Arborist({ path: this.resolved })

node_modules/pacote/lib/fetcher.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
// It handles the unpacking and retry logic that is shared among
44
// all of the other Fetcher types.
55

6+
const { basename, dirname } = require('node:path')
7+
const { rm, mkdir } = require('node:fs/promises')
8+
const PackageJson = require('@npmcli/package-json')
9+
const cacache = require('cacache')
10+
const fsm = require('fs-minipass')
11+
const getContents = require('@npmcli/installed-package-contents')
612
const npa = require('npm-package-arg')
13+
const retry = require('promise-retry')
714
const ssri = require('ssri')
8-
const { basename, dirname } = require('path')
915
const tar = require('tar')
16+
const { Minipass } = require('minipass')
1017
const { log } = require('proc-log')
11-
const retry = require('promise-retry')
12-
const fs = require('fs/promises')
13-
const fsm = require('fs-minipass')
14-
const cacache = require('cacache')
18+
const _ = require('./util/protected.js')
19+
const cacheDir = require('./util/cache-dir.js')
1520
const isPackageBin = require('./util/is-package-bin.js')
1621
const removeTrailingSlashes = require('./util/trailing-slashes.js')
17-
const getContents = require('@npmcli/installed-package-contents')
18-
const PackageJson = require('@npmcli/package-json')
19-
const { Minipass } = require('minipass')
20-
const cacheDir = require('./util/cache-dir.js')
21-
const _ = require('./util/protected.js')
2222

2323
// Pacote is only concerned with the package.json contents
2424
const packageJsonPrepare = (p) => PackageJson.prepare(p).then(pkg => pkg.content)
@@ -337,12 +337,12 @@ class FetcherBase {
337337

338338
#empty (path) {
339339
return getContents({ path, depth: 1 }).then(contents => Promise.all(
340-
contents.map(entry => fs.rm(entry, { recursive: true, force: true }))))
340+
contents.map(entry => rm(entry, { recursive: true, force: true }))))
341341
}
342342

343343
async #mkdir (dest) {
344344
await this.#empty(dest)
345-
return await fs.mkdir(dest, { recursive: true })
345+
return await mkdir(dest, { recursive: true })
346346
}
347347

348348
// extraction is always the same. the only difference is where
@@ -369,7 +369,7 @@ class FetcherBase {
369369
// don't use this.#mkdir because we don't want to rimraf anything
370370
async tarballFile (dest) {
371371
const dir = dirname(dest)
372-
await fs.mkdir(dir, { recursive: true })
372+
await mkdir(dir, { recursive: true })
373373
return this.#toFile(dest)
374374
}
375375

node_modules/pacote/lib/file.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const fsm = require('fs-minipass')
1+
const { resolve } = require('node:path')
2+
const { stat, chmod } = require('node:fs/promises')
23
const cacache = require('cacache')
3-
const { resolve } = require('path')
4-
const { stat, chmod } = require('fs/promises')
4+
const fsm = require('fs-minipass')
55
const Fetcher = require('./fetcher.js')
66
const _ = require('./util/protected.js')
77

node_modules/pacote/lib/git.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
const Fetcher = require('./fetcher.js')
2-
const FileFetcher = require('./file.js')
3-
const RemoteFetcher = require('./remote.js')
4-
const DirFetcher = require('./dir.js')
1+
const cacache = require('cacache')
52
const git = require('@npmcli/git')
6-
const pickManifest = require('npm-pick-manifest')
73
const npa = require('npm-package-arg')
4+
const pickManifest = require('npm-pick-manifest')
85
const { Minipass } = require('minipass')
9-
const cacache = require('cacache')
106
const { log } = require('proc-log')
11-
const npm = require('./util/npm.js')
12-
const addGitSha = require('./util/add-git-sha.js')
7+
const DirFetcher = require('./dir.js')
8+
const Fetcher = require('./fetcher.js')
9+
const FileFetcher = require('./file.js')
10+
const RemoteFetcher = require('./remote.js')
1311
const _ = require('./util/protected.js')
12+
const addGitSha = require('./util/add-git-sha.js')
13+
const npm = require('./util/npm.js')
1414

1515
const hashre = /^[a-f0-9]{40}$/
1616

node_modules/pacote/lib/registry.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const Fetcher = require('./fetcher.js')
2-
const RemoteFetcher = require('./remote.js')
3-
const pacoteVersion = require('../package.json').version
4-
const removeTrailingSlashes = require('./util/trailing-slashes.js')
1+
const crypto = require('node:crypto')
52
const PackageJson = require('@npmcli/package-json')
63
const pickManifest = require('npm-pick-manifest')
74
const ssri = require('ssri')
8-
const crypto = require('crypto')
95
const npa = require('npm-package-arg')
106
const sigstore = require('sigstore')
117
const fetch = require('npm-registry-fetch')
8+
const Fetcher = require('./fetcher.js')
9+
const RemoteFetcher = require('./remote.js')
10+
const pacoteVersion = require('../package.json').version
11+
const removeTrailingSlashes = require('./util/trailing-slashes.js')
1212
const _ = require('./util/protected.js')
1313

1414
// Corgis are cute. 🐕🐶
@@ -20,6 +20,7 @@ const fullDoc = 'application/json'
2020
const MISSING_TIME_CUTOFF = '2015-01-01T00:00:00.000Z'
2121

2222
class RegistryFetcher extends Fetcher {
23+
#cacheKey
2324
constructor (spec, opts) {
2425
super(spec, opts)
2526

@@ -32,8 +33,8 @@ class RegistryFetcher extends Fetcher {
3233
this.packumentCache = this.opts.packumentCache || null
3334

3435
this.registry = fetch.pickRegistry(spec, opts)
35-
this.packumentUrl = removeTrailingSlashes(this.registry) + '/' +
36-
this.spec.escapedName
36+
this.packumentUrl = `${removeTrailingSlashes(this.registry)}/${this.spec.escapedName}`
37+
this.#cacheKey = `${this.fullMetadata ? 'full' : 'corgi'}:${this.packumentUrl}`
3738

3839
const parsed = new URL(this.registry)
3940
const regKey = `//${parsed.host}${parsed.pathname}`
@@ -78,8 +79,8 @@ class RegistryFetcher extends Fetcher {
7879
// note this might be either an in-flight promise for a request,
7980
// or the actual packument, but we never want to make more than
8081
// one request at a time for the same thing regardless.
81-
if (this.packumentCache?.has(this.packumentUrl)) {
82-
return this.packumentCache.get(this.packumentUrl)
82+
if (this.packumentCache?.has(this.#cacheKey)) {
83+
return this.packumentCache.get(this.#cacheKey)
8384
}
8485

8586
// npm-registry-fetch the packument
@@ -99,10 +100,10 @@ class RegistryFetcher extends Fetcher {
99100
if (contentLength) {
100101
packument._contentLength = Number(contentLength)
101102
}
102-
this.packumentCache?.set(this.packumentUrl, packument)
103+
this.packumentCache?.set(this.#cacheKey, packument)
103104
return packument
104105
} catch (err) {
105-
this.packumentCache?.delete(this.packumentUrl)
106+
this.packumentCache?.delete(this.#cacheKey)
106107
if (err.code !== 'E404' || this.fullMetadata) {
107108
throw err
108109
}

node_modules/pacote/lib/remote.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const Fetcher = require('./fetcher.js')
2-
const FileFetcher = require('./file.js')
3-
const pacoteVersion = require('../package.json').version
41
const fetch = require('npm-registry-fetch')
52
const { Minipass } = require('minipass')
3+
const Fetcher = require('./fetcher.js')
4+
const FileFetcher = require('./file.js')
65
const _ = require('./util/protected.js')
6+
const pacoteVersion = require('../package.json').version
77

88
class RemoteFetcher extends Fetcher {
99
constructor (spec, opts) {

node_modules/pacote/lib/util/cache-dir.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const os = require('os')
2-
const { resolve } = require('path')
1+
const { resolve } = require('node:path')
2+
const { tmpdir, homedir } = require('node:os')
33

44
module.exports = (fakePlatform = false) => {
5-
const temp = os.tmpdir()
5+
const temp = tmpdir()
66
const uidOrPid = process.getuid ? process.getuid() : process.pid
7-
const home = os.homedir() || resolve(temp, 'npm-' + uidOrPid)
7+
const home = homedir() || resolve(temp, 'npm-' + uidOrPid)
88
const platform = fakePlatform || process.platform
99
const cacheExtra = platform === 'win32' ? 'npm-cache' : '.npm'
1010
const cacheRoot = (platform === 'win32' && process.env.LOCALAPPDATA) || home
+3-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
const readPackageJson = Symbol.for('package.Fetcher._readPackageJson')
2-
const prepareDir = Symbol('_prepareDir')
3-
const tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
4-
const cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches')
5-
61
module.exports = {
7-
readPackageJson,
8-
prepareDir,
9-
tarballFromResolved,
10-
cacheFetches,
2+
cacheFetches: Symbol.for('pacote.Fetcher._cacheFetches'),
3+
readPackageJson: Symbol.for('package.Fetcher._readPackageJson'),
4+
tarballFromResolved: Symbol.for('pacote.Fetcher._tarballFromResolved'),
115
}

node_modules/pacote/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pacote",
3-
"version": "18.0.5",
3+
"version": "18.0.6",
44
"description": "JavaScript package downloader",
55
"author": "GitHub Inc.",
66
"bin": {

package-lock.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"npm-registry-fetch": "^17.0.1",
139139
"npm-user-validate": "^2.0.1",
140140
"p-map": "^4.0.0",
141-
"pacote": "^18.0.5",
141+
"pacote": "^18.0.6",
142142
"parse-conflict-json": "^3.0.1",
143143
"proc-log": "^4.2.0",
144144
"qrcode-terminal": "^0.12.0",
@@ -234,7 +234,7 @@
234234
"json-stringify-safe": "^5.0.1",
235235
"nock": "^13.3.3",
236236
"npm-package-arg": "^11.0.2",
237-
"pacote": "^18.0.5",
237+
"pacote": "^18.0.6",
238238
"tap": "^16.3.8"
239239
},
240240
"engines": {
@@ -9452,11 +9452,10 @@
94529452
}
94539453
},
94549454
"node_modules/pacote": {
9455-
"version": "18.0.5",
9456-
"resolved": "https://registry.npmjs.org/pacote/-/pacote-18.0.5.tgz",
9457-
"integrity": "sha512-AtbhPJE1gFPFdIb04spfX0UprUL0xK2eOBVVQnDNbLg7/VPrK/NkqgZRv7fkPPMM/zxZukjCkuGh+tZh7arrwQ==",
9455+
"version": "18.0.6",
9456+
"resolved": "https://registry.npmjs.org/pacote/-/pacote-18.0.6.tgz",
9457+
"integrity": "sha512-+eK3G27SMwsB8kLIuj4h1FUhHtwiEUo21Tw8wNjmvdlpOEr613edv+8FUsTj/4F/VN5ywGE19X18N7CC2EJk6A==",
94589458
"inBundle": true,
9459-
"license": "ISC",
94609459
"dependencies": {
94619460
"@npmcli/git": "^5.0.0",
94629461
"@npmcli/installed-package-contents": "^2.0.1",
@@ -14793,7 +14792,7 @@
1479314792
"npm-package-arg": "^11.0.2",
1479414793
"npm-pick-manifest": "^9.0.1",
1479514794
"npm-registry-fetch": "^17.0.1",
14796-
"pacote": "^18.0.5",
14795+
"pacote": "^18.0.6",
1479714796
"parse-conflict-json": "^3.0.0",
1479814797
"proc-log": "^4.2.0",
1479914798
"proggy": "^2.0.0",
@@ -14874,7 +14873,7 @@
1487414873
"diff": "^5.1.0",
1487514874
"minimatch": "^9.0.4",
1487614875
"npm-package-arg": "^11.0.2",
14877-
"pacote": "^18.0.5",
14876+
"pacote": "^18.0.6",
1487814877
"tar": "^6.2.1"
1487914878
},
1488014879
"devDependencies": {
@@ -14894,7 +14893,7 @@
1489414893
"@npmcli/run-script": "^8.1.0",
1489514894
"ci-info": "^4.0.0",
1489614895
"npm-package-arg": "^11.0.2",
14897-
"pacote": "^18.0.5",
14896+
"pacote": "^18.0.6",
1489814897
"proc-log": "^4.2.0",
1489914898
"read": "^3.0.1",
1490014899
"read-package-json-fast": "^3.0.2",
@@ -14972,7 +14971,7 @@
1497214971
"@npmcli/arborist": "^7.2.1",
1497314972
"@npmcli/run-script": "^8.1.0",
1497414973
"npm-package-arg": "^11.0.2",
14975-
"pacote": "^18.0.5"
14974+
"pacote": "^18.0.6"
1497614975
},
1497714976
"devDependencies": {
1497814977
"@npmcli/eslint-config": "^4.0.0",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"npm-registry-fetch": "^17.0.1",
104104
"npm-user-validate": "^2.0.1",
105105
"p-map": "^4.0.0",
106-
"pacote": "^18.0.5",
106+
"pacote": "^18.0.6",
107107
"parse-conflict-json": "^3.0.1",
108108
"proc-log": "^4.2.0",
109109
"qrcode-terminal": "^0.12.0",

workspaces/arborist/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"npm-package-arg": "^11.0.2",
2828
"npm-pick-manifest": "^9.0.1",
2929
"npm-registry-fetch": "^17.0.1",
30-
"pacote": "^18.0.5",
30+
"pacote": "^18.0.6",
3131
"parse-conflict-json": "^3.0.0",
3232
"proc-log": "^4.2.0",
3333
"proggy": "^2.0.0",

workspaces/libnpmdiff/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"diff": "^5.1.0",
5353
"minimatch": "^9.0.4",
5454
"npm-package-arg": "^11.0.2",
55-
"pacote": "^18.0.5",
55+
"pacote": "^18.0.6",
5656
"tar": "^6.2.1"
5757
},
5858
"templateOSS": {

workspaces/libnpmexec/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@npmcli/run-script": "^8.1.0",
6464
"ci-info": "^4.0.0",
6565
"npm-package-arg": "^11.0.2",
66-
"pacote": "^18.0.5",
66+
"pacote": "^18.0.6",
6767
"proc-log": "^4.2.0",
6868
"read": "^3.0.1",
6969
"read-package-json-fast": "^3.0.2",

workspaces/libnpmpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@npmcli/arborist": "^7.2.1",
4040
"@npmcli/run-script": "^8.1.0",
4141
"npm-package-arg": "^11.0.2",
42-
"pacote": "^18.0.5"
42+
"pacote": "^18.0.6"
4343
},
4444
"engines": {
4545
"node": "^16.14.0 || >=18.0.0"

0 commit comments

Comments
 (0)