pacote 11.3.1 → 11.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/fetcher.js +48 -15
- package/lib/git.js +6 -1
- package/lib/registry.js +3 -1
- package/lib/remote.js +7 -0
- package/package.json +5 -8
package/lib/fetcher.js
CHANGED
|
@@ -40,6 +40,7 @@ const _istream = Symbol('_istream')
|
|
|
40
40
|
const _assertType = Symbol('_assertType')
|
|
41
41
|
const _tarballFromCache = Symbol('_tarballFromCache')
|
|
42
42
|
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
|
|
43
|
+
const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches')
|
|
43
44
|
|
|
44
45
|
class FetcherBase {
|
|
45
46
|
constructor (spec, opts) {
|
|
@@ -118,6 +119,13 @@ class FetcherBase {
|
|
|
118
119
|
'--no-progress',
|
|
119
120
|
'--no-save',
|
|
120
121
|
'--no-audit',
|
|
122
|
+
// override any omit settings from the environment
|
|
123
|
+
'--include=dev',
|
|
124
|
+
'--include=peer',
|
|
125
|
+
'--include=optional',
|
|
126
|
+
// we need the actual things, not just the lockfile
|
|
127
|
+
'--no-package-lock-only',
|
|
128
|
+
'--no-dry-run',
|
|
121
129
|
]
|
|
122
130
|
}
|
|
123
131
|
|
|
@@ -166,25 +174,19 @@ class FetcherBase {
|
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
// private, should be overridden.
|
|
169
|
-
// Note that they should *not* calculate or check integrity
|
|
170
|
-
// return the raw tarball data stream.
|
|
177
|
+
// Note that they should *not* calculate or check integrity or cache,
|
|
178
|
+
// but *just* return the raw tarball data stream.
|
|
171
179
|
[_tarballFromResolved] () {
|
|
172
180
|
throw this.notImplementedError
|
|
173
181
|
}
|
|
174
182
|
|
|
175
183
|
// public, should not be overridden
|
|
176
184
|
tarball () {
|
|
177
|
-
return this.tarballStream(stream =>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
data.integrity = this.integrity && String(this.integrity)
|
|
183
|
-
data.resolved = this.resolved
|
|
184
|
-
data.from = this.from
|
|
185
|
-
return res(data)
|
|
186
|
-
})
|
|
187
|
-
stream.on('data', d => buf.push(d))
|
|
185
|
+
return this.tarballStream(stream => stream.concat().then(data => {
|
|
186
|
+
data.integrity = this.integrity && String(this.integrity)
|
|
187
|
+
data.resolved = this.resolved
|
|
188
|
+
data.from = this.from
|
|
189
|
+
return data
|
|
188
190
|
}))
|
|
189
191
|
}
|
|
190
192
|
|
|
@@ -194,6 +196,10 @@ class FetcherBase {
|
|
|
194
196
|
return cacache.get.stream.byDigest(this.cache, this.integrity, this.opts)
|
|
195
197
|
}
|
|
196
198
|
|
|
199
|
+
get [_cacheFetches] () {
|
|
200
|
+
return true
|
|
201
|
+
}
|
|
202
|
+
|
|
197
203
|
[_istream] (stream) {
|
|
198
204
|
// everyone will need one of these, either for verifying or calculating
|
|
199
205
|
// We always set it, because we have might only have a weak legacy hex
|
|
@@ -203,7 +209,31 @@ class FetcherBase {
|
|
|
203
209
|
// gets to the point of re-setting the integrity.
|
|
204
210
|
const istream = ssri.integrityStream(this.opts)
|
|
205
211
|
istream.on('integrity', i => this.integrity = i)
|
|
206
|
-
|
|
212
|
+
stream.on('error', er => istream.emit('error', er))
|
|
213
|
+
|
|
214
|
+
// if not caching this, just pipe through to the istream and return it
|
|
215
|
+
if (!this.opts.cache || !this[_cacheFetches])
|
|
216
|
+
return stream.pipe(istream)
|
|
217
|
+
|
|
218
|
+
// we have to return a stream that gets ALL the data, and proxies errors,
|
|
219
|
+
// but then pipe from the original tarball stream into the cache as well.
|
|
220
|
+
// To do this without losing any data, and since the cacache put stream
|
|
221
|
+
// is not a passthrough, we have to pipe from the original stream into
|
|
222
|
+
// the cache AFTER we pipe into the istream. Since the cache stream
|
|
223
|
+
// has an asynchronous flush to write its contents to disk, we need to
|
|
224
|
+
// defer the istream end until the cache stream ends.
|
|
225
|
+
stream.pipe(istream, { end: false })
|
|
226
|
+
const cstream = cacache.put.stream(
|
|
227
|
+
this.opts.cache,
|
|
228
|
+
`pacote:tarball:${this.from}`,
|
|
229
|
+
this.opts
|
|
230
|
+
)
|
|
231
|
+
stream.pipe(cstream)
|
|
232
|
+
// defer istream end until after cstream
|
|
233
|
+
// cache write errors should not crash the fetch, this is best-effort.
|
|
234
|
+
cstream.promise().catch(() => {}).then(() => istream.end())
|
|
235
|
+
|
|
236
|
+
return istream
|
|
207
237
|
}
|
|
208
238
|
|
|
209
239
|
pickIntegrityAlgorithm () {
|
|
@@ -232,7 +262,9 @@ class FetcherBase {
|
|
|
232
262
|
// An ENOENT trying to read a tgz file, for example, is Right Out.
|
|
233
263
|
isRetriableError (er) {
|
|
234
264
|
// TODO: check error class, once those are rolled out to our deps
|
|
235
|
-
return this.isDataCorruptionError(er) ||
|
|
265
|
+
return this.isDataCorruptionError(er) ||
|
|
266
|
+
er.code === 'ENOENT' ||
|
|
267
|
+
er.code === 'EISDIR'
|
|
236
268
|
}
|
|
237
269
|
|
|
238
270
|
// Mostly internal, but has some uses
|
|
@@ -405,6 +437,7 @@ class FetcherBase {
|
|
|
405
437
|
return {
|
|
406
438
|
cwd,
|
|
407
439
|
noChmod: true,
|
|
440
|
+
noMtime: true,
|
|
408
441
|
filter: (name, entry) => {
|
|
409
442
|
if (/Link$/.test(entry.type))
|
|
410
443
|
return false
|
package/lib/git.js
CHANGED
|
@@ -85,6 +85,9 @@ class GitFetcher extends Fetcher {
|
|
|
85
85
|
[_resolvedFromHosted] (hosted) {
|
|
86
86
|
return this[_resolvedFromRepo](hosted.https && hosted.https())
|
|
87
87
|
.catch(er => {
|
|
88
|
+
// Throw early since we know pathspec errors will fail again if retried
|
|
89
|
+
if (er instanceof git.errors.GitPathspecError)
|
|
90
|
+
throw er
|
|
88
91
|
const ssh = hosted.sshurl && hosted.sshurl()
|
|
89
92
|
// no fallthrough if we can't fall through or have https auth
|
|
90
93
|
if (!ssh || hosted.auth)
|
|
@@ -260,9 +263,11 @@ class GitFetcher extends Fetcher {
|
|
|
260
263
|
// is present, otherwise ssh if the hosted type provides it
|
|
261
264
|
[_cloneHosted] (ref, tmp) {
|
|
262
265
|
const hosted = this.spec.hosted
|
|
263
|
-
const https = hosted.https()
|
|
264
266
|
return this[_cloneRepo](hosted.https({ noCommittish: true }), ref, tmp)
|
|
265
267
|
.catch(er => {
|
|
268
|
+
// Throw early since we know pathspec errors will fail again if retried
|
|
269
|
+
if (er instanceof git.errors.GitPathspecError)
|
|
270
|
+
throw er
|
|
266
271
|
const ssh = hosted.sshurl && hosted.sshurl({ noCommittish: true })
|
|
267
272
|
// no fallthrough if we can't fall through or have https auth
|
|
268
273
|
if (!ssh || hosted.auth)
|
package/lib/registry.js
CHANGED
|
@@ -3,6 +3,7 @@ const RemoteFetcher = require('./remote.js')
|
|
|
3
3
|
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
|
|
4
4
|
const pacoteVersion = require('../package.json').version
|
|
5
5
|
const npa = require('npm-package-arg')
|
|
6
|
+
const rpj = require('read-package-json-fast')
|
|
6
7
|
const pickManifest = require('npm-pick-manifest')
|
|
7
8
|
const ssri = require('ssri')
|
|
8
9
|
const Minipass = require('minipass')
|
|
@@ -156,7 +157,8 @@ class RegistryFetcher extends Fetcher {
|
|
|
156
157
|
}
|
|
157
158
|
if (this.integrity)
|
|
158
159
|
mani._integrity = String(this.integrity)
|
|
159
|
-
|
|
160
|
+
this.package = rpj.normalize(mani)
|
|
161
|
+
return this.package
|
|
160
162
|
})
|
|
161
163
|
}
|
|
162
164
|
|
package/lib/remote.js
CHANGED
|
@@ -8,6 +8,7 @@ const Minipass = require('minipass')
|
|
|
8
8
|
// The default registry URL is a string of great magic.
|
|
9
9
|
const magic = /^https?:\/\/registry\.npmjs\.org\//
|
|
10
10
|
|
|
11
|
+
const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches')
|
|
11
12
|
const _headers = Symbol('_headers')
|
|
12
13
|
class RemoteFetcher extends Fetcher {
|
|
13
14
|
constructor (spec, opts) {
|
|
@@ -21,6 +22,12 @@ class RemoteFetcher extends Fetcher {
|
|
|
21
22
|
this.pkgid = opts.pkgid ? opts.pkgid : `remote:${nameat}${this.resolved}`
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
// Don't need to cache tarball fetches in pacote, because make-fetch-happen
|
|
26
|
+
// will write into cacache anyway.
|
|
27
|
+
get [_cacheFetches] () {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
[_tarballFromResolved] () {
|
|
25
32
|
const stream = new Minipass()
|
|
26
33
|
const fetchOpts = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacote",
|
|
3
|
-
"version": "11.3.
|
|
3
|
+
"version": "11.3.5",
|
|
4
4
|
"description": "JavaScript package downloader",
|
|
5
5
|
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
|
|
6
6
|
"bin": {
|
|
@@ -17,15 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"tap": {
|
|
19
19
|
"timeout": 300,
|
|
20
|
-
"
|
|
21
|
-
"coverage-map": "map.js",
|
|
22
|
-
"esm": false
|
|
20
|
+
"coverage-map": "map.js"
|
|
23
21
|
},
|
|
24
22
|
"devDependencies": {
|
|
25
23
|
"mutate-fs": "^2.1.1",
|
|
26
24
|
"npm-registry-mock": "^1.3.1",
|
|
27
|
-
"
|
|
28
|
-
"tap": "^14.11.0"
|
|
25
|
+
"tap": "^15.0.4"
|
|
29
26
|
},
|
|
30
27
|
"files": [
|
|
31
28
|
"lib/**/*.js"
|
|
@@ -36,7 +33,7 @@
|
|
|
36
33
|
"git"
|
|
37
34
|
],
|
|
38
35
|
"dependencies": {
|
|
39
|
-
"@npmcli/git": "^2.0
|
|
36
|
+
"@npmcli/git": "^2.1.0",
|
|
40
37
|
"@npmcli/installed-package-contents": "^1.0.6",
|
|
41
38
|
"@npmcli/promise-spawn": "^1.2.0",
|
|
42
39
|
"@npmcli/run-script": "^1.8.2",
|
|
@@ -49,7 +46,7 @@
|
|
|
49
46
|
"npm-package-arg": "^8.0.1",
|
|
50
47
|
"npm-packlist": "^2.1.4",
|
|
51
48
|
"npm-pick-manifest": "^6.0.0",
|
|
52
|
-
"npm-registry-fetch": "^
|
|
49
|
+
"npm-registry-fetch": "^11.0.0",
|
|
53
50
|
"promise-retry": "^2.0.1",
|
|
54
51
|
"read-package-json-fast": "^2.0.1",
|
|
55
52
|
"rimraf": "^3.0.2",
|