Skip to content

Commit 8402fd8

Browse files
nlflukekarrys
authored andcommitted
docs: add :outdated pseudo selector to docs
1 parent 6ee5b32 commit 8402fd8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/content/using-npm/dependency-selectors.md

+23
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The [`npm query`](/commands/npm-query) commmand exposes a new dependency selecto
6161
- `:semver(<spec>, [selector], [function])` match a valid [`node-semver`](https://github.com/npm/node-semver) version or range to a selector
6262
- `:path(<path>)` [glob](https://www.npmjs.com/package/glob) matching based on dependencies path relative to the project
6363
- `:type(<type>)` [based on currently recognized types](https://github.com/npm/npm-package-arg#result-object)
64+
- `:outdated(<type>)` when a dependency is outdated
6465

6566
##### `:semver(<spec>, [selector], [function])`
6667

@@ -78,6 +79,28 @@ Some examples:
7879
- `:semver(16.0.0, :attr(engines, [node]))` returns every node which has an `engines.node` property satisfying the version `16.0.0`
7980
- `:semver(1.0.0, [version], lt)` every node with a `version` less than `1.0.0`
8081

82+
##### `:outdated(<type>)`
83+
84+
The `:outdated` pseudo selector retrieves data from the registry and returns information about which of your dependencies are outdated. The type parameter may be one of the following:
85+
86+
- `any` (default) a version exists that is greater than the current one
87+
- `in-range` a version exists that is greater than the current one, and satisfies at least one if its dependents
88+
- `out-of-range` a version exists that is greater than the current one, does not satisfy at least one of its dependents
89+
- `major` a version exists that is a semver major greater than the current one
90+
- `minor` a version exists that is a semver minor greater than the current one
91+
- `patch` a version exists that is a semver patch greater than the current one
92+
93+
In addition to the filtering performed by the pseudo selector, some extra data is added to the resulting objects. The following data can be found under the `queryContext` property of each node.
94+
95+
- `versions` an array of every available version of the given node
96+
- `outdated.inRange` an array of objects, each with a `from` and `versions`, where `from` is the on-disk location of the node that depends on the current node and `versions` is an array of all available versions that satisfies that dependency. This is only populated if `:outdated(in-range)` is used.
97+
- `outdated.outOfRange` an array of objects, identical in shape to `inRange`, but where the `versions` array is every available version that does not satisfy the dependency. This is only populated if `:outdated(out-of-range)` is used.
98+
99+
Some examples:
100+
101+
- `:root > :outdated(major)` returns every direct dependency that has a new semver major release
102+
- `.prod:outdated(in-range)` returns production dependencies that have a new release that satisfies at least one of its edges in
103+
81104
#### [Attribute Selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)
82105

83106
The attribute selector evaluates the key/value pairs in `package.json` if they are `String`s.

0 commit comments

Comments
 (0)