harness-for-rea 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/harness-for-rea.mjs +49 -0
- package/dist/main.js +130437 -0
- package/package.json +30 -4
- package/sandbox/specialist/Dockerfile +42 -0
- package/README.md +0 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The npm command of Harness for REA's terminal UI (specs/release R2.4): runs the bundled TUI on the Bun this package
|
|
3
|
+
// depends on — the `bun` package's binary, or its platform package's when npm skipped `bun`'s install script — with
|
|
4
|
+
// the sandbox sources the package carries.
|
|
5
|
+
import { spawnSync } from "node:child_process"
|
|
6
|
+
import { existsSync, statSync } from "node:fs"
|
|
7
|
+
import { createRequire } from "node:module"
|
|
8
|
+
import { dirname, join } from "node:path"
|
|
9
|
+
import { fileURLToPath } from "node:url"
|
|
10
|
+
|
|
11
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
12
|
+
const pkg = join(here, "..")
|
|
13
|
+
const require = createRequire(import.meta.url)
|
|
14
|
+
|
|
15
|
+
const PLATFORM = { win32: "windows", darwin: "darwin", linux: "linux" }[process.platform]
|
|
16
|
+
const ARCH = { x64: "x64", arm64: "aarch64" }[process.arch]
|
|
17
|
+
|
|
18
|
+
/** A real binary, not the placeholder `bun` leaves before its install script ran. */
|
|
19
|
+
const real = (p) => existsSync(p) && statSync(p).size > 1024 * 1024
|
|
20
|
+
|
|
21
|
+
function bunBinary() {
|
|
22
|
+
const candidates = []
|
|
23
|
+
try {
|
|
24
|
+
const dir = dirname(require.resolve("bun/package.json"))
|
|
25
|
+
candidates.push(join(dir, "bin", "bun.exe"), join(dir, "bin", "bun"))
|
|
26
|
+
} catch {
|
|
27
|
+
// not installed: the platform package may still be
|
|
28
|
+
}
|
|
29
|
+
for (const variant of ["", "-baseline"]) {
|
|
30
|
+
try {
|
|
31
|
+
const dir = dirname(require.resolve(`@oven/bun-${PLATFORM}-${ARCH}${variant}/package.json`))
|
|
32
|
+
candidates.push(join(dir, "bin", "bun.exe"), join(dir, "bin", "bun"))
|
|
33
|
+
} catch {
|
|
34
|
+
// that variant is not installed
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return candidates.find(real)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const bun = bunBinary()
|
|
41
|
+
if (!bun) {
|
|
42
|
+
console.error("harness-for-rea: no Bun binary was found in this package's dependencies; reinstall it with npm install -g harness-for-rea.")
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
const r = spawnSync(bun, [join(pkg, "dist", "main.js"), ...process.argv.slice(2)], {
|
|
46
|
+
stdio: "inherit",
|
|
47
|
+
env: { ...process.env, HFR_SANDBOX_DIR: process.env.HFR_SANDBOX_DIR ?? join(pkg, "sandbox") },
|
|
48
|
+
})
|
|
49
|
+
process.exit(r.status ?? 1)
|