fix(plugins): resolve review findings and integrate main
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { copyFile, lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { delimiter, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { expect, it, onTestFinished } from "vitest";
|
||||
@@ -10,8 +10,8 @@ const launcher = fileURLToPath(
|
||||
new URL("../../../scripts/plugin-mcp-launcher.mjs", import.meta.url),
|
||||
);
|
||||
|
||||
const start = (path: string, version = "6.4.0-rc.1") => {
|
||||
const child = spawn(process.execPath, [launcher, version], {
|
||||
const start = (path: string, version = "6.4.0-rc.1", entry = launcher) => {
|
||||
const child = spawn(process.execPath, [entry, version], {
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: `${path}${delimiter}${process.env.PATH ?? ""}`,
|
||||
@@ -170,3 +170,68 @@ it("rejects a shell expression instead of treating it as the pinned package", as
|
||||
stderr: "REA plugin requires one exact rea-agents@VERSION pin.\n",
|
||||
});
|
||||
});
|
||||
|
||||
const pluginFixture = async () => {
|
||||
const root = await createTestTempDirectory("rea-plugin-release-origin-");
|
||||
await mkdir(join(root, "scripts"));
|
||||
await mkdir(join(root, "dist/mcp"), { recursive: true });
|
||||
const entry = join(root, "scripts/plugin-mcp-launcher.mjs");
|
||||
await copyFile(launcher, entry);
|
||||
await writeFile(
|
||||
join(root, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "rea-agents",
|
||||
version: "6.4.0",
|
||||
type: "module",
|
||||
}),
|
||||
);
|
||||
await writeFile(join(root, "dist/mcp/main.js"), "");
|
||||
await writeFile(
|
||||
join(root, "scripts/rea.mjs"),
|
||||
'process.stdout.write("bundled-runtime");',
|
||||
);
|
||||
return { root, entry };
|
||||
};
|
||||
|
||||
it
|
||||
.skipIf(process.platform === "win32")
|
||||
.each(["directory", "worktree file", "exported source"])(
|
||||
"uses the registry pin even when a %s checkout has same-version dist",
|
||||
async (kind) => {
|
||||
const { root, entry } = await pluginFixture();
|
||||
await mkdir(join(root, "src/application"), { recursive: true });
|
||||
await copyFile(
|
||||
fileURLToPath(
|
||||
new URL(
|
||||
"../../../src/application/PackageRunnerCommand.mjs",
|
||||
import.meta.url,
|
||||
),
|
||||
),
|
||||
join(root, "src/application/PackageRunnerCommand.mjs"),
|
||||
);
|
||||
if (kind === "directory") await mkdir(join(root, ".git"));
|
||||
else if (kind === "worktree file")
|
||||
await writeFile(join(root, ".git"), "gitdir: /fixture/worktree");
|
||||
const bin = await fakeRunner(
|
||||
"process.stdout.write(JSON.stringify(process.argv.slice(2)));",
|
||||
);
|
||||
const { child, closed } = start(bin, "6.4.0", entry);
|
||||
child.stdin.end();
|
||||
expect(await closed).toMatchObject({
|
||||
code: 0,
|
||||
stdout: '["-y","rea-agents@6.4.0","mcp"]',
|
||||
stderr: "",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("uses the matching installed runtime without another package-runner install", async () => {
|
||||
const { root, entry } = await pluginFixture();
|
||||
const { child, closed } = start(root, "6.4.0", entry);
|
||||
child.stdin.end();
|
||||
expect(await closed).toMatchObject({
|
||||
code: 0,
|
||||
stdout: "bundled-runtime",
|
||||
stderr: "",
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user