dsh-selfupdater 0.4.13 → 0.4.14
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/lib/plugin-update-task.mjs +26 -9
- package/package.json +1 -1
|
@@ -104,17 +104,31 @@ async function fetchVersionDoc(base, pkg) {
|
|
|
104
104
|
return { version: doc.version, tarball: doc?.dist?.tarball ?? null };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* 查询最新版本与下载地址(检查更新与更新任务共用,保证两边结论一致)。
|
|
109
|
+
*
|
|
110
|
+
* 0.4.14 修复:旧实现"第一个成功的 registry 就采用"。腾讯镜像 /latest 端点
|
|
111
|
+
* CDN 缓存陈旧时仍返回旧版本文档,导致"检查更新拿到 npmjs 的新版本、
|
|
112
|
+
* 点更新后任务却被镜像的旧版本骗过"而误判"无需更新"(NAS 0.4.12→0.4.13
|
|
113
|
+
* 实测踩坑)。改为并行查询全部 registry、取 semver 最大的结果:
|
|
114
|
+
* 任何一个镜像拿到新版即生效,单镜像陈旧缓存不再能压制判定。
|
|
115
|
+
*
|
|
116
|
+
* @returns {{version: string, tarball: string|null}} 全部失败时抛聚合错误。
|
|
117
|
+
*/
|
|
108
118
|
async function fetchLatestRelease(pkg) {
|
|
119
|
+
const candidates = registryCandidates();
|
|
120
|
+
const results = await Promise.allSettled(candidates.map((base) => fetchVersionDoc(base, pkg)));
|
|
121
|
+
let best = null;
|
|
109
122
|
const errors = [];
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
errors.push(`${
|
|
123
|
+
results.forEach((r, i) => {
|
|
124
|
+
if (r.status === 'fulfilled') {
|
|
125
|
+
if (best === null || isNewer(r.value.version, best.version)) best = r.value;
|
|
126
|
+
} else {
|
|
127
|
+
errors.push(`${candidates[i]}: ${r.reason.message}`);
|
|
115
128
|
}
|
|
116
|
-
}
|
|
117
|
-
throw new Error(errors.join(';'));
|
|
129
|
+
});
|
|
130
|
+
if (best === null) throw new Error(errors.join(';'));
|
|
131
|
+
return best;
|
|
118
132
|
}
|
|
119
133
|
|
|
120
134
|
/** 只取最新版本号(检查更新路由使用)。 */
|
|
@@ -375,7 +389,10 @@ export async function runPluginUpdateTask({ appDir, workspace, logger }) {
|
|
|
375
389
|
const release = await fetchLatestRelease(SELF_NAME);
|
|
376
390
|
if (!isNewer(release.version, installed)) {
|
|
377
391
|
log(`已是最新版本 ${installed},无需更新`);
|
|
378
|
-
|
|
392
|
+
// 状态必须是 idle:无需更新不是"待重启",若错用 done_pending_restart
|
|
393
|
+
// 前端会同时渲染"已是最新"消息与"重启生效"徽章,自相矛盾
|
|
394
|
+
//(NAS 0.4.12→0.4.13 实测踩坑)。消息照常显示,12 秒后自动隐藏。
|
|
395
|
+
setState('idle', `当前已是最新(${installed}),无需更新`);
|
|
379
396
|
return;
|
|
380
397
|
}
|
|
381
398
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-selfupdater",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "Self-update plugin for DeepSeek Harness: DSH core upgrades via detached swap script; plugin self-update installs in-place without killing the host and prompts for restart. DSH 主程序与已装插件的一站式在线更新插件。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|