feat(vscode): add dev-snapshot build script with username in version

This commit is contained in:
kirillk
2026-03-13 12:20:42 -04:00
parent 8ff7f2d029
commit b535131c0b
3 changed files with 83 additions and 0 deletions
+13
View File
@@ -46,6 +46,19 @@
If you want to contribute or modify the extension locally, see the [DEVELOPMENT.md](/DEVELOPMENT.md) file for build and setup instructions.
### Snapshot Builds
To build and share a development snapshot of the extension:
```bash
# Build only (outputs VSIX to system temp dir)
bun run snapshot:build
# Build and install directly into VS Code
bun run snapshot:install
```
## Contributing
We welcome contributions from developers, writers, and enthusiasts!
+2
View File
@@ -692,6 +692,8 @@
},
"scripts": {
"prepare:cli-binary": "bun script/local-bin.ts",
"snapshot:build": "bun script/dev-snapshot.ts build",
"snapshot:install": "bun script/dev-snapshot.ts install",
"compile": "bun run prepare:cli-binary && bun run rebuild-sdk && bun run typecheck && bun run lint && node esbuild.js",
"watch": "bun run rebuild-sdk && bun run --parallel watch:esbuild watch:tsc",
"watch:esbuild": "bun run prepare:cli-binary && node esbuild.js --watch",
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env bun
import { $ } from "bun"
import { join } from "node:path"
import { tmpdir } from "node:os"
import { rmSync, mkdirSync, existsSync } from "node:fs"
const mode = process.argv[2] ?? "install"
const shouldInstall = mode === "install"
const root = join(import.meta.dir, "..")
const pkgPath = join(root, "package.json")
const pkg = await Bun.file(pkgPath).json()
const sha = (await $`git rev-parse --short HEAD`.text()).trim()
const user = (await $`git config user.name`.text()).trim().toLowerCase().replace(/\s+/g, "-")
const snapshotVersion = `${pkg.version}-snapshot+${sha}.${user}`
console.log(`Building snapshot version: ${snapshotVersion}`)
console.log(`Base version: ${pkg.version}`)
console.log(`Commit: ${sha}`)
console.log(`Mode: ${mode}\n`)
console.log("🧹 Cleaning build directories...")
for (const dir of ["bin", "dist"]) {
const dirPath = join(root, dir)
if (existsSync(dirPath)) {
rmSync(dirPath, { recursive: true, force: true })
console.log(` ✓ Cleaned ${dir}/`)
}
}
const outDir = join(tmpdir(), "kilo-vscode-snapshots")
mkdirSync(outDir, { recursive: true })
console.log("\n📦 Rebuilding SDK...")
await $`bun run --cwd ../sdk/js build`.cwd(root)
console.log("\n🔧 Preparing CLI binary...")
await $`bun script/local-bin.ts`.cwd(root)
console.log("\n✅ Type-checking...")
await $`bun run check-types`.cwd(root)
console.log("\n🔍 Linting...")
await $`bun run lint`.cwd(root)
console.log("\n🏗️ Building extension...")
await $`node ${join(root, "esbuild.js")} --production`.cwd(root)
console.log("\n📦 Packaging VSIX...")
const vsixPath = join(outDir, `kilo-vscode-snapshot-${sha}.vsix`)
await $`bunx vsce package ${snapshotVersion} --no-update-package-json --no-dependencies --skip-license -o ${vsixPath}`.cwd(
root,
)
console.log(`\n✅ VSIX created: ${vsixPath}`)
if (shouldInstall) {
const execPath = process.env.VSCODE_EXEC_PATH ?? ""
const cli = execPath.toLowerCase().includes("insiders") ? "code-insiders" : "code"
console.log(`\n🚀 Installing to ${cli}...`)
await $`${cli} --force --install-extension ${vsixPath}`
console.log(`\n✨ Successfully installed snapshot extension!`)
console.log(` Version: ${snapshotVersion}`)
} else {
console.log(`\n📍 VSIX path: ${vsixPath}`)
}