Skip to content

Commit aae84bf

Browse files
committed
deps: pacote@21.3.1
1 parent eb81df8 commit aae84bf

File tree

7 files changed

+36
-23
lines changed

7 files changed

+36
-23
lines changed

node_modules/pacote/lib/fetcher.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,33 +470,32 @@ const DirFetcher = require('./dir.js')
470470
const RemoteFetcher = require('./remote.js')
471471

472472
// possible values for allow: 'all', 'root', 'none'
473-
const canUseGit = (allow = 'all', isRoot = false) => {
473+
const canUse = ({ allow = 'all', isRoot = false, allowType, spec }) => {
474474
if (allow === 'all') {
475475
return true
476476
}
477477
if (allow !== 'none' && isRoot) {
478478
return true
479479
}
480-
return false
480+
throw Object.assign(
481+
new Error(`Fetching${allow === 'root' ? ' non-root' : ''} packages of type "${allowType}" have been disabled`),
482+
{
483+
code: `EALLOW${allowType.toUpperCase()}`,
484+
package: spec.toString(),
485+
}
486+
)
481487
}
482488

483489
// Get an appropriate fetcher object from a spec and options
484490
FetcherBase.get = (rawSpec, opts = {}) => {
485491
const spec = npa(rawSpec, opts.where)
486492
switch (spec.type) {
487493
case 'git':
488-
if (!canUseGit(opts.allowGit, opts._isRoot)) {
489-
throw Object.assign(
490-
new Error(`Fetching${opts.allowGit === 'root' ? ' non-root' : ''} packages from git has been disabled`),
491-
{
492-
code: 'EALLOWGIT',
493-
package: spec.toString(),
494-
}
495-
)
496-
}
494+
canUse({ allow: opts.allowGit, isRoot: opts._isRoot, allowType: 'git', spec })
497495
return new GitFetcher(spec, opts)
498496

499497
case 'remote':
498+
canUse({ allow: opts.allowRemote, isRoot: opts._isRoot, allowType: 'remote', spec })
500499
return new RemoteFetcher(spec, opts)
501500

502501
case 'version':
@@ -506,9 +505,11 @@ FetcherBase.get = (rawSpec, opts = {}) => {
506505
return new RegistryFetcher(spec.subSpec || spec, opts)
507506

508507
case 'file':
508+
canUse({ allow: opts.allowFile, isRoot: opts._isRoot, allowType: 'file', spec })
509509
return new FileFetcher(spec, opts)
510510

511511
case 'directory':
512+
canUse({ allow: opts.allowDirectory, isRoot: opts._isRoot, allowType: 'directory', spec })
512513
return new DirFetcher(spec, opts)
513514

514515
default:

node_modules/pacote/lib/git.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const _ = require('./util/protected.js')
1212
const addGitSha = require('./util/add-git-sha.js')
1313
const npm = require('./util/npm.js')
1414

15-
const hashre = /^[a-f0-9]{40}$/
15+
const hashre = /^[a-f0-9]{40,64}$/
1616

1717
// get the repository url.
1818
// prefer https if there's auth, since ssh will drop that.
@@ -25,6 +25,14 @@ const repoUrl = (h, opts) =>
2525
// add git+ to the url, but only one time.
2626
const addGitPlus = url => url && `git+${url}`.replace(/^(git\+)+/, 'git+')
2727

28+
const checkoutError = (expected, found) => {
29+
const err = new Error(`Commit mismatch: expected SHA ${expected} and cloned HEAD ${found}`)
30+
err.code = 'EGITCHECKOUT'
31+
err.sha = expected
32+
err.head = found
33+
return err
34+
}
35+
2836
class GitFetcher extends Fetcher {
2937
constructor (spec, opts) {
3038
super(spec, opts)
@@ -245,7 +253,7 @@ class GitFetcher extends Fetcher {
245253
pkgid: `git:${nameat}${this.resolved}`,
246254
resolved: this.resolved,
247255
integrity: null, // it'll always be different, if we have one
248-
}).extract(tmp).then(() => handler(tmp), er => {
256+
}).extract(tmp).then(() => handler(`${tmp}${this.spec.gitSubdir || ''}`), er => {
249257
// fall back to ssh download if tarball fails
250258
if (er.constructor.name.match(/^Http/)) {
251259
return this.#clone(handler, false)
@@ -259,11 +267,15 @@ class GitFetcher extends Fetcher {
259267
h ? this.#cloneHosted(ref, tmp)
260268
: this.#cloneRepo(this.spec.fetchSpec, ref, tmp)
261269
)
270+
// if we already have a resolved sha ensure it doesn't change
271+
if (this.resolvedSha && this.resolvedSha !== sha) {
272+
throw checkoutError(this.resolvedSha, sha)
273+
}
262274
this.resolvedSha = sha
263275
if (!this.resolved) {
264276
await this.#addGitSha(sha)
265277
}
266-
return handler(tmp)
278+
return handler(`${tmp}${this.spec.gitSubdir || ''}`)
267279
})
268280
}
269281

node_modules/pacote/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pacote",
3-
"version": "21.1.0",
3+
"version": "21.3.1",
44
"description": "JavaScript package downloader",
55
"author": "GitHub Inc.",
66
"bin": {

package-lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"npm-registry-fetch": "^19.1.1",
136136
"npm-user-validate": "^4.0.0",
137137
"p-map": "^7.0.4",
138-
"pacote": "^21.1.0",
138+
"pacote": "^21.3.1",
139139
"parse-conflict-json": "^5.0.1",
140140
"proc-log": "^6.1.0",
141141
"qrcode-terminal": "^0.12.0",
@@ -9139,9 +9139,9 @@
91399139
"license": "BlueOak-1.0.0"
91409140
},
91419141
"node_modules/pacote": {
9142-
"version": "21.1.0",
9143-
"resolved": "https://registry.npmjs.org/pacote/-/pacote-21.1.0.tgz",
9144-
"integrity": "sha512-WF/PwrImIIVaLmtuCeO5L7n6DA0ZGCqmDPO/XbNjZgNUX+2O5z4f4Wdmu6erBWNICkl3ftKJvit2eIVcpegRRw==",
9142+
"version": "21.3.1",
9143+
"resolved": "https://registry.npmjs.org/pacote/-/pacote-21.3.1.tgz",
9144+
"integrity": "sha512-O0EDXi85LF4AzdjG74GUwEArhdvawi/YOHcsW6IijKNj7wm8IvEWNF5GnfuxNpQ/ZpO3L37+v8hqdVh8GgWYhg==",
91459145
"inBundle": true,
91469146
"license": "ISC",
91479147
"dependencies": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"npm-registry-fetch": "^19.1.1",
103103
"npm-user-validate": "^4.0.0",
104104
"p-map": "^7.0.4",
105-
"pacote": "^21.1.0",
105+
"pacote": "^21.3.1",
106106
"parse-conflict-json": "^5.0.1",
107107
"proc-log": "^6.1.0",
108108
"qrcode-terminal": "^0.12.0",

test/lib/commands/install.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ t.test('exec commands', async t => {
247247
npm.exec('install', ['npm/npm']),
248248
{
249249
code: 'EALLOWGIT',
250-
message: 'Fetching packages from git has been disabled',
250+
message: 'Fetching packages of type "git" have been disabled',
251251
package: 'github:npm/npm',
252252
}
253253
)
@@ -267,7 +267,7 @@ t.test('exec commands', async t => {
267267
})
268268
await t.rejects(
269269
npm.exec('install', ['./abbrev']),
270-
/Fetching packages from git has been disabled/
270+
/Fetching packages of type "git" have been disabled/
271271
)
272272
})
273273
})

test/lib/commands/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,6 @@ t.test('allow-git=none', async t => {
837837
await t.rejects(view.exec(['npm/npm']), {
838838
code: 'EALLOWGIT',
839839
package: 'github:npm/npm',
840-
message: 'Fetching packages from git has been disabled',
840+
message: 'Fetching packages of type "git" have been disabled',
841841
})
842842
})

0 commit comments

Comments
 (0)