Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-06-26 04:29:53 +0400
committerisaacs <i@izs.me>2014-06-27 01:22:21 +0400
commit2dac42eb6788c01a2ab48ae9979b05b302bd219d (patch)
treee3d1611b9e3fe74acc5f824ee4785b5908b5201a
parent2a9ba1168ea04f9ccf33999632dc6d8da90df9f9 (diff)
npmconf@1.1.1
-rw-r--r--node_modules/npmconf/config-defs.js19
-rw-r--r--node_modules/npmconf/lib/load-cafile.js28
-rw-r--r--node_modules/npmconf/npmconf.js63
-rw-r--r--node_modules/npmconf/package.json8
-rw-r--r--node_modules/npmconf/test/certfile.js17
-rw-r--r--node_modules/npmconf/test/fixtures/multi-ca32
-rw-r--r--package.json2
7 files changed, 146 insertions, 23 deletions
diff --git a/node_modules/npmconf/config-defs.js b/node_modules/npmconf/config-defs.js
index 7d76f8129..e53c85200 100644
--- a/node_modules/npmconf/config-defs.js
+++ b/node_modules/npmconf/config-defs.js
@@ -7,14 +7,15 @@ var path = require("path")
, semver = require("semver")
, stableFamily = semver.parse(process.version)
, nopt = require("nopt")
- , os = require('os')
+ , os = require("os")
, osenv = require("osenv")
+var log
try {
- var log = require("npmlog")
+ log = require("npmlog")
} catch (er) {
- var util = require('util')
- var log = { warn: function (m) {
+ var util = require("util")
+ log = { warn: function (m) {
console.warn(m + util.format.apply(util, [].slice.call(arguments, 1)))
} }
}
@@ -48,7 +49,7 @@ nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Octal = { type: Octal, validate: validateOctal }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
-nopt.invalidHandler = function (k, val, type, data) {
+nopt.invalidHandler = function (k, val, type) {
log.warn("invalid config", k + "=" + JSON.stringify(val))
if (Array.isArray(type)) {
@@ -118,6 +119,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, browser : null
, ca: null
+ , cafile: null
, cache : cache
@@ -153,7 +155,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
: process.env.SUDO_GID || (process.getgid && process.getgid())
, heading: "npm"
, "ignore-scripts": false
- , "init-module": path.resolve(home, '.npm-init.js')
+ , "init-module": path.resolve(home, ".npm-init.js")
, "init.author.name" : ""
, "init.author.email" : ""
, "init.author.url" : ""
@@ -190,6 +192,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, "save-exact" : false
, "save-optional" : false
, "save-prefix": "^"
+ , scope : ""
, searchopts: ""
, searchexclude: null
, searchsort: "name"
@@ -210,7 +213,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, user : process.platform === "win32" ? 0 : "nobody"
, username : ""
, userconfig : path.resolve(home, ".npmrc")
- , umask: 022
+ , umask: "022"
, version : false
, versions : false
, viewer: process.platform === "win32" ? "browser" : "man"
@@ -224,6 +227,7 @@ exports.types =
, "bin-links": Boolean
, browser : [null, String]
, ca: [null, String, Array]
+ , cafile : path
, cache : path
, "cache-lock-stale": Number
, "cache-lock-retries": Number
@@ -294,6 +298,7 @@ exports.types =
, "save-exact" : Boolean
, "save-optional" : Boolean
, "save-prefix": String
+ , scope : String
, searchopts : String
, searchexclude: [null, String]
, searchsort: [ "name", "-name"
diff --git a/node_modules/npmconf/lib/load-cafile.js b/node_modules/npmconf/lib/load-cafile.js
new file mode 100644
index 000000000..402058bdd
--- /dev/null
+++ b/node_modules/npmconf/lib/load-cafile.js
@@ -0,0 +1,28 @@
+module.exports = loadCAFile
+
+var fs = require('fs')
+
+function loadCAFile(cafilePath, cb) {
+ fs.readFile(cafilePath, 'utf8', afterCARead.bind(this))
+
+ function afterCARead(er, cadata) {
+ if (er)
+ return cb(er)
+
+ var delim = '-----END CERTIFICATE-----'
+ var output
+
+ output = cadata
+ .split(delim)
+ .filter(function(xs) {
+ return !!xs.trim()
+ })
+ .map(function(xs) {
+ return xs.trimLeft() + delim
+ })
+
+ this.set('ca', output)
+ cb(null)
+ }
+
+}
diff --git a/node_modules/npmconf/npmconf.js b/node_modules/npmconf/npmconf.js
index c319c64d4..d1f334b79 100644
--- a/node_modules/npmconf/npmconf.js
+++ b/node_modules/npmconf/npmconf.js
@@ -107,12 +107,34 @@ function load_(builtin, rc, cli, cb) {
if (er)
return cb(er)
- if (!conf.get('global')) {
- var projectConf = path.resolve(conf.localPrefix, '.npmrc')
+ // If you're doing `npm --userconfig=~/foo.npmrc` then you'd expect
+ // that ~/.npmrc won't override the stuff in ~/foo.npmrc (or, indeed
+ // be used at all).
+ //
+ // However, if the cwd is ~, then ~/.npmrc is the home for the project
+ // config, and will override the userconfig.
+ //
+ // If you're not setting the userconfig explicitly, then it will be loaded
+ // twice, which is harmless but excessive. If you *are* setting the
+ // userconfig explicitly then it will override your explicit intent, and
+ // that IS harmful and unexpected.
+ //
+ // Solution: Do not load project config file that is the same as either
+ // the default or resolved userconfig value. npm will log a "verbose"
+ // message about this when it happens, but it is a rare enough edge case
+ // that we don't have to be super concerned about it.
+ var projectConf = path.resolve(conf.localPrefix, '.npmrc')
+ var defaultUserConfig = rc.get('userconfig')
+ var resolvedUserConfig = conf.get('userconfig')
+ if (!conf.get('global') &&
+ projectConf !== defaultUserConfig &&
+ projectConf !== resolvedUserConfig) {
conf.addFile(projectConf, 'project')
conf.once('load', afterPrefix)
+ } else {
+ conf.add({}, 'project')
+ afterPrefix()
}
- else return afterPrefix()
})
function afterPrefix() {
@@ -139,16 +161,34 @@ function load_(builtin, rc, cli, cb) {
conf.root = defaults
conf.add(rc.shift(), 'builtin')
conf.once('load', function () {
- conf.loadExtras(function(er) {
- if (er)
- return cb(er)
- // warn about invalid bits.
- validate(conf)
- exports.loaded = conf
- cb(er, conf)
- })
+ conf.loadExtras(afterExtras)
})
}
+
+ function afterExtras(er) {
+ if (er)
+ return cb(er)
+
+ // warn about invalid bits.
+ validate(conf)
+
+ var cafile = conf.get('cafile')
+
+ if (cafile) {
+ return conf.loadCAFile(cafile, finalize)
+ }
+
+ finalize()
+ }
+
+ function finalize(er, cadata) {
+ if (er) {
+ return cb(er)
+ }
+
+ exports.loaded = conf
+ cb(er, conf)
+ }
}
// Basically the same as CC, but:
@@ -173,6 +213,7 @@ function Conf (base) {
}
Conf.prototype.loadPrefix = require('./lib/load-prefix.js')
+Conf.prototype.loadCAFile = require('./lib/load-cafile.js')
Conf.prototype.loadUid = require('./lib/load-uid.js')
Conf.prototype.setUser = require('./lib/set-user.js')
Conf.prototype.findPrefix = require('./lib/find-prefix.js')
diff --git a/node_modules/npmconf/package.json b/node_modules/npmconf/package.json
index f1122123e..c2f77e73f 100644
--- a/node_modules/npmconf/package.json
+++ b/node_modules/npmconf/package.json
@@ -1,6 +1,6 @@
{
"name": "npmconf",
- "version": "1.0.5",
+ "version": "1.1.1",
"description": "The config thing npm uses",
"main": "npmconf.js",
"directories": {
@@ -42,12 +42,12 @@
"license": "BSD",
"readme": "# npmconf\n\nThe config thing npm uses\n\nIf you are interested in interacting with the config settings that npm\nuses, then use this module.\n\nHowever, if you are writing a new Node.js program, and want\nconfiguration functionality similar to what npm has, but for your\nown thing, then I'd recommend using [rc](https://github.com/dominictarr/rc),\nwhich is probably what you want.\n\nIf I were to do it all over again, that's what I'd do for npm. But,\nalas, there are many systems depending on many of the particulars of\nnpm's configuration setup, so it's not worth the cost of changing.\n\n## USAGE\n\n```javascript\nvar npmconf = require('npmconf')\n\n// pass in the cli options that you read from the cli\n// or whatever top-level configs you want npm to use for now.\nnpmconf.load({some:'configs'}, function (er, conf) {\n // do stuff with conf\n conf.get('some', 'cli') // 'configs'\n conf.get('username') // 'joebobwhatevers'\n conf.set('foo', 'bar', 'user')\n conf.save('user', function (er) {\n // foo = bar is now saved to ~/.npmrc or wherever\n })\n})\n```\n",
"readmeFilename": "README.md",
- "gitHead": "e6e6657e9da51b5fba2cb2b0c4925b218f1f1ca3",
+ "gitHead": "f56051d91a964daf547a57096348d00721c289bf",
"bugs": {
"url": "https://github.com/isaacs/npmconf/issues"
},
"homepage": "https://github.com/isaacs/npmconf",
- "_id": "npmconf@1.0.5",
- "_shasum": "6064aaa3bac86c41a1cddfb77a71ce5140c9b0cc",
+ "_id": "npmconf@1.1.1",
+ "_shasum": "5fa85daf4655e059753d0dcd281763fa8e32545a",
"_from": "npmconf@latest"
}
diff --git a/node_modules/npmconf/test/certfile.js b/node_modules/npmconf/test/certfile.js
new file mode 100644
index 000000000..3dfb6e90f
--- /dev/null
+++ b/node_modules/npmconf/test/certfile.js
@@ -0,0 +1,17 @@
+var test = require('tap').test
+var npmconf = require('../npmconf.js')
+var common = require('./00-setup.js')
+var path = require('path')
+var fs = require('fs')
+
+test('cafile loads as ca', function (t) {
+ var cafile = path.join(__dirname, 'fixtures', 'multi-ca')
+
+ npmconf.load({cafile: cafile}, function (er, conf) {
+ if (er) throw er
+
+ t.same(conf.get('cafile'), cafile)
+ t.same(conf.get('ca').join('\n'), fs.readFileSync(cafile, 'utf8').trim())
+ t.end()
+ })
+})
diff --git a/node_modules/npmconf/test/fixtures/multi-ca b/node_modules/npmconf/test/fixtures/multi-ca
new file mode 100644
index 000000000..0bc922b25
--- /dev/null
+++ b/node_modules/npmconf/test/fixtures/multi-ca
@@ -0,0 +1,32 @@
+-----BEGIN CERTIFICATE-----
+MIICjTCCAfigAwIBAgIEMaYgRzALBgkqhkiG9w0BAQQwRTELMAkGA1UEBhMCVVMx
+NjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFuZCBTcGFjZSBBZG1pbmlz
+dHJhdGlvbjAmFxE5NjA1MjgxMzQ5MDUrMDgwMBcROTgwNTI4MTM0OTA1KzA4MDAw
+ZzELMAkGA1UEBhMCVVMxNjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFu
+ZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEgMAkGA1UEBRMCMTYwEwYDVQQDEwxTdGV2
+ZSBTY2hvY2gwWDALBgkqhkiG9w0BAQEDSQAwRgJBALrAwyYdgxmzNP/ts0Uy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AYTAlVTMTYwNAYDVQQK
+Ey1OYXRpb25hbCBBZXJvbmF1dGljcyBhbmQgU3BhY2UgQWRtaW5pc3RyYXRpb24x
+DTALBgNVBAMTBENSTDEwFwYDVR0BAQH/BA0wC4AJODMyOTcwODEwMBgGA1UdAgQR
+MA8ECTgzMjk3MDgyM4ACBSAwDQYDVR0KBAYwBAMCBkAwCwYJKoZIhvcNAQEEA4GB
+AH2y1VCEw/A4zaXzSYZJTTUi3uawbbFiS2yxHvgf28+8Js0OHXk1H1w2d6qOHH21
+X82tZXd/0JtG0g1T9usFFBDvYK8O0ebgz/P5ELJnBL2+atObEuJy1ZZ0pBDWINR3
+WkDNLCGiTkCKp0F5EWIrVDwh54NNevkCQRZita+z4IBO
+-----END CERTIFICATE-----
diff --git a/package.json b/package.json
index a3b43f6c2..64c8ff85f 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,7 @@
"npm-install-checks": "~1.0.2",
"npm-registry-client": "~2.0.2",
"npm-user-validate": "~0.1.0",
- "npmconf": "~1.0.5",
+ "npmconf": "~1.1.1",
"npmlog": "~0.1.1",
"once": "~1.3.0",
"opener": "~1.3.0",