mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-21 22:28:29 +08:00
PR #11591 rewrote build.ts during the sandbox refactor, which recreated the file with default 644 permissions and dropped the executable bit (100755 -> 100644). The same change stripped the bit from build-node.ts and publish.ts. The pre-release publish workflow invokes ./packages/opencode/script/build.ts directly, relying on its #!/usr/bin/env bun shebang. On Linux CI the non-executable mode fails with Permission denied before the build starts. Restore mode 100755 on all three scripts. Content is unchanged.
65 lines
1.8 KiB
TypeScript
Executable File
65 lines
1.8 KiB
TypeScript
Executable File
#!/usr/bin/env bun
|
|
|
|
import { Script } from "@opencode-ai/script"
|
|
import fs from "fs"
|
|
import path from "path"
|
|
import { fileURLToPath } from "url"
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = path.dirname(__filename)
|
|
const dir = path.resolve(__dirname, "..")
|
|
|
|
process.chdir(dir)
|
|
|
|
const generated = await import("./generate.ts")
|
|
|
|
// Load migrations from migration directories
|
|
const migrationDirs = (
|
|
await fs.promises.readdir(path.join(dir, "migration"), {
|
|
withFileTypes: true,
|
|
})
|
|
)
|
|
.filter((entry) => entry.isDirectory() && /^\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}/.test(entry.name))
|
|
.map((entry) => entry.name)
|
|
.sort()
|
|
|
|
const migrations = await Promise.all(
|
|
migrationDirs.map(async (name) => {
|
|
const file = path.join(dir, "migration", name, "migration.sql")
|
|
const sql = await Bun.file(file).text()
|
|
const match = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/.exec(name)
|
|
const timestamp = match
|
|
? Date.UTC(
|
|
Number(match[1]),
|
|
Number(match[2]) - 1,
|
|
Number(match[3]),
|
|
Number(match[4]),
|
|
Number(match[5]),
|
|
Number(match[6]),
|
|
)
|
|
: 0
|
|
return { sql, timestamp, name }
|
|
}),
|
|
)
|
|
console.log(`Loaded ${migrations.length} migrations`)
|
|
|
|
await Bun.build({
|
|
target: "node",
|
|
entrypoints: ["./src/node.ts", "../kilo-sandbox/src/kilo-sandbox-mutation-worker.ts"], // kilocode_change
|
|
outdir: "./dist/node",
|
|
format: "esm",
|
|
sourcemap: "linked",
|
|
external: ["jsonc-parser", "@lydell/node-pty"],
|
|
define: {
|
|
KILO_MIGRATIONS: JSON.stringify(migrations),
|
|
KILO_MODELS_DEV: generated.modelsData,
|
|
KILO_SANDBOX_MUTATION_WORKER_PATH: `'./kilo-sandbox-mutation-worker.js'`, // kilocode_change
|
|
KILO_CHANNEL: `'${Script.channel}'`,
|
|
},
|
|
files: {
|
|
"opencode-web-ui.gen.ts": "",
|
|
},
|
|
})
|
|
|
|
console.log("Build complete")
|