refactor(config): prune unused format wrappers and launcher export

This commit is contained in:
morluto committed 2026-10-09 03:13:27 +08:00
1 parent d1c904bac7
commit 81ae838567
3 files changed
+2 -77

No files matched your search

@@ -38,37 +38,6 @@ export const configureClientConfiguration = (
return configureClientDocument(client, environment, command, client.format);
};
/** @deprecated Use configureClientConfiguration with the client's declared format. */
export const configureJsonClient = (
client: SetupClient,
environment: SetupProviderEnvironment = {},
command: readonly string[] = defaultCommand(),
): Promise<ClientConfigurationResult> =>
configureClientWithFormat(client, "json", environment, command);
/** @deprecated Use configureClientConfiguration with the client's declared format. */
export const configureTomlClient = (
client: SetupClient,
environment: SetupProviderEnvironment = {},
command: readonly string[] = defaultCommand(),
): Promise<ClientConfigurationResult> =>
configureClientWithFormat(client, "toml", environment, command);
const configureClientWithFormat = (
client: SetupClient,
format: "json" | "toml",
environment: SetupProviderEnvironment,
command: readonly string[],
): Promise<ClientConfigurationResult> => {
if (client.format !== undefined && client.format !== format)
return Promise.resolve({ status: "failed", reason: "readback" });
return configureClientConfiguration(
{ ...client, format: client.format ?? format },
environment,
command,
);
};
const configureClientDocument = async (
client: SetupClient,
environment: SetupProviderEnvironment,
+1 -1
View File
@@ -21,7 +21,7 @@ const executableAvailable = (path: string): boolean => {
}
};
export const defaultHopperLauncherPath = (
const defaultHopperLauncherPath = (
platform: NodeJS.Platform = process.platform,
homeDirectory: string = homedir(),
executable: (path: string) => boolean = executableAvailable,
@@ -3,11 +3,7 @@ import { join } from "node:path";
import { describe, expect, it } from "vitest";
import {
configureClientConfiguration,
configureJsonClient,
configureTomlClient,
} from "../../../src/application/SetupClientConfiguration.js";
import { configureClientConfiguration } from "../../../src/application/SetupClientConfiguration.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
describe("client configuration write failures", () => {
@@ -59,43 +55,3 @@ describe("TOML client configuration comparison", () => {
});
});
});
describe("format-specific compatibility entrypoints", () => {
it("defaults a missing client format for legacy JSON and TOML calls", async () => {
const root = await createTestTempDirectory("rea-client-compat-format-");
const jsonPath = join(root, "config.json");
const tomlPath = join(root, "config.toml");
expect(
await configureJsonClient({ name: "cursor", configPath: jsonPath }),
).toMatchObject({
status: "configured",
});
expect(await readFile(jsonPath, "utf8")).toContain('"mcpServers"');
expect(
await configureTomlClient({ name: "codex", configPath: tomlPath }),
).toMatchObject({
status: "configured",
});
expect(await readFile(tomlPath, "utf8")).toContain("[mcp_servers.rea]");
});
it.each([
["JSON", configureJsonClient, "toml"],
["TOML", configureTomlClient, "json"],
] as const)(
"rejects a mismatched %s compatibility format",
async (_name, configure, format) => {
const root = await createTestTempDirectory("rea-client-compat-mismatch-");
const configPath = join(root, "config");
const original = "keep this file unchanged\n";
await writeFile(configPath, original);
expect(await configure({ name: "fixture", configPath, format })).toEqual({
status: "failed",
reason: "readback",
});
expect(await readFile(configPath, "utf8")).toBe(original);
},
);
});