dsh-selfupdater 0.4.28 → 0.4.30
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/updater.mjs +42 -12
- package/package.json +1 -1
package/lib/updater.mjs
CHANGED
|
@@ -387,9 +387,10 @@ async function downloadIntoStaging(target, registryBase) {
|
|
|
387
387
|
throw new Error(`staging 安装失败(pnpm exit ${result.code}): ${result.stderr.slice(-400)}`);
|
|
388
388
|
}
|
|
389
389
|
// pnpm 对失败的构建脚本仅告警不拦截(cnoke 缺 cmake 时就是这样静默失败的),
|
|
390
|
-
//
|
|
391
|
-
|
|
392
|
-
if (result.
|
|
390
|
+
// 必须把输出尾部落盘,问题才可诊断。尾部保留 3000 字符:500 字符在多包
|
|
391
|
+
// 并行构建时会截掉关键包的输出(0.4.28 排查 koffi 时被截断坑了一把)。
|
|
392
|
+
if (result.stdout.trim()) log(`[pnpm] 输出尾部: ${result.stdout.trim().slice(-3000).replace(/\s*\n+\s*/g, ' | ')}`);
|
|
393
|
+
if (result.stderr.trim()) log(`[pnpm] 告警尾部: ${result.stderr.trim().slice(-3000).replace(/\s*\n+\s*/g, ' | ')}`);
|
|
393
394
|
// 校验装到的确实是目标版本,防止镜像滞后悄悄装了旧版。
|
|
394
395
|
const staged = JSON.parse(readFileSync(join(stagingDir, 'node_modules', PKG, 'package.json'), 'utf8')).version;
|
|
395
396
|
if (staged !== target) throw new Error(`staging 版本不符:期望 ${target},实际 ${staged}`);
|
|
@@ -398,22 +399,51 @@ async function downloadIntoStaging(target, registryBase) {
|
|
|
398
399
|
verifyNativeModules();
|
|
399
400
|
}
|
|
400
401
|
|
|
402
|
+
/**
|
|
403
|
+
* koffi 原生二进制存在性校验(2.x / 3.x 双结构兼容)。
|
|
404
|
+
* - 2.x:cnoke 把 prebuild 解压到 koffi/build/koffi/<平台>/koffi.node;
|
|
405
|
+
* - 3.x 起架构重构:二进制改为 @koromix/koffi-<os>-<arch> 平台子包分发
|
|
406
|
+
* (esbuild 模式),主包 build/ 下不再落任何 .node —— 只认老路径会把
|
|
407
|
+
* 装好的 3.x 误判为缺失(0.4.28 实测踩坑,升级被自家校验拦下)。
|
|
408
|
+
* 任一结构命中即视为齐备。
|
|
409
|
+
*/
|
|
410
|
+
function koffiBinaryFound() {
|
|
411
|
+
// 2.x 老结构:build/ 下递归找 .node
|
|
412
|
+
if (findFileByExt(join(stagingDir, 'node_modules', 'koffi', 'build'), '.node')) return true;
|
|
413
|
+
// 3.x 新结构:@koromix/koffi-<os>-<arch> 平台子包任一含 .node 即通过
|
|
414
|
+
try {
|
|
415
|
+
const koromixDir = join(stagingDir, 'node_modules', '@koromix');
|
|
416
|
+
for (const entry of readdirSync(koromixDir, { withFileTypes: true })) {
|
|
417
|
+
if (entry.isDirectory() && entry.name.startsWith('koffi-')
|
|
418
|
+
&& findFileByExt(join(koromixDir, entry.name), '.node')) return true;
|
|
419
|
+
}
|
|
420
|
+
} catch { /* 无 @koromix 目录:2.x 或平台包未装上 */ }
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
401
424
|
/**
|
|
402
425
|
* 校验 staging 内原生模块的构建产物是否齐全。
|
|
403
|
-
* - koffi
|
|
426
|
+
* - koffi:见 koffiBinaryFound(2.x/3.x 双结构兼容);
|
|
404
427
|
* - fs-ext:node-gyp 编译,产物在 build/Release/fs-ext.node(NAS 需编译工具链)。
|
|
405
|
-
*
|
|
428
|
+
*
|
|
429
|
+
* 校验语义是"依赖树里有则必须完整",而非"必须有":上游会调整依赖
|
|
430
|
+
* (0.1.5-alpha.2 起移除了 fs-ext),无条件校验会对本就不存在的包误报,
|
|
431
|
+
* 把成功的升级拦下(0.4.29 实测踩坑)。任一缺失即抛错终止本次升级
|
|
432
|
+
* (尚未换装,旧版原样运行,天然安全)。
|
|
406
433
|
*/
|
|
407
434
|
function verifyNativeModules() {
|
|
408
435
|
const problems = [];
|
|
409
|
-
|
|
410
|
-
|
|
436
|
+
const nmDir = join(stagingDir, 'node_modules');
|
|
437
|
+
if (existsSync(join(nmDir, 'koffi')) && !koffiBinaryFound()) {
|
|
438
|
+
problems.push('koffi 缺少原生二进制(install 脚本未执行或平台子包未装上)');
|
|
411
439
|
}
|
|
412
|
-
const fsExtDir = join(
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
440
|
+
const fsExtDir = join(nmDir, 'fs-ext');
|
|
441
|
+
if (existsSync(fsExtDir)) {
|
|
442
|
+
if (!existsSync(join(fsExtDir, 'fs-ext.js'))) {
|
|
443
|
+
problems.push('fs-ext 包文件不完整(缺少 fs-ext.js)');
|
|
444
|
+
} else if (!findFileByExt(join(fsExtDir, 'build'), '.node')) {
|
|
445
|
+
problems.push('fs-ext 缺少编译产物 build/Release/fs-ext.node(NAS 需要 python3/make/g++ 工具链)');
|
|
446
|
+
}
|
|
417
447
|
}
|
|
418
448
|
if (problems.length > 0) throw new Error(`原生模块校验失败:${problems.join(';')}`);
|
|
419
449
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-selfupdater",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.30",
|
|
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",
|