@jsii/check-node 1.112.0 → 1.113.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.
@@ -6,10 +6,9 @@ import { Range } from 'semver';
6
6
  */
7
7
  export declare class NodeRelease {
8
8
  /**
9
- * How long before enf-of-life do we start warning customers? Expressed in
10
- * milliseconds to make it easier to deal with JS dates.
9
+ * How long after end-of-life do we continue to support a node version.
11
10
  */
12
- private static readonly DEPRECATION_WINDOW_MS;
11
+ private static readonly DEFAULT_EXTENDED_SUPPORT_MONTHS;
13
12
  /**
14
13
  * All registered node releases.
15
14
  */
@@ -31,18 +30,28 @@ export declare class NodeRelease {
31
30
  readonly majorVersion: number;
32
31
  /**
33
32
  * The date on which this release range starts to be considered end-of-life.
34
- * May be `undefined` for "ancient" releases (before Node 12).
33
+ * Defaults to a pre-CDK date for "ancient" releases (before Node 12).
35
34
  */
36
- readonly endOfLifeDate: Date | undefined;
35
+ readonly endOfLifeDate: Date;
37
36
  /**
38
- * Determines whether this release is currently considered end-of-life.
37
+ * Determines whether this release has reached end of support for jsii.
38
+ * This is usually longer then endOfLife;
39
39
  */
40
- readonly endOfLife: boolean;
40
+ readonly endOfJsiiSupportDate: Date;
41
41
  /**
42
42
  * Determines whether this release is within the deprecation window ahead of
43
43
  * it's end-of-life date.
44
44
  */
45
45
  readonly deprecated: boolean;
46
+ /**
47
+ * Determines whether this release has reached end-of-life.
48
+ */
49
+ readonly endOfLife: boolean;
50
+ /**
51
+ * Determines whether this major version line is currently "in support",
52
+ * meaning it is not end-of-life or within our extended support time frame.
53
+ */
54
+ readonly supported: boolean;
46
55
  /**
47
56
  * If `true` denotes that this version of node has not been added to the test
48
57
  * matrix yet. This is used when adding not-yet-released versions of node that
@@ -57,18 +66,10 @@ export declare class NodeRelease {
57
66
  * bugs).
58
67
  */
59
68
  readonly supportedRange: Range;
60
- /**
61
- * Determines whether this major version line is currently "in support",
62
- * meaning it is not end-of-life nor pending.
63
- */
64
- readonly supported: boolean;
65
- /** @internal visible for testing */
66
- constructor(majorVersion: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11, opts: {
67
- endOfLife: true;
68
- });
69
69
  /** @internal visible for testing */
70
70
  constructor(majorVersion: number, opts: {
71
71
  endOfLife: Date;
72
+ endOfJsiiSupport?: Date;
72
73
  untested?: boolean;
73
74
  supportedRange?: string;
74
75
  });
package/lib/constants.js CHANGED
@@ -10,22 +10,6 @@ const ONE_DAY_IN_MILLISECONDS = 86400000;
10
10
  * @see https://nodejs.org/en/about/releases/
11
11
  */
12
12
  class NodeRelease {
13
- /** @internal visible for testing */
14
- constructor(majorVersion, opts) {
15
- var _a, _b;
16
- this.majorVersion = majorVersion;
17
- this.endOfLifeDate = opts.endOfLife === true ? undefined : opts.endOfLife;
18
- this.untested = (_a = opts.untested) !== null && _a !== void 0 ? _a : false;
19
- this.supportedRange = new semver_1.Range((_b = opts.supportedRange) !== null && _b !== void 0 ? _b : `^${majorVersion}.0.0`);
20
- this.endOfLife =
21
- opts.endOfLife === true || opts.endOfLife.getTime() <= Date.now();
22
- this.deprecated =
23
- !this.endOfLife &&
24
- opts.endOfLife !== true &&
25
- opts.endOfLife.getTime() - NodeRelease.DEPRECATION_WINDOW_MS <=
26
- Date.now();
27
- this.supported = !this.untested && !this.endOfLife;
28
- }
29
13
  /**
30
14
  * @returns the `NodeRelease` corresponding to the version of the node runtime
31
15
  * executing this code (as provided by `process.version`), and a
@@ -46,6 +30,26 @@ class NodeRelease {
46
30
  }
47
31
  return { nodeRelease: undefined, knownBroken: false };
48
32
  }
33
+ /** @internal visible for testing */
34
+ constructor(majorVersion, opts) {
35
+ var _a, _b, _c;
36
+ this.untested = (_a = opts.untested) !== null && _a !== void 0 ? _a : false;
37
+ this.majorVersion = majorVersion;
38
+ this.supportedRange = new semver_1.Range((_b = opts.supportedRange) !== null && _b !== void 0 ? _b : `^${majorVersion}.0.0`);
39
+ this.endOfLifeDate = opts.endOfLife;
40
+ this.endOfLife =
41
+ opts.endOfLife.getTime() + ONE_DAY_IN_MILLISECONDS <= Date.now();
42
+ // jsii EOS defaults to 6 months after EOL
43
+ this.endOfJsiiSupportDate =
44
+ (_c = opts.endOfJsiiSupport) !== null && _c !== void 0 ? _c : new Date(this.endOfLifeDate.getFullYear(), this.endOfLifeDate.getMonth() +
45
+ NodeRelease.DEFAULT_EXTENDED_SUPPORT_MONTHS, this.endOfLifeDate.getDate());
46
+ const endOfJsiiSupport = this.endOfJsiiSupportDate.getTime() + ONE_DAY_IN_MILLISECONDS <=
47
+ Date.now();
48
+ // We deprecate (warn) from EOL to jsii EOS
49
+ this.deprecated = this.endOfLife && !endOfJsiiSupport;
50
+ // All tested and not EOS versions are supported
51
+ this.supported = !this.untested && !endOfJsiiSupport;
52
+ }
49
53
  toString() {
50
54
  const eolInfo = this.endOfLifeDate
51
55
  ? ` (Planned end-of-life: ${this.endOfLifeDate
@@ -57,16 +61,18 @@ class NodeRelease {
57
61
  }
58
62
  exports.NodeRelease = NodeRelease;
59
63
  /**
60
- * How long before enf-of-life do we start warning customers? Expressed in
61
- * milliseconds to make it easier to deal with JS dates.
64
+ * How long after end-of-life do we continue to support a node version.
62
65
  */
63
- NodeRelease.DEPRECATION_WINDOW_MS = 30 * ONE_DAY_IN_MILLISECONDS;
66
+ NodeRelease.DEFAULT_EXTENDED_SUPPORT_MONTHS = 6;
64
67
  /**
65
68
  * All registered node releases.
66
69
  */
67
70
  NodeRelease.ALL_RELEASES = [
68
71
  // Historical releases (not relevant at time of writing this as they're all EOL now...)
69
- ...[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map((majorVersion) => new NodeRelease(majorVersion, { endOfLife: true })),
72
+ ...[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map((majorVersion) => new NodeRelease(majorVersion, {
73
+ endOfLife: new Date('2018-01-01'),
74
+ untested: true,
75
+ })),
70
76
  // Past end-of-life releases
71
77
  new NodeRelease(12, {
72
78
  endOfLife: new Date('2022-04-30'),
@@ -89,10 +95,15 @@ NodeRelease.ALL_RELEASES = [
89
95
  }),
90
96
  new NodeRelease(19, { endOfLife: new Date('2023-06-01'), untested: true }),
91
97
  new NodeRelease(21, { endOfLife: new Date('2024-06-01'), untested: true }),
98
+ new NodeRelease(23, { endOfLife: new Date('2025-06-01'), untested: true }),
92
99
  // Currently active releases (as of last edit to this file...)
93
- new NodeRelease(18, { endOfLife: new Date('2025-04-30') }),
100
+ new NodeRelease(18, {
101
+ endOfLife: new Date('2025-04-30'),
102
+ endOfJsiiSupport: new Date('2025-11-30'),
103
+ }),
94
104
  new NodeRelease(20, { endOfLife: new Date('2026-04-30') }),
95
105
  new NodeRelease(22, { endOfLife: new Date('2027-04-30') }),
106
+ new NodeRelease(24, { endOfLife: new Date('2028-04-30') }),
96
107
  // Future (planned releases)
97
108
  ];
98
109
  //# sourceMappingURL=constants.js.map
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkNode = exports.NodeRelease = void 0;
3
+ exports.NodeRelease = void 0;
4
+ exports.checkNode = checkNode;
4
5
  const chalk_1 = require("chalk");
5
6
  const console_1 = require("console");
6
7
  const process_1 = require("process");
@@ -19,16 +20,15 @@ function checkNode(envPrefix = 'JSII') {
19
20
  var _a;
20
21
  const { nodeRelease, knownBroken } = constants_1.NodeRelease.forThisRuntime();
21
22
  const defaultCallToAction = 'Should you encounter odd runtime issues, please try using one of the supported release before filing a bug report.';
22
- if (nodeRelease === null || nodeRelease === void 0 ? void 0 : nodeRelease.endOfLife) {
23
+ if ((nodeRelease === null || nodeRelease === void 0 ? void 0 : nodeRelease.supported) === false) {
23
24
  const silenceVariable = `${envPrefix}_SILENCE_WARNING_END_OF_LIFE_NODE_VERSION`;
24
25
  const silencedVersions = ((_a = process.env[silenceVariable]) !== null && _a !== void 0 ? _a : '')
25
26
  .split(',')
26
27
  .map((v) => v.trim());
27
- const qualifier = nodeRelease.endOfLifeDate
28
- ? ` on ${nodeRelease.endOfLifeDate.toISOString().slice(0, 10)}`
29
- : '';
30
- if (!silencedVersions.includes(nodeRelease.majorVersion.toString()))
31
- 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.`);
28
+ if (!silencedVersions.includes(nodeRelease.majorVersion.toString())) {
29
+ const eos = nodeRelease.endOfJsiiSupportDate.toISOString().slice(0, 10);
30
+ veryVisibleMessage(chalk_1.bgRed.white.bold, `Node ${nodeRelease.majorVersion} is end-of-life and not supported anymore by this software since ${eos}.`, `Please upgrade to a supported node version as soon as possible.`);
31
+ }
32
32
  }
33
33
  else if (knownBroken) {
34
34
  const silenceVariable = `${envPrefix}_SILENCE_WARNING_KNOWN_BROKEN_NODE_VERSION`;
@@ -44,8 +44,9 @@ function checkNode(envPrefix = 'JSII') {
44
44
  else if (nodeRelease === null || nodeRelease === void 0 ? void 0 : nodeRelease.deprecated) {
45
45
  const silenceVariable = `${envPrefix}_SILENCE_WARNING_DEPRECATED_NODE_VERSION`;
46
46
  if (!process.env[silenceVariable]) {
47
- const deadline = nodeRelease.endOfLifeDate.toISOString().slice(0, 10);
48
- 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);
47
+ const eol = nodeRelease.endOfLifeDate.toISOString().slice(0, 10);
48
+ const eos = nodeRelease.endOfJsiiSupportDate.toISOString().slice(0, 10);
49
+ veryVisibleMessage(chalk_1.bgYellowBright.black, `Node ${nodeRelease.majorVersion} has reached end-of-life on ${eol} and will no longer be supported in new releases after ${eos}.`, `Please upgrade to a supported node version as soon as possible.`, silenceVariable);
49
50
  }
50
51
  }
51
52
  function veryVisibleMessage(chalk, message, callToAction, silenceVariable) {
@@ -56,7 +57,7 @@ function checkNode(envPrefix = 'JSII') {
56
57
  `This software is currently running on node ${process_1.version}.`,
57
58
  'As of the current release of this software, supported node releases are:',
58
59
  ...constants_1.NodeRelease.ALL_RELEASES.filter((release) => release.supported)
59
- // We display those from longest remaining support to shortest (to incitate people to be ahead of future derepcations).
60
+ // We display those from longest remaining support to shortest (to indicate people to be ahead of future deprecations).
60
61
  .sort((l, r) => {
61
62
  var _a, _b, _c, _d;
62
63
  return ((_b = (_a = r.endOfLifeDate) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0) -
@@ -83,5 +84,4 @@ function checkNode(envPrefix = 'JSII') {
83
84
  (0, console_1.error)(border);
84
85
  }
85
86
  }
86
- exports.checkNode = checkNode;
87
87
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsii/check-node",
3
- "version": "1.112.0",
3
+ "version": "1.113.0",
4
4
  "description": "Checks for supported node versions",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -27,7 +27,7 @@
27
27
  "./run": "./lib/run.js"
28
28
  },
29
29
  "scripts": {
30
- "build": "tsc --build && npm run lint",
30
+ "build": "tsc --build && yarn lint",
31
31
  "watch": "tsc --build -w",
32
32
  "lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .js,.ts --ignore-path=.gitignore",
33
33
  "lint:fix": "yarn lint --fix",
@@ -37,6 +37,6 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "chalk": "^4.1.2",
40
- "semver": "^7.7.1"
40
+ "semver": "^7.7.2"
41
41
  }
42
42
  }