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:
authorForrest L Norvell <forrest@npmjs.com>2014-11-22 05:25:02 +0300
committerForrest L Norvell <forrest@npmjs.com>2014-11-22 05:25:02 +0300
commitc8ac37a470491b2ed28514536e2e198494638c79 (patch)
tree76f46628230ea1cff7cba40f33267cc905a77548 /node_modules/npm-registry-client
parent4d5ad2f653ba36cc8a2237555416192a3362be74 (diff)
npm-registry-client@4.0.4
Deal with numeric defaults better, pass the correct configuration to the retry module, and deal with registry errors that don't come with an error message from the registry.
Diffstat (limited to 'node_modules/npm-registry-client')
-rw-r--r--node_modules/npm-registry-client/index.js21
-rw-r--r--node_modules/npm-registry-client/lib/request.js18
-rw-r--r--node_modules/npm-registry-client/package.json10
-rw-r--r--node_modules/npm-registry-client/test/config-defaults.js2
-rw-r--r--node_modules/npm-registry-client/test/publish-failed-no-message.js41
-rw-r--r--node_modules/npm-registry-client/test/retries.js2
6 files changed, 75 insertions, 19 deletions
diff --git a/node_modules/npm-registry-client/index.js b/node_modules/npm-registry-client/index.js
index ad4c4470b..801d00f8e 100644
--- a/node_modules/npm-registry-client/index.js
+++ b/node_modules/npm-registry-client/index.js
@@ -10,9 +10,16 @@ try {
npmlog = require("npmlog")
}
catch (er) {
- npmlog = { error: noop, warn: noop, info: noop,
- verbose: noop, silly: noop, http: noop,
- pause: noop, resume: noop }
+ npmlog = {
+ error : noop,
+ warn : noop,
+ info : noop,
+ verbose : noop,
+ silly : noop,
+ http : noop,
+ pause : noop,
+ resume : noop
+ }
}
function noop () {}
@@ -29,10 +36,10 @@ function RegClient (config) {
if (this.config.ssl.strict === undefined) this.config.ssl.strict = true
this.config.retry = this.config.retry || {}
- if (!this.config.retry.count) this.config.retry.count = 2
- if (!this.config.retry.factor) this.config.retry.factor = 10
- if (!this.config.retry.minTimeout) this.config.retry.minTimeout = 10000
- if (!this.config.retry.maxTimeout) this.config.retry.maxTimeout = 60000
+ if (typeof this.config.retry.retries !== "number") this.config.retry.retries = 2
+ if (typeof this.config.retry.factor !== "number") this.config.retry.factor = 10
+ if (typeof this.config.retry.minTimeout !== "number") this.config.retry.minTimeout = 10000
+ if (typeof this.config.retry.maxTimeout !== "number") this.config.retry.maxTimeout = 60000
this.config.userAgent = this.config.userAgent || "node/" + process.version
this.config.defaultTag = this.config.defaultTag || "latest"
diff --git a/node_modules/npm-registry-client/lib/request.js b/node_modules/npm-registry-client/lib/request.js
index aa17ae1ce..7156c13d7 100644
--- a/node_modules/npm-registry-client/lib/request.js
+++ b/node_modules/npm-registry-client/lib/request.js
@@ -220,7 +220,7 @@ function requestDone (method, where, cb) {
parsed._etag = response.headers.etag
}
- if (parsed && parsed.error && response.statusCode >= 400) {
+ if (parsed && parsed.error || response.statusCode >= 400) {
var w = url.parse(where).pathname.substr(1)
var name
if (!w.match(/^-/)) {
@@ -228,16 +228,24 @@ function requestDone (method, where, cb) {
name = w[w.indexOf("_rewrite") + 1]
}
- if (name && parsed.error === "not_found") {
+ if (!parsed.error) {
+ er = new Error(
+ "Registry returned " + response.statusCode +
+ " for " + method +
+ " on " + where
+ )
+ }
+ else if (name && parsed.error === "not_found") {
er = new Error("404 Not Found: " + name)
- } else {
+ }
+ else {
er = new Error(
- parsed.error + " " + (parsed.reason || "") + ": " + w)
+ parsed.error + " " + (parsed.reason || "") + ": " + w
+ )
}
if (name) er.pkgid = name
er.statusCode = response.statusCode
er.code = "E" + er.statusCode
-
}
return cb(er, parsed, data, response)
}.bind(this)
diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json
index 2ee1e100f..4b13d8711 100644
--- a/node_modules/npm-registry-client/package.json
+++ b/node_modules/npm-registry-client/package.json
@@ -6,7 +6,7 @@
},
"name": "npm-registry-client",
"description": "Client for the npm registry",
- "version": "4.0.3",
+ "version": "4.0.4",
"repository": {
"url": "git://github.com/isaacs/npm-registry-client"
},
@@ -38,12 +38,12 @@
"license": "ISC",
"readme": "# npm-registry-client\n\nThe code that npm uses to talk to the registry.\n\nIt handles all the caching and HTTP calls.\n\n## Usage\n\n```javascript\nvar RegClient = require('npm-registry-client')\nvar client = new RegClient(config)\nvar uri = \"npm://registry.npmjs.org/npm\"\nvar params = {timeout: 1000}\n\nclient.get(uri, params, function (error, data, raw, res) {\n // error is an error if there was a problem.\n // data is the parsed data object\n // raw is the json string\n // res is the response from couch\n})\n```\n\n# Registry URLs\n\nThe registry calls take either a full URL pointing to a resource in the\nregistry, or a base URL for the registry as a whole (including the registry\npath – but be sure to terminate the path with `/`). `http` and `https` URLs are\nthe only ones supported.\n\n## Using the client\n\nEvery call to the client follows the same pattern:\n\n* `uri` {String} The *fully-qualified* URI of the registry API method being\n invoked.\n* `params` {Object} Per-request parameters.\n* `callback` {Function} Callback to be invoked when the call is complete.\n\n### Credentials\n\nMany requests to the registry can by authenticated, and require credentials\nfor authorization. These credentials always look the same:\n\n* `username` {String}\n* `password` {String}\n* `email` {String}\n* `alwaysAuth` {Boolean} Whether calls to the target registry are always\n authed.\n\n**or**\n\n* `token` {String}\n* `alwaysAuth` {Boolean} Whether calls to the target registry are always\n authed.\n\n## API\n\n### client.adduser(uri, params, cb)\n\n* `uri` {String} Base registry URL.\n* `params` {Object} Object containing per-request properties.\n * `auth` {Credentials}\n* `cb` {Function}\n * `error` {Error | null}\n * `data` {Object} the parsed data object\n * `raw` {String} the json\n * `res` {Response Object} response from couch\n\nAdd a user account to the registry, or verify the credentials.\n\n### client.deprecate(uri, params, cb)\n\n* `uri` {String} Full registry URI for the deprecated package.\n* `params` {Object} Object containing per-request properties.\n * `version` {String} Semver version range.\n * `message` {String} The message to use as a deprecation warning.\n * `auth` {Credentials}\n* `cb` {Function}\n\nDeprecate a version of a package in the registry.\n\n### client.get(uri, params, cb)\n\n* `uri` {String} The complete registry URI to fetch\n* `params` {Object} Object containing per-request properties.\n * `timeout` {Number} Duration before the request times out. Optional\n (default: never).\n * `follow` {Boolean} Follow 302/301 responses. Optional (default: true).\n * `staleOk` {Boolean} If there's cached data available, then return that to\n the callback quickly, and update the cache the background. Optional\n (default: false).\n * `auth` {Credentials} Optional.\n* `cb` {Function}\n\nFetches data from the registry via a GET request, saving it in the cache folder\nwith the ETag.\n\n### client.publish(uri, params, cb)\n\n* `uri` {String} The registry URI for the package to publish.\n* `params` {Object} Object containing per-request properties.\n * `metadata` {Object} Package metadata.\n * `body` {Stream} Stream of the package body / tarball.\n * `auth` {Credentials}\n* `cb` {Function}\n\nPublish a package to the registry.\n\nNote that this does not create the tarball from a folder.\n\n### client.star(uri, params, cb)\n\n* `uri` {String} The complete registry URI for the package to star.\n* `params` {Object} Object containing per-request properties.\n * `starred` {Boolean} True to star the package, false to unstar it. Optional\n (default: false).\n * `auth` {Credentials}\n* `cb` {Function}\n\nStar or unstar a package.\n\nNote that the user does not have to be the package owner to star or unstar a\npackage, though other writes do require that the user be the package owner.\n\n### client.stars(uri, params, cb)\n\n* `uri` {String} The base URL for the registry.\n* `params` {Object} Object containing per-request properties.\n * `username` {String} Name of user to fetch starred packages for. Optional\n (default: user in `auth`).\n * `auth` {Credentials} Optional (required if `username` is omitted).\n* `cb` {Function}\n\nView your own or another user's starred packages.\n\n### client.tag(uri, params, cb)\n\n* `uri` {String} The complete registry URI to tag\n* `params` {Object} Object containing per-request properties.\n * `version` {String} Version to tag.\n * `tag` {String} Tag name to apply.\n * `auth` {Credentials}\n* `cb` {Function}\n\nMark a version in the `dist-tags` hash, so that `pkg@tag` will fetch the\nspecified version.\n\n### client.unpublish(uri, params, cb)\n\n* `uri` {String} The complete registry URI of the package to unpublish.\n* `params` {Object} Object containing per-request properties.\n * `version` {String} version to unpublish. Optional – omit to unpublish all\n versions.\n * `auth` {Credentials}\n* `cb` {Function}\n\nRemove a version of a package (or all versions) from the registry. When the\nlast version us unpublished, the entire document is removed from the database.\n\n### client.whoami(uri, params, cb)\n\n* `uri` {String} The base registry for the URI.\n* `params` {Object} Object containing per-request properties.\n * `auth` {Credentials}\n* `cb` {Function}\n\nSimple call to see who the registry thinks you are. Especially useful with\ntoken-based auth.\n\n\n## PLUMBING\n\nThe below are primarily intended for use by the rest of the API, or by the npm\ncaching logic directly.\n\n### client.request(uri, params, cb)\n\n* `uri` {String} URI pointing to the resource to request.\n* `params` {Object} Object containing per-request properties.\n * `method` {String} HTTP method. Optional (default: \"GET\").\n * `body` {Stream | Buffer | String | Object} The request body. Objects\n that are not Buffers or Streams are encoded as JSON. Optional – body\n only used for write operations.\n * `etag` {String} The cached ETag. Optional.\n * `follow` {Boolean} Follow 302/301 responses. Optional (default: true).\n * `auth` {Credentials} Optional.\n* `cb` {Function}\n * `error` {Error | null}\n * `data` {Object} the parsed data object\n * `raw` {String} the json\n * `res` {Response Object} response from couch\n\nMake a generic request to the registry. All the other methods are wrappers\naround `client.request`.\n\n### client.fetch(uri, params, cb)\n\n* `uri` {String} The complete registry URI to upload to\n* `params` {Object} Object containing per-request properties.\n * `headers` {Stream} HTTP headers to be included with the request. Optional.\n * `auth` {Credentials} Optional.\n* `cb` {Function}\n\nFetch a package from a URL, with auth set appropriately if included. Used to\ncache remote tarballs as well as request package tarballs from the registry.\n\n# Configuration\n\nThe client uses its own configuration, which is just passed in as a simple\nnested object. The following are the supported values (with their defaults, if\nany):\n\n* `proxy.http` {URL} The URL to proxy HTTP requests through.\n* `proxy.https` {URL} The URL to proxy HTTPS requests through. Defaults to be\n the same as `proxy.http` if unset.\n* `proxy.localAddress` {IP} The local address to use on multi-homed systems.\n* `ssl.ca` {String} Cerficate signing authority certificates to trust.\n* `ssl.certificate` {String} Client certificate (PEM encoded). Enable access\n to servers that require client certificates.\n* `ssl.key` {String} Private key (PEM encoded) for client certificate.\n* `ssl.strict` {Boolean} Whether or not to be strict with SSL certificates.\n Default = `true`\n* `retry.count` {Number} Number of times to retry on GET failures. Default = 2.\n* `retry.factor` {Number} `factor` setting for `node-retry`. Default = 10.\n* `retry.minTimeout` {Number} `minTimeout` setting for `node-retry`.\n Default = 10000 (10 seconds)\n* `retry.maxTimeout` {Number} `maxTimeout` setting for `node-retry`.\n Default = 60000 (60 seconds)\n* `userAgent` {String} User agent header to send. Default =\n `\"node/{process.version}\"`\n* `log` {Object} The logger to use. Defaults to `require(\"npmlog\")` if\n that works, otherwise logs are disabled.\n* `defaultTag` {String} The default tag to use when publishing new packages.\n Default = `\"latest\"`\n* `couchToken` {Object} A token for use with\n [couch-login](https://npmjs.org/package/couch-login).\n* `sessionToken` {string} A random identifier for this set of client requests.\n Default = 8 random hexadecimal bytes.\n",
"readmeFilename": "README.md",
- "gitHead": "7e6ac0ee892e5a032549d9e41fb69befd8cc5524",
+ "gitHead": "3e10914ef704b8d043c5c410281868de1756fb0e",
"bugs": {
"url": "https://github.com/isaacs/npm-registry-client/issues"
},
"homepage": "https://github.com/isaacs/npm-registry-client",
- "_id": "npm-registry-client@4.0.3",
- "_shasum": "2158168d26c9256b362cdcc3b800b571c876514f",
- "_from": "npm-registry-client@>=4.0.3 <4.1.0"
+ "_id": "npm-registry-client@4.0.4",
+ "_shasum": "6935cde6460a3bf1cb6019d7523196e0fb96fb62",
+ "_from": "npm-registry-client@>=4.0.4 <4.1.0"
}
diff --git a/node_modules/npm-registry-client/test/config-defaults.js b/node_modules/npm-registry-client/test/config-defaults.js
index 7c0852d1e..46756297a 100644
--- a/node_modules/npm-registry-client/test/config-defaults.js
+++ b/node_modules/npm-registry-client/test/config-defaults.js
@@ -18,7 +18,7 @@ test("config defaults", function (t) {
t.equal(ssl.strict, true, "SSL is strict by default")
var retry = client.config.retry
- t.equal(retry.count, 2, "default retry count is 2")
+ t.equal(retry.retries, 2, "default retry count is 2")
t.equal(retry.factor, 10, "default retry factor is 10")
t.equal(retry.minTimeout, 10000, "retry minimum timeout is 10000 (10 seconds)")
t.equal(retry.maxTimeout, 60000, "retry maximum timeout is 60000 (60 seconds)")
diff --git a/node_modules/npm-registry-client/test/publish-failed-no-message.js b/node_modules/npm-registry-client/test/publish-failed-no-message.js
new file mode 100644
index 000000000..cce6fcbc7
--- /dev/null
+++ b/node_modules/npm-registry-client/test/publish-failed-no-message.js
@@ -0,0 +1,41 @@
+var createReadStream = require("fs").createReadStream
+
+var test = require("tap").test
+
+var server = require("./lib/server.js")
+var common = require("./lib/common.js")
+var config = { retry : { retries : 0 } }
+var client = common.freshClient(config)
+
+var URI = "http://localhost:1337/"
+var USERNAME = "username"
+var PASSWORD = "%1234@asdf%"
+var EMAIL = "i@izs.me"
+var METADATA = require("../package.json")
+// not really a tarball, but doesn't matter
+var BODY_PATH = require.resolve("../package.json")
+var BODY = createReadStream(BODY_PATH, "base64")
+var AUTH = {
+ username : USERNAME,
+ password : PASSWORD,
+ email : EMAIL
+}
+var PARAMS = {
+ metadata : METADATA,
+ body : BODY,
+ auth : AUTH
+}
+
+test("publish with a 500 response but no message", function (t){
+ server.expect("/npm-registry-client", function (req, res) {
+ res.statusCode = 500
+ res.json({ success : false })
+ })
+
+ client.publish(URI, PARAMS, function (er, data) {
+ t.ok(er, "got expected error")
+ t.notOk(data, "no payload on failure")
+
+ t.end()
+ })
+})
diff --git a/node_modules/npm-registry-client/test/retries.js b/node_modules/npm-registry-client/test/retries.js
index c0b73ce7f..0f0fa3667 100644
--- a/node_modules/npm-registry-client/test/retries.js
+++ b/node_modules/npm-registry-client/test/retries.js
@@ -4,7 +4,7 @@ var server = require("./lib/server.js")
var common = require("./lib/common.js")
var client = common.freshClient({
retry : {
- count : 6,
+ retries : 6,
minTimeout : 10,
maxTimeout : 100
}