@42ailab/42plugin 0.2.16 → 0.2.17
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/42plugin +54 -5
- package/package.json +6 -6
package/bin/42plugin
CHANGED
|
@@ -34,8 +34,43 @@ function getPlatformKey() {
|
|
|
34
34
|
return `${platform}-${normalizedArch}`;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// 检测包管理器
|
|
38
|
+
function detectPackageManager() {
|
|
39
|
+
// 检查是否通过 bun 运行
|
|
40
|
+
if (process.versions.bun) {
|
|
41
|
+
return 'bun';
|
|
42
|
+
}
|
|
43
|
+
// 检查全局安装路径中是否包含 bun
|
|
44
|
+
if (__dirname.includes('.bun')) {
|
|
45
|
+
return 'bun';
|
|
46
|
+
}
|
|
47
|
+
// 默认使用 npm
|
|
48
|
+
return 'npm';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 尝试自动安装平台包
|
|
52
|
+
function tryAutoInstall(packageName) {
|
|
53
|
+
const pm = detectPackageManager();
|
|
54
|
+
console.error(`正在自动安装平台包: ${packageName}...`);
|
|
55
|
+
|
|
56
|
+
let result;
|
|
57
|
+
if (pm === 'bun') {
|
|
58
|
+
result = spawnSync('bun', ['add', '-g', packageName], {
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
shell: process.platform === 'win32',
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
result = spawnSync('npm', ['install', '-g', packageName], {
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
shell: process.platform === 'win32',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return result.status === 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
37
72
|
// 查找二进制文件路径
|
|
38
|
-
function findBinary() {
|
|
73
|
+
function findBinary(autoInstall = false) {
|
|
39
74
|
const platformKey = getPlatformKey();
|
|
40
75
|
const packageName = PLATFORMS[platformKey];
|
|
41
76
|
|
|
@@ -64,14 +99,28 @@ function findBinary() {
|
|
|
64
99
|
}
|
|
65
100
|
}
|
|
66
101
|
|
|
67
|
-
//
|
|
102
|
+
// 找不到二进制文件,尝试自动安装
|
|
103
|
+
if (!autoInstall) {
|
|
104
|
+
if (tryAutoInstall(packageName)) {
|
|
105
|
+
// 安装成功,重新查找
|
|
106
|
+
return findBinary(true);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 自动安装失败,显示手动安装提示
|
|
111
|
+
console.error('');
|
|
68
112
|
console.error(`错误: 找不到 ${platformKey} 平台的二进制文件`);
|
|
69
|
-
console.error(
|
|
113
|
+
console.error(`请手动安装: ${packageName}`);
|
|
114
|
+
console.error('');
|
|
115
|
+
console.error('尝试以下方法:');
|
|
116
|
+
console.error('');
|
|
117
|
+
console.error(' # Bun 用户');
|
|
118
|
+
console.error(` bun add -g ${packageName}`);
|
|
70
119
|
console.error('');
|
|
71
|
-
console.error('
|
|
120
|
+
console.error(' # npm 用户');
|
|
72
121
|
console.error(' npm install -g @42ailab/42plugin');
|
|
73
122
|
console.error('');
|
|
74
|
-
console.error('
|
|
123
|
+
console.error(' # Homebrew (macOS/Linux)');
|
|
75
124
|
console.error(' brew install 42ailab/42plugin/42plugin');
|
|
76
125
|
process.exit(1);
|
|
77
126
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@42ailab/42plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "42plugin CLI - AI 插件管理工具",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@42ailab/42plugin-darwin-arm64": "0.2.
|
|
36
|
-
"@42ailab/42plugin-darwin-x64": "0.2.
|
|
37
|
-
"@42ailab/42plugin-linux-arm64": "0.2.
|
|
38
|
-
"@42ailab/42plugin-linux-x64": "0.2.
|
|
39
|
-
"@42ailab/42plugin-win32-x64": "0.2.
|
|
35
|
+
"@42ailab/42plugin-darwin-arm64": "0.2.17",
|
|
36
|
+
"@42ailab/42plugin-darwin-x64": "0.2.17",
|
|
37
|
+
"@42ailab/42plugin-linux-arm64": "0.2.17",
|
|
38
|
+
"@42ailab/42plugin-linux-x64": "0.2.17",
|
|
39
|
+
"@42ailab/42plugin-win32-x64": "0.2.17"
|
|
40
40
|
}
|
|
41
41
|
}
|