@nuwax-ai/app-cli 0.2.2 → 0.3.0-beta.1

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/cli.js +23 -2
  2. package/package.json +8 -6
package/bin/cli.js CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  const { platform, arch } = process;
10
10
  const { spawn } = require("child_process");
11
+ const fs = require("fs");
11
12
  const path = require("path");
12
13
 
13
14
  const platformPackages = {
@@ -15,6 +16,7 @@ const platformPackages = {
15
16
  "linux-arm64": "@nuwax-ai/app-cli-linux-arm64",
16
17
  "darwin-x64": "@nuwax-ai/app-cli-darwin-x64",
17
18
  "darwin-arm64": "@nuwax-ai/app-cli-darwin-arm64",
19
+ "win32-x64": "@nuwax-ai/app-cli-windows-x64",
18
20
  };
19
21
 
20
22
  const key = `${platform}-${arch}`;
@@ -26,21 +28,40 @@ if (!pkgName) {
26
28
  process.exit(1);
27
29
  }
28
30
 
31
+ // win32 平台包附带自建 pingap.exe(上游官方无 Windows 产物),二进制带 .exe 后缀
32
+ const binName = platform === "win32" ? "app-cli.exe" : "app-cli";
33
+
29
34
  let binPath;
30
35
  try {
31
36
  const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
32
- binPath = path.join(pkgDir, "app-cli");
37
+ binPath = path.join(pkgDir, binName);
33
38
  } catch (e) {
34
39
  console.error(`error: platform package ${pkgName} not found.`);
35
40
  console.error(`please reinstall: npm install -g @nuwax-ai/app-cli`);
36
41
  process.exit(1);
37
42
  }
38
43
 
39
- const child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
44
+ // win32:serve 需要 pingap 反代,把包内 pingap.exe 经 env 注入(app-cli 的
45
+ // 默认值 /usr/local/bin/pingap 在 Windows 不存在)。仅用户未显式设置时注入——
46
+ // 显式 APP_CLI_PINGAP_BIN / --pingap-bin 优先。
47
+ let childEnv;
48
+ if (platform === "win32") {
49
+ const pingapPath = path.join(path.dirname(binPath), "pingap.exe");
50
+ if (!process.env.APP_CLI_PINGAP_BIN && fs.existsSync(pingapPath)) {
51
+ childEnv = { ...process.env, APP_CLI_PINGAP_BIN: pingapPath };
52
+ }
53
+ }
54
+
55
+ const child = spawn(binPath, process.argv.slice(2), {
56
+ stdio: "inherit",
57
+ env: childEnv,
58
+ });
40
59
 
41
60
  for (const sig of ["SIGTERM", "SIGINT", "SIGHUP"]) {
42
61
  process.on(sig, () => {
43
62
  try {
63
+ // Windows 上 SIGTERM/SIGHUP 是 Node 模拟信号,child.kill 退化为
64
+ // TerminateProcess(硬杀)——本地 dev 可接受;容器 PID1 语义只在 Linux。
44
65
  child.kill(sig);
45
66
  } catch {
46
67
  // 子进程已退出则忽略
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@nuwax-ai/app-cli",
3
- "version": "0.2.2",
3
+ "version": "0.3.0-beta.1",
4
4
  "description": "UserApp workspace runtime orchestrator (service orchestration + pingap routing + admin API; local build tool)",
5
5
  "main": "./bin/cli.js",
6
6
  "bin": {
7
7
  "app-cli": "./bin/cli.js"
8
8
  },
9
9
  "optionalDependencies": {
10
- "@nuwax-ai/app-cli-linux-x64": "0.2.2",
11
- "@nuwax-ai/app-cli-linux-arm64": "0.2.2",
12
- "@nuwax-ai/app-cli-darwin-x64": "0.2.2",
13
- "@nuwax-ai/app-cli-darwin-arm64": "0.2.2"
10
+ "@nuwax-ai/app-cli-linux-x64": "0.3.0-beta.1",
11
+ "@nuwax-ai/app-cli-linux-arm64": "0.3.0-beta.1",
12
+ "@nuwax-ai/app-cli-darwin-x64": "0.3.0-beta.1",
13
+ "@nuwax-ai/app-cli-darwin-arm64": "0.3.0-beta.1",
14
+ "@nuwax-ai/app-cli-windows-x64": "0.3.0-beta.1"
14
15
  },
15
16
  "os": [
16
17
  "linux",
17
- "darwin"
18
+ "darwin",
19
+ "win32"
18
20
  ],
19
21
  "cpu": [
20
22
  "x64",