@yixinkj/cli 1.0.6 → 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 +33 -14
- 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,21 +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
|
+
return;
|
|
228
|
+
}
|
|
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());
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function prepareInstalledBinaries(target) {
|
|
248
|
+
if (process.platform !== 'darwin') {
|
|
227
249
|
return;
|
|
228
250
|
}
|
|
229
251
|
for (const name of target.binaries) {
|
|
230
|
-
|
|
231
|
-
if (fs.existsSync(filePath)) {
|
|
232
|
-
fs.chmodSync(filePath, 0o755);
|
|
233
|
-
}
|
|
252
|
+
prepareMacBinary(path.join(BIN_DIR, name));
|
|
234
253
|
}
|
|
235
254
|
}
|
|
236
255
|
|
|
237
256
|
async function ensureInstalled(target) {
|
|
238
257
|
if (isInstalled(target)) {
|
|
239
|
-
|
|
258
|
+
prepareInstalledBinaries(target);
|
|
240
259
|
return;
|
|
241
260
|
}
|
|
242
261
|
|
|
@@ -249,7 +268,7 @@ async function ensureInstalled(target) {
|
|
|
249
268
|
console.error(`[yixin] 正在下载 ${url}`);
|
|
250
269
|
await downloadFile(url, archivePath);
|
|
251
270
|
extractArchive(archivePath, target);
|
|
252
|
-
|
|
271
|
+
prepareInstalledBinaries(target);
|
|
253
272
|
|
|
254
273
|
for (const name of target.binaries) {
|
|
255
274
|
const filePath = path.join(BIN_DIR, name);
|