mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 13:24:20 +00:00
refactor(verifiers): share package fixture home settings (#14523)
This commit is contained in:
1 parent
63d1ecac00
commit
4f839e6a8f
5 files changed
+32
-60
No files matched your search
@@ -2,6 +2,7 @@ import { chmod, mkdir, symlink, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { supportedClients } from "../dist/application/SupportedClients.js";
|
||||
import { packageVerifierHomeEnvironment } from "./verify-package-home.mjs";
|
||||
|
||||
/** Create an isolated prefix, fake PATH, client configs, and environment. */
|
||||
export async function verifyPackageEnvironment({
|
||||
@@ -55,15 +56,15 @@ export async function verifyPackageEnvironment({
|
||||
)?.markerPath;
|
||||
if (claudeDir === undefined)
|
||||
throw new Error("Claude Desktop fixture has no configuration directory");
|
||||
const codexDir = join(home, ".codex");
|
||||
const homeEnvironment = packageVerifierHomeEnvironment(home);
|
||||
const cursorDir = join(home, ".cursor");
|
||||
await Promise.all([
|
||||
mkdir(claudeDir, { recursive: true }),
|
||||
mkdir(codexDir, { recursive: true }),
|
||||
mkdir(homeEnvironment.CODEX_HOME, { recursive: true }),
|
||||
mkdir(cursorDir, { recursive: true }),
|
||||
]);
|
||||
const claudeConfig = join(claudeDir, "claude_desktop_config.json");
|
||||
const codexConfig = join(codexDir, "config.toml");
|
||||
const codexConfig = join(homeEnvironment.CODEX_HOME, "config.toml");
|
||||
const codexTarget = join(home, "managed-codex.toml");
|
||||
const cursorConfig = join(cursorDir, "mcp.json");
|
||||
const cursorTarget = join(home, "managed-cursor.json");
|
||||
@@ -74,26 +75,13 @@ export async function verifyPackageEnvironment({
|
||||
await symlink(cursorTarget, cursorConfig);
|
||||
const environment = {
|
||||
...process.env,
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
APPDATA: join(home, "AppData", "Roaming"),
|
||||
LOCALAPPDATA: join(home, "AppData", "Local"),
|
||||
CLAUDE_CONFIG_DIR: home,
|
||||
CODEX_HOME: codexDir,
|
||||
COPILOT_HOME: join(home, ".copilot"),
|
||||
GROK_HOME: join(home, ".grok"),
|
||||
SAND_DATA_ROOT: join(home, ".grokbot"),
|
||||
OMP_PROFILE: undefined,
|
||||
PI_CODING_AGENT_DIR: undefined,
|
||||
PI_CONFIG_DIR: undefined,
|
||||
PI_PROFILE: undefined,
|
||||
...homeEnvironment,
|
||||
QWEN_HOME: undefined,
|
||||
OPENCODE_CONFIG: undefined,
|
||||
OPENCODE_CONFIG_DIR: undefined,
|
||||
GEMINI_CLI_HOME: undefined,
|
||||
GEMINI_CLI_SYSTEM_SETTINGS_PATH: undefined,
|
||||
GEMINI_CLI_SYSTEM_DEFAULTS_PATH: undefined,
|
||||
XDG_CONFIG_HOME: join(home, ".config"),
|
||||
PATH: `${fakeBin}:${process.env.PATH ?? ""}`,
|
||||
REA_ANALYSIS_PROVIDER: "auto",
|
||||
...packageHopperEnvironment(root),
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { join } from "node:path";
|
||||
|
||||
/** Point package verification at the selected fixture home and clear profile overrides. */
|
||||
export const packageVerifierHomeEnvironment = (home) => ({
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
APPDATA: join(home, "AppData", "Roaming"),
|
||||
LOCALAPPDATA: join(home, "AppData", "Local"),
|
||||
CLAUDE_CONFIG_DIR: home,
|
||||
CODEX_HOME: join(home, ".codex"),
|
||||
COPILOT_HOME: join(home, ".copilot"),
|
||||
GROK_HOME: join(home, ".grok"),
|
||||
SAND_DATA_ROOT: join(home, ".grokbot"),
|
||||
OMP_PROFILE: undefined,
|
||||
PI_CODING_AGENT_DIR: undefined,
|
||||
PI_CONFIG_DIR: undefined,
|
||||
PI_PROFILE: undefined,
|
||||
XDG_CONFIG_HOME: join(home, ".config"),
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import { readFile, writeFile, mkdir } from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
import { packageVerifierHomeEnvironment } from "./verify-package-home.mjs";
|
||||
import { withVerifierCleanup } from "./lib/verifier-cleanup.mjs";
|
||||
|
||||
/** Exercise the packaged updater with real npm and a local release registry fixture. */
|
||||
@@ -20,7 +21,8 @@ export async function verifyPackageUpdate({
|
||||
const archive = await readFile(tarball);
|
||||
const entry = join(packageRoot, "scripts", "rea.mjs");
|
||||
const home = join(workspace, "update-home");
|
||||
const codexPath = join(home, ".codex", "config.toml");
|
||||
const homeEnvironment = packageVerifierHomeEnvironment(home);
|
||||
const codexPath = join(homeEnvironment.CODEX_HOME, "config.toml");
|
||||
const originalConfig =
|
||||
'[mcp_servers.rea]\ncommand = "npx"\nargs = ["-y", "rea-agents@0.0.0", "mcp"]\n';
|
||||
await mkdir(dirname(codexPath), { recursive: true });
|
||||
@@ -126,20 +128,7 @@ export async function verifyPackageUpdate({
|
||||
);
|
||||
const runtimeEnvironment = {
|
||||
...environment,
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
APPDATA: join(home, "AppData", "Roaming"),
|
||||
LOCALAPPDATA: join(home, "AppData", "Local"),
|
||||
CLAUDE_CONFIG_DIR: home,
|
||||
CODEX_HOME: join(home, ".codex"),
|
||||
COPILOT_HOME: join(home, ".copilot"),
|
||||
GROK_HOME: join(home, ".grok"),
|
||||
SAND_DATA_ROOT: join(home, ".grokbot"),
|
||||
OMP_PROFILE: undefined,
|
||||
PI_CODING_AGENT_DIR: undefined,
|
||||
PI_CONFIG_DIR: undefined,
|
||||
PI_PROFILE: undefined,
|
||||
XDG_CONFIG_HOME: join(home, ".config"),
|
||||
...homeEnvironment,
|
||||
OPENCODE_CONFIG: join(home, ".config", "opencode", "opencode.json"),
|
||||
npm_config_prefix: prefix,
|
||||
npm_config_registry: registry,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { packageVerifierHomeEnvironment } from "./verify-package-home.mjs";
|
||||
import { createPackageVerifierCommands } from "./lib/verify-package-commands.mjs";
|
||||
import { withVerifierCleanup } from "./lib/verifier-cleanup.mjs";
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
@@ -76,20 +77,7 @@ async function verifyPublishedUpdate({
|
||||
const home = join(canaryRoot, "update-home");
|
||||
const environment = {
|
||||
...process.env,
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
APPDATA: join(home, "AppData", "Roaming"),
|
||||
LOCALAPPDATA: join(home, "AppData", "Local"),
|
||||
CLAUDE_CONFIG_DIR: home,
|
||||
CODEX_HOME: join(home, ".codex"),
|
||||
COPILOT_HOME: join(home, ".copilot"),
|
||||
GROK_HOME: join(home, ".grok"),
|
||||
SAND_DATA_ROOT: join(home, ".grokbot"),
|
||||
OMP_PROFILE: undefined,
|
||||
PI_CODING_AGENT_DIR: undefined,
|
||||
PI_CONFIG_DIR: undefined,
|
||||
PI_PROFILE: undefined,
|
||||
XDG_CONFIG_HOME: join(home, ".config"),
|
||||
...packageVerifierHomeEnvironment(home),
|
||||
OPENCODE_CONFIG: join(home, ".config", "opencode", "opencode.json"),
|
||||
npm_config_cache: join(canaryRoot, "npm-cache"),
|
||||
npm_config_prefix: prefix,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { parse as parseJsonc } from "jsonc-parser";
|
||||
import { supportedClients } from "../dist/application/SupportedClients.js";
|
||||
import { GHIDRA_BRIDGE_SOURCES } from "../src/ghidra/GhidraBridgeSources.ts";
|
||||
|
||||
import { packageVerifierHomeEnvironment } from "./verify-package-home.mjs";
|
||||
import { verifyCanaryMcp } from "./lib/release-package-canary.mjs";
|
||||
import { createPackageVerifierCommands } from "./lib/verify-package-commands.mjs";
|
||||
import { withVerifierCleanup } from "./lib/verifier-cleanup.mjs";
|
||||
@@ -152,21 +153,8 @@ try {
|
||||
const home = join(workspace, "home");
|
||||
const setupEnvironment = {
|
||||
...environment,
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
APPDATA: join(home, "AppData", "Roaming"),
|
||||
LOCALAPPDATA: join(home, "AppData", "Local"),
|
||||
CLAUDE_CONFIG_DIR: home,
|
||||
CODEX_HOME: join(home, ".codex"),
|
||||
XDG_CONFIG_HOME: join(home, ".config"),
|
||||
...packageVerifierHomeEnvironment(home),
|
||||
OPENCODE_CONFIG: join(home, ".config", "opencode", "opencode.jsonc"),
|
||||
COPILOT_HOME: join(home, ".copilot"),
|
||||
GROK_HOME: join(home, ".grok"),
|
||||
SAND_DATA_ROOT: join(home, ".grokbot"),
|
||||
OMP_PROFILE: undefined,
|
||||
PI_CODING_AGENT_DIR: undefined,
|
||||
PI_CONFIG_DIR: undefined,
|
||||
PI_PROFILE: undefined,
|
||||
};
|
||||
await mkdir(join(home, ".config", "opencode"), { recursive: true });
|
||||
await writeFile(
|
||||
|
||||
Reference in new issue
Block a user