|
| 1 | +import { describe, expect, test } from "bun:test" |
| 2 | +import path from "path" |
| 3 | + |
| 4 | +// Bun applies a patch only to the exact `name@version` named in |
| 5 | +// `patchedDependencies`. Bumping the dependency without regenerating the patch |
| 6 | +// does not fail `bun install`; the patch just stops applying and the runtime |
| 7 | +// silently loses whatever the patch fixed. This pins the two together for the |
| 8 | +// packages that ship in the CLI. |
| 9 | +const root = path.resolve(import.meta.dir, "../../..") |
| 10 | +const workspaces = ["packages/opencode", "packages/core"] |
| 11 | +const patched = (await Bun.file(path.join(root, "package.json")).json()).patchedDependencies as Record<string, string> |
| 12 | + |
| 13 | +describe("patched dependencies", () => { |
| 14 | + for (const key of Object.keys(patched)) { |
| 15 | + const at = key.lastIndexOf("@") |
| 16 | + const name = key.slice(0, at) |
| 17 | + const version = key.slice(at + 1) |
| 18 | + |
| 19 | + test(`${key} matches the installed version`, async () => { |
| 20 | + expect(await Bun.file(path.join(root, patched[key])).exists()).toBe(true) |
| 21 | + for (const workspace of workspaces) { |
| 22 | + const file = Bun.file(path.join(root, workspace, "node_modules", name, "package.json")) |
| 23 | + if (!(await file.exists())) continue |
| 24 | + const installed = (await file.json()).version as string |
| 25 | + expect(installed, `${workspace} resolves ${name}@${installed}; patch is for ${version}`).toBe(version) |
| 26 | + } |
| 27 | + }) |
| 28 | + } |
| 29 | +}) |
0 commit comments