1 | var npm = require("./npm.js")
|
2 | , mapToRegistry = require("./utils/map-to-registry.js")
|
3 | , npa = require("npm-package-arg")
|
4 |
|
5 | module.exports = deprecate
|
6 |
|
7 | deprecate.usage = "npm deprecate <pkg>[@<version>] <message>"
|
8 |
|
9 | deprecate.completion = function (opts, cb) {
|
10 |
|
11 |
|
12 | if (opts.conf.argv.remain.length > 2) return cb()
|
13 |
|
14 | var path = "/-/by-user/"
|
15 | mapToRegistry(path, npm.config, function (er, uri) {
|
16 | if (er) return cb(er)
|
17 |
|
18 | var c = npm.config.getCredentialsByURI(uri)
|
19 | if (!(c && c.username)) return cb()
|
20 |
|
21 | npm.registry.get(uri + c.username, { timeout : 60000 }, function (er, list) {
|
22 | if (er) return cb()
|
23 | console.error(list)
|
24 | return cb(null, list[c.username])
|
25 | })
|
26 | })
|
27 | }
|
28 |
|
29 | function deprecate (args, cb) {
|
30 | var pkg = args[0]
|
31 | , msg = args[1]
|
32 | if (msg === undefined) return cb("Usage: " + deprecate.usage)
|
33 |
|
34 |
|
35 | var p = npa(pkg)
|
36 |
|
37 | mapToRegistry(p.name, npm.config, next)
|
38 |
|
39 | function next (er, uri) {
|
40 | if (er) return cb(er)
|
41 |
|
42 | npm.registry.deprecate(uri, p.spec, msg, cb)
|
43 | }
|
44 | }
|