Skip to content

Commit 56abd46

Browse files
authored
Initial scaffold and API design (#1)
Initial scaffold and API design
2 parents a1d90d3 + 70700aa commit 56abd46

File tree

8 files changed

+180
-0
lines changed

8 files changed

+180
-0
lines changed

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "@hapi/hapi",
3+
4+
"parserOptions": {
5+
"ecmaVersion": 2019
6+
}
7+
}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**/node_modules
2+
**/package-lock.json
3+
**/npm-shrinkwrap.json
4+
5+
coverage.*
6+
*.log*
7+
test-results.xml
8+
9+
**/.DS_Store
10+
**/._*
11+
12+
**/*.pem
13+
14+
**/.vs
15+
**/.vscode
16+
**/.idea

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: node_js
2+
sudo: false
3+
4+
node_js:
5+
- "10"
6+
- "12"
7+
- "13"
8+
9+
cache:
10+
npm: false
11+
12+
install:
13+
- "npm install --ignore-scripts"
14+
- "npx allow-scripts"
15+
16+
#@todo uncomment before v1
17+
#jobs:
18+
# include:
19+
# - stage: release
20+
# if: branch = master AND type = push
21+
# node_js: "12"
22+
# deploy:
23+
# provider: "script"
24+
# skip_cleanup: true
25+
# script:
26+
# - "npx semantic-release"

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+
```

lib/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
module.exports = () => {
4+
5+
throw new Error('Not implemented');
6+
};

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "node-support",
3+
"version": "0.0.0-development",
4+
"description": "List the Node.js versions supported by the package/repository",
5+
"main": "lib/index.js",
6+
"scripts": {
7+
"test": "lab -a @hapi/code -L -t 100"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/pkgjs/node-support.git"
12+
},
13+
"author": "Dominykas Blyžė <[email protected]>",
14+
"license": "MIT",
15+
"bugs": {
16+
"url": "https://github.com/pkgjs/node-support/issues"
17+
},
18+
"homepage": "https://github.com/pkgjs/node-support#readme",
19+
"devDependencies": {
20+
"@hapi/code": "^7.0.0",
21+
"@hapi/lab": "^21.0.0",
22+
"allow-scripts": "^1.5.2",
23+
"semantic-release": "^15.14.0"
24+
}
25+
}

test/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const NodeSupport = require('..');
4+
5+
6+
const { describe, it } = exports.lab = require('@hapi/lab').script();
7+
const { expect } = require('@hapi/code');
8+
9+
describe('node-support', () => {
10+
11+
it('is not implemented', () => {
12+
13+
expect(NodeSupport).to.throw('Not implemented');
14+
});
15+
});

0 commit comments

Comments
 (0)