@sciagent/cli 1.1.61 → 1.1.63
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/sciagent.js +12 -14
- package/package.json +1 -1
package/bin/sciagent.js
CHANGED
|
@@ -25,7 +25,7 @@ const https = require('https');
|
|
|
25
25
|
const http = require('http');
|
|
26
26
|
|
|
27
27
|
// 当前版本号 - 与 postinstall.js 和 package.json 保持同步
|
|
28
|
-
const CURRENT_VERSION = '1.1.
|
|
28
|
+
const CURRENT_VERSION = '1.1.63';
|
|
29
29
|
|
|
30
30
|
// Releases 下载源配置(优先级从高到低)
|
|
31
31
|
// JihuLab 通用包仓库(国内 CDN,速度快)作为主源
|
|
@@ -168,14 +168,14 @@ function applyPendingUpdate(installDir) {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
* 从
|
|
171
|
+
* 从 JihuLab Package Registry 查询最新版本号
|
|
172
172
|
* 返回: 版本字符串 或 null
|
|
173
173
|
*/
|
|
174
174
|
function fetchLatestVersion() {
|
|
175
175
|
return new Promise((resolve) => {
|
|
176
|
-
//
|
|
177
|
-
const url =
|
|
178
|
-
|
|
176
|
+
// 使用 JihuLab Package Registry API 查询版本
|
|
177
|
+
const url = `https://jihulab.com/api/v4/projects/${JIHULAB_PROJECT_ID}/packages?per_page=100&order_by=version&sort=desc`;
|
|
178
|
+
|
|
179
179
|
const protocol = url.startsWith('https') ? https : http;
|
|
180
180
|
const request = protocol.get(url, {
|
|
181
181
|
headers: { 'User-Agent': 'sciagent-cli/1.0' },
|
|
@@ -185,15 +185,13 @@ function fetchLatestVersion() {
|
|
|
185
185
|
response.on('data', (chunk) => { data += chunk; });
|
|
186
186
|
response.on('end', () => {
|
|
187
187
|
try {
|
|
188
|
-
const
|
|
189
|
-
const releases = result.releases || {};
|
|
190
|
-
// 找到所有版本中的最新版本
|
|
188
|
+
const packages = JSON.parse(data);
|
|
191
189
|
let latestVersion = null;
|
|
192
|
-
for (const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (!latestVersion || compareVersions(
|
|
196
|
-
latestVersion =
|
|
190
|
+
for (const pkg of packages) {
|
|
191
|
+
if (pkg.package_type === 'generic' && pkg.name === 'sciagent') {
|
|
192
|
+
const ver = pkg.version;
|
|
193
|
+
if (ver && (!latestVersion || compareVersions(ver, latestVersion) > 0)) {
|
|
194
|
+
latestVersion = ver;
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
}
|
|
@@ -203,7 +201,7 @@ function fetchLatestVersion() {
|
|
|
203
201
|
}
|
|
204
202
|
});
|
|
205
203
|
});
|
|
206
|
-
|
|
204
|
+
|
|
207
205
|
request.on('error', () => resolve(null));
|
|
208
206
|
request.on('timeout', () => { request.destroy(); resolve(null); });
|
|
209
207
|
});
|