@jsii/check-node 1.70.0 → 1.72.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/lib/constants.js +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +25 -6
- package/package.json +1 -1
package/lib/constants.js
CHANGED
|
@@ -89,7 +89,7 @@ NodeRelease.ALL_RELEASES = [
|
|
|
89
89
|
}),
|
|
90
90
|
new NodeRelease(18, { endOfLife: new Date('2025-04-30') }),
|
|
91
91
|
// Future (planned releases)
|
|
92
|
-
new NodeRelease(19, { endOfLife: new Date('2023-06-01')
|
|
92
|
+
new NodeRelease(19, { endOfLife: new Date('2023-06-01') }),
|
|
93
93
|
new NodeRelease(20, { endOfLife: new Date('2026-04-30'), untested: true }),
|
|
94
94
|
];
|
|
95
95
|
//# sourceMappingURL=constants.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Checks the current process' node runtime version against the release support
|
|
3
3
|
* matrix, and issues a warning to STDERR if the current version is not fully
|
|
4
4
|
* supported (i.e: it is deprecated, end-of-life, or untested).
|
|
5
|
+
*
|
|
6
|
+
* @param envPrefix will be prepended to environment variable names that can be
|
|
7
|
+
* used to silence version check warnings.
|
|
5
8
|
*/
|
|
6
|
-
export declare function checkNode(): void;
|
|
9
|
+
export declare function checkNode(envPrefix?: string): void;
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -9,9 +9,13 @@ const constants_1 = require("./constants");
|
|
|
9
9
|
* Checks the current process' node runtime version against the release support
|
|
10
10
|
* matrix, and issues a warning to STDERR if the current version is not fully
|
|
11
11
|
* supported (i.e: it is deprecated, end-of-life, or untested).
|
|
12
|
+
*
|
|
13
|
+
* @param envPrefix will be prepended to environment variable names that can be
|
|
14
|
+
* used to silence version check warnings.
|
|
12
15
|
*/
|
|
13
|
-
function checkNode() {
|
|
16
|
+
function checkNode(envPrefix = 'JSII') {
|
|
14
17
|
const { nodeRelease, knownBroken } = constants_1.NodeRelease.forThisRuntime();
|
|
18
|
+
const defaultCallToAction = 'Should you encounter odd runtime issues, please try using one of the supported release before filing a bug report.';
|
|
15
19
|
if (nodeRelease === null || nodeRelease === void 0 ? void 0 : nodeRelease.endOfLife) {
|
|
16
20
|
const qualifier = nodeRelease.endOfLifeDate
|
|
17
21
|
? ` on ${nodeRelease.endOfLifeDate.toISOString().slice(0, 10)}`
|
|
@@ -19,16 +23,24 @@ function checkNode() {
|
|
|
19
23
|
veryVisibleMessage(chalk_1.bgRed.white.bold, `Node ${nodeRelease.majorVersion} has reached end-of-life${qualifier} and is not supported.`, `Please upgrade to a supported node version as soon as possible.`);
|
|
20
24
|
}
|
|
21
25
|
else if (knownBroken) {
|
|
22
|
-
|
|
26
|
+
const silenceVariable = `${envPrefix}_SILENCE_WARNING_KNOWN_BROKEN_NODE_VERSION`;
|
|
27
|
+
if (!process.env[silenceVariable])
|
|
28
|
+
veryVisibleMessage(chalk_1.bgRed.white.bold, `Node ${process_1.version} is unsupported and has known compatibility issues with this software.`, defaultCallToAction, silenceVariable);
|
|
23
29
|
}
|
|
24
30
|
else if (!nodeRelease || nodeRelease.untested) {
|
|
25
|
-
|
|
31
|
+
const silenceVariable = `${envPrefix}_SILENCE_WARNING_UNTESTED_NODE_VERSION`;
|
|
32
|
+
if (!process.env[silenceVariable]) {
|
|
33
|
+
veryVisibleMessage(chalk_1.bgYellow.black, `This software has not been tested with node ${process_1.version}.`, defaultCallToAction, silenceVariable);
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
else if (nodeRelease === null || nodeRelease === void 0 ? void 0 : nodeRelease.deprecated) {
|
|
28
|
-
const
|
|
29
|
-
|
|
37
|
+
const silenceVariable = `${envPrefix}_SILENCE_WARNING_DEPRECATED_NODE_VERSION`;
|
|
38
|
+
if (!process.env[silenceVariable]) {
|
|
39
|
+
const deadline = nodeRelease.endOfLifeDate.toISOString().slice(0, 10);
|
|
40
|
+
veryVisibleMessage(chalk_1.bgYellowBright.black, `Node ${nodeRelease.majorVersion} is approaching end-of-life and will no longer be supported in new releases after ${deadline}.`, `Please upgrade to a supported node version as soon as possible.`, silenceVariable);
|
|
41
|
+
}
|
|
30
42
|
}
|
|
31
|
-
function veryVisibleMessage(chalk, message, callToAction
|
|
43
|
+
function veryVisibleMessage(chalk, message, callToAction, silenceVariable) {
|
|
32
44
|
const lines = [
|
|
33
45
|
message,
|
|
34
46
|
callToAction,
|
|
@@ -43,6 +55,13 @@ function checkNode() {
|
|
|
43
55
|
((_d = (_c = l.endOfLifeDate) === null || _c === void 0 ? void 0 : _c.getTime()) !== null && _d !== void 0 ? _d : 0);
|
|
44
56
|
})
|
|
45
57
|
.map((release) => `- ${release.toString()}${release.deprecated ? ' [DEPRECATED]' : ''}`),
|
|
58
|
+
// Add blurb on how this message can be silenced (if it can be silenced).
|
|
59
|
+
...(silenceVariable
|
|
60
|
+
? [
|
|
61
|
+
'',
|
|
62
|
+
`This warning can be silenced by setting the ${silenceVariable} environment variable.`,
|
|
63
|
+
]
|
|
64
|
+
: []),
|
|
46
65
|
];
|
|
47
66
|
const len = Math.max(...lines.map((l) => l.length));
|
|
48
67
|
const border = chalk('!'.repeat(len + 8));
|