Skip to content

Commit 41facf6

Browse files
wraithgarruyadorno
authored andcommitted
feat(help): refactor npm help/help-search
Lots of dead code removed thanks to streamlining of logic. `npm help` `npm <command>` and `npm help-search` are all now separated concerns, handling their own use cases. `help` calls `help-search` as a last resort, but `npm <command>` no longer tries to wind its way through to `help-search` just to get the basic npm usage displayed. The `did you mean` output has been expanded. It now always suggests top level commands, scripts, and bins, and suggests them in the way they should be called. PR-URL: #2859 Credit: @wraithgar Close: #2859 Reviewed-by: @ruyadorno
1 parent a8d0751 commit 41facf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+802
-516
lines changed

docs/content/commands/npm-dedupe.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: npm-dedupe
33
section: 1
4-
description: Reduce duplication
4+
description: Reduce duplication in the package tree
55
---
66

77
### Synopsis
@@ -10,7 +10,7 @@ description: Reduce duplication
1010
npm dedupe
1111
npm ddp
1212

13-
aliases: find-dupes, ddp
13+
aliases: ddp
1414
```
1515

1616
### Description
@@ -74,6 +74,7 @@ Using `npm find-dupes` will run the command in `--dry-run` mode.
7474

7575
### See Also
7676

77+
* [npm find-dupes](/cli-commands/find-dupes)
7778
* [npm ls](/cli-commands/ls)
7879
* [npm update](/cli-commands/update)
7980
* [npm install](/cli-commands/install)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: npm-find-dupes
3+
section: 1
4+
description: Find duplication in the package tree
5+
---
6+
7+
### Synopsis
8+
9+
```bash
10+
npm find-dupes
11+
```
12+
13+
### Description
14+
15+
Runs `npm dedupe` in `--dry-run` mode, making npm only output the
16+
duplications, without actually changing the package tree.
17+
18+
### See Also
19+
20+
* [npm dedupe](/cli-commands/dedupe)
21+
* [npm ls](/cli-commands/ls)
22+
* [npm update](/cli-commands/update)
23+
* [npm install](/cli-commands/install)
24+

docs/content/commands/npm-init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: npm-init
33
section: 1
4-
description: create a package.json file
4+
description: Create a package.json file
55
---
66

77
### Synopsis

lib/access.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const subcommands = [
2020
]
2121

2222
class Access extends BaseCommand {
23+
static get description () {
24+
return 'Set access level on published packages'
25+
}
26+
2327
static get name () {
2428
return 'access'
2529
}

lib/adduser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const authTypes = {
99
}
1010

1111
class AddUser extends BaseCommand {
12+
static get description () {
13+
return 'Add a registry user account'
14+
}
15+
1216
static get name () {
1317
return 'adduser'
1418
}

lib/audit.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const auditError = require('./utils/audit-error.js')
55
const BaseCommand = require('./base-command.js')
66

77
class Audit extends BaseCommand {
8+
/* istanbul ignore next - see test/lib/load-all-commands.js */
9+
static get description () {
10+
return 'Run a security audit'
11+
}
12+
813
/* istanbul ignore next - see test/lib/load-all-commands.js */
914
static get name () {
1015
return 'audit'

lib/base-command.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ class BaseCommand {
66
this.npm = npm
77
}
88

9+
get name () {
10+
return this.constructor.name
11+
}
12+
13+
get description () {
14+
return this.constructor.description
15+
}
16+
917
get usage () {
1018
let usage = `npm ${this.constructor.name}\n\n`
1119
if (this.constructor.description)

lib/bin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ const envPath = require('./utils/path.js')
22
const BaseCommand = require('./base-command.js')
33

44
class Bin extends BaseCommand {
5+
static get description () {
6+
return 'Display npm bin folder'
7+
}
8+
59
static get name () {
610
return 'bin'
711
}

lib/bugs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js')
55
const BaseCommand = require('./base-command.js')
66

77
class Bugs extends BaseCommand {
8+
static get description () {
9+
return 'Report bugs for a package in a web browser'
10+
}
11+
812
static get name () {
913
return 'bugs'
1014
}

lib/cache.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const rimraf = promisify(require('rimraf'))
77
const BaseCommand = require('./base-command.js')
88

99
class Cache extends BaseCommand {
10+
static get description () {
11+
return 'Manipulates packages cache'
12+
}
13+
1014
/* istanbul ignore next - see test/lib/load-all-commands.js */
1115
static get name () {
1216
return 'cache'

0 commit comments

Comments
 (0)