pacote 7.3.2 → 7.3.3
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/CHANGELOG.md +10 -0
- package/lib/fetchers/registry/tarball.js +62 -74
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="7.3.3"></a>
|
|
6
|
+
## [7.3.3](https://github.com/zkat/pacote/compare/v7.3.2...v7.3.3) (2018-02-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **tarball:** another attempt at fixing opts.resolved ([aff3b6a](https://github.com/zkat/pacote/commit/aff3b6a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
5
15
|
<a name="7.3.2"></a>
|
|
6
16
|
## [7.3.2](https://github.com/zkat/pacote/compare/v7.3.1...v7.3.2) (2018-02-15)
|
|
7
17
|
|
|
@@ -13,19 +13,30 @@ const url = require('url')
|
|
|
13
13
|
module.exports = tarball
|
|
14
14
|
function tarball (spec, opts) {
|
|
15
15
|
opts = optCheck(opts)
|
|
16
|
+
const registry = pickRegistry(spec, opts)
|
|
16
17
|
const stream = new PassThrough()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
let mani
|
|
19
|
+
if (
|
|
20
|
+
opts.resolved &&
|
|
21
|
+
// spec.type === 'version' &&
|
|
22
|
+
opts.resolved.indexOf(registry) === 0
|
|
23
|
+
) {
|
|
24
|
+
// fakeChild is a shortcut to avoid looking up a manifest!
|
|
25
|
+
mani = BB.resolve({
|
|
26
|
+
name: spec.name,
|
|
27
|
+
version: spec.fetchSpec,
|
|
28
|
+
_integrity: opts.integrity,
|
|
29
|
+
_resolved: opts.resolved,
|
|
30
|
+
_fakeChild: true
|
|
31
|
+
})
|
|
32
|
+
} else {
|
|
33
|
+
// We can't trust opts.resolved if it's going to a separate host.
|
|
34
|
+
mani = manifest(spec, opts)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
mani.then(mani => {
|
|
38
|
+
!mani._fakeChild && stream.emit('manifest', mani)
|
|
39
|
+
const fetchStream = fromManifest(mani, spec, opts).on(
|
|
29
40
|
'integrity', i => stream.emit('integrity', i)
|
|
30
41
|
)
|
|
31
42
|
fetchStream.on('error', err => stream.emit('error', err))
|
|
@@ -40,33 +51,27 @@ function fromManifest (manifest, spec, opts) {
|
|
|
40
51
|
opts.scope = spec.scope || opts.scope
|
|
41
52
|
const stream = new PassThrough()
|
|
42
53
|
const registry = pickRegistry(spec, opts)
|
|
43
|
-
getTarballUrl(spec, registry, manifest, opts)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
if (hash) {
|
|
65
|
-
stream.emit('integrity', decodeURIComponent(hash))
|
|
66
|
-
}
|
|
67
|
-
res.body.on('error', err => stream.emit('error', err))
|
|
68
|
-
res.body.pipe(stream)
|
|
69
|
-
})
|
|
54
|
+
const uri = getTarballUrl(spec, registry, manifest, opts)
|
|
55
|
+
fetch(uri, registry, Object.assign({
|
|
56
|
+
headers: {
|
|
57
|
+
'pacote-req-type': 'tarball',
|
|
58
|
+
'pacote-pkg-id': `registry:${manifest.name}@${uri}`
|
|
59
|
+
},
|
|
60
|
+
integrity: manifest._integrity,
|
|
61
|
+
algorithms: [
|
|
62
|
+
manifest._integrity
|
|
63
|
+
? ssri.parse(manifest._integrity).pickAlgorithm()
|
|
64
|
+
: 'sha1'
|
|
65
|
+
],
|
|
66
|
+
spec
|
|
67
|
+
}, opts))
|
|
68
|
+
.then(res => {
|
|
69
|
+
const hash = res.headers.get('x-local-cache-hash')
|
|
70
|
+
if (hash) {
|
|
71
|
+
stream.emit('integrity', decodeURIComponent(hash))
|
|
72
|
+
}
|
|
73
|
+
res.body.on('error', err => stream.emit('error', err))
|
|
74
|
+
res.body.pipe(stream)
|
|
70
75
|
})
|
|
71
76
|
.catch(err => stream.emit('error', err))
|
|
72
77
|
return stream
|
|
@@ -74,40 +79,23 @@ function fromManifest (manifest, spec, opts) {
|
|
|
74
79
|
|
|
75
80
|
function getTarballUrl (spec, registry, mani, opts) {
|
|
76
81
|
const reg = url.parse(registry)
|
|
77
|
-
const tarball = url.parse(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.then(mani => {
|
|
93
|
-
const tarball = url.parse(mani._resolved)
|
|
94
|
-
// https://github.com/npm/npm/pull/9471
|
|
95
|
-
//
|
|
96
|
-
// TL;DR: Some alternative registries host tarballs on http and packuments
|
|
97
|
-
// on https, and vice-versa. There's also a case where people who can't use
|
|
98
|
-
// SSL to access the npm registry, for example, might use
|
|
99
|
-
// `--registry=http://registry.npmjs.org/`. In this case, we need to
|
|
100
|
-
// rewrite `tarball` to match the protocol.
|
|
101
|
-
//
|
|
102
|
-
if (reg.hostname === tarball.hostname && reg.protocol !== tarball.protocol) {
|
|
103
|
-
tarball.protocol = reg.protocol
|
|
104
|
-
// Ports might be same host different protocol!
|
|
105
|
-
if (reg.port !== tarball.port) {
|
|
106
|
-
delete tarball.host
|
|
107
|
-
tarball.port = reg.port
|
|
108
|
-
}
|
|
109
|
-
delete tarball.href
|
|
82
|
+
const tarball = url.parse(mani._resolved)
|
|
83
|
+
// https://github.com/npm/npm/pull/9471
|
|
84
|
+
//
|
|
85
|
+
// TL;DR: Some alternative registries host tarballs on http and packuments
|
|
86
|
+
// on https, and vice-versa. There's also a case where people who can't use
|
|
87
|
+
// SSL to access the npm registry, for example, might use
|
|
88
|
+
// `--registry=http://registry.npmjs.org/`. In this case, we need to
|
|
89
|
+
// rewrite `tarball` to match the protocol.
|
|
90
|
+
//
|
|
91
|
+
if (reg.hostname === tarball.hostname && reg.protocol !== tarball.protocol) {
|
|
92
|
+
tarball.protocol = reg.protocol
|
|
93
|
+
// Ports might be same host different protocol!
|
|
94
|
+
if (reg.port !== tarball.port) {
|
|
95
|
+
delete tarball.host
|
|
96
|
+
tarball.port = reg.port
|
|
110
97
|
}
|
|
111
|
-
|
|
112
|
-
}
|
|
98
|
+
delete tarball.href
|
|
99
|
+
}
|
|
100
|
+
return url.format(tarball)
|
|
113
101
|
}
|