summaryrefslogtreecommitdiff
path: root/deps/npm/lib/install
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/install')
-rw-r--r--deps/npm/lib/install/action/extract-worker.js10
-rw-r--r--deps/npm/lib/install/action/extract.js43
-rw-r--r--deps/npm/lib/install/action/fetch.js4
-rw-r--r--deps/npm/lib/install/audit.js141
-rw-r--r--deps/npm/lib/install/is-only-dev.js1
-rw-r--r--deps/npm/lib/install/is-only-optional.js1
6 files changed, 101 insertions, 99 deletions
diff --git a/deps/npm/lib/install/action/extract-worker.js b/deps/npm/lib/install/action/extract-worker.js
index 2b082b4a57..225e5b4aea 100644
--- a/deps/npm/lib/install/action/extract-worker.js
+++ b/deps/npm/lib/install/action/extract-worker.js
@@ -3,16 +3,16 @@
const BB = require('bluebird')
const extract = require('pacote/extract')
-const npmlog = require('npmlog')
+// const npmlog = require('npmlog')
module.exports = (args, cb) => {
const parsed = typeof args === 'string' ? JSON.parse(args) : args
const spec = parsed[0]
const extractTo = parsed[1]
const opts = parsed[2]
- if (!opts.log) {
- opts.log = npmlog
- }
- opts.log.level = opts.loglevel || opts.log.level
+ // if (!opts.log) {
+ // opts.log = npmlog
+ // }
+ // opts.log.level = opts.loglevel || opts.log.level
BB.resolve(extract(spec, extractTo, opts)).nodeify(cb)
}
diff --git a/deps/npm/lib/install/action/extract.js b/deps/npm/lib/install/action/extract.js
index e8d7a6c4f6..c1c17cdf6c 100644
--- a/deps/npm/lib/install/action/extract.js
+++ b/deps/npm/lib/install/action/extract.js
@@ -2,6 +2,7 @@
const BB = require('bluebird')
+const figgyPudding = require('figgy-pudding')
const stat = BB.promisify(require('graceful-fs').stat)
const gentlyRm = BB.promisify(require('../../utils/gently-rm.js'))
const mkdirp = BB.promisify(require('mkdirp'))
@@ -9,8 +10,8 @@ const moduleStagingPath = require('../module-staging-path.js')
const move = require('../../utils/move.js')
const npa = require('npm-package-arg')
const npm = require('../../npm.js')
+let npmConfig
const packageId = require('../../utils/package-id.js')
-let pacoteOpts
const path = require('path')
const localWorker = require('./extract-worker.js')
const workerFarm = require('worker-farm')
@@ -19,19 +20,12 @@ const isRegistry = require('../../utils/is-registry.js')
const WORKER_PATH = require.resolve('./extract-worker.js')
let workers
-// NOTE: temporarily disabled on non-OSX due to ongoing issues:
-//
-// * Seems to make Windows antivirus issues much more common
-// * Messes with Docker (I think)
-//
-// There are other issues that should be fixed that affect OSX too:
-//
-// * Logging is messed up right now because pacote does its own thing
-// * Global deduplication in pacote breaks due to multiple procs
-//
-// As these get fixed, we can start experimenting with re-enabling it
-// at least on some platforms.
-const ENABLE_WORKERS = process.platform === 'darwin'
+const ExtractOpts = figgyPudding({
+ log: {}
+}, { other () { return true } })
+
+// Disabled for now. Re-enable someday. Just not today.
+const ENABLE_WORKERS = false
extract.init = () => {
if (ENABLE_WORKERS) {
@@ -53,10 +47,10 @@ module.exports = extract
function extract (staging, pkg, log) {
log.silly('extract', packageId(pkg))
const extractTo = moduleStagingPath(staging, pkg)
- if (!pacoteOpts) {
- pacoteOpts = require('../../config/pacote')
+ if (!npmConfig) {
+ npmConfig = require('../../config/figgy-config.js')
}
- const opts = pacoteOpts({
+ let opts = ExtractOpts(npmConfig()).concat({
integrity: pkg.package._integrity,
resolved: pkg.package._resolved
})
@@ -72,9 +66,18 @@ function extract (staging, pkg, log) {
args[0] = spec.raw
if (ENABLE_WORKERS && (isRegistry(spec) || spec.type === 'remote')) {
// We can't serialize these options
- opts.loglevel = opts.log.level
- opts.log = null
- opts.dirPacker = null
+ opts = opts.concat({
+ loglevel: opts.log.level,
+ log: null,
+ dirPacker: null,
+ Promise: null,
+ _events: null,
+ _eventsCount: null,
+ list: null,
+ sources: null,
+ _maxListeners: null,
+ root: null
+ })
// workers will run things in parallel!
launcher = workers
try {
diff --git a/deps/npm/lib/install/action/fetch.js b/deps/npm/lib/install/action/fetch.js
index 5ad34e29dd..346194e516 100644
--- a/deps/npm/lib/install/action/fetch.js
+++ b/deps/npm/lib/install/action/fetch.js
@@ -3,14 +3,14 @@
const BB = require('bluebird')
const finished = BB.promisify(require('mississippi').finished)
+const npmConfig = require('../../config/figgy-config.js')
const packageId = require('../../utils/package-id.js')
const pacote = require('pacote')
-const pacoteOpts = require('../../config/pacote')
module.exports = fetch
function fetch (staging, pkg, log, next) {
log.silly('fetch', packageId(pkg))
- const opts = pacoteOpts({integrity: pkg.package._integrity})
+ const opts = npmConfig({integrity: pkg.package._integrity})
return finished(pacote.tarball.stream(pkg.package._requested, opts))
.then(() => next(), next)
}
diff --git a/deps/npm/lib/install/audit.js b/deps/npm/lib/install/audit.js
index f372b425a6..f5bc5ae1a9 100644
--- a/deps/npm/lib/install/audit.js
+++ b/deps/npm/lib/install/audit.js
@@ -7,118 +7,115 @@ exports.printInstallReport = printInstallReport
exports.printParseableReport = printParseableReport
exports.printFullReport = printFullReport
-const Bluebird = require('bluebird')
const auditReport = require('npm-audit-report')
+const npmConfig = require('../config/figgy-config.js')
+const figgyPudding = require('figgy-pudding')
const treeToShrinkwrap = require('../shrinkwrap.js').treeToShrinkwrap
const packageId = require('../utils/package-id.js')
const output = require('../utils/output.js')
const npm = require('../npm.js')
const qw = require('qw')
-const registryFetch = require('npm-registry-fetch')
-const zlib = require('zlib')
-const gzip = Bluebird.promisify(zlib.gzip)
-const log = require('npmlog')
+const regFetch = require('npm-registry-fetch')
const perf = require('../utils/perf.js')
-const url = require('url')
const npa = require('npm-package-arg')
const uuid = require('uuid')
const ssri = require('ssri')
const cloneDeep = require('lodash.clonedeep')
-const pacoteOpts = require('../config/pacote.js')
// used when scrubbing module names/specifiers
const runId = uuid.v4()
+const InstallAuditConfig = figgyPudding({
+ color: {},
+ json: {},
+ unicode: {}
+}, {
+ other (key) {
+ return /:registry$/.test(key)
+ }
+})
+
function submitForInstallReport (auditData) {
- const cfg = npm.config // avoid the no-dynamic-lookups test
- const scopedRegistries = cfg.keys.filter(_ => /:registry$/.test(_)).map(_ => cfg.get(_))
- perf.emit('time', 'audit compress')
- // TODO: registryFetch will be adding native support for `Content-Encoding: gzip` at which point
- // we'll pass in something like `gzip: true` and not need to JSON stringify, gzip or headers.
- return gzip(JSON.stringify(auditData)).then(body => {
- perf.emit('timeEnd', 'audit compress')
- log.info('audit', 'Submitting payload of ' + body.length + 'bytes')
- scopedRegistries.forEach(reg => {
- // we don't care about the response so destroy the stream if we can, or leave it flowing
- // so it can eventually finish and clean up after itself
- fetchAudit(url.resolve(reg, '/-/npm/v1/security/audits/quick'))
- .then(_ => {
- _.body.on('error', () => {})
- if (_.body.destroy) {
- _.body.destroy()
- } else {
- _.body.resume()
- }
- }, _ => {})
- })
- perf.emit('time', 'audit submit')
- return fetchAudit('/-/npm/v1/security/audits/quick', body).then(response => {
- perf.emit('timeEnd', 'audit submit')
- perf.emit('time', 'audit body')
- return response.json()
- }).then(result => {
- perf.emit('timeEnd', 'audit body')
- return result
- })
+ const opts = InstallAuditConfig(npmConfig())
+ const scopedRegistries = [...opts.keys()].filter(
+ k => /:registry$/.test(k)
+ ).map(k => opts[k])
+ scopedRegistries.forEach(registry => {
+ // we don't care about the response so destroy the stream if we can, or leave it flowing
+ // so it can eventually finish and clean up after itself
+ regFetch('/-/npm/v1/security/audits/quick', opts.concat({
+ method: 'POST',
+ registry,
+ gzip: true,
+ body: auditData
+ })).then(_ => {
+ _.body.on('error', () => {})
+ if (_.body.destroy) {
+ _.body.destroy()
+ } else {
+ _.body.resume()
+ }
+ }, _ => {})
})
-}
-
-function submitForFullReport (auditData) {
- perf.emit('time', 'audit compress')
- // TODO: registryFetch will be adding native support for `Content-Encoding: gzip` at which point
- // we'll pass in something like `gzip: true` and not need to JSON stringify, gzip or headers.
- return gzip(JSON.stringify(auditData)).then(body => {
- perf.emit('timeEnd', 'audit compress')
- log.info('audit', 'Submitting payload of ' + body.length + ' bytes')
- perf.emit('time', 'audit submit')
- return fetchAudit('/-/npm/v1/security/audits', body).then(response => {
- perf.emit('timeEnd', 'audit submit')
- perf.emit('time', 'audit body')
- return response.json()
- }).then(result => {
- perf.emit('timeEnd', 'audit body')
- result.runId = runId
- return result
- })
+ perf.emit('time', 'audit submit')
+ return regFetch('/-/npm/v1/security/audits/quick', opts.concat({
+ method: 'POST',
+ gzip: true,
+ body: auditData
+ })).then(response => {
+ perf.emit('timeEnd', 'audit submit')
+ perf.emit('time', 'audit body')
+ return response.json()
+ }).then(result => {
+ perf.emit('timeEnd', 'audit body')
+ return result
})
}
-function fetchAudit (href, body) {
- const opts = pacoteOpts()
- return registryFetch(href, {
+function submitForFullReport (auditData) {
+ perf.emit('time', 'audit submit')
+ const opts = InstallAuditConfig(npmConfig())
+ return regFetch('/-/npm/v1/security/audits', opts.concat({
method: 'POST',
- headers: { 'content-encoding': 'gzip', 'content-type': 'application/json' },
- config: npm.config,
- npmSession: opts.npmSession,
- projectScope: npm.projectScope,
- log: log,
- body: body
+ gzip: true,
+ body: auditData
+ })).then(response => {
+ perf.emit('timeEnd', 'audit submit')
+ perf.emit('time', 'audit body')
+ return response.json()
+ }).then(result => {
+ perf.emit('timeEnd', 'audit body')
+ result.runId = runId
+ return result
})
}
function printInstallReport (auditResult) {
+ const opts = InstallAuditConfig(npmConfig())
return auditReport(auditResult, {
reporter: 'install',
- withColor: npm.color,
- withUnicode: npm.config.get('unicode')
+ withColor: opts.color,
+ withUnicode: opts.unicode
}).then(result => output(result.report))
}
function printFullReport (auditResult) {
+ const opts = InstallAuditConfig(npmConfig())
return auditReport(auditResult, {
log: output,
- reporter: npm.config.get('json') ? 'json' : 'detail',
- withColor: npm.color,
- withUnicode: npm.config.get('unicode')
+ reporter: opts.json ? 'json' : 'detail',
+ withColor: opts.color,
+ withUnicode: opts.unicode
}).then(result => output(result.report))
}
function printParseableReport (auditResult) {
+ const opts = InstallAuditConfig(npmConfig())
return auditReport(auditResult, {
log: output,
reporter: 'parseable',
- withColor: npm.color,
- withUnicode: npm.config.get('unicode')
+ withColor: opts.color,
+ withUnicode: opts.unicode
}).then(result => output(result.report))
}
diff --git a/deps/npm/lib/install/is-only-dev.js b/deps/npm/lib/install/is-only-dev.js
index ef41e8ad1a..2877c61a22 100644
--- a/deps/npm/lib/install/is-only-dev.js
+++ b/deps/npm/lib/install/is-only-dev.js
@@ -28,6 +28,7 @@ function andIsOnlyDev (name, seen) {
return isDev && !isProd
} else {
if (seen.has(req)) return true
+ seen = new Set(seen)
seen.add(req)
return isOnlyDev(req, seen)
}
diff --git a/deps/npm/lib/install/is-only-optional.js b/deps/npm/lib/install/is-only-optional.js
index 72d6f065e6..f1b731578d 100644
--- a/deps/npm/lib/install/is-only-optional.js
+++ b/deps/npm/lib/install/is-only-optional.js
@@ -10,6 +10,7 @@ function isOptional (node, seen) {
if (seen.has(node) || node.requiredBy.length === 0) {
return false
}
+ seen = new Set(seen)
seen.add(node)
const swOptional = node.fromShrinkwrap && node.package._optional
return node.requiredBy.every(function (req) {