diff options
-rw-r--r-- | lib/adduser.js | 7 | ||||
-rw-r--r-- | lib/bugs.js | 8 | ||||
-rw-r--r-- | lib/config.js | 20 | ||||
-rw-r--r-- | lib/dedupe.js | 6 | ||||
-rw-r--r-- | lib/dist-tag.js | 12 | ||||
-rw-r--r-- | lib/docs.js | 9 | ||||
-rw-r--r-- | lib/install-test.js | 9 | ||||
-rw-r--r-- | lib/install.js | 28 | ||||
-rw-r--r-- | lib/link.js | 9 | ||||
-rw-r--r-- | lib/ls.js | 7 | ||||
-rw-r--r-- | lib/owner.js | 13 | ||||
-rw-r--r-- | lib/rebuild.js | 6 | ||||
-rw-r--r-- | lib/run-script.js | 7 | ||||
-rw-r--r-- | lib/search.js | 7 | ||||
-rw-r--r-- | lib/star.js | 8 | ||||
-rw-r--r-- | lib/uninstall.js | 9 | ||||
-rw-r--r-- | lib/update.js | 8 | ||||
-rw-r--r-- | lib/utils/lifecycle.js | 3 | ||||
-rw-r--r-- | lib/view.js | 9 |
19 files changed, 123 insertions, 62 deletions
diff --git a/lib/adduser.js b/lib/adduser.js index c2b9bf1e7..3a7425d47 100644 --- a/lib/adduser.js +++ b/lib/adduser.js @@ -4,14 +4,17 @@ var log = require('npmlog') var npm = require('./npm.js') var read = require('read') var userValidate = require('npm-user-validate') +var usage = require('./utils/usage') var crypto try { crypto = require('crypto') } catch (ex) {} -adduser.usage = 'npm adduser [--registry=url] [--scope=@orgname] [--always-auth]' + - '\n\naliases: login' +adduser.usage = usage( + 'adduser', + 'npm adduser [--registry=url] [--scope=@orgname] [--always-auth]' +) function adduser (args, cb) { if (!crypto) { diff --git a/lib/bugs.js b/lib/bugs.js index d42e68faa..003ce7f8c 100644 --- a/lib/bugs.js +++ b/lib/bugs.js @@ -1,11 +1,15 @@ module.exports = bugs -bugs.usage = 'npm bugs [<pkgname>]' - var npm = require('./npm.js') var log = require('npmlog') var opener = require('opener') var fetchPackageMetadata = require('./fetch-package-metadata.js') +var usage = require('./utils/usage') + +bugs.usage = usage( + 'bugs', + 'npm bugs [<pkgname>]' +) bugs.completion = function (opts, cb) { // FIXME: there used to be registry completion here, but it stopped making diff --git a/lib/config.js b/lib/config.js index 65bd9fece..80958ec5f 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,14 +1,5 @@ - module.exports = config -config.usage = 'npm config set <key> <value>' + - '\nnpm config get [<key>]' + - '\nnpm config delete <key>' + - '\nnpm config list' + - '\nnpm config edit' + - '\nnpm set <key> <value>' + - '\nnpm get [<key>]' - var log = require('npmlog') var npm = require('./npm.js') var npmconf = require('./config/core.js') @@ -19,7 +10,18 @@ var ini = require('ini') var editor = require('editor') var os = require('os') var umask = require('./utils/umask') +var usage = require('./utils/usage') +config.usage = usage( + 'config', + 'npm config set <key> <value>' + + '\nnpm config get [<key>]' + + '\nnpm config delete <key>' + + '\nnpm config list' + + '\nnpm config edit' + + '\nnpm set <key> <value>' + + '\nnpm get [<key>]' +) config.completion = function (opts, cb) { var argv = opts.conf.argv.remain if (argv[1] !== 'config') argv.unshift('config') diff --git a/lib/dedupe.js b/lib/dedupe.js index 3159d4139..b99a9a1fd 100644 --- a/lib/dedupe.js +++ b/lib/dedupe.js @@ -19,11 +19,15 @@ var sortActions = require('./install/diff-trees.js').sortActions var moduleName = require('./utils/module-name.js') var packageId = require('./utils/package-id.js') var childPath = require('./utils/child-path.js') +var usage = require('./utils/usage') module.exports = dedupe module.exports.Deduper = Deduper -dedupe.usage = 'npm dedupe' +dedupe.usage = usage( + 'dedupe', + 'npm dedupe' +) function dedupe (args, cb) { validate('AF', arguments) diff --git a/lib/dist-tag.js b/lib/dist-tag.js index d0bae9ab4..0e9d914d3 100644 --- a/lib/dist-tag.js +++ b/lib/dist-tag.js @@ -7,10 +7,14 @@ var semver = require('semver') var npm = require('./npm.js') var mapToRegistry = require('./utils/map-to-registry.js') var readLocalPkg = require('./utils/read-local-package.js') - -distTag.usage = 'npm dist-tag add <pkg>@<version> [<tag>]' + - '\nnpm dist-tag rm <pkg> <tag>' + - '\nnpm dist-tag ls [<pkg>]' +var usage = require('./utils/usage') + +distTag.usage = usage( + 'dist-tag', + 'npm dist-tag add <pkg>@<version> [<tag>]' + + '\nnpm dist-tag rm <pkg> <tag>' + + '\nnpm dist-tag ls [<pkg>]' +) distTag.completion = function (opts, cb) { var argv = opts.conf.argv.remain diff --git a/lib/docs.js b/lib/docs.js index ea4bd5610..19dcce163 100644 --- a/lib/docs.js +++ b/lib/docs.js @@ -1,13 +1,16 @@ module.exports = docs -docs.usage = 'npm docs <pkgname>' + - '\nnpm docs .' - var npm = require('./npm.js') var opener = require('opener') var log = require('npmlog') var fetchPackageMetadata = require('./fetch-package-metadata.js') +var usage = require('./utils/usage') +docs.usage = usage( + 'docs', + 'npm docs <pkgname>' + + '\nnpm docs .' +) docs.completion = function (opts, cb) { // FIXME: there used to be registry completion here, but it stopped making // sense somewhere around 50,000 packages on the registry diff --git a/lib/install-test.js b/lib/install-test.js index feadb25d6..f66dfd401 100644 --- a/lib/install-test.js +++ b/lib/install-test.js @@ -6,10 +6,13 @@ module.exports = installTest var install = require('./install.js') var test = require('./test.js') +var usage = require('./utils/usage') -installTest.usage = '\nnpm install-test [args]' + - '\nSame args as `npm install`' + - '\n\nalias: npm it' +installTest.usage = usage( + 'install-test', + '\nnpm install-test [args]' + + '\nSame args as `npm install`' +) installTest.completion = install.completion diff --git a/lib/install.js b/lib/install.js index 02c02902e..53153e146 100644 --- a/lib/install.js +++ b/lib/install.js @@ -15,18 +15,22 @@ module.exports = install module.exports.Installer = Installer -install.usage = '\nnpm install (with no args, in package dir)' + - '\nnpm install [<@scope>/]<pkg>' + - '\nnpm install [<@scope>/]<pkg>@<tag>' + - '\nnpm install [<@scope>/]<pkg>@<version>' + - '\nnpm install [<@scope>/]<pkg>@<version range>' + - '\nnpm install <folder>' + - '\nnpm install <tarball file>' + - '\nnpm install <tarball url>' + - '\nnpm install <git:// url>' + - '\nnpm install <github username>/<github project>' + - '\n\nalias: npm i' + - '\ncommon options: [--save|--save-dev|--save-optional] [--save-exact]' +var usage = require('./utils/usage') + +install.usage = usage( + 'install', + '\nnpm install (with no args, in package dir)' + + '\nnpm install [<@scope>/]<pkg>' + + '\nnpm install [<@scope>/]<pkg>@<tag>' + + '\nnpm install [<@scope>/]<pkg>@<version>' + + '\nnpm install [<@scope>/]<pkg>@<version range>' + + '\nnpm install <folder>' + + '\nnpm install <tarball file>' + + '\nnpm install <tarball url>' + + '\nnpm install <git:// url>' + + '\nnpm install <github username>/<github project>', + '[--save|--save-dev|--save-optional] [--save-exact]' +) install.completion = function (opts, cb) { validate('OF', arguments) diff --git a/lib/link.js b/lib/link.js index 7ee518419..3624a16c9 100644 --- a/lib/link.js +++ b/lib/link.js @@ -10,12 +10,15 @@ var chain = require('slide').chain var path = require('path') var build = require('./build.js') var npa = require('npm-package-arg') +var usage = require('./utils/usage') module.exports = link -link.usage = 'npm link (in package dir)' + - '\nnpm link [<@scope>/]<pkg>[@<version>]' + - '\n\nalias: npm ln' +link.usage = usage( + 'link', + 'npm link (in package dir)' + + '\nnpm link [<@scope>/]<pkg>[@<version>]' +) link.completion = function (opts, cb) { var dir = npm.globalDir @@ -19,9 +19,12 @@ var npm = require('./npm.js') var mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js') var recalculateMetadata = require('./install/deps.js').recalculateMetadata var packageId = require('./utils/package-id.js') +var usage = require('./utils/usage') -ls.usage = 'npm ls [[<@scope>/]<pkg> ...]' + - '\n\naliases: list, la, ll' +ls.usage = usage( + 'ls', + 'npm ls [[<@scope>/]<pkg> ...]' +) ls.completion = require('./utils/completion/installed-deep.js') diff --git a/lib/owner.js b/lib/owner.js index f32f405dd..2cc3eef3b 100644 --- a/lib/owner.js +++ b/lib/owner.js @@ -1,14 +1,17 @@ module.exports = owner -owner.usage = 'npm owner add <user> [<@scope>/]<pkg>' + - '\nnpm owner rm <user> [<@scope>/]<pkg>' + - '\nnpm owner ls [<@scope>/]<pkg>' - 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') + +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() diff --git a/lib/rebuild.js b/lib/rebuild.js index 0e36c6361..29492c27f 100644 --- a/lib/rebuild.js +++ b/lib/rebuild.js @@ -6,8 +6,12 @@ var semver = require('semver') var log = require('npmlog') var npm = require('./npm.js') var npa = require('npm-package-arg') +var usage = require('./utils/usage') -rebuild.usage = 'npm rebuild [[<@scope>/<name>]...]' +rebuild.usage = usage( + 'rebuild', + 'npm rebuild [[<@scope>/<name>]...]' +) rebuild.completion = require('./utils/completion/installed-deep.js') diff --git a/lib/run-script.js b/lib/run-script.js index ef5e65600..f9c6872aa 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -6,9 +6,12 @@ var path = require('path') var readJson = require('read-package-json') var log = require('npmlog') var chain = require('slide').chain +var usage = require('./utils/usage') -runScript.usage = 'npm run-script <command> [-- <args>...]' + - '\n\nalias: npm run' +runScript.usage = usage( + 'run-script', + 'npm run-script <command> [-- <args>...]' +) runScript.completion = function (opts, cb) { // see if there's already a package specified. diff --git a/lib/search.js b/lib/search.js index bf1f6499a..d71102ac3 100644 --- a/lib/search.js +++ b/lib/search.js @@ -4,9 +4,12 @@ module.exports = exports = search var npm = require('./npm.js') var columnify = require('columnify') var updateIndex = require('./cache/update-index.js') +var usage = require('./utils/usage') -search.usage = 'npm search [--long] [search terms ...]' + - '\n\naliases: s, se' +search.usage = usage( + 'search', + 'npm search [--long] [search terms ...]' +) search.completion = function (opts, cb) { var compl = {} diff --git a/lib/star.js b/lib/star.js index 29c4037d0..ce141688b 100644 --- a/lib/star.js +++ b/lib/star.js @@ -4,9 +4,13 @@ var npm = require('./npm.js') var log = require('npmlog') var asyncMap = require('slide').asyncMap var mapToRegistry = require('./utils/map-to-registry.js') +var usage = require('./utils/usage') -star.usage = 'npm star [<pkg>...]\n' + - 'npm unstar [<pkg>...]' +star.usage = usage( + 'star', + 'npm star [<pkg>...]\n' + + 'npm unstar [<pkg>...]' +) star.completion = function (opts, cb) { // FIXME: there used to be registry completion here, but it stopped making diff --git a/lib/uninstall.js b/lib/uninstall.js index 03a0a5630..9a05e6697 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -4,9 +4,6 @@ module.exports = uninstall module.exports.Uninstaller = Uninstaller -uninstall.usage = 'npm uninstall [<@scope>/]<pkg>[@<version>]... [--save|--save-dev|--save-optional]' + - '\n\naliases: remove, rm, r, un, unlink' - var util = require('util') var path = require('path') var validate = require('aproba') @@ -18,6 +15,12 @@ var getSaveType = require('./install/save.js').getSaveType var removeDeps = require('./install/deps.js').removeDeps var loadExtraneous = require('./install/deps.js').loadExtraneous var log = require('npmlog') +var usage = require('./utils/usage') + +uninstall.usage = usage( + 'uninstall', + 'npm uninstall [<@scope>/]<pkg>[@<version>]... [--save|--save-dev|--save-optional]' +) uninstall.completion = require('./utils/completion/installed-shallow.js') diff --git a/lib/update.js b/lib/update.js index f09b5acca..2c1d1e82a 100644 --- a/lib/update.js +++ b/lib/update.js @@ -1,12 +1,16 @@ module.exports = update -update.usage = 'npm update [-g] [<pkg>...]' - var url = require('url') var log = require('npmlog') var chain = require('slide').chain var npm = require('./npm.js') var Installer = require('./install.js').Installer +var usage = require('./utils/usage') + +update.usage = usage( + 'update', + 'npm update [-g] [<pkg>...]' +) update.completion = npm.commands.outdated.completion diff --git a/lib/utils/lifecycle.js b/lib/utils/lifecycle.js index b6c83d322..b5893ff6a 100644 --- a/lib/utils/lifecycle.js +++ b/lib/utils/lifecycle.js @@ -13,6 +13,7 @@ var Stream = require('stream').Stream var PATH = 'PATH' var uidNumber = require('uid-number') var umask = require('./umask') +var usage = require('./usage') // windows calls it's path 'Path' usually, but this is not guaranteed. if (process.platform === 'win32') { @@ -391,7 +392,7 @@ function cmd (stage) { function CMD (args, cb) { npm.commands['run-script']([stage].concat(args), cb) } - CMD.usage = 'npm ' + stage + ' [-- <args>]' + CMD.usage = usage(stage, 'npm ' + stage + ' [-- <args>]') var installedShallow = require('./completion/installed-shallow.js') CMD.completion = function (opts, cb) { installedShallow(opts, function (d) { diff --git a/lib/view.js b/lib/view.js index bff7565b8..79c440426 100644 --- a/lib/view.js +++ b/lib/view.js @@ -1,8 +1,5 @@ // npm view [pkg [pkg ...]] - module.exports = view -view.usage = 'npm view [<@scope>/]<pkg>[@<version>] [<field>[.subfield]...]' + - '\n\naliases: info, show, v' var npm = require('./npm.js') var readJson = require('read-package-json') @@ -12,6 +9,12 @@ var semver = require('semver') var mapToRegistry = require('./utils/map-to-registry.js') var npa = require('npm-package-arg') var path = require('path') +var usage = require('./utils/usage') + +view.usage = usage( + 'view', + 'npm view [<@scope>/]<pkg>[@<version>] [<field>[.subfield]...]' +) view.completion = function (opts, cb) { if (opts.conf.argv.remain.length <= 2) { |