pacote 14.0.0 → 15.0.0

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.
Files changed (2) hide show
  1. package/lib/fetcher.js +13 -49
  2. package/package.json +5 -9
package/lib/fetcher.js CHANGED
@@ -7,10 +7,10 @@ const npa = require('npm-package-arg')
7
7
  const ssri = require('ssri')
8
8
  const { promisify } = require('util')
9
9
  const { basename, dirname } = require('path')
10
- const rimraf = promisify(require('rimraf'))
11
10
  const tar = require('tar')
12
11
  const log = require('proc-log')
13
12
  const retry = require('promise-retry')
13
+ const fs = require('fs/promises')
14
14
  const fsm = require('fs-minipass')
15
15
  const cacache = require('cacache')
16
16
  const isPackageBin = require('./util/is-package-bin.js')
@@ -20,20 +20,11 @@ const readPackageJsonFast = require('read-package-json-fast')
20
20
  const readPackageJson = promisify(require('read-package-json'))
21
21
  const Minipass = require('minipass')
22
22
 
23
- // we only change ownership on unix platforms, and only if uid is 0
24
- const selfOwner = process.getuid && process.getuid() === 0 ? {
25
- uid: 0,
26
- gid: process.getgid(),
27
- } : null
28
- const chownr = selfOwner ? promisify(require('chownr')) : null
29
- const inferOwner = selfOwner ? require('infer-owner') : null
30
- const mkdirp = require('mkdirp')
31
23
  const cacheDir = require('./util/cache-dir.js')
32
24
 
33
25
  // Private methods.
34
26
  // Child classes should not have to override these.
35
27
  // Users should never call them.
36
- const _chown = Symbol('_chown')
37
28
  const _extract = Symbol('_extract')
38
29
  const _mkdir = Symbol('_mkdir')
39
30
  const _empty = Symbol('_empty')
@@ -359,44 +350,21 @@ class FetcherBase {
359
350
  return cacache.rm.content(this.cache, this.integrity, this.opts)
360
351
  }
361
352
 
362
- async [_chown] (path, uid, gid) {
363
- return selfOwner && (selfOwner.gid !== gid || selfOwner.uid !== uid)
364
- ? chownr(path, uid, gid)
365
- : /* istanbul ignore next - we don't test in root-owned folders */ null
366
- }
367
-
368
353
  [_empty] (path) {
369
354
  return getContents({ path, depth: 1 }).then(contents => Promise.all(
370
- contents.map(entry => rimraf(entry))))
355
+ contents.map(entry => fs.rm(entry, { recursive: true, force: true }))))
371
356
  }
372
357
 
373
- [_mkdir] (dest) {
374
- // if we're bothering to do owner inference, then do it.
375
- // otherwise just make the dir, and return an empty object.
376
- // always empty the dir dir to start with, but do so
377
- // _after_ inferring the owner, in case there's an existing folder
378
- // there that we would want to preserve which differs from the
379
- // parent folder (rare, but probably happens sometimes).
380
- return !inferOwner
381
- ? this[_empty](dest).then(() => mkdirp(dest)).then(() => ({}))
382
- : inferOwner(dest).then(({ uid, gid }) =>
383
- this[_empty](dest)
384
- .then(() => mkdirp(dest))
385
- .then(made => {
386
- // ignore the || dest part in coverage. It's there to handle
387
- // race conditions where the dir may be made by someone else
388
- // after being removed by us.
389
- const dir = made || /* istanbul ignore next */ dest
390
- return this[_chown](dir, uid, gid)
391
- })
392
- .then(() => ({ uid, gid })))
358
+ async [_mkdir] (dest) {
359
+ await this[_empty](dest)
360
+ return await fs.mkdir(dest, { recursive: true })
393
361
  }
394
362
 
395
363
  // extraction is always the same. the only difference is where
396
364
  // the tarball comes from.
397
- extract (dest) {
398
- return this[_mkdir](dest).then(({ uid, gid }) =>
399
- this.tarballStream(tarball => this[_extract](dest, tarball, uid, gid)))
365
+ async extract (dest) {
366
+ await this[_mkdir](dest)
367
+ return this.tarballStream((tarball) => this[_extract](dest, tarball))
400
368
  }
401
369
 
402
370
  [_toFile] (dest) {
@@ -414,18 +382,14 @@ class FetcherBase {
414
382
  }
415
383
 
416
384
  // don't use this[_mkdir] because we don't want to rimraf anything
417
- tarballFile (dest) {
385
+ async tarballFile (dest) {
418
386
  const dir = dirname(dest)
419
- return !inferOwner
420
- ? mkdirp(dir).then(() => this[_toFile](dest))
421
- : inferOwner(dest).then(({ uid, gid }) =>
422
- mkdirp(dir).then(made => this[_toFile](dest)
423
- .then(res => this[_chown](made || dir, uid, gid)
424
- .then(() => res))))
387
+ await fs.mkdir(dir, { recursive: true })
388
+ return this[_toFile](dest)
425
389
  }
426
390
 
427
- [_extract] (dest, tarball, uid, gid) {
428
- const extractor = tar.x(this[_tarxOptions]({ cwd: dest, uid, gid }))
391
+ [_extract] (dest, tarball) {
392
+ const extractor = tar.x(this[_tarxOptions]({ cwd: dest }))
429
393
  const p = new Promise((resolve, reject) => {
430
394
  extractor.on('end', () => {
431
395
  resolve({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacote",
3
- "version": "14.0.0",
3
+ "version": "15.0.0",
4
4
  "description": "JavaScript package downloader",
5
5
  "author": "GitHub Inc.",
6
6
  "bin": {
@@ -27,7 +27,7 @@
27
27
  "devDependencies": {
28
28
  "@npmcli/arborist": "^6.0.0 || ^6.0.0-pre.0",
29
29
  "@npmcli/eslint-config": "^3.1.0",
30
- "@npmcli/template-oss": "4.4.4",
30
+ "@npmcli/template-oss": "4.5.1",
31
31
  "hosted-git-info": "^5.0.0",
32
32
  "mutate-fs": "^2.1.1",
33
33
  "nock": "^13.2.4",
@@ -48,12 +48,9 @@
48
48
  "@npmcli/installed-package-contents": "^1.0.7",
49
49
  "@npmcli/promise-spawn": "^3.0.0",
50
50
  "@npmcli/run-script": "^4.1.0",
51
- "cacache": "^16.0.0",
52
- "chownr": "^2.0.0",
51
+ "cacache": "^17.0.0",
53
52
  "fs-minipass": "^2.1.0",
54
- "infer-owner": "^1.0.4",
55
53
  "minipass": "^3.1.6",
56
- "mkdirp": "^1.0.4",
57
54
  "npm-package-arg": "^9.0.0",
58
55
  "npm-packlist": "^7.0.0",
59
56
  "npm-pick-manifest": "^7.0.0",
@@ -61,8 +58,7 @@
61
58
  "proc-log": "^2.0.0",
62
59
  "promise-retry": "^2.0.1",
63
60
  "read-package-json": "^5.0.0",
64
- "read-package-json-fast": "^2.0.3",
65
- "rimraf": "^3.0.2",
61
+ "read-package-json-fast": "^3.0.0",
66
62
  "ssri": "^9.0.0",
67
63
  "tar": "^6.1.11"
68
64
  },
@@ -75,7 +71,7 @@
75
71
  },
76
72
  "templateOSS": {
77
73
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
78
- "version": "4.4.4",
74
+ "version": "4.5.1",
79
75
  "windowsCI": false
80
76
  }
81
77
  }