Update runtime checks and installer behavior

This commit is contained in:
Advait Paliwal
2026-03-25 13:55:32 -07:00
parent 572de7ba85
commit f6dbacc9d5
24 changed files with 431 additions and 21 deletions

View File

@@ -0,0 +1,35 @@
import test from "node:test";
import assert from "node:assert/strict";
import {
MIN_NODE_VERSION,
ensureSupportedNodeVersion,
getUnsupportedNodeVersionLines,
isSupportedNodeVersion,
} from "../src/system/node-version.js";
test("isSupportedNodeVersion enforces the exact minimum floor", () => {
assert.equal(isSupportedNodeVersion("20.18.1"), true);
assert.equal(isSupportedNodeVersion("20.19.0"), true);
assert.equal(isSupportedNodeVersion("21.0.0"), true);
assert.equal(isSupportedNodeVersion("20.18.0"), false);
assert.equal(isSupportedNodeVersion("18.17.0"), false);
});
test("ensureSupportedNodeVersion throws a guided upgrade message", () => {
assert.throws(
() => ensureSupportedNodeVersion("18.17.0"),
(error: unknown) =>
error instanceof Error &&
error.message.includes(`Node.js ${MIN_NODE_VERSION}`) &&
error.message.includes("nvm install 20 && nvm use 20") &&
error.message.includes("https://feynman.is/install"),
);
});
test("unsupported version guidance reports the detected version", () => {
const lines = getUnsupportedNodeVersionLines("18.17.0");
assert.equal(lines[0], "feynman requires Node.js 20.18.1 or later (detected 18.17.0).");
assert.ok(lines.some((line) => line.includes("curl -fsSL https://feynman.is/install | bash")));
});

View File

@@ -41,6 +41,7 @@ test("buildPiEnv wires Feynman paths into the Pi environment", () => {
assert.equal(env.FEYNMAN_SESSION_DIR, "/sessions");
assert.equal(env.FEYNMAN_BIN_PATH, "/repo/feynman/bin/feynman.js");
assert.equal(env.FEYNMAN_MEMORY_DIR, "/home/.feynman/memory");
assert.ok(env.PATH?.startsWith("/repo/feynman/node_modules/.bin:/repo/feynman/.feynman/npm/node_modules/.bin:"));
});
test("resolvePiPaths includes the Promise.withResolvers polyfill path", () => {