Skip to content

Commit 70700aa

Browse files
committed
docs: draft the proposed API
1 parent 2de28c8 commit 70700aa

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,86 @@
11
# node-support
2+
23
List the Node.js versions supported by the package/repository
4+
5+
## Usage (command line)
6+
7+
```
8+
$ npx node-support [path]
9+
```
10+
11+
Prints the supported Node.js versions for the package at the specified path. When the path is not a git repository - tries to read the git repository from `package.json` and tries to detect the versions listed in the repository as well.
12+
13+
When `path` is omitted, tries to detect the versions for `cwd`.
14+
15+
```
16+
$ npx node-support [package name]
17+
```
18+
19+
Prints supported Node.js versions for the package from the registry.
20+
21+
```
22+
$ npx node-support [repository git URL]
23+
```
24+
25+
Prints supported Node.js versions for the package at the git URL.
26+
27+
## Usage (library)
28+
29+
```
30+
const result = await require('node-support').detect({ path });
31+
```
32+
33+
`path` should be a folder in the local file system. When the path is not a git repository - tries to read the git repository from `package.json` and tries to detect the versions listed in the repository as well.
34+
35+
```
36+
const result = await require('node-support').detect({ package });
37+
```
38+
39+
`package` is a string name for the package in the registry.
40+
41+
```
42+
const result = await require('node-support').detect({ repository });
43+
```
44+
45+
`repository` is a URL for a git repository.
46+
47+
### Result
48+
49+
- Throws if the `path` / `repository` does not have a `package.json`
50+
- Throws if `package` does not exist in the registry
51+
52+
Otherwise returns an object with:
53+
54+
```javascript
55+
const result = {
56+
57+
// the "name" field of the `package.json`
58+
name: "package-name",
59+
60+
// the "version" field of the `package.json` when used with `path` / `repository`,
61+
// the `latest` dist-tag version when used with `package`
62+
version: "0.0.0",
63+
64+
// the current time when the result is returned
65+
timestamp: 1577115956099,
66+
67+
// git commit hash of the repository HEAD at the time of scanning
68+
// will be left out when no git repository detected
69+
commit: "2de28c8c4ab8ac998d403509123736929131908c",
70+
71+
// will be left out when not present in the `package.json`
72+
// a copy of the `engines.node` field from the `package.json` if present
73+
engines: ">=x.y.z",
74+
75+
// will be left out when `.travis.yml` file is not present
76+
travis: {
77+
// the list of versions as detected by inspecting `node_js` / `matrix` configuration
78+
// will be an empty array when no versions are detected or the project is not a Node.js project
79+
// will contain "latest" when `language: node_js` specified, but no explicit versions detected
80+
raw: ["8", "10", "lts/*"],
81+
82+
// raw version specifiers and keywords resolved to exact Node.js versions
83+
resolved: ["8.17.0", "10.18.0", "12.14.0"]
84+
}
85+
}
86+
```

0 commit comments

Comments
 (0)