From 58963edeee4a974611f4147c0b6dc7c1b12bfc53 Mon Sep 17 00:00:00 2001 From: Wassim Chegham Date: Fri, 18 Feb 2022 09:08:47 +0100 Subject: [PATCH 1/7] docs: auto-generate synopsis sections Fixes #4189 --- docs/content/commands/npm-init.md | 4 ++++ scripts/config-doc-command.js | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/content/commands/npm-init.md b/docs/content/commands/npm-init.md index a608061a96d8d..7a96ccc389627 100644 --- a/docs/content/commands/npm-init.md +++ b/docs/content/commands/npm-init.md @@ -6,6 +6,8 @@ description: Create a package.json file ### Synopsis + + ```bash npm init [--yes|-y|--scope] npm init <@scope> (same as `npm exec <@scope>/create`) @@ -13,6 +15,8 @@ npm init [<@scope>/] (same as `npm exec [<@scope>/]create-`) npm init [-w ] [args...] ``` + + ### Description `npm init ` can be used to set up a new or existing npm diff --git a/scripts/config-doc-command.js b/scripts/config-doc-command.js index 9db026f304281..9fa3f83d01490 100644 --- a/scripts/config-doc-command.js +++ b/scripts/config-doc-command.js @@ -6,16 +6,18 @@ const configDoc = process.argv[2] const commandFile = process.argv[3] // Note: commands without params skip this whole process. -const { params } = require(resolve(commandFile)) +const { params, usage } = require(resolve(commandFile)) -const describeAll = () => - params.map(name => definitions[name].describe()).join( +const describeAll = (content) => + content.map(name => definitions[name].describe()).join( '\n\n\n' + '\n\n' ) const addBetweenTags = (doc, startTag, endTag, body) => { const startSplit = doc.split(startTag) + console.log(startSplit) + if (startSplit.length !== 2) { throw new Error('Did not find exactly one start tag') } @@ -42,14 +44,28 @@ const addBetweenTags = (doc, startTag, endTag, body) => { const addDescriptions = doc => { const startTag = '' const endTag = '' - return addBetweenTags(doc, startTag, endTag, describeAll()) + return addBetweenTags(doc, startTag, endTag, describeAll(params)) +} + +const addUsageDescriptions = doc => { + const startTag = '' + const endTag = '' + return addBetweenTags(doc, startTag, endTag, describeAll(usage)) } // always write SOMETHING so that Make sees the file is up to date. const doc = readFileSync(configDoc, 'utf8') const hasTag = doc.includes('') -const newDoc = params && hasTag ? addDescriptions(doc) : doc +const hasUsageTag = doc.includes('') + +let newDoc = params && hasTag ? addDescriptions(doc) : doc +newDoc = usage && hasUsageTag ? addUsageDescriptions(newDoc) : newDoc + if (params && !hasTag) { console.error('WARNING: did not find config description section', configDoc) } + +if (usage && !hasUsageTag) { + console.error('WARNING: did not find usage description section', configDoc) +} writeFileSync(configDoc, newDoc) From 25fc0eeff00a2bc06bd140cd9beb1ee426f7da43 Mon Sep 17 00:00:00 2001 From: Wassim Chegham Date: Fri, 18 Feb 2022 14:00:32 +0100 Subject: [PATCH 2/7] feat: improve usage auto-generation --- scripts/config-doc-command.js | 55 ++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/scripts/config-doc-command.js b/scripts/config-doc-command.js index 9fa3f83d01490..486f71b2a4a5c 100644 --- a/scripts/config-doc-command.js +++ b/scripts/config-doc-command.js @@ -6,7 +6,12 @@ const configDoc = process.argv[2] const commandFile = process.argv[3] // Note: commands without params skip this whole process. -const { params, usage } = require(resolve(commandFile)) +const { + params, + usage, + alias, + options, +} = require(resolve(commandFile)) const describeAll = (content) => content.map(name => definitions[name].describe()).join( @@ -14,9 +19,34 @@ const describeAll = (content) => '\n\n' ) -const addBetweenTags = (doc, startTag, endTag, body) => { +const describeUsage = ({ usage, alias, options }) => { + const synopsis = [] + synopsis.push('\n```bash') + + if (usage) { + synopsis.push(usage.join('\n')) + } + + if (alias) { + synopsis.push('\nalias: ' + alias.join(', ')) + } + + if (options) { + synopsis.push('\ncommon options:') + synopsis.push(options.join('\n')) + } + + synopsis.push('```') + return synopsis.join('\n') +} + +const addBetweenTags = ( + doc, + startTag, + endTag, + body, + sourceFilepath = 'lib/utils/config/definitions.js') => { const startSplit = doc.split(startTag) - console.log(startSplit) if (startSplit.length !== 2) { throw new Error('Did not find exactly one start tag') @@ -31,10 +61,10 @@ const addBetweenTags = (doc, startTag, endTag, body) => { startSplit[0], startTag, '\n\n' + - '\n', + '\n', body, '\n\n\n' + - '', + '', '\n\n', endTag, endSplit[1], @@ -44,19 +74,28 @@ const addBetweenTags = (doc, startTag, endTag, body) => { const addDescriptions = doc => { const startTag = '' const endTag = '' + + console.log('adding config descriptions') + console.log({ params }) return addBetweenTags(doc, startTag, endTag, describeAll(params)) } const addUsageDescriptions = doc => { const startTag = '' const endTag = '' - return addBetweenTags(doc, startTag, endTag, describeAll(usage)) + + console.log('adding usage descriptions') + console.log({ usage }) + return addBetweenTags(doc, startTag, endTag, + describeUsage({ usage, alias, options }), + commandFile + ) } // always write SOMETHING so that Make sees the file is up to date. const doc = readFileSync(configDoc, 'utf8') const hasTag = doc.includes('') -const hasUsageTag = doc.includes('') +const hasUsageTag = doc.includes('') let newDoc = params && hasTag ? addDescriptions(doc) : doc newDoc = usage && hasUsageTag ? addUsageDescriptions(newDoc) : newDoc @@ -65,7 +104,7 @@ if (params && !hasTag) { console.error('WARNING: did not find config description section', configDoc) } -if (usage && !hasUsageTag) { +if ((usage || alias || options) && !hasUsageTag) { console.error('WARNING: did not find usage description section', configDoc) } writeFileSync(configDoc, newDoc) From ccb9d31975ca5500de42c7e2caaaec593e1fac56 Mon Sep 17 00:00:00 2001 From: Wassim Chegham Date: Mon, 21 Feb 2022 14:54:15 +0100 Subject: [PATCH 3/7] chore: auto-generate npm usage for each command Fixes #4189 --- docs/content/commands/npm-access.md | 12 ++- docs/content/commands/npm-adduser.md | 7 +- docs/content/commands/npm-audit.md | 14 ++- docs/content/commands/npm-bin.md | 5 +- docs/content/commands/npm-bugs.md | 13 ++- docs/content/commands/npm-cache.md | 24 ++++-- docs/content/commands/npm-ci.md | 5 +- docs/content/commands/npm-completion.md | 5 +- docs/content/commands/npm-config.md | 11 ++- docs/content/commands/npm-dedupe.md | 26 ++++-- docs/content/commands/npm-deprecate.md | 11 ++- docs/content/commands/npm-diff.md | 13 ++- docs/content/commands/npm-dist-tag.md | 11 ++- docs/content/commands/npm-docs.md | 11 ++- docs/content/commands/npm-doctor.md | 5 +- docs/content/commands/npm-edit.md | 11 ++- docs/content/commands/npm-exec.md | 21 ++--- docs/content/commands/npm-explain.md | 9 ++ docs/content/commands/npm-explore.md | 9 ++ docs/content/commands/npm-find-dupes.md | 7 +- docs/content/commands/npm-fund.md | 12 ++- docs/content/commands/npm-help-search.md | 9 ++ docs/content/commands/npm-help.md | 11 +++ docs/content/commands/npm-hook.md | 13 ++- docs/content/commands/npm-init.md | 14 ++- docs/content/commands/npm-install-ci-test.md | 7 +- docs/content/commands/npm-install-test.md | 37 +++++--- docs/content/commands/npm-install.md | 38 ++++++--- docs/content/commands/npm-link.md | 22 ++++- docs/content/commands/npm-logout.md | 5 +- docs/content/commands/npm-ls.md | 11 ++- docs/content/commands/npm-org.md | 17 +++- docs/content/commands/npm-outdated.md | 9 ++ docs/content/commands/npm-owner.md | 11 ++- docs/content/commands/npm-pack.md | 11 ++- docs/content/commands/npm-ping.md | 5 +- docs/content/commands/npm-pkg.md | 15 +++- docs/content/commands/npm-prefix.md | 9 ++ docs/content/commands/npm-profile.md | 16 +++- docs/content/commands/npm-prune.md | 11 ++- docs/content/commands/npm-publish.md | 14 ++- docs/content/commands/npm-rebuild.md | 9 ++ docs/content/commands/npm-repo.md | 9 ++ docs/content/commands/npm-restart.md | 9 ++ docs/content/commands/npm-root.md | 5 +- docs/content/commands/npm-run-script.md | 13 ++- docs/content/commands/npm-search.md | 11 ++- docs/content/commands/npm-set-script.md | 9 ++ docs/content/commands/npm-shrinkwrap.md | 5 +- docs/content/commands/npm-star.md | 9 ++ docs/content/commands/npm-stars.md | 10 +++ docs/content/commands/npm-start.md | 9 ++ docs/content/commands/npm-stop.md | 9 ++ docs/content/commands/npm-team.md | 19 +++-- docs/content/commands/npm-test.md | 11 ++- docs/content/commands/npm-token.md | 16 +++- docs/content/commands/npm-uninstall.md | 22 +++-- docs/content/commands/npm-unstar.md | 9 ++ docs/content/commands/npm-update.md | 31 ++++++- docs/content/commands/npm-version.md | 15 +++- docs/content/commands/npm-view.md | 13 ++- docs/content/commands/npm-whoami.md | 5 +- docs/content/commands/npm.md | 5 +- docs/content/commands/npx.md | 19 +---- scripts/config-doc-command.js | 89 ++++++++++---------- 65 files changed, 659 insertions(+), 229 deletions(-) diff --git a/docs/content/commands/npm-access.md b/docs/content/commands/npm-access.md index 1f661c911f47d..162e94f1fec02 100644 --- a/docs/content/commands/npm-access.md +++ b/docs/content/commands/npm-access.md @@ -6,21 +6,27 @@ description: Set access level on published packages ### Synopsis + + + + ```bash npm access public [] npm access restricted [] - npm access grant [] npm access revoke [] - npm access 2fa-required [] npm access 2fa-not-required [] - npm access ls-packages [||] npm access ls-collaborators [ []] npm access edit [] ``` + + + + + ### Description Used to set access controls on private packages. diff --git a/docs/content/commands/npm-adduser.md b/docs/content/commands/npm-adduser.md index 21a31ca940e52..0e3df32ef1ea5 100644 --- a/docs/content/commands/npm-adduser.md +++ b/docs/content/commands/npm-adduser.md @@ -6,11 +6,8 @@ description: Add a registry user account ### Synopsis -```bash -npm adduser [--registry=url] [--scope=@orgname] [--auth-type=legacy] - -aliases: login, add-user -``` + + Note: This command is unaware of workspaces. diff --git a/docs/content/commands/npm-audit.md b/docs/content/commands/npm-audit.md index 58c614d793db2..323d38f64c14f 100644 --- a/docs/content/commands/npm-audit.md +++ b/docs/content/commands/npm-audit.md @@ -6,13 +6,19 @@ description: Run a security audit ### Synopsis -```bash -npm audit [--json] [--production] [--audit-level=(low|moderate|high|critical)] -npm audit fix [--force|--package-lock-only|--dry-run|--production|--only=(dev|prod)] + + + -common options: [--production] [--only=(dev|prod)] +```bash +npm audit [fix] ``` + + + + + ### Description The audit command submits a description of the dependencies configured in diff --git a/docs/content/commands/npm-bin.md b/docs/content/commands/npm-bin.md index 2d7c1d5b8149e..b41e0a412c4db 100644 --- a/docs/content/commands/npm-bin.md +++ b/docs/content/commands/npm-bin.md @@ -6,9 +6,8 @@ description: Display npm bin folder ### Synopsis -```bash -npm bin [-g|--global] -``` + + Note: This command is unaware of workspaces. diff --git a/docs/content/commands/npm-bugs.md b/docs/content/commands/npm-bugs.md index f92241a14b95c..aeddeb848e81b 100644 --- a/docs/content/commands/npm-bugs.md +++ b/docs/content/commands/npm-bugs.md @@ -6,12 +6,21 @@ description: Report bugs for a package in a web browser ### Synopsis + + + + ```bash -npm bugs [ [ ...]] +npm bugs [] -aliases: issues +alias: issues ``` + + + + + ### Description This command tries to guess at the likely location of a package's bug diff --git a/docs/content/commands/npm-cache.md b/docs/content/commands/npm-cache.md index 6497a3988c938..091e26e8a7182 100644 --- a/docs/content/commands/npm-cache.md +++ b/docs/content/commands/npm-cache.md @@ -6,18 +6,26 @@ description: Manipulates packages cache ### Synopsis -```bash -npm cache add ... -npm cache add ... -npm cache add ... -npm cache add @... - -npm cache clean -aliases: npm cache clear, npm cache rm + + + +```bash +npm cache add +npm cache add +npm cache add +npm cache add +npm cache add @ +npm cache clean [] +npm cache ls [@] npm cache verify ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-ci.md b/docs/content/commands/npm-ci.md index 1ce50c66d5faf..3645b6247a068 100644 --- a/docs/content/commands/npm-ci.md +++ b/docs/content/commands/npm-ci.md @@ -6,9 +6,8 @@ description: Install a project with a clean slate ### Synopsis -```bash -npm ci -``` + + ### Description diff --git a/docs/content/commands/npm-completion.md b/docs/content/commands/npm-completion.md index 9dbd960913f27..d4841a6a63b89 100644 --- a/docs/content/commands/npm-completion.md +++ b/docs/content/commands/npm-completion.md @@ -6,9 +6,8 @@ description: Tab Completion for npm ### Synopsis -```bash -source <(npm completion) -``` + + Note: This command is unaware of workspaces. diff --git a/docs/content/commands/npm-config.md b/docs/content/commands/npm-config.md index 2d77f045cbc47..a66a198ce42d1 100644 --- a/docs/content/commands/npm-config.md +++ b/docs/content/commands/npm-config.md @@ -6,18 +6,25 @@ description: Manage the npm configuration files ### Synopsis + + + + ```bash npm config set = [= ...] npm config get [ [ ...]] npm config delete [ ...] npm config list [--json] npm config edit -npm set = [= ...] -npm get [ [ ...]] alias: c ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-dedupe.md b/docs/content/commands/npm-dedupe.md index 53d2e64272a67..5cd00f7f4d2e4 100644 --- a/docs/content/commands/npm-dedupe.md +++ b/docs/content/commands/npm-dedupe.md @@ -6,12 +6,8 @@ description: Reduce duplication in the package tree ### Synopsis -```bash -npm dedupe -npm ddp - -aliases: ddp -``` + + ### Description @@ -145,6 +141,24 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + + + + +#### `save` + +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` +* Type: Boolean + +Save installed packages to a `package.json` file as dependencies. + +When used with the `npm rm` command, removes the dependency from +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. + diff --git a/docs/content/commands/npm-deprecate.md b/docs/content/commands/npm-deprecate.md index 438a54ec6e4f3..4345120d3744b 100644 --- a/docs/content/commands/npm-deprecate.md +++ b/docs/content/commands/npm-deprecate.md @@ -6,10 +6,19 @@ description: Deprecate a version of a package ### Synopsis + + + + ```bash -npm deprecate [@] +npm deprecate [@] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-diff.md b/docs/content/commands/npm-diff.md index 8d05df779f3ca..c4c9eafdb3524 100644 --- a/docs/content/commands/npm-diff.md +++ b/docs/content/commands/npm-diff.md @@ -6,14 +6,19 @@ description: The registry diff command ### Synopsis + + + + ```bash npm diff [...] -npm diff --diff= [...] -npm diff --diff= [--diff=] [...] -npm diff --diff= [--diff=] [...] -npm diff [--diff-ignore-all-space] [--diff-name-only] [...] ``` + + + + + ### Description Similar to its `git diff` counterpart, this command will print diff patches diff --git a/docs/content/commands/npm-dist-tag.md b/docs/content/commands/npm-dist-tag.md index a4e0243aac87b..a0f306cd4970d 100644 --- a/docs/content/commands/npm-dist-tag.md +++ b/docs/content/commands/npm-dist-tag.md @@ -6,14 +6,23 @@ description: Modify package distribution tags ### Synopsis + + + + ```bash npm dist-tag add @ [] npm dist-tag rm npm dist-tag ls [] -aliases: dist-tags +alias: dist-tags ``` + + + + + ### Description Add, remove, and enumerate distribution tags on a package: diff --git a/docs/content/commands/npm-docs.md b/docs/content/commands/npm-docs.md index 970d17aa829c6..8d5a278286a88 100644 --- a/docs/content/commands/npm-docs.md +++ b/docs/content/commands/npm-docs.md @@ -6,12 +6,21 @@ description: Open documentation for a package in a web browser ### Synopsis + + + + ```bash npm docs [ [ ...]] -aliases: home +alias: home ``` + + + + + ### Description This command tries to guess at the likely location of a package's diff --git a/docs/content/commands/npm-doctor.md b/docs/content/commands/npm-doctor.md index 0cce60c7b7b15..1b915ff997726 100644 --- a/docs/content/commands/npm-doctor.md +++ b/docs/content/commands/npm-doctor.md @@ -6,9 +6,8 @@ description: Check your npm environment ### Synopsis -```bash -npm doctor -``` + + Note: This command is unaware of workspaces. diff --git a/docs/content/commands/npm-edit.md b/docs/content/commands/npm-edit.md index 5ae7f2481ae45..39fc49592c571 100644 --- a/docs/content/commands/npm-edit.md +++ b/docs/content/commands/npm-edit.md @@ -6,10 +6,19 @@ description: Edit an installed package ### Synopsis + + + + ```bash -npm edit +npm edit [/...] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-exec.md b/docs/content/commands/npm-exec.md index d154f5780b9c9..3645e336b9da9 100644 --- a/docs/content/commands/npm-exec.md +++ b/docs/content/commands/npm-exec.md @@ -6,26 +6,23 @@ description: Run a command from a local or remote npm package ### Synopsis + + + + ```bash npm exec -- [@] [args...] npm exec --package=[@] -- [args...] npm exec -c ' [args...]' npm exec --package=foo -c ' [args...]' -npm exec [--ws] [-w [@] [args...] -npx -p [@] [args...] -npx -c ' [args...]' -npx -p [@] -c ' [args...]' -Run without --call or positional args to open interactive subshell +alias: x +``` -alias: npm x, npx + + -common options: ---package= (may be specified multiple times) --p is a shorthand for --package only when using npx executable --c --call= (may not be mixed with positional arguments) -``` + ### Description diff --git a/docs/content/commands/npm-explain.md b/docs/content/commands/npm-explain.md index 5f05cac0f906b..765221056585d 100644 --- a/docs/content/commands/npm-explain.md +++ b/docs/content/commands/npm-explain.md @@ -6,12 +6,21 @@ description: Explain installed packages ### Synopsis + + + + ```bash npm explain alias: why ``` + + + + + ### Description This command will print the chain of dependencies causing a given package diff --git a/docs/content/commands/npm-explore.md b/docs/content/commands/npm-explore.md index 3979da9573db0..90753c7e09199 100644 --- a/docs/content/commands/npm-explore.md +++ b/docs/content/commands/npm-explore.md @@ -6,10 +6,19 @@ description: Browse an installed package ### Synopsis + + + + ```bash npm explore [ -- ] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-find-dupes.md b/docs/content/commands/npm-find-dupes.md index f7dc84f9c5306..6f792302723bd 100644 --- a/docs/content/commands/npm-find-dupes.md +++ b/docs/content/commands/npm-find-dupes.md @@ -6,9 +6,8 @@ description: Find duplication in the package tree ### Synopsis -```bash -npm find-dupes -``` + + ### Description @@ -82,6 +81,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-fund.md b/docs/content/commands/npm-fund.md index 606b0a188c554..5b96e91ab8ccb 100644 --- a/docs/content/commands/npm-fund.md +++ b/docs/content/commands/npm-fund.md @@ -6,11 +6,19 @@ description: Retrieve funding information ### Synopsis + + + + ```bash -npm fund [] -npm fund [-w ] +npm fund [[<@scope>/]] ``` + + + + + ### Description This command retrieves information on how to fund the dependencies of a diff --git a/docs/content/commands/npm-help-search.md b/docs/content/commands/npm-help-search.md index 78553a14ecb01..152f9f6bec16f 100644 --- a/docs/content/commands/npm-help-search.md +++ b/docs/content/commands/npm-help-search.md @@ -6,10 +6,19 @@ description: Search npm help documentation ### Synopsis + + + + ```bash npm help-search ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-help.md b/docs/content/commands/npm-help.md index a8002eef17156..83c595db696b9 100644 --- a/docs/content/commands/npm-help.md +++ b/docs/content/commands/npm-help.md @@ -6,10 +6,21 @@ description: Get help on npm ### Synopsis + + + + ```bash npm help [] + +alias: hlep ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-hook.md b/docs/content/commands/npm-hook.md index c91bce3075e7b..4a9805d02f9d4 100644 --- a/docs/content/commands/npm-hook.md +++ b/docs/content/commands/npm-hook.md @@ -6,13 +6,22 @@ description: Manage registry hooks ### Synopsis + + + + ```bash +npm hook add [--type=] npm hook ls [pkg] -npm hook add -npm hook update [secret] npm hook rm +npm hook update ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-init.md b/docs/content/commands/npm-init.md index 7a96ccc389627..a2439dee267f4 100644 --- a/docs/content/commands/npm-init.md +++ b/docs/content/commands/npm-init.md @@ -7,14 +7,20 @@ description: Create a package.json file ### Synopsis + + ```bash -npm init [--yes|-y|--scope] -npm init <@scope> (same as `npm exec <@scope>/create`) -npm init [<@scope>/] (same as `npm exec [<@scope>/]create-`) -npm init [-w ] [args...] +npm init [--force|-f|--yes|-y|--scope] +npm init <@scope> (same as `npx <@scope>/create`) +npm init [<@scope>/] (same as `npx [<@scope>/]create-`) + +aliases: create, innit ``` + + + ### Description diff --git a/docs/content/commands/npm-install-ci-test.md b/docs/content/commands/npm-install-ci-test.md index 5c37ed8f56128..af15b1d134faa 100644 --- a/docs/content/commands/npm-install-ci-test.md +++ b/docs/content/commands/npm-install-ci-test.md @@ -6,11 +6,8 @@ description: Install a project with a clean slate and run tests ### Synopsis -```bash -npm install-ci-test - -alias: npm cit -``` + + ### Description diff --git a/docs/content/commands/npm-install-test.md b/docs/content/commands/npm-install-test.md index c464e5bd0b8c6..ed39c6705a484 100644 --- a/docs/content/commands/npm-install-test.md +++ b/docs/content/commands/npm-install-test.md @@ -6,20 +6,30 @@ description: Install package(s) and run tests ### Synopsis + + + + ```bash -npm install-test (with no args, in package dir) -npm install-test [<@scope>/] -npm install-test [<@scope>/]@ -npm install-test [<@scope>/]@ -npm install-test [<@scope>/]@ +npm install-test [<@scope>/] +npm install-test [<@scope>/]@ +npm install-test [<@scope>/]@ +npm install-test [<@scope>/]@ +npm install-test @npm: +npm install-test npm install-test npm install-test -npm install-test +npm install-test +npm install-test / -alias: npm it -common options: [--save|--save-dev|--save-optional] [--save-exact] [--dry-run] +alias: it ``` + + + + + ### Description This command runs an `npm install` followed immediately by an `npm test`. It @@ -32,13 +42,16 @@ takes exactly the same arguments as `npm install`. #### `save` -* Default: true +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` * Type: Boolean -Save installed packages to a package.json file as dependencies. +Save installed packages to a `package.json` file as dependencies. When used with the `npm rm` command, removes the dependency from -package.json. +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. @@ -133,6 +146,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-install.md b/docs/content/commands/npm-install.md index b4f8da8373d05..66193e733133b 100644 --- a/docs/content/commands/npm-install.md +++ b/docs/content/commands/npm-install.md @@ -6,23 +6,30 @@ description: Install a package ### Synopsis + + + + ```bash -npm install (with no args, in package dir) -npm install [<@scope>/] -npm install [<@scope>/]@ -npm install [<@scope>/]@ -npm install [<@scope>/]@ +npm install [<@scope>/] +npm install [<@scope>/]@ +npm install [<@scope>/]@ +npm install [<@scope>/]@ npm install @npm: -npm install :/ -npm install +npm install npm install npm install -npm install +npm install +npm install / -aliases: npm i, npm add -common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional|--save-peer] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run] +aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, add ``` + + + + + ### Description This command installs a package and any packages that it depends on. If the @@ -425,13 +432,16 @@ These are some of the most common options related to installation. #### `save` -* Default: true +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` * Type: Boolean -Save installed packages to a package.json file as dependencies. +Save installed packages to a `package.json` file as dependencies. When used with the `npm rm` command, removes the dependency from -package.json. +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. @@ -526,6 +536,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-link.md b/docs/content/commands/npm-link.md index d4ef41ae96462..892b55496c9b6 100644 --- a/docs/content/commands/npm-link.md +++ b/docs/content/commands/npm-link.md @@ -6,13 +6,22 @@ description: Symlink a package folder ### Synopsis + + + + ```bash npm link (in package dir) npm link [<@scope>/][@] -alias: npm ln +alias: ln ``` + + + + + ### Description This is handy for installing your own stuff, so that you can work on it and @@ -116,13 +125,16 @@ workspace(s). #### `save` -* Default: true +* Default: `true` unless when using `npm update` or `npm dedupe` where it + defaults to `false` * Type: Boolean -Save installed packages to a package.json file as dependencies. +Save installed packages to a `package.json` file as dependencies. When used with the `npm rm` command, removes the dependency from -package.json. +`package.json`. + +Will also prevent writing to `package-lock.json` if set to `false`. @@ -217,6 +229,8 @@ When package package-locks are disabled, automatic pruning of extraneous modules will also be disabled. To remove extraneous modules with package-locks disabled use `npm prune`. +This configuration does not affect `npm ci`. + diff --git a/docs/content/commands/npm-logout.md b/docs/content/commands/npm-logout.md index cb7c8496fb479..40c0e6744388d 100644 --- a/docs/content/commands/npm-logout.md +++ b/docs/content/commands/npm-logout.md @@ -6,9 +6,8 @@ description: Log out of the registry ### Synopsis -```bash -npm logout [--registry=] [--scope=<@scope>] -``` + + Note: This command is unaware of workspaces. diff --git a/docs/content/commands/npm-ls.md b/docs/content/commands/npm-ls.md index 3b33f0a3605e0..0f06e131f414b 100644 --- a/docs/content/commands/npm-ls.md +++ b/docs/content/commands/npm-ls.md @@ -6,12 +6,21 @@ description: List installed packages ### Synopsis + + + + ```bash npm ls [[<@scope>/] ...] -aliases: list, la, ll +alias: list ``` + + + + + ### Description This command will print to stdout all the versions of packages that are diff --git a/docs/content/commands/npm-org.md b/docs/content/commands/npm-org.md index 2f08f61152992..975581c860df6 100644 --- a/docs/content/commands/npm-org.md +++ b/docs/content/commands/npm-org.md @@ -6,12 +6,23 @@ description: Manage orgs ### Synopsis + + + + ```bash -npm org set [developer | admin | owner] -npm org rm -npm org ls [] +npm org set orgname username [developer | admin | owner] +npm org rm orgname username +npm org ls orgname [] + +alias: ogr ``` + + + + + Note: This command is unaware of workspaces. ### Example diff --git a/docs/content/commands/npm-outdated.md b/docs/content/commands/npm-outdated.md index 1b58a6afda64b..6fa026550e747 100644 --- a/docs/content/commands/npm-outdated.md +++ b/docs/content/commands/npm-outdated.md @@ -6,10 +6,19 @@ description: Check for outdated packages ### Synopsis + + + + ```bash npm outdated [[<@scope>/] ...] ``` + + + + + ### Description This command will check the registry to see if any (or, specific) installed diff --git a/docs/content/commands/npm-owner.md b/docs/content/commands/npm-owner.md index 74e7f84af6c80..0779984e19a9d 100644 --- a/docs/content/commands/npm-owner.md +++ b/docs/content/commands/npm-owner.md @@ -6,14 +6,23 @@ description: Manage package owners ### Synopsis + + + + ```bash npm owner add [<@scope>/] npm owner rm [<@scope>/] npm owner ls [<@scope>/] -aliases: author +alias: author ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-pack.md b/docs/content/commands/npm-pack.md index 53945986837b9..c834f643ac0bb 100644 --- a/docs/content/commands/npm-pack.md +++ b/docs/content/commands/npm-pack.md @@ -6,10 +6,19 @@ description: Create a tarball from a package ### Synopsis + + + + ```bash -npm pack [[<@scope>/]...] [--dry-run] [--json] +npm pack [[<@scope>/]...] ``` + + + + + ### Configuration diff --git a/docs/content/commands/npm-ping.md b/docs/content/commands/npm-ping.md index 6f1c4582f058f..f0469dd5c38c0 100644 --- a/docs/content/commands/npm-ping.md +++ b/docs/content/commands/npm-ping.md @@ -6,9 +6,8 @@ description: Ping npm registry ### Synopsis -```bash -npm ping [--registry ] -``` + + Note: This command is unaware of workspaces. diff --git a/docs/content/commands/npm-pkg.md b/docs/content/commands/npm-pkg.md index beee9c1c4e78a..8f6cbecf958fd 100644 --- a/docs/content/commands/npm-pkg.md +++ b/docs/content/commands/npm-pkg.md @@ -6,12 +6,21 @@ description: Manages your package.json ### Synopsis + + + + ```bash -npm pkg get [ [. ...]] -npm pkg set = [.= ...] -npm pkg delete [. ...] +npm pkg set = [= ...] +npm pkg get [ [ ...]] +npm pkg delete [ ...] ``` + + + + + ### Description A command that automates the management of `package.json` files. diff --git a/docs/content/commands/npm-prefix.md b/docs/content/commands/npm-prefix.md index 276a9e9e69910..39328bcc88a14 100644 --- a/docs/content/commands/npm-prefix.md +++ b/docs/content/commands/npm-prefix.md @@ -6,10 +6,19 @@ description: Display prefix ### Synopsis + + + + ```bash npm prefix [-g] ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-profile.md b/docs/content/commands/npm-profile.md index cecc48518dbdb..af1f9d8aa1063 100644 --- a/docs/content/commands/npm-profile.md +++ b/docs/content/commands/npm-profile.md @@ -6,14 +6,22 @@ description: Change settings on your registry profile ### Synopsis + + + + ```bash -npm profile get [--json|--parseable] [] -npm profile set [--json|--parseable] -npm profile set password -npm profile enable-2fa [auth-and-writes|auth-only] +npm profile enable-2fa [auth-only|auth-and-writes] npm profile disable-2fa +npm profile get [] +npm profile set ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-prune.md b/docs/content/commands/npm-prune.md index 658ab2610e0ed..49420e5b9d99c 100644 --- a/docs/content/commands/npm-prune.md +++ b/docs/content/commands/npm-prune.md @@ -6,10 +6,19 @@ description: Remove extraneous packages ### Synopsis + + + + ```bash -npm prune [[<@scope>/]...] [--production] [--dry-run] [--json] +npm prune [[<@scope>/]...] ``` + + + + + ### Description This command removes "extraneous" packages. If a package name is provided, diff --git a/docs/content/commands/npm-publish.md b/docs/content/commands/npm-publish.md index 6958b1066de7f..ce6e1c1012c8e 100644 --- a/docs/content/commands/npm-publish.md +++ b/docs/content/commands/npm-publish.md @@ -6,13 +6,19 @@ description: Publish a package ### Synopsis -```bash -npm publish [|] [--tag ] [--access ] [--otp otpcode] [--dry-run] + + + -Publishes '.' if no argument supplied -Sets tag 'latest' if no --tag specified +```bash +npm publish [] ``` + + + + + ### Description Publishes a package to the registry so that it can be installed by name. diff --git a/docs/content/commands/npm-rebuild.md b/docs/content/commands/npm-rebuild.md index 75e71c60e6810..ecb4a7ce34c62 100644 --- a/docs/content/commands/npm-rebuild.md +++ b/docs/content/commands/npm-rebuild.md @@ -6,12 +6,21 @@ description: Rebuild a package ### Synopsis + + + + ```bash npm rebuild [[<@scope>/][@] ...] alias: rb ``` + + + + + ### Description This command runs the `npm build` command on the matched folders. This is diff --git a/docs/content/commands/npm-repo.md b/docs/content/commands/npm-repo.md index cd47fde47127e..e14f07012a248 100644 --- a/docs/content/commands/npm-repo.md +++ b/docs/content/commands/npm-repo.md @@ -6,10 +6,19 @@ description: Open package repository page in the browser ### Synopsis + + + + ```bash npm repo [ [ ...]] ``` + + + + + ### Description This command tries to guess at the likely location of a package's diff --git a/docs/content/commands/npm-restart.md b/docs/content/commands/npm-restart.md index 80f8ab77ef018..f01cd014e7435 100644 --- a/docs/content/commands/npm-restart.md +++ b/docs/content/commands/npm-restart.md @@ -6,10 +6,19 @@ description: Restart a package ### Synopsis + + + + ```bash npm restart [-- ] ``` + + + + + ### Description This restarts a project. It is equivalent to running `npm run-script diff --git a/docs/content/commands/npm-root.md b/docs/content/commands/npm-root.md index 98d1108d33f75..8bc9e57a0c5e5 100644 --- a/docs/content/commands/npm-root.md +++ b/docs/content/commands/npm-root.md @@ -6,9 +6,8 @@ description: Display npm root ### Synopsis -```bash -npm root [-g] -``` + + ### Description diff --git a/docs/content/commands/npm-run-script.md b/docs/content/commands/npm-run-script.md index 6dd602d03e00a..79b7c9a25780e 100644 --- a/docs/content/commands/npm-run-script.md +++ b/docs/content/commands/npm-run-script.md @@ -6,14 +6,21 @@ description: Run arbitrary package scripts ### Synopsis + + + + ```bash -npm run-script [--if-present] [--silent] [-- ] -npm run-script [--workspace=] -npm run-script [--workspaces] +npm run-script [-- ] aliases: run, rum, urn ``` + + + + + ### Description This runs an arbitrary command from a package's `"scripts"` object. If no diff --git a/docs/content/commands/npm-search.md b/docs/content/commands/npm-search.md index 252822e719844..db6a12bafabf1 100644 --- a/docs/content/commands/npm-search.md +++ b/docs/content/commands/npm-search.md @@ -6,12 +6,21 @@ description: Search for packages ### Synopsis + + + + ```bash -npm search [-l|--long] [--json] [--parseable] [--no-description] [search terms ...] +npm search [search terms ...] aliases: s, se, find ``` + + + + + Note: This command is unaware of workspaces. ### Description diff --git a/docs/content/commands/npm-set-script.md b/docs/content/commands/npm-set-script.md index 869ceede045ae..2d8e87db85219 100644 --- a/docs/content/commands/npm-set-script.md +++ b/docs/content/commands/npm-set-script.md @@ -7,10 +7,19 @@ description: Set tasks in the scripts section of package.json ### Synopsis An npm command that lets you create a task in the `scripts` section of the `package.json`. + + + + ```bash npm set-script [