summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/libcipm/lib
diff options
context:
space:
mode:
authorKat Marchán <kzm@zkat.tech>2019-01-29 14:43:00 -0800
committerMyles Borins <mylesborins@google.com>2019-02-12 00:06:29 -0800
commit43dd49c9782848c25e5b03448c8a0f923f13c158 (patch)
treef7ac5d645019b2b844f26be66c291bbae734d097 /deps/npm/node_modules/libcipm/lib
parentb361f9577fbd72e518438d3fa0b01f7d34d814a5 (diff)
downloadandroid-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.tar.gz
android-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.tar.bz2
android-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.zip
deps: upgrade npm to 6.7.0
PR-URL: https://github.com/nodejs/node/pull/25804 Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/libcipm/lib')
-rw-r--r--deps/npm/node_modules/libcipm/lib/config/lifecycle-opts.js29
-rw-r--r--deps/npm/node_modules/libcipm/lib/config/npm-config.js72
-rw-r--r--deps/npm/node_modules/libcipm/lib/config/pacote-opts.js135
-rw-r--r--deps/npm/node_modules/libcipm/lib/extract.js51
-rw-r--r--deps/npm/node_modules/libcipm/lib/worker.js6
5 files changed, 76 insertions, 217 deletions
diff --git a/deps/npm/node_modules/libcipm/lib/config/lifecycle-opts.js b/deps/npm/node_modules/libcipm/lib/config/lifecycle-opts.js
deleted file mode 100644
index 7d57459779..0000000000
--- a/deps/npm/node_modules/libcipm/lib/config/lifecycle-opts.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict'
-
-const log = require('npmlog')
-
-module.exports = lifecycleOpts
-function lifecycleOpts (opts) {
- const objConfig = {}
- for (const key of opts.keys()) {
- const val = opts.get(key)
- if (val != null) {
- objConfig[key] = val
- }
- }
- return {
- config: objConfig,
- scriptShell: opts.get('script-shell'),
- force: opts.get('force'),
- user: opts.get('user'),
- group: opts.get('group'),
- ignoreScripts: opts.get('ignore-scripts'),
- ignorePrepublish: opts.get('ignore-prepublish'),
- scriptsPrependNodePath: opts.get('scripts-prepend-node-path'),
- unsafePerm: opts.get('unsafe-perm'),
- log,
- dir: opts.get('prefix'),
- failOk: false,
- production: opts.get('production')
- }
-}
diff --git a/deps/npm/node_modules/libcipm/lib/config/npm-config.js b/deps/npm/node_modules/libcipm/lib/config/npm-config.js
index 76b4054eef..a051190619 100644
--- a/deps/npm/node_modules/libcipm/lib/config/npm-config.js
+++ b/deps/npm/node_modules/libcipm/lib/config/npm-config.js
@@ -1,40 +1,22 @@
'use strict'
const BB = require('bluebird')
-const lifecycleOpts = require('./lifecycle-opts.js')
-const pacoteOpts = require('./pacote-opts.js')
-const protoduck = require('protoduck')
-const spawn = require('child_process').spawn
-class NpmConfig extends Map {}
+const fs = require('fs')
+const figgyPudding = require('figgy-pudding')
+const ini = require('ini')
+const path = require('path')
+const spawn = require('child_process').spawn
-const CipmConfig = protoduck.define({
- get: [],
- set: [],
- toPacote: [],
- toLifecycle: []
-}, {
- name: 'CipmConfig'
-})
-module.exports.CipmConfig = CipmConfig
+const readFileAsync = BB.promisify(fs.readFile)
-CipmConfig.impl(NpmConfig, {
- get: Map.prototype.get,
- set: Map.prototype.set,
- toPacote (opts) {
- return pacoteOpts(this, opts)
- },
- toLifecycle () {
- return lifecycleOpts(this)
- }
+const NpmConfig = figgyPudding({
+ cache: { default: '' },
+ then: {},
+ userconfig: {}
})
-module.exports.fromObject = fromObj
-function fromObj (obj) {
- const map = new NpmConfig()
- Object.keys(obj).forEach(k => map.set(k, obj[k]))
- return map
-}
+module.exports = NpmConfig
module.exports.fromNpm = getNpmConfig
function getNpmConfig (argv) {
@@ -62,11 +44,41 @@ function getNpmConfig (argv) {
reject(new Error('`npm` command not found. Please ensure you have npm@5.4.0 or later installed.'))
} else {
try {
- resolve(fromObj(JSON.parse(stdout)))
+ resolve(JSON.parse(stdout))
} catch (e) {
reject(new Error('`npm config ls --json` failed to output json. Please ensure you have npm@5.4.0 or later installed.'))
}
}
})
+ }).then(opts => {
+ return BB.all(
+ process.cwd().split(path.sep).reduce((acc, next) => {
+ acc.path = path.join(acc.path, next)
+ acc.promises.push(maybeReadIni(path.join(acc.path, '.npmrc')))
+ acc.promises.push(maybeReadIni(path.join(acc.path, 'npmrc')))
+ return acc
+ }, {
+ path: '',
+ promises: []
+ }).promises.concat(
+ opts.userconfig ? maybeReadIni(opts.userconfig) : {}
+ )
+ ).then(configs => NpmConfig(...configs, opts))
+ }).then(opts => {
+ if (opts.cache) {
+ return opts.concat({ cache: path.join(opts.cache, '_cacache') })
+ } else {
+ return opts
+ }
})
}
+
+function maybeReadIni (f) {
+ return readFileAsync(f, 'utf8').catch(err => {
+ if (err.code === 'ENOENT') {
+ return ''
+ } else {
+ throw err
+ }
+ }).then(ini.parse)
+}
diff --git a/deps/npm/node_modules/libcipm/lib/config/pacote-opts.js b/deps/npm/node_modules/libcipm/lib/config/pacote-opts.js
deleted file mode 100644
index 234ed1352a..0000000000
--- a/deps/npm/node_modules/libcipm/lib/config/pacote-opts.js
+++ /dev/null
@@ -1,135 +0,0 @@
-'use strict'
-
-const Buffer = require('safe-buffer').Buffer
-
-const crypto = require('crypto')
-const path = require('path')
-
-let effectiveOwner
-
-const npmSession = crypto.randomBytes(8).toString('hex')
-
-module.exports = pacoteOpts
-function pacoteOpts (npmOpts, moreOpts) {
- const ownerStats = calculateOwner()
- const opts = {
- cache: path.join(npmOpts.get('cache'), '_cacache'),
- ca: npmOpts.get('ca'),
- cert: npmOpts.get('cert'),
- git: npmOpts.get('git'),
- key: npmOpts.get('key'),
- localAddress: npmOpts.get('local-address'),
- loglevel: npmOpts.get('loglevel'),
- maxSockets: +(npmOpts.get('maxsockets') || 15),
- npmSession: npmSession,
- offline: npmOpts.get('offline'),
- projectScope: moreOpts.rootPkg && getProjectScope(moreOpts.rootPkg.name),
- proxy: npmOpts.get('https-proxy') || npmOpts.get('proxy'),
- refer: 'cipm',
- registry: npmOpts.get('registry'),
- retry: {
- retries: npmOpts.get('fetch-retries'),
- factor: npmOpts.get('fetch-retry-factor'),
- minTimeout: npmOpts.get('fetch-retry-mintimeout'),
- maxTimeout: npmOpts.get('fetch-retry-maxtimeout')
- },
- strictSSL: npmOpts.get('strict-ssl'),
- userAgent: npmOpts.get('user-agent'),
-
- dmode: parseInt('0777', 8) & (~npmOpts.get('umask')),
- fmode: parseInt('0666', 8) & (~npmOpts.get('umask')),
- umask: npmOpts.get('umask')
- }
-
- if (ownerStats.uid != null || ownerStats.gid != null) {
- Object.assign(opts, ownerStats)
- }
-
- (npmOpts.forEach ? Array.from(npmOpts.keys()) : npmOpts.keys).forEach(k => {
- const authMatchGlobal = k.match(
- /^(_authToken|username|_password|password|email|always-auth|_auth)$/
- )
- const authMatchScoped = k[0] === '/' && k.match(
- /(.*):(_authToken|username|_password|password|email|always-auth|_auth)$/
- )
-
- // if it matches scoped it will also match global
- if (authMatchGlobal || authMatchScoped) {
- let nerfDart = null
- let key = null
- let val = null
-
- if (!opts.auth) { opts.auth = {} }
-
- if (authMatchScoped) {
- nerfDart = authMatchScoped[1]
- key = authMatchScoped[2]
- val = npmOpts.get(k)
- if (!opts.auth[nerfDart]) {
- opts.auth[nerfDart] = {
- alwaysAuth: !!npmOpts.get('always-auth')
- }
- }
- } else {
- key = authMatchGlobal[1]
- val = npmOpts.get(k)
- opts.auth.alwaysAuth = !!npmOpts.get('always-auth')
- }
-
- const auth = authMatchScoped ? opts.auth[nerfDart] : opts.auth
- if (key === '_authToken') {
- auth.token = val
- } else if (key.match(/password$/i)) {
- auth.password =
- // the config file stores password auth already-encoded. pacote expects
- // the actual username/password pair.
- Buffer.from(val, 'base64').toString('utf8')
- } else if (key === 'always-auth') {
- auth.alwaysAuth = val === 'false' ? false : !!val
- } else {
- auth[key] = val
- }
- }
-
- if (k[0] === '@') {
- if (!opts.scopeTargets) { opts.scopeTargets = {} }
- opts.scopeTargets[k.replace(/:registry$/, '')] = npmOpts.get(k)
- }
- })
-
- Object.keys(moreOpts || {}).forEach((k) => {
- opts[k] = moreOpts[k]
- })
-
- return opts
-}
-
-function calculateOwner () {
- if (!effectiveOwner) {
- effectiveOwner = { uid: 0, gid: 0 }
-
- // Pretty much only on windows
- if (!process.getuid) {
- return effectiveOwner
- }
-
- effectiveOwner.uid = +process.getuid()
- effectiveOwner.gid = +process.getgid()
-
- if (effectiveOwner.uid === 0) {
- if (process.env.SUDO_UID) effectiveOwner.uid = +process.env.SUDO_UID
- if (process.env.SUDO_GID) effectiveOwner.gid = +process.env.SUDO_GID
- }
- }
-
- return effectiveOwner
-}
-
-function getProjectScope (pkgName) {
- const sep = pkgName.indexOf('/')
- if (sep === -1) {
- return ''
- } else {
- return pkgName.slice(0, sep)
- }
-}
diff --git a/deps/npm/node_modules/libcipm/lib/extract.js b/deps/npm/node_modules/libcipm/lib/extract.js
index 9166ebc058..5681d1ce8c 100644
--- a/deps/npm/node_modules/libcipm/lib/extract.js
+++ b/deps/npm/node_modules/libcipm/lib/extract.js
@@ -2,45 +2,56 @@
const BB = require('bluebird')
-const npa = require('npm-package-arg')
-const workerFarm = require('worker-farm')
-
const extractionWorker = require('./worker.js')
+const figgyPudding = require('figgy-pudding')
+const npa = require('npm-package-arg')
const WORKER_PATH = require.resolve('./worker.js')
+let workerFarm
+
+// Broken for now, cause too many issues on some systems.
+const ENABLE_WORKERS = false
+
+const ExtractOpts = figgyPudding({
+ log: {}
+})
module.exports = {
startWorkers () {
- this._workers = workerFarm({
- maxConcurrentCallsPerWorker: 20,
- maxRetries: 1
- }, WORKER_PATH)
+ if (ENABLE_WORKERS) {
+ if (!workerFarm) { workerFarm = require('worker-farm') }
+ this._workers = workerFarm({
+ maxConcurrentCallsPerWorker: 20,
+ maxRetries: 1
+ }, WORKER_PATH)
+ }
},
stopWorkers () {
- workerFarm.end(this._workers)
+ if (ENABLE_WORKERS) {
+ if (!workerFarm) { workerFarm = require('worker-farm') }
+ workerFarm.end(this._workers)
+ }
},
- child (name, child, childPath, config, opts) {
+ child (name, child, childPath, opts) {
+ opts = ExtractOpts(opts)
const spec = npa.resolve(name, child.version)
- const additionalToPacoteOpts = {}
- if (typeof opts.dirPacker !== 'undefined') {
- additionalToPacoteOpts.dirPacker = opts.dirPacker
- }
- const childOpts = config.toPacote(Object.assign({
+ let childOpts = opts.concat({
integrity: child.integrity,
resolved: child.resolved
- }, additionalToPacoteOpts))
+ })
const args = [spec, childPath, childOpts]
return BB.fromNode((cb) => {
let launcher = extractionWorker
let msg = args
const spec = typeof args[0] === 'string' ? npa(args[0]) : args[0]
- childOpts.loglevel = opts.log.level
- if (spec.registry || spec.type === 'remote') {
+ if (ENABLE_WORKERS && (spec.registry || spec.type === 'remote')) {
+ if (!workerFarm) { workerFarm = require('worker-farm') }
// We can't serialize these options
- childOpts.config = null
- childOpts.log = null
- childOpts.dirPacker = null
+ childOpts = childOpts.concat({
+ log: null,
+ dirPacker: null
+ })
// workers will run things in parallel!
launcher = this._workers
try {
diff --git a/deps/npm/node_modules/libcipm/lib/worker.js b/deps/npm/node_modules/libcipm/lib/worker.js
index ac61b06236..bab607e527 100644
--- a/deps/npm/node_modules/libcipm/lib/worker.js
+++ b/deps/npm/node_modules/libcipm/lib/worker.js
@@ -2,7 +2,7 @@
const BB = require('bluebird')
-const log = require('npmlog')
+// const log = require('npmlog')
const pacote = require('pacote')
module.exports = (args, cb) => {
@@ -10,7 +10,7 @@ module.exports = (args, cb) => {
const spec = parsed[0]
const extractTo = parsed[1]
const opts = parsed[2]
- opts.log = log
- log.level = opts.loglevel
+ // opts.log = log
+ // log.level = opts.loglevel
return BB.resolve(pacote.extract(spec, extractTo, opts)).nodeify(cb)
}