feat: add stripPrefix config to remap pack destination paths - #1
Conversation
mxx1111
left a comment
There was a problem hiding this comment.
Reviewed by checking it out and running it, not by reading the description. The implementation is right and I want to merge it — one documentation gap first.
What I verified:
| Criterion | Result |
|---|---|
stripPrefix accepted and in KNOWN_KEYS |
✓ |
| Applies to destination path only, not file lookup | ✓ applied after assembly in pack.mjs |
| Prefix matching nothing is an error | ✓ and the message explains why |
| Collision is an error naming both paths | ✓ |
.. and absolute rejected |
✓ |
MANIFEST.json records post-strip paths |
✓ |
verify round-trip |
✓ |
init mentions the key |
✓ |
| Tests | ✓ 84 passing, up from 80 |
End-to-end on a monorepo fixture: packages/api/src/types.ts → src/types.ts, packages/api/tests/o.spec.ts → tests/o.spec.ts, manifest matches, verify clean. Exactly the shape the task asked for.
I also like that the "matched no files" error explains the reasoning rather than just failing — it matches the tone of the existing check in config.mjs.
The one change I want before merging
The PR removes the limitation paragraph from README but never adds stripPrefix to the Configuration section. Net effect: a reader of the README can no longer learn that the paths are fixed, and still cannot learn that there is a key to change them. The knowledge left the document instead of moving inside it.
Right now the only place it is documented is the commented output of sparepack init, which you only see if you already ran the thing.
Please add it to the sparepack.yaml block under ## Configuration, alongside the other five keys — something like:
stripPrefix: packages/api/ # strip this from every path inside the packand a sentence after the block on why it exists (packing from a monorepo root otherwise gives you packages/api/src/... inside the pack). One or two lines of prose is plenty; the removed paragraph had the reasoning already, it just needs re-pointing at the solution rather than at the absence of one.
No other changes requested. Push to the same branch and I will merge and settle the 10 TP.
中文摘要:实现没问题,端到端跑通了,84 个测试全过,我实测了前缀不匹配报错、碰撞报错、.. 拒绝、MANIFEST 记剥离后路径、verify 往返——全部符合验收标准。
唯一要改的:PR 把 README 里「路径不能重映射」那段局限删掉了,但没有在 Configuration 段补上 stripPrefix。结果是读 README 的人既看不到「路径是固定的」,也看不到「有个键可以改」——这个知识是离开了文档,而不是在文档里换了个位置。请在 sparepack.yaml 示例里加上这个键,再补一两句说明为什么需要它。推到同一个分支即可,我合并并结算 10 TP。
|
Updated! Added |
Summary
Closes mxx1111/spare-cycles#10
Adds the configuration option to allow users to strip a leading path prefix from destination paths inside the pack without altering how source files are resolved on disk.
Acceptance Criteria Covered
Testing
All 84 unit and e2e tests passed.