From 7b79823b24cd3b245c7c6394520f878440184b30 Mon Sep 17 00:00:00 2001 From: Josh Palmer Date: Fri, 9 Jan 2026 13:38:46 +0100 Subject: [PATCH] Adjust UI install for offline pnpm fetch (#568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🤖 codex: make ui build install prod deps for offline pnpm (issue-pnpm-offline) * 🤖 codex: ensure ui:test installs dev deps (issue-pnpm-offline) --- pnpm-lock.yaml | 6 +++--- scripts/ui.js | 31 ++++++++++++++++++++++++++----- ui/package.json | 4 ++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5e4aa8faa..f4900ffeb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -233,6 +233,9 @@ importers: marked: specifier: ^17.0.1 version: 17.0.1 + vite: + specifier: 7.3.1 + version: 7.3.1(@types/node@25.0.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)(yaml@2.8.2) devDependencies: '@vitest/browser-playwright': specifier: 4.0.16 @@ -243,9 +246,6 @@ importers: typescript: specifier: ^5.9.3 version: 5.9.3 - vite: - specifier: 7.3.1 - version: 7.3.1(@types/node@25.0.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)(yaml@2.8.2) vitest: specifier: 4.0.16 version: 4.0.16(@types/node@25.0.3)(@vitest/browser-playwright@4.0.16)(@vitest/browser-preview@4.0.16)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)(yaml@2.8.2) diff --git a/scripts/ui.js b/scripts/ui.js index 8296491b7..16f112ee3 100644 --- a/scripts/ui.js +++ b/scripts/ui.js @@ -64,21 +64,26 @@ function run(cmd, args) { }); } -function runSync(cmd, args) { +function runSync(cmd, args, envOverride) { const result = spawnSync(cmd, args, { cwd: uiDir, stdio: "inherit", - env: process.env, + env: envOverride ?? process.env, }); if (result.signal) process.exit(1); if ((result.status ?? 1) !== 0) process.exit(result.status ?? 1); } -function depsInstalled() { +function depsInstalled(kind) { try { const require = createRequire(path.join(uiDir, "package.json")); require.resolve("vite"); require.resolve("dompurify"); + if (kind === "test") { + require.resolve("vitest"); + require.resolve("@vitest/browser-playwright"); + require.resolve("playwright"); + } return true; } catch { return false; @@ -118,13 +123,29 @@ if (action !== "install" && !script) { if (runner.kind === "bun") { if (action === "install") run(runner.cmd, ["install", ...rest]); else { - if (!depsInstalled()) runSync(runner.cmd, ["install"]); + if (!depsInstalled(action === "test" ? "test" : "build")) { + const installEnv = + action === "build" + ? { ...process.env, NODE_ENV: "production" } + : process.env; + const installArgs = + action === "build" ? ["install", "--production"] : ["install"]; + runSync(runner.cmd, installArgs, installEnv); + } run(runner.cmd, ["run", script, ...rest]); } } else { if (action === "install") run(runner.cmd, ["install", ...rest]); else { - if (!depsInstalled()) runSync(runner.cmd, ["install"]); + if (!depsInstalled(action === "test" ? "test" : "build")) { + const installEnv = + action === "build" + ? { ...process.env, NODE_ENV: "production" } + : process.env; + const installArgs = + action === "build" ? ["install", "--prod"] : ["install"]; + runSync(runner.cmd, installArgs, installEnv); + } run(runner.cmd, ["run", script, ...rest]); } } diff --git a/ui/package.json b/ui/package.json index 5cf8d4a01..3a656cc4f 100644 --- a/ui/package.json +++ b/ui/package.json @@ -11,13 +11,13 @@ "dependencies": { "dompurify": "^3.3.1", "lit": "^3.3.2", - "marked": "^17.0.1" + "marked": "^17.0.1", + "vite": "7.3.1" }, "devDependencies": { "@vitest/browser-playwright": "4.0.16", "playwright": "^1.57.0", "typescript": "^5.9.3", - "vite": "7.3.1", "vitest": "4.0.16" } }