Server IP : 127.0.0.2 / Your IP : 13.59.50.189 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/npm/lib/ |
Upload File : |
module.exports = unpublish var log = require('npmlog') var npm = require('./npm.js') var readJson = require('read-package-json') var path = require('path') var mapToRegistry = require('./utils/map-to-registry.js') var npa = require('npm-package-arg') var getPublishConfig = require('./utils/get-publish-config.js') unpublish.usage = 'npm unpublish [<@scope>/]<pkg>[@<version>]' unpublish.completion = function (opts, cb) { if (opts.conf.argv.remain.length >= 3) return cb() npm.commands.whoami([], true, function (er, username) { if (er) return cb() var un = encodeURIComponent(username) if (!un) return cb() var byUser = '-/by-user/' + un mapToRegistry(byUser, npm.config, function (er, uri, auth) { if (er) return cb(er) npm.registry.get(uri, { auth: auth }, function (er, pkgs) { // do a bit of filtering at this point, so that we don't need // to fetch versions for more than one thing, but also don't // accidentally a whole project. pkgs = pkgs[un] if (!pkgs || !pkgs.length) return cb() var pp = npa(opts.partialWord).name pkgs = pkgs.filter(function (p) { return p.indexOf(pp) === 0 }) if (pkgs.length > 1) return cb(null, pkgs) mapToRegistry(pkgs[0], npm.config, function (er, uri, auth) { if (er) return cb(er) npm.registry.get(uri, { auth: auth }, function (er, d) { if (er) return cb(er) var vers = Object.keys(d.versions) if (!vers.length) return cb(null, pkgs) return cb(null, vers.map(function (v) { return pkgs[0] + '@' + v })) }) }) }) }) }) } function unpublish (args, cb) { if (args.length > 1) return cb(unpublish.usage) var thing = args.length ? npa(args[0]) : {} var project = thing.name var version = thing.rawSpec log.silly('unpublish', 'args[0]', args[0]) log.silly('unpublish', 'thing', thing) if (!version && !npm.config.get('force')) { return cb( 'Refusing to delete entire project.\n' + 'Run with --force to do this.\n' + unpublish.usage ) } if (!project || path.resolve(project) === npm.localPrefix) { // if there's a package.json in the current folder, then // read the package name and version out of that. var cwdJson = path.join(npm.localPrefix, 'package.json') return readJson(cwdJson, function (er, data) { if (er && er.code !== 'ENOENT' && er.code !== 'ENOTDIR') return cb(er) if (er) return cb('Usage:\n' + unpublish.usage) log.verbose('unpublish', data) gotProject(data.name, data.version, data.publishConfig, cb) }) } return gotProject(project, version, cb) } function gotProject (project, version, publishConfig, cb_) { if (typeof cb_ !== 'function') { cb_ = publishConfig publishConfig = null } function cb (er) { if (er) return cb_(er) console.log('- ' + project + (version ? '@' + version : '')) cb_() } var mappedConfig = getPublishConfig(publishConfig, npm.config, npm.registry) var config = mappedConfig.config var registry = mappedConfig.client // remove from the cache first npm.commands.cache(['clean', project, version], function (er) { if (er) { log.error('unpublish', 'Failed to clean cache') return cb(er) } mapToRegistry(project, config, function (er, uri, auth) { if (er) return cb(er) var params = { version: version, auth: auth } registry.unpublish(uri, params, cb) }) }) }