baton-host 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.
Files changed (2) hide show
  1. package/bin/baton-host.js +41 -0
  2. package/package.json +18 -0
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require("node:child_process");
4
+ const path = require("node:path");
5
+
6
+ const mapping = {
7
+ "darwin-arm64": "baton-host-darwin-arm64",
8
+ "darwin-x64": "baton-host-darwin-x64",
9
+ "linux-arm64": "baton-host-linux-arm64",
10
+ "linux-x64": "baton-host-linux-x64"
11
+ };
12
+
13
+ const key = `${process.platform}-${process.arch}`;
14
+ const pkg = mapping[key];
15
+
16
+ if (!pkg) {
17
+ console.error(`❌ 当前平台暂不支持: ${key}`);
18
+ process.exit(1);
19
+ }
20
+
21
+ let binaryPath;
22
+ try {
23
+ const pkgJsonPath = require.resolve(`${pkg}/package.json`);
24
+ binaryPath = path.join(path.dirname(pkgJsonPath), "bin", "baton-host");
25
+ } catch (error) {
26
+ console.error(`❌ 未找到平台二进制包 ${pkg},请重装 baton-host`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const child = spawn(binaryPath, process.argv.slice(2), {
31
+ stdio: "inherit",
32
+ env: process.env
33
+ });
34
+
35
+ child.on("exit", (code, signal) => {
36
+ if (signal) {
37
+ process.kill(process.pid, signal);
38
+ return;
39
+ }
40
+ process.exit(code ?? 0);
41
+ });
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "baton-host",
3
+ "version": "0.1.0",
4
+ "description": "Baton Bridge Host CLI(二进制分发入口)",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "baton-host": "bin/baton-host.js"
8
+ },
9
+ "files": [
10
+ "bin"
11
+ ],
12
+ "optionalDependencies": {
13
+ "baton-host-darwin-arm64": "0.1.0",
14
+ "baton-host-darwin-x64": "0.1.0",
15
+ "baton-host-linux-arm64": "0.1.0",
16
+ "baton-host-linux-x64": "0.1.0"
17
+ }
18
+ }