Skip to content

Commit 88beaab

Browse files
committedNov 9, 2019
Return the requested spec as the 'from' value
While this is a bit redundant, given the fact that whoever is calling pacote already knows this by definition, it's also a huge pain to track when kicking off a ton of requests in parallel. Much better to just return it at the end of the process as well, to save the caller that reassembly and bookkeeping.
1 parent e5b84f2 commit 88beaab

17 files changed

+112
-20
lines changed
 

‎README.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pacote.manifest('foo@1.x').then(manifest => console.log('got it', manifest))
1212

1313
// extract a package into a folder
1414
pacote.extract('github:npm/cli', 'some/path', options)
15-
.then(({resolved, integrity}) => {
16-
console.log('extracted!', resolved, integrity)
15+
.then(({from, resolved, integrity}) => {
16+
console.log('extracted!', from, resolved, integrity)
1717
})
1818

1919
pacote.tarball('https://server.com/package.tgz').then(data => {
@@ -31,28 +31,34 @@ This module exports a command line interface that can do most of what is
3131
described below. Run `pacote -h` to learn more.
3232

3333
```
34-
Pacote - The JavaScript Package Handler, v10.0.0
34+
Pacote - The JavaScript Package Handler, v10.1.1
3535
3636
Usage:
3737
3838
pacote resolve <spec>
39-
Fesolve a specifier and output the fully resolved target
39+
Resolve a specifier and output the fully resolved target
40+
Returns integrity and from if '--long' flag is set.
4041
4142
pacote manifest <spec>
4243
Fetch a manifest and print to stdout
4344
4445
pacote packument <spec>
4546
Fetch a full packument and print to stdout
4647
47-
pacote tarball <spec> <filename>
48+
pacote tarball <spec> [<filename>]
4849
Fetch a package tarball and save to <filename>
4950
If <filename> is missing or '-', the tarball will be streamed to stdout.
5051
5152
pacote extract <spec> <folder>
5253
Extract a package to the destination folder.
5354
54-
Configuration values all match the names of configs passed to npm, or options
55-
passed to Pacote.
55+
Configuration values all match the names of configs passed to npm, or
56+
options passed to Pacote. Additional flags for this executable:
57+
58+
--long Print an object from 'resolve', including integrity and spec.
59+
--json Print result objects as JSON rather than node's default.
60+
(This is the default if stdout is not a TTY.)
61+
--help -h Print this helpful text.
5662
5763
For example '--cache=/path/to/folder' will use that folder as the cache.
5864
```
@@ -71,7 +77,7 @@ See below for valid `opts` values.
7177

7278
* `pacote.extract(spec, dest, opts)` Extract a package's tarball into a
7379
destination folder. Returns a promise that resolves to the
74-
`{resolved,integrity}` of the extracted package.
80+
`{from,resolved,integrity}` of the extracted package.
7581

7682
* `pacote.manifest(spec, opts)` Fetch (or simulate) a package's manifest
7783
(basically, the `package.json` file, plus a bit of metadata).
@@ -85,11 +91,11 @@ See below for valid `opts` values.
8591

8692
* `pacote.tarball(spec, opts)` Get a package tarball data as a buffer in
8793
memory. Returns a Promise that resolves to the tarball data Buffer, with
88-
`resolved` and `integrity` fields attached.
94+
`from`, `resolved`, and `integrity` fields attached.
8995

9096
* `pacote.tarball.file(spec, dest, opts)` Save a package tarball data to
9197
a file on disk. Returns a Promise that resolves to
92-
`{integrity,resolved}` of the fetched tarball.
98+
`{from,integrity,resolved}` of the fetched tarball.
9399

94100
* `pacote.tarball.stream(spec, streamHandler, opts)` Fetch a tarball and
95101
make the stream available to the `streamHandler` function.
@@ -185,6 +191,7 @@ In addition to the common `package.json` fields, manifests include:
185191

186192
* `manifest._resolved` The tarball url or file path where the package
187193
artifact can be found.
194+
* `manifest._from` A normalized form of the spec passed in as an argument.
188195
* `manifest._integrity` The integrity value for the package artifact.
189196
* `manifest.dist` Registry manifests (those included in a packument) have a
190197
`dist` object. Only `tarball` is required, though at least one of

‎lib/bin.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const run = conf => {
44
const pacote = require('../')
55
switch (conf._[0]) {
66
case 'resolve':
7+
if (conf.long)
8+
return pacote.manifest(conf._[1], conf).then(mani => ({
9+
resolved: mani._resolved,
10+
integrity: mani._integrity,
11+
from: mani._from,
12+
}))
713
case 'manifest':
814
case 'packument':
915
return pacote[conf._[0]](conf._[1], conf)
@@ -36,6 +42,7 @@ Usage:
3642
3743
pacote resolve <spec>
3844
Resolve a specifier and output the fully resolved target
45+
Returns integrity and from if '--long' flag is set.
3946
4047
pacote manifest <spec>
4148
Fetch a manifest and print to stdout
@@ -50,8 +57,13 @@ Usage:
5057
pacote extract <spec> <folder>
5158
Extract a package to the destination folder.
5259
53-
Configuration values all match the names of configs passed to npm, or options
54-
passed to Pacote.
60+
Configuration values all match the names of configs passed to npm, or
61+
options passed to Pacote. Additional flags for this executable:
62+
63+
--long Print an object from 'resolve', including integrity and spec.
64+
--json Print result objects as JSON rather than node's default.
65+
(This is the default if stdout is not a TTY.)
66+
--help -h Print this helpful text.
5567
5668
For example '--cache=/path/to/folder' will use that folder as the cache.
5769
`

‎lib/dir.js

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class DirFetcher extends Fetcher {
8787
...mani,
8888
_integrity: String(this.integrity),
8989
_resolved: this.resolved,
90+
_from: this.from,
9091
})
9192
}
9293

‎lib/fetcher.js

+13
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ class FetcherBase {
4545
if (!opts || typeof opts !== 'object')
4646
throw new TypeError('options object is required')
4747
this.spec = npa(spec, opts.where)
48+
49+
// a bit redundant because presumably the caller already knows this,
50+
// but it makes it easier to not have to keep track of the requested
51+
// spec when we're dispatching thousands of these at once, and normalizing
52+
// is nice. saveSpec is preferred if set, because it turns stuff like
53+
// x/y#committish into github:x/y#committish. use name@rawSpec for
54+
// registry deps so that we turn xyz and xyz@ -> xyz@
55+
this.from = this.spec.registry
56+
? `${this.spec.name}@${this.spec.rawSpec}` : this.spec.saveSpec
57+
4858
this[_assertType]()
4959
this.opts = opts
5060
this.cache = opts.cache || cacheDir()
@@ -164,6 +174,7 @@ class FetcherBase {
164174
const data = Buffer.concat(buf)
165175
data.integrity = String(this.integrity)
166176
data.resolved = this.resolved
177+
data.from = this.from
167178
return res(data)
168179
})
169180
stream.on('data', d => buf.push(d))
@@ -323,6 +334,7 @@ class FetcherBase {
323334
writer.on('close', () => res({
324335
integrity: this.integrity && String(this.integrity),
325336
resolved: this.resolved,
337+
from: this.from,
326338
}))
327339
str.pipe(writer)
328340
}))
@@ -346,6 +358,7 @@ class FetcherBase {
346358
resolve({
347359
resolved: this.resolved,
348360
integrity: this.integrity && String(this.integrity),
361+
from: this.from,
349362
})
350363
})
351364

‎lib/file.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FileFetcher extends Fetcher {
3131
...mani,
3232
_integrity: String(this.integrity),
3333
_resolved: this.resolved,
34+
_from: this.from,
3435
}))
3536
}
3637

‎lib/git.js

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class GitFetcher extends Fetcher {
143143
const stream = new Minipass()
144144
stream.resolved = this.resolved
145145
stream.integrity = this.integrity
146+
stream.from = this.from
146147

147148
// check it out and then shell out to the DirFetcher tarball packer
148149
this[_clone](dir => this[_prepareDir](dir)

‎lib/registry.js

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class RegistryFetcher extends Fetcher {
106106
const { dist } = mani
107107
if (dist) {
108108
this.resolved = mani._resolved = dist.tarball
109+
mani._from = this.from
109110
if (!this.integrity) {
110111
if (dist.integrity)
111112
this.integrity = ssri.parse(dist.integrity)

‎tap-snapshots/test-bin.js-TAP.test.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Object {
1111
"exitlog": Array [],
1212
"loglog": Array [
1313
Array [
14-
"Pacote - The JavaScript Package Handler, v{VERSION}\\n\\nUsage:\\n\\n pacote resolve <spec>\\n Resolve a specifier and output the fully resolved target\\n\\n pacote manifest <spec>\\n Fetch a manifest and print to stdout\\n\\n pacote packument <spec>\\n Fetch a full packument and print to stdout\\n\\n pacote tarball <spec> [<filename>]\\n Fetch a package tarball and save to <filename>\\n If <filename> is missing or '-', the tarball will be streamed to stdout.\\n\\n pacote extract <spec> <folder>\\n Extract a package to the destination folder.\\n\\nConfiguration values all match the names of configs passed to npm, or options\\npassed to Pacote.\\n\\nFor example '--cache=/path/to/folder' will use that folder as the cache.\\n",
14+
"Pacote - The JavaScript Package Handler, v{VERSION}\\n\\nUsage:\\n\\n pacote resolve <spec>\\n Resolve a specifier and output the fully resolved target\\n Returns integrity and from if '--long' flag is set.\\n\\n pacote manifest <spec>\\n Fetch a manifest and print to stdout\\n\\n pacote packument <spec>\\n Fetch a full packument and print to stdout\\n\\n pacote tarball <spec> [<filename>]\\n Fetch a package tarball and save to <filename>\\n If <filename> is missing or '-', the tarball will be streamed to stdout.\\n\\n pacote extract <spec> <folder>\\n Extract a package to the destination folder.\\n\\nConfiguration values all match the names of configs passed to npm, or\\noptions passed to Pacote. Additional flags for this executable:\\n\\n --long Print an object from 'resolve', including integrity and spec.\\n --json Print result objects as JSON rather than node's default.\\n (This is the default if stdout is not a TTY.)\\n --help -h Print this helpful text.\\n\\nFor example '--cache=/path/to/folder' will use that folder as the cache.\\n",
1515
],
1616
],
1717
}
@@ -24,7 +24,7 @@ Object {
2424
"bad command: blerg",
2525
],
2626
Array [
27-
"Pacote - The JavaScript Package Handler, v{VERSION}\\n\\nUsage:\\n\\n pacote resolve <spec>\\n Resolve a specifier and output the fully resolved target\\n\\n pacote manifest <spec>\\n Fetch a manifest and print to stdout\\n\\n pacote packument <spec>\\n Fetch a full packument and print to stdout\\n\\n pacote tarball <spec> [<filename>]\\n Fetch a package tarball and save to <filename>\\n If <filename> is missing or '-', the tarball will be streamed to stdout.\\n\\n pacote extract <spec> <folder>\\n Extract a package to the destination folder.\\n\\nConfiguration values all match the names of configs passed to npm, or options\\npassed to Pacote.\\n\\nFor example '--cache=/path/to/folder' will use that folder as the cache.\\n",
27+
"Pacote - The JavaScript Package Handler, v{VERSION}\\n\\nUsage:\\n\\n pacote resolve <spec>\\n Resolve a specifier and output the fully resolved target\\n Returns integrity and from if '--long' flag is set.\\n\\n pacote manifest <spec>\\n Fetch a manifest and print to stdout\\n\\n pacote packument <spec>\\n Fetch a full packument and print to stdout\\n\\n pacote tarball <spec> [<filename>]\\n Fetch a package tarball and save to <filename>\\n If <filename> is missing or '-', the tarball will be streamed to stdout.\\n\\n pacote extract <spec> <folder>\\n Extract a package to the destination folder.\\n\\nConfiguration values all match the names of configs passed to npm, or\\noptions passed to Pacote. Additional flags for this executable:\\n\\n --long Print an object from 'resolve', including integrity and spec.\\n --json Print result objects as JSON rather than node's default.\\n (This is the default if stdout is not a TTY.)\\n --help -h Print this helpful text.\\n\\nFor example '--cache=/path/to/folder' will use that folder as the cache.\\n",
2828
],
2929
],
3030
"exitlog": Array [],
@@ -75,7 +75,7 @@ Object {
7575
"exitlog": Array [],
7676
"loglog": Array [
7777
Array [
78-
"{\\n \\"method\\": \\"manifest\\",\\n \\"spec\\": \\"bar@foo\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"manifest\\",\\n \\"bar@foo\\"\\n ],\\n \\"json\\": true,\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\"\\n }\\n}",
78+
"{\\n \\"method\\": \\"manifest\\",\\n \\"spec\\": \\"bar@foo\\",\\n \\"conf\\": {\\n \\"_\\": [\\n \\"manifest\\",\\n \\"bar@foo\\"\\n ],\\n \\"json\\": true,\\n \\"cache\\": \\"{HOME}/.npm/_cacache\\"\\n },\\n \\"_resolved\\": \\"manifest resolved\\",\\n \\"_integrity\\": \\"manifest integrity\\",\\n \\"_from\\": \\"manifest from\\"\\n}",
7979
],
8080
],
8181
}
@@ -107,6 +107,18 @@ Object {
107107
}
108108
`
109109

110+
exports[`test/bin.js TAP main resolve foo@bar --long > must match snapshot 1`] = `
111+
Object {
112+
"errorlog": Array [],
113+
"exitlog": Array [],
114+
"loglog": Array [
115+
Array [
116+
"{\\n \\"resolved\\": \\"manifest resolved\\",\\n \\"integrity\\": \\"manifest integrity\\",\\n \\"from\\": \\"manifest from\\"\\n}",
117+
],
118+
],
119+
}
120+
`
121+
110122
exports[`test/bin.js TAP main resolve foo@bar > must match snapshot 1`] = `
111123
Object {
112124
"errorlog": Array [],
@@ -147,6 +159,9 @@ Object {
147159

148160
exports[`test/bin.js TAP run > expect resolving Promise 2`] = `
149161
Object {
162+
"_from": "manifest from",
163+
"_integrity": "manifest integrity",
164+
"_resolved": "manifest resolved",
150165
"conf": Object {
151166
"_": Array [
152167
"manifest",
@@ -216,6 +231,7 @@ Usage:
216231
217232
pacote resolve <spec>
218233
Resolve a specifier and output the fully resolved target
234+
Returns integrity and from if '--long' flag is set.
219235
220236
pacote manifest <spec>
221237
Fetch a manifest and print to stdout
@@ -230,8 +246,13 @@ Usage:
230246
pacote extract <spec> <folder>
231247
Extract a package to the destination folder.
232248
233-
Configuration values all match the names of configs passed to npm, or options
234-
passed to Pacote.
249+
Configuration values all match the names of configs passed to npm, or
250+
options passed to Pacote. Additional flags for this executable:
251+
252+
--long Print an object from 'resolve', including integrity and spec.
253+
--json Print result objects as JSON rather than node's default.
254+
(This is the default if stdout is not a TTY.)
255+
--help -h Print this helpful text.
235256
236257
For example '--cache=/path/to/folder' will use that folder as the cache.
237258

‎tap-snapshots/test-dir.js-TAP.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
'use strict'
88
exports[`test/dir.js TAP basic > extract 1`] = `
99
Object {
10+
"from": "file:test/fixtures/abbrev",
1011
"integrity": "sha512-Ict4yhLfiPOkcX+yjBRSI2QUetKt+A08AXMyLeQbKGYg/OGI/1k47Hu9tWZOx1l4j+M1z07Zxt3IL41TmLkbDw==",
1112
"resolved": "\${CWD}/test/fixtures/abbrev",
1213
}
1314
`
1415

1516
exports[`test/dir.js TAP basic > manifest 1`] = `
1617
Object {
18+
"_from": "file:test/fixtures/abbrev",
1719
"_id": "abbrev@1.1.1",
1820
"_integrity": "null",
1921
"_resolved": "\${CWD}/test/fixtures/abbrev",
@@ -83,6 +85,7 @@ Object {
8385
"name": "abbrev",
8486
"versions": Object {
8587
"1.1.1": Object {
88+
"_from": "file:test/fixtures/abbrev",
8689
"_id": "abbrev@1.1.1",
8790
"_integrity": "null",
8891
"_resolved": "\${CWD}/test/fixtures/abbrev",
@@ -128,6 +131,7 @@ Object {
128131

129132
exports[`test/dir.js TAP basic > saved package.json 1`] = `
130133
Object {
134+
"_from": "file:test/fixtures/abbrev",
131135
"_id": "abbrev@1.1.1",
132136
"_integrity": "null",
133137
"_resolved": "\${CWD}/test/fixtures/abbrev",
@@ -167,13 +171,15 @@ Object {
167171

168172
exports[`test/dir.js TAP make bins executable > results of unpack 1`] = `
169173
Object {
174+
"from": "file:test/fixtures/bin-object",
170175
"integrity": "sha512-rlE32nBV7XgKCm0I7YqAewyVPbaRJWUQMZUFLlngGK3imG+som3Hin7d/zPTikWg64tHIxb8VXeeq6u0IRRfmQ==",
171176
"resolved": "\${CWD}/test/fixtures/bin-object",
172177
}
173178
`
174179

175180
exports[`test/dir.js TAP with prepare script > extract 1`] = `
176181
Object {
182+
"from": "file:test/fixtures/prepare-script",
177183
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
178184
"resolved": "\${CWD}/test/fixtures/prepare-script",
179185
}
@@ -189,6 +195,7 @@ Array [
189195

190196
exports[`test/dir.js TAP with prepare script > manifest 1`] = `
191197
Object {
198+
"_from": "file:test/fixtures/prepare-script",
192199
"_id": "git-prepare-script@1.0.0",
193200
"_integrity": "null",
194201
"_resolved": "\${CWD}/test/fixtures/prepare-script",
@@ -214,6 +221,7 @@ Object {
214221
"name": "git-prepare-script",
215222
"versions": Object {
216223
"1.0.0": Object {
224+
"_from": "file:test/fixtures/prepare-script",
217225
"_id": "git-prepare-script@1.0.0",
218226
"_integrity": "null",
219227
"_resolved": "\${CWD}/test/fixtures/prepare-script",

‎tap-snapshots/test-fetcher.js-TAP.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'use strict'
88
exports[`test/fetcher.js TAP make bins executable > results of unpack 1`] = `
99
Object {
10+
"from": "file:test/fixtures/bin-object.tgz",
1011
"integrity": "sha512-TqzCjecWyQe8vqLbT0nv/OaWf0ptRZ2DnPmiuGUYJJb70shp02+/uu37IJSkM2ZEP1SAOeKrYrWPVIIYW+d//g==",
1112
"resolved": "{CWD}/test/fixtures/bin-object.tgz",
1213
}

‎tap-snapshots/test-fetcher.js-fake-sudo-TAP.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'use strict'
88
exports[`test/fetcher.js fake-sudo TAP make bins executable > results of unpack 1`] = `
99
Object {
10+
"from": "file:test/fixtures/bin-object.tgz",
1011
"integrity": "sha512-TqzCjecWyQe8vqLbT0nv/OaWf0ptRZ2DnPmiuGUYJJb70shp02+/uu37IJSkM2ZEP1SAOeKrYrWPVIIYW+d//g==",
1112
"resolved": "{CWD}/test/fixtures/bin-object.tgz",
1213
}

‎tap-snapshots/test-file.js-TAP.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
'use strict'
88
exports[`test/file.js TAP basic > extract 1`] = `
99
Object {
10+
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
1011
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
1112
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
1213
}
1314
`
1415

1516
exports[`test/file.js TAP basic > manifest 1`] = `
1617
Object {
18+
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
1719
"_id": "abbrev@1.1.1",
1820
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
1921
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
@@ -83,6 +85,7 @@ Object {
8385
"name": "abbrev",
8486
"versions": Object {
8587
"1.1.1": Object {
88+
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
8689
"_id": "abbrev@1.1.1",
8790
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
8891
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
@@ -128,20 +131,23 @@ Object {
128131

129132
exports[`test/file.js TAP make bins executable bin-good > results of unpack 1`] = `
130133
Object {
134+
"from": "file:test/fixtures/bin-good.tgz",
131135
"integrity": "sha512-Fx11OiHxV82CztnPk+k0S6H/66J4/eUzZEMGX2dJjP+Mxfrm8fSzE4SQG604zWk17ELZsOGENCdWSkvj4cpjUw==",
132136
"resolved": "\${CWD}/test/fixtures/bin-good.tgz",
133137
}
134138
`
135139

136140
exports[`test/file.js TAP make bins executable bin-object > results of unpack 1`] = `
137141
Object {
142+
"from": "file:test/fixtures/bin-object.tgz",
138143
"integrity": "sha512-TqzCjecWyQe8vqLbT0nv/OaWf0ptRZ2DnPmiuGUYJJb70shp02+/uu37IJSkM2ZEP1SAOeKrYrWPVIIYW+d//g==",
139144
"resolved": "\${CWD}/test/fixtures/bin-object.tgz",
140145
}
141146
`
142147

143148
exports[`test/file.js TAP make bins executable bin-string > results of unpack 1`] = `
144149
Object {
150+
"from": "file:test/fixtures/bin-string.tgz",
145151
"integrity": "sha512-iCc87DMYVMofO221ksAlMD88Zgsr4OIvqeX73KxTPikWaQPvBFZpzI9FGWnD4PTLTyJzOSETQh86+IwEidJRZg==",
146152
"resolved": "\${CWD}/test/fixtures/bin-string.tgz",
147153
}

‎tap-snapshots/test-index.js-TAP.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
'use strict'
88
exports[`test/index.js TAP > extract 1`] = `
99
Object {
10+
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
1011
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
1112
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
1213
}
1314
`
1415

1516
exports[`test/index.js TAP > manifest 1`] = `
1617
Object {
18+
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
1719
"_id": "abbrev@1.1.1",
1820
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
1921
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
@@ -53,6 +55,7 @@ Object {
5355

5456
exports[`test/index.js TAP > manifest 2`] = `
5557
Object {
58+
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
5659
"_id": "abbrev@1.1.1",
5760
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
5861
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
@@ -98,6 +101,7 @@ Object {
98101
"name": "abbrev",
99102
"versions": Object {
100103
"1.1.1": Object {
104+
"_from": "file:test/fixtures/abbrev-1.1.1.tgz",
101105
"_id": "abbrev@1.1.1",
102106
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
103107
"_resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
@@ -147,6 +151,7 @@ exports[`test/index.js TAP > resolve 1`] = `
147151

148152
exports[`test/index.js TAP > tarball to file 1`] = `
149153
Object {
154+
"from": "file:test/fixtures/abbrev-1.1.1.tgz",
150155
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
151156
"resolved": "\${CWD}/test/fixtures/abbrev-1.1.1.tgz",
152157
}

‎tap-snapshots/test-remote.js-TAP.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Object {
1313
"name": "abbrev",
1414
"versions": Object {
1515
"1.1.1": Object {
16+
"_from": "http://localhost:{PORT}/abbrev.tgz",
1617
"_id": "abbrev@1.1.1",
1718
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
1819
"_resolved": "http://localhost:{PORT}/abbrev.tgz",
@@ -64,6 +65,7 @@ Object {
6465
"name": "abbrev",
6566
"versions": Object {
6667
"1.1.1": Object {
68+
"_from": "http://localhost:{PORT}/abbrev.tgz",
6769
"_id": "abbrev@1.1.1",
6870
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
6971
"_resolved": "http://localhost:{PORT}/abbrev.tgz",

‎test/bin.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ const called = []
1212
pacote.resolve = (spec, conf) =>
1313
spec === 'fail' ? Promise.reject(new Error('fail'))
1414
: Promise.resolve({method: 'resolve', spec, conf})
15-
pacote.manifest = (spec, conf) => Promise.resolve({method: 'manifest', spec, conf})
15+
pacote.manifest = (spec, conf) => Promise.resolve({
16+
method: 'manifest',
17+
spec,
18+
conf,
19+
_resolved: 'manifest resolved',
20+
_integrity: 'manifest integrity',
21+
_from: 'manifest from',
22+
})
1623
pacote.packument = (spec, conf) => Promise.resolve({method: 'packument', spec, conf})
1724
pacote.tarball.file = (spec, file, conf) => Promise.resolve({method: 'tarball', spec, file, conf})
1825
const Minipass = require('minipass')
@@ -103,6 +110,7 @@ t.test('main', t => {
103110

104111
test('--help')
105112
test('resolve', 'foo@bar')
113+
test('resolve', 'foo@bar', '--long')
106114
test('manifest', 'bar@foo')
107115
test('packument', 'paku@mint')
108116
test('tarball', 'tar@ball', 'file.tgz')

‎test/git.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ t.test('basic stuff', async t => {
254254

255255
const gx = await g.extract(me + '/g')
256256
const rx = await r.extract(me + '/r')
257-
t.same(gx, rx, 'got the same resolved and integrity')
257+
t.equal(gx.resolved, rx.resolved, 'got the same resolved')
258+
t.equal(gx.integrity, rx.integrity, 'got the same integrity')
258259

259260
// prepare script ran, files were filtered properly
260261
fs.statSync(me + '/g/index.js')

‎test/registry.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ t.test('underscore, no tag or version', t => {
6868
.then(result => t.deepEqual(result, {
6969
resolved: `${registry}underscore/-/underscore-1.5.1.tgz`,
7070
integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck= sha512-yOc7VukmA45a1D6clUn1mD7Mbc9LcVYAQEXNKSTblzha59hSFJ6cAt90JDoxh05GQnTPI9nk4wjT/I8C/nAMPw==',
71+
from: "underscore@",
7172
}))
7273
})
7374

@@ -80,6 +81,7 @@ t.test('scoped, no tag or version', t => {
8081
.then(result => t.deepEqual(result, {
8182
resolved: `${registry}@isaacs/namespace-test/-/namespace-test-1.0.0.tgz`,
8283
integrity: 'sha512-5ZYe1LgwHIaag0p9loMwsf5N/wJ4XAuHVNhSO+qulQOXWnyJVuco6IZjo+5u4ZLF/GimdHJcX+QK892ONfOCqQ==',
84+
from: "@isaacs/namespace-test@",
8385
}))
8486
})
8587

@@ -121,6 +123,7 @@ t.test('a manifest that lacks integrity', t => {
121123
return f.extract(me + '/no-integrity')
122124
}).then(result => t.deepEqual(result, {
123125
resolved: `${registry}no-integrity/-/no-integrity-1.2.3.tgz`,
124-
integrity: 'sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=='
126+
integrity: 'sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==',
127+
from: "no-integrity@",
125128
}, 'calculated integrity anyway'))
126129
})

0 commit comments

Comments
 (0)
Please sign in to comment.