fix(deploy): 每次部署重建 shell dist,杜绝陈旧复用(#73) - #74
Merged
Merged
Conversation
provisionAll 中 apps/shell/dist 一旦存在即跳过 vite build、直接 cp 复用旧产物, 源码变更被静默丢弃(真机实证:PR #72 合并重部署后线上 bundle hash 未变化)。 - 删除 dist 复用捷径:每次部署无条件重建 shell,部署器职责=始终搬运当前源码树; - 新增 buildShell 注入口(同 steps.ts putSecret/resolveZone 模式),测试注入 fake 避免真实 vite; - runNineSteps 转发 buildShell;steps.test.ts 注入快速 fake(真实 vite ~4.4s/次会使套件超时); - 修正 provisionAll JSDoc 与文件头注释中 FORCE_BUILD/dist 复用措辞; - 新增 provisionAll 用例:预置陈旧 dist + stale.marker,断言新产物入 assets/shell 且无陈旧残留。 Signed-off-by: HandyWote <huangyinghui01@corp.netease.com>
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.
背景
provisionAll里apps/shell/dist一旦存在就跳过vite build、直接cp复用旧产物,源码变更被静默丢弃。真机实证:PR #72 合并后重部署,线上壳 bundle hash 与修复前完全相同(未带新实现)。另有注释声称支持 FORCE_BUILD,但代码中不存在该机制。修法
删除 dist 复用捷径:每次部署都重建 shell(vite build ~2s;幂等语义由 wrangler deploy/路由幂等保证,部署器职责=始终搬运当前源码树)。
改动文件
deploy/cloudflare/src/assemble.tsexistsSync(shellDist)条件构建捷径 → 无条件构建后 cp 到outDir/assets/shell;provisionAlloptions 新增buildShell?: (rootDir) => Promise<void>注入口(默认pnpm --filter @unself/shell build);修正 JSDoc/文件头 FORCE_BUILD 与 dist 复用措辞deploy/cloudflare/test/assemble.test.tsprovisionAll用例:mkdtemp 临时 rootDir + 预置陈旧 dist(stale.marker+ 旧index.html),注入 fakebuildShell重建新产物,断言assets/shell含新产物且无陈旧残留deploy/cloudflare/src/steps.tsrunNineSteps转发buildShell注入口(与既有putSecret/resolveZone同模式)——#73 语义变化后仍保持注入模式一致deploy/cloudflare/test/steps.test.tsbuildShell(真实 vite ~4.4s/次,每次部署重建后套件必超时;fake 写最小 dist 产物)验收对照表
provisionAll(③ shell 每次部署重建,#73)通过(69/69)。破坏性回验:条件构建恢复时expect(buildCalled).toBe(true)红(AssertationError: expected false to be true,assemble.test.ts:219);还原后绿pnpm -r typecheck全过;pnpm -r test全过(deploy/cloudflare 69、apps/shell 41、modules/hello 12 等);pnpm -r buildexit=0origin/m0/dev(082ee78),线性单 commit26f9e4d,未合并