fix(setup): align Node runtime checks with package engines

This commit is contained in:
Kaoru0822
2026-10-05 22:13:22 -07:00
parent 19f8cddfd6
commit ea0b733687
18 changed files with 121 additions and 40 deletions
+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import { supportsNodeVersion } from "./runtimeVersion.js";
describe("supported Node.js versions", () => {
it.each([
["20.0.0", false],
["22.18.9", false],
["22.19.0", true],
["22.99.0", true],
["23.0.0", false],
["24.10.9", false],
["24.11.0", true],
["24.99.0", true],
["25.1.0", false],
["26.0.0", true],
["27.0.0", true],
["24.11.0-rc.1", false],
["26.0.0-nightly.20261001", false],
["24.11", false],
["24.11.invalid", false],
["invalid", false],
])("classifies %s as supported=%s", (version, expected) => {
expect(supportsNodeVersion(version)).toBe(expected);
});
});
+7 -9
View File
@@ -1,10 +1,8 @@
import { satisfies } from "semver";
/** Supported runtime range, kept in sync with the published package engines. */
export const SUPPORTED_NODE_VERSION_RANGE = "^22.19.0 || ^24.11.0 || >=26.0.0";
/** Return whether a Node.js version satisfies REA's tested runtime families. */
export const supportsNodeVersion = (version: string): boolean => {
const [majorText = "", minorText = ""] = version.split(".");
const major = Number.parseInt(majorText, 10);
const minor = Number.parseInt(minorText, 10);
return (
(major === 22 && minor >= 19) ||
(major >= 24 && (major !== 24 || minor >= 11))
);
};
export const supportsNodeVersion = (version: string): boolean =>
satisfies(version, SUPPORTED_NODE_VERSION_RANGE);