@nuwax-ai/app-cli 0.3.5 → 0.3.9

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/bin/cli.js CHANGED
@@ -41,12 +41,12 @@ try {
41
41
  process.exit(1);
42
42
  }
43
43
 
44
- // win32:serve 需要 pingap 反代,把包内 pingap.exe 经 env 注入(app-cli 的
45
- // 默认值 /usr/local/bin/pingap 在 Windows 不存在)。仅用户未显式设置时注入——
44
+ // All bundled platforms use their paired Pingap instead of a possibly stale
45
+ // system installation. Only inject when the caller has not configured it:
46
46
  // 显式 APP_CLI_PINGAP_BIN / --pingap-bin 优先。
47
47
  let childEnv;
48
- if (platform === "win32") {
49
- const pingapPath = path.join(path.dirname(binPath), "pingap.exe");
48
+ {
49
+ const pingapPath = path.join(path.dirname(binPath), platform === "win32" ? "pingap.exe" : "pingap");
50
50
  if (!process.env.APP_CLI_PINGAP_BIN && fs.existsSync(pingapPath)) {
51
51
  childEnv = { ...process.env, APP_CLI_PINGAP_BIN: pingapPath };
52
52
  }
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@nuwax-ai/app-cli",
3
- "version": "0.3.5",
3
+ "version": "0.3.9",
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.3.5",
11
- "@nuwax-ai/app-cli-linux-arm64": "0.3.5",
12
- "@nuwax-ai/app-cli-darwin-x64": "0.3.5",
13
- "@nuwax-ai/app-cli-darwin-arm64": "0.3.5",
14
- "@nuwax-ai/app-cli-windows-x64": "0.3.5"
10
+ "@nuwax-ai/app-cli-linux-x64": "0.3.9",
11
+ "@nuwax-ai/app-cli-linux-arm64": "0.3.9",
12
+ "@nuwax-ai/app-cli-darwin-x64": "0.3.9",
13
+ "@nuwax-ai/app-cli-darwin-arm64": "0.3.9",
14
+ "@nuwax-ai/app-cli-windows-x64": "0.3.9"
15
15
  },
16
16
  "os": [
17
17
  "linux",
@@ -0,0 +1,36 @@
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const vm = require('node:vm');
6
+ const os = require('node:os');
7
+ const { execFileSync } = require('node:child_process');
8
+ const { EventEmitter } = require('node:events');
9
+ const source = fs.readFileSync(path.join(__dirname, '../bin/cli.js'), 'utf8');
10
+
11
+ for (const [platform, arch, suffix] of [['darwin', 'arm64', 'darwin-arm64'], ['darwin', 'x64', 'darwin-x64'], ['linux', 'x64', 'linux-x64'], ['win32', 'x64', 'windows-x64']]) {
12
+ test(`${suffix}: launcher selects paired Pingap and respects explicit env`, () => {
13
+ for (const explicit of [undefined, '/custom/pingap']) {
14
+ let captured;
15
+ const env = explicit ? { APP_CLI_PINGAP_BIN: explicit } : {};
16
+ const req = name => ({ child_process: { spawn: (...args) => { captured = args; return new EventEmitter(); } }, fs: { existsSync: () => true }, path })[name];
17
+ req.resolve = () => `/packages/${suffix}/package.json`;
18
+ vm.runInNewContext(source, { require: req, console, process: { platform, arch, env, argv: ['node', 'cli', 'serve'], on() {}, exit(code) { throw new Error(`unexpected exit ${code}`); } } });
19
+ const selectedEnv = captured[2].env || env;
20
+ assert.equal(selectedEnv.APP_CLI_PINGAP_BIN, explicit || `/packages/${suffix}/${platform === 'win32' ? 'pingap.exe' : 'pingap'}`);
21
+ assert.equal(captured[1][0], 'serve');
22
+ }
23
+ });
24
+ test(`${suffix}: npm tarball includes both executables`, () => {
25
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'app-cli-pack-'));
26
+ try {
27
+ fs.copyFileSync(path.join(__dirname, `../../app-cli-${suffix}/package.json`), path.join(root, 'package.json'));
28
+ const binaries = platform === 'win32' ? ['app-cli.exe', 'pingap.exe'] : ['app-cli', 'pingap'];
29
+ for (const name of binaries) fs.writeFileSync(path.join(root, name), 'packaging fixture');
30
+ const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
31
+ const result = JSON.parse(execFileSync(npm, ['pack', '--dry-run', '--ignore-scripts', '--json'], { cwd: root, encoding: 'utf8', shell: process.platform === 'win32' }));
32
+ const files = result[0].files.map(file => file.path);
33
+ for (const name of binaries) assert.ok(files.includes(name), `missing ${name}`);
34
+ } finally { fs.rmSync(root, { recursive: true, force: true }); }
35
+ });
36
+ }