Skip to content

Commit fe4e19f

Browse files
committed
docs: consolidate docs and help for package spec
Many of our commands parse their args via [npm-package-arg](https://npm.im/npm-package-arg), which is a good standard way of parsing a "package" argument. However the docs surrounding these args are not very consistent. This can lead to confusion in commands such as `npm publish` where the behavior is slightly different than in the past due to this. This adds a new help command `npm help package-spec` that describes what this argument is, and can be, and also updates all the commands that interpret their args this with to refer to them as `<package-spec>`. It also adds a link to the new help page on their docs pages.
1 parent f2340f8 commit fe4e19f

Some content is hidden

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

42 files changed

+269
-230
lines changed

docs/content/commands/npm-cache.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ cache`](/commands/npm-cache)
101101

102102
### See Also
103103

104+
* [package spec](/using-npm/package-spec)
104105
* [npm folders](/configuring-npm/folders)
105106
* [npm config](/commands/npm-config)
106107
* [npmrc](/configuring-npm/npmrc)

docs/content/commands/npm-deprecate.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ In this case, a version `my-thing@1.0.0-beta.0` will also be deprecated.
4545
You must be the package owner to deprecate something. See the `owner` and
4646
`adduser` help topics.
4747

48-
To un-deprecate a package, specify an empty string (`""`) for the `message`
49-
argument. Note that you must use double quotes with no space between them to
48+
To un-deprecate a package, specify an empty string (`""`) for the `message`
49+
argument. Note that you must use double quotes with no space between them to
5050
format an empty string.
5151

5252
### Configuration
@@ -82,6 +82,7 @@ password, npm will prompt on the command line for one.
8282

8383
### See Also
8484

85+
* [package spec](/using-npm/package-spec)
8586
* [npm publish](/commands/npm-publish)
8687
* [npm registry](/using-npm/registry)
8788
* [npm owner](/commands/npm-owner)

docs/content/commands/npm-dist-tag.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ description: Modify package distribution tags
1111
<!-- see lib/commands/dist-tag.js -->
1212

1313
```bash
14-
npm dist-tag add <pkg>@<version> [<tag>]
15-
npm dist-tag rm <pkg> <tag>
16-
npm dist-tag ls [<pkg>]
14+
npm dist-tag add <package-spec (with version)> [<tag>]
15+
npm dist-tag rm <package-spec> <tag>
16+
npm dist-tag ls [<package-spec>]
1717

1818
alias: dist-tags
1919
```
@@ -27,11 +27,11 @@ alias: dist-tags
2727

2828
Add, remove, and enumerate distribution tags on a package:
2929

30-
* add: Tags the specified version of the package with the specified tag, or
31-
the `--tag` config if not specified. If you have two-factor
32-
authentication on auth-and-writes then you’ll need to include a one-time
33-
password on the command line with `--otp <one-time password>`, or at the
34-
OTP prompt.
30+
* add: Tags the specified version of the package with the specified tag,
31+
or the `--tag` config if not specified. If you have two-factor
32+
authentication on auth-and-writes then you’ll need to include a
33+
one-time password on the command line with
34+
`--otp <one-time password>`, or at the OTP prompt.
3535

3636
* rm: Clear a tag that is no longer in use from the package. If you have
3737
two-factor authentication on auth-and-writes then you’ll need to include
@@ -168,6 +168,7 @@ This value is not exported to the environment for child processes.
168168

169169
### See Also
170170

171+
* [package spec](/using-npm/package-spec)
171172
* [npm publish](/commands/npm-publish)
172173
* [npm install](/commands/npm-install)
173174
* [npm dedupe](/commands/npm-dedupe)

docs/content/commands/npm-explain.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ alias: why
2626
This command will print the chain of dependencies causing a given package
2727
to be installed in the current project.
2828

29-
Positional arguments can be either folders within `node_modules`, or
30-
`name@version-range` specifiers, which will select the dependency
31-
relationships to explain.
29+
If one or more package specs are provided, then only packages matching
30+
one of the specifiers will have their relationships explained.
3231

3332
For example, running `npm explain glob` within npm's source tree will show:
3433

@@ -110,6 +109,7 @@ This value is not exported to the environment for child processes.
110109

111110
### See Also
112111

112+
* [package spec](/using-npm/package-spec)
113113
* [npm config](/commands/npm-config)
114114
* [npmrc](/configuring-npm/npmrc)
115115
* [npm folders](/configuring-npm/folders)

docs/content/commands/npm-fund.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ npm fund [[<@scope>/]<pkg>]
2323

2424
This command retrieves information on how to fund the dependencies of a
2525
given project. If no package name is provided, it will list all
26-
dependencies that are looking for funding in a tree structure, listing the
27-
type of funding and the url to visit. If a package name is provided then it
28-
tries to open its funding url using the `--browser` config param; if there
29-
are multiple funding sources for the package, the user will be instructed
30-
to pass the `--which` option to disambiguate.
26+
dependencies that are looking for funding in a tree structure, listing
27+
the type of funding and the url to visit. If a package name is provided
28+
then it tries to open its funding url using the `--browser` config
29+
param; if there are multiple funding sources for the package, the user
30+
will be instructed to pass the `--which` option to disambiguate.
3131

3232
The list will avoid duplicated entries and will stack all packages that
33-
share the same url as a single entry. Thus, the list does not have the same
34-
shape of the output from `npm ls`.
33+
share the same url as a single entry. Thus, the list does not have the
34+
same shape of the output from `npm ls`.
3535

3636
#### Example
3737

3838
### Workspaces support
3939

40-
It's possible to filter the results to only include a single workspace and its
41-
dependencies using the `workspace` config option.
40+
It's possible to filter the results to only include a single workspace
41+
and its dependencies using the `workspace` config option.
4242

4343
#### Example:
4444

@@ -58,8 +58,8 @@ test-workspaces-fund@1.0.0
5858
`-- bar@2.0.0
5959
```
6060

61-
And here is an example of the expected result when filtering only by
62-
a specific workspace `a` in the same project:
61+
And here is an example of the expected result when filtering only by a
62+
specific workspace `a` in the same project:
6363

6464
```bash
6565
$ npm fund -w a
@@ -82,8 +82,8 @@ test-workspaces-fund@1.0.0
8282

8383
Whether or not to output JSON data, rather than the normal output.
8484

85-
* In `npm pkg set` it enables parsing set values with JSON.parse() before
86-
saving them to your `package.json`.
85+
* In `npm pkg set` it enables parsing set values with JSON.parse()
86+
before saving them to your `package.json`.
8787

8888
Not supported by all npm commands.
8989

@@ -156,6 +156,7 @@ If there are multiple funding sources, which 1-indexed source URL to open.
156156

157157
## See Also
158158

159+
* [package spec](/using-npm/package-spec)
159160
* [npm install](/commands/npm-install)
160161
* [npm docs](/commands/npm-docs)
161162
* [npm ls](/commands/npm-ls)

docs/content/commands/npm-init.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ This value is not exported to the environment for child processes.
284284

285285
### See Also
286286

287+
* [package spec](/using-npm/package-spec)
287288
* [init-package-json module](http://npm.im/init-package-json)
288289
* [package.json](/configuring-npm/package-json)
289290
* [npm version](/commands/npm-version)

docs/content/commands/npm-install.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@ description: Install a package
1111
<!-- see lib/commands/install.js -->
1212

1313
```bash
14-
npm install [<@scope>/]<pkg>
15-
npm install [<@scope>/]<pkg>@<tag>
16-
npm install [<@scope>/]<pkg>@<version>
17-
npm install [<@scope>/]<pkg>@<version range>
18-
npm install <alias>@npm:<name>
19-
npm install <folder>
20-
npm install <tarball file>
21-
npm install <tarball url>
22-
npm install <git:// url>
23-
npm install <github username>/<github project>
14+
npm install [<package-spec> ...]
2415

2516
aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
2617
```

docs/content/commands/npm-link.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ description: Symlink a package folder
1111
<!-- see lib/commands/link.js -->
1212

1313
```bash
14-
npm link (in package dir)
15-
npm link [<@scope>/]<pkg>[@<version>]
14+
npm link [<package-spec>]
1615

1716
alias: ln
1817
```
@@ -29,11 +28,11 @@ test iteratively without having to continually rebuild.
2928

3029
Package linking is a two-step process.
3130

32-
First, `npm link` in a package folder will create a symlink in the global
33-
folder `{prefix}/lib/node_modules/<package>` that links to the package
34-
where the `npm link` command was executed. It will also link any bins in
35-
the package to `{prefix}/bin/{name}`. Note that `npm link` uses the global
36-
prefix (see `npm prefix -g` for its value).
31+
First, `npm link` in a package folder with no arguments will create a
32+
symlink in the global folder `{prefix}/lib/node_modules/<package>` that
33+
links to the package where the `npm link` command was executed. It will
34+
also link any bins in the package to `{prefix}/bin/{name}`. Note that
35+
`npm link` uses the global prefix (see `npm prefix -g` for its value).
3736

3837
Next, in some other location, `npm link package-name` will create a
3938
symbolic link from globally-installed `package-name` to `node_modules/` of
@@ -399,6 +398,7 @@ symlink. This option has no effect on workspaces.
399398

400399
### See Also
401400

401+
* [package spec](/using-npm/package-spec)
402402
* [npm developers](/using-npm/developers)
403403
* [package.json](/configuring-npm/package-json)
404404
* [npm install](/commands/npm-install)

docs/content/commands/npm-ls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ symlink. This option has no effect on workspaces.
301301

302302
### See Also
303303

304+
* [package spec](/using-npm/package-spec)
304305
* [npm explain](/commands/npm-explain)
305306
* [npm config](/commands/npm-config)
306307
* [npmrc](/configuring-npm/npmrc)

docs/content/commands/npm-outdated.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ This value is not exported to the environment for child processes.
192192

193193
### See Also
194194

195+
* [package spec](/using-npm/package-spec)
195196
* [npm update](/commands/npm-update)
196197
* [npm dist-tag](/commands/npm-dist-tag)
197198
* [npm registry](/using-npm/registry)

0 commit comments

Comments
 (0)