@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.
- package/README.md +1 -1
- package/index.js +29 -24
- 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-
|
|
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', '
|
|
31
|
+
binaries: ['alibaba-cli-mac-arm64', 'browser-bridge-mac-arm64']
|
|
32
32
|
},
|
|
33
33
|
'win32-x64': {
|
|
34
|
-
id: '
|
|
35
|
-
archive: 'yixin-
|
|
36
|
-
mainBinary: 'alibaba-cli-
|
|
37
|
-
binaries: ['alibaba-cli-
|
|
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、
|
|
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
|
|
226
|
-
if (process.platform
|
|
225
|
+
function prepareMacBinary(filePath) {
|
|
226
|
+
if (process.platform !== 'darwin' || !fs.existsSync(filePath)) {
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
|
238
|
-
if (process.platform !== 'darwin'
|
|
247
|
+
function prepareInstalledBinaries(target) {
|
|
248
|
+
if (process.platform !== 'darwin') {
|
|
239
249
|
return;
|
|
240
250
|
}
|
|
241
|
-
const
|
|
242
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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);
|