1 module.exports = deprecate
3 var assert = require('assert')
4 var semver = require('semver')
6 function deprecate (uri, params, cb) {
7 assert(typeof uri === 'string', 'must pass registry URI to deprecate')
8 assert(params && typeof params === 'object', 'must pass params to deprecate')
9 assert(typeof cb === 'function', 'must pass callback to deprecate')
11 assert(typeof params.version === 'string', 'must pass version to deprecate')
12 assert(typeof params.message === 'string', 'must pass message to deprecate')
14 params.auth && typeof params.auth === 'object',
15 'must pass auth to deprecate'
18 var version = params.version
19 var message = params.message
20 var auth = params.auth
22 if (semver.validRange(version) === null) {
23 return cb(new Error('invalid version range: ' + version))
26 this.get(uri + '?write=true', { auth: auth }, function (er, data) {
28 // filter all the versions that match
29 Object.keys(data.versions).filter(function (v) {
30 return semver.satisfies(v, version)
31 }).forEach(function (v) {
32 data.versions[v].deprecated = message
34 // now update the doc on the registry
40 this.request(uri, options, cb)