@yixinkj/cli 1.0.7 → 1.0.8

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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +29 -24
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -89,6 +89,6 @@ YIXIN_AUTH_URL=http://47.237.81.135:3000/v1/token
89
89
  默认从 `yixinkj/cli-releases` 下载与 npm 包版本一致的 release asset:
90
90
 
91
91
  - `darwin-arm64` -> `yixin-mac-arm64.tar.gz`
92
- - `win32-x64` -> `yixin-win-x64.zip`
92
+ - `win32-x64` -> `yixin-win32-x64.zip`
93
93
 
94
94
  可通过 `YIXIN_RELEASE_REPO` 或 `YIXIN_RELEASE_BASE_URL` 覆盖下载来源。
package/index.js CHANGED
@@ -28,13 +28,13 @@ const PLATFORM_TARGETS = {
28
28
  id: 'mac-arm64',
29
29
  archive: 'yixin-mac-arm64.tar.gz',
30
30
  mainBinary: 'alibaba-cli-mac-arm64',
31
- binaries: ['alibaba-cli-mac-arm64', 'report-engine-mac-arm64', 'browser-bridge-mac-arm64']
31
+ binaries: ['alibaba-cli-mac-arm64', 'browser-bridge-mac-arm64']
32
32
  },
33
33
  'win32-x64': {
34
- id: 'win-x64',
35
- archive: 'yixin-win-x64.zip',
36
- mainBinary: 'alibaba-cli-win-x64.exe',
37
- binaries: ['alibaba-cli-win-x64.exe', 'report-engine-win-x64.exe', 'browser-bridge-win-x64.exe']
34
+ id: 'win32-x64',
35
+ archive: 'yixin-win32-x64.zip',
36
+ mainBinary: 'alibaba-cli-win32-x64.exe',
37
+ binaries: ['alibaba-cli-win32-x64.exe', 'browser-bridge-win32-x64.exe']
38
38
  }
39
39
  };
40
40
 
@@ -65,7 +65,7 @@ function detectTarget() {
65
65
  const platformKey = `${process.platform}-${process.arch}`;
66
66
  const target = PLATFORM_TARGETS[platformKey];
67
67
  if (!target) {
68
- throw new Error(`暂不支持当前平台:${process.platform}/${process.arch}。已支持:mac-arm64、win-x64。`);
68
+ throw new Error(`暂不支持当前平台:${process.platform}/${process.arch}。已支持:mac-arm64、win32-x64。`);
69
69
  }
70
70
  return target;
71
71
  }
@@ -222,34 +222,40 @@ function extractArchive(archivePath, target) {
222
222
  throw new Error(`暂不支持的压缩包类型:${target.archive}`);
223
223
  }
224
224
 
225
- function chmodExecutables(target) {
226
- if (process.platform === 'win32') {
225
+ function prepareMacBinary(filePath) {
226
+ if (process.platform !== 'darwin' || !fs.existsSync(filePath)) {
227
227
  return;
228
228
  }
229
- for (const name of target.binaries) {
230
- const filePath = path.join(BIN_DIR, name);
231
- if (fs.existsSync(filePath)) {
232
- fs.chmodSync(filePath, 0o755);
233
- }
229
+
230
+ spawnSync('xattr', ['-dr', 'com.apple.quarantine', filePath], {
231
+ encoding: 'utf8',
232
+ stdio: 'ignore'
233
+ });
234
+
235
+ const chmod = spawnSync('chmod', ['+x', filePath], {
236
+ encoding: 'utf8',
237
+ stdio: ['ignore', 'pipe', 'pipe']
238
+ });
239
+ if (chmod.error) {
240
+ throw chmod.error;
241
+ }
242
+ if (chmod.status !== 0) {
243
+ throw new Error((chmod.stderr || chmod.stdout || `chmod +x failed: ${filePath}`).trim());
234
244
  }
235
245
  }
236
246
 
237
- function clearMacQuarantine() {
238
- if (process.platform !== 'darwin' || !fs.existsSync(BIN_DIR)) {
247
+ function prepareInstalledBinaries(target) {
248
+ if (process.platform !== 'darwin') {
239
249
  return;
240
250
  }
241
- const result = spawnSync('xattr', ['-dr', 'com.apple.quarantine', BIN_DIR], {
242
- encoding: 'utf8'
243
- });
244
- if (result.error && result.error.code !== 'ENOENT') {
245
- console.error(`[yixin] macOS 安全隔离标记清理失败:${result.error.message}`);
251
+ for (const name of target.binaries) {
252
+ prepareMacBinary(path.join(BIN_DIR, name));
246
253
  }
247
254
  }
248
255
 
249
256
  async function ensureInstalled(target) {
250
257
  if (isInstalled(target)) {
251
- clearMacQuarantine();
252
- chmodExecutables(target);
258
+ prepareInstalledBinaries(target);
253
259
  return;
254
260
  }
255
261
 
@@ -262,8 +268,7 @@ async function ensureInstalled(target) {
262
268
  console.error(`[yixin] 正在下载 ${url}`);
263
269
  await downloadFile(url, archivePath);
264
270
  extractArchive(archivePath, target);
265
- clearMacQuarantine();
266
- chmodExecutables(target);
271
+ prepareInstalledBinaries(target);
267
272
 
268
273
  for (const name of target.binaries) {
269
274
  const filePath = path.join(BIN_DIR, name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yixinkj/cli",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Yixin local MCP server and CLI launcher for MCP clients.",
5
5
  "type": "module",
6
6
  "bin": {