From c066339d8035f98e3211e3278cd2e125b95a0bbf Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:59:45 -0500 Subject: [PATCH] test(opencode): guard patched dependency versions (#46673) --- package.json | 1 - .../test/patched-dependencies.test.ts | 29 +++++++++++++++++ patches/@ff-labs%2Ffff-bun@0.9.3.patch | 31 ------------------- 3 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 packages/opencode/test/patched-dependencies.test.ts delete mode 100644 patches/@ff-labs%2Ffff-bun@0.9.3.patch diff --git a/package.json b/package.json index dc4a813c505..8d58ace1b45 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,6 @@ }, "patchedDependencies": { "@dnd-kit/dom@0.5.0": "patches/@dnd-kit%2Fdom@0.5.0.patch", - "@ff-labs/fff-bun@0.9.3": "patches/@ff-labs%2Ffff-bun@0.9.3.patch", "@npmcli/agent@4.0.2": "patches/@npmcli%2Fagent@4.0.2.patch", "@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch", "@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch", diff --git a/packages/opencode/test/patched-dependencies.test.ts b/packages/opencode/test/patched-dependencies.test.ts new file mode 100644 index 00000000000..5405401bbe6 --- /dev/null +++ b/packages/opencode/test/patched-dependencies.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, test } from "bun:test" +import path from "path" + +// Bun applies a patch only to the exact `name@version` named in +// `patchedDependencies`. Bumping the dependency without regenerating the patch +// does not fail `bun install`; the patch just stops applying and the runtime +// silently loses whatever the patch fixed. This pins the two together for the +// packages that ship in the CLI. +const root = path.resolve(import.meta.dir, "../../..") +const workspaces = ["packages/opencode", "packages/core"] +const patched = (await Bun.file(path.join(root, "package.json")).json()).patchedDependencies as Record + +describe("patched dependencies", () => { + for (const key of Object.keys(patched)) { + const at = key.lastIndexOf("@") + const name = key.slice(0, at) + const version = key.slice(at + 1) + + test(`${key} matches the installed version`, async () => { + expect(await Bun.file(path.join(root, patched[key])).exists()).toBe(true) + for (const workspace of workspaces) { + const file = Bun.file(path.join(root, workspace, "node_modules", name, "package.json")) + if (!(await file.exists())) continue + const installed = (await file.json()).version as string + expect(installed, `${workspace} resolves ${name}@${installed}; patch is for ${version}`).toBe(version) + } + }) + } +}) diff --git a/patches/@ff-labs%2Ffff-bun@0.9.3.patch b/patches/@ff-labs%2Ffff-bun@0.9.3.patch deleted file mode 100644 index 23a7dd54fb1..00000000000 --- a/patches/@ff-labs%2Ffff-bun@0.9.3.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/src/download.ts b/src/download.ts -index 3454256..6dca25a 100644 ---- a/src/download.ts -+++ b/src/download.ts -@@ -7,7 +7,7 @@ - */ - -+declare const FFF_LIBC: "gnu" | "musl"; - import { existsSync } from "node:fs"; --import { createRequire } from "node:module"; - import { dirname, join } from "node:path"; - import { fileURLToPath } from "node:url"; - import { getLibFilename, getNpmPackageName } from "./platform"; -@@ -54,14 +54,10 @@ export function binaryExists(): boolean { - * in the same directory. - */ - function resolveFromNpmPackage(): string | null { -- const packageName = getNpmPackageName(); -- - try { -- // Use createRequire to resolve the platform package's location -- const require = createRequire(join(getPackageDir(), "package.json")); -- const packageJsonPath = require.resolve(`${packageName}/package.json`); -- const packageDir = dirname(packageJsonPath); -- const binaryPath = join(packageDir, getLibFilename()); -+ const binaryPath = require( -+ `@ff-labs/fff-bin-${process.platform === "linux" ? `linux-${process.arch}-${typeof FFF_LIBC === "string" ? FFF_LIBC : getNpmPackageName().endsWith("musl") ? "musl" : "gnu"}` : `${process.platform}-${process.arch}`}/${process.platform === "win32" ? "fff_c.dll" : process.platform === "darwin" ? "libfff_c.dylib" : "libfff_c.so"}`, -+ ); - - if (existsSync(binaryPath)) { - return binaryPath;