Skip to content

Commit a9a6dcd

Browse files
committed
deps: pacote@18.0.5
1 parent e2fdb65 commit a9a6dcd

File tree

17 files changed

+137
-162
lines changed

17 files changed

+137
-162
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.1",
54+
"pacote": "^18.0.5",
5555
"tap": "^16.3.8"
5656
}
5757
}
File renamed without changes.

node_modules/pacote/lib/dir.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ const { Minipass } = require('minipass')
44
const tarCreateOptions = require('./util/tar-create-options.js')
55
const packlist = require('npm-packlist')
66
const tar = require('tar')
7-
const _prepareDir = Symbol('_prepareDir')
87
const { resolve } = require('path')
9-
const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson')
10-
118
const runScript = require('@npmcli/run-script')
9+
const _ = require('./util/protected.js')
1210

13-
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
1411
class DirFetcher extends Fetcher {
1512
constructor (spec, opts) {
1613
super(spec, opts)
@@ -30,7 +27,7 @@ class DirFetcher extends Fetcher {
3027
return ['directory']
3128
}
3229

33-
[_prepareDir] () {
30+
[_.prepareDir] () {
3431
return this.manifest().then(mani => {
3532
if (!mani.scripts || !mani.scripts.prepare) {
3633
return
@@ -55,7 +52,7 @@ class DirFetcher extends Fetcher {
5552
})
5653
}
5754

58-
[_tarballFromResolved] () {
55+
[_.tarballFromResolved] () {
5956
if (!this.tree && !this.Arborist) {
6057
throw new Error('DirFetcher requires either a tree or an Arborist constructor to pack')
6158
}
@@ -68,7 +65,7 @@ class DirFetcher extends Fetcher {
6865

6966
// run the prepare script, get the list of files, and tar it up
7067
// pipe to the stream, and proxy errors the chain.
71-
this[_prepareDir]()
68+
this[_.prepareDir]()
7269
.then(async () => {
7370
if (!this.tree) {
7471
const arb = new this.Arborist({ path: this.resolved })
@@ -87,7 +84,7 @@ class DirFetcher extends Fetcher {
8784
return Promise.resolve(this.package)
8885
}
8986

90-
return this[_readPackageJson](this.resolved)
87+
return this[_.readPackageJson](this.resolved)
9188
.then(mani => this.package = {
9289
...mani,
9390
_integrity: this.integrity && String(this.integrity),

node_modules/pacote/lib/fetcher.js

+26-43
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,12 @@ const getContents = require('@npmcli/installed-package-contents')
1818
const PackageJson = require('@npmcli/package-json')
1919
const { Minipass } = require('minipass')
2020
const cacheDir = require('./util/cache-dir.js')
21+
const _ = require('./util/protected.js')
2122

2223
// Pacote is only concerned with the package.json contents
2324
const packageJsonPrepare = (p) => PackageJson.prepare(p).then(pkg => pkg.content)
2425
const packageJsonNormalize = (p) => PackageJson.normalize(p).then(pkg => pkg.content)
2526

26-
// Private methods.
27-
// Child classes should not have to override these.
28-
// Users should never call them.
29-
const _extract = Symbol('_extract')
30-
const _mkdir = Symbol('_mkdir')
31-
const _empty = Symbol('_empty')
32-
const _toFile = Symbol('_toFile')
33-
const _tarxOptions = Symbol('_tarxOptions')
34-
const _entryMode = Symbol('_entryMode')
35-
const _istream = Symbol('_istream')
36-
const _assertType = Symbol('_assertType')
37-
const _tarballFromCache = Symbol('_tarballFromCache')
38-
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
39-
const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches')
40-
const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson')
41-
4227
class FetcherBase {
4328
constructor (spec, opts) {
4429
if (!opts || typeof opts !== 'object') {
@@ -57,7 +42,7 @@ class FetcherBase {
5742
this.from = this.spec.registry
5843
? `${this.spec.name}@${this.spec.rawSpec}` : this.spec.saveSpec
5944

60-
this[_assertType]()
45+
this.#assertType()
6146
// clone the opts object so that others aren't upset when we mutate it
6247
// by adding/modifying the integrity value.
6348
this.opts = { ...opts }
@@ -93,11 +78,9 @@ class FetcherBase {
9378
this.before = opts.before
9479
this.fullMetadata = this.before ? true : !!opts.fullMetadata
9580
this.fullReadJson = !!opts.fullReadJson
96-
if (this.fullReadJson) {
97-
this[_readPackageJson] = packageJsonPrepare
98-
} else {
99-
this[_readPackageJson] = packageJsonNormalize
100-
}
81+
this[_.readPackageJson] = this.fullReadJson
82+
? packageJsonPrepare
83+
: packageJsonNormalize
10184

10285
// rrh is a registry hostname or 'never' or 'always'
10386
// defaults to registry.npmjs.org
@@ -188,7 +171,7 @@ class FetcherBase {
188171
// private, should be overridden.
189172
// Note that they should *not* calculate or check integrity or cache,
190173
// but *just* return the raw tarball data stream.
191-
[_tarballFromResolved] () {
174+
[_.tarballFromResolved] () {
192175
throw this.notImplementedError
193176
}
194177

@@ -204,17 +187,17 @@ class FetcherBase {
204187

205188
// private
206189
// Note: cacache will raise a EINTEGRITY error if the integrity doesn't match
207-
[_tarballFromCache] () {
190+
#tarballFromCache () {
208191
return cacache.get.stream.byDigest(this.cache, this.integrity, this.opts)
209192
}
210193

211-
get [_cacheFetches] () {
194+
get [_.cacheFetches] () {
212195
return true
213196
}
214197

215-
[_istream] (stream) {
198+
#istream (stream) {
216199
// if not caching this, just return it
217-
if (!this.opts.cache || !this[_cacheFetches]) {
200+
if (!this.opts.cache || !this[_.cacheFetches]) {
218201
// instead of creating a new integrity stream, we only piggyback on the
219202
// provided stream's events
220203
if (stream.hasIntegrityEmitter) {
@@ -267,7 +250,7 @@ class FetcherBase {
267250
return false
268251
}
269252

270-
[_assertType] () {
253+
#assertType () {
271254
if (this.types && !this.types.includes(this.spec.type)) {
272255
throw new TypeError(`Wrong spec type (${
273256
this.spec.type
@@ -306,7 +289,7 @@ class FetcherBase {
306289
!this.preferOnline &&
307290
this.integrity &&
308291
this.resolved
309-
) ? streamHandler(this[_tarballFromCache]()).catch(er => {
292+
) ? streamHandler(this.#tarballFromCache()).catch(er => {
310293
if (this.isDataCorruptionError(er)) {
311294
log.warn('tarball', `cached data for ${
312295
this.spec
@@ -329,7 +312,7 @@ class FetcherBase {
329312
}. Extracting by manifest.`)
330313
}
331314
return this.resolve().then(() => retry(tryAgain =>
332-
streamHandler(this[_istream](this[_tarballFromResolved]()))
315+
streamHandler(this.#istream(this[_.tarballFromResolved]()))
333316
.catch(streamErr => {
334317
// Most likely data integrity. A cache ENOENT error is unlikely
335318
// here, since we're definitely not reading from the cache, but it
@@ -352,24 +335,24 @@ class FetcherBase {
352335
return cacache.rm.content(this.cache, this.integrity, this.opts)
353336
}
354337

355-
[_empty] (path) {
338+
#empty (path) {
356339
return getContents({ path, depth: 1 }).then(contents => Promise.all(
357340
contents.map(entry => fs.rm(entry, { recursive: true, force: true }))))
358341
}
359342

360-
async [_mkdir] (dest) {
361-
await this[_empty](dest)
343+
async #mkdir (dest) {
344+
await this.#empty(dest)
362345
return await fs.mkdir(dest, { recursive: true })
363346
}
364347

365348
// extraction is always the same. the only difference is where
366349
// the tarball comes from.
367350
async extract (dest) {
368-
await this[_mkdir](dest)
369-
return this.tarballStream((tarball) => this[_extract](dest, tarball))
351+
await this.#mkdir(dest)
352+
return this.tarballStream((tarball) => this.#extract(dest, tarball))
370353
}
371354

372-
[_toFile] (dest) {
355+
#toFile (dest) {
373356
return this.tarballStream(str => new Promise((res, rej) => {
374357
const writer = new fsm.WriteStream(dest)
375358
str.on('error', er => writer.emit('error', er))
@@ -383,15 +366,15 @@ class FetcherBase {
383366
}))
384367
}
385368

386-
// don't use this[_mkdir] because we don't want to rimraf anything
369+
// don't use this.#mkdir because we don't want to rimraf anything
387370
async tarballFile (dest) {
388371
const dir = dirname(dest)
389372
await fs.mkdir(dir, { recursive: true })
390-
return this[_toFile](dest)
373+
return this.#toFile(dest)
391374
}
392375

393-
[_extract] (dest, tarball) {
394-
const extractor = tar.x(this[_tarxOptions]({ cwd: dest }))
376+
#extract (dest, tarball) {
377+
const extractor = tar.x(this.#tarxOptions({ cwd: dest }))
395378
const p = new Promise((resolve, reject) => {
396379
extractor.on('end', () => {
397380
resolve({
@@ -416,7 +399,7 @@ class FetcherBase {
416399

417400
// always ensure that entries are at least as permissive as our configured
418401
// dmode/fmode, but never more permissive than the umask allows.
419-
[_entryMode] (path, mode, type) {
402+
#entryMode (path, mode, type) {
420403
const m = /Directory|GNUDumpDir/.test(type) ? this.dmode
421404
: /File$/.test(type) ? this.fmode
422405
: /* istanbul ignore next - should never happen in a pkg */ 0
@@ -427,7 +410,7 @@ class FetcherBase {
427410
return ((mode | m) & ~this.umask) | exe | 0o600
428411
}
429412

430-
[_tarxOptions] ({ cwd }) {
413+
#tarxOptions ({ cwd }) {
431414
const sawIgnores = new Set()
432415
return {
433416
cwd,
@@ -437,7 +420,7 @@ class FetcherBase {
437420
if (/Link$/.test(entry.type)) {
438421
return false
439422
}
440-
entry.mode = this[_entryMode](entry.path, entry.mode, entry.type)
423+
entry.mode = this.#entryMode(entry.path, entry.mode, entry.type)
441424
// this replicates the npm pack behavior where .gitignore files
442425
// are treated like .npmignore files, but only if a .npmignore
443426
// file is not present.

node_modules/pacote/lib/file.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ const cacache = require('cacache')
33
const { resolve } = require('path')
44
const { stat, chmod } = require('fs/promises')
55
const Fetcher = require('./fetcher.js')
6-
7-
const _exeBins = Symbol('_exeBins')
8-
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
9-
const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson')
6+
const _ = require('./util/protected.js')
107

118
class FileFetcher extends Fetcher {
129
constructor (spec, opts) {
@@ -27,7 +24,7 @@ class FileFetcher extends Fetcher {
2724
// have to unpack the tarball for this.
2825
return cacache.tmp.withTmp(this.cache, this.opts, dir =>
2926
this.extract(dir)
30-
.then(() => this[_readPackageJson](dir))
27+
.then(() => this[_.readPackageJson](dir))
3128
.then(mani => this.package = {
3229
...mani,
3330
_integrity: this.integrity && String(this.integrity),
@@ -36,7 +33,7 @@ class FileFetcher extends Fetcher {
3633
}))
3734
}
3835

39-
[_exeBins] (pkg, dest) {
36+
#exeBins (pkg, dest) {
4037
if (!pkg.bin) {
4138
return Promise.resolve()
4239
}
@@ -65,11 +62,11 @@ class FileFetcher extends Fetcher {
6562
// but if not, read the unpacked manifest and chmod properly.
6663
return super.extract(dest)
6764
.then(result => this.package ? result
68-
: this[_readPackageJson](dest).then(pkg =>
69-
this[_exeBins](pkg, dest)).then(() => result))
65+
: this[_.readPackageJson](dest).then(pkg =>
66+
this.#exeBins(pkg, dest)).then(() => result))
7067
}
7168

72-
[_tarballFromResolved] () {
69+
[_.tarballFromResolved] () {
7370
// create a read stream and return it
7471
return new fsm.ReadStream(this.resolved)
7572
}

0 commit comments

Comments
 (0)