fix(bds-tools): isMainModule 破坏 recovery.js shim(LSP 回归) - #43
Merged
Tanya7z merged 1 commit intoJul 23, 2026
Merged
Conversation
8bb9337 将入口判断改为 argv 与 import.meta.url 严格路径相等后, `node recovery.js`(根目录 shim → dist/recovery.js)不再触发 CLI。 恢复同 stem shim 契约,realpath 抗符号链接,recovery shim 改动态 import, 并为 manager 补齐 SFMC_SERVICE 对称判定;附 node:test 覆盖。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
Tanya7z
marked this pull request as ready for review
July 23, 2026 03:07
Contributor
Author
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
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.
背景
main@8bb9337 将
require.main === module/endsWith(...)收敛为isMainModule(import.meta.url)严格路径相等。审查结论(DRY / OCP / DIP / LSP / Demeter)
BLOCKER — LSP
node recovery.js(根目录 shim →dist/recovery.js)时process.argv[1]与import.meta.url路径不同,isMain()恒为 false,CLI 不再执行。历史endsWith("recovery.js")契约被破坏。BLOCKER — ESM 加载
recovery.js仍用createRequire加载 ESMdist/,在"type":"module"下不可靠;改为动态import()。MAJOR — LSP 对称性
check-update有SFMC_SERVICE==="update"兜底,bds-manager缺失;补齐manager。正向(DRY)
抽取
is-main.ts本身正确,保留并加固该唯一入口判定来源。修复
isMainModule:realpath + 同 stem shim 兼容(对齐历史契约)recovery.js:动态import(dist)bds-manager:SFMC_SERVICE==="manager"is-main.test.mjs:直接入口 / 同名 shim / 异名 import 三场景验证
CI
触发 push 的 ootb run 29975803843 已 success;本 PR 修的是 ootb 未覆盖的 rollback shim 路径。