X7ROOT File Manager
Current Path:
/opt/alt/alt-nodejs6/root/usr/lib/node_modules/npm/lib
opt
/
alt
/
alt-nodejs6
/
root
/
usr
/
lib
/
node_modules
/
npm
/
lib
/
??
..
??
access.js
(3.23 KB)
??
adduser.js
(3.98 KB)
??
bin.js
(515 B)
??
bugs.js
(857 B)
??
build.js
(8.5 KB)
??
cache
??
cache.js
(10.17 KB)
??
completion.js
(7.06 KB)
??
config
??
config.js
(8.27 KB)
??
dedupe.js
(5.27 KB)
??
deprecate.js
(1.4 KB)
??
dist-tag.js
(3.67 KB)
??
docs.js
(1.03 KB)
??
edit.js
(985 B)
??
explore.js
(1.63 KB)
??
fetch-package-metadata.js
(11.5 KB)
??
fetch-package-metadata.md
(1.76 KB)
??
get.js
(235 B)
??
help-search.js
(5.65 KB)
??
help.js
(6.19 KB)
??
init.js
(1.27 KB)
??
install
??
install-test.js
(507 B)
??
install.js
(25.49 KB)
??
link.js
(5.55 KB)
??
logout.js
(1.1 KB)
??
ls.js
(13.94 KB)
??
npm.js
(11.23 KB)
??
outdated.js
(12.1 KB)
??
owner.js
(7.55 KB)
??
pack.js
(1.79 KB)
??
ping.js
(556 B)
??
prefix.js
(330 B)
??
prune.js
(1.5 KB)
??
publish.js
(5.02 KB)
??
rebuild.js
(2.11 KB)
??
repo.js
(1.43 KB)
??
restart.js
(64 B)
??
root.js
(316 B)
??
run-script.js
(5.16 KB)
??
search.js
(7.76 KB)
??
set.js
(276 B)
??
shrinkwrap.js
(6.54 KB)
??
star.js
(1.17 KB)
??
stars.js
(1.1 KB)
??
start.js
(62 B)
??
stop.js
(61 B)
??
substack.js
(509 B)
??
tag.js
(1.08 KB)
??
team.js
(1.41 KB)
??
test.js
(294 B)
??
unbuild.js
(3.97 KB)
??
uninstall.js
(2.31 KB)
??
unpublish.js
(3.55 KB)
??
update.js
(1.76 KB)
??
utils
??
version.js
(7.71 KB)
??
view.js
(9.12 KB)
??
visnup.js
(4.01 KB)
??
whoami.js
(1.42 KB)
??
xmas.js
(1.57 KB)
Editing: owner.js
module.exports = owner var npm = require('./npm.js') var log = require('npmlog') var mapToRegistry = require('./utils/map-to-registry.js') var readLocalPkg = require('./utils/read-local-package.js') var usage = require('./utils/usage') var output = require('./utils/output.js') owner.usage = usage( 'owner', 'npm owner add <user> [<@scope>/]<pkg>' + '\nnpm owner rm <user> [<@scope>/]<pkg>' + '\nnpm owner ls [<@scope>/]<pkg>' ) owner.completion = function (opts, cb) { var argv = opts.conf.argv.remain if (argv.length > 4) return cb() if (argv.length <= 2) { var subs = ['add', 'rm'] if (opts.partialWord === 'l') subs.push('ls') else subs.push('ls', 'list') return cb(null, subs) } npm.commands.whoami([], true, function (er, username) { if (er) return cb() var un = encodeURIComponent(username) var byUser, theUser switch (argv[2]) { case 'ls': // FIXME: there used to be registry completion here, but it stopped // making sense somewhere around 50,000 packages on the registry return cb() case 'rm': if (argv.length > 3) { theUser = encodeURIComponent(argv[3]) byUser = '-/by-user/' + theUser + '|' + un return mapToRegistry(byUser, npm.config, function (er, uri, auth) { if (er) return cb(er) console.error(uri) npm.registry.get(uri, { auth: auth }, function (er, d) { if (er) return cb(er) // return the intersection return cb(null, d[theUser].filter(function (p) { // kludge for server adminery. return un === 'isaacs' || d[un].indexOf(p) === -1 })) }) }) } // else fallthrough /*eslint no-fallthrough:0*/ case 'add': if (argv.length > 3) { theUser = encodeURIComponent(argv[3]) byUser = '-/by-user/' + theUser + '|' + un return mapToRegistry(byUser, npm.config, function (er, uri, auth) { if (er) return cb(er) console.error(uri) npm.registry.get(uri, { auth: auth }, function (er, d) { console.error(uri, er || d) // return mine that they're not already on. if (er) return cb(er) var mine = d[un] || [] var theirs = d[theUser] || [] return cb(null, mine.filter(function (p) { return theirs.indexOf(p) === -1 })) }) }) } // just list all users who aren't me. return mapToRegistry('-/users', npm.config, function (er, uri, auth) { if (er) return cb(er) npm.registry.get(uri, { auth: auth }, function (er, list) { if (er) return cb() return cb(null, Object.keys(list).filter(function (n) { return n !== un })) }) }) default: return cb() } }) } function owner (args, cb) { var action = args.shift() switch (action) { case 'ls': case 'list': return ls(args[0], cb) case 'add': return add(args[0], args[1], cb) case 'rm': case 'remove': return rm(args[0], args[1], cb) default: return unknown(action, cb) } } function ls (pkg, cb) { if (!pkg) { return readLocalPkg(function (er, pkg) { if (er) return cb(er) if (!pkg) return cb(owner.usage) ls(pkg, cb) }) } mapToRegistry(pkg, npm.config, function (er, uri, auth) { if (er) return cb(er) npm.registry.get(uri, { auth: auth }, function (er, data) { var msg = '' if (er) { log.error('owner ls', "Couldn't get owner data", pkg) return cb(er) } var owners = data.maintainers if (!owners || !owners.length) { msg = 'admin party!' } else { msg = owners.map(function (o) { return o.name + ' <' + o.email + '>' }).join('\n') } output(msg) cb(er, owners) }) }) } function add (user, pkg, cb) { if (!user) return cb(owner.usage) if (!pkg) { return readLocalPkg(function (er, pkg) { if (er) return cb(er) if (!pkg) return cb(new Error(owner.usage)) add(user, pkg, cb) }) } log.verbose('owner add', '%s to %s', user, pkg) mutate(pkg, user, function (u, owners) { if (!owners) owners = [] for (var i = 0, l = owners.length; i < l; i++) { var o = owners[i] if (o.name === u.name) { log.info( 'owner add', 'Already a package owner: ' + o.name + ' <' + o.email + '>' ) return false } } owners.push(u) return owners }, cb) } function rm (user, pkg, cb) { if (!pkg) { return readLocalPkg(function (er, pkg) { if (er) return cb(er) if (!pkg) return cb(new Error(owner.usage)) rm(user, pkg, cb) }) } log.verbose('owner rm', '%s from %s', user, pkg) mutate(pkg, user, function (u, owners) { var found = false var m = owners.filter(function (o) { var match = (o.name === user) found = found || match return !match }) if (!found) { log.info('owner rm', 'Not a package owner: ' + user) return false } if (!m.length) { return new Error( 'Cannot remove all owners of a package. Add someone else first.' ) } return m }, cb) } function mutate (pkg, user, mutation, cb) { if (user) { var byUser = '-/user/org.couchdb.user:' + user mapToRegistry(byUser, npm.config, function (er, uri, auth) { if (er) return cb(er) npm.registry.get(uri, { auth: auth }, mutate_) }) } else { mutate_(null, null) } function mutate_ (er, u) { if (!er && user && (!u || u.error)) { er = new Error( "Couldn't get user data for " + user + ': ' + JSON.stringify(u) ) } if (er) { log.error('owner mutate', 'Error getting user data for %s', user) return cb(er) } if (u) u = { name: u.name, email: u.email } mapToRegistry(pkg, npm.config, function (er, uri, auth) { if (er) return cb(er) npm.registry.get(uri, { auth: auth }, function (er, data) { if (er) { log.error('owner mutate', 'Error getting package data for %s', pkg) return cb(er) } // save the number of maintainers before mutation so that we can figure // out if maintainers were added or removed var beforeMutation = data.maintainers.length var m = mutation(u, data.maintainers) if (!m) return cb() // handled if (m instanceof Error) return cb(m) // error data = { _id: data._id, _rev: data._rev, maintainers: m } var dataPath = pkg.replace('/', '%2f') + '/-rev/' + data._rev mapToRegistry(dataPath, npm.config, function (er, uri, auth) { if (er) return cb(er) var params = { method: 'PUT', body: data, auth: auth } npm.registry.request(uri, params, function (er, data) { if (!er && data.error) { er = new Error('Failed to update package metadata: ' + JSON.stringify(data)) } if (er) { log.error('owner mutate', 'Failed to update package metadata') } else if (m.length > beforeMutation) { output('+ %s (%s)', user, pkg) } else if (m.length < beforeMutation) { output('- %s (%s)', user, pkg) } cb(er, data) }) }) }) }) } } function unknown (action, cb) { cb('Usage: \n' + owner.usage) }
Upload File
Create Folder