forked from shareAI-lab/Kode-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-binary.mjs
More file actions
executable file
·57 lines (47 loc) · 1.3 KB
/
Copy pathbuild-binary.mjs
File metadata and controls
executable file
·57 lines (47 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bun
import { mkdirSync, rmSync } from 'node:fs'
import { dirname, join } from 'node:path'
function platformArchSuffix() {
const platform = process.platform
const arch = process.arch
return `${platform}-${arch}`
}
function outFileForCurrentPlatform() {
const suffix = platformArchSuffix()
const ext = process.platform === 'win32' ? '.exe' : ''
return join('dist', 'bin', suffix, `kode${ext}`)
}
function runOrThrow(cmd) {
const proc = Bun.spawnSync({
cmd,
stdout: 'inherit',
stderr: 'inherit',
})
if (proc.exitCode !== 0) {
throw new Error(`Command failed (${proc.exitCode}): ${cmd.join(' ')}`)
}
}
async function main() {
const outFile = outFileForCurrentPlatform()
const outDir = dirname(outFile)
rmSync(outDir, { recursive: true, force: true })
mkdirSync(outDir, { recursive: true })
console.log('🚀 Building standalone executable (Bun --compile)...')
console.log(`📦 Target: ${platformArchSuffix()}`)
console.log(`📍 Output: ${outFile}`)
runOrThrow([
'bun',
'build',
'--compile',
'--target=bun',
'--format=esm',
'--outfile',
outFile,
'src/entrypoints/index.ts',
])
console.log('✅ Binary build completed')
}
main().catch(err => {
console.error('❌ Binary build failed:', err)
process.exit(1)
})