fix(console): 检查更新改原生 fetch 查 registry + 面板移入官方「插件」页子 tab - #12
Closed
spacexun2 wants to merge 3 commits into
Closed
Conversation
- npmViewLatest 不再 spawn npm(受限宿主管道捕获被拦 EPERM、Windows .cmd 垫片 ENOENT 均致静默 null) - 404=非 registry 包(null 无 error);网络/HTTP 错误返回 error 并记日志,缓存含 error - /versions 与 /versions/refresh 响应带 error 字段;面板区分「已最新/本地包/检查失败」三态 - client 挂载点 settings.section「插件」→ 官方 settings.plugins.tab 子 tab「插件控制台」(消除导航同名 tab) - 新增 versions.spec.ts(mock fetch 200/404/非 404/网络错误/镜像源/scoped 编码),全套 41 测试通过 - 顺带修正 enumerate.spec.ts 仓库迁移后过期的 owner 断言(dsh-external→vlln)
This was referenced Aug 15, 2026
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
面板「检查更新」在受限宿主环境(sandboxed host)永远不出现可更新项、也无失败提示:
/api/plugin-console/versions/refresh返回全latest: null(含 registry 上确有新版的包)。旧
npmViewLatest根因(src/index.ts):spawnSync('npm', ['view', ...], { stdio: ['ignore','pipe','pipe'] })依赖子进程管道捕获输出——受限宿主环境拦截管道捕获(EPERM);Windows 下裸名npm是.cmd垫片,spawnSync 不解析(ENOENT)。catch {}静默折叠成null,且照常写缓存 → UI 显示「已检查」,用户无法区分「已最新」「本地包」「检查失败」。修复
Node half(新增
src/versions.ts):改为原生fetch查询 registry JSON API(GET <registry>/<name>/latest),零子进程,任何环境可工作:404= 非 registry 包(git/link 依赖)→latest: null, error: null;error带回响应并ctx.logger.warn记录,不再静默;npm_config_registry,兼容镜像源;scoped 包名/编码%2f。版本缓存记录 error;
/versions、/versions/refresh响应每项新增error字段。client half:
settings.section(label「插件」)改为官方settings.plugins.tab子 tab(label「插件控制台」)——官方 settings-plugins 节已声明该插槽,第三方管理面板挂这里可避免设置页导航出现多个同名「插件」tab。测试
tests/versions.spec.ts(mock fetch):200 / 404 / 非 404 / 网络错误 / 镜像源 / scoped 编码,7 用例;enumerate.spec.ts在仓库迁移后过期的 owner 断言(URL 已迁 vlln 但断言仍写 dsh-external)——既有失败,与本次改动无关,一并修正使套件全绿;spawnSync管道捕获 EPERM、新链路fetch返回 200;常规宿主(非受限)上旧实现因 Windows.cmd垫片同样全部latest: null,新实现返回真实 registry 版本(registry 包),git/link 依赖包返回null且error: null。与 #8 的关系
#8(Windows spawn 兼容)同样改了
npmViewLatest(win32 走 node 直跑 npm-cli.js),但仍是 spawnSync + 管道,不解决受限宿主拦截与静默失败。本 PR 用 fetch 重写该函数,与 #8 的runPnpm部分(install/update/remove 仍需 pnpm CLI)互补、冲突极小。AI 披露
本 PR 由 AI 辅助完成:模型 DeepSeek,工具 DeepSeek Harness。
关联 issue