|
@@ -249,29 +249,22 @@ export namespace Config {
|
|
|
|
|
|
|
|
export async function installDependencies(dir: string) {
|
|
export async function installDependencies(dir: string) {
|
|
|
const pkg = path.join(dir, "package.json")
|
|
const pkg = path.join(dir, "package.json")
|
|
|
- const targetVersion = Installation.isLocal() ? "latest" : Installation.VERSION
|
|
|
|
|
-
|
|
|
|
|
- if (!(await Bun.file(pkg).exists())) {
|
|
|
|
|
- await Bun.write(pkg, "{}")
|
|
|
|
|
|
|
+ const targetVersion = Installation.isLocal() ? "*" : Installation.VERSION
|
|
|
|
|
+
|
|
|
|
|
+ const json = await Bun.file(pkg)
|
|
|
|
|
+ .json()
|
|
|
|
|
+ .catch(() => ({}))
|
|
|
|
|
+ json.dependencies = {
|
|
|
|
|
+ ...json.dependencies,
|
|
|
|
|
+ "@opencode-ai/plugin": targetVersion,
|
|
|
}
|
|
}
|
|
|
|
|
+ await Bun.write(pkg, JSON.stringify(json, null, 2))
|
|
|
|
|
+ await new Promise((resolve) => setTimeout(resolve, 3000))
|
|
|
|
|
|
|
|
const gitignore = path.join(dir, ".gitignore")
|
|
const gitignore = path.join(dir, ".gitignore")
|
|
|
const hasGitIgnore = await Bun.file(gitignore).exists()
|
|
const hasGitIgnore = await Bun.file(gitignore).exists()
|
|
|
if (!hasGitIgnore) await Bun.write(gitignore, ["node_modules", "package.json", "bun.lock", ".gitignore"].join("\n"))
|
|
if (!hasGitIgnore) await Bun.write(gitignore, ["node_modules", "package.json", "bun.lock", ".gitignore"].join("\n"))
|
|
|
|
|
|
|
|
- await BunProc.run(
|
|
|
|
|
- [
|
|
|
|
|
- "add",
|
|
|
|
|
- `@opencode-ai/plugin@${targetVersion}`,
|
|
|
|
|
- "--exact",
|
|
|
|
|
- // TODO: get rid of this case (see: https://github.com/oven-sh/bun/issues/19936)
|
|
|
|
|
- ...(proxied() ? ["--no-cache"] : []),
|
|
|
|
|
- ],
|
|
|
|
|
- {
|
|
|
|
|
- cwd: dir,
|
|
|
|
|
- },
|
|
|
|
|
- ).catch(() => {})
|
|
|
|
|
-
|
|
|
|
|
// Install any additional dependencies defined in the package.json
|
|
// Install any additional dependencies defined in the package.json
|
|
|
// This allows local plugins and custom tools to use external packages
|
|
// This allows local plugins and custom tools to use external packages
|
|
|
await BunProc.run(
|
|
await BunProc.run(
|