mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
deps: upgrade npm to 8.16.0
PR-URL: https://github.com/nodejs/node/pull/44119 Reviewed-By: Ruy Adorno <ruyadorno@google.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
1 parent
c02bbdd921
commit
194587e767
191 files changed
+9596
-2127
No files matched your search
+1
-1
@@ -67,7 +67,7 @@ $ npm ci
|
||||
added 154 packages in 5s
|
||||
```
|
||||
|
||||
Configure Travis to build using `npm ci` instead of `npm install`:
|
||||
Configure Travis CI to build using `npm ci` instead of `npm install`:
|
||||
|
||||
```bash
|
||||
# .travis.yml
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ $ npm exec -- foo@latest bar --package=@npmcli/foo
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
The package to install for [`npm exec`](/commands/npm-exec)
|
||||
The package or packages to install for [`npm exec`](/commands/npm-exec)
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
---
|
||||
title: npm-query
|
||||
section: 1
|
||||
description: Dependency selector query
|
||||
---
|
||||
|
||||
### Synopsis
|
||||
|
||||
<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/commands/query.js -->
|
||||
|
||||
```bash
|
||||
npm query <selector>
|
||||
```
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/commands/query.js -->
|
||||
|
||||
<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->
|
||||
|
||||
### Description
|
||||
|
||||
The `npm query` command allows for usage of css selectors in order to retrieve
|
||||
an array of dependency objects.
|
||||
|
||||
### Piping npm query to other commands
|
||||
|
||||
```bash
|
||||
# find all dependencies with postinstall scripts & uninstall them
|
||||
npm query ":attr(scripts, [postinstall])" | jq 'map(.name)|join("\n")' -r | xargs -I {} npm uninstall {}
|
||||
|
||||
# find all git dependencies & explain who requires them
|
||||
npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}
|
||||
```
|
||||
|
||||
### Extended Use Cases & Queries
|
||||
|
||||
```stylus
|
||||
// all deps
|
||||
*
|
||||
|
||||
// all direct deps
|
||||
:root > *
|
||||
|
||||
// direct production deps
|
||||
:root > .prod
|
||||
|
||||
// direct development deps
|
||||
:root > .dev
|
||||
|
||||
// any peer dep of a direct deps
|
||||
:root > * > .peer
|
||||
|
||||
// any workspace dep
|
||||
.workspace
|
||||
|
||||
// all workspaces that depend on another workspace
|
||||
.workspace > .workspace
|
||||
|
||||
// all workspaces that have peer deps
|
||||
.workspace:has(.peer)
|
||||
|
||||
// any dep named "lodash"
|
||||
// equivalent to [name="lodash"]
|
||||
#lodash
|
||||
|
||||
// any deps named "lodash" & within semver range ^"1.2.3"
|
||||
#lodash@^1.2.3
|
||||
// equivalent to...
|
||||
[name="lodash"]:semver(^1.2.3)
|
||||
|
||||
// get the hoisted node for a given semver range
|
||||
#lodash@^1.2.3:not(:deduped)
|
||||
|
||||
// querying deps with a specific version
|
||||
#lodash@2.1.5
|
||||
// equivalent to...
|
||||
[name="lodash"][version="2.1.5"]
|
||||
|
||||
// has any deps
|
||||
:has(*)
|
||||
|
||||
// deps with no other deps (ie. "leaf" nodes)
|
||||
:empty
|
||||
|
||||
// manually querying git dependencies
|
||||
[repository^=github:],
|
||||
[repository^=git:],
|
||||
[repository^=https://github.com],
|
||||
[repository^=http://github.com],
|
||||
[repository^=https://github.com],
|
||||
[repository^=+git:...]
|
||||
|
||||
// querying for all git dependencies
|
||||
:type(git)
|
||||
|
||||
// get production dependencies that aren't also dev deps
|
||||
.prod:not(.dev)
|
||||
|
||||
// get dependencies with specific licenses
|
||||
[license=MIT], [license=ISC]
|
||||
|
||||
// find all packages that have @ruyadorno as a contributor
|
||||
:attr(contributors, [email=ruyadorno@github.com])
|
||||
```
|
||||
|
||||
### Example Response Output
|
||||
|
||||
- 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
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "",
|
||||
"version": "",
|
||||
"description": "",
|
||||
"homepage": "",
|
||||
"bugs": {},
|
||||
"author": {},
|
||||
"license": {},
|
||||
"funding": {},
|
||||
"files": [],
|
||||
"main": "",
|
||||
"browser": "",
|
||||
"bin": {},
|
||||
"man": [],
|
||||
"directories": {},
|
||||
"repository": {},
|
||||
"scripts": {},
|
||||
"config": {},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": {},
|
||||
"peerDependencies": {},
|
||||
"peerDependenciesMeta": {},
|
||||
"engines": {},
|
||||
"os": [],
|
||||
"cpu": [],
|
||||
"workspaces": {},
|
||||
"keywords": [],
|
||||
...
|
||||
},
|
||||
...
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
#### `global`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Operates in "global" mode, so that packages are installed into the `prefix`
|
||||
folder instead of the current working directory. See
|
||||
[folders](/configuring-npm/folders) for more on the differences in behavior.
|
||||
|
||||
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
|
||||
of the current working directory.
|
||||
* bin files are linked to `{prefix}/bin`
|
||||
* man pages are linked to `{prefix}/share/man`
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
#### `workspace`
|
||||
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.
|
||||
|
||||
Valid values for the `workspace` config are either:
|
||||
|
||||
* Workspace names
|
||||
* Path to a workspace directory
|
||||
* Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
When set for the `npm init` command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
#### `workspaces`
|
||||
|
||||
* Default: null
|
||||
* Type: null or Boolean
|
||||
|
||||
Set to true to run the command in the context of **all** configured
|
||||
workspaces.
|
||||
|
||||
Explicitly setting this to false will cause commands like `install` to
|
||||
ignore workspaces altogether. When not set explicitly:
|
||||
|
||||
- Commands that operate on the `node_modules` tree (install, update, etc.)
|
||||
will link workspaces into the `node_modules` folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
_unless_ one or more workspaces are specified in the `workspace` config.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
#### `include-workspace-root`
|
||||
|
||||
* Default: false
|
||||
* Type: Boolean
|
||||
|
||||
Include the workspace root when workspaces are enabled for a command.
|
||||
|
||||
When false, specifying individual workspaces via the `workspace` config, or
|
||||
all workspaces via the `workspaces` flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.
|
||||
|
||||
This value is not exported to the environment for child processes.
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
|
||||
## See Also
|
||||
|
||||
* [dependency selector](/using-npm/dependency-selector)
|
||||
+19
-1
@@ -1244,7 +1244,7 @@ Directory in which `npm pack` will save tarballs.
|
||||
* Default:
|
||||
* Type: String (can be set multiple times)
|
||||
|
||||
The package to install for [`npm exec`](/commands/npm-exec)
|
||||
The package or packages to install for [`npm exec`](/commands/npm-exec)
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
@@ -1393,6 +1393,24 @@ The base URL of the npm registry.
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
#### `replace-registry-host`
|
||||
|
||||
* Default: "npmjs"
|
||||
* Type: "npmjs", "never", "always", or String
|
||||
|
||||
Defines behavior for replacing the registry host in a lockfile with the
|
||||
configured registry.
|
||||
|
||||
The default behavior is to replace package dist URLs from the default
|
||||
registry (https://registry.npmjs.org) to the configured registry. If set to
|
||||
"never", then use the registry value. If set to "always", then replace the
|
||||
registry host with the configured host every time.
|
||||
|
||||
You may also specify a bare hostname (e.g., "registry.npmjs.org").
|
||||
|
||||
<!-- automatically generated, do not edit manually -->
|
||||
<!-- see lib/utils/config/definitions.js -->
|
||||
|
||||
#### `save`
|
||||
|
||||
* Default: `true` unless when using `npm update` where it defaults to `false`
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
---
|
||||
title: Dependency Selector Syntax & Querying
|
||||
section: 7
|
||||
description: Dependency Selector Syntax & Querying
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
The [`npm query`](/commands/npm-query) commmand exposes a new dependency selector syntax (informed by & respecting many aspects of the [CSS Selectors 4 Spec](https://dev.w3.org/csswg/selectors4/#relational)) which:
|
||||
|
||||
- Standardizes the shape of, & querying of, dependency graphs with a robust object model, metadata & selector syntax
|
||||
- Leverages existing, known language syntax & operators from CSS to make disparate package information broadly accessible
|
||||
- Unlocks the ability to answer complex, multi-faceted questions about dependencies, their relationships & associative metadata
|
||||
- Consolidates redundant logic of similar query commands in `npm` (ex. `npm fund`, `npm ls`, `npm outdated`, `npm audit` ...)
|
||||
|
||||
### Dependency Selector Syntax `v1.0.0`
|
||||
|
||||
#### Overview:
|
||||
|
||||
- there is no "type" or "tag" selectors (ex. `div, h1, a`) as a dependency/target is the only type of `Node` that can be queried
|
||||
- the term "dependencies" is in reference to any `Node` found in a `tree` returned by `Arborist`
|
||||
|
||||
#### Combinators
|
||||
|
||||
- `>` direct descendant/child
|
||||
- ` ` any descendant/child
|
||||
- `~` sibling
|
||||
|
||||
#### Selectors
|
||||
|
||||
- `*` universal selector
|
||||
- `#<name>` dependency selector (equivalent to `[name="..."]`)
|
||||
- `#<name>@<version>` (equivalent to `[name=<name>]:semver(<version>)`)
|
||||
- `,` selector list delimiter
|
||||
- `.` dependency type selector
|
||||
- `:` pseudo selector
|
||||
|
||||
#### Dependency Type Selectors
|
||||
|
||||
- `.prod` dependency found in the `dependencies` section of `package.json`, or is a child of said dependency
|
||||
- `.dev` dependency found in the `devDependencies` section of `package.json`, or is a child of said dependency
|
||||
- `.optional` dependency found in the `optionalDependencies` section of `package.json`, or has `"optional": true` set in its entry in the `peerDependenciesMeta` section of `package.json`, or a child of said dependency
|
||||
- `.peer` dependency found in the `peerDependencies` section of `package.json`
|
||||
- `.workspace` dependency found in the [`workspaces`](https://docs.npmjs.com/cli/v8/using-npm/workspaces) section of `package.json`
|
||||
- `.bundled` dependency found in the `bundleDependencies` section of `package.json`, or is a child of said dependency
|
||||
|
||||
#### Pseudo Selectors
|
||||
- [`:not(<selector>)`](https://developer.mozilla.org/en-US/docs/Web/CSS/:not)
|
||||
- [`:has(<selector>)`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has)
|
||||
- [`:is(<selector list>)`](https://developer.mozilla.org/en-US/docs/Web/CSS/:is)
|
||||
- [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) matches the root node/dependency
|
||||
- [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) matches node/dependency it was queried against
|
||||
- [`:empty`](https://developer.mozilla.org/en-US/docs/Web/CSS/:empty) when a dependency has no dependencies
|
||||
- [`:private`](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#private) when a dependency is private
|
||||
- `:link` when a dependency is linked (for instance, workspaces or packages manually [`linked`](https://docs.npmjs.com/cli/v8/commands/npm-link)
|
||||
- `:deduped` when a dependency has been deduped (note that this does *not* always mean the dependency has been hoisted to the root of node_modules)
|
||||
- `:override` when a dependency is an override (not implemented yet)
|
||||
- `:extraneous` when a dependency exists but is not defined as a dependency of any node
|
||||
- `:invalid` when a dependency version is out of its ancestors specified range
|
||||
- `:missing` when a dependency is not found on disk
|
||||
- `:semver(<spec>)` matching a valid [`node-semver`](https://github.com/npm/node-semver) spec
|
||||
- `:path(<path>)` [glob](https://www.npmjs.com/package/glob) matching based on dependencies path relative to the project
|
||||
- `:type(<type>)` [based on currently recognized types](https://github.com/npm/npm-package-arg#result-object)
|
||||
|
||||
#### [Attribute Selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)
|
||||
|
||||
The attribute selector evaluates the key/value pairs in `package.json` if they are `String`s.
|
||||
|
||||
- `[]` attribute selector (ie. existence of attribute)
|
||||
- `[attribute=value]` attribute value is equivalant...
|
||||
- `[attribute~=value]` attribute value contains word...
|
||||
- `[attribute*=value]` attribute value contains string...
|
||||
- `[attribute|=value]` attribute value is equal to or starts with...
|
||||
- `[attribute^=value]` attribute value starts with...
|
||||
- `[attribute$=value]` attribute value ends with...
|
||||
|
||||
#### `Array` & `Object` Attribute Selectors
|
||||
|
||||
The generic `:attr()` pseudo selector standardizes a pattern which can be used for attribute selection of `Object`s, `Array`s or `Arrays` of `Object`s accessible via `Arborist`'s `Node.package` metadata. This allows for iterative attribute selection beyond top-level `String` evaluation. The last argument passed to `:attr()` must be an `attribute` selector or a nested `:attr()`. See examples below:
|
||||
|
||||
#### `Objects`
|
||||
|
||||
```css
|
||||
/* return dependencies that have a `scripts.test` containing `"tap"` */
|
||||
*:attr(scripts, [test~=tap])
|
||||
```
|
||||
|
||||
#### Nested `Objects`
|
||||
|
||||
Nested objects are expressed as sequential arguments to `:attr()`.
|
||||
|
||||
```css
|
||||
/* return dependencies that have a testling config for opera browsers */
|
||||
*:attr(testling, browsers, [~=opera])
|
||||
```
|
||||
|
||||
#### `Arrays`
|
||||
|
||||
`Array`s specifically uses a special/reserved `.` character in place of a typical attribute name. `Arrays` also support exact `value` matching when a `String` is passed to the selector.
|
||||
|
||||
##### Example of an `Array` Attribute Selection:
|
||||
```css
|
||||
/* removes the distinction between properties & arrays */
|
||||
/* ie. we'd have to check the property & iterate to match selection */
|
||||
*:attr([keywords^=react])
|
||||
*:attr(contributors, :attr([name~=Jordan]))
|
||||
```
|
||||
|
||||
##### Example of an `Array` matching directly to a value:
|
||||
```css
|
||||
/* return dependencies that have the exact keyword "react" */
|
||||
/* this is equivalent to `*:keywords([value="react"])` */
|
||||
*:attr([keywords=react])
|
||||
```
|
||||
|
||||
##### Example of an `Array` of `Object`s:
|
||||
```css
|
||||
/* returns */
|
||||
*:attr(contributors, [email=ruyadorno@github.com])
|
||||
```
|
||||
|
||||
### Groups
|
||||
|
||||
Dependency groups are defined by the package relationships to their ancestors (ie. the dependency types that are defined in `package.json`). This approach is user-centric as the ecosystem has been taught to think about dependencies in these groups first-and-foremost. Dependencies are allowed to be included in multiple groups (ex. a `prod` dependency may also be a `dev` dependency (in that it's also required by another `dev` dependency) & may also be `bundled` - a selector for that type of dependency would look like: `*.prod.dev.bundled`).
|
||||
|
||||
- `.prod`
|
||||
- `.dev`
|
||||
- `.optional`
|
||||
- `.peer`
|
||||
- `.bundled`
|
||||
- `.workspace`
|
||||
|
||||
Please note that currently `workspace` deps are always `prod` dependencies. Additionally the `.root` dependency is also considered a `prod` dependency.
|
||||
|
||||
### Programmatic Usage
|
||||
|
||||
- `Arborist`'s `Node` Class has a `.querySelectorAll()` method
|
||||
- this method will return a filtered, flattened dependency Arborist `Node` list based on a valid query selector
|
||||
|
||||
```js
|
||||
const Arborist = require('@npmcli/arborist')
|
||||
const arb = new Arborist({})
|
||||
```
|
||||
|
||||
```js
|
||||
// root-level
|
||||
arb.loadActual((tree) => {
|
||||
// query all production dependencies
|
||||
const results = await tree.querySelectorAll('.prod')
|
||||
console.log(results)
|
||||
})
|
||||
```
|
||||
|
||||
```js
|
||||
// iterative
|
||||
arb.loadActual((tree) => {
|
||||
// query for the deduped version of react
|
||||
const results = await tree.querySelectorAll('#react:not(:deduped)')
|
||||
// query the deduped react for git deps
|
||||
const deps = await results[0].querySelectorAll(':type(git)')
|
||||
console.log(deps)
|
||||
})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [npm query](/commands/npm-query)
|
||||
* [@npmcli/arborist](https://npm.im/@npmcli/arborist]
|
||||
+1
-1
@@ -192,7 +192,7 @@ $ ls | grep package-lock
|
||||
<pre lang="bash"><code>$ npm ci
|
||||
added 154 packages in 5s
|
||||
</code></pre>
|
||||
<p>Configure Travis to build using <code>npm ci</code> instead of <code>npm install</code>:</p>
|
||||
<p>Configure Travis CI to build using <code>npm ci</code> instead of <code>npm install</code>:</p>
|
||||
<pre lang="bash"><code># .travis.yml
|
||||
install:
|
||||
- npm ci
|
||||
|
||||
+1
-1
@@ -236,7 +236,7 @@ thus be equivalent to the <code>npx</code> command above:</p>
|
||||
<li>Default:</li>
|
||||
<li>Type: String (can be set multiple times)</li>
|
||||
</ul>
|
||||
<p>The package to install for <a href="../commands/npm-exec.html"><code>npm exec</code></a></p>
|
||||
<p>The package or packages to install for <a href="../commands/npm-exec.html"><code>npm exec</code></a></p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="call"><code>call</code></h4>
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@ tree at all, use <a href="../commands/npm-explain.html"><code>npm explain</code>
|
||||
the results to only the paths to the packages named. Note that nested
|
||||
packages will <em>also</em> show the paths to the specified packages. For
|
||||
example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
|
||||
<pre lang="bash"><code>npm@8.15.1 /path/to/npm
|
||||
<pre lang="bash"><code>npm@8.16.0 /path/to/npm
|
||||
└─┬ init-package-json@0.0.4
|
||||
└── promzard@0.1.5
|
||||
</code></pre>
|
||||
|
||||
+363
@@ -0,0 +1,363 @@
|
||||
<!DOCTYPE html><html><head>
|
||||
<meta charset="utf-8">
|
||||
<title>npm-query</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #ffffff;
|
||||
color: #24292e;
|
||||
|
||||
margin: 0;
|
||||
|
||||
line-height: 1.5;
|
||||
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
}
|
||||
#rainbar {
|
||||
height: 10px;
|
||||
background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #0366d6;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 1em 0px;
|
||||
padding: 1em;
|
||||
border: solid 1px #e1e4e8;
|
||||
border-radius: 6px;
|
||||
|
||||
display: block;
|
||||
overflow: auto;
|
||||
|
||||
white-space: pre;
|
||||
|
||||
background-color: #f6f8fa;
|
||||
color: #393a34;
|
||||
}
|
||||
code {
|
||||
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
font-size: 85%;
|
||||
padding: 0.2em 0.4em;
|
||||
background-color: #f6f8fa;
|
||||
color: #393a34;
|
||||
}
|
||||
pre > code {
|
||||
padding: 0;
|
||||
background-color: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#logobar {
|
||||
background-color: #333333;
|
||||
margin: 0 auto;
|
||||
padding: 1em 4em;
|
||||
}
|
||||
#logobar .logo {
|
||||
float: left;
|
||||
}
|
||||
#logobar .title {
|
||||
font-weight: 600;
|
||||
color: #dddddd;
|
||||
float: left;
|
||||
margin: 5px 0 0 1em;
|
||||
}
|
||||
#logobar:after {
|
||||
content: "";
|
||||
display: block;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin: 0 auto;
|
||||
padding: 0 4em;
|
||||
}
|
||||
|
||||
#table_of_contents > h2 {
|
||||
font-size: 1.17em;
|
||||
}
|
||||
#table_of_contents ul:first-child {
|
||||
border: solid 1px #e1e4e8;
|
||||
border-radius: 6px;
|
||||
padding: 1em;
|
||||
background-color: #f6f8fa;
|
||||
color: #393a34;
|
||||
}
|
||||
#table_of_contents ul {
|
||||
list-style-type: none;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
#table_of_contents li {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
#table_of_contents li a {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
header.title {
|
||||
border-bottom: solid 1px #e1e4e8;
|
||||
}
|
||||
header.title > h1 {
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
header.title > .description {
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
footer#edit {
|
||||
border-top: solid 1px #e1e4e8;
|
||||
margin: 3em 0 4em 0;
|
||||
padding-top: 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
<div id="rainbar"></div>
|
||||
<div id="logobar">
|
||||
<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
|
||||
<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
|
||||
<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
|
||||
</svg>
|
||||
<div class="title">
|
||||
npm command-line interface
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section id="content">
|
||||
<header class="title">
|
||||
<h1 id="npm-query">npm-query</h1>
|
||||
<span class="description">Dependency selector query</span>
|
||||
</header>
|
||||
|
||||
<section id="table_of_contents">
|
||||
<h2 id="table-of-contents">Table of contents</h2>
|
||||
<div id="_table_of_contents"><ul><li><a href="#see-also">See Also</a></li></ul></div>
|
||||
</section>
|
||||
|
||||
<div id="_content"><h3 id="synopsis">Synopsis</h3>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<pre lang="bash"><code>npm query <selector>
|
||||
</code></pre>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h3 id="description">Description</h3>
|
||||
<p>The <code>npm query</code> command allows for usage of css selectors in order to retrieve
|
||||
an array of dependency objects.</p>
|
||||
<h3 id="piping-npm-query-to-other-commands">Piping npm query to other commands</h3>
|
||||
<pre lang="bash"><code># find all dependencies with postinstall scripts & uninstall them
|
||||
npm query ":attr(scripts, [postinstall])" | jq 'map(.name)|join("\n")' -r | xargs -I {} npm uninstall {}
|
||||
|
||||
# find all git dependencies & explain who requires them
|
||||
npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}
|
||||
</code></pre>
|
||||
<h3 id="extended-use-cases--queries">Extended Use Cases & Queries</h3>
|
||||
<pre lang="stylus"><code>// all deps
|
||||
*
|
||||
|
||||
// all direct deps
|
||||
:root > *
|
||||
|
||||
// direct production deps
|
||||
:root > .prod
|
||||
|
||||
// direct development deps
|
||||
:root > .dev
|
||||
|
||||
// any peer dep of a direct deps
|
||||
:root > * > .peer
|
||||
|
||||
// any workspace dep
|
||||
.workspace
|
||||
|
||||
// all workspaces that depend on another workspace
|
||||
.workspace > .workspace
|
||||
|
||||
// all workspaces that have peer deps
|
||||
.workspace:has(.peer)
|
||||
|
||||
// any dep named "lodash"
|
||||
// equivalent to [name="lodash"]
|
||||
#lodash
|
||||
|
||||
// any deps named "lodash" & within semver range ^"1.2.3"
|
||||
#lodash@^1.2.3
|
||||
// equivalent to...
|
||||
[name="lodash"]:semver(^1.2.3)
|
||||
|
||||
// get the hoisted node for a given semver range
|
||||
#lodash@^1.2.3:not(:deduped)
|
||||
|
||||
// querying deps with a specific version
|
||||
#lodash@2.1.5
|
||||
// equivalent to...
|
||||
[name="lodash"][version="2.1.5"]
|
||||
|
||||
// has any deps
|
||||
:has(*)
|
||||
|
||||
// deps with no other deps (ie. "leaf" nodes)
|
||||
:empty
|
||||
|
||||
// manually querying git dependencies
|
||||
[repository^=github:],
|
||||
[repository^=git:],
|
||||
[repository^=https://github.com],
|
||||
[repository^=http://github.com],
|
||||
[repository^=https://github.com],
|
||||
[repository^=+git:...]
|
||||
|
||||
// querying for all git dependencies
|
||||
:type(git)
|
||||
|
||||
// get production dependencies that aren't also dev deps
|
||||
.prod:not(.dev)
|
||||
|
||||
// get dependencies with specific licenses
|
||||
[license=MIT], [license=ISC]
|
||||
|
||||
// find all packages that have @ruyadorno as a contributor
|
||||
:attr(contributors, [email=ruyadorno@github.com])
|
||||
</code></pre>
|
||||
<h3 id="example-response-output">Example Response Output</h3>
|
||||
<ul>
|
||||
<li>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</li>
|
||||
</ul>
|
||||
<pre lang="json"><code>[
|
||||
{
|
||||
"name": "",
|
||||
"version": "",
|
||||
"description": "",
|
||||
"homepage": "",
|
||||
"bugs": {},
|
||||
"author": {},
|
||||
"license": {},
|
||||
"funding": {},
|
||||
"files": [],
|
||||
"main": "",
|
||||
"browser": "",
|
||||
"bin": {},
|
||||
"man": [],
|
||||
"directories": {},
|
||||
"repository": {},
|
||||
"scripts": {},
|
||||
"config": {},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": {},
|
||||
"peerDependencies": {},
|
||||
"peerDependenciesMeta": {},
|
||||
"engines": {},
|
||||
"os": [],
|
||||
"cpu": [],
|
||||
"workspaces": {},
|
||||
"keywords": [],
|
||||
...
|
||||
},
|
||||
...
|
||||
</code></pre>
|
||||
<h3 id="configuration">Configuration</h3>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="global"><code>global</code></h4>
|
||||
<ul>
|
||||
<li>Default: false</li>
|
||||
<li>Type: Boolean</li>
|
||||
</ul>
|
||||
<p>Operates in "global" mode, so that packages are installed into the <code>prefix</code>
|
||||
folder instead of the current working directory. See
|
||||
<a href="../configuring-npm/folders.html">folders</a> for more on the differences in behavior.</p>
|
||||
<ul>
|
||||
<li>packages are installed into the <code>{prefix}/lib/node_modules</code> folder, instead
|
||||
of the current working directory.</li>
|
||||
<li>bin files are linked to <code>{prefix}/bin</code></li>
|
||||
<li>man pages are linked to <code>{prefix}/share/man</code></li>
|
||||
</ul>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="workspace"><code>workspace</code></h4>
|
||||
<ul>
|
||||
<li>Default:</li>
|
||||
<li>Type: String (can be set multiple times)</li>
|
||||
</ul>
|
||||
<p>Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option.</p>
|
||||
<p>Valid values for the <code>workspace</code> config are either:</p>
|
||||
<ul>
|
||||
<li>Workspace names</li>
|
||||
<li>Path to a workspace directory</li>
|
||||
<li>Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)</li>
|
||||
</ul>
|
||||
<p>When set for the <code>npm init</code> command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project.</p>
|
||||
<p>This value is not exported to the environment for child processes.</p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="workspaces"><code>workspaces</code></h4>
|
||||
<ul>
|
||||
<li>Default: null</li>
|
||||
<li>Type: null or Boolean</li>
|
||||
</ul>
|
||||
<p>Set to true to run the command in the context of <strong>all</strong> configured
|
||||
workspaces.</p>
|
||||
<p>Explicitly setting this to false will cause commands like <code>install</code> to
|
||||
ignore workspaces altogether. When not set explicitly:</p>
|
||||
<ul>
|
||||
<li>Commands that operate on the <code>node_modules</code> tree (install, update, etc.)
|
||||
will link workspaces into the <code>node_modules</code> folder. - Commands that do
|
||||
other things (test, exec, publish, etc.) will operate on the root project,
|
||||
<em>unless</em> one or more workspaces are specified in the <code>workspace</code> config.</li>
|
||||
</ul>
|
||||
<p>This value is not exported to the environment for child processes.</p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="include-workspace-root"><code>include-workspace-root</code></h4>
|
||||
<ul>
|
||||
<li>Default: false</li>
|
||||
<li>Type: Boolean</li>
|
||||
</ul>
|
||||
<p>Include the workspace root when workspaces are enabled for a command.</p>
|
||||
<p>When false, specifying individual workspaces via the <code>workspace</code> config, or
|
||||
all workspaces via the <code>workspaces</code> flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project.</p>
|
||||
<p>This value is not exported to the environment for child processes.</p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h2 id="see-also">See Also</h2>
|
||||
<ul>
|
||||
<li><a href="../using-npm/dependency-selector.html">dependency selector</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<footer id="edit">
|
||||
<a href="https://github.com/npm/cli/edit/latest/docs/content/commands/npm-query.md">
|
||||
<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
|
||||
<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path>
|
||||
</svg>
|
||||
Edit this page on GitHub
|
||||
</a>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</body></html>
|
||||
+1
-1
@@ -149,7 +149,7 @@ npm command-line interface
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h3 id="version">Version</h3>
|
||||
<p>8.15.1</p>
|
||||
<p>8.16.0</p>
|
||||
<h3 id="description">Description</h3>
|
||||
<p>npm is the package manager for the Node JavaScript platform. It puts
|
||||
modules in place so that node can find them, and manages dependency
|
||||
|
||||
+16
-2
@@ -142,7 +142,7 @@ npm command-line interface
|
||||
|
||||
<section id="table_of_contents">
|
||||
<h2 id="table-of-contents">Table of contents</h2>
|
||||
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><ul><li><a href="#command-line-flags">Command Line Flags</a></li><li><a href="#environment-variables">Environment Variables</a></li><li><a href="#npmrc-files">npmrc Files</a></li><li><a href="#default-configs">Default Configs</a></li></ul><li><a href="#shorthands-and-other-cli-niceties">Shorthands and Other CLI Niceties</a></li><li><a href="#config-settings">Config Settings</a></li><ul><li><a href="#auth"><code>_auth</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#all"><code>all</code></a></li><li><a href="#allow-same-version"><code>allow-same-version</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#audit-level"><code>audit-level</code></a></li><li><a href="#auth-type"><code>auth-type</code></a></li><li><a href="#before"><code>before</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#browser"><code>browser</code></a></li><li><a href="#ca"><code>ca</code></a></li><li><a href="#cache"><code>cache</code></a></li><li><a href="#cafile"><code>cafile</code></a></li><li><a href="#call"><code>call</code></a></li><li><a href="#cert"><code>cert</code></a></li><li><a href="#ci-name"><code>ci-name</code></a></li><li><a href="#cidr"><code>cidr</code></a></li><li><a href="#color"><code>color</code></a></li><li><a href="#commit-hooks"><code>commit-hooks</code></a></li><li><a href="#depth"><code>depth</code></a></li><li><a href="#description2"><code>description</code></a></li><li><a href="#diff"><code>diff</code></a></li><li><a href="#diff-dst-prefix"><code>diff-dst-prefix</code></a></li><li><a href="#diff-ignore-all-space"><code>diff-ignore-all-space</code></a></li><li><a href="#diff-name-only"><code>diff-name-only</code></a></li><li><a href="#diff-no-prefix"><code>diff-no-prefix</code></a></li><li><a href="#diff-src-prefix"><code>diff-src-prefix</code></a></li><li><a href="#diff-text"><code>diff-text</code></a></li><li><a href="#diff-unified"><code>diff-unified</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#editor"><code>editor</code></a></li><li><a href="#engine-strict"><code>engine-strict</code></a></li><li><a href="#fetch-retries"><code>fetch-retries</code></a></li><li><a href="#fetch-retry-factor"><code>fetch-retry-factor</code></a></li><li><a href="#fetch-retry-maxtimeout"><code>fetch-retry-maxtimeout</code></a></li><li><a href="#fetch-retry-mintimeout"><code>fetch-retry-mintimeout</code></a></li><li><a href="#fetch-timeout"><code>fetch-timeout</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#format-package-lock"><code>format-package-lock</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#git"><code>git</code></a></li><li><a href="#git-tag-version"><code>git-tag-version</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#globalconfig"><code>globalconfig</code></a></li><li><a href="#heading"><code>heading</code></a></li><li><a href="#https-proxy"><code>https-proxy</code></a></li><li><a href="#if-present"><code>if-present</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#include"><code>include</code></a></li><li><a href="#include-staged"><code>include-staged</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#init-author-email"><code>init-author-email</code></a></li><li><a href="#init-author-name"><code>init-author-name</code></a></li><li><a href="#init-author-url"><code>init-author-url</code></a></li><li><a href="#init-license"><code>init-license</code></a></li><li><a href="#init-module"><code>init-module</code></a></li><li><a href="#init-version"><code>init-version</code></a></li><li><a href="#install-links"><code>install-links</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#key"><code>key</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#legacy-peer-deps"><code>legacy-peer-deps</code></a></li><li><a href="#link"><code>link</code></a></li><li><a href="#local-address"><code>local-address</code></a></li><li><a href="#location"><code>location</code></a></li><li><a href="#lockfile-version"><code>lockfile-version</code></a></li><li><a href="#loglevel"><code>loglevel</code></a></li><li><a href="#logs-dir"><code>logs-dir</code></a></li><li><a href="#logs-max"><code>logs-max</code></a></li><li><a href="#long"><code>long</code></a></li><li><a href="#maxsockets"><code>maxsockets</code></a></li><li><a href="#message"><code>message</code></a></li><li><a href="#node-options"><code>node-options</code></a></li><li><a href="#node-version"><code>node-version</code></a></li><li><a href="#noproxy"><code>noproxy</code></a></li><li><a href="#npm-veLine truncated
|
||||
<div id="_table_of_contents"><ul><li><a href="#description">Description</a></li><ul><li><a href="#command-line-flags">Command Line Flags</a></li><li><a href="#environment-variables">Environment Variables</a></li><li><a href="#npmrc-files">npmrc Files</a></li><li><a href="#default-configs">Default Configs</a></li></ul><li><a href="#shorthands-and-other-cli-niceties">Shorthands and Other CLI Niceties</a></li><li><a href="#config-settings">Config Settings</a></li><ul><li><a href="#auth"><code>_auth</code></a></li><li><a href="#access"><code>access</code></a></li><li><a href="#all"><code>all</code></a></li><li><a href="#allow-same-version"><code>allow-same-version</code></a></li><li><a href="#audit"><code>audit</code></a></li><li><a href="#audit-level"><code>audit-level</code></a></li><li><a href="#auth-type"><code>auth-type</code></a></li><li><a href="#before"><code>before</code></a></li><li><a href="#bin-links"><code>bin-links</code></a></li><li><a href="#browser"><code>browser</code></a></li><li><a href="#ca"><code>ca</code></a></li><li><a href="#cache"><code>cache</code></a></li><li><a href="#cafile"><code>cafile</code></a></li><li><a href="#call"><code>call</code></a></li><li><a href="#cert"><code>cert</code></a></li><li><a href="#ci-name"><code>ci-name</code></a></li><li><a href="#cidr"><code>cidr</code></a></li><li><a href="#color"><code>color</code></a></li><li><a href="#commit-hooks"><code>commit-hooks</code></a></li><li><a href="#depth"><code>depth</code></a></li><li><a href="#description2"><code>description</code></a></li><li><a href="#diff"><code>diff</code></a></li><li><a href="#diff-dst-prefix"><code>diff-dst-prefix</code></a></li><li><a href="#diff-ignore-all-space"><code>diff-ignore-all-space</code></a></li><li><a href="#diff-name-only"><code>diff-name-only</code></a></li><li><a href="#diff-no-prefix"><code>diff-no-prefix</code></a></li><li><a href="#diff-src-prefix"><code>diff-src-prefix</code></a></li><li><a href="#diff-text"><code>diff-text</code></a></li><li><a href="#diff-unified"><code>diff-unified</code></a></li><li><a href="#dry-run"><code>dry-run</code></a></li><li><a href="#editor"><code>editor</code></a></li><li><a href="#engine-strict"><code>engine-strict</code></a></li><li><a href="#fetch-retries"><code>fetch-retries</code></a></li><li><a href="#fetch-retry-factor"><code>fetch-retry-factor</code></a></li><li><a href="#fetch-retry-maxtimeout"><code>fetch-retry-maxtimeout</code></a></li><li><a href="#fetch-retry-mintimeout"><code>fetch-retry-mintimeout</code></a></li><li><a href="#fetch-timeout"><code>fetch-timeout</code></a></li><li><a href="#force"><code>force</code></a></li><li><a href="#foreground-scripts"><code>foreground-scripts</code></a></li><li><a href="#format-package-lock"><code>format-package-lock</code></a></li><li><a href="#fund"><code>fund</code></a></li><li><a href="#git"><code>git</code></a></li><li><a href="#git-tag-version"><code>git-tag-version</code></a></li><li><a href="#global"><code>global</code></a></li><li><a href="#global-style"><code>global-style</code></a></li><li><a href="#globalconfig"><code>globalconfig</code></a></li><li><a href="#heading"><code>heading</code></a></li><li><a href="#https-proxy"><code>https-proxy</code></a></li><li><a href="#if-present"><code>if-present</code></a></li><li><a href="#ignore-scripts"><code>ignore-scripts</code></a></li><li><a href="#include"><code>include</code></a></li><li><a href="#include-staged"><code>include-staged</code></a></li><li><a href="#include-workspace-root"><code>include-workspace-root</code></a></li><li><a href="#init-author-email"><code>init-author-email</code></a></li><li><a href="#init-author-name"><code>init-author-name</code></a></li><li><a href="#init-author-url"><code>init-author-url</code></a></li><li><a href="#init-license"><code>init-license</code></a></li><li><a href="#init-module"><code>init-module</code></a></li><li><a href="#init-version"><code>init-version</code></a></li><li><a href="#install-links"><code>install-links</code></a></li><li><a href="#json"><code>json</code></a></li><li><a href="#key"><code>key</code></a></li><li><a href="#legacy-bundling"><code>legacy-bundling</code></a></li><li><a href="#legacy-peer-deps"><code>legacy-peer-deps</code></a></li><li><a href="#link"><code>link</code></a></li><li><a href="#local-address"><code>local-address</code></a></li><li><a href="#location"><code>location</code></a></li><li><a href="#lockfile-version"><code>lockfile-version</code></a></li><li><a href="#loglevel"><code>loglevel</code></a></li><li><a href="#logs-dir"><code>logs-dir</code></a></li><li><a href="#logs-max"><code>logs-max</code></a></li><li><a href="#long"><code>long</code></a></li><li><a href="#maxsockets"><code>maxsockets</code></a></li><li><a href="#message"><code>message</code></a></li><li><a href="#node-options"><code>node-options</code></a></li><li><a href="#node-version"><code>node-version</code></a></li><li><a href="#noproxy"><code>noproxy</code></a></li><li><a href="#npm-veLine truncated
|
||||
</section>
|
||||
|
||||
<div id="_content"><h3 id="description">Description</h3>
|
||||
@@ -1146,7 +1146,7 @@ password, npm will prompt on the command line for one.</p>
|
||||
<li>Default:</li>
|
||||
<li>Type: String (can be set multiple times)</li>
|
||||
</ul>
|
||||
<p>The package to install for <a href="../commands/npm-exec.html"><code>npm exec</code></a></p>
|
||||
<p>The package or packages to install for <a href="../commands/npm-exec.html"><code>npm exec</code></a></p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="package-lock"><code>package-lock</code></h4>
|
||||
@@ -1265,6 +1265,20 @@ access tokens with the <code>npm token create</code> command.</p>
|
||||
<p>The base URL of the npm registry.</p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="replace-registry-host"><code>replace-registry-host</code></h4>
|
||||
<ul>
|
||||
<li>Default: "npmjs"</li>
|
||||
<li>Type: "npmjs", "never", "always", or String</li>
|
||||
</ul>
|
||||
<p>Defines behavior for replacing the registry host in a lockfile with the
|
||||
configured registry.</p>
|
||||
<p>The default behavior is to replace package dist URLs from the default
|
||||
registry (<a href="https://registry.npmjs.org">https://registry.npmjs.org</a>) to the configured registry. If set to
|
||||
"never", then use the registry value. If set to "always", then replace the
|
||||
registry host with the configured host every time.</p>
|
||||
<p>You may also specify a bare hostname (e.g., "registry.npmjs.org").</p>
|
||||
<!-- raw HTML omitted -->
|
||||
<!-- raw HTML omitted -->
|
||||
<h4 id="save"><code>save</code></h4>
|
||||
<ul>
|
||||
<li>Default: <code>true</code> unless when using <code>npm update</code> where it defaults to <code>false</code></li>
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
<!DOCTYPE html><html><head>
|
||||
<meta charset="utf-8">
|
||||
<title>Dependency Selector Syntax & Querying</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #ffffff;
|
||||
color: #24292e;
|
||||
|
||||
margin: 0;
|
||||
|
||||
line-height: 1.5;
|
||||
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
}
|
||||
#rainbar {
|
||||
height: 10px;
|
||||
background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #0366d6;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 1em 0px;
|
||||
padding: 1em;
|
||||
border: solid 1px #e1e4e8;
|
||||
border-radius: 6px;
|
||||
|
||||
display: block;
|
||||
overflow: auto;
|
||||
|
||||
white-space: pre;
|
||||
|
||||
background-color: #f6f8fa;
|
||||
color: #393a34;
|
||||
}
|
||||
code {
|
||||
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
font-size: 85%;
|
||||
padding: 0.2em 0.4em;
|
||||
background-color: #f6f8fa;
|
||||
color: #393a34;
|
||||
}
|
||||
pre > code {
|
||||
padding: 0;
|
||||
background-color: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#logobar {
|
||||
background-color: #333333;
|
||||
margin: 0 auto;
|
||||
padding: 1em 4em;
|
||||
}
|
||||
#logobar .logo {
|
||||
float: left;
|
||||
}
|
||||
#logobar .title {
|
||||
font-weight: 600;
|
||||
color: #dddddd;
|
||||
float: left;
|
||||
margin: 5px 0 0 1em;
|
||||
}
|
||||
#logobar:after {
|
||||
content: "";
|
||||
display: block;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin: 0 auto;
|
||||
padding: 0 4em;
|
||||
}
|
||||
|
||||
#table_of_contents > h2 {
|
||||
font-size: 1.17em;
|
||||
}
|
||||
#table_of_contents ul:first-child {
|
||||
border: solid 1px #e1e4e8;
|
||||
border-radius: 6px;
|
||||
padding: 1em;
|
||||
background-color: #f6f8fa;
|
||||
color: #393a34;
|
||||
}
|
||||
#table_of_contents ul {
|
||||
list-style-type: none;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
#table_of_contents li {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
#table_of_contents li a {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
header.title {
|
||||
border-bottom: solid 1px #e1e4e8;
|
||||
}
|
||||
header.title > h1 {
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
header.title > .description {
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
footer#edit {
|
||||
border-top: solid 1px #e1e4e8;
|
||||
margin: 3em 0 4em 0;
|
||||
padding-top: 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
<div id="rainbar"></div>
|
||||
<div id="logobar">
|
||||
<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
|
||||
<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
|
||||
<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
|
||||
</svg>
|
||||
<div class="title">
|
||||
npm command-line interface
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section id="content">
|
||||
<header class="title">
|
||||
<h1 id="dependency-selector-syntax--querying">Dependency Selector Syntax & Querying</h1>
|
||||
<span class="description">Dependency Selector Syntax & Querying</span>
|
||||
</header>
|
||||
|
||||
<section id="table_of_contents">
|
||||
<h2 id="table-of-contents">Table of contents</h2>
|
||||
<div id="_table_of_contents"><ul><li><a href="#see-also">See Also</a></li></ul></div>
|
||||
</section>
|
||||
|
||||
<div id="_content"><h3 id="description">Description</h3>
|
||||
<p>The <a href="../commands/npm-query.html"><code>npm query</code></a> commmand exposes a new dependency selector syntax (informed by & respecting many aspects of the <a href="https://dev.w3.org/csswg/selectors4/#relational">CSS Selectors 4 Spec</a>) which:</p>
|
||||
<ul>
|
||||
<li>Standardizes the shape of, & querying of, dependency graphs with a robust object model, metadata & selector syntax</li>
|
||||
<li>Leverages existing, known language syntax & operators from CSS to make disparate package information broadly accessible</li>
|
||||
<li>Unlocks the ability to answer complex, multi-faceted questions about dependencies, their relationships & associative metadata</li>
|
||||
<li>Consolidates redundant logic of similar query commands in <code>npm</code> (ex. <code>npm fund</code>, <code>npm ls</code>, <code>npm outdated</code>, <code>npm audit</code> ...)</li>
|
||||
</ul>
|
||||
<h3 id="dependency-selector-syntax-v100">Dependency Selector Syntax <code>v1.0.0</code></h3>
|
||||
<h4 id="overview">Overview:</h4>
|
||||
<ul>
|
||||
<li>there is no "type" or "tag" selectors (ex. <code>div, h1, a</code>) as a dependency/target is the only type of <code>Node</code> that can be queried</li>
|
||||
<li>the term "dependencies" is in reference to any <code>Node</code> found in a <code>tree</code> returned by <code>Arborist</code></li>
|
||||
</ul>
|
||||
<h4 id="combinators">Combinators</h4>
|
||||
<ul>
|
||||
<li><code>></code> direct descendant/child</li>
|
||||
<li><code> </code> any descendant/child</li>
|
||||
<li><code>~</code> sibling</li>
|
||||
</ul>
|
||||
<h4 id="selectors">Selectors</h4>
|
||||
<ul>
|
||||
<li><code>*</code> universal selector</li>
|
||||
<li><code>#<name></code> dependency selector (equivalent to <code>[name="..."]</code>)</li>
|
||||
<li><code>#<name>@<version></code> (equivalent to <code>[name=<name>]:semver(<version>)</code>)</li>
|
||||
<li><code>,</code> selector list delimiter</li>
|
||||
<li><code>.</code> dependency type selector</li>
|
||||
<li><code>:</code> pseudo selector</li>
|
||||
</ul>
|
||||
<h4 id="dependency-type-selectors">Dependency Type Selectors</h4>
|
||||
<ul>
|
||||
<li><code>.prod</code> dependency found in the <code>dependencies</code> section of <code>package.json</code>, or is a child of said dependency</li>
|
||||
<li><code>.dev</code> dependency found in the <code>devDependencies</code> section of <code>package.json</code>, or is a child of said dependency</li>
|
||||
<li><code>.optional</code> dependency found in the <code>optionalDependencies</code> section of <code>package.json</code>, or has <code>"optional": true</code> set in its entry in the <code>peerDependenciesMeta</code> section of <code>package.json</code>, or a child of said dependency</li>
|
||||
<li><code>.peer</code> dependency found in the <code>peerDependencies</code> section of <code>package.json</code></li>
|
||||
<li><code>.workspace</code> dependency found in the <a href="https://docs.npmjs.com/cli/v8/using-npm/workspaces"><code>workspaces</code></a> section of <code>package.json</code></li>
|
||||
<li><code>.bundled</code> dependency found in the <code>bundleDependencies</code> section of <code>package.json</code>, or is a child of said dependency</li>
|
||||
</ul>
|
||||
<h4 id="pseudo-selectors">Pseudo Selectors</h4>
|
||||
<ul>
|
||||
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:not"><code>:not(<selector>)</code></a></li>
|
||||
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:has"><code>:has(<selector>)</code></a></li>
|
||||
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:is"><code>:is(<selector list>)</code></a></li>
|
||||
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:root"><code>:root</code></a> matches the root node/dependency</li>
|
||||
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:scope"><code>:scope</code></a> matches node/dependency it was queried against</li>
|
||||
<li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:empty"><code>:empty</code></a> when a dependency has no dependencies</li>
|
||||
<li><a href="https://docs.npmjs.com/cli/v8/configuring-npm/package-json#private"><code>:private</code></a> when a dependency is private</li>
|
||||
<li><code>:link</code> when a dependency is linked (for instance, workspaces or packages manually <a href="https://docs.npmjs.com/cli/v8/commands/npm-link"><code>linked</code></a></li>
|
||||
<li><code>:deduped</code> when a dependency has been deduped (note that this does <em>not</em> always mean the dependency has been hoisted to the root of node_modules)</li>
|
||||
<li><code>:override</code> when a dependency is an override (not implemented yet)</li>
|
||||
<li><code>:extraneous</code> when a dependency exists but is not defined as a dependency of any node</li>
|
||||
<li><code>:invalid</code> when a dependency version is out of its ancestors specified range</li>
|
||||
<li><code>:missing</code> when a dependency is not found on disk</li>
|
||||
<li><code>:semver(<spec>)</code> matching a valid <a href="https://github.com/npm/node-semver"><code>node-semver</code></a> spec</li>
|
||||
<li><code>:path(<path>)</code> <a href="https://www.npmjs.com/package/glob">glob</a> matching based on dependencies path relative to the project</li>
|
||||
<li><code>:type(<type>)</code> <a href="https://github.com/npm/npm-package-arg#result-object">based on currently recognized types</a></li>
|
||||
</ul>
|
||||
<h4 id="attribute-selectors"><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors">Attribute Selectors</a></h4>
|
||||
<p>The attribute selector evaluates the key/value pairs in <code>package.json</code> if they are <code>String</code>s.</p>
|
||||
<ul>
|
||||
<li><code>[]</code> attribute selector (ie. existence of attribute)</li>
|
||||
<li><code>[attribute=value]</code> attribute value is equivalant...</li>
|
||||
<li><code>[attribute~=value]</code> attribute value contains word...</li>
|
||||
<li><code>[attribute*=value]</code> attribute value contains string...</li>
|
||||
<li><code>[attribute|=value]</code> attribute value is equal to or starts with...</li>
|
||||
<li><code>[attribute^=value]</code> attribute value starts with...</li>
|
||||
<li><code>[attribute$=value]</code> attribute value ends with...</li>
|
||||
</ul>
|
||||
<h4 id="array--object-attribute-selectors"><code>Array</code> & <code>Object</code> Attribute Selectors</h4>
|
||||
<p>The generic <code>:attr()</code> pseudo selector standardizes a pattern which can be used for attribute selection of <code>Object</code>s, <code>Array</code>s or <code>Arrays</code> of <code>Object</code>s accessible via <code>Arborist</code>'s <code>Node.package</code> metadata. This allows for iterative attribute selection beyond top-level <code>String</code> evaluation. The last argument passed to <code>:attr()</code> must be an <code>attribute</code> selector or a nested <code>:attr()</code>. See examples below:</p>
|
||||
<h4 id="objects"><code>Objects</code></h4>
|
||||
<pre lang="css"><code>/* return dependencies that have a `scripts.test` containing `"tap"` */
|
||||
*:attr(scripts, [test~=tap])
|
||||
</code></pre>
|
||||
<h4 id="nested-objects">Nested <code>Objects</code></h4>
|
||||
<p>Nested objects are expressed as sequential arguments to <code>:attr()</code>.</p>
|
||||
<pre lang="css"><code>/* return dependencies that have a testling config for opera browsers */
|
||||
*:attr(testling, browsers, [~=opera])
|
||||
</code></pre>
|
||||
<h4 id="arrays"><code>Arrays</code></h4>
|
||||
<p><code>Array</code>s specifically uses a special/reserved <code>.</code> character in place of a typical attribute name. <code>Arrays</code> also support exact <code>value</code> matching when a <code>String</code> is passed to the selector.</p>
|
||||
<h5 id="example-of-an-array-attribute-selection">Example of an <code>Array</code> Attribute Selection:</h5>
|
||||
<pre lang="css"><code>/* removes the distinction between properties & arrays */
|
||||
/* ie. we'd have to check the property & iterate to match selection */
|
||||
*:attr([keywords^=react])
|
||||
*:attr(contributors, :attr([name~=Jordan]))
|
||||
</code></pre>
|
||||
<h5 id="example-of-an-array-matching-directly-to-a-value">Example of an <code>Array</code> matching directly to a value:</h5>
|
||||
<pre lang="css"><code>/* return dependencies that have the exact keyword "react" */
|
||||
/* this is equivalent to `*:keywords([value="react"])` */
|
||||
*:attr([keywords=react])
|
||||
</code></pre>
|
||||
<h5 id="example-of-an-array-of-objects">Example of an <code>Array</code> of <code>Object</code>s:</h5>
|
||||
<pre lang="css"><code>/* returns */
|
||||
*:attr(contributors, [email=ruyadorno@github.com])
|
||||
</code></pre>
|
||||
<h3 id="groups">Groups</h3>
|
||||
<p>Dependency groups are defined by the package relationships to their ancestors (ie. the dependency types that are defined in <code>package.json</code>). This approach is user-centric as the ecosystem has been taught to think about dependencies in these groups first-and-foremost. Dependencies are allowed to be included in multiple groups (ex. a <code>prod</code> dependency may also be a <code>dev</code> dependency (in that it's also required by another <code>dev</code> dependency) & may also be <code>bundled</code> - a selector for that type of dependency would look like: <code>*.prod.dev.bundled</code>).</p>
|
||||
<ul>
|
||||
<li><code>.prod</code></li>
|
||||
<li><code>.dev</code></li>
|
||||
<li><code>.optional</code></li>
|
||||
<li><code>.peer</code></li>
|
||||
<li><code>.bundled</code></li>
|
||||
<li><code>.workspace</code></li>
|
||||
</ul>
|
||||
<p>Please note that currently <code>workspace</code> deps are always <code>prod</code> dependencies. Additionally the <code>.root</code> dependency is also considered a <code>prod</code> dependency.</p>
|
||||
<h3 id="programmatic-usage">Programmatic Usage</h3>
|
||||
<ul>
|
||||
<li><code>Arborist</code>'s <code>Node</code> Class has a <code>.querySelectorAll()</code> method
|
||||
<ul>
|
||||
<li>this method will return a filtered, flattened dependency Arborist <code>Node</code> list based on a valid query selector</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<pre lang="js"><code>const Arborist = require('@npmcli/arborist')
|
||||
const arb = new Arborist({})
|
||||
</code></pre>
|
||||
<pre lang="js"><code>// root-level
|
||||
arb.loadActual((tree) => {
|
||||
// query all production dependencies
|
||||
const results = await tree.querySelectorAll('.prod')
|
||||
console.log(results)
|
||||
})
|
||||
</code></pre>
|
||||
<pre lang="js"><code>// iterative
|
||||
arb.loadActual((tree) => {
|
||||
// query for the deduped version of react
|
||||
const results = await tree.querySelectorAll('#react:not(:deduped)')
|
||||
// query the deduped react for git deps
|
||||
const deps = await results[0].querySelectorAll(':type(git)')
|
||||
console.log(deps)
|
||||
})
|
||||
</code></pre>
|
||||
<h2 id="see-also">See Also</h2>
|
||||
<ul>
|
||||
<li><a href="../commands/npm-query.html">npm query</a></li>
|
||||
<li>[@npmcli/arborist](<a href="https://npm.im/@npmcli/arborist%5D">https://npm.im/@npmcli/arborist]</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<footer id="edit">
|
||||
<a href="https://github.com/npm/cli/edit/latest/docs/content/using-npm/dependency-selectors.md">
|
||||
<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
|
||||
<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path>
|
||||
</svg>
|
||||
Edit this page on GitHub
|
||||
</a>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</body></html>
|
||||
Vendored
+11
-32
@@ -1,31 +1,6 @@
|
||||
const path = require('path')
|
||||
const libexec = require('libnpmexec')
|
||||
const BaseCommand = require('../base-command.js')
|
||||
const getLocationMsg = require('../exec/get-workspace-location-msg.js')
|
||||
|
||||
// it's like this:
|
||||
//
|
||||
// npm x pkg@version <-- runs the bin named "pkg" or the only bin if only 1
|
||||
//
|
||||
// { name: 'pkg', bin: { pkg: 'pkg.js', foo: 'foo.js' }} <-- run pkg
|
||||
// { name: 'pkg', bin: { foo: 'foo.js' }} <-- run foo?
|
||||
//
|
||||
// npm x -p pkg@version -- foo
|
||||
//
|
||||
// npm x -p pkg@version -- foo --registry=/dev/null
|
||||
//
|
||||
// const pkg = npm.config.get('package') || getPackageFrom(args[0])
|
||||
// const cmd = getCommand(pkg, args[0])
|
||||
// --> npm x -c 'cmd ...args.slice(1)'
|
||||
//
|
||||
// we've resolved cmd and args, and escaped them properly, and installed the
|
||||
// relevant packages.
|
||||
//
|
||||
// Add the ${npx install prefix}/node_modules/.bin to PATH
|
||||
//
|
||||
// pkg = readPackageJson('./package.json')
|
||||
// pkg.scripts.___npx = ${the -c arg}
|
||||
// runScript({ pkg, event: 'npx', ... })
|
||||
// process.env.npm_lifecycle_event = 'npx'
|
||||
|
||||
class Exec extends BaseCommand {
|
||||
static description = 'Run a command from a local or remote npm package'
|
||||
@@ -49,8 +24,10 @@ class Exec extends BaseCommand {
|
||||
static isShellout = true
|
||||
|
||||
async exec (_args, { locationMsg, runPath } = {}) {
|
||||
const path = this.npm.localPrefix
|
||||
// This is where libnpmexec will look for locally installed packages
|
||||
const localPrefix = this.npm.localPrefix
|
||||
|
||||
// This is where libnpmexec will actually run the scripts from
|
||||
if (!runPath) {
|
||||
runPath = process.cwd()
|
||||
}
|
||||
@@ -61,8 +38,9 @@ class Exec extends BaseCommand {
|
||||
flatOptions,
|
||||
localBin,
|
||||
globalBin,
|
||||
globalDir,
|
||||
} = this.npm
|
||||
const output = (...outputArgs) => this.npm.output(...outputArgs)
|
||||
const output = this.npm.output.bind(this.npm)
|
||||
const scriptShell = this.npm.config.get('script-shell') || undefined
|
||||
const packages = this.npm.config.get('package')
|
||||
const yes = this.npm.config.get('yes')
|
||||
@@ -81,9 +59,10 @@ class Exec extends BaseCommand {
|
||||
localBin,
|
||||
locationMsg,
|
||||
globalBin,
|
||||
globalPath: path.resolve(globalDir, '..'),
|
||||
output,
|
||||
packages,
|
||||
path,
|
||||
path: localPrefix,
|
||||
runPath,
|
||||
scriptShell,
|
||||
yes,
|
||||
@@ -92,10 +71,10 @@ class Exec extends BaseCommand {
|
||||
|
||||
async execWorkspaces (args, filters) {
|
||||
await this.setWorkspaces(filters)
|
||||
const color = this.npm.color
|
||||
|
||||
for (const path of this.workspacePaths) {
|
||||
const locationMsg = await getLocationMsg({ color, path })
|
||||
for (const [name, path] of this.workspaces) {
|
||||
const locationMsg =
|
||||
`in workspace ${this.npm.chalk.green(name)} at location:\n${this.npm.chalk.dim(path)}`
|
||||
await this.exec(args, { locationMsg, runPath: path })
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-9
@@ -10,7 +10,6 @@ const PackageJson = require('@npmcli/package-json')
|
||||
const log = require('../utils/log-shim.js')
|
||||
const updateWorkspaces = require('../workspaces/update-workspaces.js')
|
||||
|
||||
const getLocationMsg = require('../exec/get-workspace-location-msg.js')
|
||||
const BaseCommand = require('../base-command.js')
|
||||
|
||||
class Init extends BaseCommand {
|
||||
@@ -119,13 +118,7 @@ class Init extends BaseCommand {
|
||||
localBin,
|
||||
globalBin,
|
||||
} = this.npm
|
||||
// this function is definitely called. But because of coverage map stuff
|
||||
// it ends up both uncovered, and the coverage report doesn't even mention.
|
||||
// the tests do assert that some output happens, so we know this line is
|
||||
// being hit.
|
||||
/* istanbul ignore next */
|
||||
const output = (...outputArgs) => this.npm.output(...outputArgs)
|
||||
const locationMsg = await getLocationMsg({ color, path })
|
||||
const output = this.npm.output.bind(this.npm)
|
||||
const runPath = path
|
||||
const scriptShell = this.npm.config.get('script-shell') || undefined
|
||||
const yes = this.npm.config.get('yes')
|
||||
@@ -135,7 +128,6 @@ class Init extends BaseCommand {
|
||||
args: newArgs,
|
||||
color,
|
||||
localBin,
|
||||
locationMsg,
|
||||
globalBin,
|
||||
output,
|
||||
path,
|
||||
|
||||
Vendored
+1
-1
@@ -92,7 +92,7 @@ class LS extends ArboristWorkspaceCmd {
|
||||
}
|
||||
|
||||
if (this.npm.flatOptions.includeWorkspaceRoot
|
||||
&& !edge.to.isWorkspace) {
|
||||
&& edge.to && !edge.to.isWorkspace) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Vendored
+104
@@ -0,0 +1,104 @@
|
||||
'use strict'
|
||||
|
||||
const { resolve } = require('path')
|
||||
const Arborist = require('@npmcli/arborist')
|
||||
const BaseCommand = require('../base-command.js')
|
||||
|
||||
class QuerySelectorItem {
|
||||
constructor (node) {
|
||||
// all enumerable properties from the target
|
||||
Object.assign(this, node.target.package)
|
||||
|
||||
// append extra info
|
||||
this.pkgid = node.target.pkgid
|
||||
this.location = node.target.location
|
||||
this.path = node.target.path
|
||||
this.realpath = node.target.realpath
|
||||
this.resolved = node.target.resolved
|
||||
this.from = []
|
||||
this.to = []
|
||||
this.dev = node.target.dev
|
||||
this.inBundle = node.target.inBundle
|
||||
this.deduped = this.from.length > 1
|
||||
for (const edge of node.target.edgesIn) {
|
||||
this.from.push(edge.from.location)
|
||||
}
|
||||
for (const [, edge] of node.target.edgesOut) {
|
||||
if (edge.to) {
|
||||
this.to.push(edge.to.location)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Query extends BaseCommand {
|
||||
#response = [] // response is the query response
|
||||
#seen = new Set() // paths we've seen so we can keep response deduped
|
||||
|
||||
static description = 'Retrieve a filtered list of packages'
|
||||
static name = 'query'
|
||||
static usage = ['<selector>']
|
||||
|
||||
static ignoreImplicitWorkspace = false
|
||||
|
||||
static params = [
|
||||
'global',
|
||||
'workspace',
|
||||
'workspaces',
|
||||
'include-workspace-root',
|
||||
]
|
||||
|
||||
get parsedResponse () {
|
||||
return JSON.stringify(this.#response, null, 2)
|
||||
}
|
||||
|
||||
async exec (args) {
|
||||
// one dir up from wherever node_modules lives
|
||||
const where = resolve(this.npm.dir, '..')
|
||||
const opts = {
|
||||
...this.npm.flatOptions,
|
||||
path: where,
|
||||
}
|
||||
const arb = new Arborist(opts)
|
||||
const tree = await arb.loadActual(opts)
|
||||
const items = await tree.querySelectorAll(args[0])
|
||||
this.buildResponse(items)
|
||||
|
||||
this.npm.output(this.parsedResponse)
|
||||
}
|
||||
|
||||
async execWorkspaces (args, filters) {
|
||||
await this.setWorkspaces(filters)
|
||||
const opts = {
|
||||
...this.npm.flatOptions,
|
||||
path: this.npm.prefix,
|
||||
}
|
||||
const arb = new Arborist(opts)
|
||||
const tree = await arb.loadActual(opts)
|
||||
for (const workspacePath of this.workspacePaths) {
|
||||
let items
|
||||
if (workspacePath === tree.root.path) {
|
||||
// include-workspace-root
|
||||
items = await tree.querySelectorAll(args[0])
|
||||
} else {
|
||||
const [workspace] = await tree.querySelectorAll(`.workspace:path(${workspacePath})`)
|
||||
items = await workspace.target.querySelectorAll(args[0])
|
||||
}
|
||||
this.buildResponse(items)
|
||||
}
|
||||
this.npm.output(this.parsedResponse)
|
||||
}
|
||||
|
||||
// builds a normalized inventory
|
||||
buildResponse (items) {
|
||||
for (const node of items) {
|
||||
if (!this.#seen.has(node.target.location)) {
|
||||
const item = new QuerySelectorItem(node)
|
||||
this.#response.push(item)
|
||||
this.#seen.add(item.location)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Query
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
const chalk = require('chalk')
|
||||
const readPackageJson = require('read-package-json-fast')
|
||||
|
||||
const nocolor = {
|
||||
dim: s => s,
|
||||
green: s => s,
|
||||
}
|
||||
|
||||
const getLocationMsg = async ({ color, path }) => {
|
||||
const colorize = color ? chalk : nocolor
|
||||
const { _id } =
|
||||
await readPackageJson(`${path}/package.json`)
|
||||
.catch(() => ({}))
|
||||
|
||||
const workspaceMsg = _id
|
||||
? ` in workspace ${colorize.green(_id)}`
|
||||
: ` in a ${colorize.green('new')} workspace`
|
||||
const locationMsg = ` at location:\n${
|
||||
colorize.dim(path)
|
||||
}`
|
||||
|
||||
return `${workspaceMsg}${locationMsg}`
|
||||
}
|
||||
|
||||
module.exports = getLocationMsg
|
||||
Vendored
+1
@@ -114,6 +114,7 @@ const cmdList = [
|
||||
'profile',
|
||||
'prune',
|
||||
'publish',
|
||||
'query',
|
||||
'rebuild',
|
||||
'repo',
|
||||
'restart',
|
||||
|
||||
+19
-1
@@ -1470,7 +1470,7 @@ define('package', {
|
||||
hint: '<package-spec>',
|
||||
type: [String, Array],
|
||||
description: `
|
||||
The package to install for [\`npm exec\`](/commands/npm-exec)
|
||||
The package or packages to install for [\`npm exec\`](/commands/npm-exec)
|
||||
`,
|
||||
flatten,
|
||||
})
|
||||
@@ -1649,6 +1649,24 @@ define('registry', {
|
||||
flatten,
|
||||
})
|
||||
|
||||
define('replace-registry-host', {
|
||||
default: 'npmjs',
|
||||
hint: '<npmjs|never|always> | hostname',
|
||||
type: ['npmjs', 'never', 'always', String],
|
||||
description: `
|
||||
Defines behavior for replacing the registry host in a lockfile with the
|
||||
configured registry.
|
||||
|
||||
The default behavior is to replace package dist URLs from the default
|
||||
registry (https://registry.npmjs.org) to the configured registry. If set to
|
||||
"never", then use the registry value. If set to "always", then replace the
|
||||
registry host with the configured host every time.
|
||||
|
||||
You may also specify a bare hostname (e.g., "registry.npmjs.org").
|
||||
`,
|
||||
flatten,
|
||||
})
|
||||
|
||||
define('save', {
|
||||
default: true,
|
||||
defaultDescription: `\`true\` unless when using \`npm update\` where it
|
||||
|
||||
+9
@@ -34,6 +34,11 @@ const promptOpen = async (npm, url, title, prompt, emitter) => {
|
||||
})
|
||||
|
||||
const tryOpen = await new Promise(resolve => {
|
||||
rl.on('SIGINT', () => {
|
||||
rl.close()
|
||||
resolve('SIGINT')
|
||||
})
|
||||
|
||||
rl.question(prompt, () => {
|
||||
resolve(true)
|
||||
})
|
||||
@@ -50,6 +55,10 @@ const promptOpen = async (npm, url, title, prompt, emitter) => {
|
||||
}
|
||||
})
|
||||
|
||||
if (tryOpen === 'SIGINT') {
|
||||
throw new Error('canceled')
|
||||
}
|
||||
|
||||
if (!tryOpen) {
|
||||
return
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-ACCESS" "1" "July 2022" "" ""
|
||||
.TH "NPM\-ACCESS" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-access\fR \- Set access level on published packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-ADDUSER" "1" "July 2022" "" ""
|
||||
.TH "NPM\-ADDUSER" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-adduser\fR \- Add a registry user account
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-AUDIT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-AUDIT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-audit\fR \- Run a security audit
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-BIN" "1" "July 2022" "" ""
|
||||
.TH "NPM\-BIN" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-bin\fR \- Display npm bin folder
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-BUGS" "1" "July 2022" "" ""
|
||||
.TH "NPM\-BUGS" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-bugs\fR \- Report bugs for a package in a web browser
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-CACHE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-CACHE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-cache\fR \- Manipulates packages cache
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-CI" "1" "July 2022" "" ""
|
||||
.TH "NPM\-CI" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-ci\fR \- Clean install a project
|
||||
.SS Synopsis
|
||||
@@ -66,7 +66,7 @@ added 154 packages in 5s
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
Configure Travis to build using \fBnpm ci\fP instead of \fBnpm install\fP:
|
||||
Configure Travis CI to build using \fBnpm ci\fP instead of \fBnpm install\fP:
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-COMPLETION" "1" "July 2022" "" ""
|
||||
.TH "NPM\-COMPLETION" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-completion\fR \- Tab Completion for npm
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-CONFIG" "1" "July 2022" "" ""
|
||||
.TH "NPM\-CONFIG" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-config\fR \- Manage the npm configuration files
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-DEDUPE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-DEDUPE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-dedupe\fR \- Reduce duplication in the package tree
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-DEPRECATE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-DEPRECATE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-deprecate\fR \- Deprecate a version of a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-DIFF" "1" "July 2022" "" ""
|
||||
.TH "NPM\-DIFF" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-diff\fR \- The registry diff command
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-DIST\-TAG" "1" "July 2022" "" ""
|
||||
.TH "NPM\-DIST\-TAG" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-dist-tag\fR \- Modify package distribution tags
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-DOCS" "1" "July 2022" "" ""
|
||||
.TH "NPM\-DOCS" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-docs\fR \- Open documentation for a package in a web browser
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-DOCTOR" "1" "July 2022" "" ""
|
||||
.TH "NPM\-DOCTOR" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-doctor\fR \- Check your npm environment
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-EDIT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-EDIT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-edit\fR \- Edit an installed package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-EXEC" "1" "July 2022" "" ""
|
||||
.TH "NPM\-EXEC" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-exec\fR \- Run a command from a local or remote npm package
|
||||
.SS Synopsis
|
||||
@@ -129,7 +129,7 @@ Type: String (can be set multiple times)
|
||||
|
||||
.RE
|
||||
.P
|
||||
The package to install for npm help \fBexec\fP
|
||||
The package or packages to install for npm help \fBexec\fP
|
||||
.SS \fBcall\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-EXPLAIN" "1" "July 2022" "" ""
|
||||
.TH "NPM\-EXPLAIN" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-explain\fR \- Explain installed packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-EXPLORE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-EXPLORE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-explore\fR \- Browse an installed package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-FIND\-DUPES" "1" "July 2022" "" ""
|
||||
.TH "NPM\-FIND\-DUPES" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-find-dupes\fR \- Find duplication in the package tree
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-FUND" "1" "July 2022" "" ""
|
||||
.TH "NPM\-FUND" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-fund\fR \- Retrieve funding information
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-HELP\-SEARCH" "1" "July 2022" "" ""
|
||||
.TH "NPM\-HELP\-SEARCH" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-help-search\fR \- Search npm help documentation
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-HELP" "1" "July 2022" "" ""
|
||||
.TH "NPM\-HELP" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-help\fR \- Get help on npm
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-HOOK" "1" "July 2022" "" ""
|
||||
.TH "NPM\-HOOK" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-hook\fR \- Manage registry hooks
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-INIT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-INIT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-init\fR \- Create a package\.json file
|
||||
.SS Synopsis
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-INSTALL\-CI\-TEST" "1" "July 2022" "" ""
|
||||
.TH "NPM\-INSTALL\-CI\-TEST" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-install-ci-test\fR \- Install a project with a clean slate and run tests
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-INSTALL\-TEST" "1" "July 2022" "" ""
|
||||
.TH "NPM\-INSTALL\-TEST" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-install-test\fR \- Install package(s) and run tests
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-INSTALL" "1" "July 2022" "" ""
|
||||
.TH "NPM\-INSTALL" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-install\fR \- Install a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-LINK" "1" "July 2022" "" ""
|
||||
.TH "NPM\-LINK" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-link\fR \- Symlink a package folder
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-LOGOUT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-LOGOUT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-logout\fR \- Log out of the registry
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-LS" "1" "July 2022" "" ""
|
||||
.TH "NPM\-LS" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-ls\fR \- List installed packages
|
||||
.SS Synopsis
|
||||
@@ -26,7 +26,7 @@ example, running \fBnpm ls promzard\fP in npm's source tree will show:
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
npm@8\.15\.1 /path/to/npm
|
||||
npm@8\.16\.0 /path/to/npm
|
||||
└─┬ init\-package\-json@0\.0\.4
|
||||
└── promzard@0\.1\.5
|
||||
.fi
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-ORG" "1" "July 2022" "" ""
|
||||
.TH "NPM\-ORG" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-org\fR \- Manage orgs
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-OUTDATED" "1" "July 2022" "" ""
|
||||
.TH "NPM\-OUTDATED" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-outdated\fR \- Check for outdated packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-OWNER" "1" "July 2022" "" ""
|
||||
.TH "NPM\-OWNER" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-owner\fR \- Manage package owners
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PACK" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PACK" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-pack\fR \- Create a tarball from a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PING" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PING" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-ping\fR \- Ping npm registry
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PKG" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PKG" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-pkg\fR \- Manages your package\.json
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PREFIX" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PREFIX" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-prefix\fR \- Display prefix
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PROFILE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PROFILE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-profile\fR \- Change settings on your registry profile
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PRUNE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PRUNE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-prune\fR \- Remove extraneous packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-PUBLISH" "1" "July 2022" "" ""
|
||||
.TH "NPM\-PUBLISH" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-publish\fR \- Publish a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+240
@@ -0,0 +1,240 @@
|
||||
.TH "NPM\-QUERY" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-query\fR \- Dependency selector query
|
||||
.SS Synopsis
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
npm query <selector>
|
||||
.fi
|
||||
.RE
|
||||
.SS Description
|
||||
.P
|
||||
The \fBnpm query\fP command allows for usage of css selectors in order to retrieve
|
||||
an array of dependency objects\.
|
||||
.SS Piping npm query to other commands
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
# find all dependencies with postinstall scripts & uninstall them
|
||||
npm query ":attr(scripts, [postinstall])" | jq 'map(\.name)|join("\\n")' \-r | xargs \-I {} npm uninstall {}
|
||||
|
||||
# find all git dependencies & explain who requires them
|
||||
npm query ":type(git)" | jq 'map(\.name)' | xargs \-I {} npm why {}
|
||||
.fi
|
||||
.RE
|
||||
.SS Extended Use Cases & Queries
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
// all deps
|
||||
*
|
||||
|
||||
// all direct deps
|
||||
:root > *
|
||||
|
||||
// direct production deps
|
||||
:root > \.prod
|
||||
|
||||
// direct development deps
|
||||
:root > \.dev
|
||||
|
||||
// any peer dep of a direct deps
|
||||
:root > * > \.peer
|
||||
|
||||
// any workspace dep
|
||||
\|\.workspace
|
||||
|
||||
// all workspaces that depend on another workspace
|
||||
\|\.workspace > \.workspace
|
||||
|
||||
// all workspaces that have peer deps
|
||||
\|\.workspace:has(\.peer)
|
||||
|
||||
// any dep named "lodash"
|
||||
// equivalent to [name="lodash"]
|
||||
#lodash
|
||||
|
||||
// any deps named "lodash" & within semver range ^"1\.2\.3"
|
||||
#lodash@^1\.2\.3
|
||||
// equivalent to\.\.\.
|
||||
[name="lodash"]:semver(^1\.2\.3)
|
||||
|
||||
// get the hoisted node for a given semver range
|
||||
#lodash@^1\.2\.3:not(:deduped)
|
||||
|
||||
// querying deps with a specific version
|
||||
#lodash@2\.1\.5
|
||||
// equivalent to\.\.\.
|
||||
[name="lodash"][version="2\.1\.5"]
|
||||
|
||||
// has any deps
|
||||
:has(*)
|
||||
|
||||
// deps with no other deps (ie\. "leaf" nodes)
|
||||
:empty
|
||||
|
||||
// manually querying git dependencies
|
||||
[repository^=github:],
|
||||
[repository^=git:],
|
||||
[repository^=https://github\.com],
|
||||
[repository^=http://github\.com],
|
||||
[repository^=https://github\.com],
|
||||
[repository^=+git:\.\.\.]
|
||||
|
||||
// querying for all git dependencies
|
||||
:type(git)
|
||||
|
||||
// get production dependencies that aren't also dev deps
|
||||
\|\.prod:not(\.dev)
|
||||
|
||||
// get dependencies with specific licenses
|
||||
[license=MIT], [license=ISC]
|
||||
|
||||
// find all packages that have @ruyadorno as a contributor
|
||||
:attr(contributors, [email=ruyadorno@github\.com])
|
||||
.fi
|
||||
.RE
|
||||
.SS Example Response Output
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
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
|
||||
|
||||
.RE
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
[
|
||||
{
|
||||
"name": "",
|
||||
"version": "",
|
||||
"description": "",
|
||||
"homepage": "",
|
||||
"bugs": {},
|
||||
"author": {},
|
||||
"license": {},
|
||||
"funding": {},
|
||||
"files": [],
|
||||
"main": "",
|
||||
"browser": "",
|
||||
"bin": {},
|
||||
"man": [],
|
||||
"directories": {},
|
||||
"repository": {},
|
||||
"scripts": {},
|
||||
"config": {},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": {},
|
||||
"peerDependencies": {},
|
||||
"peerDependenciesMeta": {},
|
||||
"engines": {},
|
||||
"os": [],
|
||||
"cpu": [],
|
||||
"workspaces": {},
|
||||
"keywords": [],
|
||||
\.\.\.
|
||||
},
|
||||
\.\.\.
|
||||
.fi
|
||||
.RE
|
||||
.SS Configuration
|
||||
.SS \fBglobal\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Default: false
|
||||
.IP \(bu 2
|
||||
Type: Boolean
|
||||
|
||||
.RE
|
||||
.P
|
||||
Operates in "global" mode, so that packages are installed into the \fBprefix\fP
|
||||
folder instead of the current working directory\. See
|
||||
npm help folders for more on the differences in behavior\.
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
packages are installed into the \fB{prefix}/lib/node_modules\fP folder, instead
|
||||
of the current working directory\.
|
||||
.IP \(bu 2
|
||||
bin files are linked to \fB{prefix}/bin\fP
|
||||
.IP \(bu 2
|
||||
man pages are linked to \fB{prefix}/share/man\fP
|
||||
|
||||
.RE
|
||||
.SS \fBworkspace\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Default:
|
||||
.IP \(bu 2
|
||||
Type: String (can be set multiple times)
|
||||
|
||||
.RE
|
||||
.P
|
||||
Enable running a command in the context of the configured workspaces of the
|
||||
current project while filtering by running only the workspaces defined by
|
||||
this configuration option\.
|
||||
.P
|
||||
Valid values for the \fBworkspace\fP config are either:
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Workspace names
|
||||
.IP \(bu 2
|
||||
Path to a workspace directory
|
||||
.IP \(bu 2
|
||||
Path to a parent workspace directory (will result in selecting all
|
||||
workspaces within that folder)
|
||||
|
||||
.RE
|
||||
.P
|
||||
When set for the \fBnpm init\fP command, this may be set to the folder of a
|
||||
workspace which does not yet exist, to create the folder and set it up as a
|
||||
brand new workspace within the project\.
|
||||
.P
|
||||
This value is not exported to the environment for child processes\.
|
||||
.SS \fBworkspaces\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Default: null
|
||||
.IP \(bu 2
|
||||
Type: null or Boolean
|
||||
|
||||
.RE
|
||||
.P
|
||||
Set to true to run the command in the context of \fBall\fR configured
|
||||
workspaces\.
|
||||
.P
|
||||
Explicitly setting this to false will cause commands like \fBinstall\fP to
|
||||
ignore workspaces altogether\. When not set explicitly:
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Commands that operate on the \fBnode_modules\fP tree (install, update, etc\.)
|
||||
will link workspaces into the \fBnode_modules\fP folder\. \- Commands that do
|
||||
other things (test, exec, publish, etc\.) will operate on the root project,
|
||||
\fIunless\fR one or more workspaces are specified in the \fBworkspace\fP config\.
|
||||
|
||||
.RE
|
||||
.P
|
||||
This value is not exported to the environment for child processes\.
|
||||
.SS \fBinclude\-workspace\-root\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Default: false
|
||||
.IP \(bu 2
|
||||
Type: Boolean
|
||||
|
||||
.RE
|
||||
.P
|
||||
Include the workspace root when workspaces are enabled for a command\.
|
||||
.P
|
||||
When false, specifying individual workspaces via the \fBworkspace\fP config, or
|
||||
all workspaces via the \fBworkspaces\fP flag, will cause npm to operate only on
|
||||
the specified workspaces, and not on the root project\.
|
||||
.P
|
||||
This value is not exported to the environment for child processes\.
|
||||
.SH See Also
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
npm help dependency selector
|
||||
|
||||
.RE
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-REBUILD" "1" "July 2022" "" ""
|
||||
.TH "NPM\-REBUILD" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-rebuild\fR \- Rebuild a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-REPO" "1" "July 2022" "" ""
|
||||
.TH "NPM\-REPO" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-repo\fR \- Open package repository page in the browser
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-RESTART" "1" "July 2022" "" ""
|
||||
.TH "NPM\-RESTART" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-restart\fR \- Restart a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-ROOT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-ROOT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-root\fR \- Display npm root
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-RUN\-SCRIPT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-RUN\-SCRIPT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-run-script\fR \- Run arbitrary package scripts
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-SEARCH" "1" "July 2022" "" ""
|
||||
.TH "NPM\-SEARCH" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-search\fR \- Search for packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-SET\-SCRIPT" "1" "July 2022" "" ""
|
||||
.TH "NPM\-SET\-SCRIPT" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-set-script\fR \- Set tasks in the scripts section of package\.json
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-SHRINKWRAP" "1" "July 2022" "" ""
|
||||
.TH "NPM\-SHRINKWRAP" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-shrinkwrap\fR \- Lock down dependency versions for publication
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-STAR" "1" "July 2022" "" ""
|
||||
.TH "NPM\-STAR" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-star\fR \- Mark your favorite packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-STARS" "1" "July 2022" "" ""
|
||||
.TH "NPM\-STARS" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-stars\fR \- View packages marked as favorites
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-START" "1" "July 2022" "" ""
|
||||
.TH "NPM\-START" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-start\fR \- Start a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-STOP" "1" "July 2022" "" ""
|
||||
.TH "NPM\-STOP" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-stop\fR \- Stop a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-TEAM" "1" "July 2022" "" ""
|
||||
.TH "NPM\-TEAM" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-team\fR \- Manage organization teams and team memberships
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-TEST" "1" "July 2022" "" ""
|
||||
.TH "NPM\-TEST" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-test\fR \- Test a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-TOKEN" "1" "July 2022" "" ""
|
||||
.TH "NPM\-TOKEN" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-token\fR \- Manage your authentication tokens
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-UNINSTALL" "1" "July 2022" "" ""
|
||||
.TH "NPM\-UNINSTALL" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-uninstall\fR \- Remove a package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-UNPUBLISH" "1" "July 2022" "" ""
|
||||
.TH "NPM\-UNPUBLISH" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-unpublish\fR \- Remove a package from the registry
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-UNSTAR" "1" "July 2022" "" ""
|
||||
.TH "NPM\-UNSTAR" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-unstar\fR \- Remove an item from your favorite packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-UPDATE" "1" "July 2022" "" ""
|
||||
.TH "NPM\-UPDATE" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-update\fR \- Update packages
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-VERSION" "1" "July 2022" "" ""
|
||||
.TH "NPM\-VERSION" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-version\fR \- Bump a package version
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-VIEW" "1" "July 2022" "" ""
|
||||
.TH "NPM\-VIEW" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-view\fR \- View registry info
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-WHOAMI" "1" "July 2022" "" ""
|
||||
.TH "NPM\-WHOAMI" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-whoami\fR \- Display npm username
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+2
-2
@@ -1,10 +1,10 @@
|
||||
.TH "NPM" "1" "July 2022" "" ""
|
||||
.TH "NPM" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm\fR \- javascript package manager
|
||||
.SS Synopsis
|
||||
.SS Version
|
||||
.P
|
||||
8\.15\.1
|
||||
8\.16\.0
|
||||
.SS Description
|
||||
.P
|
||||
npm is the package manager for the Node JavaScript platform\. It puts
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPX" "1" "July 2022" "" ""
|
||||
.TH "NPX" "1" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpx\fR \- Run a command from a local or remote npm package
|
||||
.SS Synopsis
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "FOLDERS" "5" "July 2022" "" ""
|
||||
.TH "FOLDERS" "5" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBfolders\fR \- Folder Structures Used by npm
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "INSTALL" "5" "July 2022" "" ""
|
||||
.TH "INSTALL" "5" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBinstall\fR \- Download and install node and npm
|
||||
.SS Description
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPM\-SHRINKWRAP\.JSON" "5" "July 2022" "" ""
|
||||
.TH "NPM\-SHRINKWRAP\.JSON" "5" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpm-shrinkwrap.json\fR \- A publishable lockfile
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "NPMRC" "5" "July 2022" "" ""
|
||||
.TH "NPMRC" "5" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBnpmrc\fR \- The npm config files
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "PACKAGE\.JSON" "5" "July 2022" "" ""
|
||||
.TH "PACKAGE\.JSON" "5" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBpackage.json\fR \- Specifics of npm's package\.json handling
|
||||
.SS Description
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "PACKAGE\-LOCK\.JSON" "5" "July 2022" "" ""
|
||||
.TH "PACKAGE\-LOCK\.JSON" "5" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBpackage-lock.json\fR \- A manifestation of the manifest
|
||||
.SS Description
|
||||
|
||||
Vendored
+20
-2
@@ -1,4 +1,4 @@
|
||||
.TH "CONFIG" "7" "July 2022" "" ""
|
||||
.TH "CONFIG" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBconfig\fR \- More than you probably want to know about npm configuration
|
||||
.SS Description
|
||||
@@ -1315,7 +1315,7 @@ Type: String (can be set multiple times)
|
||||
|
||||
.RE
|
||||
.P
|
||||
The package to install for npm help \fBexec\fP
|
||||
The package or packages to install for npm help \fBexec\fP
|
||||
.SS \fBpackage\-lock\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
@@ -1460,6 +1460,24 @@ Type: URL
|
||||
.RE
|
||||
.P
|
||||
The base URL of the npm registry\.
|
||||
.SS \fBreplace\-registry\-host\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Default: "npmjs"
|
||||
.IP \(bu 2
|
||||
Type: "npmjs", "never", "always", or String
|
||||
|
||||
.RE
|
||||
.P
|
||||
Defines behavior for replacing the registry host in a lockfile with the
|
||||
configured registry\.
|
||||
.P
|
||||
The default behavior is to replace package dist URLs from the default
|
||||
registry (https://registry\.npmjs\.org) to the configured registry\. If set to
|
||||
"never", then use the registry value\. If set to "always", then replace the
|
||||
registry host with the configured host every time\.
|
||||
.P
|
||||
You may also specify a bare hostname (e\.g\., "registry\.npmjs\.org")\.
|
||||
.SS \fBsave\fP
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
.TH "DEPENDENCY" "" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBDependency\fR
|
||||
.SS Description
|
||||
.P
|
||||
The npm help \fBquery\fP commmand exposes a new dependency selector syntax (informed by & respecting many aspects of the CSS Selectors 4 Spec \fIhttps://dev\.w3\.org/csswg/selectors4/#relational)\fR which:
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
Standardizes the shape of, & querying of, dependency graphs with a robust object model, metadata & selector syntax
|
||||
.IP \(bu 2
|
||||
Leverages existing, known language syntax & operators from CSS to make disparate package information broadly accessible
|
||||
.IP \(bu 2
|
||||
Unlocks the ability to answer complex, multi\-faceted questions about dependencies, their relationships & associative metadata
|
||||
.IP \(bu 2
|
||||
Consolidates redundant logic of similar query commands in \fBnpm\fP (ex\. \fBnpm fund\fP, \fBnpm ls\fP, \fBnpm outdated\fP, \fBnpm audit\fP \.\.\.)
|
||||
|
||||
.RE
|
||||
.SS Dependency Selector Syntax \fBv1\.0\.0\fP
|
||||
.SS Overview:
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
there is no "type" or "tag" selectors (ex\. \fBdiv, h1, a\fP) as a dependency/target is the only type of \fBNode\fP that can be queried
|
||||
.IP \(bu 2
|
||||
the term "dependencies" is in reference to any \fBNode\fP found in a \fBtree\fP returned by \fBArborist\fP
|
||||
|
||||
.RE
|
||||
.SS Combinators
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fB>\fP direct descendant/child
|
||||
.IP \(bu 2
|
||||
\fB \fP any descendant/child
|
||||
.IP \(bu 2
|
||||
\fB~\fP sibling
|
||||
|
||||
.RE
|
||||
.SS Selectors
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fB*\fP universal selector
|
||||
.IP \(bu 2
|
||||
\fB#<name>\fP dependency selector (equivalent to \fB[name="\.\.\."]\fP)
|
||||
.IP \(bu 2
|
||||
\fB#<name>@<version>\fP (equivalent to \fB[name=<name>]:semver(<version>)\fP)
|
||||
.IP \(bu 2
|
||||
\fB,\fP selector list delimiter
|
||||
.IP \(bu 2
|
||||
\fB\|\.\fP dependency type selector
|
||||
.IP \(bu 2
|
||||
\fB:\fP pseudo selector
|
||||
|
||||
.RE
|
||||
.SS Dependency Type Selectors
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fB\|\.prod\fP dependency found in the \fBdependencies\fP section of \fBpackage\.json\fP, or is a child of said dependency
|
||||
.IP \(bu 2
|
||||
\fB\|\.dev\fP dependency found in the \fBdevDependencies\fP section of \fBpackage\.json\fP, or is a child of said dependency
|
||||
.IP \(bu 2
|
||||
\fB\|\.optional\fP dependency found in the \fBoptionalDependencies\fP section of \fBpackage\.json\fP, or has \fB"optional": true\fP set in its entry in the \fBpeerDependenciesMeta\fP section of \fBpackage\.json\fP, or a child of said dependency
|
||||
.IP \(bu 2
|
||||
\fB\|\.peer\fP dependency found in the \fBpeerDependencies\fP section of \fBpackage\.json\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.workspace\fP dependency found in the \fBworkspaces\fP \fIhttps://docs\.npmjs\.com/cli/v8/using\-npm/workspaces\fR section of \fBpackage\.json\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.bundled\fP dependency found in the \fBbundleDependencies\fP section of \fBpackage\.json\fP, or is a child of said dependency
|
||||
|
||||
.RE
|
||||
.SS Pseudo Selectors
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fB:not(<selector>)\fP \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/:not\fR
|
||||
.IP \(bu 2
|
||||
\fB:has(<selector>)\fP \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/:has\fR
|
||||
.IP \(bu 2
|
||||
\fB:is(<selector list>)\fP \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/:is\fR
|
||||
.IP \(bu 2
|
||||
\fB:root\fP \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/:root\fR matches the root node/dependency
|
||||
.IP \(bu 2
|
||||
\fB:scope\fP \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/:scope\fR matches node/dependency it was queried against
|
||||
.IP \(bu 2
|
||||
\fB:empty\fP \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/:empty\fR when a dependency has no dependencies
|
||||
.IP \(bu 2
|
||||
\fB:private\fP \fIhttps://docs\.npmjs\.com/cli/v8/configuring\-npm/package\-json#private\fR when a dependency is private
|
||||
.IP \(bu 2
|
||||
\fB:link\fP when a dependency is linked (for instance, workspaces or packages manually \fBlinked\fP \fIhttps://docs\.npmjs\.com/cli/v8/commands/npm\-link\fR
|
||||
.IP \(bu 2
|
||||
\fB:deduped\fP when a dependency has been deduped (note that this does \fInot\fR always mean the dependency has been hoisted to the root of node_modules)
|
||||
.IP \(bu 2
|
||||
\fB:override\fP when a dependency is an override (not implemented yet)
|
||||
.IP \(bu 2
|
||||
\fB:extraneous\fP when a dependency exists but is not defined as a dependency of any node
|
||||
.IP \(bu 2
|
||||
\fB:invalid\fP when a dependency version is out of its ancestors specified range
|
||||
.IP \(bu 2
|
||||
\fB:missing\fP when a dependency is not found on disk
|
||||
.IP \(bu 2
|
||||
\fB:semver(<spec>)\fP matching a valid \fBnode\-semver\fP \fIhttps://github\.com/npm/node\-semver\fR spec
|
||||
.IP \(bu 2
|
||||
\fB:path(<path>)\fP glob \fIhttps://www\.npmjs\.com/package/glob\fR matching based on dependencies path relative to the project
|
||||
.IP \(bu 2
|
||||
\fB:type(<type>)\fP based on currently recognized types \fIhttps://github\.com/npm/npm\-package\-arg#result\-object\fR
|
||||
|
||||
.RE
|
||||
.SS Attribute Selectors \fIhttps://developer\.mozilla\.org/en\-US/docs/Web/CSS/Attribute_selectors\fR
|
||||
.P
|
||||
The attribute selector evaluates the key/value pairs in \fBpackage\.json\fP if they are \fBString\fPs\.
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fB[]\fP attribute selector (ie\. existence of attribute)
|
||||
.IP \(bu 2
|
||||
\fB[attribute=value]\fP attribute value is equivalant\.\.\.
|
||||
.IP \(bu 2
|
||||
\fB[attribute~=value]\fP attribute value contains word\.\.\.
|
||||
.IP \(bu 2
|
||||
\fB[attribute*=value]\fP attribute value contains string\.\.\.
|
||||
.IP \(bu 2
|
||||
\fB[attribute|=value]\fP attribute value is equal to or starts with\.\.\.
|
||||
.IP \(bu 2
|
||||
\fB[attribute^=value]\fP attribute value starts with\.\.\.
|
||||
.IP \(bu 2
|
||||
\fB[attribute$=value]\fP attribute value ends with\.\.\.
|
||||
|
||||
.RE
|
||||
.SS \fBArray\fP & \fBObject\fP Attribute Selectors
|
||||
.P
|
||||
The generic \fB:attr()\fP pseudo selector standardizes a pattern which can be used for attribute selection of \fBObject\fPs, \fBArray\fPs or \fBArrays\fP of \fBObject\fPs accessible via \fBArborist\fP\|'s \fBNode\.package\fP metadata\. This allows for iterative attribute selection beyond top\-level \fBString\fP evaluation\. The last argument passed to \fB:attr()\fP must be an \fBattribute\fP selector or a nested \fB:attr()\fP\|\. See examples below:
|
||||
.SS \fBObjects\fP
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
/* return dependencies that have a `scripts\.test` containing `"tap"` */
|
||||
*:attr(scripts, [test~=tap])
|
||||
.fi
|
||||
.RE
|
||||
.SS Nested \fBObjects\fP
|
||||
.P
|
||||
Nested objects are expressed as sequential arguments to \fB:attr()\fP\|\.
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
/* return dependencies that have a testling config for opera browsers */
|
||||
*:attr(testling, browsers, [~=opera])
|
||||
.fi
|
||||
.RE
|
||||
.SS \fBArrays\fP
|
||||
.P
|
||||
\fBArray\fPs specifically uses a special/reserved \fB\|\.\fP character in place of a typical attribute name\. \fBArrays\fP also support exact \fBvalue\fP matching when a \fBString\fP is passed to the selector\.
|
||||
.SS Example of an \fBArray\fP Attribute Selection:
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
/* removes the distinction between properties & arrays */
|
||||
/* ie\. we'd have to check the property & iterate to match selection */
|
||||
*:attr([keywords^=react])
|
||||
*:attr(contributors, :attr([name~=Jordan]))
|
||||
.fi
|
||||
.RE
|
||||
.SS Example of an \fBArray\fP matching directly to a value:
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
/* return dependencies that have the exact keyword "react" */
|
||||
/* this is equivalent to `*:keywords([value="react"])` */
|
||||
*:attr([keywords=react])
|
||||
.fi
|
||||
.RE
|
||||
.SS Example of an \fBArray\fP of \fBObject\fPs:
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
/* returns */
|
||||
*:attr(contributors, [email=ruyadorno@github\.com])
|
||||
.fi
|
||||
.RE
|
||||
.SS Groups
|
||||
.P
|
||||
Dependency groups are defined by the package relationships to their ancestors (ie\. the dependency types that are defined in \fBpackage\.json\fP)\. This approach is user\-centric as the ecosystem has been taught to think about dependencies in these groups first\-and\-foremost\. Dependencies are allowed to be included in multiple groups (ex\. a \fBprod\fP dependency may also be a \fBdev\fP dependency (in that it's also required by another \fBdev\fP dependency) & may also be \fBbundled\fP \- a selector for that type of dependency would look like: \fB*\.prod\.dev\.bundled\fP)\.
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fB\|\.prod\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.dev\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.optional\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.peer\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.bundled\fP
|
||||
.IP \(bu 2
|
||||
\fB\|\.workspace\fP
|
||||
|
||||
.RE
|
||||
.P
|
||||
Please note that currently \fBworkspace\fP deps are always \fBprod\fP dependencies\. Additionally the \fB\|\.root\fP dependency is also considered a \fBprod\fP dependency\.
|
||||
.SS Programmatic Usage
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
\fBArborist\fP\|'s \fBNode\fP Class has a \fB\|\.querySelectorAll()\fP method
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
this method will return a filtered, flattened dependency Arborist \fBNode\fP list based on a valid query selector
|
||||
|
||||
.RE
|
||||
|
||||
.RE
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
const Arborist = require('@npmcli/arborist')
|
||||
const arb = new Arborist({})
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
// root\-level
|
||||
arb\.loadActual((tree) => {
|
||||
// query all production dependencies
|
||||
const results = await tree\.querySelectorAll('\.prod')
|
||||
console\.log(results)
|
||||
})
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
.RS 2
|
||||
.nf
|
||||
// iterative
|
||||
arb\.loadActual((tree) => {
|
||||
// query for the deduped version of react
|
||||
const results = await tree\.querySelectorAll('#react:not(:deduped)')
|
||||
// query the deduped react for git deps
|
||||
const deps = await results[0]\.querySelectorAll(':type(git)')
|
||||
console\.log(deps)
|
||||
})
|
||||
.fi
|
||||
.RE
|
||||
.SH See Also
|
||||
.RS 0
|
||||
.IP \(bu 2
|
||||
npm help query
|
||||
.IP \(bu 2
|
||||
[@npmcli/arborist](https://npm\.im/@npmcli/arborist]
|
||||
|
||||
.RE
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "DEVELOPERS" "7" "July 2022" "" ""
|
||||
.TH "DEVELOPERS" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBdevelopers\fR \- Developer Guide
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "LOGGING" "7" "July 2022" "" ""
|
||||
.TH "LOGGING" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBLogging\fR \- Why, What & How We Log
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "ORGS" "7" "July 2022" "" ""
|
||||
.TH "ORGS" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBorgs\fR \- Working with Teams & Orgs
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "PACKAGE\-SPEC" "7" "July 2022" "" ""
|
||||
.TH "PACKAGE\-SPEC" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBpackage-spec\fR \- Package name specifier
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "REGISTRY" "7" "July 2022" "" ""
|
||||
.TH "REGISTRY" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBregistry\fR \- The JavaScript Package Registry
|
||||
.SS Description
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH "REMOVAL" "7" "July 2022" "" ""
|
||||
.TH "REMOVAL" "7" "August 2022" "" ""
|
||||
.SH "NAME"
|
||||
\fBremoval\fR \- Cleaning the Slate
|
||||
.SS Synopsis
|
||||
|
||||
Loaded 100 of 191 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user