diff options
author | isaacs <i@izs.me> | 2012-08-18 02:08:03 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-08-18 02:08:03 +0400 |
commit | 95e5ef25aaf51fd91960714b0ec671e37d1951fe (patch) | |
tree | 73f1c38870d4a073f7837773df1c4557a4dcf1ea | |
parent | 62c0a7ea9e80ad363e807e09e021c4c14e4df9dd (diff) |
npm-registry-client@0.2.1
-rw-r--r-- | lib/npm.js | 23 | ||||
-rw-r--r-- | node_modules/npm-registry-client/README.md | 32 | ||||
-rw-r--r-- | node_modules/npm-registry-client/index.js | 82 | ||||
-rw-r--r-- | node_modules/npm-registry-client/lib/adduser.js | 36 | ||||
-rw-r--r-- | node_modules/npm-registry-client/lib/get.js | 24 | ||||
-rw-r--r-- | node_modules/npm-registry-client/lib/publish.js | 14 | ||||
-rw-r--r-- | node_modules/npm-registry-client/lib/request.js | 52 | ||||
-rw-r--r-- | node_modules/npm-registry-client/package.json | 8 | ||||
-rw-r--r-- | node_modules/npm-registry-client/test/retries.js | 6 | ||||
-rw-r--r-- | package.json | 2 |
10 files changed, 126 insertions, 153 deletions
diff --git a/lib/npm.js b/lib/npm.js index c66c1f4e0..737423d2e 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -308,28 +308,7 @@ function load (npm, cli, cb) { } catch (e) { token = null } } - npm.registry = new RegClient( - { registry: npm.config.get("registry") - , cache: npm.config.get("cache") - , auth: npm.config.get("_auth") - , token: token - , alwaysAuth: npm.config.get("always-auth") - , email: npm.config.get("email") - , proxy: npm.config.get("proxy") - , tag: npm.config.get("tag") - , ca: npm.config.get("ca") - , strictSSL: npm.config.get("strict-ssl") - , userAgent: npm.config.get("user-agent") - , E404: npm.E404 - , EPUBLISHCONFLICT: npm.EPUBLISHCONFLICT - , log: log - , retries: npm.config.get("fetch-retries") - , retryFactor: npm.config.get("fetch-retry-factor") - , retryMinTimeout: npm.config.get("fetch-retry-mintimeout") - , retryMaxTimeout: npm.config.get("fetch-retry-maxtimeout") - , cacheMin: npm.config.get("cache-min") - , cacheMax: npm.config.get("cache-max") - }) + npm.registry = new RegClient(npm.config) // save the token cookie in the config file if (npm.registry.couchLogin) { diff --git a/node_modules/npm-registry-client/README.md b/node_modules/npm-registry-client/README.md index dbeb94422..4b180a029 100644 --- a/node_modules/npm-registry-client/README.md +++ b/node_modules/npm-registry-client/README.md @@ -8,7 +8,7 @@ It handles all the caching and HTTP calls. ```javascript var RegClient = require('npm-registry-client') -var client = new RegClient(options) +var client = new RegClient(config) client.get("npm", "latest", 1000, function (er, data, raw, res) { // error is an error if there was a problem. @@ -18,29 +18,43 @@ client.get("npm", "latest", 1000, function (er, data, raw, res) { }) ``` -# Options +# Configuration + +This program is designed to work with +[npmconf](https://npmjs.org/package/npmconf), but you can also pass in +a plain-jane object with the appropriate configs, and it'll shim it +for you. Any configuration thingie that has get/set/del methods will +also be accepted. * `registry` **Required** {String} URL to the registry * `cache` **Required** {String} Path to the cache folder -* `alwaysAuth` {Boolean} Auth even for GET requests. +* `always-auth` {Boolean} Auth even for GET requests. * `auth` {String} A base64-encoded `username:password` * `email` {String} User's email address * `tag` {String} The default tag to use when publishing new packages. Default = `"latest"` * `ca` {String} Cerficate signing authority certificates to trust. -* `strictSSL` {Boolean} Whether or not to be strict with SSL +* `strict-ssl` {Boolean} Whether or not to be strict with SSL certificates. Default = `true` -* `userAgent` {String} User agent header to send. Default = +* `user-agent` {String} User agent header to send. Default = `"node/{process.version}"` * `log` {Object} The logger to use. Defaults to `require("npmlog")` if that works, otherwise logs are disabled. -* `retries` {Number} Number of times to retry on GET failures. +* `fetch-retries` {Number} Number of times to retry on GET failures. Default=2 -* `retryFactor` {Number} `factor` setting for `node-retry`. Default=10 -* `retryMinTimeout` {Number} `minTimeout` setting for `node-retry`. +* `fetch-retry-factor` {Number} `factor` setting for `node-retry`. Default=10 +* `fetch-retry-mintimeout` {Number} `minTimeout` setting for `node-retry`. Default=10000 (10 seconds) -* `retryMaxTimeout` {Number} `maxTimeout` setting for `node-retry`. +* `fetch-retry-maxtimeout` {Number} `maxTimeout` setting for `node-retry`. Default=60000 (60 seconds) +* `proxy` {URL} The url to proxy requests through. +* `https-proxy` {URL} The url to proxy https requests through. + Defaults to be the same as `proxy` if unset. +* `_auth` {String} The base64-encoded authorization header. +* `username` `_password` {String} Username/password to use to generate + `_auth` if not supplied. +* `_token` {Object} A token for use with + [couch-login](https://npmjs.org/package/couch-login) # client.request(method, where, [what], [etag], [nofollow], cb) diff --git a/node_modules/npm-registry-client/index.js b/node_modules/npm-registry-client/index.js index 377f787f4..8d321b869 100644 --- a/node_modules/npm-registry-client/index.js +++ b/node_modules/npm-registry-client/index.js @@ -19,78 +19,48 @@ try { function noop () {} -function RegClient (options) { +function RegClient (conf) { + // accept either a plain-jane object, or a npmconf object + // with a "get" method. + if (typeof conf.get !== 'function') { + var data = conf + conf = { get: function (k) { return data[k] } + , set: function (k, v) { data[k] = v } + , del: function (k) { delete data[k] } } + } + + this.conf = conf + // if provided, then the registry needs to be a url. // if it's not provided, then we're just using the cache only. - var registry = options.registry + var registry = conf.get('registry') if (registry) { registry = url.parse(registry) if (!registry.protocol) throw new Error( 'Invalid registry: ' + registry.url) - this.registry = registry.href - if (this.registry.slice(-1) !== '/') { - this.registry += '/' + registry = registry.href + if (registry.slice(-1) !== '/') { + registry += '/' } + this.conf.set('registry', registry) } else { - this.registry = null + registry = null } - this.retries = options.retries || 2 - this.retryFactor = options.retryFactor || 10 - this.retryMinTimeout = options.retryMinTimeout || 10000 - this.retryMaxTimeout = options.retryMaxTimeout || 60000 - - this.cache = options.cache - if (!this.cache) throw new Error("Cache dir is required") - - this.alwaysAuth = options.alwaysAuth || false + if (!conf.get('cache')) throw new Error("Cache dir is required") - this.auth = options.auth || null - if (this.auth) { - var a = new Buffer(this.auth, "base64").toString() - a = a.split(":") - this.username = a.shift() - this.password = a.join(":") - } else { - this.username = options.username - this.password = options.password - - // if username and password are set, but auth isn't, use them. - if (this.username && this.password) { - var a = this.username + ":" + this.password - this.auth = new Buffer(a, "utf8").toString("base64") - } - } - - if (this.auth && !this.alwaysAuth && this.registry) { + var auth = this.conf.get('_auth') + var alwaysAuth = this.conf.get('always-auth') + if (auth && !alwaysAuth && registry) { // if we're always authing, then we just send the // user/pass on every thing. otherwise, create a // session, and use that. - this.token = options.token - this.couchLogin = new CouchLogin(this.registry, this.token) - this.couchLogin.proxy = this.proxy - } - - this.email = options.email || null - this.defaultTag = options.tag || "latest" - - this.ca = options.ca || null - - this.strictSSL = options.strictSSL - if (this.strictSSL === undefined) this.strictSSL = true - - this.userAgent = options.userAgent - if (this.userAgent === undefined) { - this.userAgent = 'node/' + process.version + var token = this.conf.get('_token') + this.couchLogin = new CouchLogin(registry, token) + this.couchLogin.proxy = this.conf.get('proxy') } - this.cacheMin = options.cacheMin || 0 - this.cacheMax = options.cacheMax || Infinity - - this.proxy = options.proxy - this.httpsProxy = options.httpsProxy || options.proxy - - this.log = options.log || npmlog + this.log = conf.log || conf.get('log') || npmlog } require('fs').readdirSync(__dirname + "/lib").forEach(function (f) { diff --git a/node_modules/npm-registry-client/lib/adduser.js b/node_modules/npm-registry-client/lib/adduser.js index f940ca1ca..ef8c322a6 100644 --- a/node_modules/npm-registry-client/lib/adduser.js +++ b/node_modules/npm-registry-client/lib/adduser.js @@ -41,18 +41,18 @@ function adduser (username, password, email, cb) { // pluck off any other username/password/token. it needs to be the // same as the user we're becoming now. replace them on error. - var pre = { username: this.username - , password: this.password - , auth: this.auth - , token: this.token } - - this.token = null + var pre = { username: this.conf.get('username') + , password: this.conf.get('_password') + , auth: this.conf.get('_auth') + , token: this.conf.get('_token') } + + this.conf.del('_token') + this.conf.del('username') + this.conf.del('_auth') + this.conf.del('_password') if (this.couchLogin) { this.couchLogin.token = null } - this.username = null - this.password = null - this.auth = null cb = done.call(this, cb, pre) @@ -72,13 +72,13 @@ function adduser (username, password, email, cb) { , function (error, data, json, response) { // if it worked, then we just created a new user, and all is well. // but if we're updating a current record, then it'll 409 first - if (error && !this.auth) { + if (error && !this.conf.get('_auth')) { // must be trying to re-auth on a new machine. // use this info as auth var b = new Buffer(username + ":" + password) - this.auth = b.toString("base64") - this.username = username - this.password = password + this.conf.set('_auth', b.toString("base64")) + this.conf.set('username', username) + this.conf.set('_password', password) } if (!error || !response || response.statusCode !== 409) { @@ -114,16 +114,16 @@ function done (cb, pre) { } // there was some kind of error, re-instate previous auth/token/etc. - this.token = pre.token + this.conf.set('_token', pre.token) if (this.couchLogin) { - this.couchLogin.token = this.token + this.couchLogin.token = pre.token if (this.couchLogin.tokenSet) { this.couchLogin.tokenSet(pre.token) } } - this.username = pre.username - this.password = pre.password - this.auth = pre.auth + this.conf.set('username', pre.username) + this.conf.set('_password', pre.password) + this.conf.set('_auth', pre.auth) this.log.verbose("adduser", "back", [error, data, json]) if (!error) { diff --git a/node_modules/npm-registry-client/lib/get.js b/node_modules/npm-registry-client/lib/get.js index 835eb4ce5..584a986b5 100644 --- a/node_modules/npm-registry-client/lib/get.js +++ b/node_modules/npm-registry-client/lib/get.js @@ -12,10 +12,10 @@ function get (uri, timeout, nofollow, staleOk, cb) { if (typeof cb !== "function") cb = timeout, timeout = -1 if (typeof cb !== "function") cb = version, version = null - timeout = Math.min(timeout, this.cacheMax) - timeout = Math.max(timeout, this.cacheMin) + timeout = Math.min(timeout, this.conf.get('cache-max') || 0) + timeout = Math.max(timeout, this.conf.get('cache-min') || Infinity) - if (!this.registry) timeout = Infinity + if (!this.conf.get('registry')) timeout = Infinity if ( process.env.COMP_CWORD !== undefined && process.env.COMP_LINE !== undefined @@ -29,7 +29,7 @@ function get (uri, timeout, nofollow, staleOk, cb) { return requestAll.call(this, cb) } - var cache = path.join(this.cache, uri, ".cache.json") + var cache = path.join(this.conf.get('cache'), uri, ".cache.json") fs.stat(cache, function (er, stat) { if (!er) fs.readFile(cache, function (er, data) { try { data = JSON.parse(data) } @@ -41,9 +41,9 @@ function get (uri, timeout, nofollow, staleOk, cb) { } function requestAll (cb) { - var cache = path.join(this.cache, "/-/all", ".cache.json") + var cache = path.join(this.conf.get('cache'), "/-/all", ".cache.json") - mkdir(path.join(this.cache, "-", "all"), function (er) { + mkdir(path.join(this.conf.get('cache'), "-", "all"), function (er) { fs.readFile(cache, function (er, data) { if (er) return requestAll_.call(this, 0, {}, cb) try { @@ -74,7 +74,7 @@ function requestAll_ (c, data, cb) { uri = "/-/all" } - var cache = path.join(this.cache, "-/all", ".cache.json") + var cache = path.join(this.conf.get('cache'), "-/all", ".cache.json") this.request('GET', uri, function (er, updates, _, res) { if (er) return cb(er, data) var headers = res.headers @@ -143,20 +143,20 @@ function get_ (uri, timeout, cache, stat, data, nofollow, staleOk, cb) { } function saveToCache (cache, data, saved) { - if (this.cacheStat) { - var cs = this.cacheStat + if (this._cacheStat) { + var cs = this._cacheStat return saveToCache_.call(this, cache, data, cs.uid, cs.gid, saved) } - fs.stat(this.cache, function (er, st) { + fs.stat(this.conf.get('cache'), function (er, st) { if (er) { return fs.stat(process.env.HOME || "", function (er, st) { // if this fails, oh well. if (er) return saved() - this.cacheStat = st + this._cacheStat = st return saveToCache.call(this, cache, data, saved) }.bind(this)) } - this.cacheStat = st || { uid: null, gid: null } + this._cacheStat = st || { uid: null, gid: null } return saveToCache.call(this, cache, data, saved) }.bind(this)) } diff --git a/node_modules/npm-registry-client/lib/publish.js b/node_modules/npm-registry-client/lib/publish.js index 11aa599e6..69e8eb4d0 100644 --- a/node_modules/npm-registry-client/lib/publish.js +++ b/node_modules/npm-registry-client/lib/publish.js @@ -6,7 +6,11 @@ var path = require("path") function publish (data, tarball, cb) { - if (!this.email || !this.auth || !this.username) { + var email = this.conf.get('email') + var auth = this.conf.get('_auth') + var username = this.conf.get('username') + + if (!email || !auth || !username) { return cb(new Error("auth and email required for publishing")) } @@ -15,7 +19,7 @@ function publish (data, tarball, cb) { // if the {version} is already there, then fail. // then: // PUT the data to {config.registry}/{data.name}/{data.version} - var registry = this.registry + var registry = this.conf.get('registry') var fullData = { _id : data.name @@ -25,8 +29,8 @@ function publish (data, tarball, cb) { , versions : {} , readme: data.readme || "" , maintainers : - [ { name : this.username - , email : this.email + [ { name : username + , email : email } ] } @@ -58,7 +62,7 @@ function publish (data, tarball, cb) { var dataURI = encodeURIComponent(data.name) + "/" + encodeURIComponent(data.version) - var tag = data.tag || this.defaultTag || "latest" + var tag = data.tag || this.conf.get('tag') || "latest" dataURI += "/-tag/" + tag // let's see what versions are already published. diff --git a/node_modules/npm-registry-client/lib/request.js b/node_modules/npm-registry-client/lib/request.js index 486226a71..d8f73498d 100644 --- a/node_modules/npm-registry-client/lib/request.js +++ b/node_modules/npm-registry-client/lib/request.js @@ -13,7 +13,8 @@ function regRequest (method, where, what, etag, nofollow, cb_) { if (typeof cb_ !== "function") cb_ = etag, etag = null if (typeof cb_ !== "function") cb_ = what, what = null - if (!this.registry) return cb(new Error( + var registry = this.conf.get('registry') + if (!registry) return cb(new Error( "No registry url provided: " + method + " " + where)) // Since there are multiple places where an error could occur, @@ -29,13 +30,11 @@ function regRequest (method, where, what, etag, nofollow, cb_) { return cb(new Error("favicon.ico isn't a package, it's a picture.")) } - var registry = this.registry - var adduserChange = /^\/?-\/user\/org\.couchdb\.user:([^\/]+)\/-rev/ , adduserNew = /^\/?-\/user\/org\.couchdb\.user:([^\/]+)/ , nu = where.match(adduserNew) , uc = where.match(adduserChange) - , isUpload = what || this.alwaysAuth + , isUpload = what || this.conf.get('always-auth') , isDel = method === "DELETE" , authRequired = isUpload && !nu || uc || isDel @@ -62,15 +61,15 @@ function regRequest (method, where, what, etag, nofollow, cb_) { } var remote = url.parse(where) - , auth = this.auth + , auth = this.conf.get('_auth') - if (authRequired && !this.alwaysAuth) { + if (authRequired && !this.conf.get('always-auth')) { var couch = this.couchLogin - , token = couch && (this.token || couch.token) + , token = couch && (this.conf.get('_token') || couch.token) , validToken = token && couch.valid(token) if (!validToken) token = null - else this.token = token + else this.conf.set('_token', token) if (couch && !token) { // login to get a valid token @@ -81,8 +80,10 @@ function regRequest (method, where, what, etag, nofollow, cb_) { er = er || new Error('login error') return cb(er, cr, data) } - this.token = this.couchLogin.token - return regRequest.call(this, method, where, what, etag, nofollow, cb_) + this.conf.set('_token', this.couchLogin.token) + return regRequest.call(this, + method, where, what, + etag, nofollow, cb_) }.bind(this)) } } @@ -101,11 +102,12 @@ function regRequest (method, where, what, etag, nofollow, cb_) { // Tuned to spread 3 attempts over about a minute. // See formula at <https://github.com/tim-kos/node-retry>. var operation = retry.operation({ - retries: this.retries, - factor: this.retryFactor, - minTimeout: this.retryMinTimeout, - maxTimeout: this.retryMaxTimeout + retries: this.conf.get('fetch-retries') || 2, + factor: this.conf.get('fetch-retry-factor'), + minTimeout: this.conf.get('fetch-retry-mintimeout') || 10000, + maxTimeout: this.conf.get('fetch-retry-maxtimeout') || 60000 }) + var self = this operation.attempt(function (currentAttempt) { self.log.info("retry", "registry request attempt " + currentAttempt @@ -118,8 +120,8 @@ function regRequest (method, where, what, etag, nofollow, cb_) { var timeout = statusCode === 408 var serverError = statusCode >= 500 var statusRetry = !statusCode || timeout || serverError - if (reauth && this.auth && this.token) { - this.token = null + if (reauth && this.conf.get('_auth') && this.conf.get('_token')) { + this.conf.del('_token') this.couchLogin.token = null return regRequest.call(this, method, where, what, etag, nofollow, cb_) } @@ -140,10 +142,12 @@ function makeRequest (method, remote, where, what, etag, nofollow, tok, cb_) { cb_.apply(null, arguments) } + var strict = this.conf.get('strict-ssl') + if (strict === undefined) strict = true var opts = { url: remote , method: method - , ca: this.ca - , strictSSL: this.strictSSL } + , ca: this.conf.get('ca') + , strictSSL: strict } , headers = opts.headers = {} if (etag) { this.log.verbose("etag", etag) @@ -156,10 +160,12 @@ function makeRequest (method, remote, where, what, etag, nofollow, tok, cb_) { headers.accept = "application/json" - headers["user-agent"] = this.userAgent + headers["user-agent"] = this.conf.get('user-agent') || + 'node/' + process.version - opts.proxy = remote.protocol === "https:" - ? this.httpsProxy : this.proxy + var p = this.conf.get('proxy') + var sp = this.conf.get('https-proxy') || p + opts.proxy = remote.protocol === "https:" ? sp : p // figure out wth 'what' is if (what) { @@ -259,7 +265,7 @@ function requestDone (method, where, cb) { , caches = p.map(function (part) { return _ = path.join(_, part) }).map(function (cache) { - return path.join(this.cache, cache, ".cache.json") + return path.join(this.conf.get('cache'), cache, ".cache.json") }, this) // if the method is DELETE, then also remove the thing itself. @@ -267,7 +273,7 @@ function requestDone (method, where, cb) { // That's what you get for deleting stuff. Don't do that. if (method === "DELETE") { p = p.slice(0, p.indexOf("-rev")) - caches.push(path.join(this.cache, p.join("/"))) + caches.push(path.join(this.conf.get('cache'), p.join("/"))) } asyncMap(caches, rm, function () {}) diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json index 709027af4..251703a42 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": "0.1.4", + "version": "0.2.1", "repository": { "url": "git://github.com/isaacs/npm-registry-client" }, @@ -34,7 +34,7 @@ "npmlog": "" }, "license": "BSD", - "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(options)\n\nclient.get(\"npm\", \"latest\", 1000, function (er, 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# Options\n\n* `registry` **Required** {String} URL to the registry\n* `cache` **Required** {String} Path to the cache folder\n* `alwaysAuth` {Boolean} Auth even for GET requests.\n* `auth` {String} A base64-encoded `username:password`\n* `email` {String} User's email address\n* `tag` {String} The default tag to use when publishing new packages.\n Default = `\"latest\"`\n* `ca` {String} Cerficate signing authority certificates to trust.\n* `strictSSL` {Boolean} Whether or not to be strict with SSL\n certificates. Default = `true`\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* `retries` {Number} Number of times to retry on GET failures.\n Default=2\n* `retryFactor` {Number} `factor` setting for `node-retry`. Default=10\n* `retryMinTimeout` {Number} `minTimeout` setting for `node-retry`.\n Default=10000 (10 seconds)\n* `retryMaxTimeout` {Number} `maxTimeout` setting for `node-retry`.\n Default=60000 (60 seconds)\n\n# client.request(method, where, [what], [etag], [nofollow], cb)\n\n* `method` {String} HTTP method\n* `where` {String} Path to request on the server\n* `what` {Stream | Buffer | String | Object} The request body. Objects\n that are not Buffers or Streams are encoded as JSON.\n* `etag` {String} The cached ETag\n* `nofollow` {Boolean} Prevent following 302/301 responses\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 request to the registry. All the other methods are wrappers\naround this. one.\n\n# client.adduser(username, password, email, cb)\n\n* `username` {String}\n* `password` {String}\n* `email` {String}\n* `cb` {Function}\n\nAdd a user account to the registry, or verify the credentials.\n\n# client.get(url, [timeout], [nofollow], [staleOk], cb)\n\n* `url` {String} The url path to fetch\n* `timeout` {Number} Number of seconds old that a cached copy must be\n before a new request will be made.\n* `nofollow` {Boolean} Do not follow 301/302 responses\n* `staleOk` {Boolean} If there's cached data available, then return that\n to the callback quickly, and update the cache the background.\n\nFetches data from the registry via a GET request, saving it in\nthe cache folder with the ETag.\n\n# client.publish(data, tarball, [readme], cb)\n\n* `data` {Object} Package data\n* `tarball` {String | Stream} Filename or stream of the package tarball\n* `readme` {String} Contents of the README markdown file\n* `cb` {Function}\n\nPublish a package to the registry.\n\nNote that this does not create the tarball from a folder. However, it\ncan accept a gzipped tar stream or a filename to a tarball.\n\n# client.star(package, starred, cb)\n\n* `package` {String} Name of the package to star\n* `starred` {Boolean} True to star the package, false to unstar it.\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\nunstar a package, though other writes do require that the user be the\npackage owner.\n\n# client.tag(project, version, tag, cb)\n\n* `project` {String} Project name\n* `version` {String} Version to tag\n* `tag` {String} Tag name to apply\n* `cb` {Function}\n\nMark a version in the `dist-tags` hash, so that `pkg@tag`\nwill fetch the specified version.\n\n# client.unpublish(name, [ver], cb)\n\n* `name` {String} package name\n* `ver` {String} version to unpublish. Leave blank to unpublish all\n versions.\n* `cb` {Function}\n\nRemove a version of a package (or all versions) from the registry. When\nthe last version us unpublished, the entire document is removed from the\ndatabase.\n\n# client.upload(where, file, [etag], [nofollow], cb)\n\n* `where` {String} URL path to upload to\n* `file` {String | Stream} Either the filename or a readable stream\n* `etag` {String} Cache ETag\n* `nofollow` {Boolean} Do not follow 301/302 responses\n* `cb` {Function}\n\nUpload an attachment. Mostly used by `client.publish()`.\n", - "_id": "npm-registry-client@0.1.4", - "_from": "npm-registry-client@latest" + "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)\n\nclient.get(\"npm\", \"latest\", 1000, function (er, 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# Configuration\n\nThis program is designed to work with\n[npmconf](https://npmjs.org/package/npmconf), but you can also pass in\na plain-jane object with the appropriate configs, and it'll shim it\nfor you. Any configuration thingie that has get/set/del methods will\nalso be accepted.\n\n* `registry` **Required** {String} URL to the registry\n* `cache` **Required** {String} Path to the cache folder\n* `always-auth` {Boolean} Auth even for GET requests.\n* `auth` {String} A base64-encoded `username:password`\n* `email` {String} User's email address\n* `tag` {String} The default tag to use when publishing new packages.\n Default = `\"latest\"`\n* `ca` {String} Cerficate signing authority certificates to trust.\n* `strict-ssl` {Boolean} Whether or not to be strict with SSL\n certificates. Default = `true`\n* `user-agent` {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* `fetch-retries` {Number} Number of times to retry on GET failures.\n Default=2\n* `fetch-retry-factor` {Number} `factor` setting for `node-retry`. Default=10\n* `fetch-retry-mintimeout` {Number} `minTimeout` setting for `node-retry`.\n Default=10000 (10 seconds)\n* `fetch-retry-maxtimeout` {Number} `maxTimeout` setting for `node-retry`.\n Default=60000 (60 seconds)\n* `proxy` {URL} The url to proxy requests through.\n* `https-proxy` {URL} The url to proxy https requests through.\n Defaults to be the same as `proxy` if unset.\n* `_auth` {String} The base64-encoded authorization header.\n* `username` `_password` {String} Username/password to use to generate\n `_auth` if not supplied.\n* `_token` {Object} A token for use with\n [couch-login](https://npmjs.org/package/couch-login)\n\n# client.request(method, where, [what], [etag], [nofollow], cb)\n\n* `method` {String} HTTP method\n* `where` {String} Path to request on the server\n* `what` {Stream | Buffer | String | Object} The request body. Objects\n that are not Buffers or Streams are encoded as JSON.\n* `etag` {String} The cached ETag\n* `nofollow` {Boolean} Prevent following 302/301 responses\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 request to the registry. All the other methods are wrappers\naround this. one.\n\n# client.adduser(username, password, email, cb)\n\n* `username` {String}\n* `password` {String}\n* `email` {String}\n* `cb` {Function}\n\nAdd a user account to the registry, or verify the credentials.\n\n# client.get(url, [timeout], [nofollow], [staleOk], cb)\n\n* `url` {String} The url path to fetch\n* `timeout` {Number} Number of seconds old that a cached copy must be\n before a new request will be made.\n* `nofollow` {Boolean} Do not follow 301/302 responses\n* `staleOk` {Boolean} If there's cached data available, then return that\n to the callback quickly, and update the cache the background.\n\nFetches data from the registry via a GET request, saving it in\nthe cache folder with the ETag.\n\n# client.publish(data, tarball, [readme], cb)\n\n* `data` {Object} Package data\n* `tarball` {String | Stream} Filename or stream of the package tarball\n* `readme` {String} Contents of the README markdown file\n* `cb` {Function}\n\nPublish a package to the registry.\n\nNote that this does not create the tarball from a folder. However, it\ncan accept a gzipped tar stream or a filename to a tarball.\n\n# client.star(package, starred, cb)\n\n* `package` {String} Name of the package to star\n* `starred` {Boolean} True to star the package, false to unstar it.\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\nunstar a package, though other writes do require that the user be the\npackage owner.\n\n# client.tag(project, version, tag, cb)\n\n* `project` {String} Project name\n* `version` {String} Version to tag\n* `tag` {String} Tag name to apply\n* `cb` {Function}\n\nMark a version in the `dist-tags` hash, so that `pkg@tag`\nwill fetch the specified version.\n\n# client.unpublish(name, [ver], cb)\n\n* `name` {String} package name\n* `ver` {String} version to unpublish. Leave blank to unpublish all\n versions.\n* `cb` {Function}\n\nRemove a version of a package (or all versions) from the registry. When\nthe last version us unpublished, the entire document is removed from the\ndatabase.\n\n# client.upload(where, file, [etag], [nofollow], cb)\n\n* `where` {String} URL path to upload to\n* `file` {String | Stream} Either the filename or a readable stream\n* `etag` {String} Cache ETag\n* `nofollow` {Boolean} Do not follow 301/302 responses\n* `cb` {Function}\n\nUpload an attachment. Mostly used by `client.publish()`.\n", + "_id": "npm-registry-client@0.2.1", + "_from": "npm-registry-client@~0.2.0" } diff --git a/node_modules/npm-registry-client/test/retries.js b/node_modules/npm-registry-client/test/retries.js index 500abf29d..8f0e63f72 100644 --- a/node_modules/npm-registry-client/test/retries.js +++ b/node_modules/npm-registry-client/test/retries.js @@ -5,9 +5,9 @@ var pkg = { _id: 'some-package@1.2.3', name: 'some-package', version: '1.2.3' } var client = new RC({ - retries: 6 - , retryMinTimeout: 10 - , retryMaxTimeout: 100 + 'fetch-retries': 6 + , 'fetch-retry-mintimeout': 10 + , 'fetch-retry-maxtimeout': 100 , cache: __dirname + '/fixtures/cache' , registry: 'http://localhost:' + server.port }) diff --git a/package.json b/package.json index 7baddccc7..56b24b230 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "chownr": "0", "npmlog": "0", "ansi": "~0.1.2", - "npm-registry-client": "~0.1.4", + "npm-registry-client": "~0.2.1", "read-package-json": "~0.1.3", "read-installed": "0", "glob": "~3.1.12", |