Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib/node_mod.../npm/lib
File: deprecate.js
'use strict'
[0] Fix | Delete
[1] Fix | Delete
const BB = require('bluebird')
[2] Fix | Delete
[3] Fix | Delete
const npmConfig = require('./config/figgy-config.js')
[4] Fix | Delete
const fetch = require('libnpm/fetch')
[5] Fix | Delete
const figgyPudding = require('figgy-pudding')
[6] Fix | Delete
const otplease = require('./utils/otplease.js')
[7] Fix | Delete
const npa = require('libnpm/parse-arg')
[8] Fix | Delete
const semver = require('semver')
[9] Fix | Delete
const whoami = require('./whoami.js')
[10] Fix | Delete
[11] Fix | Delete
const DeprecateConfig = figgyPudding({})
[12] Fix | Delete
[13] Fix | Delete
module.exports = deprecate
[14] Fix | Delete
[15] Fix | Delete
deprecate.usage = 'npm deprecate <pkg>[@<version>] <message>'
[16] Fix | Delete
[17] Fix | Delete
deprecate.completion = function (opts, cb) {
[18] Fix | Delete
return BB.try(() => {
[19] Fix | Delete
if (opts.conf.argv.remain.length > 2) { return }
[20] Fix | Delete
return whoami([], true, () => {}).then(username => {
[21] Fix | Delete
if (username) {
[22] Fix | Delete
// first, get a list of remote packages this user owns.
[23] Fix | Delete
// once we have a user account, then don't complete anything.
[24] Fix | Delete
// get the list of packages by user
[25] Fix | Delete
return fetch(
[26] Fix | Delete
`/-/by-user/${encodeURIComponent(username)}`,
[27] Fix | Delete
DeprecateConfig()
[28] Fix | Delete
).then(list => list[username])
[29] Fix | Delete
}
[30] Fix | Delete
})
[31] Fix | Delete
}).nodeify(cb)
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
function deprecate ([pkg, msg], opts, cb) {
[35] Fix | Delete
if (typeof cb !== 'function') {
[36] Fix | Delete
cb = opts
[37] Fix | Delete
opts = null
[38] Fix | Delete
}
[39] Fix | Delete
opts = DeprecateConfig(opts || npmConfig())
[40] Fix | Delete
return BB.try(() => {
[41] Fix | Delete
if (msg == null) throw new Error(`Usage: ${deprecate.usage}`)
[42] Fix | Delete
// fetch the data and make sure it exists.
[43] Fix | Delete
const p = npa(pkg)
[44] Fix | Delete
[45] Fix | Delete
// npa makes the default spec "latest", but for deprecation
[46] Fix | Delete
// "*" is the appropriate default.
[47] Fix | Delete
const spec = p.rawSpec === '' ? '*' : p.fetchSpec
[48] Fix | Delete
[49] Fix | Delete
if (semver.validRange(spec, true) === null) {
[50] Fix | Delete
throw new Error('invalid version range: ' + spec)
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
const uri = '/' + p.escapedName
[54] Fix | Delete
return fetch.json(uri, opts.concat({
[55] Fix | Delete
spec: p,
[56] Fix | Delete
query: {write: true}
[57] Fix | Delete
})).then(packument => {
[58] Fix | Delete
// filter all the versions that match
[59] Fix | Delete
Object.keys(packument.versions)
[60] Fix | Delete
.filter(v => semver.satisfies(v, spec))
[61] Fix | Delete
.forEach(v => { packument.versions[v].deprecated = msg })
[62] Fix | Delete
return otplease(opts, opts => fetch(uri, opts.concat({
[63] Fix | Delete
spec: p,
[64] Fix | Delete
method: 'PUT',
[65] Fix | Delete
body: packument,
[66] Fix | Delete
ignoreBody: true
[67] Fix | Delete
})))
[68] Fix | Delete
})
[69] Fix | Delete
}).nodeify(cb)
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function