ReviewOS

also looking at this

craft-native/craft

Test the built native CLI startup in CI

#317
Merged glennmichael123 wants to merge codex/native-startup-rehearsal into main
3 files +54 -2
scripts/verify-native-startup.tsadded+20-0
Changes to scripts/verify-native-startup.ts
@@ -0,0 +1,20 @@
1import { resolve } from 'node:path'
2
3export function verifyNativeStartup(binary: string, version: string): void {
4 const result = Bun.spawnSync([resolve(binary), '--version'], {
5 stdout: 'pipe', stderr: 'pipe', timeout: 30_000,
6 })
7 if (result.exitCode !== 0)
8 throw new Error(`Native CLI failed to start (${result.signalCode ?? result.exitCode}): ${result.stderr.toString()}`)
9 const firstLine = result.stdout.toString().trim().split('\n')[0]
10 if (firstLine !== `craft version ${version}`)
11 throw new Error(`Native CLI reported ${JSON.stringify(firstLine)}, expected craft version ${version}`)
12 console.log(`Verified native CLI startup: craft version ${version}`)
13}
14
15if (import.meta.main) {
16 const [binary, version] = Bun.argv.slice(2)
17 if (!binary || !version)
18 throw new Error('Usage: bun scripts/verify-native-startup.ts <binary> <version>')
19 verifyNativeStartup(binary, version)
20}