Skip to content

Commit 41d19e1

Browse files
committed
pacote: get rid of legacy pacoteOpts
1 parent 8a56fa3 commit 41d19e1

File tree

9 files changed

+42
-212
lines changed

9 files changed

+42
-212
lines changed

lib/cache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const finished = BB.promisify(require('mississippi').finished)
99
const log = require('npmlog')
1010
const npa = require('npm-package-arg')
1111
const npm = require('./npm.js')
12+
const npmConfig = require('./config/figgy-config.js')
1213
const output = require('./utils/output.js')
1314
const pacote = require('pacote')
14-
const pacoteOpts = require('./config/pacote')
1515
const path = require('path')
1616
const rm = BB.promisify(require('./utils/gently-rm.js'))
1717
const unbuild = BB.promisify(npm.commands.unbuild)
@@ -107,7 +107,7 @@ function add (args, where) {
107107
log.verbose('cache add', 'spec', spec)
108108
if (!spec) return BB.reject(new Error(usage))
109109
log.silly('cache add', 'parsed spec', spec)
110-
return finished(pacote.tarball.stream(spec, pacoteOpts({where})).resume())
110+
return finished(pacote.tarball.stream(spec, npmConfig({where})).resume())
111111
}
112112

113113
cache.verify = verify
@@ -131,7 +131,7 @@ function verify () {
131131
cache.unpack = unpack
132132
function unpack (pkg, ver, unpackTarget, dmode, fmode, uid, gid) {
133133
return unbuild([unpackTarget], true).then(() => {
134-
const opts = pacoteOpts({dmode, fmode, uid, gid, offline: true})
134+
const opts = npmConfig({dmode, fmode, uid, gid, offline: true})
135135
return pacote.extract(npa.resolve(pkg, ver), unpackTarget, opts)
136136
})
137137
}

lib/ci.js

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,19 @@
11
'use strict'
22

33
const Installer = require('libcipm')
4-
const lifecycleOpts = require('./config/lifecycle.js')
5-
const npm = require('./npm.js')
4+
const npmConfig = require('./config/figgy-config.js')
65
const npmlog = require('npmlog')
7-
const pacoteOpts = require('./config/pacote.js')
86

97
ci.usage = 'npm ci'
108

119
ci.completion = (cb) => cb(null, [])
1210

13-
Installer.CipmConfig.impl(npm.config, {
14-
get: npm.config.get,
15-
set: npm.config.set,
16-
toLifecycle (moreOpts) {
17-
return lifecycleOpts(moreOpts)
18-
},
19-
toPacote (moreOpts) {
20-
return pacoteOpts(moreOpts)
21-
}
22-
})
23-
2411
module.exports = ci
2512
function ci (args, cb) {
26-
return new Installer({
27-
config: npm.config,
28-
log: npmlog
29-
})
30-
.run()
31-
.then(
32-
(details) => {
33-
npmlog.disableProgress()
34-
console.log(`added ${details.pkgCount} packages in ${
35-
details.runTime / 1000
36-
}s`)
37-
}
38-
)
39-
.then(() => cb(), cb)
13+
return new Installer(npmConfig({ log: npmlog })).run().then(details => {
14+
npmlog.disableProgress()
15+
console.log(`added ${details.pkgCount} packages in ${
16+
details.runTime / 1000
17+
}s`)
18+
}).then(() => cb(), cb)
4019
}

lib/config/figgy-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function mkConfig (...providers) {
3333
dirPacker: pack.packGitDep,
3434
hashAlgorithm: 'sha1',
3535
includeDeprecated: false,
36+
log,
3637
'npm-session': npmSession,
3738
'project-scope': npm.projectScope,
3839
refer: npm.refer,

lib/config/pacote.js

Lines changed: 0 additions & 142 deletions
This file was deleted.

lib/fetch-package-metadata.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const rimraf = require('rimraf')
88
const validate = require('aproba')
99
const npa = require('npm-package-arg')
1010
const npm = require('./npm')
11+
const npmConfig = require('./config/figgy-config.js')
1112
const npmlog = require('npmlog')
1213
const limit = require('call-limit')
1314
const tempFilename = require('./utils/temp-filename')
1415
const pacote = require('pacote')
15-
let pacoteOpts
1616
const isWindows = require('./utils/is-windows.js')
1717

1818
function andLogAndFinish (spec, tracker, done) {
@@ -52,10 +52,7 @@ function fetchPackageMetadata (spec, where, opts, done) {
5252
err.code = 'EWINDOWSPATH'
5353
return logAndFinish(err)
5454
}
55-
if (!pacoteOpts) {
56-
pacoteOpts = require('./config/pacote')
57-
}
58-
pacote.manifest(dep, pacoteOpts({
55+
pacote.manifest(dep, npmConfig({
5956
annotate: true,
6057
fullMetadata: opts.fullMetadata,
6158
log: tracker || npmlog,
@@ -85,9 +82,6 @@ function fetchPackageMetadata (spec, where, opts, done) {
8582
module.exports.addBundled = addBundled
8683
function addBundled (pkg, next) {
8784
validate('OF', arguments)
88-
if (!pacoteOpts) {
89-
pacoteOpts = require('./config/pacote')
90-
}
9185
if (pkg._bundled !== undefined) return next(null, pkg)
9286

9387
if (!pkg.bundleDependencies && pkg._requested.type !== 'directory') return next(null, pkg)
@@ -101,7 +95,7 @@ function addBundled (pkg, next) {
10195
}
10296
pkg._bundled = null
10397
const target = tempFilename('unpack')
104-
const opts = pacoteOpts({integrity: pkg._integrity})
98+
const opts = npmConfig({integrity: pkg._integrity})
10599
pacote.extract(pkg._resolved || pkg._requested || npa.resolve(pkg.name, pkg.version), target, opts).then(() => {
106100
log.silly('addBundled', 'read tarball')
107101
readPackageTree(target, (err, tree) => {

lib/install/action/extract.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
const BB = require('bluebird')
44

5+
const figgyPudding = require('figgy-pudding')
56
const stat = BB.promisify(require('graceful-fs').stat)
67
const gentlyRm = BB.promisify(require('../../utils/gently-rm.js'))
78
const mkdirp = BB.promisify(require('mkdirp'))
89
const moduleStagingPath = require('../module-staging-path.js')
910
const move = require('../../utils/move.js')
1011
const npa = require('npm-package-arg')
1112
const npm = require('../../npm.js')
13+
const npmConfig = require('../../config/figgy-config.js')
1214
const packageId = require('../../utils/package-id.js')
13-
let pacoteOpts
1415
const path = require('path')
1516
const localWorker = require('./extract-worker.js')
1617
const workerFarm = require('worker-farm')
@@ -19,19 +20,12 @@ const isRegistry = require('../../utils/is-registry.js')
1920
const WORKER_PATH = require.resolve('./extract-worker.js')
2021
let workers
2122

22-
// NOTE: temporarily disabled on non-OSX due to ongoing issues:
23-
//
24-
// * Seems to make Windows antivirus issues much more common
25-
// * Messes with Docker (I think)
26-
//
27-
// There are other issues that should be fixed that affect OSX too:
28-
//
29-
// * Logging is messed up right now because pacote does its own thing
30-
// * Global deduplication in pacote breaks due to multiple procs
31-
//
32-
// As these get fixed, we can start experimenting with re-enabling it
33-
// at least on some platforms.
34-
const ENABLE_WORKERS = process.platform === 'darwin'
23+
const ExtractOpts = figgyPudding({
24+
log: {}
25+
}, { other () { return true } })
26+
27+
// Disabled for now. Re-enable someday. Just not today.
28+
const ENABLE_WORKERS = false
3529

3630
extract.init = () => {
3731
if (ENABLE_WORKERS) {
@@ -53,10 +47,7 @@ module.exports = extract
5347
function extract (staging, pkg, log) {
5448
log.silly('extract', packageId(pkg))
5549
const extractTo = moduleStagingPath(staging, pkg)
56-
if (!pacoteOpts) {
57-
pacoteOpts = require('../../config/pacote')
58-
}
59-
const opts = pacoteOpts({
50+
let opts = ExtractOpts(npmConfig()).concat({
6051
integrity: pkg.package._integrity,
6152
resolved: pkg.package._resolved
6253
})
@@ -72,9 +63,18 @@ function extract (staging, pkg, log) {
7263
args[0] = spec.raw
7364
if (ENABLE_WORKERS && (isRegistry(spec) || spec.type === 'remote')) {
7465
// We can't serialize these options
75-
opts.loglevel = opts.log.level
76-
opts.log = null
77-
opts.dirPacker = null
66+
opts = opts.concat({
67+
loglevel: opts.log.level,
68+
log: null,
69+
dirPacker: null,
70+
Promise: null,
71+
_events: null,
72+
_eventsCount: null,
73+
list: null,
74+
sources: null,
75+
_maxListeners: null,
76+
root: null
77+
})
7878
// workers will run things in parallel!
7979
launcher = workers
8080
try {

lib/install/action/fetch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
const BB = require('bluebird')
44

55
const finished = BB.promisify(require('mississippi').finished)
6+
const npmConfig = require('../../config/figgy-config.js')
67
const packageId = require('../../utils/package-id.js')
78
const pacote = require('pacote')
8-
const pacoteOpts = require('../../config/pacote')
99

1010
module.exports = fetch
1111
function fetch (staging, pkg, log, next) {
1212
log.silly('fetch', packageId(pkg))
13-
const opts = pacoteOpts({integrity: pkg.package._integrity})
13+
const opts = npmConfig({integrity: pkg.package._integrity})
1414
return finished(pacote.tarball.stream(pkg.package._requested, opts))
1515
.then(() => next(), next)
1616
}

lib/pack.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const lifecycle = BB.promisify(require('./utils/lifecycle'))
1818
const log = require('npmlog')
1919
const move = require('move-concurrently')
2020
const npm = require('./npm')
21+
const npmConfig = require('./config/figgy-config.js')
2122
const output = require('./utils/output')
2223
const pacote = require('pacote')
23-
const pacoteOpts = require('./config/pacote')
2424
const path = require('path')
2525
const PassThrough = require('stream').PassThrough
2626
const pathIsInside = require('path-is-inside')
@@ -88,8 +88,8 @@ function pack_ (pkg, dir) {
8888
}
8989

9090
function packFromPackage (arg, target, filename) {
91-
const opts = pacoteOpts()
92-
return pacote.tarball.toFile(arg, target, pacoteOpts())
91+
const opts = npmConfig()
92+
return pacote.tarball.toFile(arg, target, opts)
9393
.then(() => cacache.tmp.withTmp(npm.tmp, {tmpPrefix: 'unpacking'}, (tmp) => {
9494
const tmpTarget = path.join(tmp, filename)
9595
return pacote.extract(arg, tmpTarget, opts)

0 commit comments

Comments
 (0)