CLI documentation update from CI
CI User committed
Apr 24, 2021 at 02:33 UTC
c50281005beb088d35c51a65d676e6309f315475
7 files changed
+139
-42
cli/v7
+1
-1
@@ -1 +1 @@
1
-Subproject commit a4e7f4e4b40d645fed97622a97c7fa72aa5da82b
1
+Subproject commit 8f8f71e4dd5ee66b3b17888faad5a7bf6c657eed
content/cli/v7/commands/npm-adduser.md
+1
-18
@@ -17,7 +17,7 @@ github_path: docs/content/commands/npm-adduser.md
17
### Synopsis
18
19
```bash
20
-npm adduser [--registry=url] [--scope=@orgname] [--always-auth] [--auth-type=legacy]
20
+npm adduser [--registry=url] [--scope=@orgname] [--auth-type=legacy]
21
22
aliases: login, add-user
23
```
@@ -68,23 +68,6 @@ npm adduser --registry=http://myregistry.example.com --scope=@myco
68
This will set a registry for the given scope and login or create a user for
69
that registry at the same time.
70
71
-#### always-auth
72
-
73
-Default: false
74
-
75
-If specified, save configuration indicating that all requests to the given
76
-registry should include authorization information. Useful for private
77
-registries. Can be used with `--registry` and / or `--scope`, e.g.
78
-
79
-```bash
80
-npm adduser --registry=http://private-registry.example.com --always-auth
81
-```
82
-
83
-This will ensure that all requests to that registry (including for tarballs)
84
-include an authorization header. This setting may be necessary for use with
85
-private registries where metadata and package tarballs are stored on hosts with
86
-different hostnames. See `always-auth` in [`config`](/cli/v7/using-npm/config) for more details on always-auth. Registry-specific configuration of `always-auth` takes precedence over any global configuration.
87
-
71
#### auth-type
72
73
* Default: `'legacy'`
content/cli/v7/commands/npm-exec.md
+4
-3
@@ -21,7 +21,7 @@ npm exec -- <pkg>[@<version>] [args...]
21
npm exec --package=<pkg>[@<version>] -- <cmd> [args...]
22
npm exec -c '<cmd> [args...]'
23
npm exec --package=foo -c '<cmd> [args...]'
24
-npm exec [-ws] [-w <workspace-name] [args...]
24
+npm exec [--ws] [-w <workspace-name] [args...]
25
26
npx <pkg>[@<specifier>] [args...]
27
npx -p <pkg>[@<specifier>] <cmd> [args...]
@@ -194,7 +194,7 @@ in this example we're using **eslint** to lint any js file found within each
194
workspace folder:
195
196
```
197
-npm exec -ws -- eslint ./*.js
197
+npm exec --ws -- eslint ./*.js
198
```
199
200
#### Filtering workspaces
@@ -285,7 +285,7 @@ children workspaces)
285
286
#### workspaces
287
288
-* Alias: `-ws`
288
+* Alias: `--ws`
289
* Type: Boolean
290
* Default: `false`
291
@@ -301,3 +301,4 @@ project.
301
* [npm restart](/cli/v7/commands/npm-restart)
302
* [npm stop](/cli/v7/commands/npm-stop)
303
* [npm config](/cli/v7/commands/npm-config)
304
+* [npm workspaces](/cli/v7/using-npm/workspaces)
content/cli/v7/commands/npm-init.md
+110
-10
@@ -18,8 +18,9 @@ github_path: docs/content/commands/npm-init.md
18
19
```bash
20
npm init [--force|-f|--yes|-y|--scope]
21
-npm init <@scope> (same as `npx <@scope>/create`)
22
-npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)
21
+npm init <@scope> (same as `npm exec <@scope>/create`)
22
+npm init [<@scope>/]<name> (same as `npm exec [<@scope>/]create-<name>`)
23
+npm init [-w <dir>] [args...]
24
```
25
26
### Description
@@ -28,19 +29,16 @@ npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)
29
package.
30
31
`initializer` in this case is an npm package named `create-<initializer>`,
31
-which will be installed by [`npx`](https://npm.im/npx), and then have its
32
+which will be installed by [`npm-exec`](/cli/v7/commands/npm-exec), and then have its
33
main bin executed -- presumably creating or updating `package.json` and
34
running any other initialization-related operations.
35
35
-The init command is transformed to a corresponding `npx` operation as
36
+The init command is transformed to a corresponding `npm exec` operation as
37
follows:
38
38
-* `npm init foo` -> `npx create-foo`
39
-* `npm init @usr/foo` -> `npx @usr/create-foo`
40
-* `npm init @usr` -> `npx @usr/create`
41
-
42
-Any additional options will be passed directly to the command, so `npm init
43
-foo -- --hello` will map to `npx create-foo --hello`.
39
+* `npm init foo` -> `npm exec create-foo`
40
+* `npm init @usr/foo` -> `npm exec @usr/create-foo`
41
+* `npm init @usr` -> `npm exec @usr/create`
42
43
If the initializer is omitted (by just calling `npm init`), init will fall
44
back to legacy init behavior. It will ask you a bunch of questions, and
@@ -50,6 +48,18 @@ strictly additive, so it will keep any fields and values that were already
48
set. You can also use `-y`/`--yes` to skip the questionnaire altogether. If
49
you pass `--scope`, it will create a scoped package.
50
51
+#### Forwarding additional options
52
+
53
+Any additional options will be passed directly to the command, so `npm init
54
+foo -- --hello` will map to `npm exec -- create-foo --hello`.
55
+
56
+To better illustrate how options are forwarded, here's a more evolved
57
+example showing options passed to both the **npm cli** and a create package,
58
+both following commands are equivalent:
59
+
60
+- `npm init foo -y --registry=<url> -- --hello -a`
61
+- `npm exec -y --registry=<url> -- create-foo --hello -a`
62
+
63
### Examples
64
65
Create a new React-based project using
@@ -81,6 +91,68 @@ Generate it without having it ask any questions:
91
$ npm init -y
92
```
93
94
+### Workspaces support
95
+
96
+It's possible to create a new workspace within your project by using the
97
+`workspace` config option. When using `npm init -w <dir>` the cli will
98
+create the folders and boilerplate expected while also adding a reference
99
+to your project `package.json` `"workspaces": []` property in order to make
100
+sure that new generated **workspace** is properly set up as such.
101
+
102
+Given a project with no workspaces, e.g:
103
+
104
+```
105
+.
106
++-- package.json
107
+```
108
+
109
+You may generate a new workspace using the legacy init:
110
+
111
+```bash
112
+$ npm init -w packages/a
113
+```
114
+
115
+That will generate a new folder and `package.json` file, while also updating
116
+your top-level `package.json` to add the reference to this new workspace:
117
+
118
+```
119
+.
120
++-- package.json
121
+`-- packages
122
+ `-- a
123
+ `-- package.json
124
+```
125
+
126
+The workspaces init also supports the `npm init <initializer> -w <dir>`
127
+syntax, following the same set of rules explained earlier in the initial
128
+**Description** section of this page. Similar to the previous example of
129
+creating a new React-based project using
130
+[`create-react-app`](https://npm.im/create-react-app), the following syntax
131
+will make sure to create the new react app as a nested **workspace** within your
132
+project and configure your `package.json` to recognize it as such:
133
+
134
+```bash
135
+npm init -w packages/my-react-app react-app .
136
+```
137
+
138
+This will make sure to generate your react app as expected, one important
139
+consideration to have in mind is that `npm exec` is going to be run in the
140
+context of the newly created folder for that workspace, and that's the reason
141
+why in this example the initializer uses the initializer name followed with a
142
+dot to represent the current directory in that context, e.g: `react-app .`:
143
+
144
+```
145
+.
146
++-- package.json
147
+`-- packages
148
+ +-- a
149
+ | `-- package.json
150
+ `-- my-react-app
151
+ +-- README
152
+ +-- package.json
153
+ `-- ...
154
+```
155
+
156
### A note on caching
157
158
The npm cli utilizes its internal package cache when using the package
@@ -103,6 +175,33 @@ requested from the server. To force full offline mode, use `offline`.
175
Forces full offline mode. Any packages not locally cached will result in
176
an error.
177
178
+#### workspace
179
+
180
+* Alias: `-w`
181
+* Type: Array
182
+* Default: `[]`
183
+
184
+Enable running `npm init` in the context of workspaces, creating any missing
185
+folders, generating files and adding/updating the `"workspaces"` property of
186
+the project `package.json`.
187
+
188
+the provided names or paths provided.
189
+
190
+Valid values for the `workspace` config are either:
191
+- Workspace names
192
+- Path to a workspace directory
193
+- Path to a parent workspace directory (will result to selecting all of the
194
+children workspaces)
195
+
196
+#### workspaces
197
+
198
+* Alias: `-ws`
199
+* Type: Boolean
200
+* Default: `false`
201
+
202
+Run `npm init` in the context of all configured workspaces for the
203
+current project.
204
+
205
### See Also
206
207
* [init-package-json module](http://npm.im/init-package-json)
@@ -110,3 +209,4 @@ an error.
209
* [npm version](/cli/v7/commands/npm-version)
210
* [npm scope](/cli/v7/using-npm/scope)
211
* [npm exec](/cli/v7/commands/npm-exec)
212
+* [npm workspaces](/cli/v7/using-npm/workspaces)
content/cli/v7/commands/npm-run-script.md
+2
-1
@@ -199,7 +199,7 @@ children workspaces)
199
200
#### workspaces
201
202
-* Alias: `-ws`
202
+* Alias: `--ws`
203
* Type: Boolean
204
* Default: `false`
205
@@ -214,3 +214,4 @@ project.
214
* [npm restart](/cli/v7/commands/npm-restart)
215
* [npm stop](/cli/v7/commands/npm-stop)
216
* [npm config](/cli/v7/commands/npm-config)
217
+* [npm workspaces](/cli/v7/using-npm/workspaces)
content/cli/v7/commands/npm-view.md
+19
@@ -104,6 +104,25 @@ this:
104
npm view connect versions
105
```
106
107
+### Configuration
108
+
109
+#### json
110
+
111
+Show information in JSON format. See [`Output`](#output) below.
112
+
113
+#### workspaces
114
+
115
+Enables workspaces context while searching the `package.json` in the
116
+current folder. Information about packages named in each workspace will
117
+be viewed.
118
+
119
+#### workspace
120
+
121
+Enables workspaces context and limits results to only those specified by
122
+this config item. Only the information about packages named in the
123
+workspaces given here will be viewed.
124
+
125
+
126
### Output
127
128
If only a single string field for a single version is output, then it
content/cli/v7/using-npm/config.md
+2
-9
@@ -173,14 +173,6 @@ upon by the current project.
173
Prevents throwing an error when `npm version` is used to set the new version
174
to the same value as the current version.
175
176
-#### `always-auth`
177
-
178
-* Default: false
179
-* Type: Boolean
180
-
181
-Force npm to always require authentication when accessing the registry, even
182
-for `GET` requests.
183
-
176
#### `audit`
177
178
* Default: true
@@ -1095,7 +1087,8 @@ installation of packages specified according to the pattern
1087
* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows
1088
* Type: null or String
1089
1098
-The shell to use for scripts run with the `npm run` command.
1090
+The shell to use for scripts run with the `npm exec`, `npm run` and `npm
1091
+init <pkg>` commands.
1092
1093
#### `searchexclude`
1094