@hlix/cli 0.7.1 → 0.7.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/README.md CHANGED
@@ -42,12 +42,20 @@ hlix --help # the commands
42
42
  hlix # open Hlix Code
43
43
  ```
44
44
 
45
+ `hlix` runs as one self-contained executable: npm installs the one for your
46
+ platform (`@hlix/cli-darwin-arm64`, `-darwin-x64`, `-linux-x64` or
47
+ `-linux-arm64`) and `hlix` runs it directly. Where there is none (Windows,
48
+ musl-based Linux, `--omit=optional`) the Node build in this package runs
49
+ instead, after one line on stderr. Without npm,
50
+ `curl -fsSL https://staging.hlix.ai/install.sh | bash` installs the same
51
+ executable, and so does `brew install hlix-ai/tap/hlix`.
52
+
45
53
  For CI, and for anything else that must not change underneath you, pin the
46
54
  version instead of floating to `latest`:
47
55
 
48
56
  ```bash
49
- npm install --global @hlix/cli@0.7.1
50
- npx @hlix/cli@0.7.1 status --json
57
+ npm install --global @hlix/cli@0.7.2
58
+ npx @hlix/cli@0.7.2 status --json
51
59
  ```
52
60
 
53
61
  ## Authenticate
package/bin/hlix ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ // `hlix` as npm installs it. After a normal install the postinstall
3
+ // (install.cjs) has replaced this file with the standalone binary itself, so
4
+ // this only runs when that did not happen: scripts off (--ignore-scripts, pnpm)
5
+ // runs the platform package's binary from here; no platform package
6
+ // (--omit=optional, an unsupported platform) runs the Node build, after one line.
7
+ import { spawn } from "node:child_process"
8
+ import { createRequire } from "node:module"
9
+ import { fileURLToPath } from "node:url"
10
+
11
+ const { nativeBinary } = createRequire(import.meta.url)("../install.cjs")
12
+ const found = nativeBinary()
13
+ let command = found.binary
14
+ let args = process.argv.slice(2)
15
+ if (!command) {
16
+ process.stderr.write(`hlix: using the Node build (${found.reason})\n`)
17
+ command = process.execPath
18
+ args = [fileURLToPath(new URL("../dist/index.js", import.meta.url)), ...args]
19
+ }
20
+
21
+ // This copy is the one a person installed; the binary runs from the platform
22
+ // package, so it is told which path to report (hlix status).
23
+ const child = spawn(command, args, { stdio: "inherit", env: { ...process.env, HLIX_SELF: process.argv[1] } })
24
+ // The terminal signals the whole process group; a signal sent to this
25
+ // process alone (a supervisor, `kill`) is passed on instead of orphaning it.
26
+ const forward = (signal) => child.kill(signal)
27
+ const signals = ["SIGINT", "SIGTERM", "SIGHUP"]
28
+ for (const signal of signals) process.on(signal, forward)
29
+ child.on("error", (error) => {
30
+ process.stderr.write(`hlix: ${command}: ${error.message}\n`)
31
+ process.exit(1)
32
+ })
33
+ child.on("exit", (code, signal) => {
34
+ for (const name of signals) process.off(name, forward)
35
+ if (signal) process.kill(process.pid, signal)
36
+ else process.exit(code ?? 1)
37
+ })