hermium 0.1.0 → 0.1.2
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/hermium.mjs +38 -1
- package/package.json +1 -1
package/bin/hermium.mjs
CHANGED
|
@@ -7,6 +7,32 @@ import { homedir } from 'os'
|
|
|
7
7
|
import pc from 'picocolors'
|
|
8
8
|
|
|
9
9
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
|
|
11
|
+
// ─── Runtime detection ─────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
function detectRuntime() {
|
|
14
|
+
// Check if bun is available on PATH
|
|
15
|
+
try {
|
|
16
|
+
execSync('bun --version', { stdio: 'ignore' })
|
|
17
|
+
return { cmd: 'bun', found: true }
|
|
18
|
+
} catch {
|
|
19
|
+
// fall back to current process
|
|
20
|
+
const exe = process.execPath
|
|
21
|
+
const isBun = exe.includes('bun') || (process.versions && process.versions.bun)
|
|
22
|
+
return { cmd: exe, found: !!isBun }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getRuntimeCmd() {
|
|
27
|
+
const rt = detectRuntime()
|
|
28
|
+
if (!rt.found) {
|
|
29
|
+
console.log(pc.red(' ✗ Bun is required to run Hermium.'))
|
|
30
|
+
console.log(' Install: curl -fsSL https://bun.sh/install | bash')
|
|
31
|
+
console.log(' Or: npm install -g bun')
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
return rt.cmd
|
|
35
|
+
}
|
|
10
36
|
const pkgDir = resolve(__dirname, '..')
|
|
11
37
|
const serverEntry = resolve(pkgDir, 'dist', 'server', 'index.mjs')
|
|
12
38
|
const WEB_UI_HOME = resolve(homedir(), '.hermium')
|
|
@@ -127,8 +153,9 @@ function cmdStart() {
|
|
|
127
153
|
}
|
|
128
154
|
} catch {}
|
|
129
155
|
|
|
156
|
+
const runtime = getRuntimeCmd()
|
|
130
157
|
const logFd = openSync(LOG_FILE, 'a')
|
|
131
|
-
const child = spawn(
|
|
158
|
+
const child = spawn(runtime, [serverEntry], {
|
|
132
159
|
detached: true,
|
|
133
160
|
stdio: ['ignore', logFd, logFd],
|
|
134
161
|
env: {
|
|
@@ -261,6 +288,11 @@ ${pc.bold('Examples:')}
|
|
|
261
288
|
`)
|
|
262
289
|
}
|
|
263
290
|
|
|
291
|
+
function cmdVersion() {
|
|
292
|
+
const pkg = JSON.parse(readFileSync(resolve(pkgDir, 'package.json'), 'utf-8'))
|
|
293
|
+
console.log(pkg.version)
|
|
294
|
+
}
|
|
295
|
+
|
|
264
296
|
// ─── Entrypoint ─────────────────────────────────────────────────────────────
|
|
265
297
|
|
|
266
298
|
const command = process.argv[2] || 'help'
|
|
@@ -278,6 +310,11 @@ switch (command) {
|
|
|
278
310
|
case 'status':
|
|
279
311
|
cmdStatus()
|
|
280
312
|
break
|
|
313
|
+
case 'version':
|
|
314
|
+
case '--version':
|
|
315
|
+
case '-v':
|
|
316
|
+
cmdVersion()
|
|
317
|
+
break
|
|
281
318
|
case 'help':
|
|
282
319
|
case '--help':
|
|
283
320
|
case '-h':
|