]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/lib/deprecate.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-registry-client / lib / deprecate.js
1 module.exports = deprecate
2
3 var assert = require('assert')
4 var semver = require('semver')
5
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')
10
11   assert(typeof params.version === 'string', 'must pass version to deprecate')
12   assert(typeof params.message === 'string', 'must pass message to deprecate')
13   assert(
14     params.auth && typeof params.auth === 'object',
15     'must pass auth to deprecate'
16   )
17
18   var version = params.version
19   var message = params.message
20   var auth = params.auth
21
22   if (semver.validRange(version) === null) {
23     return cb(new Error('invalid version range: ' + version))
24   }
25
26   this.get(uri + '?write=true', { auth: auth }, function (er, data) {
27     if (er) return cb(er)
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
33     })
34     // now update the doc on the registry
35     var options = {
36       method: 'PUT',
37       body: data,
38       auth: auth
39     }
40     this.request(uri, options, cb)
41   }.bind(this))
42 }