check-installed 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/lib/checkEngines.js +2 -2
- package/lib/checkModules.js +5 -6
- package/lib/getOptions.js +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -14,8 +14,7 @@ $ npm i check-installed --save-dev
|
|
|
14
14
|
### Engines Check
|
|
15
15
|
- Compares the installed version of engines to the versions specified in `package.json`
|
|
16
16
|
- Engines can be things like node, dotnet, or anything that responds to `--version`
|
|
17
|
-
-
|
|
18
|
-
- See [semver](https://www.npmjs.com/package/semver) for more info
|
|
17
|
+
- Versions are checked with [semver](https://www.npmjs.com/package/semver), so you can use any valid semver range
|
|
19
18
|
```json
|
|
20
19
|
"engines": {
|
|
21
20
|
"node": ">=12.x",
|
|
@@ -28,7 +27,7 @@ $ npm i check-installed --save-dev
|
|
|
28
27
|
- Compares the installed versions of node modules to the versions specified in `package.json`
|
|
29
28
|
- Versions for modules that have `latest` are not checked, only that they are installed
|
|
30
29
|
- Optional node module dependencies are only checked if they are installed
|
|
31
|
-
- Git URL versions are skipped
|
|
30
|
+
- URL, Git URL, and file path versions are currently skipped
|
|
32
31
|
|
|
33
32
|
## Usage
|
|
34
33
|
|
package/lib/checkEngines.js
CHANGED
|
@@ -40,7 +40,7 @@ async function getEngineVersion (name) {
|
|
|
40
40
|
* @returns {Promise<[string, string, string]>} - The [name, version, installed] installed and checked successfully
|
|
41
41
|
*/
|
|
42
42
|
async function checkEngineVersion (name, version) {
|
|
43
|
-
const installed = await getEngineVersion(name
|
|
43
|
+
const installed = await getEngineVersion(name)
|
|
44
44
|
|
|
45
45
|
if (!semver.satisfies(installed, version)) {
|
|
46
46
|
throw new Error(`check-installed engine failed for ${name}: installed ${installed}, expected ${version}`)
|
|
@@ -55,7 +55,7 @@ async function checkEngineVersion (name, version) {
|
|
|
55
55
|
* @param {Partial<typeof import('./constants').OPTIONS>} options - Options for the CLI
|
|
56
56
|
* @returns {Promise<void>} - Resolves when all engines are checked (throws on check fail)
|
|
57
57
|
*/
|
|
58
|
-
async function checkEngines (json = {}, options) {
|
|
58
|
+
async function checkEngines (json = {}, options = {}) {
|
|
59
59
|
const { showSuccess, showEngines } = { ...OPTIONS, ...options }
|
|
60
60
|
|
|
61
61
|
// Check engines
|
package/lib/checkModules.js
CHANGED
|
@@ -25,15 +25,14 @@ function checkModuleVersion (name, version, optional) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Ignore git URLs version
|
|
28
|
-
if (/^(git.*:\/\/|github:|gitlab:|bitbucket:|gist:)/.test(version)) {
|
|
28
|
+
if (/^(file:|https?:\/\/|git.*:\/\/|github:|gitlab:|bitbucket:|gist:)/.test(version)) {
|
|
29
29
|
return [name, version, aliased, 'skipped']
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
const jsonPath = `${directoryPath}/package.json`
|
|
32
|
+
const jsonPath = resolve('node_modules', name, 'package.json')
|
|
34
33
|
|
|
35
34
|
// Check if module is installed and contains a `package.json` (throw if not optional)
|
|
36
|
-
if (!fs.existsSync(
|
|
35
|
+
if (!fs.existsSync(jsonPath)) {
|
|
37
36
|
if (optional) {
|
|
38
37
|
return [name, version, aliased, 'none']
|
|
39
38
|
} else {
|
|
@@ -41,7 +40,7 @@ function checkModuleVersion (name, version, optional) {
|
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
const json = require(
|
|
43
|
+
const json = require(jsonPath)
|
|
45
44
|
const installed = json.version
|
|
46
45
|
|
|
47
46
|
if (version !== 'latest' && !semver.satisfies(json.version, version)) {
|
|
@@ -57,7 +56,7 @@ function checkModuleVersion (name, version, optional) {
|
|
|
57
56
|
* @param {Partial<typeof import('./constants').OPTIONS>} options - Options for the CLI
|
|
58
57
|
* @returns {Promise<void>} - Resolves when all modules are checked (throws on check fail)
|
|
59
58
|
*/
|
|
60
|
-
async function checkModules (json = {}, options) {
|
|
59
|
+
async function checkModules (json = {}, options = {}) {
|
|
61
60
|
const { showSuccess, showModules } = { ...OPTIONS, ...options }
|
|
62
61
|
|
|
63
62
|
// Check modules
|
package/lib/getOptions.js
CHANGED
|
@@ -3,7 +3,7 @@ const { OPTIONS } = require('./constants')
|
|
|
3
3
|
/**
|
|
4
4
|
* Get check-installed options from CLI arguments
|
|
5
5
|
* @param {string[]} args - CLI arguments
|
|
6
|
-
* @returns {typeof OPTIONS} - Options for the CLI with defaults
|
|
6
|
+
* @returns {Partial<typeof OPTIONS>} - Options for the CLI with defaults
|
|
7
7
|
*/
|
|
8
8
|
function getOptions (args = []) {
|
|
9
9
|
const options = {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "check-installed",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Minimal Node package to check that dependencies are installed ✅",
|
|
5
5
|
"author": "Phillip Lanclos <check-installed@flippidippi.com>",
|
|
6
6
|
"license": "Unlicense",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"check": "./bin/check-installed --show-engines",
|
|
36
36
|
"lint": "standard",
|
|
37
37
|
"lint:fix": "npm run lint -- --fix",
|
|
38
|
+
"compile": "tsc",
|
|
38
39
|
"test": "npm run check && jest",
|
|
39
40
|
"test:coverage": "npm run test -- --coverage",
|
|
40
41
|
"test:watch": "npm run test -- --watch",
|
|
@@ -45,10 +46,12 @@
|
|
|
45
46
|
"semver": "^7.5.4"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
49
|
+
"@types/jest": "^29.5.5",
|
|
48
50
|
"husky": "^8.0.3",
|
|
49
51
|
"jest": "^29.7.0",
|
|
50
52
|
"jest-junit": "^16.0.0",
|
|
51
|
-
"standard": "^17.1.0"
|
|
53
|
+
"standard": "^17.1.0",
|
|
54
|
+
"typescript": "^5.2.2"
|
|
52
55
|
},
|
|
53
56
|
"standard": {
|
|
54
57
|
"env": [
|