node-lifecycle 1.0.6 → 1.2.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 +69 -68
- package/dist/cli.js +4 -4
- package/dist/index.js +10 -2
- package/dist/utils.js +18 -4
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,130 +1,131 @@
|
|
|
1
1
|
# node-lifecycle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight Node.js EOL checker and lifecycle CLI.
|
|
4
|
+
|
|
5
|
+
Check whether your current or specified Node.js version is **Current**, **Active LTS**, **Maintenance**, approaching **end-of-life (EOL)**, or already **EOL**.
|
|
6
|
+
|
|
7
|
+
Use `node-lifecycle` locally or in CI to identify unsupported Node.js versions and get advance warning before a version reaches end-of-life.
|
|
4
8
|
|
|
5
9
|
[](https://www.npmjs.com/package/node-lifecycle)
|
|
10
|
+
[](https://www.npmjs.com/package/node-lifecycle)
|
|
11
|
+
[](https://github.com/ksalguera/node-lifecycle/actions/workflows/ci.yml)
|
|
12
|
+
[](https://socket.dev/npm/package/node-lifecycle)
|
|
6
13
|
[](LICENSE)
|
|
7
14
|
|
|
15
|
+
## 📦 Installation
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
### Run without installing
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
For a quick lifecycle check:
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npx node-lifecycle
|
|
14
23
|
```
|
|
24
|
+
|
|
25
|
+
### Global installation
|
|
26
|
+
|
|
27
|
+
Install the CLI globally:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
15
30
|
npm install -g node-lifecycle
|
|
16
31
|
```
|
|
17
32
|
|
|
18
|
-
|
|
33
|
+
Then run:
|
|
19
34
|
|
|
20
|
-
```
|
|
35
|
+
```bash
|
|
21
36
|
node-lifecycle
|
|
22
37
|
```
|
|
23
38
|
|
|
24
|
-
###
|
|
39
|
+
### Project installation
|
|
25
40
|
|
|
26
|
-
|
|
41
|
+
Install `node-lifecycle` as a development dependency:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
27
44
|
npm install --save-dev node-lifecycle
|
|
28
45
|
```
|
|
29
46
|
|
|
30
|
-
|
|
47
|
+
Run it with:
|
|
31
48
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Use npx (simple):
|
|
35
|
-
|
|
36
|
-
```
|
|
49
|
+
```bash
|
|
37
50
|
npx node-lifecycle
|
|
38
51
|
```
|
|
39
52
|
|
|
40
|
-
|
|
53
|
+
Or add it to your npm scripts:
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"scripts": {
|
|
45
|
-
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"scripts": {
|
|
58
|
+
"check-node": "node-lifecycle"
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
```
|
|
48
62
|
|
|
49
63
|
Then run:
|
|
50
|
-
```
|
|
51
|
-
npm run check-node
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Option 3: Run without installing at all
|
|
55
64
|
|
|
65
|
+
```bash
|
|
66
|
+
npm run check-node
|
|
56
67
|
```
|
|
57
|
-
npx node-lifecycle
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
This will fetch the latest version from npm on demand.
|
|
61
|
-
|
|
62
|
-
### Option 4: CircleCI configuration example
|
|
63
|
-
|
|
64
|
-
See the [CircleCI configuration example](documentation/circleci-config-example.md).
|
|
65
68
|
|
|
66
69
|
## 🚀 Usage
|
|
67
70
|
|
|
68
|
-
Check the status of your current Node.js version:
|
|
71
|
+
Check the lifecycle status of your current Node.js version:
|
|
69
72
|
|
|
70
|
-
```
|
|
73
|
+
```bash
|
|
71
74
|
node-lifecycle
|
|
72
75
|
```
|
|
73
76
|
|
|
74
|
-
Check
|
|
77
|
+
Check a specific Node.js version:
|
|
75
78
|
|
|
79
|
+
```bash
|
|
80
|
+
node-lifecycle --version=22.0.0
|
|
76
81
|
```
|
|
77
|
-
node-lifecycle --version=18.20.4
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## ⚙️ Options
|
|
81
|
-
|
|
82
|
-
| Flag | Description |
|
|
83
|
-
| ------------------ | --------------------------------------------------------------------------------- |
|
|
84
|
-
| `--version=VER` | Check this specific Node.js version instead of your current runtime. |
|
|
85
|
-
| `--warn-days=N` | Warn if EOL is within `N` days (default: `180`). |
|
|
86
|
-
| `--cache-ttl=SECS` | Cache the Node.js release schedule for `N` seconds (default: `86400` / 24 hours). |
|
|
87
|
-
| `--no-fail` | Do not exit with code `2` on EOL (still prints ❌). |
|
|
88
|
-
| `--help` | Show help message. |
|
|
89
82
|
|
|
90
|
-
|
|
83
|
+
Use a custom EOL warning window:
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
node-lifecycle --version=20.5.0
|
|
85
|
+
```bash
|
|
86
|
+
node-lifecycle --warn-days=90
|
|
96
87
|
```
|
|
97
88
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
node-lifecycle --warn-days=30
|
|
89
|
+
```bash
|
|
90
|
+
node-lifecycle --version=18.20.4 --no-fail
|
|
102
91
|
```
|
|
103
92
|
|
|
104
|
-
|
|
93
|
+
## ⚙️ Options
|
|
105
94
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
| Flag | Description |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| `--version=VER` | Check a specific Node.js version instead of the current runtime. |
|
|
98
|
+
| `--warn-days=N` | Warn if EOL is within `N` days (default: `180`). |
|
|
99
|
+
| `--cache-ttl=SECS` | Cache the Node.js release schedule for `N` seconds (default: `86400` / 24 hours). |
|
|
100
|
+
| `--no-fail` | Do not exit with code `2` when the version is EOL. |
|
|
101
|
+
| `--help` | Show the help message. |
|
|
102
|
+
|
|
103
|
+
## 🔄 Exit Codes
|
|
109
104
|
|
|
110
|
-
|
|
105
|
+
`node-lifecycle` uses exit codes so it can be used in scripts and CI pipelines.
|
|
111
106
|
|
|
112
|
-
| Code | Meaning
|
|
113
|
-
|
|
|
114
|
-
| `0`
|
|
115
|
-
| `1`
|
|
116
|
-
| `2`
|
|
107
|
+
| Code | Meaning |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `0` | Supported, or EOL when `--no-fail` is used |
|
|
110
|
+
| `1` | Warning — version is within `warn-days` of EOL |
|
|
111
|
+
| `2` | Node.js version has reached EOL |
|
|
117
112
|
|
|
113
|
+
## 🧪 CI Integration
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
`node-lifecycle` can be used in CI to detect unsupported or soon-to-be-unsupported Node.js versions.
|
|
120
116
|
|
|
121
117
|
### GitHub Actions
|
|
122
118
|
|
|
123
119
|
See the [GitHub Actions configuration example](documentation/github-actions-config-example.md).
|
|
124
120
|
|
|
121
|
+
### CircleCI
|
|
122
|
+
|
|
123
|
+
See the [CircleCI configuration example](documentation/circleci-config-example.md).
|
|
125
124
|
|
|
126
125
|
## 📄 License
|
|
127
126
|
|
|
128
127
|
MIT © 2026 Kelsey Salguera
|
|
129
128
|
|
|
130
|
-
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
`node-lifecycle` retrieves Node.js release lifecycle information from the Node.js Release schedule and endoflife.date, with local caching for faster subsequent checks.
|
package/dist/cli.js
CHANGED
|
@@ -61,12 +61,12 @@ async function main() {
|
|
|
61
61
|
const current = findCurrent(schedule); // e.g., 24
|
|
62
62
|
// Only recommend LTS if it's newer than the user's major
|
|
63
63
|
if (Number.isFinite(topLts) && topLts > result.major) {
|
|
64
|
-
const name = codenameFor(topLts);
|
|
64
|
+
const name = codenameFor(topLts, schedule);
|
|
65
65
|
rec.push(`LTS v${topLts}${name ? ` (“${name}”)` : ""}`);
|
|
66
66
|
}
|
|
67
67
|
// Always recommend Current unless they're already on it
|
|
68
68
|
if (current && current !== result.major) {
|
|
69
|
-
const name = codenameFor(current);
|
|
69
|
+
const name = codenameFor(current, schedule);
|
|
70
70
|
rec.push(`Current v${current}${name ? ` (“${name}”)` : ""}`);
|
|
71
71
|
}
|
|
72
72
|
return rec;
|
|
@@ -82,7 +82,7 @@ async function main() {
|
|
|
82
82
|
}
|
|
83
83
|
// Unknown line → warn (non-fatal)
|
|
84
84
|
if (result.status === "unknown") {
|
|
85
|
-
console.warn(`⚠️ Node ${runtime} → unknown
|
|
85
|
+
console.warn(`⚠️ Node ${runtime} → unknown or unreleased line (check version and schedule data).`);
|
|
86
86
|
process.exit(1);
|
|
87
87
|
}
|
|
88
88
|
// Near-EOL window
|
|
@@ -96,7 +96,7 @@ async function main() {
|
|
|
96
96
|
}
|
|
97
97
|
// Supported OK
|
|
98
98
|
const eolPretty = formatFriendlyDate(result.eol);
|
|
99
|
-
const code = codenameFor(result.major);
|
|
99
|
+
const code = codenameFor(result.major, schedule);
|
|
100
100
|
const suffix = code ? ` (“${code}”)` : "";
|
|
101
101
|
console.log(`✅ Node ${runtime} (major ${result.major})${suffix} → ${result.status}. EOL ${result.eol} (${eolPretty}) in ${result.daysToEol} days.`);
|
|
102
102
|
process.exit(0);
|
package/dist/index.js
CHANGED
|
@@ -42,13 +42,17 @@ async function fetchJson(url) {
|
|
|
42
42
|
throw new Error(`${url} -> ${r.status}`);
|
|
43
43
|
return r.json();
|
|
44
44
|
}
|
|
45
|
+
// Strip the upstream prefix without collapsing historical lines such as v0.10.
|
|
46
|
+
function normalizeScheduleKeys(schedule) {
|
|
47
|
+
return Object.fromEntries(Object.entries(schedule).map(([version, release]) => [version.replace(/^v/, ""), release]));
|
|
48
|
+
}
|
|
45
49
|
async function fetchWG(ttlMs) {
|
|
46
50
|
const url = "https://raw.githubusercontent.com/nodejs/Release/HEAD/schedule.json";
|
|
47
51
|
const cacheName = "schedule.wg.json";
|
|
48
52
|
const cached = await readCache(cacheName, ttlMs);
|
|
49
53
|
if (cached)
|
|
50
|
-
return cached;
|
|
51
|
-
const data = (await fetchJson(url));
|
|
54
|
+
return normalizeScheduleKeys(cached);
|
|
55
|
+
const data = normalizeScheduleKeys((await fetchJson(url)));
|
|
52
56
|
await writeCache(cacheName, data);
|
|
53
57
|
return data;
|
|
54
58
|
}
|
|
@@ -117,6 +121,10 @@ export function classify(nodeVersion, schedule) {
|
|
|
117
121
|
if (!rel)
|
|
118
122
|
return { major, status: "unknown" };
|
|
119
123
|
const now = new Date();
|
|
124
|
+
// A scheduled release is not supported before its initial release date.
|
|
125
|
+
if (rel.start && new Date(rel.start) > now) {
|
|
126
|
+
return { major, status: "unknown" };
|
|
127
|
+
}
|
|
120
128
|
// If no end date or invalid date → unknown
|
|
121
129
|
if (!rel.end || Number.isNaN(new Date(rel.end).getTime())) {
|
|
122
130
|
return { major, status: "unknown" };
|
package/dist/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ export const CODENAMES = {
|
|
|
3
3
|
20: "Iron",
|
|
4
4
|
22: "Jod",
|
|
5
5
|
24: "Krypton",
|
|
6
|
+
26: "Lithium",
|
|
6
7
|
};
|
|
7
8
|
const toValidDate = (iso) => {
|
|
8
9
|
if (!iso)
|
|
@@ -10,6 +11,15 @@ const toValidDate = (iso) => {
|
|
|
10
11
|
const d = new Date(iso);
|
|
11
12
|
return Number.isNaN(d.getTime()) ? null : d;
|
|
12
13
|
};
|
|
14
|
+
function releasedMajors(schedule, now) {
|
|
15
|
+
return Object.keys(schedule).map(Number).filter((major) => {
|
|
16
|
+
if (!Number.isFinite(major))
|
|
17
|
+
return false;
|
|
18
|
+
const start = toValidDate(schedule[String(major)]?.start);
|
|
19
|
+
// Sources without a start date retain the existing fallback behavior.
|
|
20
|
+
return !start || start <= now;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
13
23
|
// ISO → friendly date without TZ drift
|
|
14
24
|
export function formatFriendlyDate(isoDate) {
|
|
15
25
|
if (!isoDate)
|
|
@@ -27,6 +37,7 @@ export function formatFriendlyDate(isoDate) {
|
|
|
27
37
|
}
|
|
28
38
|
/**
|
|
29
39
|
* Return ALL active LTS majors.
|
|
40
|
+
* Only consider releases whose known start date has arrived.
|
|
30
41
|
* Normal path: require ltsStart <= now && eol > now.
|
|
31
42
|
* Fallback path (when no majors have an `lts` field at all, e.g. endoflife.date only):
|
|
32
43
|
* infer LTS = even majors with eol > now, EXCLUDING the highest supported major (assumed Current).
|
|
@@ -35,7 +46,7 @@ export function findActiveLTS(schedule, now = new Date()) {
|
|
|
35
46
|
const keys = Object.keys(schedule);
|
|
36
47
|
if (keys.length === 0)
|
|
37
48
|
return [];
|
|
38
|
-
const majors =
|
|
49
|
+
const majors = releasedMajors(schedule, now);
|
|
39
50
|
const anyLtsInfo = majors.some((m) => !!schedule[String(m)]?.lts);
|
|
40
51
|
if (anyLtsInfo) {
|
|
41
52
|
return majors
|
|
@@ -62,14 +73,14 @@ export function findActiveLTS(schedule, now = new Date()) {
|
|
|
62
73
|
.sort((a, b) => b - a);
|
|
63
74
|
}
|
|
64
75
|
/**
|
|
65
|
-
* Latest Current (supported & not yet LTS).
|
|
76
|
+
* Latest Current (released, supported & not yet LTS).
|
|
66
77
|
* Fallback (no `lts` fields): the highest supported major.
|
|
67
78
|
*/
|
|
68
79
|
export function findCurrent(schedule, now = new Date()) {
|
|
69
80
|
const keys = Object.keys(schedule);
|
|
70
81
|
if (keys.length === 0)
|
|
71
82
|
return null;
|
|
72
|
-
const majors =
|
|
83
|
+
const majors = releasedMajors(schedule, now);
|
|
73
84
|
const anyLtsInfo = majors.some((m) => !!schedule[String(m)]?.lts);
|
|
74
85
|
if (anyLtsInfo) {
|
|
75
86
|
const candidates = majors.filter((m) => {
|
|
@@ -91,8 +102,11 @@ export function findCurrent(schedule, now = new Date()) {
|
|
|
91
102
|
});
|
|
92
103
|
return supported.length ? Math.max(...supported) : null;
|
|
93
104
|
}
|
|
94
|
-
export function codenameFor(major) {
|
|
105
|
+
export function codenameFor(major, schedule) {
|
|
95
106
|
if (!Number.isFinite(major))
|
|
96
107
|
return "";
|
|
108
|
+
const release = schedule?.[String(major)];
|
|
109
|
+
if (release?.codename?.trim())
|
|
110
|
+
return release.codename.trim();
|
|
97
111
|
return CODENAMES[major] || "";
|
|
98
112
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-lifecycle",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Node.js EOL checker and CLI for checking version lifecycle, LTS, maintenance, and end-of-life status",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"node-lifecycle": "./dist/cli.js"
|
|
@@ -18,12 +18,19 @@
|
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"node",
|
|
21
|
+
"nodejs",
|
|
22
|
+
"node.js",
|
|
23
|
+
"node-version",
|
|
24
|
+
"ci",
|
|
21
25
|
"cli",
|
|
22
26
|
"lifecycle",
|
|
23
27
|
"eol",
|
|
28
|
+
"eol-checker",
|
|
29
|
+
"end-of-life",
|
|
24
30
|
"nodejs",
|
|
25
31
|
"lts",
|
|
26
|
-
"maintenance"
|
|
32
|
+
"maintenance",
|
|
33
|
+
"version-checker"
|
|
27
34
|
],
|
|
28
35
|
"author": "Kelsey Salguera",
|
|
29
36
|
"license": "MIT",
|