fix(setup): persist detected Hopper launcher

This commit is contained in:
morluto
2026-07-12 09:12:13 +08:00
parent 88f5edc236
commit b2866e4706
3 changed files with 43 additions and 3 deletions
+5
View File
@@ -22,6 +22,7 @@ class FakeSetupHost implements SetupHost {
homebrewInstalls = 0;
hopperInstalls = 0;
configurations = 0;
configuredHopperPaths: string[] = [];
macosVersion = (): Promise<string | undefined> =>
Promise.resolve(this.version);
@@ -41,8 +42,10 @@ class FakeSetupHost implements SetupHost {
Promise.resolve(this.clients);
configureClient = (
client: SetupClient,
hopperPath: string,
): Promise<ClientConfigurationResult> => {
this.configurations += 1;
this.configuredHopperPaths.push(hopperPath);
return Promise.resolve(
this.clientResults.get(client.name) ?? {
status: "configured",
@@ -99,6 +102,7 @@ describe("setup workflow", () => {
host.hopper = "/Applications/Manual Hopper";
expect((await runSetup(true, host)).actions).toEqual(["installed_skill"]);
expect(host.hopperInstalls).toBe(0);
expect(host.configuredHopperPaths).toEqual([]);
});
it.each(["homebrew", "hopper"] as const)(
@@ -127,6 +131,7 @@ describe("setup workflow", () => {
const result = await runSetup(true, host);
expect(Object.keys(result.clients)).toEqual(["claude", "cursor"]);
expect(host.configurations).toBe(2);
expect(host.configuredHopperPaths).toEqual(["/Hopper", "/Hopper"]);
});
it.each(["backup", "write", "readback"] as const)(
+22
View File
@@ -49,6 +49,28 @@ describe("JSON client configuration transaction", () => {
).rejects.toThrow();
});
it("persists a custom Hopper launcher and remains idempotent", async () => {
directory = await mkdtemp(join(tmpdir(), "rea-setup-"));
const configPath = join(directory, "mcp.json");
const hopperPath = "/Applications/Hopper v6.app/Contents/MacOS/hopper";
const client = { name: "cursor", configPath };
expect(await configureJsonClient(client, hopperPath)).toMatchObject({
status: "configured",
});
expect(JSON.parse(await readFile(configPath, "utf8"))).toMatchObject({
mcpServers: {
rea: {
command: "npx",
args: ["-y", "@morluto/rea", "mcp"],
env: { HOPPER_LAUNCHER_PATH: hopperPath },
},
},
});
expect(await configureJsonClient(client, hopperPath)).toEqual({
status: "unchanged",
});
});
it("refuses malformed existing JSON without overwriting it", async () => {
directory = await mkdtemp(join(tmpdir(), "rea-setup-"));
const configPath = join(directory, "mcp.json");