[tech] 🐛 fix(cli): 修复 Windows 下 update 的 Core 范围查询 + 发布 cli@3.6.6 - #64
Merged
Merged
Conversation
flow2spec update 用 `npm view <core>@^x.y.z` 查兼容范围内最新 Core;Windows 上 参数经 cmd.exe 执行(shell:true 才能找到 npm.cmd)且只拼接不转义,`^` 被当转义符 吃掉后查询退化为精确版本,目标永远等于当前基线:update --check 永远显示已最新、 update --core 实际 no-op(Linux/macOS 不受影响,CI 在 Linux 故未暴露)。 改为 `npm view <core> versions --json` 列全部版本,在 JS 里按 caret 范围过滤取最大, 再对选中的精确版本查 templateVersion;全程不向 argv 传特殊字符。 test-cli-update 的 mock 与断言同步,并新增「任何调用都不得传 ^」回归断言。
Core 保持 3.8.3、Template 3.8.2,CLI 兼容范围仍为 ^3.8.2。 本轮已跑 version:check / npm test / pack:check 全部通过。
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.
问题
Windows 上
flow2spec update永远认为 Core 已是最新(update --core实际是 no-op):根因
queryLatestCoreMetadata()用npm view <core>@^3.8.2 …查兼容范围内最新 Core。Windows 下runCommandSync必须shell: true(否则找不到npm.cmd),而参数只拼接、不转义,cmd.exe 把^当转义符吃掉,查询退化成精确版本@3.8.2,目标永远等于当前基线。本机实测(同一条命令,唯一差别是 shell):
shell: true→ 只返回 3.8.2/3.8.1;bash(^不特殊)→ 返回含 3.8.3 的完整列表。Linux/macOS 与 CI 一直正常,所以此前未暴露。改法
npm view <core> versions --json列全部版本,在 JS 里按 caret 范围过滤取最大templateVersion(老版本缺该字段时回落到 Core 版本本身)satisfiesCoreRange()验证
update --check现在正确报告Core: 3.8.3 -> 3.8.3^3.8.2 → 3.9.0、^0.2.3 → 0.2.4、--core生效校验通过、任何调用都不含^npm test全链、version:check、pack:check通过(test-cli-update在 win32 只跑 help 冒烟,CI 会跑完整 mock)版本
CLI
3.6.5 → 3.6.6;Core 保持 3.8.3、Template 3.8.2,兼容范围仍^3.8.2。