chore(pm2): 清理迁移后零调用方的 PM2 spawn 命令构造 - #1302
Open
deepcoldy wants to merge 1 commit into
Open
Conversation
插件服务改走内置 supervisor(#1254)后,`src/core/plugins/pm2.ts` 被删除, `buildPm2SpawnCommand` 随之在全仓零调用方——已无任何代码路径 spawn PM2。 一并移除它的专测,并清掉 `tsconfig.test-mocks.json` 里指向已删除 `test/plugin-pm2-env.test.ts` 的 include 条目(tsc 对匹配不到的条目静默 容忍,不报错但是陈旧配置)。 有意保留 `src/cli/pm2-env.ts`:它虽然同样没有生产调用方,却是 `test/child-env.test.ts` 的**参照基准**—— `expect(viaExternal).toEqual(viaPm2)` 用旧 PM2 边界证明新的 `scrubExternalMemberEnv` 剥离的东西一模一样,删掉它等于让迁移 静默降低防护。 影响面:仅 PM2 spawn 命令行构造(Windows 引号/绝对 Node 路径那套)。 `legacy-pm2-reaper`(升级机清残留 God)、`pm2-graceful-exit`(退出码哨兵, 5 处在用)、`pm2-readonly-client`(桌面端按磁盘路径起子进程)均不受影响。 验证:tsc ✅ / typecheck:test-mocks ✅ / build ✅ / 6 文件 115 用例全通过;已确认参照基准用例 「strips exactly what the whole pm2 plugin boundary stripped」仍在执行。
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.
改了什么
插件服务迁到内置 supervisor(#1254)之后的收尾清理,删掉三样已经没人用的东西:
src/cli/pm2-command.ts(buildPm2SpawnCommand)test/pm2-command.test.ts(它的专测)tsconfig.test-mocks.json里指向已删除文件test/plugin-pm2-env.test.ts的 include 条目为什么
#1254 删掉了
src/core/plugins/pm2.ts,而它是buildPm2SpawnCommand在主干上唯一的生产调用方。现在全仓已经没有任何代码路径会 spawn PM2,这个函数(以及它那套 Windows 引号处理、绝对 Node 路径解析的逻辑)就成了纯粹的死代码。tsconfig.test-mocks.json那条 include 指向的文件已随 #1254 删除。tsc对匹配不到的 include 条目是静默容忍的(typecheck:test-mocks照样 exit 0),所以它不会让 CI 变红,只是一条陈旧配置。src/cli/pm2-env.ts它同样没有生产调用方,但不能删——它是
test/child-env.test.ts的参照基准:这条用例(
strips exactly what the whole pm2 plugin boundary stripped)拿旧的 PM2 边界当基准,证明迁移后的scrubExternalMemberEnv剥离的环境变量与旧路径一模一样。删掉pm2-env.ts等于让这条对照消失,迁移可能静默降低防护而没有任何测试会红。用例注释里也写明了这个意图("a migration must not quietly reduce protection")。影响面
只碰 PM2 spawn 命令行构造这一处。以下几个名字带 pm2 但仍在服役的模块都没动:
core/legacy-pm2-reaper.tspm2-graceful-exit.tscli/pm2-readonly-client.tsdesktop/main/pm2-apps.ts:68拼磁盘路径起子进程调用core/pm2-lifecycle-owner.ts/desktop/main/pm2-apps.ts不涉及跨平台差异(删掉的是 Windows 分支逻辑,但整个函数已无调用方);不涉及其它 CLI 适配器;不涉及 PtyBackend / TmuxBackend 或任何会话类型。
实测验证
跑的 6 个文件是整个 PM2 面 + supervisor 面:
child-env、pm2-graceful-exit、legacy-pm2-reaper、desktop/desktop-pm2-apps、plugin-supervisor-state、plugin-supervisor.integration。另外单独确认了参照基准那条用例确实在执行(不是被 vitest 静默跳过):
删除前也核过全仓对
pm2-command/buildPm2SpawnCommand的引用数为 0(src/test/scripts/ 配置文件全搜过;src/worker.ts里的capturedSpawnCommand、copySpawnCommand是同名无关标识符)。