@ut-protocol/utp-kittplus 0.6.28-beta.11

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/utp-kittplus +44 -0
  2. package/package.json +14 -0
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ // 主包入口:按当前平台找到对应子包里的原生二进制,透传参数与 stdio 执行。
3
+ // Scope 与包基名都从主包 package.json 的 name 字段动态读取,支持渠道包
4
+ // (如 @ali/utp-customer-a → @ali/utp-customer-a-darwin-arm64)。
5
+ "use strict";
6
+
7
+ const { execFileSync } = require("child_process");
8
+ const path = require("path");
9
+
10
+ // 主包名如 @ali/utp 或 @ali/utp-customer-a。
11
+ const mainPkg = require(path.resolve(__dirname, "../package.json"));
12
+ const [scope = "@ali", packageBase = "utp"] = mainPkg.name.split("/");
13
+
14
+ const PKG_BY_PLATFORM = {
15
+ "darwin-arm64": `${scope}/${packageBase}-darwin-arm64`,
16
+ "darwin-x64": `${scope}/${packageBase}-darwin-x64`,
17
+ "linux-x64": `${scope}/${packageBase}-linux-x64`,
18
+ "linux-arm64": `${scope}/${packageBase}-linux-arm64`,
19
+ "win32-x64": `${scope}/${packageBase}-win32-x64`,
20
+ };
21
+
22
+ const key = `${process.platform}-${process.arch}`; // 如 darwin-arm64 / linux-x64
23
+ const pkg = PKG_BY_PLATFORM[key];
24
+ if (!pkg) {
25
+ console.error(`[utp] 不支持的平台: ${key}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const binName = process.platform === "win32" ? "utp.exe" : "utp";
30
+ let binPath;
31
+ try {
32
+ binPath = path.join(path.dirname(require.resolve(`${pkg}/package.json`)), binName);
33
+ } catch (e) {
34
+ console.error(`[utp] 缺少平台二进制包 ${pkg},请重新安装: npm i -g ${scope}/${packageBase}`);
35
+ process.exit(1);
36
+ }
37
+
38
+ try {
39
+ execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
40
+ } catch (e) {
41
+ if (typeof e.status === "number") process.exit(e.status); // 透传子进程退出码
42
+ console.error(e.message);
43
+ process.exit(1);
44
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@ut-protocol/utp-kittplus",
3
+ "version": "0.6.28-beta.11",
4
+ "description": "UTP Protocol CLI - Universal Transaction Protocol client",
5
+ "bin": { "utp-kittplus": "bin/utp-kittplus" },
6
+ "optionalDependencies": { "@ut-protocol/utp-kittplus-darwin-arm64": "0.6.28-beta.11",
7
+ "@ut-protocol/utp-kittplus-darwin-x64": "0.6.28-beta.11",
8
+ "@ut-protocol/utp-kittplus-linux-x64": "0.6.28-beta.11",
9
+ "@ut-protocol/utp-kittplus-linux-arm64": "0.6.28-beta.11",
10
+ "@ut-protocol/utp-kittplus-win32-x64": "0.6.28-beta.11"
11
+ },
12
+ "files": ["bin/utp-kittplus"],
13
+ "publishConfig": { "registry": "https://registry.npmjs.org" }
14
+ }