Skip to content

Commit c066339

Browse files
authored
test(opencode): guard patched dependency versions (anomalyco#46673)
1 parent 1542195 commit c066339

3 files changed

Lines changed: 29 additions & 32 deletions

File tree

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
},
147147
"patchedDependencies": {
148148
"@dnd-kit/[email protected]": "patches/@dnd-kit%[email protected]",
149-
"@ff-labs/[email protected]": "patches/@ff-labs%[email protected]",
150149
"@npmcli/[email protected]": "patches/@npmcli%[email protected]",
151150
"@silvia-odwyer/[email protected]": "patches/@silvia-odwyer%[email protected]",
152151
"@standard-community/[email protected]": "patches/@standard-community%[email protected]",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
})

‎patches/@ff-labs%[email protected]‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)