node-lifecycle 1.0.5 โ 1.1.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 +1 -1
- package/README.md +7 -52
- package/dist/cli.js +4 -4
- package/dist/index.js +10 -2
- package/dist/utils.js +18 -4
- package/package.json +12 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# node-lifecycle
|
|
2
2
|
|
|
3
|
-
Check the lifecycle status (Current, Active LTS, Maintenance, or EOL) of any Node.js version
|
|
3
|
+
Check the lifecycle status (Current, Active LTS, Maintenance, or EOL) of any Node.js version.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/node-lifecycle)
|
|
6
6
|
[](LICENSE)
|
|
@@ -59,7 +59,9 @@ npx node-lifecycle
|
|
|
59
59
|
|
|
60
60
|
This will fetch the latest version from npm on demand.
|
|
61
61
|
|
|
62
|
-
### Option 4:
|
|
62
|
+
### Option 4: CircleCI configuration example
|
|
63
|
+
|
|
64
|
+
See the [CircleCI configuration example](documentation/circleci-config-example.md).
|
|
63
65
|
|
|
64
66
|
## ๐ Usage
|
|
65
67
|
|
|
@@ -116,60 +118,13 @@ node-lifecycle --version=18.20.4 --no-fail
|
|
|
116
118
|
|
|
117
119
|
## ๐งช CI Integration and GitHub Actions
|
|
118
120
|
|
|
119
|
-
### CircleCI
|
|
120
|
-
|
|
121
|
-
There are two ways to use `node-lifecycle` in CircleCI:
|
|
122
|
-
|
|
123
|
-
**Without installing in your repo (uses npx)**
|
|
124
|
-
|
|
125
|
-
This always fetches the latest published version from npm:
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
jobs:
|
|
129
|
-
verify:
|
|
130
|
-
docker:
|
|
131
|
-
- image: cimg/node:20.12
|
|
132
|
-
steps:
|
|
133
|
-
- checkout
|
|
134
|
-
- run:
|
|
135
|
-
name: Node lifecycle check
|
|
136
|
-
command: npx node-lifecycle --warn-days=180
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**With devDependencies (preferred if already in your repo)**
|
|
140
|
-
|
|
141
|
-
If you already have `node-lifecycle` in devDependencies, `npm ci` will install it and you can run it directly:
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
jobs:
|
|
145
|
-
verify:
|
|
146
|
-
docker:
|
|
147
|
-
- image: cimg/node:20.12
|
|
148
|
-
steps:
|
|
149
|
-
- checkout
|
|
150
|
-
- run: npm ci
|
|
151
|
-
- run:
|
|
152
|
-
name: Node lifecycle check
|
|
153
|
-
command: node-lifecycle --warn-days=180
|
|
154
|
-
```
|
|
155
|
-
|
|
156
121
|
### GitHub Actions
|
|
157
122
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
jobs:
|
|
162
|
-
check-node-lifecycle:
|
|
163
|
-
runs-on: ubuntu-latest
|
|
164
|
-
steps:
|
|
165
|
-
- uses: actions/checkout@v4
|
|
166
|
-
- run: npm install -g node-lifecycle
|
|
167
|
-
- run: node-lifecycle
|
|
168
|
-
```
|
|
123
|
+
See the [GitHub Actions configuration example](documentation/github-actions-config-example.md).
|
|
169
124
|
|
|
170
125
|
|
|
171
126
|
## ๐ License
|
|
172
127
|
|
|
173
|
-
MIT ยฉ
|
|
128
|
+
MIT ยฉ 2026 Kelsey Salguera
|
|
174
129
|
|
|
175
|
-
Note: This tool fetches Node.js release schedules from official sources (nodejs/Release and endoflife.date) and caches them locally for faster performance.
|
|
130
|
+
Note: This tool fetches Node.js release schedules from official sources (nodejs/Release and endoflife.date) and caches them locally for faster performance.
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-lifecycle",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CLI tool to check Node.js version lifecycle and EOL status",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
|
-
"start": "
|
|
14
|
+
"start": "npm run build && node dist/cli.js",
|
|
15
15
|
"test": "jest",
|
|
16
16
|
"test:watch": "jest --watch",
|
|
17
17
|
"prepublishOnly": "npm run build"
|
|
@@ -29,24 +29,25 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "git
|
|
32
|
+
"url": "git+https://github.com/ksalguera/node-lifecycle.git"
|
|
33
33
|
},
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/ksalguera/node-lifecycle/issues"
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/ksalguera/node-lifecycle#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"semver": "^7.6.0"
|
|
39
|
+
"semver": "^7.8.5"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
42
|
+
"@babel/core": "^7.29.7",
|
|
43
|
+
"@babel/preset-env": "^7.29.7",
|
|
44
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
43
45
|
"@types/jest": "^30.0.0",
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"@types/semver": "^7.
|
|
46
|
-
"jest": "^
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"typescript": "^5.0.0"
|
|
46
|
+
"@types/node": "^26.5.1",
|
|
47
|
+
"@types/semver": "^7.8.0",
|
|
48
|
+
"babel-jest": "^30.5.1",
|
|
49
|
+
"jest": "^30.5.1",
|
|
50
|
+
"typescript": "^7.0.2"
|
|
50
51
|
},
|
|
51
52
|
"engines": {
|
|
52
53
|
"node": ">=18.0.0"
|