@aipoju/breakout-cli 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/breakout.js +52 -0
  2. package/package.json +31 -0
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { spawn } = require("node:child_process");
6
+ const { dirname, join } = require("node:path");
7
+
8
+ const platform = process.platform;
9
+ const architecture = process.arch;
10
+ const supportedPlatforms = new Set(["darwin", "linux", "win32"]);
11
+ const supportedArchitectures = new Set(["arm64", "x64"]);
12
+
13
+ if (!supportedPlatforms.has(platform) || !supportedArchitectures.has(architecture)) {
14
+ console.error(`破局官网 CLI 暂不支持当前系统:${platform}/${architecture}`);
15
+ process.exit(1);
16
+ }
17
+
18
+ const packageName = `@aipoju/breakout-cli-${platform}-${architecture}`;
19
+ const executableName = platform === "win32" ? "breakout.exe" : "breakout";
20
+
21
+ let executablePath;
22
+ try {
23
+ const manifestPath = require.resolve(`${packageName}/package.json`);
24
+ executablePath = join(dirname(manifestPath), "bin", executableName);
25
+ } catch (error) {
26
+ console.error(
27
+ `未找到适用于 ${platform}/${architecture} 的破局官网 CLI。` +
28
+ `\n请重新安装:npm install -g @aipoju/breakout-cli`,
29
+ );
30
+ if (process.env.BREAKOUT_CLI_DEBUG === "1") {
31
+ console.error(error);
32
+ }
33
+ process.exit(1);
34
+ }
35
+
36
+ const child = spawn(executablePath, process.argv.slice(2), {
37
+ stdio: "inherit",
38
+ windowsHide: false,
39
+ });
40
+
41
+ child.on("error", (error) => {
42
+ console.error(`破局官网 CLI 启动失败:${error.message}`);
43
+ process.exitCode = 1;
44
+ });
45
+
46
+ child.on("exit", (code, signal) => {
47
+ if (signal !== null) {
48
+ process.kill(process.pid, signal);
49
+ return;
50
+ }
51
+ process.exitCode = code ?? 1;
52
+ });
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@aipoju/breakout-cli",
3
+ "version": "0.1.0",
4
+ "description": "AI 破局俱乐部官方命令行工具",
5
+ "license": "UNLICENSED",
6
+ "bin": {
7
+ "breakout": "bin/breakout.js",
8
+ "breakout-cli": "bin/breakout.js"
9
+ },
10
+ "files": [
11
+ "bin"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "optionalDependencies": {
20
+ "@aipoju/breakout-cli-darwin-arm64": "0.1.0",
21
+ "@aipoju/breakout-cli-darwin-x64": "0.1.0",
22
+ "@aipoju/breakout-cli-linux-arm64": "0.1.0",
23
+ "@aipoju/breakout-cli-linux-x64": "0.1.0",
24
+ "@aipoju/breakout-cli-win32-arm64": "0.1.0",
25
+ "@aipoju/breakout-cli-win32-x64": "0.1.0"
26
+ },
27
+ "scripts": {
28
+ "build:packages": "node scripts/build-packages.mjs",
29
+ "pack:all": "node scripts/pack-packages.mjs"
30
+ }
31
+ }