@sys9/run9-cli 0.2.4 → 0.2.5

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
@@ -10,11 +10,14 @@ npm install -g @sys9/run9-cli
10
10
  bun install -g @sys9/run9-cli
11
11
  ```
12
12
 
13
+ The installed `run9` launcher is a POSIX shell wrapper around the bundled
14
+ native binary, so `bun install -g` works even when `node` is not present.
15
+
13
16
  Run:
14
17
 
15
18
  ```sh
16
19
  run9 auth login \
17
- --endpoint https://api.run9.example.com \
20
+ --endpoint https://api.run.sys9.ai \
18
21
  --ak ak-... \
19
22
  --sk sk-...
20
23
  ```
package/bin/run9 ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -eu
4
+
5
+ resolve_script_path() {
6
+ script_path="$1"
7
+ while [ -L "$script_path" ]; do
8
+ link_target="$(readlink "$script_path")"
9
+ case "$link_target" in
10
+ /*) script_path="$link_target" ;;
11
+ *) script_path="$(dirname "$script_path")/$link_target" ;;
12
+ esac
13
+ done
14
+ printf '%s\n' "$script_path"
15
+ }
16
+
17
+ script_path="$(resolve_script_path "$0")"
18
+ script_dir="$(CDPATH= cd -- "$(dirname -- "$script_path")" && pwd)"
19
+
20
+ uname_s="$(uname -s)"
21
+ uname_m="$(uname -m)"
22
+
23
+ case "$uname_s" in
24
+ Linux)
25
+ case "$uname_m" in
26
+ x86_64|amd64) target_triple="x86_64-unknown-linux-musl" ;;
27
+ aarch64|arm64) target_triple="aarch64-unknown-linux-musl" ;;
28
+ *)
29
+ echo "Unsupported architecture: $uname_m" >&2
30
+ exit 1
31
+ ;;
32
+ esac
33
+ ;;
34
+ Darwin)
35
+ case "$uname_m" in
36
+ x86_64|amd64) target_triple="x86_64-apple-darwin" ;;
37
+ arm64|aarch64) target_triple="aarch64-apple-darwin" ;;
38
+ *)
39
+ echo "Unsupported architecture: $uname_m" >&2
40
+ exit 1
41
+ ;;
42
+ esac
43
+ ;;
44
+ *)
45
+ echo "Unsupported platform: $uname_s ($uname_m)" >&2
46
+ exit 1
47
+ ;;
48
+ esac
49
+
50
+ binary_path="${script_dir}/../vendor/${target_triple}/run9/run9"
51
+ if [ ! -x "$binary_path" ]; then
52
+ echo "Bundled run9 binary not found at ${binary_path}" >&2
53
+ exit 1
54
+ fi
55
+
56
+ exec "$binary_path" "$@"
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@sys9/run9-cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "run9 CLI with bundled native binaries for Linux and macOS",
5
5
  "license": "MIT",
6
6
  "bin": {
7
- "run9": "bin/run9.js"
7
+ "run9": "bin/run9"
8
8
  },
9
9
  "type": "module",
10
10
  "engines": {
package/bin/run9.js DELETED
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from "node:child_process";
4
- import { existsSync } from "node:fs";
5
- import path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
-
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- function resolveTargetTriple(platform, arch) {
12
- switch (platform) {
13
- case "linux":
14
- case "android":
15
- switch (arch) {
16
- case "x64":
17
- return "x86_64-unknown-linux-musl";
18
- case "arm64":
19
- return "aarch64-unknown-linux-musl";
20
- default:
21
- return null;
22
- }
23
- case "darwin":
24
- switch (arch) {
25
- case "x64":
26
- return "x86_64-apple-darwin";
27
- case "arm64":
28
- return "aarch64-apple-darwin";
29
- default:
30
- return null;
31
- }
32
- default:
33
- return null;
34
- }
35
- }
36
-
37
- const targetTriple = resolveTargetTriple(process.platform, process.arch);
38
- if (!targetTriple) {
39
- throw new Error(`Unsupported platform: ${process.platform} (${process.arch})`);
40
- }
41
-
42
- const binaryPath = path.join(__dirname, "..", "vendor", targetTriple, "run9", "run9");
43
- if (!existsSync(binaryPath)) {
44
- throw new Error(`Bundled run9 binary not found at ${binaryPath}`);
45
- }
46
-
47
- // Use asynchronous spawn so the parent process can forward terminal signals
48
- // while the native binary is running.
49
- const child = spawn(binaryPath, process.argv.slice(2), {
50
- stdio: "inherit",
51
- env: process.env,
52
- });
53
-
54
- child.on("error", (err) => {
55
- // eslint-disable-next-line no-console
56
- console.error(err);
57
- process.exit(1);
58
- });
59
-
60
- const forwardSignal = (signal) => {
61
- if (child.killed) {
62
- return;
63
- }
64
- try {
65
- child.kill(signal);
66
- } catch {
67
- // Ignore races where the process already exited.
68
- }
69
- };
70
-
71
- ["SIGINT", "SIGTERM", "SIGHUP"].forEach((signal) => {
72
- process.on(signal, () => forwardSignal(signal));
73
- });
74
-
75
- const childResult = await new Promise((resolve) => {
76
- child.on("exit", (code, signal) => {
77
- if (signal) {
78
- resolve({ type: "signal", signal });
79
- return;
80
- }
81
- resolve({ type: "code", exitCode: code ?? 1 });
82
- });
83
- });
84
-
85
- if (childResult.type === "signal") {
86
- process.kill(process.pid, childResult.signal);
87
- } else {
88
- process.exit(childResult.exitCode);
89
- }