Skip to content

Commit

Permalink
docs: print default usage when usage is missing
Browse files Browse the repository at this point in the history
Closes npm#4189
  • Loading branch information
manekinekko committed Feb 23, 2022
1 parent ccb9d31 commit 2b43fb1
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/content/commands/npm-adduser.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ description: Add a registry user account
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/adduser.js -->

```bash
npm adduser

aliases: login, add-user
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/adduser.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-bin.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Display npm bin folder
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/bin.js -->

```bash
npm bin
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/bin.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
12 changes: 12 additions & 0 deletions docs/content/commands/npm-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ description: Install a project with a clean slate
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/ci.js -->

```bash
npm ci

aliases: clean-install, ic, install-clean, isntall-clean
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/ci.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

### Description
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Tab Completion for npm
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/completion.js -->

```bash
npm completion
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/completion.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
12 changes: 12 additions & 0 deletions docs/content/commands/npm-dedupe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ description: Reduce duplication in the package tree
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/dedupe.js -->

```bash
npm dedupe

alias: ddp
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/dedupe.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

### Description
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-doctor.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Check your npm environment
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/doctor.js -->

```bash
npm doctor
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/doctor.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-find-dupes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Find duplication in the package tree
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/find-dupes.js -->

```bash
npm find-dupes
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/find-dupes.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

### Description
Expand Down
12 changes: 12 additions & 0 deletions docs/content/commands/npm-install-ci-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ description: Install a project with a clean slate and run tests
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/install-ci-test.js -->

```bash
npm install-ci-test

alias: cit
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/install-ci-test.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

### Description
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Log out of the registry
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/logout.js -->

```bash
npm logout
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/logout.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-ping.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Ping npm registry
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/ping.js -->

```bash
npm ping
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/ping.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-root.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Display npm root
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/root.js -->

```bash
npm root
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/root.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

### Description
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-shrinkwrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Lock down dependency versions for publication
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/shrinkwrap.js -->

```bash
npm shrinkwrap
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/shrinkwrap.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
10 changes: 10 additions & 0 deletions docs/content/commands/npm-whoami.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ description: Display npm username
### Synopsis

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/whoami.js -->

```bash
npm whoami
```

<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/whoami.js -->

<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->

Note: This command is unaware of workspaces.
Expand Down
6 changes: 4 additions & 2 deletions scripts/config-doc-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const describeUsage = ({ usage }) => {
synopsis.push('\n```bash')

if (commandName) {
if (usage) {
if (!usage) {
synopsis.push(`npm ${commandName}`)
} else {
synopsis.push(usage.map(usageInfo => `npm ${commandName} ${usageInfo}`).join('\n'))
}

Expand Down Expand Up @@ -98,7 +100,7 @@ try {
const hasUsageTag = doc.includes(TAGS.USAGE.START)

let newDoc = params && hasTag ? addDescriptions(doc) : doc
newDoc = usage && hasUsageTag ? addUsageDescriptions(newDoc) : newDoc
newDoc = hasUsageTag ? addUsageDescriptions(newDoc) : newDoc

if (params && !hasTag) {
console.error('WARNING: did not find config description section', configDoc)
Expand Down

0 comments on commit 2b43fb1

Please sign in to comment.