@webiny/system-requirements 5.42.0-beta.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/LICENSE +21 -0
- package/README.md +6 -0
- package/SystemRequirements.js +77 -0
- package/constraints.json +6 -0
- package/ensureSystemRequirements.js +93 -0
- package/index.js +4 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const semver = require("semver");
|
|
2
|
+
const execa = require("execa");
|
|
3
|
+
const constraints = require("./constraints.json");
|
|
4
|
+
|
|
5
|
+
class SystemRequirements {
|
|
6
|
+
static validate() {
|
|
7
|
+
const nodeVersion = SystemRequirements.getNodeVersion();
|
|
8
|
+
const yarnVersion = SystemRequirements.getYarnVersion();
|
|
9
|
+
const npmVersion = SystemRequirements.getNpmVersion();
|
|
10
|
+
const npxVersion = SystemRequirements.getNpxVersion();
|
|
11
|
+
|
|
12
|
+
const systemRequirements = {
|
|
13
|
+
valid: false,
|
|
14
|
+
node: {
|
|
15
|
+
currentVersion: nodeVersion,
|
|
16
|
+
requiredVersion: constraints.node,
|
|
17
|
+
valid: semver.satisfies(nodeVersion, constraints.node)
|
|
18
|
+
},
|
|
19
|
+
npm: {
|
|
20
|
+
currentVersion: npmVersion,
|
|
21
|
+
requiredVersion: constraints.npm,
|
|
22
|
+
valid: semver.satisfies(npmVersion, constraints.npm)
|
|
23
|
+
},
|
|
24
|
+
npx: {
|
|
25
|
+
currentVersion: npxVersion,
|
|
26
|
+
requiredVersion: constraints.npx,
|
|
27
|
+
valid: semver.satisfies(npxVersion, constraints.npx)
|
|
28
|
+
},
|
|
29
|
+
yarn: {
|
|
30
|
+
currentVersion: yarnVersion,
|
|
31
|
+
requiredVersion: constraints.yarn,
|
|
32
|
+
valid: semver.satisfies(yarnVersion, constraints.yarn)
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
systemRequirements.valid =
|
|
37
|
+
systemRequirements.node.valid &&
|
|
38
|
+
systemRequirements.npm.valid &&
|
|
39
|
+
systemRequirements.npx.valid &&
|
|
40
|
+
systemRequirements.yarn.valid;
|
|
41
|
+
|
|
42
|
+
return systemRequirements;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static getNodeVersion() {
|
|
46
|
+
return process.versions.node;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static getNpmVersion() {
|
|
50
|
+
try {
|
|
51
|
+
const { stdout } = execa.sync("npm", ["--version"]);
|
|
52
|
+
return stdout;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static getNpxVersion() {
|
|
59
|
+
try {
|
|
60
|
+
const { stdout } = execa.sync("npx", ["--version"]);
|
|
61
|
+
return stdout;
|
|
62
|
+
} catch (err) {
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static getYarnVersion() {
|
|
68
|
+
try {
|
|
69
|
+
const { stdout } = execa.sync("yarn", ["--version"]);
|
|
70
|
+
return stdout;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { SystemRequirements };
|
package/constraints.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const ensureSystemRequirements = () => {
|
|
2
|
+
// Just in case, we want to allow users to skip the system requirements check.
|
|
3
|
+
const skipSystemRequirementsCheck = process.argv.includes("--no-system-requirements-check");
|
|
4
|
+
if (skipSystemRequirementsCheck) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { SystemRequirements } = require("./SystemRequirements");
|
|
9
|
+
|
|
10
|
+
const systemRequirements = SystemRequirements.validate();
|
|
11
|
+
if (systemRequirements.valid) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const chalk = require("chalk");
|
|
16
|
+
|
|
17
|
+
console.log(
|
|
18
|
+
[
|
|
19
|
+
"One or more system requirements are not met.",
|
|
20
|
+
"Please make sure to install the required versions of the following tools:"
|
|
21
|
+
].join("\n\n")
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const Table = require("cli-table3");
|
|
25
|
+
|
|
26
|
+
// Create a table instance
|
|
27
|
+
const table = new Table({
|
|
28
|
+
head: ["", "Current version", "Required version", "Valid"],
|
|
29
|
+
style: { head: ["bold"] },
|
|
30
|
+
colWidths: [10, 20, 20, 10]
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const IS_VALID_TEXT = `${chalk.green("\u2713")} Yes`;
|
|
34
|
+
const IS_INVALID_TEXT = `${chalk.red("\u2717")} No`;
|
|
35
|
+
|
|
36
|
+
// Define the rows
|
|
37
|
+
const { node, npm, npx, yarn } = systemRequirements;
|
|
38
|
+
|
|
39
|
+
const rows = [
|
|
40
|
+
[
|
|
41
|
+
"Node.js",
|
|
42
|
+
node.currentVersion,
|
|
43
|
+
node.requiredVersion,
|
|
44
|
+
node.valid ? IS_VALID_TEXT : IS_INVALID_TEXT
|
|
45
|
+
].map(v => {
|
|
46
|
+
return node.valid ? v : chalk.red(v);
|
|
47
|
+
}),
|
|
48
|
+
[
|
|
49
|
+
"NPM",
|
|
50
|
+
npm.currentVersion,
|
|
51
|
+
npm.requiredVersion,
|
|
52
|
+
npm.valid ? IS_VALID_TEXT : IS_INVALID_TEXT
|
|
53
|
+
].map(v => {
|
|
54
|
+
return npm.valid ? v : chalk.red(v);
|
|
55
|
+
}),
|
|
56
|
+
[
|
|
57
|
+
"NPX",
|
|
58
|
+
npx.currentVersion,
|
|
59
|
+
npx.requiredVersion,
|
|
60
|
+
npx.valid ? IS_VALID_TEXT : IS_INVALID_TEXT
|
|
61
|
+
].map(v => {
|
|
62
|
+
return npx.valid ? v : chalk.red(v);
|
|
63
|
+
}),
|
|
64
|
+
[
|
|
65
|
+
"Yarn",
|
|
66
|
+
yarn.currentVersion,
|
|
67
|
+
yarn.requiredVersion,
|
|
68
|
+
yarn.valid ? IS_VALID_TEXT : IS_INVALID_TEXT
|
|
69
|
+
].map(v => {
|
|
70
|
+
return yarn.valid ? v : chalk.red(v);
|
|
71
|
+
})
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
// Add rows to the table
|
|
75
|
+
rows.forEach(row => table.push(row));
|
|
76
|
+
|
|
77
|
+
// Print the table to the console
|
|
78
|
+
console.log(table.toString());
|
|
79
|
+
|
|
80
|
+
console.log(
|
|
81
|
+
[
|
|
82
|
+
"If you think this is a mistake, you can also try skipping",
|
|
83
|
+
"the system requirements checks by appending the",
|
|
84
|
+
`${chalk.red("--no-system-requirements-check")} flag.`
|
|
85
|
+
].join(" ")
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
console.log();
|
|
89
|
+
console.log("For more information, please visit https://webiny.link/prerequisites.");
|
|
90
|
+
process.exit();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
module.exports = { ensureSystemRequirements };
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/system-requirements",
|
|
3
|
+
"version": "5.42.0-beta.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"bin": {
|
|
6
|
+
"webiny": "./bin.js"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
11
|
+
"directory": "packages/cli"
|
|
12
|
+
},
|
|
13
|
+
"author": "Webiny Ltd.",
|
|
14
|
+
"description": "Contains utilities for checking system requirements for Webiny projects",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "4.1.2",
|
|
17
|
+
"cli-table3": "0.6.5",
|
|
18
|
+
"execa": "5.1.1",
|
|
19
|
+
"semver": "7.6.3"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"directory": "."
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "ebf90f62ed3f28114ffdb012b7e5f80988af53d3"
|
|
27
|
+
}
|