Skip to content

Commit 6e4db56

Browse files
authored
upgrade opentui to 0.2.14 (#28090)
1 parent 564cde3 commit 6e4db56

5 files changed

Lines changed: 99 additions & 29 deletions

File tree

bun.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"@types/cross-spawn": "6.0.6",
3636
"@octokit/rest": "22.0.0",
3737
"@hono/zod-validator": "0.4.2",
38-
"@opentui/core": "0.2.13",
39-
"@opentui/keymap": "0.2.13",
40-
"@opentui/solid": "0.2.13",
38+
"@opentui/core": "0.2.14",
39+
"@opentui/keymap": "0.2.14",
40+
"@opentui/solid": "0.2.14",
4141
"ulid": "3.0.1",
4242
"@kobalte/core": "0.13.11",
4343
"@types/luxon": "3.7.1",

packages/opencode/test/cli/tui/slot-replace.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ test("replace slot mounts plugin content once", async () => {
4141
)
4242
}
4343

44-
await testRender(() => <App />)
45-
46-
expect(mounts).toBe(1)
44+
const app = await testRender(() => <App />)
45+
try {
46+
expect(mounts).toBe(1)
47+
} finally {
48+
app.renderer.destroy()
49+
}
4750
})

packages/plugin/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"zod": "catalog:"
2323
},
2424
"peerDependencies": {
25-
"@opentui/core": ">=0.2.13",
26-
"@opentui/keymap": ">=0.2.13",
27-
"@opentui/solid": ">=0.2.13"
25+
"@opentui/core": ">=0.2.14",
26+
"@opentui/keymap": ">=0.2.14",
27+
"@opentui/solid": ">=0.2.14"
2828
},
2929
"peerDependenciesMeta": {
3030
"@opentui/core": {

script/upgrade-opentui.ts

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if (snapshotArg === "--snapshot=") {
3434

3535
const ver = raw.replace(/^v/, "")
3636
const root = path.resolve(import.meta.dir, "..")
37+
const lockfile = path.join(root, "bun.lock")
3738
const skip = new Set([".git", ".opencode", ".turbo", "dist", "node_modules"])
3839
const keys = ["@opentui/core", "@opentui/keymap", "@opentui/solid"] as const
3940

@@ -115,11 +116,77 @@ const out = (
115116
).filter((item): item is string => item !== null)
116117

117118
if (out.length === 0) {
118-
console.log("No opentui deps found")
119-
process.exit(0)
119+
console.log(`No opentui manifest updates needed for ${ver}`)
120+
}
121+
122+
if (out.length > 0) {
123+
console.log(`Updated opentui${snapshot ? " snapshot" : ""} to ${ver} in:`)
124+
for (const file of out) {
125+
console.log(`- ${file}`)
126+
}
127+
}
128+
129+
console.log("Running bun install to update bun.lock...")
130+
const install = Bun.spawn([process.execPath, "install"], {
131+
cwd: root,
132+
stdout: "inherit",
133+
stderr: "inherit",
134+
})
135+
const installCode = await install.exited
136+
if (installCode !== 0) process.exit(installCode)
137+
138+
const fixed = await fixKnownLockfileIssues()
139+
if (fixed.length > 0) {
140+
console.log("Removed stale opentui-spinner peer lockfile entries:")
141+
for (const item of fixed) {
142+
console.log(`- ${item}`)
143+
}
144+
}
145+
146+
const stale = await findStaleLockfileEntries()
147+
if (stale.length > 0) {
148+
console.error(`bun.lock still contains stale opentui versions after upgrading to ${ver}:`)
149+
for (const item of stale) {
150+
console.error(`- ${item.entry}: ${item.pkg}@${item.version}`)
151+
}
152+
process.exit(1)
153+
}
154+
155+
console.log("bun.lock opentui versions are consistent")
156+
157+
async function fixKnownLockfileIssues() {
158+
const txt = await Bun.file(lockfile).text()
159+
const stale = findStaleLockfileEntriesInText(txt)
160+
if (stale.length === 0) return []
161+
if (stale.some((item) => !item.entry.startsWith("opentui-spinner/@opentui/"))) return []
162+
163+
const removed = txt
164+
.split("\n")
165+
.map((line) => line.match(/^ "(opentui-spinner\/@opentui\/[^\"]+)": /)?.[1])
166+
.filter((item): item is string => item !== undefined)
167+
168+
if (removed.length === 0) return []
169+
170+
await Bun.write(
171+
lockfile,
172+
txt
173+
.split("\n")
174+
.filter((line) => !line.match(/^ "opentui-spinner\/@opentui\//))
175+
.join("\n"),
176+
)
177+
return removed
178+
}
179+
180+
async function findStaleLockfileEntries() {
181+
return findStaleLockfileEntriesInText(await Bun.file(lockfile).text())
120182
}
121183

122-
console.log(`Updated opentui${snapshot ? " snapshot" : ""} to ${ver} in:`)
123-
for (const file of out) {
124-
console.log(`- ${file}`)
184+
function findStaleLockfileEntriesInText(txt: string) {
185+
return Array.from(txt.matchAll(/^ "([^"]+)": \["(@opentui\/(?:core(?:-[^@"]+)?|keymap|solid))@([^"]+)"/gm))
186+
.map((match) => ({
187+
entry: match[1]!,
188+
pkg: match[2]!,
189+
version: match[3]!,
190+
}))
191+
.filter((item) => item.version !== ver)
125192
}

0 commit comments

Comments
 (0)