@sciagent/cli 1.0.25 → 1.0.27
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/package.json +2 -2
- package/scripts/postinstall.js +94 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sciagent/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "SciAgent CLI - AI Research Assistant",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@sciagent/cli-linux-arm64": "1.0.0",
|
|
20
20
|
"@sciagent/cli-darwin-x64": "1.0.0",
|
|
21
21
|
"@sciagent/cli-darwin-arm64": "1.0.0",
|
|
22
|
-
"@sciagent/cli-win32-x64": "1.0.
|
|
22
|
+
"@sciagent/cli-win32-x64": "1.0.27",
|
|
23
23
|
"@sciagent/cli-win32-arm64": "1.0.0"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
package/scripts/postinstall.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SciAgent CLI postinstall 脚本
|
|
5
|
-
*
|
|
5
|
+
* 自动检测并安装平台特定的二进制包
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const { execSync } = require('child_process');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
|
|
@@ -22,13 +22,64 @@ const ARCH_MAP = {
|
|
|
22
22
|
amd64: 'x64'
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
// 当前版本号 - 每次发布时同步更新
|
|
26
|
+
const CURRENT_VERSION = '1.0.27';
|
|
27
|
+
|
|
28
|
+
function checkBinaryInstalled(platform, arch) {
|
|
29
|
+
const packageName = `@sciagent/cli-${platform}-${arch}`;
|
|
30
|
+
const binName = platform === 'win32' ? 'sciagent.exe' : 'sciagent';
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const packagePath = require.resolve(`${packageName}/bin/${binName}`);
|
|
34
|
+
return { installed: true, path: packagePath };
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return { installed: false };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function installBinaryPackage(platform, arch) {
|
|
41
|
+
const packageName = `@sciagent/cli-${platform}-${arch}@${CURRENT_VERSION}`;
|
|
42
|
+
|
|
43
|
+
console.log(`\n Installing platform binary: ${packageName}`);
|
|
44
|
+
console.log(' This may take a moment (downloading ~180MB)...\n');
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
// Determine npm global prefix for proper global install
|
|
48
|
+
let npmCmd = 'npm';
|
|
49
|
+
let installArgs = ['install', '-g', packageName];
|
|
50
|
+
|
|
51
|
+
// Check if we're in a global install context
|
|
52
|
+
const isGlobal = process.env.npm_config_global === 'true' ||
|
|
53
|
+
process.env.npm_lifecycle_event === 'postinstall';
|
|
54
|
+
|
|
55
|
+
if (isGlobal) {
|
|
56
|
+
// Use npm install -g for global installs
|
|
57
|
+
installArgs = ['install', '-g', packageName];
|
|
58
|
+
} else {
|
|
59
|
+
// Local install
|
|
60
|
+
installArgs = ['install', packageName];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
execSync(`${npmCmd} ${installArgs.join(' ')}`, {
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
timeout: 300000 // 5 minutes timeout
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return true;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.error(`\n ❌ Failed to install ${packageName}`);
|
|
71
|
+
console.error(` Error: ${e.message}\n`);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
25
76
|
function main() {
|
|
26
77
|
const platform = PLATFORM_MAP[process.platform];
|
|
27
78
|
const arch = ARCH_MAP[process.arch];
|
|
28
79
|
|
|
29
80
|
console.log('');
|
|
30
81
|
console.log('╔══════════════════════════════════════════════════════════╗');
|
|
31
|
-
console.log('║ SciAgent CLI -
|
|
82
|
+
console.log('║ SciAgent CLI - Post Install Setup ║');
|
|
32
83
|
console.log('╚══════════════════════════════════════════════════════════╝');
|
|
33
84
|
console.log('');
|
|
34
85
|
console.log(` Platform: ${platform || process.platform}`);
|
|
@@ -38,28 +89,48 @@ function main() {
|
|
|
38
89
|
|
|
39
90
|
// 检查平台支持
|
|
40
91
|
if (!platform || !arch) {
|
|
41
|
-
console.
|
|
42
|
-
console.
|
|
43
|
-
console.
|
|
44
|
-
console.
|
|
45
|
-
console.
|
|
46
|
-
console.
|
|
47
|
-
|
|
92
|
+
console.error('❌ Unsupported platform or architecture');
|
|
93
|
+
console.error(` Platform: ${process.platform}`);
|
|
94
|
+
console.error(` Architecture: ${process.arch}`);
|
|
95
|
+
console.error('');
|
|
96
|
+
console.error(' Supported platforms: linux, darwin, win32');
|
|
97
|
+
console.error(' Supported architectures: x64, arm64');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 检查对应的二进制包是否已安装
|
|
102
|
+
const packageName = `@sciagent/cli-${platform}-${arch}`;
|
|
103
|
+
const result = checkBinaryInstalled(platform, arch);
|
|
104
|
+
|
|
105
|
+
if (result.installed) {
|
|
106
|
+
console.log(`✅ Platform binary already installed: ${packageName}`);
|
|
107
|
+
console.log(` Path: ${result.path}`);
|
|
48
108
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
109
|
+
console.log(`⚠️ Platform binary not found: ${packageName}`);
|
|
110
|
+
|
|
111
|
+
// 尝试自动安装
|
|
112
|
+
const success = installBinaryPackage(platform, arch);
|
|
113
|
+
|
|
114
|
+
if (!success) {
|
|
115
|
+
console.error('');
|
|
116
|
+
console.error('╔══════════════════════════════════════════════════════════╗');
|
|
117
|
+
console.error('║ Manual Installation Required ║');
|
|
118
|
+
console.error('╚══════════════════════════════════════════════════════════╝');
|
|
119
|
+
console.error('');
|
|
120
|
+
console.error(' Please run this command manually:');
|
|
121
|
+
console.error(` npm install -g ${packageName}@${CURRENT_VERSION}`);
|
|
122
|
+
console.error('');
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
52
125
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log(
|
|
57
|
-
}
|
|
58
|
-
console.
|
|
59
|
-
console.
|
|
60
|
-
|
|
61
|
-
console.warn(' Install it manually:');
|
|
62
|
-
console.warn(` npm install ${packageName}`);
|
|
126
|
+
// Verify installation
|
|
127
|
+
const verifyResult = checkBinaryInstalled(platform, arch);
|
|
128
|
+
if (verifyResult.installed) {
|
|
129
|
+
console.log(`\n✅ Platform binary installed successfully: ${packageName}`);
|
|
130
|
+
} else {
|
|
131
|
+
console.error(`\n❌ Installation verification failed. Please install manually:`);
|
|
132
|
+
console.error(` npm install -g ${packageName}@${CURRENT_VERSION}`);
|
|
133
|
+
process.exit(1);
|
|
63
134
|
}
|
|
64
135
|
}
|
|
65
136
|
|