Skip to content

Commit fba5286

Browse files
committed
CLI documentation update from CI
1 parent 706639d commit fba5286

File tree

5 files changed

+430
-2
lines changed

5 files changed

+430
-2
lines changed

cli/v8

Submodule v8 updated 72 files

content/cli/v8/commands/npm-ci.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ $ npm ci
7777
added 154 packages in 5s
7878
```
7979

80-
Configure Travis to build using `npm ci` instead of `npm install`:
80+
Configure Travis CI to build using `npm ci` instead of `npm install`:
8181

8282
```bash
8383
# .travis.yml

content/cli/v8/commands/npm-query.md

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
---
2+
title: npm-query
3+
section: 1
4+
description: Dependency selector query
5+
redirect_from:
6+
- /cli/query
7+
- /cli/query.html
8+
- /cli/commands/query
9+
- /cli-commands/query
10+
- /cli-commands/query.html
11+
- /cli-commands/npm-query
12+
github_repo: npm/cli
13+
github_branch: latest
14+
github_path: docs/content/commands/npm-query.md
15+
---
16+
17+
### Synopsis
18+
19+
<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
20+
<!-- automatically generated, do not edit manually -->
21+
<!-- see lib/commands/query.js -->
22+
23+
```bash
24+
npm query <selector>
25+
```
26+
27+
<!-- automatically generated, do not edit manually -->
28+
<!-- see lib/commands/query.js -->
29+
30+
<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->
31+
32+
### Description
33+
34+
The `npm query` command allows for usage of css selectors in order to retrieve
35+
an array of dependency objects.
36+
37+
### Piping npm query to other commands
38+
39+
```bash
40+
# find all dependencies with postinstall scripts & uninstall them
41+
npm query ":attr(scripts, [postinstall])" | jq 'map(.name)|join("\n")' -r | xargs -I {} npm uninstall {}
42+
43+
# find all git dependencies & explain who requires them
44+
npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}
45+
```
46+
47+
### Extended Use Cases & Queries
48+
49+
```stylus
50+
// all deps
51+
*
52+
53+
// all direct deps
54+
:root > *
55+
56+
// direct production deps
57+
:root > .prod
58+
59+
// direct development deps
60+
:root > .dev
61+
62+
// any peer dep of a direct deps
63+
:root > * > .peer
64+
65+
// any workspace dep
66+
.workspace
67+
68+
// all workspaces that depend on another workspace
69+
.workspace > .workspace
70+
71+
// all workspaces that have peer deps
72+
.workspace:has(.peer)
73+
74+
// any dep named "lodash"
75+
// equivalent to [name="lodash"]
76+
#lodash
77+
78+
// any deps named "lodash" & within semver range ^"1.2.3"
79+
#lodash@^1.2.3
80+
// equivalent to...
81+
[name="lodash"]:semver(^1.2.3)
82+
83+
// get the hoisted node for a given semver range
84+
#lodash@^1.2.3:not(:deduped)
85+
86+
// querying deps with a specific version
87+
#lodash@2.1.5
88+
// equivalent to...
89+
[name="lodash"][version="2.1.5"]
90+
91+
// has any deps
92+
:has(*)
93+
94+
// deps with no other deps (ie. "leaf" nodes)
95+
:empty
96+
97+
// manually querying git dependencies
98+
[repository^=github:],
99+
[repository^=git:],
100+
[repository^=https://github.com],
101+
[repository^=http://github.com],
102+
[repository^=https://github.com],
103+
[repository^=+git:...]
104+
105+
// querying for all git dependencies
106+
:type(git)
107+
108+
// get production dependencies that aren't also dev deps
109+
.prod:not(.dev)
110+
111+
// get dependencies with specific licenses
112+
[license=MIT], [license=ISC]
113+
114+
// find all packages that have @ruyadorno as a contributor
115+
:attr(contributors, [email=ruyadorno@github.com])
116+
```
117+
118+
### Example Response Output
119+
120+
- an array of dependency objects is returned which can contain multiple copies of the same package which may or may not have been linked or deduped
121+
122+
```json
123+
[
124+
{
125+
"name": "",
126+
"version": "",
127+
"description": "",
128+
"homepage": "",
129+
"bugs": {},
130+
"author": {},
131+
"license": {},
132+
"funding": {},
133+
"files": [],
134+
"main": "",
135+
"browser": "",
136+
"bin": {},
137+
"man": [],
138+
"directories": {},
139+
"repository": {},
140+
"scripts": {},
141+
"config": {},
142+
"dependencies": {},
143+
"devDependencies": {},
144+
"optionalDependencies": {},
145+
"bundledDependencies": {},
146+
"peerDependencies": {},
147+
"peerDependenciesMeta": {},
148+
"engines": {},
149+
"os": [],
150+
"cpu": [],
151+
"workspaces": {},
152+
"keywords": [],
153+
...
154+
},
155+
...
156+
```
157+
158+
### Configuration
159+
160+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
161+
<!-- automatically generated, do not edit manually -->
162+
<!-- see lib/utils/config/definitions.js -->
163+
#### `global`
164+
165+
* Default: false
166+
* Type: Boolean
167+
168+
Operates in "global" mode, so that packages are installed into the `prefix`
169+
folder instead of the current working directory. See
170+
[folders](/cli/v8/configuring-npm/folders) for more on the differences in behavior.
171+
172+
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
173+
of the current working directory.
174+
* bin files are linked to `{prefix}/bin`
175+
* man pages are linked to `{prefix}/share/man`
176+
177+
<!-- automatically generated, do not edit manually -->
178+
<!-- see lib/utils/config/definitions.js -->
179+
180+
#### `workspace`
181+
182+
* Default:
183+
* Type: String (can be set multiple times)
184+
185+
Enable running a command in the context of the configured workspaces of the
186+
current project while filtering by running only the workspaces defined by
187+
this configuration option.
188+
189+
Valid values for the `workspace` config are either:
190+
191+
* Workspace names
192+
* Path to a workspace directory
193+
* Path to a parent workspace directory (will result in selecting all
194+
workspaces within that folder)
195+
196+
When set for the `npm init` command, this may be set to the folder of a
197+
workspace which does not yet exist, to create the folder and set it up as a
198+
brand new workspace within the project.
199+
200+
This value is not exported to the environment for child processes.
201+
202+
<!-- automatically generated, do not edit manually -->
203+
<!-- see lib/utils/config/definitions.js -->
204+
205+
#### `workspaces`
206+
207+
* Default: null
208+
* Type: null or Boolean
209+
210+
Set to true to run the command in the context of **all** configured
211+
workspaces.
212+
213+
Explicitly setting this to false will cause commands like `install` to
214+
ignore workspaces altogether. When not set explicitly:
215+
216+
- Commands that operate on the `node_modules` tree (install, update, etc.)
217+
will link workspaces into the `node_modules` folder. - Commands that do
218+
other things (test, exec, publish, etc.) will operate on the root project,
219+
_unless_ one or more workspaces are specified in the `workspace` config.
220+
221+
This value is not exported to the environment for child processes.
222+
223+
<!-- automatically generated, do not edit manually -->
224+
<!-- see lib/utils/config/definitions.js -->
225+
226+
#### `include-workspace-root`
227+
228+
* Default: false
229+
* Type: Boolean
230+
231+
Include the workspace root when workspaces are enabled for a command.
232+
233+
When false, specifying individual workspaces via the `workspace` config, or
234+
all workspaces via the `workspaces` flag, will cause npm to operate only on
235+
the specified workspaces, and not on the root project.
236+
237+
This value is not exported to the environment for child processes.
238+
239+
<!-- automatically generated, do not edit manually -->
240+
<!-- see lib/utils/config/definitions.js -->
241+
242+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
243+
## See Also
244+
245+
* [dependency selector](/cli/v8/using-npm/dependency-selector)
246+

0 commit comments

Comments
 (0)