diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-03-19 08:05:58 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-03-19 08:05:58 +0300 |
commit | fe1bc387a14475e373557de669e03d9d006d3173 (patch) | |
tree | f7aae9c27fc917c84561dd69d243c5c1d82988c9 | |
parent | e013d3156a465f86ac378b2f3898322a530a4f38 (diff) |
npm-registry-client@3.1.2
* Use `certificate` instead of `cert` when creating HTTPS agent (fixes
npm/npm-registry-client#103).
* Convert code style to match `standard`.
70 files changed, 2021 insertions, 2044 deletions
diff --git a/node_modules/npm-registry-client/index.js b/node_modules/npm-registry-client/index.js index 6ea288b0a..9b99a2373 100644 --- a/node_modules/npm-registry-client/index.js +++ b/node_modules/npm-registry-client/index.js @@ -2,23 +2,22 @@ module.exports = RegClient -var join = require("path").join - , fs = require("graceful-fs") +var join = require('path').join +var fs = require('graceful-fs') var npmlog try { - npmlog = require("npmlog") -} -catch (er) { + npmlog = require('npmlog') +} catch (er) { npmlog = { - error : noop, - warn : noop, - info : noop, - verbose : noop, - silly : noop, - http : noop, - pause : noop, - resume : noop + error: noop, + warn: noop, + info: noop, + verbose: noop, + silly: noop, + http: noop, + pause: noop, + resume: noop } } @@ -36,20 +35,20 @@ function RegClient (config) { if (this.config.ssl.strict === undefined) this.config.ssl.strict = true this.config.retry = this.config.retry || {} - 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 + 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" + this.config.userAgent = this.config.userAgent || 'node/' + process.version + this.config.defaultTag = this.config.defaultTag || 'latest' this.log = this.config.log || npmlog delete this.config.log var client = this - fs.readdirSync(join(__dirname, "lib")).forEach(function (f) { - var entry = join(__dirname, "lib", f) + fs.readdirSync(join(__dirname, 'lib')).forEach(function (f) { + var entry = join(__dirname, 'lib', f) // lib/group-name/operation.js -> client.groupName.operation var stat = fs.statSync(entry) @@ -62,14 +61,14 @@ function RegClient (config) { // keep client.groupName.operation from stomping client.operation client[groupName] = Object.create(client) } - var name = f.replace(/\.js$/, "").replace(/-([a-z])/, dashToCamel) + var name = f.replace(/\.js$/, '').replace(/-([a-z])/, dashToCamel) client[groupName][name] = require(join(entry, f)) }) return } if (!f.match(/\.js$/)) return - var name = f.replace(/\.js$/, "").replace(/-([a-z])/, dashToCamel) + var name = f.replace(/\.js$/, '').replace(/-([a-z])/, dashToCamel) client[name] = require(entry) }) } diff --git a/node_modules/npm-registry-client/lib/access.js b/node_modules/npm-registry-client/lib/access.js index c642d16f3..b671f6b5f 100644 --- a/node_modules/npm-registry-client/lib/access.js +++ b/node_modules/npm-registry-client/lib/access.js @@ -1,30 +1,30 @@ module.exports = access -var assert = require("assert") +var assert = require('assert') function access (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to access") - assert(params && typeof params === "object", "must pass params to access") - assert(typeof cb === "function", "muss pass callback to access") + assert(typeof uri === 'string', 'must pass registry URI to access') + assert(params && typeof params === 'object', 'must pass params to access') + assert(typeof cb === 'function', 'muss pass callback to access') - assert(typeof params.level === "string", "must pass level to access") + assert(typeof params.level === 'string', 'must pass level to access') assert( - ["public", "restricted"].indexOf(params.level) !== -1, + ['public', 'restricted'].indexOf(params.level) !== -1, "access level must be either 'public' or 'restricted'" ) assert( - params.auth && typeof params.auth === "object", - "must pass auth to access" + params.auth && typeof params.auth === 'object', + 'must pass auth to access' ) var body = { - access : params.level + access: params.level } var options = { - method : "POST", - body : JSON.stringify(body), - auth : params.auth + method: 'POST', + body: JSON.stringify(body), + auth: params.auth } this.request(uri, options, cb) } diff --git a/node_modules/npm-registry-client/lib/adduser.js b/node_modules/npm-registry-client/lib/adduser.js index 5f4abc8ef..bf0a04857 100644 --- a/node_modules/npm-registry-client/lib/adduser.js +++ b/node_modules/npm-registry-client/lib/adduser.js @@ -1,45 +1,45 @@ module.exports = adduser -var url = require("url") -var assert = require("assert") +var url = require('url') +var assert = require('assert') function adduser (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to adduser") + assert(typeof uri === 'string', 'must pass registry URI to adduser') assert( - params && typeof params === "object", - "must pass params to adduser" + params && typeof params === 'object', + 'must pass params to adduser' ) - assert(typeof cb === "function", "must pass callback to adduser") + assert(typeof cb === 'function', 'must pass callback to adduser') - assert(params.auth && typeof params.auth, "must pass auth to adduser") + assert(params.auth && typeof params.auth, 'must pass auth to adduser') var auth = params.auth - assert(typeof auth.username === "string", "must include username in auth") - assert(typeof auth.password === "string", "must include password in auth") - assert(typeof auth.email === "string", "must include email in auth") + assert(typeof auth.username === 'string', 'must include username in auth') + assert(typeof auth.password === 'string', 'must include password in auth') + assert(typeof auth.email === 'string', 'must include email in auth') // normalize registry URL - if (uri.slice(-1) !== "/") uri += "/" + if (uri.slice(-1) !== '/') uri += '/' var username = auth.username.trim() var password = auth.password.trim() var email = auth.email.trim() // validation - if (!username) return cb(new Error("No username supplied.")) - if (!password) return cb(new Error("No password supplied.")) - if (!email) return cb(new Error("No email address supplied.")) + if (!username) return cb(new Error('No username supplied.')) + if (!password) return cb(new Error('No password supplied.')) + if (!email) return cb(new Error('No email address supplied.')) if (!email.match(/^[^@]+@[^\.]+\.[^\.]+/)) { - return cb(new Error("Please use a real email address.")) + return cb(new Error('Please use a real email address.')) } var userobj = { - _id : "org.couchdb.user:"+username, - name : username, - password : password, - email : email, - type : "user", - roles : [], - date : new Date().toISOString() + _id: 'org.couchdb.user:' + username, + name: username, + password: password, + email: email, + type: 'user', + roles: [], + date: new Date().toISOString() } var token = this.config.couchToken @@ -48,22 +48,22 @@ function adduser (uri, params, cb) { cb = done.call(this, token, cb) var logObj = Object.keys(userobj).map(function (k) { - if (k === "password") return [k, "XXXXX"] + if (k === 'password') return [k, 'XXXXX'] return [k, userobj[k]] }).reduce(function (s, kv) { s[kv[0]] = kv[1] return s }, {}) - this.log.verbose("adduser", "before first PUT", logObj) + this.log.verbose('adduser', 'before first PUT', logObj) var client = this - uri = url.resolve(uri, "-/user/org.couchdb.user:" + encodeURIComponent(username)) + uri = url.resolve(uri, '-/user/org.couchdb.user:' + encodeURIComponent(username)) var options = { - method : "PUT", - body : userobj, - auth : auth + method: 'PUT', + body: userobj, + auth: auth } this.request( uri, @@ -73,21 +73,21 @@ function adduser (uri, params, cb) { return cb(error, data, json, response) } - client.log.verbose("adduser", "update existing user") + client.log.verbose('adduser', 'update existing user') return client.request( - uri+"?write=true", - { body : userobj, auth : auth }, + uri + '?write=true', + { body: userobj, auth: auth }, function (er, data, json, response) { if (er || data.error) { return cb(er, data, json, response) } Object.keys(data).forEach(function (k) { - if (!userobj[k] || k === "roles") { + if (!userobj[k] || k === 'roles') { userobj[k] = data[k] } }) - client.log.verbose("adduser", "userobj", logObj) - client.request(uri+"/-rev/"+userobj._rev, options, cb) + client.log.verbose('adduser', 'userobj', logObj) + client.request(uri + '/-rev/' + userobj._rev, options, cb) } ) } @@ -107,19 +107,19 @@ function adduser (uri, params, cb) { } } - client.log.verbose("adduser", "back", [error, data, json]) + client.log.verbose('adduser', 'back', [error, data, json]) if (!error) { error = new Error( - (response && response.statusCode || "") + " " + - "Could not create user\n" + JSON.stringify(data) + (response && response.statusCode || '') + ' ' + + 'Could not create user\n' + JSON.stringify(data) ) } if (response && (response.statusCode === 401 || response.statusCode === 403)) { - client.log.warn("adduser", "Incorrect username or password\n" + - "You can reset your account by visiting:\n" + - "\n" + - " https://npmjs.org/forgot\n") + client.log.warn('adduser', 'Incorrect username or password\n' + + 'You can reset your account by visiting:\n' + + '\n' + + ' https://npmjs.org/forgot\n') } return cb(error) diff --git a/node_modules/npm-registry-client/lib/attempt.js b/node_modules/npm-registry-client/lib/attempt.js index 7f289efeb..d41bbc4fa 100644 --- a/node_modules/npm-registry-client/lib/attempt.js +++ b/node_modules/npm-registry-client/lib/attempt.js @@ -1,16 +1,19 @@ -var retry = require("retry") +var retry = require('retry') module.exports = attempt -function attempt(cb) { +function attempt (cb) { // Tuned to spread 3 attempts over about a minute. // See formula at <https://github.com/tim-kos/node-retry>. var operation = retry.operation(this.config.retry) var client = this operation.attempt(function (currentAttempt) { - client.log.info("attempt", "registry request try #"+currentAttempt+ - " at "+(new Date()).toLocaleTimeString()) + client.log.info( + 'attempt', + 'registry request try #' + currentAttempt + + ' at ' + (new Date()).toLocaleTimeString() + ) cb(operation) }) diff --git a/node_modules/npm-registry-client/lib/authify.js b/node_modules/npm-registry-client/lib/authify.js index 4d1a4dd4a..0a259757b 100644 --- a/node_modules/npm-registry-client/lib/authify.js +++ b/node_modules/npm-registry-client/lib/authify.js @@ -2,8 +2,8 @@ module.exports = authify function authify (authed, parsed, headers, credentials) { if (credentials && credentials.token) { - this.log.verbose("request", "using bearer token for auth") - headers.authorization = "Bearer " + credentials.token + this.log.verbose('request', 'using bearer token for auth') + headers.authorization = 'Bearer ' + credentials.token return null } @@ -12,11 +12,10 @@ function authify (authed, parsed, headers, credentials) { if (credentials && credentials.username && credentials.password) { var username = encodeURIComponent(credentials.username) var password = encodeURIComponent(credentials.password) - parsed.auth = username + ":" + password - } - else { + parsed.auth = username + ':' + password + } else { return new Error( - "This request requires auth credentials. Run `npm login` and repeat the request." + 'This request requires auth credentials. Run `npm login` and repeat the request.' ) } } diff --git a/node_modules/npm-registry-client/lib/deprecate.js b/node_modules/npm-registry-client/lib/deprecate.js index c018570d9..04d311cc0 100644 --- a/node_modules/npm-registry-client/lib/deprecate.js +++ b/node_modules/npm-registry-client/lib/deprecate.js @@ -1,19 +1,19 @@ module.exports = deprecate -var assert = require("assert") -var url = require("url") -var semver = require("semver") +var assert = require('assert') +var url = require('url') +var semver = require('semver') function deprecate (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to deprecate") - assert(params && typeof params === "object", "must pass params to deprecate") - assert(typeof cb === "function", "must pass callback to deprecate") + assert(typeof uri === 'string', 'must pass registry URI to deprecate') + assert(params && typeof params === 'object', 'must pass params to deprecate') + assert(typeof cb === 'function', 'must pass callback to deprecate') - assert(typeof params.version === "string", "must pass version to deprecate") - assert(typeof params.message === "string", "must pass message to deprecate") + assert(typeof params.version === 'string', 'must pass version to deprecate') + assert(typeof params.message === 'string', 'must pass message to deprecate') assert( - params.auth && typeof params.auth === "object", - "must pass auth to deprecate" + params.auth && typeof params.auth === 'object', + 'must pass auth to deprecate' ) var version = params.version @@ -21,10 +21,10 @@ function deprecate (uri, params, cb) { var auth = params.auth if (semver.validRange(version) === null) { - return cb(new Error("invalid version range: "+version)) + return cb(new Error('invalid version range: ' + version)) } - this.get(uri + "?write=true", { auth : auth }, function (er, data) { + this.get(uri + '?write=true', { auth: auth }, function (er, data) { if (er) return cb(er) // filter all the versions that match Object.keys(data.versions).filter(function (v) { @@ -34,9 +34,9 @@ function deprecate (uri, params, cb) { }) // now update the doc on the registry var options = { - method : "PUT", - body : data, - auth : auth + method: 'PUT', + body: data, + auth: auth } this.request(url.resolve(uri, data._id), options, cb) }.bind(this)) diff --git a/node_modules/npm-registry-client/lib/dist-tags/add.js b/node_modules/npm-registry-client/lib/dist-tags/add.js index 7443cbca2..924199ad1 100644 --- a/node_modules/npm-registry-client/lib/dist-tags/add.js +++ b/node_modules/npm-registry-client/lib/dist-tags/add.js @@ -1,43 +1,43 @@ module.exports = add -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') -var npa = require("npm-package-arg") +var npa = require('npm-package-arg') function add (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to distTags.add") + assert(typeof uri === 'string', 'must pass registry URI to distTags.add') assert( - params && typeof params === "object", - "must pass params to distTags.add" + params && typeof params === 'object', + 'must pass params to distTags.add' ) - assert(typeof cb === "function", "muss pass callback to distTags.add") + assert(typeof cb === 'function', 'muss pass callback to distTags.add') assert( - typeof params.package === "string", - "must pass package name to distTags.add" + typeof params.package === 'string', + 'must pass package name to distTags.add' ) assert( - typeof params.distTag === "string", - "must pass package distTag name to distTags.add" + typeof params.distTag === 'string', + 'must pass package distTag name to distTags.add' ) assert( - typeof params.version === "string", - "must pass version to be mapped to distTag to distTags.add" + typeof params.version === 'string', + 'must pass version to be mapped to distTag to distTags.add' ) assert( - params.auth && typeof params.auth === "object", - "must pass auth to distTags.add" + params.auth && typeof params.auth === 'object', + 'must pass auth to distTags.add' ) var p = npa(params.package) - var package = p.scope ? params.package.replace("/", "%2f") : params.package - var rest = "-/package/"+package+"/dist-tags/"+params.distTag + var pkg = p.scope ? params.package.replace('/', '%2f') : params.package + var rest = '-/package/' + pkg + '/dist-tags/' + params.distTag var options = { - method : "PUT", - body : JSON.stringify(params.version), - auth : params.auth + method: 'PUT', + body: JSON.stringify(params.version), + auth: params.auth } this.request(url.resolve(uri, rest), options, cb) } diff --git a/node_modules/npm-registry-client/lib/dist-tags/fetch.js b/node_modules/npm-registry-client/lib/dist-tags/fetch.js index 46bb33f4d..558e2cf82 100644 --- a/node_modules/npm-registry-client/lib/dist-tags/fetch.js +++ b/node_modules/npm-registry-client/lib/dist-tags/fetch.js @@ -1,37 +1,37 @@ module.exports = fetch -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') -var npa = require("npm-package-arg") +var npa = require('npm-package-arg') function fetch (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to distTags.fetch") + assert(typeof uri === 'string', 'must pass registry URI to distTags.fetch') assert( - params && typeof params === "object", - "must pass params to distTags.fetch" + params && typeof params === 'object', + 'must pass params to distTags.fetch' ) - assert(typeof cb === "function", "muss pass callback to distTags.fetch") + assert(typeof cb === 'function', 'muss pass callback to distTags.fetch') assert( - typeof params.package === "string", - "must pass package name to distTags.fetch" + typeof params.package === 'string', + 'must pass package name to distTags.fetch' ) assert( - params.auth && typeof params.auth === "object", - "must pass auth to distTags.fetch" + params.auth && typeof params.auth === 'object', + 'must pass auth to distTags.fetch' ) var p = npa(params.package) - var package = p.scope ? params.package.replace("/", "%2f") : params.package - var rest = "-/package/"+package+"/dist-tags" + var pkg = p.scope ? params.package.replace('/', '%2f') : params.package + var rest = '-/package/' + pkg + '/dist-tags' var options = { - method : "GET", - auth : params.auth + method: 'GET', + auth: params.auth } this.request(url.resolve(uri, rest), options, function (er, data) { - if (data && typeof data === "object") delete data._etag + if (data && typeof data === 'object') delete data._etag cb(er, data) }) } diff --git a/node_modules/npm-registry-client/lib/dist-tags/rm.js b/node_modules/npm-registry-client/lib/dist-tags/rm.js index dbae245ec..d2bdda05d 100644 --- a/node_modules/npm-registry-client/lib/dist-tags/rm.js +++ b/node_modules/npm-registry-client/lib/dist-tags/rm.js @@ -1,38 +1,38 @@ module.exports = rm -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') -var npa = require("npm-package-arg") +var npa = require('npm-package-arg') function rm (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to distTags.rm") + assert(typeof uri === 'string', 'must pass registry URI to distTags.rm') assert( - params && typeof params === "object", - "must pass params to distTags.rm" + params && typeof params === 'object', + 'must pass params to distTags.rm' ) - assert(typeof cb === "function", "muss pass callback to distTags.rm") + assert(typeof cb === 'function', 'muss pass callback to distTags.rm') assert( - typeof params.package === "string", - "must pass package name to distTags.rm" + typeof params.package === 'string', + 'must pass package name to distTags.rm' ) assert( - typeof params.distTag === "string", - "must pass package distTag name to distTags.rm" + typeof params.distTag === 'string', + 'must pass package distTag name to distTags.rm' ) assert( - params.auth && typeof params.auth === "object", - "must pass auth to distTags.rm" + params.auth && typeof params.auth === 'object', + 'must pass auth to distTags.rm' ) var p = npa(params.package) - var package = p.scope ? params.package.replace("/", "%2f") : params.package - var rest = "-/package/"+package+"/dist-tags/"+params.distTag + var pkg = p.scope ? params.package.replace('/', '%2f') : params.package + var rest = '-/package/' + pkg + '/dist-tags/' + params.distTag var options = { - method : "DELETE", - auth : params.auth + method: 'DELETE', + auth: params.auth } this.request(url.resolve(uri, rest), options, cb) } diff --git a/node_modules/npm-registry-client/lib/dist-tags/set.js b/node_modules/npm-registry-client/lib/dist-tags/set.js index e1e17cde5..7af351d63 100644 --- a/node_modules/npm-registry-client/lib/dist-tags/set.js +++ b/node_modules/npm-registry-client/lib/dist-tags/set.js @@ -1,39 +1,39 @@ module.exports = set -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') -var npa = require("npm-package-arg") +var npa = require('npm-package-arg') function set (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to distTags.set") + assert(typeof uri === 'string', 'must pass registry URI to distTags.set') assert( - params && typeof params === "object", - "must pass params to distTags.set" + params && typeof params === 'object', + 'must pass params to distTags.set' ) - assert(typeof cb === "function", "muss pass callback to distTags.set") + assert(typeof cb === 'function', 'muss pass callback to distTags.set') assert( - typeof params.package === "string", - "must pass package name to distTags.set" + typeof params.package === 'string', + 'must pass package name to distTags.set' ) assert( - params.distTags && typeof params.distTags === "object", - "must pass distTags map to distTags.set" + params.distTags && typeof params.distTags === 'object', + 'must pass distTags map to distTags.set' ) assert( - params.auth && typeof params.auth === "object", - "must pass auth to distTags.set" + params.auth && typeof params.auth === 'object', + 'must pass auth to distTags.set' ) var p = npa(params.package) - var package = p.scope ? params.package.replace("/", "%2f") : params.package - var rest = "-/package/"+package+"/dist-tags" + var pkg = p.scope ? params.package.replace('/', '%2f') : params.package + var rest = '-/package/' + pkg + '/dist-tags' var options = { - method : "PUT", - body : JSON.stringify(params.distTags), - auth : params.auth + method: 'PUT', + body: JSON.stringify(params.distTags), + auth: params.auth } this.request(url.resolve(uri, rest), options, cb) } diff --git a/node_modules/npm-registry-client/lib/dist-tags/update.js b/node_modules/npm-registry-client/lib/dist-tags/update.js index 6c46fc532..07ec3e5e7 100644 --- a/node_modules/npm-registry-client/lib/dist-tags/update.js +++ b/node_modules/npm-registry-client/lib/dist-tags/update.js @@ -1,39 +1,39 @@ module.exports = update -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') -var npa = require("npm-package-arg") +var npa = require('npm-package-arg') function update (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to distTags.update") + assert(typeof uri === 'string', 'must pass registry URI to distTags.update') assert( - params && typeof params === "object", - "must pass params to distTags.update" + params && typeof params === 'object', + 'must pass params to distTags.update' ) - assert(typeof cb === "function", "muss pass callback to distTags.update") + assert(typeof cb === 'function', 'muss pass callback to distTags.update') assert( - typeof params.package === "string", - "must pass package name to distTags.update" + typeof params.package === 'string', + 'must pass package name to distTags.update' ) assert( - params.distTags && typeof params.distTags === "object", - "must pass distTags map to distTags.update" + params.distTags && typeof params.distTags === 'object', + 'must pass distTags map to distTags.update' ) assert( - params.auth && typeof params.auth === "object", - "must pass auth to distTags.update" + params.auth && typeof params.auth === 'object', + 'must pass auth to distTags.update' ) var p = npa(params.package) - var package = p.scope ? params.package.replace("/", "%2f") : params.package - var rest = "-/package/"+package+"/dist-tags" + var pkg = p.scope ? params.package.replace('/', '%2f') : params.package + var rest = '-/package/' + pkg + '/dist-tags' var options = { - method : "POST", - body : JSON.stringify(params.distTags), - auth : params.auth + method: 'POST', + body: JSON.stringify(params.distTags), + auth: params.auth } this.request(url.resolve(uri, rest), options, cb) } diff --git a/node_modules/npm-registry-client/lib/fetch.js b/node_modules/npm-registry-client/lib/fetch.js index 2d1c6f6b8..e931d371e 100644 --- a/node_modules/npm-registry-client/lib/fetch.js +++ b/node_modules/npm-registry-client/lib/fetch.js @@ -1,15 +1,15 @@ -var assert = require("assert") - , url = require("url") +var assert = require('assert') +var url = require('url') -var request = require("request") - , once = require("once") +var request = require('request') +var once = require('once') module.exports = fetch function fetch (uri, params, cb) { - assert(typeof uri === "string", "must pass uri to request") - assert(params && typeof params === "object", "must pass params to request") - assert(typeof cb === "function", "must pass callback to request") + assert(typeof uri === 'string', 'must pass uri to request') + assert(params && typeof params === 'object', 'must pass params to request') + assert(typeof cb === 'function', 'must pass callback to request') cb = once(cb) @@ -18,17 +18,16 @@ function fetch (uri, params, cb) { makeRequest.call(client, uri, params, function (er, req) { if (er) return cb(er) - req.on("error", function (er) { + req.on('error', function (er) { if (operation.retry(er)) { - client.log.info("retry", "will retry, error on last attempt: " + er) - } - else { + client.log.info('retry', 'will retry, error on last attempt: ' + er) + } else { cb(er) } }) - req.on("response", function (res) { - client.log.http("fetch", "" + res.statusCode, uri) + req.on('response', function (res) { + client.log.http('fetch', '' + res.statusCode, uri) var er var statusCode = res && res.statusCode @@ -36,40 +35,39 @@ function fetch (uri, params, cb) { // Work around bug in node v0.10.0 where the CryptoStream // gets stuck and never starts reading again. res.resume() - if (process.version === "v0.10.0") unstick(res) + if (process.version === 'v0.10.0') unstick(res) return cb(null, res) - } - // Only retry on 408, 5xx or no `response`. - else if (statusCode === 408) { - er = new Error("request timed out") - } - else if (statusCode >= 500) { - er = new Error("server error " + statusCode) + // Only retry on 408, 5xx or no `response`. + } else if (statusCode === 408) { + er = new Error('request timed out') + } else if (statusCode >= 500) { + er = new Error('server error ' + statusCode) } if (er && operation.retry(er)) { - client.log.info("retry", "will retry, error on last attempt: " + er) - } - else { - cb(new Error("fetch failed with status code " + statusCode)) + client.log.info('retry', 'will retry, error on last attempt: ' + er) + } else { + cb(new Error('fetch failed with status code ' + statusCode)) } }) }) }) } -function unstick(response) { - response.resume = function (orig) { return function() { - var ret = orig.apply(response, arguments) - if (response.socket.encrypted) response.socket.encrypted.read(0) - return ret - }}(response.resume) +function unstick (response) { + response.resume = (function (orig) { + return function () { + var ret = orig.apply(response, arguments) + if (response.socket.encrypted) response.socket.encrypted.read(0) + return ret + } + })(response.resume) } function makeRequest (remote, params, cb) { var parsed = url.parse(remote) - this.log.http("fetch", "GET", parsed.href) + this.log.http('fetch', 'GET', parsed.href) var headers = params.headers || {} var er = this.authify( @@ -82,8 +80,8 @@ function makeRequest (remote, params, cb) { var opts = this.initialize( parsed, - "GET", - "application/x-tar, application/vnd.github+json; q=0.1", + 'GET', + 'application/x-tar, application/vnd.github+json; q=0.1', headers ) // always want to follow redirects for fetch diff --git a/node_modules/npm-registry-client/lib/get.js b/node_modules/npm-registry-client/lib/get.js index 17e134977..ab0eae10f 100644 --- a/node_modules/npm-registry-client/lib/get.js +++ b/node_modules/npm-registry-client/lib/get.js @@ -1,21 +1,21 @@ module.exports = get -var assert = require("assert") - , url = require("url") +var assert = require('assert') +var url = require('url') /* * This is meant to be overridden in specific implementations if you * want specialized behavior for metadata (i.e. caching). */ function get (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to get") - assert(params && typeof params === "object", "must pass params to get") - assert(typeof cb === "function", "must pass callback to get") + assert(typeof uri === 'string', 'must pass registry URI to get') + assert(params && typeof params === 'object', 'must pass params to get') + assert(typeof cb === 'function', 'must pass callback to get') var parsed = url.parse(uri) assert( - parsed.protocol === "http:" || parsed.protocol === "https:", - "must have a URL that starts with http: or https:" + parsed.protocol === 'http:' || parsed.protocol === 'https:', + 'must have a URL that starts with http: or https:' ) this.request(uri, params, cb) diff --git a/node_modules/npm-registry-client/lib/initialize.js b/node_modules/npm-registry-client/lib/initialize.js index e7215bc78..4a2160fbb 100644 --- a/node_modules/npm-registry-client/lib/initialize.js +++ b/node_modules/npm-registry-client/lib/initialize.js @@ -1,8 +1,8 @@ -var crypto = require("crypto") -var HttpAgent = require("http").Agent -var HttpsAgent = require("https").Agent +var crypto = require('crypto') +var HttpAgent = require('http').Agent +var HttpsAgent = require('https').Agent -var pkg = require("../package.json") +var pkg = require('../package.json') var httpAgent var httpsAgent @@ -11,20 +11,20 @@ module.exports = initialize function initialize (uri, method, accept, headers) { if (!this.config.sessionToken) { - this.config.sessionToken = crypto.randomBytes(8).toString("hex") - this.log.verbose("request id", this.config.sessionToken) + this.config.sessionToken = crypto.randomBytes(8).toString('hex') + this.log.verbose('request id', this.config.sessionToken) } var opts = { - url : uri, - method : method, - headers : headers, - localAddress : this.config.proxy.localAddress, - strictSSL : this.config.ssl.strict, - cert : this.config.ssl.certificate, - key : this.config.ssl.key, - ca : this.config.ssl.ca, - agent : getAgent(uri.protocol, this.config) + url: uri, + method: method, + headers: headers, + localAddress: this.config.proxy.localAddress, + strictSSL: this.config.ssl.strict, + cert: this.config.ssl.certificate, + key: this.config.ssl.key, + ca: this.config.ssl.ca, + agent: getAgent(uri.protocol, this.config) } // allow explicit disabling of proxy in environment via CLI @@ -32,18 +32,16 @@ function initialize (uri, method, accept, headers) { // how false gets here is the CLI's problem (it's gross) if (this.config.proxy.http === false) { opts.proxy = null - } - else { + } else { // request will not pay attention to the NOPROXY environment variable if a // config value named proxy is passed in, even if it's set to null. var proxy - if (uri.protocol === "https:") { + if (uri.protocol === 'https:') { proxy = this.config.proxy.https - } - else { + } else { proxy = this.config.proxy.http } - if (typeof proxy === "string") opts.proxy = proxy + if (typeof proxy === 'string') opts.proxy = proxy } headers.version = this.version || pkg.version @@ -51,32 +49,31 @@ function initialize (uri, method, accept, headers) { if (this.refer) headers.referer = this.refer - headers["npm-session"] = this.config.sessionToken - headers["user-agent"] = this.config.userAgent + headers['npm-session'] = this.config.sessionToken + headers['user-agent'] = this.config.userAgent return opts } function getAgent (protocol, config) { - if (protocol === "https:") { + if (protocol === 'https:') { if (!httpsAgent) { httpsAgent = new HttpsAgent({ - keepAlive : true, - localAddress : config.proxy.localAddress, - rejectUnauthorized : config.ssl.strict, - ca : config.ssl.ca, - cert : config.ssl.cert, - key : config.ssl.key + keepAlive: true, + localAddress: config.proxy.localAddress, + rejectUnauthorized: config.ssl.strict, + ca: config.ssl.ca, + cert: config.ssl.certificate, + key: config.ssl.key }) } return httpsAgent - } - else { + } else { if (!httpAgent) { httpAgent = new HttpAgent({ - keepAlive : true, - localAddress : config.proxy.localAddress + keepAlive: true, + localAddress: config.proxy.localAddress }) } diff --git a/node_modules/npm-registry-client/lib/logout.js b/node_modules/npm-registry-client/lib/logout.js index 00964a4be..e66e9b78a 100644 --- a/node_modules/npm-registry-client/lib/logout.js +++ b/node_modules/npm-registry-client/lib/logout.js @@ -1,23 +1,23 @@ module.exports = logout -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') function logout (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to logout") - assert(params && typeof params === "object", "must pass params to logout") - assert(typeof cb === "function", "must pass callback to star") + assert(typeof uri === 'string', 'must pass registry URI to logout') + assert(params && typeof params === 'object', 'must pass params to logout') + assert(typeof cb === 'function', 'must pass callback to star') var auth = params.auth - assert(auth && typeof auth === "object", "must pass auth to logout") - assert(typeof auth.token === "string", "can only log out for token auth") + assert(auth && typeof auth === 'object', 'must pass auth to logout') + assert(typeof auth.token === 'string', 'can only log out for token auth') - uri = url.resolve(uri, "-/user/token/" + auth.token) + uri = url.resolve(uri, '-/user/token/' + auth.token) var options = { - method: "DELETE", + method: 'DELETE', auth: auth } - this.log.verbose("logout", "invalidating session token for user") + this.log.verbose('logout', 'invalidating session token for user') this.request(uri, options, cb) } diff --git a/node_modules/npm-registry-client/lib/publish.js b/node_modules/npm-registry-client/lib/publish.js index 348648b2e..f6f37ab47 100644 --- a/node_modules/npm-registry-client/lib/publish.js +++ b/node_modules/npm-registry-client/lib/publish.js @@ -1,60 +1,59 @@ module.exports = publish -var url = require("url") - , semver = require("semver") - , crypto = require("crypto") - , Stream = require("stream").Stream - , assert = require("assert") - , fixer = require("normalize-package-data/lib/fixer.js") - , concat = require("concat-stream") +var url = require('url') +var semver = require('semver') +var crypto = require('crypto') +var Stream = require('stream').Stream +var assert = require('assert') +var fixer = require('normalize-package-data/lib/fixer.js') +var concat = require('concat-stream') function escaped (name) { - return name.replace("/", "%2f") + return name.replace('/', '%2f') } function publish (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to publish") - assert(params && typeof params === "object", "must pass params to publish") - assert(typeof cb === "function", "must pass callback to publish") + assert(typeof uri === 'string', 'must pass registry URI to publish') + assert(params && typeof params === 'object', 'must pass params to publish') + assert(typeof cb === 'function', 'must pass callback to publish') var access = params.access assert( - (!access) || ["public", "restricted"].indexOf(access) !== -1, + (!access) || ['public', 'restricted'].indexOf(access) !== -1, "if present, access level must be either 'public' or 'restricted'" ) var auth = params.auth - assert(auth && typeof auth === "object", "must pass auth to publish") + assert(auth && typeof auth === 'object', 'must pass auth to publish') if (!(auth.token || (auth.password && auth.username && auth.email))) { - var er = new Error("auth required for publishing") - er.code = "ENEEDAUTH" + var er = new Error('auth required for publishing') + er.code = 'ENEEDAUTH' return cb(er) } var metadata = params.metadata assert( - metadata && typeof metadata === "object", - "must pass package metadata to publish" + metadata && typeof metadata === 'object', + 'must pass package metadata to publish' ) try { fixer.fixNameField(metadata, true) - } - catch (er) { + } catch (er) { return cb(er) } var version = semver.clean(metadata.version) - if (!version) return cb(new Error("invalid semver: " + metadata.version)) + if (!version) return cb(new Error('invalid semver: ' + metadata.version)) metadata.version = version var body = params.body - assert(body, "must pass package body to publish") - assert(body instanceof Stream, "package body passed to publish must be a stream") + assert(body, 'must pass package body to publish') + assert(body instanceof Stream, 'package body passed to publish must be a stream') var client = this var sink = concat(function (tarbuffer) { putFirst.call(client, uri, metadata, tarbuffer, access, auth, cb) }) - sink.on("error", cb) + sink.on('error', cb) body.pipe(sink) } @@ -63,67 +62,67 @@ function putFirst (registry, data, tarbuffer, access, auth, cb) { // If 409, then GET and merge, try again. // If other error, then fail. - var root = - { _id : data.name - , name : data.name - , description : data.description - , "dist-tags" : {} - , versions : {} - , readme: data.readme || "" - } + var root = { + _id: data.name, + name: data.name, + description: data.description, + 'dist-tags': {}, + versions: {}, + readme: data.readme || '' + } if (access) root.access = access if (!auth.token) { - root.maintainers = [{name : auth.username, email : auth.email}] + root.maintainers = [{ name: auth.username, email: auth.email }] data.maintainers = JSON.parse(JSON.stringify(root.maintainers)) } root.versions[ data.version ] = data var tag = data.tag || this.config.defaultTag - root["dist-tags"][tag] = data.version + root['dist-tags'][tag] = data.version - var tbName = data.name + "-" + data.version + ".tgz" - , tbURI = data.name + "/-/" + tbName + var tbName = data.name + '-' + data.version + '.tgz' + var tbURI = data.name + '/-/' + tbName - data._id = data.name+"@"+data.version + data._id = data.name + '@' + data.version data.dist = data.dist || {} - data.dist.shasum = crypto.createHash("sha1").update(tarbuffer).digest("hex") + data.dist.shasum = crypto.createHash('sha1').update(tarbuffer).digest('hex') data.dist.tarball = url.resolve(registry, tbURI) - .replace(/^https:\/\//, "http://") + .replace(/^https:\/\//, 'http://') root._attachments = {} root._attachments[ tbName ] = { - "content_type": "application/octet-stream", - "data": tarbuffer.toString("base64"), - "length": tarbuffer.length + 'content_type': 'application/octet-stream', + 'data': tarbuffer.toString('base64'), + 'length': tarbuffer.length } var fixed = url.resolve(registry, escaped(data.name)) var client = this var options = { - method : "PUT", - body : root, - auth : auth + method: 'PUT', + body: root, + auth: auth } this.request(fixed, options, function (er, parsed, json, res) { - var r409 = "must supply latest _rev to update existing package" - var r409b = "Document update conflict." + var r409 = 'must supply latest _rev to update existing package' + var r409b = 'Document update conflict.' var conflict = res && res.statusCode === 409 - if (parsed && (parsed.reason === r409 || parsed.reason === r409b)) + if (parsed && (parsed.reason === r409 || parsed.reason === r409b)) { conflict = true + } // a 409 is typical here. GET the data and merge in. if (er && !conflict) { - client.log.error("publish", "Failed PUT "+(res && res.statusCode)) + client.log.error('publish', 'Failed PUT ' + (res && res.statusCode)) return cb(er) } - if (!er && !conflict) - return cb(er, parsed, json, res) + if (!er && !conflict) return cb(er, parsed, json, res) // let's see what versions are already published. - client.request(fixed+"?write=true", { auth : auth }, function (er, current) { + client.request(fixed + '?write=true', { auth: auth }, function (er, current) { if (er) return cb(er) putNext.call(client, registry, data.version, root, current, auth, cb) @@ -136,10 +135,9 @@ function putNext (registry, newVersion, root, current, auth, cb) { // just merge in existing stuff var curVers = Object.keys(current.versions || {}).map(function (v) { return semver.clean(v, true) - }).concat(Object.keys(current.time || {}).map(function(v) { - if (semver.valid(v, true)) - return semver.clean(v, true) - }).filter(function(v) { + }).concat(Object.keys(current.time || {}).map(function (v) { + if (semver.valid(v, true)) return semver.clean(v, true) + }).filter(function (v) { return v })) @@ -152,15 +150,15 @@ function putNext (registry, newVersion, root, current, auth, cb) { for (var i in root) { switch (i) { // objects that copy over the new stuffs - case "dist-tags": - case "versions": - case "_attachments": + case 'dist-tags': + case 'versions': + case '_attachments': for (var j in root[i]) current[i][j] = root[i][j] break // ignore these - case "maintainers": + case 'maintainers': break // copy @@ -173,16 +171,16 @@ function putNext (registry, newVersion, root, current, auth, cb) { var uri = url.resolve(registry, escaped(root.name)) var options = { - method : "PUT", - body : current, - auth : auth + method: 'PUT', + body: current, + auth: auth } this.request(uri, options, cb) } function conflictError (pkgid, version) { - var e = new Error("cannot modify pre-existing version") - e.code = "EPUBLISHCONFLICT" + var e = new Error('cannot modify pre-existing version') + e.code = 'EPUBLISHCONFLICT' e.pkgid = pkgid e.version = version return e diff --git a/node_modules/npm-registry-client/lib/request.js b/node_modules/npm-registry-client/lib/request.js index c2a7944e9..963eabaec 100644 --- a/node_modules/npm-registry-client/lib/request.js +++ b/node_modules/npm-registry-client/lib/request.js @@ -5,21 +5,21 @@ module.exports = regRequest // 2. send authorization // 3. content-type is 'application/json' -- metadata // -var assert = require("assert") - , url = require("url") - , zlib = require("zlib") - , Stream = require("stream").Stream +var assert = require('assert') +var url = require('url') +var zlib = require('zlib') +var Stream = require('stream').Stream -var request = require("request") - , once = require("once") +var request = require('request') +var once = require('once') function regRequest (uri, params, cb_) { - assert(typeof uri === "string", "must pass uri to request") - assert(params && typeof params === "object", "must pass params to request") - assert(typeof cb_ === "function", "must pass callback to request") + assert(typeof uri === 'string', 'must pass uri to request') + assert(params && typeof params === 'object', 'must pass params to request') + assert(typeof cb_ === 'function', 'must pass callback to request') - params.method = params.method || "GET" - this.log.verbose("request", "uri", uri) + params.method = params.method || 'GET' + this.log.verbose('request', 'uri', uri) // Since there are multiple places where an error could occur, // don't let the cb be called more than once. @@ -30,37 +30,33 @@ function regRequest (uri, params, cb_) { } var adduserChange = /\/?-\/user\/org\.couchdb\.user:([^/]+)\/-rev/ - , isUserChange = uri.match(adduserChange) - , adduserNew = /\/?-\/user\/org\.couchdb\.user:([^/?]+)$/ - , isNewUser = uri.match(adduserNew) - , alwaysAuth = params.auth && params.auth.alwaysAuth - , isDelete = params.method === "DELETE" - , isWrite = params.body || isDelete + var isUserChange = uri.match(adduserChange) + var adduserNew = /\/?-\/user\/org\.couchdb\.user:([^/?]+)$/ + var isNewUser = uri.match(adduserNew) + var alwaysAuth = params.auth && params.auth.alwaysAuth + var isDelete = params.method === 'DELETE' + var isWrite = params.body || isDelete if (isUserChange && !isWrite) { - return cb(new Error("trying to change user document without writing(?!)")) + return cb(new Error('trying to change user document without writing(?!)')) } // new users can *not* use auth, because they don't *have* auth yet if (isUserChange) { - this.log.verbose("request", "updating existing user; sending authorization") + this.log.verbose('request', 'updating existing user; sending authorization') params.authed = true - } - else if (isNewUser) { - this.log.verbose("request", "new user, so can't send auth") + } else if (isNewUser) { + this.log.verbose('request', "new user, so can't send auth") params.authed = false - } - else if (alwaysAuth) { - this.log.verbose("request", "always-auth set; sending authorization") + } else if (alwaysAuth) { + this.log.verbose('request', 'always-auth set; sending authorization') params.authed = true - } - else if (isWrite) { - this.log.verbose("request", "sending authorization for write operation") + } else if (isWrite) { + this.log.verbose('request', 'sending authorization for write operation') params.authed = true - } - else { + } else { // most of the time we don't want to auth - this.log.verbose("request", "no auth needed") + this.log.verbose('request', 'no auth needed') params.authed = false } @@ -68,8 +64,7 @@ function regRequest (uri, params, cb_) { this.attempt(function (operation) { makeRequest.call(self, uri, params, function (er, parsed, raw, response) { if (!er || (er.message && er.message.match(/^SSL Error/))) { - if (er) - er.code = "ESSL" + if (er) er.code = 'ESSL' return cb(er, parsed, raw, response) } @@ -80,13 +75,13 @@ function regRequest (uri, params, cb_) { var serverError = statusCode >= 500 var statusRetry = !statusCode || timeout || serverError if (er && statusRetry && operation.retry(er)) { - self.log.info("retry", "will retry, error on last attempt: " + er) + self.log.info('retry', 'will retry, error on last attempt: ' + er) return undefined } if (response) { - self.log.verbose("headers", response.headers) - if (response.headers["npm-notice"]) { - self.log.warn("notice", response.headers["npm-notice"]) + self.log.verbose('headers', response.headers) + if (response.headers['npm-notice']) { + self.log.warn('notice', response.headers['npm-notice']) } } cb.apply(null, arguments) @@ -101,7 +96,7 @@ function makeRequest (uri, params, cb_) { var headers = {} // metadata should be compressed - headers["accept-encoding"] = "gzip" + headers['accept-encoding'] = 'gzip' var er = this.authify(params.authed, parsed, headers, params.auth) if (er) return cb_(er) @@ -109,54 +104,51 @@ function makeRequest (uri, params, cb_) { var opts = this.initialize( parsed, params.method, - "application/json", + 'application/json', headers ) - opts.followRedirect = (typeof params.follow === "boolean" ? params.follow : true) + opts.followRedirect = (typeof params.follow === 'boolean' ? params.follow : true) opts.encoding = null // tell request let body be Buffer instance if (params.etag) { - this.log.verbose("etag", params.etag) - headers[params.method === "GET" ? "if-none-match" : "if-match"] = params.etag + this.log.verbose('etag', params.etag) + headers[params.method === 'GET' ? 'if-none-match' : 'if-match'] = params.etag } - if (params.lastModified && params.method === "GET") { - this.log.verbose("lastModified", params.lastModified) - headers["if-modified-since"] = params.lastModified + if (params.lastModified && params.method === 'GET') { + this.log.verbose('lastModified', params.lastModified) + headers['if-modified-since'] = params.lastModified } // figure out wth body is if (params.body) { if (Buffer.isBuffer(params.body)) { opts.body = params.body - headers["content-type"] = "application/json" - headers["content-length"] = params.body.length - } - else if (typeof params.body === "string") { + headers['content-type'] = 'application/json' + headers['content-length'] = params.body.length + } else if (typeof params.body === 'string') { opts.body = params.body - headers["content-type"] = "application/json" - headers["content-length"] = Buffer.byteLength(params.body) - } - else if (params.body instanceof Stream) { - headers["content-type"] = "application/octet-stream" - if (params.body.size) headers["content-length"] = params.body.size - } - else { + headers['content-type'] = 'application/json' + headers['content-length'] = Buffer.byteLength(params.body) + } else if (params.body instanceof Stream) { + headers['content-type'] = 'application/octet-stream' + if (params.body.size) headers['content-length'] = params.body.size + } else { delete params.body._etag delete params.body._lastModified opts.json = params.body } } - this.log.http("request", params.method, parsed.href || "/") + this.log.http('request', params.method, parsed.href || '/') var done = requestDone.call(this, params.method, uri, cb) var req = request(opts, decodeResponseBody(done)) - req.on("error", cb) - req.on("socket", function (s) { - s.on("error", cb) + req.on('error', cb) + req.on('socket', function (s) { + s.on('error', cb) }) if (params.body && (params.body instanceof Stream)) { @@ -164,7 +156,7 @@ function makeRequest (uri, params, cb_) { } } -function decodeResponseBody(cb) { +function decodeResponseBody (cb) { return function (er, response, data) { if (er) return cb(er, response, data) @@ -174,7 +166,7 @@ function decodeResponseBody(cb) { response.socket.destroy() } - if (response.headers["content-encoding"] !== "gzip") { + if (response.headers['content-encoding'] !== 'gzip') { return cb(er, response, data) } @@ -192,7 +184,7 @@ function requestDone (method, where, cb) { if (er) return cb(er) var urlObj = url.parse(where) - if (urlObj.auth) urlObj.auth = "***" + if (urlObj.auth) urlObj.auth = '***' this.log.http(response.statusCode, url.format(urlObj)) if (Buffer.isBuffer(data)) { @@ -200,13 +192,13 @@ function requestDone (method, where, cb) { } var parsed - if (data && typeof data === "string" && response.statusCode !== 304) { + if (data && typeof data === 'string' && response.statusCode !== 304) { try { parsed = JSON.parse(data) } catch (ex) { - ex.message += "\n" + data - this.log.verbose("bad json", data) - this.log.error("registry", "error parsing json") + ex.message += '\n' + data + this.log.verbose('bad json', data) + this.log.error('registry', 'error parsing json') return cb(ex, null, data, response) } } else if (data) { @@ -216,9 +208,12 @@ function requestDone (method, where, cb) { // expect data with any error codes if (!data && response.statusCode >= 400) { - return cb( response.statusCode + " " - + require("http").STATUS_CODES[response.statusCode] - , null, data, response ) + return cb( + response.statusCode + ' ' + require('http').STATUS_CODES[response.statusCode], + null, + data, + response + ) } er = null @@ -226,38 +221,36 @@ function requestDone (method, where, cb) { parsed._etag = response.headers.etag } - if (parsed && response.headers["last-modified"]) { - parsed._lastModified = response.headers["last-modified"] + if (parsed && response.headers['last-modified']) { + parsed._lastModified = response.headers['last-modified'] } - // for the search endpoint, the "error" property can be an object - if (parsed && parsed.error && typeof parsed.error !== "object" || + // for the search endpoint, the 'error' property can be an object + if (parsed && parsed.error && typeof parsed.error !== 'object' || response.statusCode >= 400) { var w = url.parse(where).pathname.substr(1) var name if (!w.match(/^-/)) { - w = w.split("/") - name = w[w.indexOf("_rewrite") + 1] + w = w.split('/') + name = w[w.indexOf('_rewrite') + 1] } if (!parsed.error) { er = new Error( - "Registry returned " + response.statusCode + - " for " + method + - " on " + where + 'Registry returned ' + response.statusCode + + ' for ' + method + + ' on ' + where ) - } - else if (name && parsed.error === "not_found") { - er = new Error("404 Not Found: " + name) - } - else { + } else if (name && parsed.error === 'not_found') { + er = new Error('404 Not Found: ' + name) + } 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 + er.code = 'E' + er.statusCode } return cb(er, parsed, data, response) }.bind(this) diff --git a/node_modules/npm-registry-client/lib/star.js b/node_modules/npm-registry-client/lib/star.js index 87c5b67c4..426b40cec 100644 --- a/node_modules/npm-registry-client/lib/star.js +++ b/node_modules/npm-registry-client/lib/star.js @@ -1,50 +1,49 @@ module.exports = star -var assert = require("assert") +var assert = require('assert') function star (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to star") - assert(params && typeof params === "object", "must pass params to star") - assert(typeof cb === "function", "must pass callback to star") + assert(typeof uri === 'string', 'must pass registry URI to star') + assert(params && typeof params === 'object', 'must pass params to star') + assert(typeof cb === 'function', 'must pass callback to star') var starred = params.starred ? true : false var auth = params.auth - assert(auth && typeof auth === "object", "must pass auth to star") + assert(auth && typeof auth === 'object', 'must pass auth to star') if (!(auth.token || (auth.password && auth.username && auth.email))) { - var er = new Error("Must be logged in to star/unstar packages") - er.code = "ENEEDAUTH" + var er = new Error('Must be logged in to star/unstar packages') + er.code = 'ENEEDAUTH' return cb(er) } var client = this - this.request(uri+"?write=true", { auth : auth }, function (er, fullData) { + this.request(uri + '?write=true', { auth: auth }, function (er, fullData) { if (er) return cb(er) client.whoami(uri, params, function (er, username) { if (er) return cb(er) var data = { - _id : fullData._id, - _rev : fullData._rev, - users : fullData.users || {} + _id: fullData._id, + _rev: fullData._rev, + users: fullData.users || {} } if (starred) { - client.log.info("starring", data._id) + client.log.info('starring', data._id) data.users[username] = true - client.log.verbose("starring", data) - } - else { + client.log.verbose('starring', data) + } else { delete data.users[username] - client.log.info("unstarring", data._id) - client.log.verbose("unstarring", data) + client.log.info('unstarring', data._id) + client.log.verbose('unstarring', data) } var options = { - method : "PUT", - body : data, - auth : auth + method: 'PUT', + body: data, + auth: auth } return client.request(uri, options, cb) }) diff --git a/node_modules/npm-registry-client/lib/stars.js b/node_modules/npm-registry-client/lib/stars.js index f55551242..ba47f2c1e 100644 --- a/node_modules/npm-registry-client/lib/stars.js +++ b/node_modules/npm-registry-client/lib/stars.js @@ -1,18 +1,18 @@ module.exports = stars -var assert = require("assert") -var url = require("url") +var assert = require('assert') +var url = require('url') function stars (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to stars") - assert(params && typeof params === "object", "must pass params to stars") - assert(typeof cb === "function", "must pass callback to stars") + assert(typeof uri === 'string', 'must pass registry URI to stars') + assert(params && typeof params === 'object', 'must pass params to stars') + assert(typeof cb === 'function', 'must pass callback to stars') var auth = params.auth var name = params.username || (auth && auth.username) - if (!name) return cb(new Error("must pass either username or auth to stars")) + if (!name) return cb(new Error('must pass either username or auth to stars')) var encoded = encodeURIComponent(name) - var path = "-/_view/starredByUser?key=\""+encoded+"\"" + var path = '-/_view/starredByUser?key="' + encoded + '"' - this.request(url.resolve(uri, path), { auth : auth }, cb) + this.request(url.resolve(uri, path), { auth: auth }, cb) } diff --git a/node_modules/npm-registry-client/lib/tag.js b/node_modules/npm-registry-client/lib/tag.js index cad5154d7..3b6dad1df 100644 --- a/node_modules/npm-registry-client/lib/tag.js +++ b/node_modules/npm-registry-client/lib/tag.js @@ -1,23 +1,23 @@ module.exports = tag -var assert = require("assert") +var assert = require('assert') function tag (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to tag") - assert(params && typeof params === "object", "must pass params to tag") - assert(typeof cb === "function", "must pass callback to tag") + assert(typeof uri === 'string', 'must pass registry URI to tag') + assert(params && typeof params === 'object', 'must pass params to tag') + assert(typeof cb === 'function', 'must pass callback to tag') - assert(typeof params.version === "string", "must pass version to tag") - assert(typeof params.tag === "string", "must pass tag name to tag") + assert(typeof params.version === 'string', 'must pass version to tag') + assert(typeof params.tag === 'string', 'must pass tag name to tag') assert( - params.auth && typeof params.auth === "object", - "must pass auth to tag" + params.auth && typeof params.auth === 'object', + 'must pass auth to tag' ) var options = { - method : "PUT", - body : JSON.stringify(params.version), - auth : params.auth + method: 'PUT', + body: JSON.stringify(params.version), + auth: params.auth } - this.request(uri+"/"+params.tag, options, cb) + this.request(uri + '/' + params.tag, options, cb) } diff --git a/node_modules/npm-registry-client/lib/unpublish.js b/node_modules/npm-registry-client/lib/unpublish.js index e6e954935..05c5a4b61 100644 --- a/node_modules/npm-registry-client/lib/unpublish.js +++ b/node_modules/npm-registry-client/lib/unpublish.js @@ -6,63 +6,63 @@ module.exports = unpublish // else, PUT the modified data // delete the tarball -var semver = require("semver") - , url = require("url") - , chain = require("slide").chain - , assert = require("assert") +var semver = require('semver') +var url = require('url') +var chain = require('slide').chain +var assert = require('assert') function unpublish (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to unpublish") - assert(params && typeof params === "object", "must pass params to unpublish") - assert(typeof cb === "function", "must pass callback to unpublish") + assert(typeof uri === 'string', 'must pass registry URI to unpublish') + assert(params && typeof params === 'object', 'must pass params to unpublish') + assert(typeof cb === 'function', 'must pass callback to unpublish') var ver = params.version var auth = params.auth - assert(auth && typeof auth === "object", "must pass auth to unpublish") + assert(auth && typeof auth === 'object', 'must pass auth to unpublish') var options = { - timeout : -1, - follow : false, - auth : auth + timeout: -1, + follow: false, + auth: auth } - this.get(uri + "?write=true", options, function (er, data) { + this.get(uri + '?write=true', options, function (er, data) { if (er) { - this.log.info("unpublish", uri+" not published") + this.log.info('unpublish', uri + ' not published') return cb() } // remove all if no version specified if (!ver) { - this.log.info("unpublish", "No version specified, removing all") - return this.request(uri+"/-rev/"+data._rev, { method : "DELETE", auth : auth }, cb) + this.log.info('unpublish', 'No version specified, removing all') + return this.request(uri + '/-rev/' + data._rev, { method: 'DELETE', auth: auth }, cb) } var versions = data.versions || {} - , versionPublic = versions.hasOwnProperty(ver) + var versionPublic = versions.hasOwnProperty(ver) var dist if (!versionPublic) { - this.log.info("unpublish", uri+"@"+ver+" not published") + this.log.info('unpublish', uri + '@' + ver + ' not published') } else { dist = versions[ver].dist - this.log.verbose("unpublish", "removing attachments", dist) + this.log.verbose('unpublish', 'removing attachments', dist) } delete versions[ver] // if it was the only version, then delete the whole package. if (!Object.keys(versions).length) { - this.log.info("unpublish", "No versions remain, removing entire package") - return this.request(uri+"/-rev/"+data._rev, { method : "DELETE", auth : auth }, cb) + this.log.info('unpublish', 'No versions remain, removing entire package') + return this.request(uri + '/-rev/' + data._rev, { method: 'DELETE', auth: auth }, cb) } if (!versionPublic) return cb() - var latestVer = data["dist-tags"].latest - for (var tag in data["dist-tags"]) { - if (data["dist-tags"][tag] === ver) delete data["dist-tags"][tag] + var latestVer = data['dist-tags'].latest + for (var tag in data['dist-tags']) { + if (data['dist-tags'][tag] === ver) delete data['dist-tags'][tag] } if (latestVer === ver) { - data["dist-tags"].latest = + data['dist-tags'].latest = Object.getOwnPropertyNames(versions).sort(semver.compareLoose).pop() } @@ -71,9 +71,9 @@ function unpublish (uri, params, cb) { delete data._attachments var cb_ = detacher.call(this, uri, data, dist, auth, cb) - this.request(uri+"/-rev/"+rev, { method : "PUT", body : data, auth : auth }, function (er) { + this.request(uri + '/-rev/' + rev, { method: 'PUT', body: data, auth: auth }, function (er) { if (er) { - this.log.error("unpublish", "Failed to update data") + this.log.error('unpublish', 'Failed to update data') } cb_(er) }.bind(this)) @@ -83,7 +83,7 @@ function unpublish (uri, params, cb) { function detacher (uri, data, dist, credentials, cb) { return function (er) { if (er) return cb(er) - this.get(escape(uri, data.name), { auth : credentials }, function (er, data) { + this.get(escape(uri, data.name), { auth: credentials }, function (er, data) { if (er) return cb(er) var tb = url.parse(dist.tarball) @@ -103,19 +103,18 @@ function detacher (uri, data, dist, credentials, cb) { function detach (uri, data, path, rev, credentials, cb) { if (rev) { - path += "/-rev/" + rev - this.log.info("detach", path) - return this.request(url.resolve(uri, path), { method : "DELETE", auth : credentials }, cb) + path += '/-rev/' + rev + this.log.info('detach', path) + return this.request(url.resolve(uri, path), { method: 'DELETE', auth: credentials }, cb) } - this.get(escape(uri, data.name), { auth : credentials }, function (er, data) { + this.get(escape(uri, data.name), { auth: credentials }, function (er, data) { rev = data._rev - if (!rev) return cb(new Error( - "No _rev found in "+data._id)) + if (!rev) return cb(new Error('No _rev found in ' + data._id)) detach.call(this, data, path, rev, cb) }.bind(this)) } function escape (base, name) { - var escaped = name.replace(/\//, "%2f") + var escaped = name.replace(/\//, '%2f') return url.resolve(base, escaped) } diff --git a/node_modules/npm-registry-client/lib/whoami.js b/node_modules/npm-registry-client/lib/whoami.js index 4c099ebec..68db49e59 100644 --- a/node_modules/npm-registry-client/lib/whoami.js +++ b/node_modules/npm-registry-client/lib/whoami.js @@ -1,19 +1,19 @@ module.exports = whoami -var url = require("url") - , assert = require("assert") +var url = require('url') +var assert = require('assert') function whoami (uri, params, cb) { - assert(typeof uri === "string", "must pass registry URI to whoami") - assert(params && typeof params === "object", "must pass params to whoami") - assert(typeof cb === "function", "must pass callback to whoami") + assert(typeof uri === 'string', 'must pass registry URI to whoami') + assert(params && typeof params === 'object', 'must pass params to whoami') + assert(typeof cb === 'function', 'must pass callback to whoami') var auth = params.auth - assert(auth && typeof auth === "object", "must pass auth to whoami") + assert(auth && typeof auth === 'object', 'must pass auth to whoami') if (auth.username) return process.nextTick(cb.bind(this, null, auth.username)) - this.request(url.resolve(uri, "-/whoami"), { auth : auth }, function (er, userdata) { + this.request(url.resolve(uri, '-/whoami'), { auth: auth }, function (er, userdata) { if (er) return cb(er) cb(null, userdata.username) diff --git a/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/isarray/package.json b/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/isarray/package.json index fc7904b67..19228ab6f 100644 --- a/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/isarray/package.json +++ b/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/node_modules/isarray/package.json @@ -26,8 +26,6 @@ "url": "http://juliangruber.com" }, "license": "MIT", - "readme": "\n# isarray\n\n`Array#isArray` for older browsers.\n\n## Usage\n\n```js\nvar isArray = require('isarray');\n\nconsole.log(isArray([])); // => true\nconsole.log(isArray({})); // => false\n```\n\n## Installation\n\nWith [npm](http://npmjs.org) do\n\n```bash\n$ npm install isarray\n```\n\nThen bundle for the browser with\n[browserify](https://github.com/substack/browserify).\n\nWith [component](http://component.io) do\n\n```bash\n$ component install juliangruber/isarray\n```\n\n## License\n\n(MIT)\n\nCopyright (c) 2013 Julian Gruber <julian@juliangruber.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", - "readmeFilename": "README.md", "_id": "isarray@0.0.1", "dist": { "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", @@ -50,5 +48,6 @@ "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "bugs": { "url": "https://github.com/juliangruber/isarray/issues" - } + }, + "readme": "ERROR: No README data found!" } diff --git a/node_modules/npm-registry-client/node_modules/npm-package-arg/README.md b/node_modules/npm-registry-client/node_modules/npm-package-arg/README.md index 21683f5e5..d37b35533 100644 --- a/node_modules/npm-registry-client/node_modules/npm-package-arg/README.md +++ b/node_modules/npm-registry-client/node_modules/npm-package-arg/README.md @@ -23,7 +23,7 @@ var parsed = npa("@bar/foo@1.2") // Returns an object like: { raw: '@bar/foo@1.2', // what was passed in - name: "foo", // the name of the package + name: "@bar/foo", // the name of the package scope: "@bar", // the private scope of the package, or null type: "range", // the type of specifier this is spec: ">=1.2.0 <1.3.0" // the expanded specifier diff --git a/node_modules/npm-registry-client/node_modules/npm-package-arg/package.json b/node_modules/npm-registry-client/node_modules/npm-package-arg/package.json index ad8c540f3..ebfc8918e 100644 --- a/node_modules/npm-registry-client/node_modules/npm-package-arg/package.json +++ b/node_modules/npm-registry-client/node_modules/npm-package-arg/package.json @@ -1,6 +1,6 @@ { "name": "npm-package-arg", - "version": "3.1.0", + "version": "3.1.1", "description": "Parse the things that can be arguments to `npm install`", "main": "npa.js", "directories": { @@ -30,12 +30,12 @@ "url": "https://github.com/npm/npm-package-arg/issues" }, "homepage": "https://github.com/npm/npm-package-arg", - "gitHead": "3d5c7f91c5e90e4b9792d881080c462f718f4747", - "_id": "npm-package-arg@3.1.0", - "_shasum": "8ce9d8ad83ae9fcc433783ca813e4e91f885703e", + "gitHead": "1dc802d4b449f1599c7275bb948c6ecd265c23a8", + "_id": "npm-package-arg@3.1.1", + "_shasum": "c9e5f7587f8484d1372a9b386fbf8b2443fc1bdb", "_from": "npm-package-arg@>=3.0.0 <4.0.0", - "_npmVersion": "2.4.1", - "_nodeVersion": "1.0.4", + "_npmVersion": "2.6.1", + "_nodeVersion": "1.1.0", "_npmUser": { "name": "iarna", "email": "me@re-becca.org" @@ -55,9 +55,9 @@ } ], "dist": { - "shasum": "8ce9d8ad83ae9fcc433783ca813e4e91f885703e", - "tarball": "http://registry.npmjs.org/npm-package-arg/-/npm-package-arg-3.1.0.tgz" + "shasum": "c9e5f7587f8484d1372a9b386fbf8b2443fc1bdb", + "tarball": "http://registry.npmjs.org/npm-package-arg/-/npm-package-arg-3.1.1.tgz" }, - "_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-3.1.0.tgz", + "_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-3.1.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json index 35b1ea460..5643d79a4 100644 --- a/node_modules/npm-registry-client/package.json +++ b/node_modules/npm-registry-client/package.json @@ -6,13 +6,13 @@ }, "name": "npm-registry-client", "description": "Client for the npm registry", - "version": "6.1.1", + "version": "6.1.2", "repository": { "url": "git://github.com/isaacs/npm-registry-client" }, "main": "index.js", "scripts": { - "test": "tap test/*.js" + "test": "standard && tap test/*.js" }, "dependencies": { "chownr": "0", @@ -32,6 +32,7 @@ "devDependencies": { "negotiator": "^0.4.9", "nock": "^0.56.0", + "standard": "^3.2.0", "tap": "" }, "optionalDependencies": { @@ -40,12 +41,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.access(uri, params, cb)\n\n* `uri` {String} Registry URL for the package's access API endpoint.\n Looks like `/-/package/<package name>/access`.\n* `params` {Object} Object containing per-request properties.\n * `access` {String} New access level for the package. Can be either\n `public` or `restricted`. Registry will raise an error if trying\n to change the access level of an unscoped package.\n * `auth` {Credentials}\n\nSet the access level for scoped packages. For now, there are only two\naccess levels: \"public\" and \"restricted\".\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.distTags.fetch(uri, params, cb)\n\n* `uri` {String} Base URL for the registry.\n* `params` {Object} Object containing per-request properties.\n * `package` {String} Name of the package.\n * `auth` {Credentials}\n* `cb` {Function}\n\nFetch all of the `dist-tags` for the named package.\n\n### client.distTags.add(uri, params, cb)\n\n* `uri` {String} Base URL for the registry.\n* `params` {Object} Object containing per-request properties.\n * `package` {String} Name of the package.\n * `distTag` {String} Name of the new `dist-tag`.\n * `version` {String} Exact version to be mapped to the `dist-tag`.\n * `auth` {Credentials}\n* `cb` {Function}\n\nAdd (or replace) a single dist-tag onto the named package.\n\n### client.distTags.set(uri, params, cb)\n\n* `uri` {String} Base URL for the registry.\n* `params` {Object} Object containing per-request properties.\n * `package` {String} Name of the package.\n * `distTags` {Object} Object containing a map from tag names to package\n versions.\n * `auth` {Credentials}\n* `cb` {Function}\n\nSet all of the `dist-tags` for the named package at once, creating any\n`dist-tags` that do not already exit. Any `dist-tags` not included in the\n`distTags` map will be removed.\n\n### client.distTags.update(uri, params, cb)\n\n* `uri` {String} Base URL for the registry.\n* `params` {Object} Object containing per-request properties.\n * `package` {String} Name of the package.\n * `distTags` {Object} Object containing a map from tag names to package\n versions.\n * `auth` {Credentials}\n* `cb` {Function}\n\nUpdate the values of multiple `dist-tags`, creating any `dist-tags` that do\nnot already exist. Any pre-existing `dist-tags` not included in the `distTags`\nmap will be left alone.\n\n### client.distTags.rm(uri, params, cb)\n\n* `uri` {String} Base URL for the registry.\n* `params` {Object} Object containing per-request properties.\n * `package` {String} Name of the package.\n * `distTag` {String} Name of the new `dist-tag`.\n * `auth` {Credentials}\n* `cb` {Function}\n\nRemove a single `dist-tag` from the named package.\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 or the \"Last Modified\" timestamp.\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 * `access` {String} Access for the package. Can be `public` or `restricted` (no default).\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 * `lastModified` {String} The cached Last-Modified timestamp. 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} Certificate 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": "88399fa1ebc5473125466ffa940c5b7df9e693bc", + "gitHead": "93606bb3d6c23971ff5d43763dfa10aada5775da", "bugs": { "url": "https://github.com/isaacs/npm-registry-client/issues" }, "homepage": "https://github.com/isaacs/npm-registry-client", - "_id": "npm-registry-client@6.1.1", - "_shasum": "ffc74d9d85f3228fcd21a7eaad8a8ed134a5dddb", - "_from": "npm-registry-client@>=6.1.1 <6.2.0" + "_id": "npm-registry-client@6.1.2", + "_shasum": "b74ba7efa9bfbbce46a1bd15fa97dc7d784099cb", + "_from": "npm-registry-client@>=6.1.2 <7.0.0" } diff --git a/node_modules/npm-registry-client/test/00-setup.js b/node_modules/npm-registry-client/test/00-setup.js index ae6d03ed3..747768fb8 100644 --- a/node_modules/npm-registry-client/test/00-setup.js +++ b/node_modules/npm-registry-client/test/00-setup.js @@ -1,10 +1,10 @@ -var tap = require("tap") -var rimraf = require("rimraf") +var tap = require('tap') +var rimraf = require('rimraf') -tap.test("setup", function (t) { - rimraf(__dirname + "/fixtures/cache", function (er) { +tap.test('setup', function (t) { + rimraf(__dirname + '/fixtures/cache', function (er) { if (er) throw er - t.pass("cache cleaned") + t.pass('cache cleaned') t.end() }) }) diff --git a/node_modules/npm-registry-client/test/access.js b/node_modules/npm-registry-client/test/access.js index 52ecdda4a..4081c329f 100644 --- a/node_modules/npm-registry-client/test/access.js +++ b/node_modules/npm-registry-client/test/access.js @@ -1,95 +1,95 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function nop() {} +function nop () {} -var URI = "http://localhost:1337/-/package/underscore/access" -var TOKEN = "foo" +var URI = 'http://localhost:1337/-/package/underscore/access' +var TOKEN = 'foo' var AUTH = { - token : TOKEN + token: TOKEN } -var LEVEL = "public" +var LEVEL = 'public' var PARAMS = { - level : LEVEL, - auth : AUTH + level: LEVEL, + auth: AUTH } -test("access call contract", function (t) { +test('access call contract', function (t) { t.throws(function () { client.access(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.access([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.access(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.access(URI, "", nop) - }, "params must be object") + client.access(URI, '', nop) + }, 'params must be object') t.throws(function () { client.access(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.access(URI, PARAMS, "callback") - }, "callback must be function") + client.access(URI, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - auth : AUTH + auth: AUTH } client.access(URI, params, nop) }, - { name : "AssertionError", message : "must pass level to access" }, - "access must include level" + { name: 'AssertionError', message: 'must pass level to access' }, + 'access must include level' ) t.throws( function () { var params = { - level : LEVEL + level: LEVEL } client.access(URI, params, nop) }, - { name : "AssertionError", message : "must pass auth to access" }, - "access must include auth" + { name: 'AssertionError', message: 'must pass auth to access' }, + 'access must include auth' ) t.end() }) -test("set access level on a package", function (t) { - server.expect("POST", "/-/package/underscore/access", function (req, res) { - t.equal(req.method, "POST") +test('set access level on a package', function (t) { + server.expect('POST', '/-/package/underscore/access', function (req, res) { + t.equal(req.method, 'POST') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var updated = JSON.parse(b) - t.deepEqual(updated, { access : "public" }) + t.deepEqual(updated, { access: 'public' }) res.statusCode = 201 - res.json({accessChanged : true}) + res.json({ accessChanged: true }) }) }) client.access(URI, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.ok(data.accessChanged, "access level set") + t.ifError(error, 'no errors') + t.ok(data.accessChanged, 'access level set') t.end() }) diff --git a/node_modules/npm-registry-client/test/adduser-new.js b/node_modules/npm-registry-client/test/adduser-new.js index 3789fc954..d8c415bc5 100644 --- a/node_modules/npm-registry-client/test/adduser-new.js +++ b/node_modules/npm-registry-client/test/adduser-new.js @@ -1,38 +1,40 @@ -var tap = require("tap") +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var password = "%1234@asdf%" - , username = "username" - , email = "i@izs.me" - , userdata = { - name: username, - email: email, - _id: "org.couchdb.user:username", - type: "user", - roles: [], - date: "2012-06-07T04:11:21.591Z" } - , SD = require("string_decoder").StringDecoder - , decoder = new SD() - -tap.test("create new user account", function (t) { +var password = '%1234@asdf%' +var username = 'username' +var email = 'i@izs.me' +var userdata = { + name: username, + email: email, + _id: 'org.couchdb.user:username', + type: 'user', + roles: [], + date: '2012-06-07T04:11:21.591Z' +} + +var SD = require('string_decoder').StringDecoder +var decoder = new SD() + +tap.test('create new user account', function (t) { var auth = { - username : username, - password : password, - email : email + username: username, + password: password, + email: email } - var params = { auth : auth } + var params = { auth: auth } - server.expect("/registry/_design/app/_rewrite/-/user/org.couchdb.user:username", function (req, res) { - t.equal(req.method, "PUT") - var b = "" - req.on("data", function (d) { + server.expect('/registry/_design/app/_rewrite/-/user/org.couchdb.user:username', function (req, res) { + t.equal(req.method, 'PUT') + var b = '' + req.on('data', function (d) { b += decoder.write(d) }) - req.on("end", function () { + req.on('end', function () { var o = JSON.parse(b) userdata.password = password userdata.date = o.date @@ -44,11 +46,11 @@ tap.test("create new user account", function (t) { }) client.adduser( - "http://localhost:1337/registry/_design/app/_rewrite", + 'http://localhost:1337/registry/_design/app/_rewrite', params, function (er, data) { if (er) throw er - t.deepEqual(data, auth, "received expected auth data") + t.deepEqual(data, auth, 'received expected auth data') t.end() } ) diff --git a/node_modules/npm-registry-client/test/adduser-update.js b/node_modules/npm-registry-client/test/adduser-update.js index 6732f7ba0..18aad3ebe 100644 --- a/node_modules/npm-registry-client/test/adduser-update.js +++ b/node_modules/npm-registry-client/test/adduser-update.js @@ -1,51 +1,50 @@ -var tap = require("tap") +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var password = "%1234@asdf%" -, username = "username" -, email = "i@izs.me" -, userdata = { +var password = '%1234@asdf%' +var username = 'username' +var email = 'i@izs.me' +var userdata = { name: username, email: email, - _id: "org.couchdb.user:username", - type: "user", + _id: 'org.couchdb.user:username', + type: 'user', roles: [], - date: "2012-06-07T04:11:21.591Z" } -, SD = require("string_decoder").StringDecoder -, decoder = new SD() + date: '2012-06-07T04:11:21.591Z' } +var SD = require('string_decoder').StringDecoder +var decoder = new SD() - -tap.test("update a user acct", function (t) { +tap.test('update a user acct', function (t) { var auth = { - username : username, - password : password, - email : email + username: username, + password: password, + email: email } - var params = { auth : auth } + var params = { auth: auth } - server.expect("PUT", "/-/user/org.couchdb.user:username", function (req, res) { - t.equal(req.method, "PUT") + server.expect('PUT', '/-/user/org.couchdb.user:username', function (req, res) { + t.equal(req.method, 'PUT') res.statusCode = 409 - res.json({error: "conflict"}) + res.json({error: 'conflict'}) }) - server.expect("GET", "/-/user/org.couchdb.user:username?write=true", function (req, res) { - t.equal(req.method, "GET") + server.expect('GET', '/-/user/org.couchdb.user:username?write=true', function (req, res) { + t.equal(req.method, 'GET') res.json(userdata) }) - server.expect("PUT", "/-/user/org.couchdb.user:username/-rev/" + userdata._rev, function (req, res) { - t.equal(req.method, "PUT") + server.expect('PUT', '/-/user/org.couchdb.user:username/-rev/' + userdata._rev, function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.on("data", function (d) { + var b = '' + req.on('data', function (d) { b += decoder.write(d) }) - req.on("end", function () { + req.on('end', function () { var o = JSON.parse(b) userdata.password = password userdata.date = o.date @@ -57,11 +56,11 @@ tap.test("update a user acct", function (t) { }) client.adduser( - "http://localhost:1337/", + 'http://localhost:1337/', params, function (er, data) { if (er) throw er - t.deepEqual(data, auth, "got expected auth data") + t.deepEqual(data, auth, 'got expected auth data') t.end() } ) diff --git a/node_modules/npm-registry-client/test/adduser.js b/node_modules/npm-registry-client/test/adduser.js index fccb037af..10816ebf9 100644 --- a/node_modules/npm-registry-client/test/adduser.js +++ b/node_modules/npm-registry-client/test/adduser.js @@ -1,153 +1,153 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() function nop () {} -var URI = "https://npm.registry:8043/rewrite" -var USERNAME = "username" -var PASSWORD = "password" -var EMAIL = "n@p.m" -var AUTH = { - auth : { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var URI = 'https://npm.registry:8043/rewrite' +var USERNAME = 'username' +var PASSWORD = 'password' +var EMAIL = 'n@p.m' +var AUTH = { + auth: { + username: USERNAME, + password: PASSWORD, + email: EMAIL } } -test("adduser call contract", function (t) { +test('adduser call contract', function (t) { t.throws(function () { client.adduser(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.adduser([], AUTH, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.adduser(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.adduser(URI, "", nop) - }, "params must be object") + client.adduser(URI, '', nop) + }, 'params must be object') t.throws(function () { client.adduser(URI, AUTH, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.adduser(URI, AUTH, "callback") - }, "callback must be function") + client.adduser(URI, AUTH, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - auth : { - password : PASSWORD, - email : EMAIL + auth: { + password: PASSWORD, + email: EMAIL } } client.adduser(URI, params, nop) }, - { name : "AssertionError", message : "must include username in auth" }, - "auth must include username" + { name: 'AssertionError', message: 'must include username in auth' }, + 'auth must include username' ) t.throws( function () { var params = { - auth : { - username : USERNAME, - email : EMAIL + auth: { + username: USERNAME, + email: EMAIL } } client.adduser(URI, params, nop) }, - { name : "AssertionError", message : "must include password in auth" }, - "auth must include password" + { name: 'AssertionError', message: 'must include password in auth' }, + 'auth must include password' ) t.throws( function () { var params = { - auth : { - username : USERNAME, - password : PASSWORD + auth: { + username: USERNAME, + password: PASSWORD } } client.adduser(URI, params, nop) }, - { name : "AssertionError", message : "must include email in auth" }, - "auth must include email" + { name: 'AssertionError', message: 'must include email in auth' }, + 'auth must include email' ) - t.test("username missing", function (t) { + t.test('username missing', function (t) { var params = { - auth : { - username : "", - password : PASSWORD, - email : EMAIL + auth: { + username: '', + password: PASSWORD, + email: EMAIL } } client.adduser(URI, params, function (err) { - t.equal(err && err.message, "No username supplied.", "username must not be empty") + t.equal(err && err.message, 'No username supplied.', 'username must not be empty') t.end() }) }) - t.test("password missing", function (t) { + t.test('password missing', function (t) { var params = { - auth : { - username : USERNAME, - password : "", - email : EMAIL + auth: { + username: USERNAME, + password: '', + email: EMAIL } } client.adduser(URI, params, function (err) { t.equal( err && err.message, - "No password supplied.", - "password must not be empty" + 'No password supplied.', + 'password must not be empty' ) t.end() }) }) - t.test("email missing", function (t) { + t.test('email missing', function (t) { var params = { - auth : { - username : USERNAME, - password : PASSWORD, - email : "" + auth: { + username: USERNAME, + password: PASSWORD, + email: '' } } client.adduser(URI, params, function (err) { t.equal( err && err.message, - "No email address supplied.", - "email must not be empty" + 'No email address supplied.', + 'email must not be empty' ) t.end() }) }) - t.test("email malformed", function (t) { + t.test('email malformed', function (t) { var params = { - auth : { - username : USERNAME, - password : PASSWORD, - email : "lolbutts" + auth: { + username: USERNAME, + password: PASSWORD, + email: 'lolbutts' } } client.adduser(URI, params, function (err) { t.equal( err && err.message, - "Please use a real email address.", - "email must look like email" + 'Please use a real email address.', + 'email must look like email' ) t.end() }) @@ -156,7 +156,7 @@ test("adduser call contract", function (t) { t.end() }) -test("cleanup", function (t) { +test('cleanup', function (t) { server.close() t.end() }) diff --git a/node_modules/npm-registry-client/test/config-defaults.js b/node_modules/npm-registry-client/test/config-defaults.js index 46756297a..a432da858 100644 --- a/node_modules/npm-registry-client/test/config-defaults.js +++ b/node_modules/npm-registry-client/test/config-defaults.js @@ -1,42 +1,42 @@ -var test = require("tap").test +var test = require('tap').test -require("./lib/server.js").close() -var common = require("./lib/common.js") +require('./lib/server.js').close() +var common = require('./lib/common.js') -test("config defaults", function (t) { +test('config defaults', function (t) { var client = common.freshClient() var proxy = client.config.proxy - t.notOk(proxy.http, "no default value for HTTP proxy") - t.notOk(proxy.https, "no default value for HTTPS proxy") - t.notOk(proxy.localAddress, "no default value for local address") + t.notOk(proxy.http, 'no default value for HTTP proxy') + t.notOk(proxy.https, 'no default value for HTTPS proxy') + t.notOk(proxy.localAddress, 'no default value for local address') var ssl = client.config.ssl - t.notOk(ssl.ca, "no default value for SSL certificate authority bundle") - t.notOk(ssl.certificate, "no default value for SSL client certificate") - t.notOk(ssl.key, "no default value for SSL client certificate key") - t.equal(ssl.strict, true, "SSL is strict by default") + t.notOk(ssl.ca, 'no default value for SSL certificate authority bundle') + t.notOk(ssl.certificate, 'no default value for SSL client certificate') + t.notOk(ssl.key, 'no default value for SSL client certificate key') + t.equal(ssl.strict, true, 'SSL is strict by default') var retry = client.config.retry - 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)") + 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)') - t.equal(client.config.userAgent, "node/"+process.version, "default userAgent") + t.equal(client.config.userAgent, 'node/' + process.version, 'default userAgent') t.ok(client.log.info, "there's a default logger") - t.equal(client.config.defaultTag, "latest", "default tag is 'latest'") - t.notOk(client.config.couchToken, "no couchToken by default") - t.notOk(client.config.sessionToken, "no sessionToken by default") + t.equal(client.config.defaultTag, 'latest', 'default tag is "latest"') + t.notOk(client.config.couchToken, 'no couchToken by default') + t.notOk(client.config.sessionToken, 'no sessionToken by default') t.end() }) -test("missing HTTPS proxy defaults to HTTP proxy", function (t) { - var client = common.freshClient({ proxy : { http : "http://proxy.npm:8088/" }}) +test('missing HTTPS proxy defaults to HTTP proxy', function (t) { + var client = common.freshClient({ proxy: { http: 'http://proxy.npm:8088/' }}) - t.equal(client.config.proxy.http, "http://proxy.npm:8088/", "HTTP proxy set") - t.equal(client.config.proxy.http, client.config.proxy.https, "HTTP === HTTPS") + t.equal(client.config.proxy.http, 'http://proxy.npm:8088/', 'HTTP proxy set') + t.equal(client.config.proxy.http, client.config.proxy.https, 'HTTP === HTTPS') t.end() }) diff --git a/node_modules/npm-registry-client/test/config-override.js b/node_modules/npm-registry-client/test/config-override.js index 4e1240692..026cb199c 100644 --- a/node_modules/npm-registry-client/test/config-override.js +++ b/node_modules/npm-registry-client/test/config-override.js @@ -1,44 +1,44 @@ -var test = require("tap").test +var test = require('tap').test -require("./lib/server.js").close() -var common = require("./lib/common.js") +require('./lib/server.js').close() +var common = require('./lib/common.js') var config = { - proxy : { - http : "http://proxy.npm:8088/", - https : "https://proxy.npm:8043/", - localAddress : "localhost.localdomain" + proxy: { + http: 'http://proxy.npm:8088/', + https: 'https://proxy.npm:8043/', + localAddress: 'localhost.localdomain' }, - ssl : { - ca : "not including a PEM", - certificate : "still not including a PEM", - key : "nope", - strict : false + ssl: { + ca: 'not including a PEM', + certificate: 'still not including a PEM', + key: 'nope', + strict: false }, - retry : { - count : 1, - factor : 9001, - minTimeout : -1, - maxTimeout : Infinity + retry: { + count: 1, + factor: 9001, + minTimeout: -1, + maxTimeout: Infinity }, - userAgent : "npm-awesome/4 (Mozilla 5.0)", - log : { fake : function () {} }, - defaultTag : "next", - couchToken : { object : true }, - sessionToken : "hamchunx" + userAgent: 'npm-awesome/4 (Mozilla 5.0)', + log: { fake: function () {} }, + defaultTag: 'next', + couchToken: { object: true }, + sessionToken: 'hamchunx' } -test("config defaults", function (t) { +test('config defaults', function (t) { var client = common.freshClient(config) var proxy = client.config.proxy - t.equal(proxy.http, "http://proxy.npm:8088/") - t.equal(proxy.https, "https://proxy.npm:8043/") - t.equal(proxy.localAddress, "localhost.localdomain") + t.equal(proxy.http, 'http://proxy.npm:8088/') + t.equal(proxy.https, 'https://proxy.npm:8043/') + t.equal(proxy.localAddress, 'localhost.localdomain') var ssl = client.config.ssl - t.equal(ssl.ca, "not including a PEM") - t.equal(ssl.certificate, "still not including a PEM") - t.equal(ssl.key, "nope") + t.equal(ssl.ca, 'not including a PEM') + t.equal(ssl.certificate, 'still not including a PEM') + t.equal(ssl.key, 'nope') t.equal(ssl.strict, false) var retry = client.config.retry @@ -47,11 +47,11 @@ test("config defaults", function (t) { t.equal(retry.minTimeout, -1) t.equal(retry.maxTimeout, Infinity) - t.equal(client.config.userAgent, "npm-awesome/4 (Mozilla 5.0)") + t.equal(client.config.userAgent, 'npm-awesome/4 (Mozilla 5.0)') t.ok(client.log.fake) - t.equal(client.config.defaultTag, "next") + t.equal(client.config.defaultTag, 'next') t.ok(client.config.couchToken.object) - t.equal(client.config.sessionToken, "hamchunx") + t.equal(client.config.sessionToken, 'hamchunx') t.end() }) diff --git a/node_modules/npm-registry-client/test/deprecate.js b/node_modules/npm-registry-client/test/deprecate.js index 84b82b919..d49f71215 100644 --- a/node_modules/npm-registry-client/test/deprecate.js +++ b/node_modules/npm-registry-client/test/deprecate.js @@ -1,98 +1,98 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") -var cache = require("./fixtures/underscore/cache.json") +var server = require('./lib/server.js') +var common = require('./lib/common.js') +var cache = require('./fixtures/underscore/cache.json') var client = common.freshClient() function nop () {} -var URI = "https://npm.registry:8043/rewrite" -var VERSION = "1.3.2" -var MESSAGE = "uhhh" -var TOKEN = "lolbutts" -var AUTH = { - token : TOKEN +var URI = 'https://npm.registry:8043/rewrite' +var VERSION = '1.3.2' +var MESSAGE = 'uhhh' +var TOKEN = 'lolbutts' +var AUTH = { + token: TOKEN } -var PARAMS = { - version : VERSION, - message : MESSAGE, - auth : AUTH +var PARAMS = { + version: VERSION, + message: MESSAGE, + auth: AUTH } -test("deprecate call contract", function (t) { +test('deprecate call contract', function (t) { t.throws(function () { client.deprecate(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.deprecate([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.deprecate(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.deprecate(URI, "", nop) - }, "params must be object") + client.deprecate(URI, '', nop) + }, 'params must be object') t.throws(function () { client.deprecate(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.deprecate(URI, PARAMS, "callback") - }, "callback must be function") + client.deprecate(URI, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - message : MESSAGE, - auth : AUTH + message: MESSAGE, + auth: AUTH } client.deprecate(URI, params, nop) }, - { name : "AssertionError", message : "must pass version to deprecate" }, - "params must include version to deprecate" + { name: 'AssertionError', message: 'must pass version to deprecate' }, + 'params must include version to deprecate' ) t.throws( function () { var params = { - version : VERSION, - auth : AUTH + version: VERSION, + auth: AUTH } client.deprecate(URI, params, nop) }, - { name : "AssertionError", message : "must pass message to deprecate" }, - "params must include deprecation message" + { name: 'AssertionError', message: 'must pass message to deprecate' }, + 'params must include deprecation message' ) t.throws( function () { var params = { - version : VERSION, - message : MESSAGE + version: VERSION, + message: MESSAGE } client.deprecate(URI, params, nop) }, - { name : "AssertionError", message : "must pass auth to deprecate" }, - "params must include auth" + { name: 'AssertionError', message: 'must pass auth to deprecate' }, + 'params must include auth' ) - t.test("malformed semver in deprecation", function (t) { + t.test('malformed semver in deprecation', function (t) { var params = { - version : "-9001", - message : MESSAGE, - auth : AUTH + version: '-9001', + message: MESSAGE, + auth: AUTH } client.deprecate(URI, params, function (err) { t.equal( err && err.message, - "invalid version range: -9001", - "got expected semver validation failure" + 'invalid version range: -9001', + 'got expected semver validation failure' ) t.end() }) @@ -101,54 +101,54 @@ test("deprecate call contract", function (t) { t.end() }) -test("deprecate a package", function (t) { - server.expect("GET", "/underscore?write=true", function (req, res) { - t.equal(req.method, "GET") +test('deprecate a package', function (t) { + server.expect('GET', '/underscore?write=true', function (req, res) { + t.equal(req.method, 'GET') res.json(cache) }) - server.expect("PUT", "/underscore", function (req, res) { - t.equal(req.method, "PUT") + server.expect('PUT', '/underscore', function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var updated = JSON.parse(b) - var undeprecated = [ - "1.0.3", "1.0.4", "1.1.0", "1.1.1", "1.1.2", "1.1.3", "1.1.4", "1.1.5", "1.1.6", - "1.1.7", "1.2.0", "1.2.1", "1.2.2", "1.2.3", "1.2.4", "1.3.0", "1.3.1", "1.3.3" + var undeprecated = [ + '1.0.3', '1.0.4', '1.1.0', '1.1.1', '1.1.2', '1.1.3', '1.1.4', '1.1.5', '1.1.6', + '1.1.7', '1.2.0', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.3.0', '1.3.1', '1.3.3' ] for (var i = 0; i < undeprecated.length; i++) { var current = undeprecated[i] t.notEqual( updated.versions[current].deprecated, MESSAGE, - current + " not deprecated" + current + ' not deprecated' ) } t.equal( updated.versions[VERSION].deprecated, MESSAGE, - VERSION + " deprecated" + VERSION + ' deprecated' ) res.statusCode = 201 - res.json({deprecated:true}) + res.json({ deprecated: true }) }) }) client.deprecate( - common.registry + "/underscore", + common.registry + '/underscore', PARAMS, function (er, data) { t.ifError(er) - t.ok(data.deprecated, "was deprecated") + t.ok(data.deprecated, 'was deprecated') t.end() } diff --git a/node_modules/npm-registry-client/test/dist-tags-add.js b/node_modules/npm-registry-client/test/dist-tags-add.js index a215c67d9..e66d80a3e 100644 --- a/node_modules/npm-registry-client/test/dist-tags-add.js +++ b/node_modules/npm-registry-client/test/dist-tags-add.js @@ -1,140 +1,140 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function nop() {} +function nop () {} -var BASE_URL = "http://localhost:1337/" -var URI = "/-/package/underscore/dist-tags/test" -var TOKEN = "foo" +var BASE_URL = 'http://localhost:1337/' +var URI = '/-/package/underscore/dist-tags/test' +var TOKEN = 'foo' var AUTH = { - token : TOKEN + token: TOKEN } -var PACKAGE = "underscore" -var DIST_TAG = "test" -var VERSION = "3.1.3" +var PACKAGE = 'underscore' +var DIST_TAG = 'test' +var VERSION = '3.1.3' var PARAMS = { - package : PACKAGE, - distTag : DIST_TAG, - version : VERSION, - auth : AUTH + 'package': PACKAGE, + distTag: DIST_TAG, + version: VERSION, + auth: AUTH } -test("distTags.add call contract", function (t) { +test('distTags.add call contract', function (t) { t.throws(function () { client.distTags.add(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.distTags.add([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.distTags.add(BASE_URL, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.distTags.add(BASE_URL, "", nop) - }, "params must be object") + client.distTags.add(BASE_URL, '', nop) + }, 'params must be object') t.throws(function () { client.distTags.add(BASE_URL, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.distTags.add(BASE_URL, PARAMS, "callback") - }, "callback must be function") + client.distTags.add(BASE_URL, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - distTag : DIST_TAG, - version : VERSION, - auth : AUTH + distTag: DIST_TAG, + version: VERSION, + auth: AUTH } client.distTags.add(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package name to distTags.add" + name: 'AssertionError', + message: 'must pass package name to distTags.add' }, - "distTags.add must include package name" + 'distTags.add must include package name' ) t.throws( function () { var params = { - package : PACKAGE, - version : VERSION, - auth : AUTH + 'package': PACKAGE, + version: VERSION, + auth: AUTH } client.distTags.add(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package distTag name to distTags.add" + name: 'AssertionError', + message: 'must pass package distTag name to distTags.add' }, - "distTags.add must include dist-tag" + 'distTags.add must include dist-tag' ) t.throws( function () { var params = { - package : PACKAGE, - distTag : DIST_TAG, - auth : AUTH + 'package': PACKAGE, + distTag: DIST_TAG, + auth: AUTH } client.distTags.add(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass version to be mapped to distTag to distTags.add" + name: 'AssertionError', + message: 'must pass version to be mapped to distTag to distTags.add' }, - "distTags.add must include version" + 'distTags.add must include version' ) t.throws( function () { var params = { - package : PACKAGE, - distTag : DIST_TAG, - version : VERSION + 'package': PACKAGE, + distTag: DIST_TAG, + version: VERSION } client.distTags.add(BASE_URL, params, nop) }, - { name : "AssertionError", message : "must pass auth to distTags.add" }, - "distTags.add must include auth" + { name: 'AssertionError', message: 'must pass auth to distTags.add' }, + 'distTags.add must include auth' ) t.end() }) -test("add a new dist-tag to a package", function (t) { - server.expect("PUT", URI, function (req, res) { - t.equal(req.method, "PUT") +test('add a new dist-tag to a package', function (t) { + server.expect('PUT', URI, function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { t.doesNotThrow(function () { var parsed = JSON.parse(b) t.deepEqual(parsed, VERSION) res.statusCode = 200 - res.json({ "test" : VERSION }) - }, "got valid JSON from client") + res.json({ test: VERSION }) + }, 'got valid JSON from client') }) }) client.distTags.add(BASE_URL, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.ok(data.test, "dist-tag added") + t.ifError(error, 'no errors') + t.ok(data.test, 'dist-tag added') t.end() }) diff --git a/node_modules/npm-registry-client/test/dist-tags-fetch.js b/node_modules/npm-registry-client/test/dist-tags-fetch.js index c108b6b39..ef0901ea7 100644 --- a/node_modules/npm-registry-client/test/dist-tags-fetch.js +++ b/node_modules/npm-registry-client/test/dist-tags-fetch.js @@ -1,97 +1,97 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function nop() {} +function nop () {} -var BASE_URL = "http://localhost:1337/" -var URI = "/-/package/underscore/dist-tags" -var TOKEN = "foo" +var BASE_URL = 'http://localhost:1337/' +var URI = '/-/package/underscore/dist-tags' +var TOKEN = 'foo' var AUTH = { - token : TOKEN + token: TOKEN } -var PACKAGE = "underscore" +var PACKAGE = 'underscore' var PARAMS = { - package : PACKAGE, - auth : AUTH + 'package': PACKAGE, + auth: AUTH } -test("distTags.fetch call contract", function (t) { +test('distTags.fetch call contract', function (t) { t.throws(function () { client.distTags.fetch(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.distTags.fetch([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.distTags.fetch(BASE_URL, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.distTags.fetch(BASE_URL, "", nop) - }, "params must be object") + client.distTags.fetch(BASE_URL, '', nop) + }, 'params must be object') t.throws(function () { client.distTags.fetch(BASE_URL, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.distTags.fetch(BASE_URL, PARAMS, "callback") - }, "callback must be function") + client.distTags.fetch(BASE_URL, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - auth : AUTH + auth: AUTH } client.distTags.fetch(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package name to distTags.fetch" + name: 'AssertionError', + message: 'must pass package name to distTags.fetch' }, - "distTags.fetch must include package name" + 'distTags.fetch must include package name' ) t.throws( function () { var params = { - package : PACKAGE + 'package': PACKAGE } client.distTags.fetch(BASE_URL, params, nop) }, - { name : "AssertionError", message : "must pass auth to distTags.fetch" }, - "distTags.fetch must include auth" + { name: 'AssertionError', message: 'must pass auth to distTags.fetch' }, + 'distTags.fetch must include auth' ) t.end() }) -test("fetch dist-tags for a package", function (t) { - server.expect("GET", URI, function (req, res) { - t.equal(req.method, "GET") +test('fetch dist-tags for a package', function (t) { + server.expect('GET', URI, function (req, res) { + t.equal(req.method, 'GET') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { - t.notOk(b, "no request body") + req.on('end', function () { + t.notOk(b, 'no request body') res.statusCode = 200 - res.json({ a : "1.0.0", b : "2.0.0", _etag : "xxx" }) + res.json({ a: '1.0.0', b: '2.0.0', _etag: 'xxx' }) }) }) client.distTags.fetch(BASE_URL, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.same(data, { a : "1.0.0", b : "2.0.0" }, "etag filtered from response") + t.ifError(error, 'no errors') + t.same(data, { a: '1.0.0', b: '2.0.0' }, 'etag filtered from response') t.end() }) diff --git a/node_modules/npm-registry-client/test/dist-tags-rm.js b/node_modules/npm-registry-client/test/dist-tags-rm.js index 6268a06aa..a035014dc 100644 --- a/node_modules/npm-registry-client/test/dist-tags-rm.js +++ b/node_modules/npm-registry-client/test/dist-tags-rm.js @@ -1,107 +1,107 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function nop() {} +function nop () {} -var BASE_URL = "http://localhost:1337/" -var URI = "/-/package/underscore/dist-tags/test" -var TOKEN = "foo" +var BASE_URL = 'http://localhost:1337/' +var URI = '/-/package/underscore/dist-tags/test' +var TOKEN = 'foo' var AUTH = { - token : TOKEN + token: TOKEN } -var PACKAGE = "underscore" -var DIST_TAG = "test" +var PACKAGE = 'underscore' +var DIST_TAG = 'test' var PARAMS = { - package : PACKAGE, - distTag : DIST_TAG, - auth : AUTH + 'package': PACKAGE, + distTag: DIST_TAG, + auth: AUTH } -test("distTags.rm call contract", function (t) { +test('distTags.rm call contract', function (t) { t.throws(function () { client.distTags.rm(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.distTags.rm([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.distTags.rm(BASE_URL, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.distTags.rm(BASE_URL, "", nop) - }, "params must be object") + client.distTags.rm(BASE_URL, '', nop) + }, 'params must be object') t.throws(function () { client.distTags.rm(BASE_URL, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.distTags.rm(BASE_URL, PARAMS, "callback") - }, "callback must be function") + client.distTags.rm(BASE_URL, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - distTag : DIST_TAG, - auth : AUTH + distTag: DIST_TAG, + auth: AUTH } client.distTags.rm(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package name to distTags.rm" + name: 'AssertionError', + message: 'must pass package name to distTags.rm' }, - "distTags.rm must include package name" + 'distTags.rm must include package name' ) t.throws( function () { var params = { - package : PACKAGE, - auth : AUTH + 'package': PACKAGE, + auth: AUTH } client.distTags.rm(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package distTag name to distTags.rm" + name: 'AssertionError', + message: 'must pass package distTag name to distTags.rm' }, - "distTags.rm must include dist-tag" + 'distTags.rm must include dist-tag' ) t.throws( function () { var params = { - package : PACKAGE, - distTag : DIST_TAG + 'package': PACKAGE, + distTag: DIST_TAG } client.distTags.rm(BASE_URL, params, nop) }, - { name : "AssertionError", message : "must pass auth to distTags.rm" }, - "distTags.rm must include auth" + { name: 'AssertionError', message: 'must pass auth to distTags.rm' }, + 'distTags.rm must include auth' ) t.end() }) -test("remove a dist-tag from a package", function (t) { - server.expect("DELETE", URI, function (req, res) { - t.equal(req.method, "DELETE") +test('remove a dist-tag from a package', function (t) { + server.expect('DELETE', URI, function (req, res) { + t.equal(req.method, 'DELETE') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { - t.notOk(b, "got no message body") + req.on('end', function () { + t.notOk(b, 'got no message body') res.statusCode = 200 res.json({}) @@ -109,8 +109,8 @@ test("remove a dist-tag from a package", function (t) { }) client.distTags.rm(BASE_URL, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.notOk(data.test, "dist-tag removed") + t.ifError(error, 'no errors') + t.notOk(data.test, 'dist-tag removed') t.end() }) diff --git a/node_modules/npm-registry-client/test/dist-tags-set.js b/node_modules/npm-registry-client/test/dist-tags-set.js index ff5591dbd..691aef13e 100644 --- a/node_modules/npm-registry-client/test/dist-tags-set.js +++ b/node_modules/npm-registry-client/test/dist-tags-set.js @@ -1,111 +1,111 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function nop() {} +function nop () {} -var BASE_URL = "http://localhost:1337/" -var URI = "/-/package/underscore/dist-tags" -var TOKEN = "foo" +var BASE_URL = 'http://localhost:1337/' +var URI = '/-/package/underscore/dist-tags' +var TOKEN = 'foo' var AUTH = { - token : TOKEN + token: TOKEN } -var PACKAGE = "underscore" +var PACKAGE = 'underscore' var DIST_TAGS = { - "a" : "8.0.8", - "b" : "3.0.3" + 'a': '8.0.8', + 'b': '3.0.3' } var PARAMS = { - package : PACKAGE, - distTags : DIST_TAGS, - auth : AUTH + 'package': PACKAGE, + distTags: DIST_TAGS, + auth: AUTH } -test("distTags.set call contract", function (t) { +test('distTags.set call contract', function (t) { t.throws(function () { client.distTags.set(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.distTags.set([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.distTags.set(BASE_URL, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.distTags.set(BASE_URL, "", nop) - }, "params must be object") + client.distTags.set(BASE_URL, '', nop) + }, 'params must be object') t.throws(function () { client.distTags.set(BASE_URL, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.distTags.set(BASE_URL, PARAMS, "callback") - }, "callback must be function") + client.distTags.set(BASE_URL, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - distTags : DIST_TAGS, - auth : AUTH + distTags: DIST_TAGS, + auth: AUTH } client.distTags.set(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package name to distTags.set" + name: 'AssertionError', + message: 'must pass package name to distTags.set' }, - "distTags.set must include package name" + 'distTags.set must include package name' ) t.throws( function () { var params = { - package : PACKAGE, - auth : AUTH + 'package': PACKAGE, + auth: AUTH } client.distTags.set(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass distTags map to distTags.set" + name: 'AssertionError', + message: 'must pass distTags map to distTags.set' }, - "distTags.set must include dist-tags" + 'distTags.set must include dist-tags' ) t.throws( function () { var params = { - package : PACKAGE, - distTags : DIST_TAGS + 'package': PACKAGE, + distTags: DIST_TAGS } client.distTags.set(BASE_URL, params, nop) }, - { name : "AssertionError", message : "must pass auth to distTags.set" }, - "distTags.set must include auth" + { name: 'AssertionError', message: 'must pass auth to distTags.set' }, + 'distTags.set must include auth' ) t.end() }) -test("set dist-tags for a package", function (t) { - server.expect("PUT", URI, function (req, res) { - t.equal(req.method, "PUT") +test('set dist-tags for a package', function (t) { + server.expect('PUT', URI, function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var d = JSON.parse(b) - t.deepEqual(d, DIST_TAGS, "got back tags") + t.deepEqual(d, DIST_TAGS, 'got back tags') res.statusCode = 200 res.json(DIST_TAGS) @@ -113,8 +113,8 @@ test("set dist-tags for a package", function (t) { }) client.distTags.set(BASE_URL, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.ok(data.a && data.b, "dist-tags set") + t.ifError(error, 'no errors') + t.ok(data.a && data.b, 'dist-tags set') t.end() }) diff --git a/node_modules/npm-registry-client/test/dist-tags-update.js b/node_modules/npm-registry-client/test/dist-tags-update.js index 7c29e1114..4a829c85d 100644 --- a/node_modules/npm-registry-client/test/dist-tags-update.js +++ b/node_modules/npm-registry-client/test/dist-tags-update.js @@ -1,111 +1,102 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function nop() {} +function nop () {} -var BASE_URL = "http://localhost:1337/" -var URI = "/-/package/underscore/dist-tags" -var TOKEN = "foo" +var BASE_URL = 'http://localhost:1337/' +var URI = '/-/package/underscore/dist-tags' +var TOKEN = 'foo' var AUTH = { - token : TOKEN + token: TOKEN } -var PACKAGE = "underscore" +var PACKAGE = 'underscore' var DIST_TAGS = { - "a" : "8.0.8", - "b" : "3.0.3" + 'a': '8.0.8', + 'b': '3.0.3' } var PARAMS = { - package : PACKAGE, - distTags : DIST_TAGS, - auth : AUTH + 'package': PACKAGE, + distTags: DIST_TAGS, + auth: AUTH } -test("distTags.update call contract", function (t) { +test('distTags.update call contract', function (t) { t.throws(function () { client.distTags.update(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.distTags.update([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.distTags.update(BASE_URL, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.distTags.update(BASE_URL, "", nop) - }, "params must be object") + client.distTags.update(BASE_URL, '', nop) + }, 'params must be object') t.throws(function () { client.distTags.update(BASE_URL, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.distTags.update(BASE_URL, PARAMS, "callback") - }, "callback must be function") + client.distTags.update(BASE_URL, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { - var params = { - distTags : DIST_TAGS, - auth : AUTH - } + var params = { distTags: DIST_TAGS, auth: AUTH } client.distTags.update(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass package name to distTags.update" + name: 'AssertionError', + message: 'must pass package name to distTags.update' }, - "distTags.update must include package name" + 'distTags.update must include package name' ) t.throws( function () { - var params = { - package : PACKAGE, - auth : AUTH - } + var params = { 'package': PACKAGE, auth: AUTH } client.distTags.update(BASE_URL, params, nop) }, { - name : "AssertionError", - message : "must pass distTags map to distTags.update" + name: 'AssertionError', + message: 'must pass distTags map to distTags.update' }, - "distTags.update must include dist-tags" + 'distTags.update must include dist-tags' ) t.throws( function () { - var params = { - package : PACKAGE, - distTags : DIST_TAGS - } + var params = { 'package': PACKAGE, distTags: DIST_TAGS } client.distTags.update(BASE_URL, params, nop) }, - { name : "AssertionError", message : "must pass auth to distTags.update" }, - "distTags.update must include auth" + { name: 'AssertionError', message: 'must pass auth to distTags.update' }, + 'distTags.update must include auth' ) t.end() }) -test("update dist-tags for a package", function (t) { - server.expect("POST", URI, function (req, res) { - t.equal(req.method, "POST") +test('update dist-tags for a package', function (t) { + server.expect('POST', URI, function (req, res) { + t.equal(req.method, 'POST') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var d = JSON.parse(b) - t.deepEqual(d, DIST_TAGS, "got back tags") + t.deepEqual(d, DIST_TAGS, 'got back tags') res.statusCode = 200 res.json(DIST_TAGS) @@ -113,8 +104,8 @@ test("update dist-tags for a package", function (t) { }) client.distTags.update(BASE_URL, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.ok(data.a && data.b, "dist-tags set") + t.ifError(error, 'no errors') + t.ok(data.a && data.b, 'dist-tags set') t.end() }) diff --git a/node_modules/npm-registry-client/test/fetch-404.js b/node_modules/npm-registry-client/test/fetch-404.js index 25def1bec..e05e36f26 100644 --- a/node_modules/npm-registry-client/test/fetch-404.js +++ b/node_modules/npm-registry-client/test/fetch-404.js @@ -1,22 +1,22 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var tap = require("tap") -var cat = require("concat-stream") +var tap = require('tap') +var cat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') -tap.test("fetch with a 404 response", function (t) { - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") +tap.test('fetch with a 404 response', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(200, { - "content-type" : "application/x-tar", - "content-encoding" : "gzip" + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' }) createReadStream(tgz).pipe(res) @@ -25,18 +25,18 @@ tap.test("fetch with a 404 response", function (t) { var client = common.freshClient() var defaulted = {} client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3.tgz", + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', defaulted, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = cat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/fetch-408.js b/node_modules/npm-registry-client/test/fetch-408.js index 1e48bd42e..d49b149f6 100644 --- a/node_modules/npm-registry-client/test/fetch-408.js +++ b/node_modules/npm-registry-client/test/fetch-408.js @@ -1,29 +1,29 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var tap = require("tap") -var cat = require("concat-stream") +var tap = require('tap') +var cat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') -tap.test("fetch with retry on timeout", function (t) { - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") +tap.test('fetch with retry on timeout', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(408) res.end() }) - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(200, { - "content-type" : "application/x-tar", - "content-encoding" : "gzip" + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' }) createReadStream(tgz).pipe(res) @@ -33,18 +33,18 @@ tap.test("fetch with retry on timeout", function (t) { var defaulted = {} client.config.retry.minTimeout = 100 client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3.tgz", + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', defaulted, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = cat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/fetch-503.js b/node_modules/npm-registry-client/test/fetch-503.js index 239e2e774..04f5901e8 100644 --- a/node_modules/npm-registry-client/test/fetch-503.js +++ b/node_modules/npm-registry-client/test/fetch-503.js @@ -1,29 +1,29 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var tap = require("tap") -var cat = require("concat-stream") +var tap = require('tap') +var cat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') -tap.test("fetch with retry on server error", function (t) { - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") +tap.test('fetch with retry on server error', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(503) res.end() }) - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(200, { - "content-type" : "application/x-tar", - "content-encoding" : "gzip" + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' }) createReadStream(tgz).pipe(res) @@ -33,18 +33,18 @@ tap.test("fetch with retry on server error", function (t) { var defaulted = {} client.config.retry.minTimeout = 100 client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3.tgz", + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', defaulted, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = cat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/fetch-authed.js b/node_modules/npm-registry-client/test/fetch-authed.js index e3171a559..ccfd4b77f 100644 --- a/node_modules/npm-registry-client/test/fetch-authed.js +++ b/node_modules/npm-registry-client/test/fetch-authed.js @@ -1,54 +1,54 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var tap = require("tap") -var cat = require("concat-stream") +var tap = require('tap') +var cat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') -tap.test("basic fetch with scoped always-auth enabled", function (t) { - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") +tap.test('basic fetch with scoped always-auth enabled', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') t.equal( req.headers.authorization, - "Basic dXNlcm5hbWU6JTEyMzRAYXNkZiU=", - "got expected auth header" + 'Basic dXNlcm5hbWU6JTEyMzRAYXNkZiU=', + 'got expected auth header' ) res.writeHead(200, { - "content-type" : "application/x-tar", - "content-encoding" : "gzip" + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' }) createReadStream(tgz).pipe(res) }) var auth = { - username : "username", - password : "%1234@asdf%", - email : "i@izs.me", - alwaysAuth : true + username: 'username', + password: '%1234@asdf%', + email: 'i@izs.me', + alwaysAuth: true } var client = common.freshClient() - var authed = { auth : auth } + var authed = { auth: auth } client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3.tgz", + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', authed, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = cat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/fetch-basic.js b/node_modules/npm-registry-client/test/fetch-basic.js index 68e67f023..7bf4d1bd1 100644 --- a/node_modules/npm-registry-client/test/fetch-basic.js +++ b/node_modules/npm-registry-client/test/fetch-basic.js @@ -1,70 +1,70 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var test = require("tap").test -var concat = require("concat-stream") +var test = require('tap').test +var concat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') function nop () {} -var URI = "https://npm.registry:8043/rewrite" -var USERNAME = "username" -var PASSWORD = "hi" -var EMAIL = "n@p.m" -var HEADERS = { - "npm-custom" : "lolbutts" +var URI = 'https://npm.registry:8043/rewrite' +var USERNAME = 'username' +var PASSWORD = 'hi' +var EMAIL = 'n@p.m' +var HEADERS = { + 'npm-custom': 'lolbutts' } -var AUTH = { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } -var PARAMS = { - headers : HEADERS, - auth : AUTH +var PARAMS = { + headers: HEADERS, + auth: AUTH } -test("fetch call contract", function (t) { +test('fetch call contract', function (t) { t.throws(function () { client.get(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.get([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.get(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.get(URI, "", nop) - }, "params must be object") + client.get(URI, '', nop) + }, 'params must be object') t.throws(function () { client.get(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.get(URI, PARAMS, "callback") - }, "callback must be function") + client.get(URI, PARAMS, 'callback') + }, 'callback must be function') t.end() }) -test("basic fetch", function (t) { - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") +test('basic fetch', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(200, { - "content-type" : "application/x-tar", - "content-encoding" : "gzip" + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' }) createReadStream(tgz).pipe(res) @@ -72,18 +72,18 @@ test("basic fetch", function (t) { var defaulted = {} client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3.tgz", + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', defaulted, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = concat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/fetch-github-api-json.js b/node_modules/npm-registry-client/test/fetch-github-api-json.js index 643ac9927..43f25f1ad 100644 --- a/node_modules/npm-registry-client/test/fetch-github-api-json.js +++ b/node_modules/npm-registry-client/test/fetch-github-api-json.js @@ -1,45 +1,44 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var tap = require("tap") -var cat = require("concat-stream") -var Negotiator = require("negotiator") +var tap = require('tap') +var cat = require('concat-stream') +var Negotiator = require('negotiator') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') tap.test("fetch accepts github api's json", function (t) { - server.expect("/underscore/-/underscore-1.3.3", function (req, res) { - t.equal(req.method, "GET", "got expected method") + server.expect('/underscore/-/underscore-1.3.3', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') var negotiator = new Negotiator(req) // fetching a tarball from `api.github.com` returns a 415 error if json is // not accepted - if (negotiator.mediaTypes().indexOf("application/vnd.github+json") === -1) { + if (negotiator.mediaTypes().indexOf('application/vnd.github+json') === -1) { res.writeHead(415, { - "Content-Type" : "application/json" + 'Content-Type': 'application/json' }) - } - else { + } else { res.writeHead(302, { - "Content-Type" : "text/html", - "Location" : "/underscore/-/underscore-1.3.3.tgz" + 'Content-Type': 'text/html', + 'Location': '/underscore/-/underscore-1.3.3.tgz' }) } res.end() }) - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(200, { - "Content-Type" : "application/x-tar", - "Content-Encoding" : "gzip" + 'Content-Type': 'application/x-tar', + 'Content-Encoding': 'gzip' }) createReadStream(tgz).pipe(res) @@ -48,18 +47,18 @@ tap.test("fetch accepts github api's json", function (t) { var client = common.freshClient() var defaulted = {} client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3", + 'http://localhost:1337/underscore/-/underscore-1.3.3', defaulted, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = cat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/fetch-not-authed.js b/node_modules/npm-registry-client/test/fetch-not-authed.js index 413377044..2fb92c2c2 100644 --- a/node_modules/npm-registry-client/test/fetch-not-authed.js +++ b/node_modules/npm-registry-client/test/fetch-not-authed.js @@ -1,50 +1,50 @@ -var resolve = require("path").resolve -var createReadStream = require("graceful-fs").createReadStream -var readFileSync = require("graceful-fs").readFileSync +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync -var tap = require("tap") -var cat = require("concat-stream") +var tap = require('tap') +var cat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var tgz = resolve(__dirname, "./fixtures/underscore/1.3.3/package.tgz") +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') -tap.test("basic fetch with scoped always-auth disabled", function (t) { - server.expect("/underscore/-/underscore-1.3.3.tgz", function (req, res) { - t.equal(req.method, "GET", "got expected method") - t.notOk(req.headers.authorization, "received no auth header") +tap.test('basic fetch with scoped always-auth disabled', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') + t.notOk(req.headers.authorization, 'received no auth header') res.writeHead(200, { - "content-type" : "application/x-tar", - "content-encoding" : "gzip" + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' }) createReadStream(tgz).pipe(res) }) var auth = { - username : "username", - password : "%1234@asdf%", - email : "i@izs.me", - alwaysAuth : false + username: 'username', + password: '%1234@asdf%', + email: 'i@izs.me', + alwaysAuth: false } var client = common.freshClient() - var authed = { auth : auth } + var authed = { auth: auth } client.fetch( - "http://localhost:1337/underscore/-/underscore-1.3.3.tgz", + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', authed, function (er, res) { - t.ifError(er, "loaded successfully") + t.ifError(er, 'loaded successfully') var sink = cat(function (data) { t.deepEqual(data, readFileSync(tgz)) t.end() }) - res.on("error", function (error) { - t.ifError(error, "no errors on stream") + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') }) res.pipe(sink) diff --git a/node_modules/npm-registry-client/test/get-basic.js b/node_modules/npm-registry-client/test/get-basic.js index 1f28bdfbf..a2ab27fe0 100644 --- a/node_modules/npm-registry-client/test/get-basic.js +++ b/node_modules/npm-registry-client/test/get-basic.js @@ -1,80 +1,80 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var us = require("./fixtures/underscore/1.3.3/cache.json") -var usroot = require("./fixtures/underscore/cache.json") +var us = require('./fixtures/underscore/1.3.3/cache.json') +var usroot = require('./fixtures/underscore/cache.json') function nop () {} -var URI = "https://npm.registry:8043/rewrite" -var TIMEOUT = 3600 -var FOLLOW = false +var URI = 'https://npm.registry:8043/rewrite' +var TIMEOUT = 3600 +var FOLLOW = false var STALE_OK = true -var TOKEN = "lolbutts" -var AUTH = { - token : TOKEN +var TOKEN = 'lolbutts' +var AUTH = { + token: TOKEN } -var PARAMS = { - timeout : TIMEOUT, - follow : FOLLOW, - staleOk : STALE_OK, - auth : AUTH +var PARAMS = { + timeout: TIMEOUT, + follow: FOLLOW, + staleOk: STALE_OK, + auth: AUTH } -test("get call contract", function (t) { +test('get call contract', function (t) { t.throws(function () { client.get(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.get([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.get(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.get(URI, "", nop) - }, "params must be object") + client.get(URI, '', nop) + }, 'params must be object') t.throws(function () { client.get(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.get(URI, PARAMS, "callback") - }, "callback must be function") + client.get(URI, PARAMS, 'callback') + }, 'callback must be function') t.end() }) -test("basic request", function (t) { - server.expect("/underscore/1.3.3", function (req, res) { +test('basic request', function (t) { + server.expect('/underscore/1.3.3', function (req, res) { res.json(us) }) - server.expect("/underscore", function (req, res) { + server.expect('/underscore', function (req, res) { res.json(usroot) }) - server.expect("/@bigco%2funderscore", function (req, res) { + server.expect('/@bigco%2funderscore', function (req, res) { res.json(usroot) }) t.plan(3) - client.get("http://localhost:1337/underscore/1.3.3", PARAMS, function (er, data) { + client.get('http://localhost:1337/underscore/1.3.3', PARAMS, function (er, data) { t.deepEqual(data, us) }) - client.get("http://localhost:1337/underscore", PARAMS, function (er, data) { + client.get('http://localhost:1337/underscore', PARAMS, function (er, data) { t.deepEqual(data, usroot) }) - client.get("http://localhost:1337/@bigco%2funderscore", PARAMS, function (er, data) { + client.get('http://localhost:1337/@bigco%2funderscore', PARAMS, function (er, data) { t.deepEqual(data, usroot) }) }) diff --git a/node_modules/npm-registry-client/test/get-error-403.js b/node_modules/npm-registry-client/test/get-error-403.js index dc20a8caf..c9c96d354 100644 --- a/node_modules/npm-registry-client/test/get-error-403.js +++ b/node_modules/npm-registry-client/test/get-error-403.js @@ -1,30 +1,30 @@ -var tap = require("tap") +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -tap.test("get fails with 403", function (t) { - server.expect("/habanero", function (req, res) { - t.equal(req.method, "GET", "got expected method") +tap.test('get fails with 403', function (t) { + server.expect('/habanero', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') res.writeHead(403) - res.end("{\"error\":\"get that cat out of the toilet that's gross omg\"}") + res.end('{"error":"get that cat out of the toilet that\'s gross omg"}') }) var client = common.freshClient() client.config.retry.minTimeout = 100 client.get( - "http://localhost:1337/habanero", + 'http://localhost:1337/habanero', {}, function (er) { - t.ok(er, "failed as expected") + t.ok(er, 'failed as expected') - t.equal(er.statusCode, 403, "status code was attached as expected") - t.equal(er.code, "E403", "error code was formatted as expected") + t.equal(er.statusCode, 403, 'status code was attached as expected') + t.equal(er.code, 'E403', 'error code was formatted as expected') t.equal( er.message, - "get that cat out of the toilet that's gross omg : habanero", - "got error message" + 'get that cat out of the toilet that\'s gross omg : habanero', + 'got error message' ) t.end() diff --git a/node_modules/npm-registry-client/test/initialize.js b/node_modules/npm-registry-client/test/initialize.js index 980a9a7d9..aefbe626f 100644 --- a/node_modules/npm-registry-client/test/initialize.js +++ b/node_modules/npm-registry-client/test/initialize.js @@ -1,74 +1,91 @@ -var test = require("tap").test +var test = require('tap').test -// var server = require("./lib/server.js") -var Client = require("../") +// var server = require('./lib/server.js') +var Client = require('../') -test("defaulted initialization", function (t) { +test('defaulted initialization', function (t) { var client = new Client() var options = client.initialize( - "http://localhost:1337/", - "GET", - "application/json", + 'http://localhost:1337/', + 'GET', + 'application/json', {} ) - t.equal(options.url, "http://localhost:1337/", "URLs match") - t.equal(options.method, "GET", "methods match") + t.equal(options.url, 'http://localhost:1337/', 'URLs match') + t.equal(options.method, 'GET', 'methods match') t.equal(options.proxy, undefined, "proxy won't overwrite environment") - t.equal(options.localAddress, undefined, "localAddress has no default value") - t.equal(options.strictSSL, true, "SSL is strict by default") + t.equal(options.localAddress, undefined, 'localAddress has no default value') + t.equal(options.strictSSL, true, 'SSL is strict by default') - t.equal(options.headers.accept, "application/json", "accept header set") + t.equal(options.headers.accept, 'application/json', 'accept header set') t.equal( options.headers.version, - require("../package.json").version, - "npm-registry-client version is present in headers" + require('../package.json').version, + 'npm-registry-client version is present in headers' ) - t.ok(options.headers["npm-session"], "request ID generated") - t.ok(options.headers["user-agent"], "user-agent preset") + t.ok(options.headers['npm-session'], 'request ID generated') + t.ok(options.headers['user-agent'], 'user-agent preset') - var HttpAgent = require("http").Agent - t.ok(options.agent instanceof HttpAgent, "got an HTTP agent for an HTTP URL") + var HttpAgent = require('http').Agent + t.ok(options.agent instanceof HttpAgent, 'got an HTTP agent for an HTTP URL') t.end() }) -test("referer set on client", function (t) { +test('referer set on client', function (t) { var client = new Client() - client.refer = "xtestx" + client.refer = 'xtestx' var options = client.initialize( - "http://localhost:1337/", - "GET", - "application/json", + 'http://localhost:1337/', + 'GET', + 'application/json', {} ) - t.equal(options.headers.referer, "xtestx", "referer header set") + t.equal(options.headers.referer, 'xtestx', 'referer header set') t.end() }) -test("initializing with proxy explicitly disabled", function (t) { - var client = new Client({ proxy : { http : false }}) +test('initializing with proxy explicitly disabled', function (t) { + var client = new Client({ proxy: { http: false }}) var options = client.initialize( - "http://localhost:1337/", - "GET", - "application/json", + 'http://localhost:1337/', + 'GET', + 'application/json', {} ) - t.ok("proxy" in options, "proxy overridden by explicitly setting to false") - t.equal(options.proxy, null, "request will override proxy when empty proxy passed in") + t.ok('proxy' in options, 'proxy overridden by explicitly setting to false') + t.equal(options.proxy, null, 'request will override proxy when empty proxy passed in') t.end() }) -test("initializing with proxy undefined", function (t) { - var client = new Client({ proxy : { http : undefined }}) +test('initializing with proxy undefined', function (t) { + var client = new Client({ proxy: { http: undefined }}) var options = client.initialize( - "http://localhost:1337/", - "GET", - "application/json", + 'http://localhost:1337/', + 'GET', + 'application/json', {} ) - t.notOk("proxy" in options, "proxy can be read from env.PROXY by request") + t.notOk('proxy' in options, 'proxy can be read from env.PROXY by request') + t.end() +}) + +test('initializing with a certificate should map down to the https agent', function (t) { + var certificate = '-----BEGIN CERTIFICATE----- TEST\nTEST -----END CERTIFICATE-----\n' + var client = new Client({ + ssl: { + certificate: certificate + } + }) + var options = client.initialize( + { protocol: 'https:' }, + 'GET', + 'application/json', + {} + ) + t.equal(options.agent.options.cert, certificate, 'certificate will be saved properly on agent') t.end() }) diff --git a/node_modules/npm-registry-client/test/lib/common.js b/node_modules/npm-registry-client/test/lib/common.js index 178a75bb5..8b7875d4c 100644 --- a/node_modules/npm-registry-client/test/lib/common.js +++ b/node_modules/npm-registry-client/test/lib/common.js @@ -1,14 +1,14 @@ -var server = require("./server.js") -var RC = require("../../") -var REGISTRY = "http://localhost:" + server.port +var server = require('./server.js') +var RC = require('../../') +var REGISTRY = 'http://localhost:' + server.port module.exports = { - port : server.port, - registry : REGISTRY, - freshClient : function freshClient(config) { + port: server.port, + registry: REGISTRY, + freshClient: function freshClient (config) { var client = new RC(config) server.log = client.log - client.log.level = "silent" + client.log.level = 'silent' return client } diff --git a/node_modules/npm-registry-client/test/lib/server.js b/node_modules/npm-registry-client/test/lib/server.js index 775f7548c..60b116d80 100644 --- a/node_modules/npm-registry-client/test/lib/server.js +++ b/node_modules/npm-registry-client/test/lib/server.js @@ -3,7 +3,7 @@ var http = require('http') var server = http.createServer(handler) var port = server.port = process.env.PORT || 1337 -var assert = require("assert") +var assert = require('assert') server.listen(port) module.exports = server @@ -15,13 +15,13 @@ function handler (req, res) { // If we got authorization, make sure it's the right password. if (req.headers.authorization && req.headers.authorization.match(/^Basic/)) { - var auth = req.headers.authorization.replace(/^Basic /, "") - auth = new Buffer(auth, "base64").toString("utf8") - assert.equal(auth, "username:%1234@asdf%") + var auth = req.headers.authorization.replace(/^Basic /, '') + auth = new Buffer(auth, 'base64').toString('utf8') + assert.equal(auth, 'username:%1234@asdf%') } var u = '* ' + req.url - , mu = req.method + ' ' + req.url + var mu = req.method + ' ' + req.url var k = server._expect[mu] ? mu : server._expect[u] ? u : null if (!k) throw Error('unexpected request: ' + req.method + ' ' + req.url) @@ -29,13 +29,12 @@ function handler (req, res) { var fn = server._expect[k].shift() if (!fn) throw Error('unexpected request: ' + req.method + ' ' + req.url) - var remain = (Object.keys(server._expect).reduce(function (s, k) { return s + server._expect[k].length }, 0)) if (remain === 0) server.close() - else this.log.info("fake-registry", "TEST SERVER: %d reqs remain", remain) - this.log.info("fake-registry", Object.keys(server._expect).map(function(k) { + else this.log.info('fake-registry', 'TEST SERVER: %d reqs remain', remain) + this.log.info('fake-registry', Object.keys(server._expect).map(function (k) { return [k, server._expect[k].length] }).reduce(function (acc, kv) { acc[kv[0]] = kv[1] @@ -52,7 +51,7 @@ function json (o) { } // this log is meanto to be overridden -server.log = require("npmlog") +server.log = require('npmlog') server.expect = function (method, u, fn) { if (typeof u === 'function') { diff --git a/node_modules/npm-registry-client/test/logout.js b/node_modules/npm-registry-client/test/logout.js index bbf1b8c09..7836d805a 100644 --- a/node_modules/npm-registry-client/test/logout.js +++ b/node_modules/npm-registry-client/test/logout.js @@ -1,43 +1,43 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() function nop () {} -var URI = "http://localhost:1337/rewrite" -var TOKEN = "b00b00feed" +var URI = 'http://localhost:1337/rewrite' +var TOKEN = 'b00b00feed' var PARAMS = { auth: { token: TOKEN } } -test("logout call contract", function (t) { +test('logout call contract', function (t) { t.throws(function () { client.logout(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.logout([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.logout(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.logout(URI, "", nop) - }, "params must be object") + client.logout(URI, '', nop) + }, 'params must be object') t.throws(function () { client.logout(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.logout(URI, PARAMS, "callback") - }, "callback must be function") + client.logout(URI, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { @@ -46,29 +46,29 @@ test("logout call contract", function (t) { } client.logout(URI, params, nop) }, - { name: "AssertionError", message: "can only log out for token auth" }, - "auth must include token" + { name: 'AssertionError', message: 'can only log out for token auth' }, + 'auth must include token' ) t.end() }) -test("log out from a token-based registry", function (t) { - server.expect("DELETE", "/-/user/token/" + TOKEN, function (req, res) { - t.equal(req.method, "DELETE") - t.equal(req.headers.authorization, "Bearer " + TOKEN, "request is authed") +test('log out from a token-based registry', function (t) { + server.expect('DELETE', '/-/user/token/' + TOKEN, function (req, res) { + t.equal(req.method, 'DELETE') + t.equal(req.headers.authorization, 'Bearer ' + TOKEN, 'request is authed') - res.json({message: "ok"}) + res.json({message: 'ok'}) }) client.logout(URI, PARAMS, function (er) { - t.ifError(er, "no errors") + t.ifError(er, 'no errors') t.end() }) }) -test("cleanup", function (t) { +test('cleanup', function (t) { server.close() t.end() }) diff --git a/node_modules/npm-registry-client/test/publish-again-scoped.js b/node_modules/npm-registry-client/test/publish-again-scoped.js index b9d9a24d6..42f672721 100644 --- a/node_modules/npm-registry-client/test/publish-again-scoped.js +++ b/node_modules/npm-registry-client/test/publish-again-scoped.js @@ -1,88 +1,88 @@ -var tap = require("tap") -var fs = require("fs") +var tap = require('tap') +var fs = require('fs') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var auth = { - username : "username", - password : "%1234@asdf%", - email : "i@izs.me", - alwaysAuth : true + username: 'username', + password: '%1234@asdf%', + email: 'i@izs.me', + alwaysAuth: true } var client = common.freshClient() -tap.test("publish again", function (t) { +tap.test('publish again', function (t) { // not really a tarball, but doesn't matter - var bodyPath = require.resolve("../package.json") - var tarball = fs.createReadStream(bodyPath, "base64") - var pd = fs.readFileSync(bodyPath, "base64") - var pkg = require("../package.json") + var bodyPath = require.resolve('../package.json') + var tarball = fs.createReadStream(bodyPath) + var pd = fs.readFileSync(bodyPath, 'base64') + var pkg = require('../package.json') var lastTime = null - server.expect("/@npm%2fnpm-registry-client", function (req, res) { - t.equal(req.method, "PUT") - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + server.expect('/@npm%2fnpm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var o = lastTime = JSON.parse(b) - t.equal(o._id, "@npm/npm-registry-client") - t.equal(o["dist-tags"].latest, pkg.version) + t.equal(o._id, '@npm/npm-registry-client') + t.equal(o['dist-tags'].latest, pkg.version) t.has(o.versions[pkg.version], pkg) - t.same(o.maintainers, [ { name: "username", email: "i@izs.me" } ]) - var att = o._attachments[ pkg.name + "-" + pkg.version + ".tgz" ] + t.same(o.maintainers, [ { name: 'username', email: 'i@izs.me' } ]) + var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ] t.same(att.data, pd) res.statusCode = 409 - res.json({reason: "must supply latest _rev to update existing package"}) + res.json({reason: 'must supply latest _rev to update existing package'}) }) }) - server.expect("/@npm%2fnpm-registry-client?write=true", function (req, res) { - t.equal(req.method, "GET") + server.expect('/@npm%2fnpm-registry-client?write=true', function (req, res) { + t.equal(req.method, 'GET') t.ok(lastTime) for (var i in lastTime.versions) { var v = lastTime.versions[i] delete lastTime.versions[i] - lastTime.versions["0.0.2"] = v - lastTime["dist-tags"] = { latest: "0.0.2" } + lastTime.versions['0.0.2'] = v + lastTime['dist-tags'] = { latest: '0.0.2' } } - lastTime._rev = "asdf" + lastTime._rev = 'asdf' res.json(lastTime) }) - server.expect("/@npm%2fnpm-registry-client", function (req, res) { - t.equal(req.method, "PUT") + server.expect('/@npm%2fnpm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') t.ok(lastTime) - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function() { + req.on('end', function () { var o = JSON.parse(b) - t.equal(o._rev, "asdf") - t.deepEqual(o.versions["0.0.2"], o.versions[pkg.version]) + t.equal(o._rev, 'asdf') + t.deepEqual(o.versions['0.0.2'], o.versions[pkg.version]) res.statusCode = 201 res.json({created: true}) }) }) - pkg.name = "@npm/npm-registry-client" + pkg.name = '@npm/npm-registry-client' var params = { - metadata : pkg, - access : "restricted", - body : tarball, - auth : auth + metadata: pkg, + access: 'restricted', + body: tarball, + auth: auth } - client.publish("http://localhost:1337/", params, function (er, data) { + client.publish('http://localhost:1337/', params, function (er, data) { if (er) throw er t.deepEqual(data, { created: true }) t.end() diff --git a/node_modules/npm-registry-client/test/publish-again.js b/node_modules/npm-registry-client/test/publish-again.js index f5da5b243..5beec90e4 100644 --- a/node_modules/npm-registry-client/test/publish-again.js +++ b/node_modules/npm-registry-client/test/publish-again.js @@ -1,86 +1,86 @@ -var tap = require("tap") -var fs = require("fs") +var tap = require('tap') +var fs = require('fs') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var auth = { - username : "username", - password : "%1234@asdf%", - email : "i@izs.me", - alwaysAuth : true + username: 'username', + password: '%1234@asdf%', + email: 'i@izs.me', + alwaysAuth: true } var client = common.freshClient() -tap.test("publish again", function (t) { +tap.test('publish again', function (t) { // not really a tarball, but doesn't matter - var bodyPath = require.resolve("../package.json") - var tarball = fs.createReadStream(bodyPath, "base64") - var pd = fs.readFileSync(bodyPath, "base64") - var pkg = require("../package.json") + var bodyPath = require.resolve('../package.json') + var tarball = fs.createReadStream(bodyPath) + var pd = fs.readFileSync(bodyPath, 'base64') + var pkg = require('../package.json') var lastTime = null - server.expect("/npm-registry-client", function (req, res) { - t.equal(req.method, "PUT") - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + server.expect('/npm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var o = lastTime = JSON.parse(b) - t.equal(o._id, "npm-registry-client") - t.equal(o["dist-tags"].latest, pkg.version) + t.equal(o._id, 'npm-registry-client') + t.equal(o['dist-tags'].latest, pkg.version) t.has(o.versions[pkg.version], pkg) - t.same(o.maintainers, [ { name: "username", email: "i@izs.me" } ]) - var att = o._attachments[ pkg.name + "-" + pkg.version + ".tgz" ] + t.same(o.maintainers, [ { name: 'username', email: 'i@izs.me' } ]) + var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ] t.same(att.data, pd) res.statusCode = 409 - res.json({reason: "must supply latest _rev to update existing package"}) + res.json({reason: 'must supply latest _rev to update existing package'}) }) }) - server.expect("/npm-registry-client?write=true", function (req, res) { - t.equal(req.method, "GET") + server.expect('/npm-registry-client?write=true', function (req, res) { + t.equal(req.method, 'GET') t.ok(lastTime) for (var i in lastTime.versions) { var v = lastTime.versions[i] delete lastTime.versions[i] - lastTime.versions["0.0.2"] = v - lastTime["dist-tags"] = { latest: "0.0.2" } + lastTime.versions['0.0.2'] = v + lastTime['dist-tags'] = { latest: '0.0.2' } } - lastTime._rev = "asdf" + lastTime._rev = 'asdf' res.json(lastTime) }) - server.expect("/npm-registry-client", function (req, res) { - t.equal(req.method, "PUT") + server.expect('/npm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') t.ok(lastTime) - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function() { + req.on('end', function () { var o = JSON.parse(b) - t.equal(o._rev, "asdf") - t.deepEqual(o.versions["0.0.2"], o.versions[pkg.version]) + t.equal(o._rev, 'asdf') + t.deepEqual(o.versions['0.0.2'], o.versions[pkg.version]) res.statusCode = 201 res.json({created: true}) }) }) var params = { - metadata : pkg, - access : "public", - body : tarball, - auth : auth + metadata: pkg, + access: 'public', + body: tarball, + auth: auth } - client.publish("http://localhost:1337/", params, function (er, data) { + client.publish('http://localhost:1337/', params, function (er, data) { if (er) throw er t.deepEqual(data, { created: true }) t.end() 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 index 50b3f9349..5cb66d1e0 100644 --- a/node_modules/npm-registry-client/test/publish-failed-no-message.js +++ b/node_modules/npm-registry-client/test/publish-failed-no-message.js @@ -1,42 +1,42 @@ -var createReadStream = require("fs").createReadStream +var createReadStream = require('fs').createReadStream -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") -var config = { retry : { retries : 0 } } +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") -var ACCESS = "public" +var URI = 'http://localhost:1337/' +var USERNAME = 'username' +var PASSWORD = '%1234@asdf%' +var EMAIL = 'i@izs.me' +var METADATA = require('../package.json') +var ACCESS = 'public' // 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 BODY_PATH = require.resolve('../package.json') +var BODY = createReadStream(BODY_PATH) +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } -var PARAMS = { - metadata : METADATA, - access : ACCESS, - body : BODY, - auth : AUTH +var PARAMS = { + metadata: METADATA, + access: ACCESS, + body: BODY, + auth: AUTH } -test("publish with a 500 response but no message", function (t){ - server.expect("/npm-registry-client", function (req, res) { +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 }) + 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.ok(er, 'got expected error') + t.notOk(data, 'no payload on failure') t.end() }) diff --git a/node_modules/npm-registry-client/test/publish-scoped-auth-token.js b/node_modules/npm-registry-client/test/publish-scoped-auth-token.js index 203c80004..d4704ca49 100644 --- a/node_modules/npm-registry-client/test/publish-scoped-auth-token.js +++ b/node_modules/npm-registry-client/test/publish-scoped-auth-token.js @@ -1,52 +1,52 @@ -var tap = require("tap") -var crypto = require("crypto") -var fs = require("fs") +var tap = require('tap') +var crypto = require('crypto') +var fs = require('fs') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') -var auth = { token : "of-glad-tidings" } +var auth = { token: 'of-glad-tidings' } var client = common.freshClient() -tap.test("publish", function (t) { +tap.test('publish', function (t) { // not really a tarball, but doesn't matter - var bodyPath = require.resolve("../package.json") - var tarball = fs.createReadStream(bodyPath, "base64") - var pd = fs.readFileSync(bodyPath, "base64") - var pkg = require("../package.json") - pkg.name = "@npm/npm-registry-client" - - server.expect("/@npm%2fnpm-registry-client", function (req, res) { - t.equal(req.method, "PUT") - t.equal(req.headers.authorization, "Bearer of-glad-tidings") - - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var bodyPath = require.resolve('../package.json') + var tarball = fs.createReadStream(bodyPath) + var pd = fs.readFileSync(bodyPath, 'base64') + var pkg = require('../package.json') + pkg.name = '@npm/npm-registry-client' + + server.expect('/@npm%2fnpm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') + t.equal(req.headers.authorization, 'Bearer of-glad-tidings') + + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var o = JSON.parse(b) - t.equal(o._id, "@npm/npm-registry-client") - t.equal(o["dist-tags"].latest, pkg.version) + t.equal(o._id, '@npm/npm-registry-client') + t.equal(o['dist-tags'].latest, pkg.version) t.has(o.versions[pkg.version], pkg) t.same(o.maintainers, o.versions[pkg.version].maintainers) - var att = o._attachments[ pkg.name + "-" + pkg.version + ".tgz" ] + var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ] t.same(att.data, pd) - var hash = crypto.createHash("sha1").update(pd, "base64").digest("hex") + var hash = crypto.createHash('sha1').update(pd, 'base64').digest('hex') t.equal(o.versions[pkg.version].dist.shasum, hash) res.statusCode = 201 - res.json({created:true}) + res.json({ created: true }) }) }) var params = { - metadata : pkg, - access : "restricted", - body : tarball, - auth : auth + metadata: pkg, + access: 'restricted', + body: tarball, + auth: auth } client.publish(common.registry, params, function (er, data) { if (er) throw er diff --git a/node_modules/npm-registry-client/test/publish-scoped.js b/node_modules/npm-registry-client/test/publish-scoped.js index 6bb48617d..7758c3c12 100644 --- a/node_modules/npm-registry-client/test/publish-scoped.js +++ b/node_modules/npm-registry-client/test/publish-scoped.js @@ -1,59 +1,59 @@ -var tap = require("tap") -var crypto = require("crypto") -var fs = require("fs") +var tap = require('tap') +var crypto = require('crypto') +var fs = require('fs') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var auth = { - username : "username", - password : "%1234@asdf%", - email : "ogd@aoaioxxysz.net" + username: 'username', + password: '%1234@asdf%', + email: 'ogd@aoaioxxysz.net' } var client = common.freshClient() -var _auth = new Buffer("username:%1234@asdf%").toString("base64") +var _auth = new Buffer('username:%1234@asdf%').toString('base64') -tap.test("publish", function (t) { +tap.test('publish', function (t) { // not really a tarball, but doesn't matter - var bodyPath = require.resolve("../package.json") - var tarball = fs.createReadStream(bodyPath, "base64") - var pd = fs.readFileSync(bodyPath, "base64") - var pkg = require("../package.json") - pkg.name = "@npm/npm-registry-client" - - server.expect("/@npm%2fnpm-registry-client", function (req, res) { - t.equal(req.method, "PUT") - t.equal(req.headers.authorization, "Basic " + _auth) - - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var bodyPath = require.resolve('../package.json') + var tarball = fs.createReadStream(bodyPath) + var pd = fs.readFileSync(bodyPath, 'base64') + var pkg = require('../package.json') + pkg.name = '@npm/npm-registry-client' + + server.expect('/@npm%2fnpm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') + t.equal(req.headers.authorization, 'Basic ' + _auth) + + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var o = JSON.parse(b) - t.equal(o._id, "@npm/npm-registry-client") - t.equal(o["dist-tags"].latest, pkg.version) + t.equal(o._id, '@npm/npm-registry-client') + t.equal(o['dist-tags'].latest, pkg.version) t.has(o.versions[pkg.version], pkg) - t.same(o.maintainers, [ { name: "username", email: "ogd@aoaioxxysz.net" } ]) + t.same(o.maintainers, [ { name: 'username', email: 'ogd@aoaioxxysz.net' } ]) t.same(o.maintainers, o.versions[pkg.version].maintainers) - var att = o._attachments[ pkg.name + "-" + pkg.version + ".tgz" ] + var att = o._attachments[ pkg.name + '-' + pkg.version + '.tgz' ] t.same(att.data, pd) - var hash = crypto.createHash("sha1").update(pd, "base64").digest("hex") + var hash = crypto.createHash('sha1').update(pd, 'base64').digest('hex') t.equal(o.versions[pkg.version].dist.shasum, hash) res.statusCode = 201 - res.json({created:true}) + res.json({ created: true }) }) }) var params = { - metadata : pkg, - access : "restricted", - body : tarball, - auth : auth + metadata: pkg, + access: 'restricted', + body: tarball, + auth: auth } client.publish(common.registry, params, function (er, data) { if (er) throw er diff --git a/node_modules/npm-registry-client/test/publish.js b/node_modules/npm-registry-client/test/publish.js index 5a87b64c0..f2c257e95 100644 --- a/node_modules/npm-registry-client/test/publish.js +++ b/node_modules/npm-registry-client/test/publish.js @@ -1,125 +1,125 @@ -var test = require("tap").test -var crypto = require("crypto") -var fs = require("fs") +var test = require('tap').test +var crypto = require('crypto') +var fs = require('fs') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() function nop () {} -var URI = "http://localhost:1337/" -var USERNAME = "username" -var PASSWORD = "%1234@asdf%" -var EMAIL = "i@izs.me" -var METADATA = require("../package.json") -var ACCESS = "public" +var URI = 'http://localhost:1337/' +var USERNAME = 'username' +var PASSWORD = '%1234@asdf%' +var EMAIL = 'i@izs.me' +var METADATA = require('../package.json') +var ACCESS = 'public' // not really a tarball, but doesn't matter -var BODY_PATH = require.resolve("../package.json") -var BODY = fs.createReadStream(BODY_PATH, "base64") -var AUTH = { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var BODY_PATH = require.resolve('../package.json') +var BODY = fs.createReadStream(BODY_PATH) +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } -var PARAMS = { - metadata : METADATA, - access : ACCESS, - body : BODY, - auth : AUTH +var PARAMS = { + metadata: METADATA, + access: ACCESS, + body: BODY, + auth: AUTH } -test("publish call contract", function (t) { +test('publish call contract', function (t) { t.throws(function () { client.publish(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.publish([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.publish(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.publish(URI, "", nop) - }, "params must be object") + client.publish(URI, '', nop) + }, 'params must be object') t.throws(function () { client.publish(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.publish(URI, PARAMS, "callback") - }, "callback must be function") + client.publish(URI, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - access : ACCESS, - body : BODY, - auth : AUTH + access: ACCESS, + body: BODY, + auth: AUTH } client.publish(URI, params, nop) }, - { name : "AssertionError", message : "must pass package metadata to publish" }, - "params must include metadata for package" + { name: 'AssertionError', message: 'must pass package metadata to publish' }, + 'params must include metadata for package' ) t.throws( function () { var params = { - metadata : METADATA, - access : ACCESS, - auth : AUTH + metadata: METADATA, + access: ACCESS, + auth: AUTH } client.publish(URI, params, nop) }, - { name : "AssertionError", message : "must pass package body to publish" }, - "params must include body of package to publish" + { name: 'AssertionError', message: 'must pass package body to publish' }, + 'params must include body of package to publish' ) t.throws( function () { var params = { - metadata : METADATA, - access : ACCESS, - body : BODY + metadata: METADATA, + access: ACCESS, + body: BODY } client.publish(URI, params, nop) }, - { name : "AssertionError", message : "must pass auth to publish" }, - "params must include auth" + { name: 'AssertionError', message: 'must pass auth to publish' }, + 'params must include auth' ) t.throws( function () { var params = { - metadata : -1, - access : ACCESS, - body : BODY, - auth : AUTH + metadata: -1, + access: ACCESS, + body: BODY, + auth: AUTH } client.publish(URI, params, nop) }, - { name : "AssertionError", message : "must pass package metadata to publish" }, - "metadata must be object" + { name: 'AssertionError', message: 'must pass package metadata to publish' }, + 'metadata must be object' ) t.throws( function () { var params = { - metadata : METADATA, - access : "hamchunx", - body : BODY, - auth : AUTH + metadata: METADATA, + access: 'hamchunx', + body: BODY, + auth: AUTH } client.publish(URI, params, nop) }, { - name : "AssertionError", - message : "if present, access level must be either 'public' or 'restricted'" + name: 'AssertionError', + message: "if present, access level must be either 'public' or 'restricted'" }, "access level must be 'public' or 'restricted'" ) @@ -127,34 +127,34 @@ test("publish call contract", function (t) { t.throws( function () { var params = { - metadata : METADATA, - access : ACCESS, - body : -1, - auth : AUTH + metadata: METADATA, + access: ACCESS, + body: -1, + auth: AUTH } client.publish(URI, params, nop) }, { - name : "AssertionError", - message : "package body passed to publish must be a stream" + name: 'AssertionError', + message: 'package body passed to publish must be a stream' }, - "body must be a Stream" + 'body must be a Stream' ) - t.test("malformed semver in publish", function (t) { + t.test('malformed semver in publish', function (t) { var metadata = JSON.parse(JSON.stringify(METADATA)) - metadata.version = "%!@#$" + metadata.version = '%!@#$' var params = { - metadata : metadata, - access : ACCESS, - message : BODY, - auth : AUTH + metadata: metadata, + access: ACCESS, + message: BODY, + auth: AUTH } client.publish(URI, params, function (err) { t.equal( err && err.message, - "invalid semver: %!@#$", - "got expected semver validation failure" + 'invalid semver: %!@#$', + 'got expected semver validation failure' ) t.end() }) @@ -163,41 +163,41 @@ test("publish call contract", function (t) { t.end() }) -test("publish", function (t) { - var pd = fs.readFileSync(BODY_PATH, "base64") +test('publish', function (t) { + var pd = fs.readFileSync(BODY_PATH, 'base64') - server.expect("/npm-registry-client", function (req, res) { - t.equal(req.method, "PUT") - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + server.expect('/npm-registry-client', function (req, res) { + t.equal(req.method, 'PUT') + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var o = JSON.parse(b) - t.equal(o._id, "npm-registry-client") - t.equal(o["dist-tags"].latest, METADATA.version) + t.equal(o._id, 'npm-registry-client') + t.equal(o['dist-tags'].latest, METADATA.version) t.equal(o.access, ACCESS) t.has(o.versions[METADATA.version], METADATA) - t.same(o.maintainers, [{ name : "username", email : "i@izs.me" }]) + t.same(o.maintainers, [{ name: 'username', email: 'i@izs.me' }]) t.same(o.maintainers, o.versions[METADATA.version].maintainers) - var att = o._attachments[METADATA.name+"-"+METADATA.version+".tgz"] + var att = o._attachments[METADATA.name + '-' + METADATA.version + '.tgz'] t.same(att.data, pd) - var hash = crypto.createHash("sha1").update(pd, "base64").digest("hex") + var hash = crypto.createHash('sha1').update(pd, 'base64').digest('hex') t.equal(o.versions[METADATA.version].dist.shasum, hash) res.statusCode = 201 - res.json({ created : true }) + res.json({ created: true }) }) }) client.publish(URI, PARAMS, function (er, data) { if (er) throw er - t.deepEqual(data, { created : true }) + t.deepEqual(data, { created: true }) t.end() }) }) diff --git a/node_modules/npm-registry-client/test/redirects.js b/node_modules/npm-registry-client/test/redirects.js index ba3814349..d589f161a 100644 --- a/node_modules/npm-registry-client/test/redirects.js +++ b/node_modules/npm-registry-client/test/redirects.js @@ -1,49 +1,49 @@ -var tap = require("tap") +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() var pkg = { - _id: "some-package@1.2.3", - name: "some-package", - version: "1.2.3" + _id: 'some-package@1.2.3', + name: 'some-package', + version: '1.2.3' } -tap.test("basic request", function (t) { +tap.test('basic request', function (t) { // Expect one request for { follow : false } - server.expect("/-/some-package/1.2.3", function (req, res) { + server.expect('/-/some-package/1.2.3', function (req, res) { res.writeHead(301, { - "Location": "/some-package/1.2.3" + 'Location': '/some-package/1.2.3' }) - res.end("Redirecting") + res.end('Redirecting') }) // Expect 2 requests for { follow : true } - server.expect("/-/some-package/1.2.3", function (req, res) { + server.expect('/-/some-package/1.2.3', function (req, res) { res.writeHead(301, { - "Location": "/some-package/1.2.3" + 'Location': '/some-package/1.2.3' }) - res.end("Redirecting") + res.end('Redirecting') }) - server.expect("/some-package/1.2.3", function (req, res) { + server.expect('/some-package/1.2.3', function (req, res) { res.json(pkg) }) t.plan(2) client.get( - "http://localhost:1337/-/some-package/1.2.3", - { follow : false }, + 'http://localhost:1337/-/some-package/1.2.3', + { follow: false }, function (er) { - t.ok(er, "Error must be set") + t.ok(er, 'Error must be set') } ) client.get( - "http://localhost:1337/-/some-package/1.2.3", - { follow : true }, + 'http://localhost:1337/-/some-package/1.2.3', + { follow: true }, function (er, data) { t.deepEqual(data, pkg) } diff --git a/node_modules/npm-registry-client/test/request-gzip-content.js b/node_modules/npm-registry-client/test/request-gzip-content.js index 5f6a33daa..27a76b8a8 100644 --- a/node_modules/npm-registry-client/test/request-gzip-content.js +++ b/node_modules/npm-registry-client/test/request-gzip-content.js @@ -1,55 +1,55 @@ -var zlib = require("zlib") -var tap = require("tap") +var zlib = require('zlib') +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient({ - retry : { - count : 1, - minTimeout : 10, - maxTimeout : 100 + retry: { + count: 1, + minTimeout: 10, + maxTimeout: 100 } }) -var TEST_URL = common.registry+"/some-package-gzip/1.2.3" +var TEST_URL = common.registry + '/some-package-gzip/1.2.3' var pkg = { - _id : "some-package-gzip@1.2.3", - name : "some-package-gzip", - version : "1.2.3" + _id: 'some-package-gzip@1.2.3', + name: 'some-package-gzip', + version: '1.2.3' } zlib.gzip(JSON.stringify(pkg), function (err, pkgGzip) { - tap.test("request gzip package content", function (t) { - t.ifError(err, "example package compressed") + tap.test('request gzip package content', function (t) { + t.ifError(err, 'example package compressed') - server.expect("GET", "/some-package-gzip/1.2.3", function (req, res) { + server.expect('GET', '/some-package-gzip/1.2.3', function (req, res) { res.statusCode = 200 - res.setHeader("Content-Encoding", "gzip") - res.setHeader("Content-Type", "application/json") + res.setHeader('Content-Encoding', 'gzip') + res.setHeader('Content-Type', 'application/json') res.end(pkgGzip) }) client.get(TEST_URL, {}, function (er, data) { if (er) throw er - t.deepEqual(data, pkg, "some-package-gzip version 1.2.3") + t.deepEqual(data, pkg, 'some-package-gzip version 1.2.3') t.end() }) }) - tap.test("request wrong gzip package content", function (t) { + tap.test('request wrong gzip package content', function (t) { // will retry 3 times for (var i = 0; i < 3; i++) { - server.expect("GET", "/some-package-gzip/1.2.3", function (req, res) { + server.expect('GET', '/some-package-gzip/1.2.3', function (req, res) { res.statusCode = 200 - res.setHeader("Content-Encoding", "gzip") - res.setHeader("Content-Type", "application/json") - res.end(new Buffer("wrong gzip content")) + res.setHeader('Content-Encoding', 'gzip') + res.setHeader('Content-Type', 'application/json') + res.end(new Buffer('wrong gzip content')) }) } client.get(TEST_URL, {}, function (er) { - t.ok(er, "ungzip error") + t.ok(er, 'ungzip error') t.end() }) }) diff --git a/node_modules/npm-registry-client/test/request.js b/node_modules/npm-registry-client/test/request.js index cdc4b75f5..0024c9b21 100644 --- a/node_modules/npm-registry-client/test/request.js +++ b/node_modules/npm-registry-client/test/request.js @@ -1,252 +1,252 @@ -var Readable = require("stream").Readable -var inherits = require("util").inherits +var Readable = require('stream').Readable +var inherits = require('util').inherits -var test = require("tap").test -var concat = require("concat-stream") +var test = require('tap').test +var concat = require('concat-stream') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -function OneA() { +function OneA () { Readable.call(this) - this.push("A") + this.push('A') this.push(null) } inherits(OneA, Readable) function nop () {} -var URI = "http://localhost:1337/" -var USERNAME = "username" -var PASSWORD = "%1234@asdf%" -var EMAIL = "i@izs.me" -var AUTH = { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var URI = 'http://localhost:1337/' +var USERNAME = 'username' +var PASSWORD = '%1234@asdf%' +var EMAIL = 'i@izs.me' +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } -var PARAMS = { auth : AUTH } +var PARAMS = { auth: AUTH } -test("request call contract", function (t) { +test('request call contract', function (t) { t.throws( function () { client.request(undefined, PARAMS, nop) }, - { name : "AssertionError", message : "must pass uri to request" }, - "requires a URI" + { name: 'AssertionError', message: 'must pass uri to request' }, + 'requires a URI' ) t.throws( function () { client.request([], PARAMS, nop) }, - { name : "AssertionError", message : "must pass uri to request" }, - "requires URI to be a string" + { name: 'AssertionError', message: 'must pass uri to request' }, + 'requires URI to be a string' ) t.throws( function () { client.request(URI, undefined, nop) }, - { name : "AssertionError", message : "must pass params to request" }, - "requires params object" + { name: 'AssertionError', message: 'must pass params to request' }, + 'requires params object' ) t.throws( function () { - client.request(URI, "", nop) + client.request(URI, '', nop) }, - { name : "AssertionError", message : "must pass params to request" }, - "params must be object" + { name: 'AssertionError', message: 'must pass params to request' }, + 'params must be object' ) t.throws( function () { client.request(URI, PARAMS, undefined) }, - { name : "AssertionError", message : "must pass callback to request" }, - "requires callback" + { name: 'AssertionError', message: 'must pass callback to request' }, + 'requires callback' ) t.throws( function () { - client.request(URI, PARAMS, "callback") + client.request(URI, PARAMS, 'callback') }, - { name : "AssertionError", message : "must pass callback to request" }, - "callback must be function" + { name: 'AssertionError', message: 'must pass callback to request' }, + 'callback must be function' ) t.end() }) -test("run request through its paces", function (t) { +test('run request through its paces', function (t) { t.plan(27) - server.expect("/request-defaults", function (req, res) { - t.equal(req.method, "GET", "uses GET by default") + server.expect('/request-defaults', function (req, res) { + t.equal(req.method, 'GET', 'uses GET by default') req.pipe(concat(function (d) { - t.notOk(d.toString("utf7"), "no data included in request") + t.notOk(d.toString('utf7'), 'no data included in request') res.statusCode = 200 - res.json({ fetched : "defaults" }) + res.json({ fetched: 'defaults' }) })) }) - server.expect("/last-modified", function (req, res) { - t.equal(req.headers["if-modified-since"], "test-last-modified", - "got test if-modified-since") + server.expect('/last-modified', function (req, res) { + t.equal(req.headers['if-modified-since'], 'test-last-modified', + 'got test if-modified-since') res.statusCode = 200 - res.json({ fetched : "last-modified" }) + res.json({ fetched: 'last-modified' }) }) - server.expect("/etag", function (req, res) { - t.equal(req.headers["if-none-match"], "test-etag", "got test etag") + server.expect('/etag', function (req, res) { + t.equal(req.headers['if-none-match'], 'test-etag', 'got test etag') res.statusCode = 200 - res.json({ fetched : "etag" }) + res.json({ fetched: 'etag' }) }) - server.expect("POST", "/etag-post", function (req, res) { - t.equal(req.headers["if-match"], "post-etag", "got test post etag") + server.expect('POST', '/etag-post', function (req, res) { + t.equal(req.headers['if-match'], 'post-etag', 'got test post etag') res.statusCode = 200 - res.json({ posted : "etag" }) + res.json({ posted: 'etag' }) }) - server.expect("PUT", "/body-stream", function (req, res) { + server.expect('PUT', '/body-stream', function (req, res) { req.pipe(concat(function (d) { - t.equal(d.toString("utf8"), "A", "streamed expected data") + t.equal(d.toString('utf8'), 'A', 'streamed expected data') res.statusCode = 200 - res.json({ put : "stream" }) + res.json({ put: 'stream' }) })) }) - server.expect("PUT", "/body-buffer", function (req, res) { + server.expect('PUT', '/body-buffer', function (req, res) { req.pipe(concat(function (d) { - t.equal(d.toString("utf8"), "hi", "streamed expected data") + t.equal(d.toString('utf8'), 'hi', 'streamed expected data') res.statusCode = 200 - res.json({ put : "buffer" }) + res.json({ put: 'buffer' }) })) }) - server.expect("PUT", "/body-string", function (req, res) { + server.expect('PUT', '/body-string', function (req, res) { req.pipe(concat(function (d) { - t.equal(d.toString("utf8"), "erp", "streamed expected data") + t.equal(d.toString('utf8'), 'erp', 'streamed expected data') res.statusCode = 200 - res.json({ put : "string" }) + res.json({ put: 'string' }) })) }) - server.expect("PUT", "/body-object", function (req, res) { + server.expect('PUT', '/body-object', function (req, res) { req.pipe(concat(function (d) { - t.equal(d.toString("utf8"), '["tricky"]', "streamed expected data") + t.equal(d.toString('utf8'), '["tricky"]', 'streamed expected data') res.statusCode = 200 - res.json({ put : "object" }) + res.json({ put: 'object' }) })) }) - server.expect("GET", "/body-error-string", function (req, res) { + server.expect('GET', '/body-error-string', function (req, res) { req.pipe(concat(function () { res.statusCode = 200 - res.json({ "error" : "not really an error", "reason" : "unknown" }) + res.json({ error: 'not really an error', reason: 'unknown' }) })) }) - server.expect("GET", "/body-error-object", function (req, res) { + server.expect('GET', '/body-error-object', function (req, res) { req.pipe(concat(function () { res.statusCode = 200 - res.json({ "error" : {} }) + res.json({ error: {} }) })) }) var defaults = {} client.request( - common.registry+"/request-defaults", + common.registry + '/request-defaults', defaults, function (er, data, raw, response) { - t.ifError(er, "call worked") - t.deepEquals(data, { fetched : "defaults" }, "confirmed defaults work") - t.equal(response.headers.connection, "keep-alive", "keep-alive set") + t.ifError(er, 'call worked') + t.deepEquals(data, { fetched: 'defaults' }, 'confirmed defaults work') + t.equal(response.headers.connection, 'keep-alive', 'keep-alive set') } ) - var lastModified = { lastModified : "test-last-modified" } - client.request(common.registry+"/last-modified", lastModified, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { fetched : "last-modified" }, "last-modified request sent") + var lastModified = { lastModified: 'test-last-modified' } + client.request(common.registry + '/last-modified', lastModified, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { fetched: 'last-modified' }, 'last-modified request sent') }) - var etagged = { etag : "test-etag" } - client.request(common.registry+"/etag", etagged, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { fetched : "etag" }, "etag request sent") + var etagged = { etag: 'test-etag' } + client.request(common.registry + '/etag', etagged, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { fetched: 'etag' }, 'etag request sent') }) var postEtagged = { - method : "post", - etag : "post-etag" + method: 'post', + etag: 'post-etag' } - client.request(common.registry+"/etag-post", postEtagged, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { posted : "etag" }, "POST etag request sent") + client.request(common.registry + '/etag-post', postEtagged, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { posted: 'etag' }, 'POST etag request sent') }) var putStream = { - method : "PUT", - body : new OneA(), - auth : AUTH + method: 'PUT', + body: new OneA(), + auth: AUTH } - client.request(common.registry+"/body-stream", putStream, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { put : "stream" }, "PUT request with stream sent") + client.request(common.registry + '/body-stream', putStream, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { put: 'stream' }, 'PUT request with stream sent') }) var putBuffer = { - method : "PUT", - body : new Buffer("hi"), - auth : AUTH + method: 'PUT', + body: new Buffer('hi'), + auth: AUTH } - client.request(common.registry+"/body-buffer", putBuffer, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { put : "buffer" }, "PUT request with buffer sent") + client.request(common.registry + '/body-buffer', putBuffer, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { put: 'buffer' }, 'PUT request with buffer sent') }) var putString = { - method : "PUT", - body : "erp", - auth : AUTH + method: 'PUT', + body: 'erp', + auth: AUTH } - client.request(common.registry+"/body-string", putString, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { put : "string" }, "PUT request with string sent") + client.request(common.registry + '/body-string', putString, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { put: 'string' }, 'PUT request with string sent') }) var putObject = { - method : "PUT", - body : { toJSON : function () { return [ "tricky" ] } }, - auth : AUTH + method: 'PUT', + body: { toJSON: function () { return ['tricky'] } }, + auth: AUTH } - client.request(common.registry+"/body-object", putObject, function (er, data) { - t.ifError(er, "call worked") - t.deepEquals(data, { put : "object" }, "PUT request with object sent") + client.request(common.registry + '/body-object', putObject, function (er, data) { + t.ifError(er, 'call worked') + t.deepEquals(data, { put: 'object' }, 'PUT request with object sent') }) - client.request(common.registry+"/body-error-string", defaults, function (er) { + client.request(common.registry + '/body-error-string', defaults, function (er) { t.equal( er && er.message, - "not really an error unknown: body-error-string", - "call worked" + 'not really an error unknown: body-error-string', + 'call worked' ) }) - client.request(common.registry+"/body-error-object", defaults, function (er) { - t.ifError(er, "call worked") + client.request(common.registry + '/body-error-object', defaults, function (er) { + t.ifError(er, 'call worked') }) }) diff --git a/node_modules/npm-registry-client/test/retries.js b/node_modules/npm-registry-client/test/retries.js index 0f0fa3667..3101a5d57 100644 --- a/node_modules/npm-registry-client/test/retries.js +++ b/node_modules/npm-registry-client/test/retries.js @@ -1,49 +1,49 @@ -var tap = require("tap") +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient({ - retry : { - retries : 6, - minTimeout : 10, - maxTimeout : 100 + retry: { + retries: 6, + minTimeout: 10, + maxTimeout: 100 } }) var pkg = { - _id : "some-package@1.2.3", - name : "some-package", - version : "1.2.3" + _id: 'some-package@1.2.3', + name: 'some-package', + version: '1.2.3' } -tap.test("create new user account", function (t) { +tap.test('create new user account', function (t) { // first time, return a 408 - server.expect("GET", "/some-package/1.2.3", function (req, res) { + server.expect('GET', '/some-package/1.2.3', function (req, res) { res.statusCode = 408 - res.end("Timeout") + res.end('Timeout') }) // then, slam the door in their face - server.expect("GET", "/some-package/1.2.3", function (req, res) { + server.expect('GET', '/some-package/1.2.3', function (req, res) { res.destroy() }) // then, blame someone else - server.expect("GET", "/some-package/1.2.3", function (req, res) { + server.expect('GET', '/some-package/1.2.3', function (req, res) { res.statusCode = 502 - res.end("Gateway Timeout") + res.end('Gateway Timeout') }) // 'No one's home right now, come back later' - server.expect("GET", "/some-package/1.2.3", function (req, res) { + server.expect('GET', '/some-package/1.2.3', function (req, res) { res.statusCode = 503 - res.setHeader("retry-after", "10") - res.end("Come back later") + res.setHeader('retry-after', '10') + res.end('Come back later') }) // finally, you may enter. - server.expect("GET", "/some-package/1.2.3", function (req, res) { + server.expect('GET', '/some-package/1.2.3', function (req, res) { res.statusCode = 200 res.json(pkg) }) - client.get("http://localhost:1337/some-package/1.2.3", {}, function (er, data) { + client.get('http://localhost:1337/some-package/1.2.3', {}, function (er, data) { if (er) throw er t.deepEqual(data, pkg) t.end() diff --git a/node_modules/npm-registry-client/test/star.js b/node_modules/npm-registry-client/test/star.js index 0d899ee50..ff00bab1c 100644 --- a/node_modules/npm-registry-client/test/star.js +++ b/node_modules/npm-registry-client/test/star.js @@ -1,178 +1,168 @@ -var test = require("tap").test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var test = require('tap').test +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var cache = require("./fixtures/underscore/cache.json") -var nock = require("nock") +var cache = require('./fixtures/underscore/cache.json') +var nock = require('nock') function nop () {} -var URI = "https://npm.registry:8043/rewrite" -var STARRED = true -var USERNAME = "username" -var PASSWORD = "%1234@asdf%" -var EMAIL = "i@izs.me" -var AUTH = { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var URI = 'https://npm.registry:8043/rewrite' +var STARRED = true +var USERNAME = 'username' +var PASSWORD = '%1234@asdf%' +var EMAIL = 'i@izs.me' +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } -var PARAMS = { - starred : STARRED, - auth : AUTH +var PARAMS = { + starred: STARRED, + auth: AUTH } -test("star call contract", function (t) { +test('star call contract', function (t) { t.throws(function () { client.star(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.star([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.star(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.star(URI, "", nop) - }, "params must be object") + client.star(URI, '', nop) + }, 'params must be object') t.throws(function () { client.star(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.star(URI, PARAMS, "callback") - }, "callback must be function") + client.star(URI, PARAMS, 'callback') + }, 'callback must be function') t.throws( function () { - var params = { - starred : STARRED - } + var params = { starred: STARRED } client.star(URI, params, nop) }, - { name : "AssertionError", message : "must pass auth to star" }, - "params must include auth" + { name: 'AssertionError', message: 'must pass auth to star' }, + 'params must include auth' ) t.end() }) -test("star a package", function (t) { - server.expect("GET", "/underscore?write=true", function (req, res) { - t.equal(req.method, "GET") +test('star a package', function (t) { + server.expect('GET', '/underscore?write=true', function (req, res) { + t.equal(req.method, 'GET') res.json(cache) }) - server.expect("PUT", "/underscore", function (req, res) { - t.equal(req.method, "PUT") + server.expect('PUT', '/underscore', function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var updated = JSON.parse(b) var already = [ - "vesln", "mvolkmann", "lancehunt", "mikl", "linus", "vasc", "bat", - "dmalam", "mbrevoort", "danielr", "rsimoes", "thlorenz" + 'vesln', 'mvolkmann', 'lancehunt', 'mikl', 'linus', 'vasc', 'bat', + 'dmalam', 'mbrevoort', 'danielr', 'rsimoes', 'thlorenz' ] for (var i = 0; i < already.length; i++) { var current = already[i] t.ok( updated.users[current], - current + " still likes this package" + current + ' still likes this package' ) } - t.ok(updated.users[USERNAME], "user is in the starred list") + t.ok(updated.users[USERNAME], 'user is in the starred list') res.statusCode = 201 - res.json({ starred : true }) + res.json({ starred: true }) }) }) - var params = { - starred : STARRED, - auth : AUTH - } + var params = { starred: STARRED, auth: AUTH } - client.star("http://localhost:1337/underscore", params, function (er, data) { - t.ifError(er, "no errors") - t.ok(data.starred, "was starred") + client.star('http://localhost:1337/underscore', params, function (er, data) { + t.ifError(er, 'no errors') + t.ok(data.starred, 'was starred') t.end() }) }) -test("if password auth, only sets authorization on put", function (t) { - var starGet = nock("http://localhost:1010") - .get("/underscore?write=true") +test('if password auth, only sets authorization on put', function (t) { + var starGet = nock('http://localhost:1010') + .get('/underscore?write=true') .reply(200, {}) - var starPut = nock("http://localhost:1010", { - reqheaders : { - authorization : "Basic " + new Buffer(AUTH.username+":"+ - AUTH.password).toString("base64") + var starPut = nock('http://localhost:1010', { + reqheaders: { + authorization: 'Basic ' + new Buffer(AUTH.username + ':' + + AUTH.password).toString('base64') } }) - .put("/underscore") + .put('/underscore') .reply(200) - var params = { - starred : STARRED, - auth : AUTH - } + var params = { starred: STARRED, auth: AUTH } - client.star("http://localhost:1010/underscore", params, function (er) { - t.ifError(er, "starred without issues") + client.star('http://localhost:1010/underscore', params, function (er) { + t.ifError(er, 'starred without issues') starGet.done() starPut.done() t.end() }) }) -test("if token auth, sets bearer on get and put", function (t) { - var starGet = nock("http://localhost:1010", { - reqheaders : { - authorization : "Bearer foo" +test('if token auth, sets bearer on get and put', function (t) { + var starGet = nock('http://localhost:1010', { + reqheaders: { + authorization: 'Bearer foo' } }) - .get("/underscore?write=true") + .get('/underscore?write=true') .reply(200, {}) - var getUser = nock("http://localhost:1010", { - reqheaders : { - authorization : "Bearer foo" + var getUser = nock('http://localhost:1010', { + reqheaders: { + authorization: 'Bearer foo' } }) - .get("/-/whoami") - .reply(200, { - username : "bcoe" - }) + .get('/-/whoami') + .reply(200, { username: 'bcoe' }) - var starPut = nock("http://localhost:1010", { - reqheaders : { - authorization : "Bearer foo" + var starPut = nock('http://localhost:1010', { + reqheaders: { + authorization: 'Bearer foo' } }) - .put("/underscore") + .put('/underscore') .reply(200) var params = { - starred : STARRED, - auth : { - token : "foo" + starred: STARRED, + auth: { + token: 'foo' } } - client.star("http://localhost:1010/underscore", params, function (er) { - t.ifError(er, "starred without error") + client.star('http://localhost:1010/underscore', params, function (er) { + t.ifError(er, 'starred without error') starGet.done() starPut.done() getUser.done() diff --git a/node_modules/npm-registry-client/test/stars.js b/node_modules/npm-registry-client/test/stars.js index cd1c28686..d990e05c5 100644 --- a/node_modules/npm-registry-client/test/stars.js +++ b/node_modules/npm-registry-client/test/stars.js @@ -1,62 +1,62 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() function nop () {} -var URI = "https://npm.registry:8043/rewrite" -var USERNAME = "sample" -var PASSWORD = "%1234@asdf%" -var EMAIL = "i@izs.me" -var AUTH = { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var URI = 'https://npm.registry:8043/rewrite' +var USERNAME = 'sample' +var PASSWORD = '%1234@asdf%' +var EMAIL = 'i@izs.me' +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } -var PARAMS = { - username : USERNAME, - auth : AUTH +var PARAMS = { + username: USERNAME, + auth: AUTH } var USERS = [ - "benjamincoe", - "seldo", - "ceejbot" + 'benjamincoe', + 'seldo', + 'ceejbot' ] -test("stars call contract", function (t) { +test('stars call contract', function (t) { t.throws(function () { client.stars(undefined, PARAMS, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.stars([], PARAMS, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.stars(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.stars(URI, "", nop) - }, "params must be object") + client.stars(URI, '', nop) + }, 'params must be object') t.throws(function () { client.stars(URI, PARAMS, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.stars(URI, PARAMS, "callback") - }, "callback must be function") + client.stars(URI, PARAMS, 'callback') + }, 'callback must be function') - t.test("no username anywhere", function (t) { + t.test('no username anywhere', function (t) { var params = {} client.stars(URI, params, function (err) { t.equal( err && err.message, - "must pass either username or auth to stars", - "username must not be empty") + 'must pass either username or auth to stars', + 'username must not be empty') t.end() }) }) @@ -64,16 +64,16 @@ test("stars call contract", function (t) { t.end() }) -test("get the stars for a package", function (t) { - server.expect("GET", "/-/_view/starredByUser?key=%22sample%22", function (req, res) { - t.equal(req.method, "GET") +test('get the stars for a package', function (t) { + server.expect('GET', '/-/_view/starredByUser?key=%22sample%22', function (req, res) { + t.equal(req.method, 'GET') res.json(USERS) }) - client.stars("http://localhost:1337/", PARAMS, function (er, info) { - t.ifError(er, "no errors") - t.deepEqual(info, USERS, "got the list of users") + client.stars('http://localhost:1337/', PARAMS, function (er, info) { + t.ifError(er, 'no errors') + t.deepEqual(info, USERS, 'got the list of users') t.end() }) diff --git a/node_modules/npm-registry-client/test/tag.js b/node_modules/npm-registry-client/test/tag.js index 4116586ee..2ab5134e4 100644 --- a/node_modules/npm-registry-client/test/tag.js +++ b/node_modules/npm-registry-client/test/tag.js @@ -1,115 +1,106 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() function nop () {} -var URI = "http://localhost:1337/underscore" -var USERNAME = "username" -var PASSWORD = "%1234@asdf%" -var EMAIL = "i@izs.me" -var VERSION = "1.3.2" -var TAG = "not-lodash" -var AUTH = { - username : USERNAME, - password : PASSWORD, - email : EMAIL +var URI = 'http://localhost:1337/underscore' +var USERNAME = 'username' +var PASSWORD = '%1234@asdf%' +var EMAIL = 'i@izs.me' +var VERSION = '1.3.2' +var TAG = 'not-lodash' +var AUTH = { + username: USERNAME, + password: PASSWORD, + email: EMAIL } var PARAMS = { - tag : TAG, - version : VERSION, - auth : AUTH + tag: TAG, + version: VERSION, + auth: AUTH } -test("tag call contract", function (t) { +test('tag call contract', function (t) { t.throws(function () { client.tag(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.tag([], AUTH, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.tag(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.tag(URI, "", nop) - }, "params must be object") + client.tag(URI, '', nop) + }, 'params must be object') t.throws(function () { client.tag(URI, AUTH, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.tag(URI, AUTH, "callback") - }, "callback must be function") + client.tag(URI, AUTH, 'callback') + }, 'callback must be function') t.throws( function () { - var params = { - tag : TAG, - auth : AUTH - } + var params = { tag: TAG, auth: AUTH } client.tag(URI, params, nop) }, - { name : "AssertionError", message : "must pass version to tag" }, - "tag must include version" + { name: 'AssertionError', message: 'must pass version to tag' }, + 'tag must include version' ) t.throws( function () { - var params = { - version : VERSION, - auth : AUTH - } + var params = { version: VERSION, auth: AUTH } client.tag(URI, params, nop) }, - { name : "AssertionError", message : "must pass tag name to tag" }, - "tag must include name" + { name: 'AssertionError', message: 'must pass tag name to tag' }, + 'tag must include name' ) t.throws( function () { - var params = { - version : VERSION, - tag : TAG - } + var params = { version: VERSION, tag: TAG } client.tag(URI, params, nop) }, - { name : "AssertionError", message : "must pass auth to tag" }, - "params must include auth" + { name: 'AssertionError', message: 'must pass auth to tag' }, + 'params must include auth' ) t.end() }) -test("tag a package", function (t) { - server.expect("PUT", "/underscore/not-lodash", function (req, res) { - t.equal(req.method, "PUT") +test('tag a package', function (t) { + server.expect('PUT', '/underscore/not-lodash', function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var updated = JSON.parse(b) - t.deepEqual(updated, "1.3.2") + t.deepEqual(updated, '1.3.2') res.statusCode = 201 - res.json({tagged:true}) + res.json({ tagged: true }) }) }) client.tag(URI, PARAMS, function (error, data) { - t.ifError(error, "no errors") - t.ok(data.tagged, "was tagged") + t.ifError(error, 'no errors') + t.ok(data.tagged, 'was tagged') t.end() }) diff --git a/node_modules/npm-registry-client/test/unpublish-scoped.js b/node_modules/npm-registry-client/test/unpublish-scoped.js index 88ee13f37..d3222de47 100644 --- a/node_modules/npm-registry-client/test/unpublish-scoped.js +++ b/node_modules/npm-registry-client/test/unpublish-scoped.js @@ -1,41 +1,41 @@ -var tap = require("tap") +var tap = require('tap') -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var cache = require("./fixtures/@npm/npm-registry-client/cache.json") +var cache = require('./fixtures/@npm/npm-registry-client/cache.json') -var REV = "/-rev/213-0a1049cf56172b7d9a1184742c6477b9" -var PACKAGE = "/@npm%2fnpm-registry-client" -var URI = common.registry + PACKAGE -var TOKEN = "of-glad-tidings" -var VERSION = "3.0.6" -var AUTH = { - token : TOKEN +var REV = '/-rev/213-0a1049cf56172b7d9a1184742c6477b9' +var PACKAGE = '/@npm%2fnpm-registry-client' +var URI = common.registry + PACKAGE +var TOKEN = 'of-glad-tidings' +var VERSION = '3.0.6' +var AUTH = { + token: TOKEN } -var PARAMS = { - version : VERSION, - auth : AUTH +var PARAMS = { + version: VERSION, + auth: AUTH } -tap.test("unpublish a package", function (t) { - server.expect("GET", "/@npm%2fnpm-registry-client?write=true", function (req, res) { - t.equal(req.method, "GET") +tap.test('unpublish a package', function (t) { + server.expect('GET', '/@npm%2fnpm-registry-client?write=true', function (req, res) { + t.equal(req.method, 'GET') res.json(cache) }) - server.expect("PUT", "/@npm%2fnpm-registry-client" + REV, function (req, res) { - t.equal(req.method, "PUT") + server.expect('PUT', '/@npm%2fnpm-registry-client' + REV, function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf-8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf-8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var updated = JSON.parse(b) t.notOk(updated.versions[VERSION]) }) @@ -43,20 +43,24 @@ tap.test("unpublish a package", function (t) { res.json(cache) }) - server.expect("GET", PACKAGE, function (req, res) { - t.equal(req.method, "GET") + server.expect('GET', PACKAGE, function (req, res) { + t.equal(req.method, 'GET') res.json(cache) }) - server.expect("DELETE", PACKAGE+"/-"+PACKAGE+"-"+VERSION+".tgz"+REV, function (req, res) { - t.equal(req.method, "DELETE") + server.expect( + 'DELETE', + PACKAGE + '/-' + PACKAGE + '-' + VERSION + '.tgz' + REV, + function (req, res) { + t.equal(req.method, 'DELETE') - res.json({unpublished:true}) - }) + res.json({ unpublished: true }) + } + ) client.unpublish(URI, PARAMS, function (er) { - t.ifError(er, "no errors") + t.ifError(er, 'no errors') t.end() }) diff --git a/node_modules/npm-registry-client/test/unpublish.js b/node_modules/npm-registry-client/test/unpublish.js index edc42699e..afb16b787 100644 --- a/node_modules/npm-registry-client/test/unpublish.js +++ b/node_modules/npm-registry-client/test/unpublish.js @@ -1,81 +1,81 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() -var cache = require("./fixtures/underscore/cache.json") +var cache = require('./fixtures/underscore/cache.json') function nop () {} -var REV = "/-rev/72-47f2986bfd8e8b55068b204588bbf484" -var URI = "http://localhost:1337/underscore" -var TOKEN = "of-glad-tidings" -var VERSION = "1.3.2" -var AUTH = { - token : TOKEN +var REV = '/-rev/72-47f2986bfd8e8b55068b204588bbf484' +var URI = 'http://localhost:1337/underscore' +var TOKEN = 'of-glad-tidings' +var VERSION = '1.3.2' +var AUTH = { + token: TOKEN } var PARAMS = { - version : VERSION, - auth : AUTH + version: VERSION, + auth: AUTH } -test("unpublish call contract", function (t) { +test('unpublish call contract', function (t) { t.throws(function () { client.unpublish(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.unpublish([], AUTH, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.unpublish(URI, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.unpublish(URI, "", nop) - }, "params must be object") + client.unpublish(URI, '', nop) + }, 'params must be object') t.throws(function () { client.unpublish(URI, AUTH, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.unpublish(URI, AUTH, "callback") - }, "callback must be function") + client.unpublish(URI, AUTH, 'callback') + }, 'callback must be function') t.throws( function () { var params = { - version : VERSION + version: VERSION } client.unpublish(URI, params, nop) }, - { name : "AssertionError", message : "must pass auth to unpublish" }, - "must pass auth to unpublish" + { name: 'AssertionError', message: 'must pass auth to unpublish' }, + 'must pass auth to unpublish' ) t.end() }) -test("unpublish a package", function (t) { - server.expect("GET", "/underscore?write=true", function (req, res) { - t.equal(req.method, "GET") +test('unpublish a package', function (t) { + server.expect('GET', '/underscore?write=true', function (req, res) { + t.equal(req.method, 'GET') res.json(cache) }) - server.expect("PUT", "/underscore" + REV, function (req, res) { - t.equal(req.method, "PUT") + server.expect('PUT', '/underscore' + REV, function (req, res) { + t.equal(req.method, 'PUT') - var b = "" - req.setEncoding("utf-8") - req.on("data", function (d) { + var b = '' + req.setEncoding('utf-8') + req.on('data', function (d) { b += d }) - req.on("end", function () { + req.on('end', function () { var updated = JSON.parse(b) t.notOk(updated.versions[VERSION]) }) @@ -83,20 +83,20 @@ test("unpublish a package", function (t) { res.json(cache) }) - server.expect("GET", "/underscore", function (req, res) { - t.equal(req.method, "GET") + server.expect('GET', '/underscore', function (req, res) { + t.equal(req.method, 'GET') res.json(cache) }) - server.expect("DELETE", "/underscore/-/underscore-1.3.2.tgz" + REV, function (req, res) { - t.equal(req.method, "DELETE") + server.expect('DELETE', '/underscore/-/underscore-1.3.2.tgz' + REV, function (req, res) { + t.equal(req.method, 'DELETE') - res.json({unpublished:true}) + res.json({ unpublished: true }) }) client.unpublish(URI, PARAMS, function (error) { - t.ifError(error, "no errors") + t.ifError(error, 'no errors') t.end() }) diff --git a/node_modules/npm-registry-client/test/whoami.js b/node_modules/npm-registry-client/test/whoami.js index 21b70e82f..764fc0c30 100644 --- a/node_modules/npm-registry-client/test/whoami.js +++ b/node_modules/npm-registry-client/test/whoami.js @@ -1,68 +1,68 @@ -var test = require("tap").test +var test = require('tap').test -var server = require("./lib/server.js") -var common = require("./lib/common.js") +var server = require('./lib/server.js') +var common = require('./lib/common.js') var client = common.freshClient() function nop () {} -var WHOIAM = "wombat" -var TOKEN = "not-bad-meaning-bad-but-bad-meaning-wombat" -var AUTH = { token : TOKEN } -var PARAMS = { auth : AUTH } +var WHOIAM = 'wombat' +var TOKEN = 'not-bad-meaning-bad-but-bad-meaning-wombat' +var AUTH = { token: TOKEN } +var PARAMS = { auth: AUTH } -test("whoami call contract", function (t) { +test('whoami call contract', function (t) { t.throws(function () { client.whoami(undefined, AUTH, nop) - }, "requires a URI") + }, 'requires a URI') t.throws(function () { client.whoami([], AUTH, nop) - }, "requires URI to be a string") + }, 'requires URI to be a string') t.throws(function () { client.whoami(common.registry, undefined, nop) - }, "requires params object") + }, 'requires params object') t.throws(function () { - client.whoami(common.registry, "", nop) - }, "params must be object") + client.whoami(common.registry, '', nop) + }, 'params must be object') t.throws(function () { client.whoami(common.registry, AUTH, undefined) - }, "requires callback") + }, 'requires callback') t.throws(function () { - client.whoami(common.registry, AUTH, "callback") - }, "callback must be function") + client.whoami(common.registry, AUTH, 'callback') + }, 'callback must be function') t.throws( function () { var params = {} client.whoami(common.registry, params, nop) }, - { name : "AssertionError", message : "must pass auth to whoami" }, - "must pass auth to whoami" + { name: 'AssertionError', message: 'must pass auth to whoami' }, + 'must pass auth to whoami' ) t.end() }) -test("whoami", function (t) { - server.expect("GET", "/-/whoami", function (req, res) { - t.equal(req.method, "GET") +test('whoami', function (t) { + server.expect('GET', '/-/whoami', function (req, res) { + t.equal(req.method, 'GET') // only available for token-based auth for now t.equal( req.headers.authorization, - "Bearer not-bad-meaning-bad-but-bad-meaning-wombat" + 'Bearer not-bad-meaning-bad-but-bad-meaning-wombat' ) - res.json({username : WHOIAM}) + res.json({ username: WHOIAM }) }) client.whoami(common.registry, PARAMS, function (error, wombat) { - t.ifError(error, "no errors") - t.equal(wombat, WHOIAM, "im a wombat") + t.ifError(error, 'no errors') + t.equal(wombat, WHOIAM, 'im a wombat') t.end() }) diff --git a/node_modules/npm-registry-client/test/zz-cleanup.js b/node_modules/npm-registry-client/test/zz-cleanup.js index f030b11ee..35253c7ac 100644 --- a/node_modules/npm-registry-client/test/zz-cleanup.js +++ b/node_modules/npm-registry-client/test/zz-cleanup.js @@ -1,10 +1,10 @@ -var tap = require("tap") -var rimraf = require("rimraf") +var tap = require('tap') +var rimraf = require('rimraf') -tap.test("teardown", function (t) { - rimraf(__dirname + "/fixtures/cache", function (er) { +tap.test('teardown', function (t) { + rimraf(__dirname + '/fixtures/cache', function (er) { if (er) throw er - t.pass("cache cleaned") + t.pass('cache cleaned') t.end() }) }) diff --git a/package.json b/package.json index 5ac08e8c7..098796842 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "npm-cache-filename": "~1.0.1", "npm-install-checks": "~1.0.5", "npm-package-arg": "~2.1.3", - "npm-registry-client": "~6.1.1", + "npm-registry-client": "~6.1.2", "npm-user-validate": "~0.1.1", "npmlog": "~0.1.1", "once": "~1.3.1", |