@sciagent/cli 1.1.60 → 1.1.62
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 +17 -14
- package/package.json +1 -1
- package/scripts/postinstall.js +6 -1
package/bin/sciagent.js
CHANGED
|
@@ -36,10 +36,15 @@ const JIHULAB_DEPLOY_TOKEN = 'gldt-5kp7mgt4ztyyBMx1Uvn6';
|
|
|
36
36
|
const JIHULAB_BASE_URL = `https://jihulab.com/api/v4/projects/${JIHULAB_PROJECT_ID}/packages/generic/sciagent`;
|
|
37
37
|
const SELF_HOSTED_URL = process.env.RELEASE_SERVER_URL || 'https://px1-jcy.matpool.com:26741?token=BdZ2oxzimV';
|
|
38
38
|
|
|
39
|
+
// Parse SELF_HOSTED_URL to separate base URL from query params (e.g. ?token=xxx)
|
|
40
|
+
const _url = new URL(SELF_HOSTED_URL);
|
|
41
|
+
const SELF_HOSTED_BASE = `${_url.protocol}//${_url.host}`;
|
|
42
|
+
const SELF_HOSTED_QUERY = _url.search;
|
|
43
|
+
|
|
39
44
|
// 下载源列表(按优先级排序)
|
|
40
45
|
const DOWNLOAD_MIRRORS = [
|
|
41
46
|
{ name: 'JihuLab CDN', getUrl: (platform, arch, version, filename) => `${JIHULAB_BASE_URL}/${version}/${filename}`, auth: 'jihulab' },
|
|
42
|
-
{ name: 'Self-hosted', getUrl: (platform, arch, version, filename) => `${
|
|
47
|
+
{ name: 'Self-hosted', getUrl: (platform, arch, version, filename) => `${SELF_HOSTED_BASE}/api/releases/download/${platform}/${arch}/${version}${SELF_HOSTED_QUERY}`, auth: 'none' },
|
|
43
48
|
];
|
|
44
49
|
|
|
45
50
|
// 平台和架构映射
|
|
@@ -163,14 +168,14 @@ function applyPendingUpdate(installDir) {
|
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
/**
|
|
166
|
-
* 从
|
|
171
|
+
* 从 JihuLab Package Registry 查询最新版本号
|
|
167
172
|
* 返回: 版本字符串 或 null
|
|
168
173
|
*/
|
|
169
174
|
function fetchLatestVersion() {
|
|
170
175
|
return new Promise((resolve) => {
|
|
171
|
-
//
|
|
172
|
-
const url =
|
|
173
|
-
|
|
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
|
+
|
|
174
179
|
const protocol = url.startsWith('https') ? https : http;
|
|
175
180
|
const request = protocol.get(url, {
|
|
176
181
|
headers: { 'User-Agent': 'sciagent-cli/1.0' },
|
|
@@ -180,15 +185,13 @@ function fetchLatestVersion() {
|
|
|
180
185
|
response.on('data', (chunk) => { data += chunk; });
|
|
181
186
|
response.on('end', () => {
|
|
182
187
|
try {
|
|
183
|
-
const
|
|
184
|
-
const releases = result.releases || {};
|
|
185
|
-
// 找到所有版本中的最新版本
|
|
188
|
+
const packages = JSON.parse(data);
|
|
186
189
|
let latestVersion = null;
|
|
187
|
-
for (const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (!latestVersion || compareVersions(
|
|
191
|
-
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;
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
}
|
|
@@ -198,7 +201,7 @@ function fetchLatestVersion() {
|
|
|
198
201
|
}
|
|
199
202
|
});
|
|
200
203
|
});
|
|
201
|
-
|
|
204
|
+
|
|
202
205
|
request.on('error', () => resolve(null));
|
|
203
206
|
request.on('timeout', () => { request.destroy(); resolve(null); });
|
|
204
207
|
});
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -41,10 +41,15 @@ const JIHULAB_BASE_URL = `https://jihulab.com/api/v4/projects/${JIHULAB_PROJECT_
|
|
|
41
41
|
// 自建服务器配置(备用源)
|
|
42
42
|
const SELF_HOSTED_URL = process.env.RELEASE_SERVER_URL || 'https://px1-jcy.matpool.com:26741?token=BdZ2oxzimV';
|
|
43
43
|
|
|
44
|
+
// Parse SELF_HOSTED_URL to separate base URL from query params (e.g. ?token=xxx)
|
|
45
|
+
const _url = new URL(SELF_HOSTED_URL);
|
|
46
|
+
const SELF_HOSTED_BASE = `${_url.protocol}//${_url.host}`;
|
|
47
|
+
const SELF_HOSTED_QUERY = _url.search;
|
|
48
|
+
|
|
44
49
|
// 下载源列表(按优先级排序)
|
|
45
50
|
const DOWNLOAD_MIRRORS = [
|
|
46
51
|
{ name: 'JihuLab CDN', getUrl: (platform, arch, version, filename) => `${JIHULAB_BASE_URL}/${version}/${filename}`, auth: 'jihulab' },
|
|
47
|
-
{ name: 'Self-hosted', getUrl: (platform, arch, version, filename) => `${
|
|
52
|
+
{ name: 'Self-hosted', getUrl: (platform, arch, version, filename) => `${SELF_HOSTED_BASE}/api/releases/download/${platform}/${arch}/${version}${SELF_HOSTED_QUERY}`, auth: 'none' },
|
|
48
53
|
];
|
|
49
54
|
|
|
50
55
|
// PyPI 镜像源列表(国内优先)
|