open-swe/tests/e2e/global-setup.ts
Johannes du Plessis e1d85526b6
chore: switch ui to pnpm (#1645)
* chore: require pnpm for ui agent work

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* chore: switch ui to pnpm

Replace Bun and Yarn lockfiles with pnpm lockfile and update UI/Vercel commands to use pnpm.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* ci: use corepack for ui pnpm e2e build

Run pnpm through Corepack in the E2E global setup so CI can use the pinned package manager without a separate pnpm install step.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-30 11:29:16 -07:00

24 lines
976 B
TypeScript

import { execSync } from "node:child_process";
import { existsSync } from "node:fs";
import { resolve } from "node:path";
// Build the real ui/ SPA once so the harness can serve it same-origin. The API
// base is baked in at build time, so it must match the harness port. Set
// E2E_FORCE_UI_BUILD=1 to rebuild (e.g. after changing the port or the UI).
export default function globalSetup() {
const repoRoot = resolve(__dirname, "..", "..");
const ui = resolve(repoRoot, "ui");
const shell = resolve(ui, ".output", "public", "_shell.html");
const port = process.env.E2E_PORT ?? "2024";
if (existsSync(shell) && !process.env.E2E_FORCE_UI_BUILD) return;
if (!existsSync(resolve(ui, "node_modules"))) {
execSync("corepack pnpm install --frozen-lockfile", { cwd: ui, stdio: "inherit" });
}
execSync("corepack pnpm run build", {
cwd: ui,
stdio: "inherit",
env: { ...process.env, VITE_DASHBOARD_API_BASE_URL: `http://127.0.0.1:${port}` },
});
}