|
|
@@ -30,6 +30,7 @@ import { GlobalBus } from "@/bus/global"
|
|
|
import { Event } from "../server/event"
|
|
|
import { PackageRegistry } from "@/bun/registry"
|
|
|
import { proxied } from "@/util/proxied"
|
|
|
+import { iife } from "@/util/iife"
|
|
|
|
|
|
export namespace Config {
|
|
|
const log = Log.create({ service: "config" })
|
|
|
@@ -144,6 +145,8 @@ export namespace Config {
|
|
|
log.debug("loading config from OPENCODE_CONFIG_DIR", { path: Flag.OPENCODE_CONFIG_DIR })
|
|
|
}
|
|
|
|
|
|
+ const deps = []
|
|
|
+
|
|
|
for (const dir of unique(directories)) {
|
|
|
if (dir.endsWith(".opencode") || dir === Flag.OPENCODE_CONFIG_DIR) {
|
|
|
for (const file of ["opencode.jsonc", "opencode.json"]) {
|
|
|
@@ -156,10 +159,12 @@ export namespace Config {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const shouldInstall = await needsInstall(dir)
|
|
|
- if (shouldInstall) {
|
|
|
- await installDependencies(dir)
|
|
|
- }
|
|
|
+ deps.push(
|
|
|
+ iife(async () => {
|
|
|
+ const shouldInstall = await needsInstall(dir)
|
|
|
+ if (shouldInstall) await installDependencies(dir)
|
|
|
+ }),
|
|
|
+ )
|
|
|
|
|
|
result.command = mergeDeep(result.command ?? {}, await loadCommand(dir))
|
|
|
result.agent = mergeDeep(result.agent, await loadAgent(dir))
|
|
|
@@ -233,9 +238,15 @@ export namespace Config {
|
|
|
return {
|
|
|
config: result,
|
|
|
directories,
|
|
|
+ deps,
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ export async function waitForDependencies() {
|
|
|
+ const deps = await state().then((x) => x.deps)
|
|
|
+ await Promise.all(deps)
|
|
|
+ }
|
|
|
+
|
|
|
export async function installDependencies(dir: string) {
|
|
|
const pkg = path.join(dir, "package.json")
|
|
|
const targetVersion = Installation.isLocal() ? "latest" : Installation.VERSION
|