Skip to content

Commit 2f5c28a

Browse files
isaacswraithgar
authored andcommitted
fix(docs): autogenerate config docs for commands
Add a script and Makefile rule to build the "Configuration" section for all command documentation based on the command classes' `params` list. Also correct several minor problems in the documentation, and add `params` listings for commands that were lacking them, to match the existing documentation and/or behavior within the code. PR-URL: #3243 Credit: @isaacs Close: #3243 Reviewed-by: @wraithgar
1 parent 3bd7583 commit 2f5c28a

Some content is hidden

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

112 files changed

+3313
-516
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js
7373
docs/content/using-npm/config.md: scripts/config-doc.js lib/utils/config/*.js
7474
node scripts/config-doc.js
7575

76+
docs/content/commands/npm-%.md: lib/%.js scripts/config-doc-command.js lib/utils/config/*.js
77+
node scripts/config-doc-command.js $@ $<
78+
7679
test: dev-deps
7780
node bin/npm-cli.js test
7881

docs/content/commands/npm-access.md

+24
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@ fail with an HTTP 402 status code (logically enough), unless you use
8181
8282
Management of teams and team memberships is done with the `npm team` command.
8383
84+
### Configuration
85+
86+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
87+
<!-- automatically generated, do not edit manually -->
88+
#### `registry`
89+
90+
* Default: "https://registry.npmjs.org/"
91+
* Type: URL
92+
93+
The base URL of the npm registry.
94+
95+
#### `otp`
96+
97+
* Default: null
98+
* Type: null or String
99+
100+
This is a one-time password from a two-factor authenticator. It's needed
101+
when publishing or changing package permissions with `npm access`.
102+
103+
If not set, and a registry response fails with a challenge for a one-time
104+
password, npm will prompt on the command line for one.
105+
106+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
107+
84108
### See Also
85109
86110
* [`libnpmaccess`](https://npm.im/libnpmaccess)

docs/content/commands/npm-adduser.md

+31-20
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,46 @@ your existing record.
3535

3636
### Configuration
3737

38-
#### registry
38+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
39+
<!-- automatically generated, do not edit manually -->
40+
#### `registry`
3941

40-
Default: https://registry.npmjs.org/
42+
* Default: "https://registry.npmjs.org/"
43+
* Type: URL
4144

42-
The base URL of the npm package registry. If `scope` is also specified,
43-
this registry will only be used for packages with that scope. `scope` defaults
44-
to the scope of the project directory you're currently in, if any. See [`scope`](/using-npm/scope).
45+
The base URL of the npm registry.
4546

46-
#### scope
47+
#### `scope`
4748

48-
Default: none
49+
* Default: the scope of the current project, if any, or ""
50+
* Type: String
4951

50-
If specified, the user and login credentials given will be associated
51-
with the specified scope. See [`scope`](/using-npm/scope). You can use both at the same time,
52-
e.g.
52+
Associate an operation with a scope for a scoped registry.
5353

54-
```bash
55-
npm adduser --registry=http://myregistry.example.com --scope=@myco
54+
Useful when logging in to or out of a private registry:
55+
56+
```
57+
# log in, linking the scope to the custom registry
58+
npm login --scope=@mycorp --registry=https://registry.mycorp.com
59+
60+
# log out, removing the link and the auth token
61+
npm logout --scope=@mycorp
5662
```
5763

58-
This will set a registry for the given scope and login or create a user for
59-
that registry at the same time.
64+
This will cause `@mycorp` to be mapped to the registry for future
65+
installation of packages specified according to the pattern
66+
`@mycorp/package`.
6067

61-
#### auth-type
68+
This will also cause `npm init` to create a scoped package.
69+
70+
```
71+
# accept all defaults, and create a package named "@foo/whatever",
72+
# instead of just named "whatever"
73+
npm init --scope=@foo --yes
74+
```
6275

63-
* Default: `'legacy'`
64-
* Type: `'legacy'`, `'sso'`, `'saml'`, `'oauth'`
6576

66-
What authentication strategy to use with `adduser`/`login`. Some npm registries
67-
(for example, npmE) might support alternative auth strategies besides classic
68-
username/password entry in legacy npm.
77+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
6978

7079
### See Also
7180

@@ -74,3 +83,5 @@ username/password entry in legacy npm.
7483
* [npmrc](/configuring-npm/npmrc)
7584
* [npm owner](/commands/npm-owner)
7685
* [npm whoami](/commands/npm-whoami)
86+
* [npm token](/commands/npm-token)
87+
* [npm profile](/commands/npm-profile)

docs/content/commands/npm-audit.md

+86
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,92 @@ Fail an audit only if the results include a vulnerability with a level of modera
187187
$ npm audit --audit-level=moderate
188188
```
189189

190+
### Configuration
191+
192+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
193+
<!-- automatically generated, do not edit manually -->
194+
#### `audit-level`
195+
196+
* Default: null
197+
* Type: null, "info", "low", "moderate", "high", "critical", or "none"
198+
199+
The minimum level of vulnerability for `npm audit` to exit with a non-zero
200+
exit code.
201+
202+
#### `dry-run`
203+
204+
* Default: false
205+
* Type: Boolean
206+
207+
Indicates that you don't want npm to make any changes and that it should
208+
only report what it would have done. This can be passed into any of the
209+
commands that modify your local installation, eg, `install`, `update`,
210+
`dedupe`, `uninstall`, as well as `pack` and `publish`.
211+
212+
Note: This is NOT honored by other network related commands, eg `dist-tags`,
213+
`owner`, etc.
214+
215+
#### `force`
216+
217+
* Default: false
218+
* Type: Boolean
219+
220+
Removes various protections against unfortunate side effects, common
221+
mistakes, unnecessary performance degradation, and malicious input.
222+
223+
* Allow clobbering non-npm files in global installs.
224+
* Allow the `npm version` command to work on an unclean git repository.
225+
* Allow deleting the cache folder with `npm cache clean`.
226+
* Allow installing packages that have an `engines` declaration requiring a
227+
different version of npm.
228+
* Allow installing packages that have an `engines` declaration requiring a
229+
different version of `node`, even if `--engine-strict` is enabled.
230+
* Allow `npm audit fix` to install modules outside your stated dependency
231+
range (including SemVer-major changes).
232+
* Allow unpublishing all versions of a published package.
233+
* Allow conflicting peerDependencies to be installed in the root project.
234+
* Implicitly set `--yes` during `npm init`.
235+
236+
If you don't have a clear idea of what you want to do, it is strongly
237+
recommended that you do not use this option!
238+
239+
#### `json`
240+
241+
* Default: false
242+
* Type: Boolean
243+
244+
Whether or not to output JSON data, rather than the normal output.
245+
246+
Not supported by all npm commands.
247+
248+
#### `package-lock-only`
249+
250+
* Default: false
251+
* Type: Boolean
252+
253+
If set to true, it will update only the `package-lock.json`, instead of
254+
checking `node_modules` and downloading dependencies.
255+
256+
#### `omit`
257+
258+
* Default: 'dev' if the `NODE_ENV` environment variable is set to
259+
'production', otherwise empty.
260+
* Type: "dev", "optional", or "peer" (can be set multiple times)
261+
262+
Dependency types to omit from the installation tree on disk.
263+
264+
Note that these dependencies _are_ still resolved and added to the
265+
`package-lock.json` or `npm-shrinkwrap.json` file. They are just not
266+
physically installed on disk.
267+
268+
If a package type appears in both the `--include` and `--omit` lists, then
269+
it will be included.
270+
271+
If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment
272+
variable will be set to `'production'` for all lifecycle scripts.
273+
274+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
275+
190276
### See Also
191277

192278
* [npm install](/commands/npm-install)

docs/content/commands/npm-bin.md

+20
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ Note: This command is unaware of workspaces.
1616

1717
Print the folder where npm will install executables.
1818

19+
### Configuration
20+
21+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
22+
<!-- automatically generated, do not edit manually -->
23+
#### `global`
24+
25+
* Default: false
26+
* Type: Boolean
27+
28+
Operates in "global" mode, so that packages are installed into the `prefix`
29+
folder instead of the current working directory. See
30+
[folders](/configuring-npm/folders) for more on the differences in behavior.
31+
32+
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
33+
of the current working directory.
34+
* bin files are linked to `{prefix}/bin`
35+
* man pages are linked to `{prefix}/share/man`
36+
37+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
38+
1939
### See Also
2040

2141
* [npm prefix](/commands/npm-prefix)

docs/content/commands/npm-bugs.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ will search for a `package.json` in the current folder and use the `name` proper
2121
2222
### Configuration
2323
24-
#### browser
24+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
25+
<!-- automatically generated, do not edit manually -->
26+
#### `browser`
2527
2628
* Default: OS X: `"open"`, Windows: `"start"`, Others: `"xdg-open"`
27-
* Type: String or Boolean
29+
* Type: null, Boolean, or String
2830
29-
The browser that is called by the `npm bugs` command to open websites.
31+
The browser that is called by npm commands to open websites.
3032
3133
Set to `false` to suppress browser behavior and instead print urls to
3234
terminal.
3335
3436
Set to `true` to use default system URL opener.
3537
36-
#### registry
38+
#### `registry`
3739
38-
* Default: https://registry.npmjs.org/
39-
* Type: url
40+
* Default: "https://registry.npmjs.org/"
41+
* Type: URL
4042
41-
The base URL of the npm package registry.
43+
The base URL of the npm registry.
44+
45+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
4246
4347
### See Also
4448

docs/content/commands/npm-cache.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,17 @@ verify`.
7575

7676
### Configuration
7777

78-
#### cache
78+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
79+
<!-- automatically generated, do not edit manually -->
80+
#### `cache`
7981

80-
Default: `~/.npm` on Posix, or `%AppData%/npm-cache` on Windows.
82+
* Default: Windows: `%LocalAppData%\npm-cache`, Posix: `~/.npm`
83+
* Type: Path
8184

82-
The root cache folder.
85+
The location of npm's cache directory. See [`npm
86+
cache`](/commands/npm-cache)
87+
88+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
8389

8490
### See Also
8591

docs/content/commands/npm-ci.md

+26
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ cache:
6565
- "$HOME/.npm"
6666
```
6767

68+
### Configuration
69+
70+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
71+
<!-- automatically generated, do not edit manually -->
72+
#### `ignore-scripts`
73+
74+
* Default: false
75+
* Type: Boolean
76+
77+
If true, npm does not run scripts specified in package.json files.
78+
79+
Note that commands explicitly intended to run a particular script, such as
80+
`npm start`, `npm stop`, `npm restart`, `npm test`, and `npm run-script`
81+
will still run their intended script if `ignore-scripts` is set, but they
82+
will *not* run any pre- or post-scripts.
83+
84+
#### `script-shell`
85+
86+
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
87+
* Type: null or String
88+
89+
The shell to use for scripts run with the `npm exec`, `npm run` and `npm
90+
init <pkg>` commands.
91+
92+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
93+
6894
### See Also
6995

7096
* [npm install](/commands/npm-install)

docs/content/commands/npm-config.md

+44
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,50 @@ npm config edit
9393
Opens the config file in an editor. Use the `--global` flag to edit the
9494
global config.
9595
96+
### Configuration
97+
98+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
99+
<!-- automatically generated, do not edit manually -->
100+
#### `json`
101+
102+
* Default: false
103+
* Type: Boolean
104+
105+
Whether or not to output JSON data, rather than the normal output.
106+
107+
Not supported by all npm commands.
108+
109+
#### `global`
110+
111+
* Default: false
112+
* Type: Boolean
113+
114+
Operates in "global" mode, so that packages are installed into the `prefix`
115+
folder instead of the current working directory. See
116+
[folders](/configuring-npm/folders) for more on the differences in behavior.
117+
118+
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
119+
of the current working directory.
120+
* bin files are linked to `{prefix}/bin`
121+
* man pages are linked to `{prefix}/share/man`
122+
123+
#### `editor`
124+
125+
* Default: The EDITOR or VISUAL environment variables, or 'notepad.exe' on
126+
Windows, or 'vim' on Unix systems
127+
* Type: String
128+
129+
The command to run for `npm edit` and `npm config edit`.
130+
131+
#### `long`
132+
133+
* Default: false
134+
* Type: Boolean
135+
136+
Show extended information in `ls`, `search`, and `help-search`.
137+
138+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
139+
96140
### See Also
97141
98142
* [npm folders](/configuring-npm/folders)

0 commit comments

Comments
 (0)