Skip to content

Commit e7ab206

Browse files
committed
deps: update pacote@19.0.0
1 parent b28dbb1 commit e7ab206

File tree

192 files changed

+5914
-2888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+5914
-2888
lines changed

mock-registry/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"json-stringify-safe": "^5.0.1",
5353
"nock": "^13.3.3",
5454
"npm-package-arg": "^12.0.0",
55-
"pacote": "^18.0.6",
55+
"pacote": "^19.0.0",
5656
"tap": "^16.3.8"
5757
}
5858
}

node_modules/.gitignore

+23-17
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,22 @@
4141
/@npmcli/metavuln-calculator/node_modules/*
4242
!/@npmcli/metavuln-calculator/node_modules/@npmcli/
4343
/@npmcli/metavuln-calculator/node_modules/@npmcli/*
44+
!/@npmcli/metavuln-calculator/node_modules/@npmcli/agent
4445
!/@npmcli/metavuln-calculator/node_modules/@npmcli/fs
46+
!/@npmcli/metavuln-calculator/node_modules/@npmcli/package-json
47+
!/@npmcli/metavuln-calculator/node_modules/@npmcli/promise-spawn
48+
!/@npmcli/metavuln-calculator/node_modules/@npmcli/redact
49+
!/@npmcli/metavuln-calculator/node_modules/@npmcli/run-script
4550
!/@npmcli/metavuln-calculator/node_modules/cacache
51+
!/@npmcli/metavuln-calculator/node_modules/hosted-git-info
4652
!/@npmcli/metavuln-calculator/node_modules/json-parse-even-better-errors
53+
!/@npmcli/metavuln-calculator/node_modules/make-fetch-happen
54+
!/@npmcli/metavuln-calculator/node_modules/normalize-package-data
55+
!/@npmcli/metavuln-calculator/node_modules/npm-install-checks
56+
!/@npmcli/metavuln-calculator/node_modules/npm-package-arg
57+
!/@npmcli/metavuln-calculator/node_modules/npm-pick-manifest
58+
!/@npmcli/metavuln-calculator/node_modules/npm-registry-fetch
59+
!/@npmcli/metavuln-calculator/node_modules/pacote
4760
!/@npmcli/metavuln-calculator/node_modules/unique-filename
4861
!/@npmcli/metavuln-calculator/node_modules/unique-slug
4962
!/@npmcli/name-from-folder
@@ -260,23 +273,16 @@
260273
/pacote/node_modules/*
261274
!/pacote/node_modules/@npmcli/
262275
/pacote/node_modules/@npmcli/*
263-
!/pacote/node_modules/@npmcli/agent
264-
!/pacote/node_modules/@npmcli/fs
265-
!/pacote/node_modules/@npmcli/package-json
266-
!/pacote/node_modules/@npmcli/promise-spawn
267-
!/pacote/node_modules/@npmcli/redact
268-
!/pacote/node_modules/@npmcli/run-script
269-
!/pacote/node_modules/cacache
270-
!/pacote/node_modules/hosted-git-info
271-
!/pacote/node_modules/json-parse-even-better-errors
272-
!/pacote/node_modules/make-fetch-happen
273-
!/pacote/node_modules/normalize-package-data
274-
!/pacote/node_modules/npm-install-checks
275-
!/pacote/node_modules/npm-package-arg
276-
!/pacote/node_modules/npm-pick-manifest
277-
!/pacote/node_modules/npm-registry-fetch
278-
!/pacote/node_modules/unique-filename
279-
!/pacote/node_modules/unique-slug
276+
!/pacote/node_modules/@npmcli/git
277+
!/pacote/node_modules/@npmcli/installed-package-contents
278+
!/pacote/node_modules/ignore-walk
279+
!/pacote/node_modules/isexe
280+
!/pacote/node_modules/npm-bundled
281+
!/pacote/node_modules/npm-normalize-package-bin
282+
!/pacote/node_modules/npm-packlist
283+
!/pacote/node_modules/proc-log
284+
!/pacote/node_modules/ssri
285+
!/pacote/node_modules/which
280286
!/parse-conflict-json
281287
!/parse-conflict-json/node_modules/
282288
/parse-conflict-json/node_modules/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The ISC License
2+
3+
Copyright (c) Isaac Z. Schlueter, Kat Marchán, npm, Inc., and Contributors
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
#!/usr/bin/env node
2+
3+
const run = conf => {
4+
const pacote = require('../')
5+
switch (conf._[0]) {
6+
case 'resolve':
7+
case 'manifest':
8+
case 'packument':
9+
if (conf._[0] === 'resolve' && conf.long) {
10+
return pacote.manifest(conf._[1], conf).then(mani => ({
11+
resolved: mani._resolved,
12+
integrity: mani._integrity,
13+
from: mani._from,
14+
}))
15+
}
16+
return pacote[conf._[0]](conf._[1], conf)
17+
18+
case 'tarball':
19+
if (!conf._[2] || conf._[2] === '-') {
20+
return pacote.tarball.stream(conf._[1], stream => {
21+
stream.pipe(
22+
conf.testStdout ||
23+
/* istanbul ignore next */
24+
process.stdout
25+
)
26+
// make sure it resolves something falsey
27+
return stream.promise().then(() => {
28+
return false
29+
})
30+
}, conf)
31+
} else {
32+
return pacote.tarball.file(conf._[1], conf._[2], conf)
33+
}
34+
35+
case 'extract':
36+
return pacote.extract(conf._[1], conf._[2], conf)
37+
38+
default: /* istanbul ignore next */ {
39+
throw new Error(`bad command: ${conf._[0]}`)
40+
}
41+
}
42+
}
43+
44+
const version = require('../package.json').version
45+
const usage = () =>
46+
`Pacote - The JavaScript Package Handler, v${version}
47+
48+
Usage:
49+
50+
pacote resolve <spec>
51+
Resolve a specifier and output the fully resolved target
52+
Returns integrity and from if '--long' flag is set.
53+
54+
pacote manifest <spec>
55+
Fetch a manifest and print to stdout
56+
57+
pacote packument <spec>
58+
Fetch a full packument and print to stdout
59+
60+
pacote tarball <spec> [<filename>]
61+
Fetch a package tarball and save to <filename>
62+
If <filename> is missing or '-', the tarball will be streamed to stdout.
63+
64+
pacote extract <spec> <folder>
65+
Extract a package to the destination folder.
66+
67+
Configuration values all match the names of configs passed to npm, or
68+
options passed to Pacote. Additional flags for this executable:
69+
70+
--long Print an object from 'resolve', including integrity and spec.
71+
--json Print result objects as JSON rather than node's default.
72+
(This is the default if stdout is not a TTY.)
73+
--help -h Print this helpful text.
74+
75+
For example '--cache=/path/to/folder' will use that folder as the cache.
76+
`
77+
78+
const shouldJSON = (conf, result) =>
79+
conf.json ||
80+
!process.stdout.isTTY &&
81+
conf.json === undefined &&
82+
result &&
83+
typeof result === 'object'
84+
85+
const pretty = (conf, result) =>
86+
shouldJSON(conf, result) ? JSON.stringify(result, 0, 2) : result
87+
88+
let addedLogListener = false
89+
const main = args => {
90+
const conf = parse(args)
91+
if (conf.help || conf.h) {
92+
return console.log(usage())
93+
}
94+
95+
if (!addedLogListener) {
96+
process.on('log', console.error)
97+
addedLogListener = true
98+
}
99+
100+
try {
101+
return run(conf)
102+
.then(result => result && console.log(pretty(conf, result)))
103+
.catch(er => {
104+
console.error(er)
105+
process.exit(1)
106+
})
107+
} catch (er) {
108+
console.error(er.message)
109+
console.error(usage())
110+
}
111+
}
112+
113+
const parseArg = arg => {
114+
const split = arg.slice(2).split('=')
115+
const k = split.shift()
116+
const v = split.join('=')
117+
const no = /^no-/.test(k) && !v
118+
const key = (no ? k.slice(3) : k)
119+
.replace(/^tag$/, 'defaultTag')
120+
.replace(/-([a-z])/g, (_, c) => c.toUpperCase())
121+
const value = v ? v.replace(/^~/, process.env.HOME) : !no
122+
return { key, value }
123+
}
124+
125+
const parse = args => {
126+
const conf = {
127+
_: [],
128+
cache: process.env.HOME + '/.npm/_cacache',
129+
}
130+
let dashdash = false
131+
args.forEach(arg => {
132+
if (dashdash) {
133+
conf._.push(arg)
134+
} else if (arg === '--') {
135+
dashdash = true
136+
} else if (arg === '-h') {
137+
conf.help = true
138+
} else if (/^--/.test(arg)) {
139+
const { key, value } = parseArg(arg)
140+
conf[key] = value
141+
} else {
142+
conf._.push(arg)
143+
}
144+
})
145+
return conf
146+
}
147+
148+
if (module === require.main) {
149+
main(process.argv.slice(2))
150+
} else {
151+
module.exports = {
152+
main,
153+
run,
154+
usage,
155+
parseArg,
156+
parse,
157+
}
158+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
const { resolve } = require('node:path')
2+
const packlist = require('npm-packlist')
3+
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')
8+
const _ = require('./util/protected.js')
9+
const tarCreateOptions = require('./util/tar-create-options.js')
10+
11+
class DirFetcher extends Fetcher {
12+
constructor (spec, opts) {
13+
super(spec, opts)
14+
// just the fully resolved filename
15+
this.resolved = this.spec.fetchSpec
16+
17+
this.tree = opts.tree || null
18+
this.Arborist = opts.Arborist || null
19+
}
20+
21+
// exposes tarCreateOptions as public API
22+
static tarCreateOptions (manifest) {
23+
return tarCreateOptions(manifest)
24+
}
25+
26+
get types () {
27+
return ['directory']
28+
}
29+
30+
#prepareDir () {
31+
return this.manifest().then(mani => {
32+
if (!mani.scripts || !mani.scripts.prepare) {
33+
return
34+
}
35+
36+
// we *only* run prepare.
37+
// pre/post-pack is run by the npm CLI for publish and pack,
38+
// but this function is *also* run when installing git deps
39+
const stdio = this.opts.foregroundScripts ? 'inherit' : 'pipe'
40+
41+
return runScript({
42+
pkg: mani,
43+
event: 'prepare',
44+
path: this.resolved,
45+
stdio,
46+
env: {
47+
npm_package_resolved: this.resolved,
48+
npm_package_integrity: this.integrity,
49+
npm_package_json: resolve(this.resolved, 'package.json'),
50+
},
51+
})
52+
})
53+
}
54+
55+
[_.tarballFromResolved] () {
56+
if (!this.tree && !this.Arborist) {
57+
throw new Error('DirFetcher requires either a tree or an Arborist constructor to pack')
58+
}
59+
60+
const stream = new Minipass()
61+
stream.resolved = this.resolved
62+
stream.integrity = this.integrity
63+
64+
const { prefix, workspaces } = this.opts
65+
66+
// run the prepare script, get the list of files, and tar it up
67+
// pipe to the stream, and proxy errors the chain.
68+
this.#prepareDir()
69+
.then(async () => {
70+
if (!this.tree) {
71+
const arb = new this.Arborist({ path: this.resolved })
72+
this.tree = await arb.loadActual()
73+
}
74+
return packlist(this.tree, { path: this.resolved, prefix, workspaces })
75+
})
76+
.then(files => tar.c(tarCreateOptions(this.package), files)
77+
.on('error', er => stream.emit('error', er)).pipe(stream))
78+
.catch(er => stream.emit('error', er))
79+
return stream
80+
}
81+
82+
manifest () {
83+
if (this.package) {
84+
return Promise.resolve(this.package)
85+
}
86+
87+
return this[_.readPackageJson](this.resolved)
88+
.then(mani => this.package = {
89+
...mani,
90+
_integrity: this.integrity && String(this.integrity),
91+
_resolved: this.resolved,
92+
_from: this.from,
93+
})
94+
}
95+
96+
packument () {
97+
return FileFetcher.prototype.packument.apply(this)
98+
}
99+
}
100+
module.exports = DirFetcher

0 commit comments

Comments
 (0)