mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-03 15:00:24 +00:00
Refactor into plugin loader and do not enforce (#20112)
This commit is contained in:
parent
9f3c2bd861
commit
fa95a61c4e
17 changed files with 1056 additions and 351 deletions
|
|
@ -6,21 +6,14 @@ type PluginSpec = string | [string, Record<string, unknown>]
|
|||
|
||||
export function mockTuiRuntime(dir: string, plugin: PluginSpec[]) {
|
||||
process.env.OPENCODE_PLUGIN_META_FILE = path.join(dir, "plugin-meta.json")
|
||||
const meta = Object.fromEntries(
|
||||
plugin.map((item) => {
|
||||
const spec = Array.isArray(item) ? item[0] : item
|
||||
return [
|
||||
spec,
|
||||
{
|
||||
scope: "local" as const,
|
||||
source: path.join(dir, "tui.json"),
|
||||
},
|
||||
]
|
||||
}),
|
||||
)
|
||||
const plugin_records = plugin.map((item) => ({
|
||||
item,
|
||||
scope: "local" as const,
|
||||
source: path.join(dir, "tui.json"),
|
||||
}))
|
||||
const get = spyOn(TuiConfig, "get").mockResolvedValue({
|
||||
plugin,
|
||||
plugin_meta: meta,
|
||||
plugin_records,
|
||||
})
|
||||
const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue()
|
||||
const cwd = spyOn(process, "cwd").mockImplementation(() => dir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue