aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/lib/config
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2017-05-09 14:46:02 -0700
committerAnna Henningsen <anna@addaleax.net>2017-05-23 19:39:43 +0200
commitc0d858f8bb8ba5212548da2fba6a7bc02db0462b (patch)
tree99f043ec5aec3f5150a2aed0f62597234b158140 /deps/npm/lib/config
parent994617370e8e66f3ea9488fec32fd912e7902396 (diff)
downloadandroid-node-v8-c0d858f8bb8ba5212548da2fba6a7bc02db0462b.tar.gz
android-node-v8-c0d858f8bb8ba5212548da2fba6a7bc02db0462b.tar.bz2
android-node-v8-c0d858f8bb8ba5212548da2fba6a7bc02db0462b.zip
deps: upgrade npm beta to 5.0.0-beta.56
PR-URL: https://github.com/nodejs/node/pull/12936 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'deps/npm/lib/config')
-rw-r--r--deps/npm/lib/config/defaults.js18
-rw-r--r--deps/npm/lib/config/pacote.js175
2 files changed, 190 insertions, 3 deletions
diff --git a/deps/npm/lib/config/defaults.js b/deps/npm/lib/config/defaults.js
index 96499d1718..517d82ae1e 100644
--- a/deps/npm/lib/config/defaults.js
+++ b/deps/npm/lib/config/defaults.js
@@ -106,6 +106,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
defaults = {
access: null,
+ 'allow-same-version': false,
'always-auth': false,
also: null,
'auth-type': 'legacy',
@@ -152,6 +153,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'ham-it-up': false,
heading: 'npm',
'if-present': false,
+ 'ignore-prepublish': false,
'ignore-scripts': false,
'init-module': path.resolve(home, '.npm-init.js'),
'init-author-name': '',
@@ -164,7 +166,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'legacy-bundling': false,
link: false,
'local-address': undefined,
- loglevel: 'warn',
+ loglevel: 'notice',
logstream: process.stderr,
'logs-max': 10,
long: false,
@@ -172,10 +174,13 @@ Object.defineProperty(exports, 'defaults', {get: function () {
message: '%s',
'metrics-registry': null,
'node-version': process.version,
+ 'offline': false,
'onload-script': false,
only: null,
optional: true,
parseable: false,
+ 'prefer-offline': false,
+ 'prefer-online': false,
prefix: globalPrefix,
production: process.env.NODE_ENV === 'production',
'progress': !process.env.TRAVIS && !process.env.CI,
@@ -189,7 +194,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'rebuild-bundle': true,
registry: 'https://registry.npmjs.org/',
rollback: true,
- save: false,
+ save: true,
'save-bundle': false,
'save-dev': false,
'save-exact': false,
@@ -210,6 +215,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'strict-ssl': true,
tag: 'latest',
'tag-version-prefix': 'v',
+ timing: false,
tmp: temp,
unicode: hasUnicode(),
'unsafe-perm': process.platform === 'win32' ||
@@ -233,6 +239,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
exports.types = {
access: [null, 'restricted', 'public'],
+ 'allow-same-version': Boolean,
'always-auth': Boolean,
also: [null, 'dev', 'development'],
'auth-type': ['legacy', 'sso', 'saml', 'oauth'],
@@ -270,6 +277,7 @@ exports.types = {
'ham-it-up': Boolean,
'heading': String,
'if-present': Boolean,
+ 'ignore-prepublish': Boolean,
'ignore-scripts': Boolean,
'init-module': path,
'init-author-name': String,
@@ -284,7 +292,7 @@ exports.types = {
// local-address must be listed as an IP for a local network interface
// must be IPv4 due to node bug
'local-address': getLocalAddresses(),
- loglevel: ['silent', 'error', 'warn', 'http', 'info', 'verbose', 'silly'],
+ loglevel: ['silent', 'error', 'warn', 'notice', 'http', 'timing', 'info', 'verbose', 'silly'],
logstream: Stream,
'logs-max': Number,
long: Boolean,
@@ -292,10 +300,13 @@ exports.types = {
message: String,
'metrics-registry': [null, String],
'node-version': [null, semver],
+ offline: Boolean,
'onload-script': [null, String],
only: [null, 'dev', 'development', 'prod', 'production'],
optional: Boolean,
parseable: Boolean,
+ 'prefer-offline': Boolean,
+ 'prefer-online': Boolean,
prefix: path,
production: Boolean,
progress: Boolean,
@@ -324,6 +335,7 @@ exports.types = {
'sso-type': [null, 'oauth', 'saml'],
'strict-ssl': Boolean,
tag: String,
+ timing: Boolean,
tmp: path,
unicode: Boolean,
'unsafe-perm': Boolean,
diff --git a/deps/npm/lib/config/pacote.js b/deps/npm/lib/config/pacote.js
new file mode 100644
index 0000000000..13b7b53f52
--- /dev/null
+++ b/deps/npm/lib/config/pacote.js
@@ -0,0 +1,175 @@
+'use strict'
+
+const BB = require('bluebird')
+
+const cp = require('child_process')
+const npm = require('../npm')
+const log = require('npmlog')
+const packToStream = require('../utils/tar').packToStream
+const path = require('path')
+const pipe = BB.promisify(require('mississippi').pipe)
+const readJson = BB.promisify(require('read-package-json'))
+const PassThrough = require('stream').PassThrough
+
+let effectiveOwner
+
+module.exports = pacoteOpts
+function pacoteOpts (moreOpts) {
+ const ownerStats = calculateOwner()
+ const opts = {
+ cache: path.join(npm.config.get('cache'), '_cacache'),
+ defaultTag: npm.config.get('tag'),
+ dirPacker: prepareAndPack,
+ hashAlgorithm: 'sha1',
+ localAddress: npm.config.get('local-address'),
+ log: log,
+ maxAge: npm.config.get('cache-min'),
+ maxSockets: npm.config.get('maxsockets'),
+ offline: npm.config.get('offline'),
+ preferOffline: npm.config.get('prefer-offline') || npm.config.get('cache-min') > 9999,
+ preferOnline: npm.config.get('prefer-online') || npm.config.get('cache-max') <= 0,
+ projectScope: npm.projectScope,
+ proxy: npm.config.get('https-proxy') || npm.config.get('proxy'),
+ refer: npm.registry.refer,
+ registry: npm.config.get('registry'),
+ retry: {
+ retries: npm.config.get('fetch-retries'),
+ factor: npm.config.get('fetch-retry-factor'),
+ minTimeout: npm.config.get('fetch-retry-mintimeout'),
+ maxTimeout: npm.config.get('fetch-retry-maxtimeout')
+ },
+ scope: npm.config.get('scope'),
+ strictSSL: npm.config.get('strict-ssl'),
+ userAgent: npm.config.get('user-agent')
+ }
+
+ if (ownerStats.uid || ownerStats.gid) {
+ Object.assign(opts, ownerStats, {
+ cacheUid: ownerStats.uid,
+ cacheGid: ownerStats.gid
+ })
+ }
+
+ npm.config.keys.forEach(function (k) {
+ if (k[0] === '/' && k.match(/.*:_authToken$/)) {
+ if (!opts.auth) { opts.auth = {} }
+ opts.auth[k.replace(/:_authToken$/, '')] = {
+ token: npm.config.get(k)
+ }
+ }
+ if (k[0] === '@') {
+ if (!opts.scopeTargets) { opts.scopeTargets = {} }
+ opts.scopeTargets[k.replace(/:registry$/, '')] = npm.config.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
+}
+
+const PASSTHROUGH_OPTS = [
+ 'always-auth',
+ 'auth-type',
+ 'ca',
+ 'cafile',
+ 'cert',
+ 'git',
+ 'local-address',
+ 'maxsockets',
+ 'offline',
+ 'prefer-offline',
+ 'prefer-online',
+ 'proxy',
+ 'https-proxy',
+ 'registry',
+ 'send-metrics',
+ 'sso-poll-frequency',
+ 'sso-type',
+ 'strict-ssl'
+]
+
+function prepareAndPack (manifest, dir) {
+ const stream = new PassThrough()
+ readJson(path.join(dir, 'package.json')).then((pkg) => {
+ if (pkg.scripts && pkg.scripts.prepare) {
+ log.verbose('prepareGitDep', `${manifest._spec}: installing devDeps and running prepare script.`)
+ const cliArgs = PASSTHROUGH_OPTS.reduce((acc, opt) => {
+ if (npm.config.get(opt, 'cli') != null) {
+ acc.push(`--${opt}=${npm.config.get(opt)}`)
+ }
+ return acc
+ }, [])
+ const child = cp.spawn(process.env.NODE || process.execPath, [
+ require.main.filename,
+ 'install',
+ '--ignore-prepublish',
+ '--no-progress',
+ '--no-save'
+ ].concat(cliArgs), {
+ cwd: dir,
+ env: process.env
+ })
+ let errData = []
+ let errDataLen = 0
+ let outData = []
+ let outDataLen = 0
+ child.stdout.on('data', (data) => {
+ outData.push(data)
+ outDataLen += data.length
+ log.gauge.pulse('preparing git package')
+ })
+ child.stderr.on('data', (data) => {
+ errData.push(data)
+ errDataLen += data.length
+ log.gauge.pulse('preparing git package')
+ })
+ return BB.fromNode((cb) => {
+ child.on('error', cb)
+ child.on('exit', (code, signal) => {
+ if (code > 0) {
+ const err = new Error(`${signal}: npm exited with code ${code} while attempting to build ${manifest._requested}. Clone the repository manually and run 'npm install' in it for more information.`)
+ err.code = code
+ err.signal = signal
+ cb(err)
+ } else {
+ cb()
+ }
+ })
+ }).then(() => {
+ if (outDataLen > 0) log.silly('prepareGitDep', '1>', Buffer.concat(outData, outDataLen).toString())
+ if (errDataLen > 0) log.silly('prepareGitDep', '2>', Buffer.concat(errData, errDataLen).toString())
+ }, (err) => {
+ if (outDataLen > 0) log.error('prepareGitDep', '1>', Buffer.concat(outData, outDataLen).toString())
+ if (errDataLen > 0) log.error('prepareGitDep', '2>', Buffer.concat(errData, errDataLen).toString())
+ throw err
+ })
+ }
+ }).then(() => {
+ return pipe(packToStream(manifest, dir), stream)
+ }).catch((err) => stream.emit('error', err))
+ return stream
+}