fix: use jsonc-parser for safe JSONC migration and add project-local config detection

This commit is contained in:
YeonGyu-Kim
2026-03-31 17:06:46 -07:00
parent 9f2c4500e8
commit 11ee88f28f
7 changed files with 187 additions and 54 deletions
+24
View File
@@ -1,3 +1,5 @@
/// <reference path="../../bun-test.d.ts" />
import { afterEach, beforeEach, describe, expect, it } from "bun:test"
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
@@ -80,4 +82,26 @@ describe("checkForLegacyPluginEntry", () => {
expect(result.legacyEntries).toEqual([])
expect(result.configPath).toBeNull()
})
describe("#given a project-local .opencode config contains a legacy plugin entry", () => {
it("#then detects the project-local config path", () => {
// given
const projectDir = join(testConfigDir, "project")
const projectConfigDir = join(projectDir, ".opencode")
mkdirSync(projectConfigDir, { recursive: true })
writeFileSync(
join(projectConfigDir, "opencode.json"),
JSON.stringify({ plugin: ["oh-my-opencode"] }, null, 2),
)
// when
const result = checkForLegacyPluginEntry(undefined, projectDir)
// then
expect(result.hasLegacyEntry).toBe(true)
expect(result.hasCanonicalEntry).toBe(false)
expect(result.legacyEntries).toEqual(["oh-my-opencode"])
expect(result.configPath).toBe(join(projectConfigDir, "opencode.json"))
})
})
})