From 4f839e6a8f025f7dea154bbd9fbabda635430d2f Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 25 Nov 2026 21:29:31 +0800 Subject: [PATCH] refactor(verifiers): share package fixture home settings (#14523) --- scripts/verify-package-environment.mjs | 22 +++++----------------- scripts/verify-package-home.mjs | 19 +++++++++++++++++++ scripts/verify-package-update.mjs | 19 ++++--------------- scripts/verify-published-package.mjs | 16 ++-------------- scripts/verify-windows-package.mjs | 16 ++-------------- 5 files changed, 32 insertions(+), 60 deletions(-) create mode 100644 scripts/verify-package-home.mjs diff --git a/scripts/verify-package-environment.mjs b/scripts/verify-package-environment.mjs index 5a0424c19b3..5ce801e1e37 100644 --- a/scripts/verify-package-environment.mjs +++ b/scripts/verify-package-environment.mjs @@ -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), diff --git a/scripts/verify-package-home.mjs b/scripts/verify-package-home.mjs new file mode 100644 index 00000000000..5ba16d7218b --- /dev/null +++ b/scripts/verify-package-home.mjs @@ -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"), +}); diff --git a/scripts/verify-package-update.mjs b/scripts/verify-package-update.mjs index a19a09e80af..81dc5f25564 100644 --- a/scripts/verify-package-update.mjs +++ b/scripts/verify-package-update.mjs @@ -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, diff --git a/scripts/verify-published-package.mjs b/scripts/verify-published-package.mjs index aae75a92297..298d28ea4b6 100644 --- a/scripts/verify-published-package.mjs +++ b/scripts/verify-published-package.mjs @@ -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, diff --git a/scripts/verify-windows-package.mjs b/scripts/verify-windows-package.mjs index ccc0379014f..4dae02be917 100644 --- a/scripts/verify-windows-package.mjs +++ b/scripts/verify-windows-package.mjs @@ -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(