fix(auto-update): pipe bun install output and restore other-deps preservation test
background-update-check.ts was using runBunInstall() which defaults to outputMode:"inherit", leaking bun install stdout/stderr into the background session. Reverted to runBunInstallWithDetails({ outputMode: "pipe" }) and explicitly logs result.error on failure.
Restores the accidentally deleted test case asserting that sibling dependencies (e.g. other:"1.0.0") are preserved in package.json after a plugin version sync.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -198,6 +198,28 @@ describe("syncCachePackageJsonToIntent", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("#given cache package.json with other dependencies", () => {
|
||||||
|
it("#then other dependencies are preserved when updating plugin version", async () => {
|
||||||
|
const { syncCachePackageJsonToIntent } = await import("./sync-package-json")
|
||||||
|
|
||||||
|
const pluginInfo: PluginEntryInfo = {
|
||||||
|
entry: "oh-my-opencode@latest",
|
||||||
|
isPinned: false,
|
||||||
|
pinnedVersion: "latest",
|
||||||
|
configPath: "/tmp/opencode.json",
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = syncCachePackageJsonToIntent(pluginInfo)
|
||||||
|
|
||||||
|
expect(result.synced).toBe(true)
|
||||||
|
expect(result.error).toBeNull()
|
||||||
|
|
||||||
|
const content = readFileSync(join(TEST_CACHE_DIR, "package.json"), "utf-8")
|
||||||
|
const pkg = JSON.parse(content) as { dependencies?: Record<string, string> }
|
||||||
|
expect(pkg.dependencies?.["other"]).toBe("1.0.0")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("#given malformed JSON in cache package.json", () => {
|
describe("#given malformed JSON in cache package.json", () => {
|
||||||
it("#then returns parse_error", async () => {
|
it("#then returns parse_error", async () => {
|
||||||
cleanupTestCache()
|
cleanupTestCache()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
import { runBunInstall } from "../../../cli/config-manager"
|
import { runBunInstallWithDetails } from "../../../cli/config-manager"
|
||||||
import { log } from "../../../shared/logger"
|
import { log } from "../../../shared/logger"
|
||||||
import { invalidatePackage } from "../cache"
|
import { invalidatePackage } from "../cache"
|
||||||
import { PACKAGE_NAME } from "../constants"
|
import { PACKAGE_NAME } from "../constants"
|
||||||
@@ -13,7 +13,11 @@ function getPinnedVersionToastMessage(latestVersion: string): string {
|
|||||||
|
|
||||||
async function runBunInstallSafe(): Promise<boolean> {
|
async function runBunInstallSafe(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
return await runBunInstall()
|
const result = await runBunInstallWithDetails({ outputMode: "pipe" })
|
||||||
|
if (!result.success && result.error) {
|
||||||
|
log("[auto-update-checker] bun install error:", result.error)
|
||||||
|
}
|
||||||
|
return result.success
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errorMessage = err instanceof Error ? err.message : String(err)
|
const errorMessage = err instanceof Error ? err.message : String(err)
|
||||||
log("[auto-update-checker] bun install error:", errorMessage)
|
log("[auto-update-checker] bun install error:", errorMessage)
|
||||||
|
|||||||
Reference in New Issue
Block a user