Files
rea/tests/conformance/package/environmentBundlePackagePin.test.ts
GamerDubzandgensokyo-dev 520f8e8042 fix(runtime): align remaining Node security pins and setup guidance (#6316)
Derive exported Docker image versions from .nvmrc through generated package metadata. Align active setup translations with patched Node release floors and verify actual CLI exports, real Docker/agentenv, package and website workflows.

Eight built-test shards pass; three unrelated managed source failures reproduce on clean main and remain tracked in #6650.

Refs #6480

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-10-23 11:03:03 +00:00

54 lines
1.9 KiB
TypeScript

import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
import { z } from "zod";
import {
bundleDockerfile,
registryPackageSource,
} from "../../../src/application/environment/environmentBundle.js";
import { PRODUCT_IDENTITY } from "../../../src/identity.js";
import { supportsNodeVersion } from "../../../src/domain/runtimeVersion.js";
/**
* The exported Dockerfile installs the CLI that produced the bundle, so the
* pin must be the exact package version of this build, read from the package
* manifest rather than restated anywhere in source.
*/
describe("environment bundle package pin", () => {
it("exports the pinned supported Node runtime in the Dockerfile", async () => {
const pinned = (
await readFile(new URL("../../../.nvmrc", import.meta.url), "utf8")
).trim();
const dockerfile = bundleDockerfile(registryPackageSource());
const nodeVersion = /^FROM node:(\d+\.\d+\.\d+)(?:[-@][^\s]+)?$/u.exec(
dockerfile.split("\n")[0] ?? "",
)?.[1];
expect(nodeVersion).toBe(pinned);
expect(supportsNodeVersion(nodeVersion ?? "")).toBe(true);
});
it("pins the registry install to the package.json version", async () => {
const manifest = z
.object({ name: z.literal("rea-agents"), version: z.string().min(1) })
.parse(
JSON.parse(
await readFile(
new URL("../../../package.json", import.meta.url),
"utf8",
),
),
);
const dockerfile = bundleDockerfile(registryPackageSource());
const install = dockerfile
.split("\n")
.find((line) => line.startsWith("RUN npm install -g"));
expect(install).toBeDefined();
expect(install?.endsWith(` ${manifest.name}@${manifest.version}`)).toBe(
true,
);
expect(PRODUCT_IDENTITY.packageVersion).toBe(manifest.version);
expect(dockerfile).not.toMatch(/rea-agents@(?:latest|\^|~)/u);
});
});