diff options
author | isaacs <i@izs.me> | 2013-02-16 07:49:39 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-16 07:49:39 +0400 |
commit | c2fb5e482199cfd73e9bf9dce479ef0631e954ec (patch) | |
tree | 55ce46462530b531a30d331dfc6527f6c940f18f | |
parent | b7c2b1c398fa0ab418734c9c9602c3ba5ba060b4 (diff) |
npm-registry-client@0.2.17
-rw-r--r-- | node_modules/npm-registry-client/lib/publish.js | 42 | ||||
-rw-r--r-- | node_modules/npm-registry-client/package.json | 10 |
2 files changed, 26 insertions, 26 deletions
diff --git a/node_modules/npm-registry-client/lib/publish.js b/node_modules/npm-registry-client/lib/publish.js index b44b801b3..f657d44dc 100644 --- a/node_modules/npm-registry-client/lib/publish.js +++ b/node_modules/npm-registry-client/lib/publish.js @@ -72,22 +72,23 @@ function publish (data, tarball, cb) { this.request("GET", data.name, function (er, fullData) { if (er) return cb(er) + function handle(er) { + if (er.message.indexOf("conflict Document update conflict.") === 0) { + return cb(conflictError.call(this, data._id)); + } + this.log.error("publish", "Error uploading package"); + return cb(er) + } + var exists = fullData.versions && fullData.versions[data.version] if (exists) return cb(conflictError.call(this, data._id)) - this.request("PUT", dataURI, data, function (er) { - if (er) { - if (er.message.indexOf("conflict Document update conflict.") === 0) { - return cb(conflictError.call(this, data._id)) - } - this.log.error("publish", "Error sending version data") - return cb(er) - } - - this.log.verbose("publish", "attach 2", [data.name, tarball, tbName]) - attach.call(this, data.name, tarball, tbName, function (er) { - this.log.verbose("publish", "attach 3" - ,[er, data.name]) + var rev = fullData._rev; + attach.call(this, data.name, tarball, tbName, rev, function (er) { + if (er) return handle(er) + this.log.verbose("publish", "attached", [data.name, tarball, tbName]) + this.request("PUT", dataURI, data, function (er) { + if (er) return handle(er) return cb(er) }.bind(this)) }.bind(this)) @@ -102,15 +103,10 @@ function conflictError (pkgid) { return e } -function attach (doc, file, filename, cb) { +function attach (doc, file, filename, rev, cb) { doc = encodeURIComponent(doc) - this.request("GET", doc, function (er, d) { - if (er) return cb(er) - if (!d) return cb(new Error( - "Attempting to upload to invalid doc "+doc)) - var rev = "-rev/"+d._rev - , attURI = doc + "/-/" + encodeURIComponent(filename) + "/" + rev - this.log.verbose("uploading", [attURI, file]) - this.upload(attURI, file, cb) - }.bind(this)) + var revu = "-rev/"+rev + , attURI = doc + "/-/" + encodeURIComponent(filename) + "/" + revu + this.log.verbose("uploading", [attURI, file]) + this.upload(attURI, file, cb) } diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json index 5b23a9ec4..a31b62a56 100644 --- a/node_modules/npm-registry-client/package.json +++ b/node_modules/npm-registry-client/package.json @@ -6,7 +6,7 @@ }, "name": "npm-registry-client", "description": "Client for the npm registry", - "version": "0.2.16", + "version": "0.2.17", "repository": { "url": "git://github.com/isaacs/npm-registry-client" }, @@ -35,6 +35,10 @@ "license": "BSD", "readme": "# npm-registry-client\n\nThe code that npm uses to talk to the registry.\n\nIt handles all the caching and HTTP calls.\n\n## Usage\n\n```javascript\nvar RegClient = require('npm-registry-client')\nvar client = new RegClient(config)\n\nclient.get(\"npm\", \"latest\", 1000, function (er, data, raw, res) {\n // error is an error if there was a problem.\n // data is the parsed data object\n // raw is the json string\n // res is the response from couch\n})\n```\n\n# Configuration\n\nThis program is designed to work with\n[npmconf](https://npmjs.org/package/npmconf), but you can also pass in\na plain-jane object with the appropriate configs, and it'll shim it\nfor you. Any configuration thingie that has get/set/del methods will\nalso be accepted.\n\n* `registry` **Required** {String} URL to the registry\n* `cache` **Required** {String} Path to the cache folder\n* `always-auth` {Boolean} Auth even for GET requests.\n* `auth` {String} A base64-encoded `username:password`\n* `email` {String} User's email address\n* `tag` {String} The default tag to use when publishing new packages.\n Default = `\"latest\"`\n* `ca` {String} Cerficate signing authority certificates to trust.\n* `strict-ssl` {Boolean} Whether or not to be strict with SSL\n certificates. Default = `true`\n* `user-agent` {String} User agent header to send. Default =\n `\"node/{process.version} {process.platform} {process.arch}\"`\n* `log` {Object} The logger to use. Defaults to `require(\"npmlog\")` if\n that works, otherwise logs are disabled.\n* `fetch-retries` {Number} Number of times to retry on GET failures.\n Default=2\n* `fetch-retry-factor` {Number} `factor` setting for `node-retry`. Default=10\n* `fetch-retry-mintimeout` {Number} `minTimeout` setting for `node-retry`.\n Default=10000 (10 seconds)\n* `fetch-retry-maxtimeout` {Number} `maxTimeout` setting for `node-retry`.\n Default=60000 (60 seconds)\n* `proxy` {URL} The url to proxy requests through.\n* `https-proxy` {URL} The url to proxy https requests through.\n Defaults to be the same as `proxy` if unset.\n* `_auth` {String} The base64-encoded authorization header.\n* `username` `_password` {String} Username/password to use to generate\n `_auth` if not supplied.\n* `_token` {Object} A token for use with\n [couch-login](https://npmjs.org/package/couch-login)\n\n# client.request(method, where, [what], [etag], [nofollow], cb)\n\n* `method` {String} HTTP method\n* `where` {String} Path to request on the server\n* `what` {Stream | Buffer | String | Object} The request body. Objects\n that are not Buffers or Streams are encoded as JSON.\n* `etag` {String} The cached ETag\n* `nofollow` {Boolean} Prevent following 302/301 responses\n* `cb` {Function}\n * `error` {Error | null}\n * `data` {Object} the parsed data object\n * `raw` {String} the json\n * `res` {Response Object} response from couch\n\nMake a request to the registry. All the other methods are wrappers\naround this. one.\n\n# client.adduser(username, password, email, cb)\n\n* `username` {String}\n* `password` {String}\n* `email` {String}\n* `cb` {Function}\n\nAdd a user account to the registry, or verify the credentials.\n\n# client.get(url, [timeout], [nofollow], [staleOk], cb)\n\n* `url` {String} The url path to fetch\n* `timeout` {Number} Number of seconds old that a cached copy must be\n before a new request will be made.\n* `nofollow` {Boolean} Do not follow 301/302 responses\n* `staleOk` {Boolean} If there's cached data available, then return that\n to the callback quickly, and update the cache the background.\n\nFetches data from the registry via a GET request, saving it in\nthe cache folder with the ETag.\n\n# client.publish(data, tarball, [readme], cb)\n\n* `data` {Object} Package data\n* `tarball` {String | Stream} Filename or stream of the package tarball\n* `readme` {String} Contents of the README markdown file\n* `cb` {Function}\n\nPublish a package to the registry.\n\nNote that this does not create the tarball from a folder. However, it\ncan accept a gzipped tar stream or a filename to a tarball.\n\n# client.star(package, starred, cb)\n\n* `package` {String} Name of the package to star\n* `starred` {Boolean} True to star the package, false to unstar it.\n* `cb` {Function}\n\nStar or unstar a package.\n\nNote that the user does not have to be the package owner to star or\nunstar a package, though other writes do require that the user be the\npackage owner.\n\n# client.stars(username, cb)\n\n* `username` {String} Name of user to fetch starred packages for.\n* `cb` {Function}\n\nView your own or another user's starred packages.\n\n# client.tag(project, version, tag, cb)\n\n* `project` {String} Project name\n* `version` {String} Version to tag\n* `tag` {String} Tag name to apply\n* `cb` {Function}\n\nMark a version in the `dist-tags` hash, so that `pkg@tag`\nwill fetch the specified version.\n\n# client.unpublish(name, [ver], cb)\n\n* `name` {String} package name\n* `ver` {String} version to unpublish. Leave blank to unpublish all\n versions.\n* `cb` {Function}\n\nRemove a version of a package (or all versions) from the registry. When\nthe last version us unpublished, the entire document is removed from the\ndatabase.\n\n# client.upload(where, file, [etag], [nofollow], cb)\n\n* `where` {String} URL path to upload to\n* `file` {String | Stream} Either the filename or a readable stream\n* `etag` {String} Cache ETag\n* `nofollow` {Boolean} Do not follow 301/302 responses\n* `cb` {Function}\n\nUpload an attachment. Mostly used by `client.publish()`.\n", "readmeFilename": "README.md", - "_id": "npm-registry-client@0.2.16", - "_from": "npm-registry-client@latest" + "_id": "npm-registry-client@0.2.17", + "dist": { + "shasum": "1df2bbecac6751f5d9600fb43722aef96d956773" + }, + "_from": "npm-registry-client@0.2.17", + "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-0.2.17.tgz" } |