Skip to content

Commit 1a231fd

Browse files
authored
chore: Prefer Node.js LTS; set Node version to 24 (#81)
1 parent 322bf40 commit 1a231fd

6 files changed

Lines changed: 42 additions & 22 deletions

File tree

.github/scripts/update-toolchain-versions.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,42 +77,60 @@ const hasReleaseDelayElapsed = (publishedAt, now = Date.now()) => {
7777
return now - publishedTimestamp >= releaseDelayMs;
7878
};
7979

80-
// The updater tracks the exact current latest release for each ecosystem.
81-
// If that latest has not aged for a full 24 hours yet, it must not fall back to
82-
// an older version, because creating a PR for that older version would still
83-
// violate the latest-only cooldown rule.
80+
// The updater tracks the exact current latest eligible release for each ecosystem.
81+
// For Node.js, that means the latest release from an LTS line instead of the
82+
// overall latest Current release. If that latest eligible release has not aged
83+
// for a full 24 hours yet, it must not fall back to an older version, because
84+
// creating a PR for that older version would still violate the latest-only
85+
// cooldown rule.
8486
const logSkippedLatest = (ecosystem, version, publishedAt) => {
8587
console.log(
8688
[
87-
`Skipping ${ecosystem} update because the current latest release ${version} was published at ${publishedAt}.`,
88-
"The updater only adopts the current latest after a full 24-hour delay and never falls back to an older version while that latest is still cooling down.",
89+
`Skipping ${ecosystem} update because the current latest eligible release ${version} was published at ${publishedAt}.`,
90+
"The updater only adopts the current latest eligible release after a full 24-hour delay and never falls back to an older version while that release is still cooling down.",
8991
].join(" "),
9092
);
9193
};
9294

95+
const isNodeLtsRelease = (release) => {
96+
const lts = release?.lts;
97+
return lts === true || (typeof lts === "string" && lts.trim() !== "");
98+
};
99+
93100
const fetchLatestNodeMajor = async () => {
94-
const response = await fetch("https://api.github.com/repos/nodejs/node/releases/latest", {
101+
const response = await fetch("https://nodejs.org/dist/index.json", {
95102
headers: {
96-
Accept: "application/vnd.github+json",
103+
Accept: "application/json",
97104
"User-Agent": userAgent,
98105
},
99106
});
100107

101108
if (!response.ok) {
102-
throw new Error(`Failed to fetch the latest Node.js release: ${response.status} ${response.statusText}`);
109+
throw new Error(`Failed to fetch the Node.js release index: ${response.status} ${response.statusText}`);
110+
}
111+
112+
const releases = await response.json();
113+
114+
if (!Array.isArray(releases)) {
115+
throw new Error("Invalid Node.js release index payload");
103116
}
104117

105-
const latestRelease = await response.json();
106-
const latestVersion = typeof latestRelease.tag_name === "string" ? latestRelease.tag_name.trim() : "";
107-
const publishedAt = typeof latestRelease.published_at === "string" ? latestRelease.published_at.trim() : "";
118+
const latestRelease = releases.find(isNodeLtsRelease);
119+
120+
if (!latestRelease || typeof latestRelease !== "object") {
121+
throw new Error("Unable to resolve the latest Node.js LTS release");
122+
}
123+
124+
const latestVersion = typeof latestRelease.version === "string" ? latestRelease.version.trim() : "";
125+
const publishedAt = typeof latestRelease.date === "string" ? latestRelease.date.trim() : "";
108126
const parsedVersion = parseSemVer(latestVersion);
109127

110128
if (!parsedVersion) {
111-
throw new Error(`Invalid latest Node.js release version: ${latestVersion || "<empty>"}`);
129+
throw new Error(`Invalid latest Node.js LTS release version: ${latestVersion || "<empty>"}`);
112130
}
113131

114132
if (!hasReleaseDelayElapsed(publishedAt)) {
115-
logSkippedLatest("Node.js", latestVersion, publishedAt);
133+
logSkippedLatest("Node.js LTS", latestVersion, publishedAt);
116134
return null;
117135
}
118136

@@ -355,9 +373,11 @@ const nodeMajor = await fetchLatestNodeMajor();
355373
const pnpmVersion = await fetchLatestPnpmVersion();
356374

357375
if (nodeMajor === null) {
358-
console.log("Resolved latest Node.js major: skipped because the current latest release has not reached the 24-hour delay");
376+
console.log(
377+
"Resolved latest Node.js LTS major: skipped because the current latest eligible release has not reached the 24-hour delay",
378+
);
359379
} else {
360-
console.log(`Resolved latest Node.js major after 24-hour latest-only delay: ${nodeMajor}`);
380+
console.log(`Resolved latest Node.js LTS major after 24-hour latest-only delay: ${nodeMajor}`);
361381
}
362382

363383
if (pnpmVersion === null) {

.github/workflows/build-and-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
name: Set up Node.js
8585
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # https://github.com/actions/setup-node/tree/v6
8686
with:
87-
node-version: 25
87+
node-version: 24
8888
cache: 'pnpm'
8989
# 仅为当前会实际触发 pnpm 的变体提供缓存依赖路径。
9090
cache-dependency-path: ${{ steps.pnpm-cache-paths.outputs.paths }}

.github/workflows/ci-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Set up Node.js
4242
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # https://github.com/actions/setup-node/tree/v6
4343
with:
44-
node-version: 25
44+
node-version: 24
4545
cache: 'pnpm'
4646
cache-dependency-path: ${{ steps.pnpm-cache-paths.outputs.paths }}
4747
- name: Make gradlew executable

.github/workflows/update-toolchain-versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Node.js
2525
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # https://github.com/actions/setup-node/tree/v6
2626
with:
27-
node-version: 25
27+
node-version: 24
2828

2929
- name: Update toolchain versions
3030
id: update-toolchain
@@ -46,7 +46,7 @@ jobs:
4646
Releases are only considered eligible after a 1 day delay, matching the repository's Dependabot cooldown.
4747
4848
Resolved by automation:
49-
- Node.js major: `${{ steps.update-toolchain.outputs.node_major }}`
49+
- Node.js LTS major: `${{ steps.update-toolchain.outputs.node_major }}`
5050
- pnpm version: `${{ steps.update-toolchain.outputs.pnpm_version }}`
5151
branch: chore/update-toolchain-versions
5252
delete-branch: true

js-modules/shiki/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"vite": "8.0.3"
2222
},
2323
"engines": {
24-
"node": ">=25",
24+
"node": ">=24",
2525
"pnpm": "^10.33.0"
2626
},
2727
"packageManager": "pnpm@10.33.0"

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"vue-tsc": "^3.2.6"
5555
},
5656
"engines": {
57-
"node": ">=25",
57+
"node": ">=24",
5858
"pnpm": "^10.33.0"
5959
},
6060
"packageManager": "pnpm@10.33.0"

0 commit comments

Comments
 (0)