Skip to content

feat: add stripPrefix config to remap pack destination paths - #1

Open
ghzhost wants to merge 2 commits into
mxx1111:mainfrom
ghzhost:feat/strip-prefix
Open

feat: add stripPrefix config to remap pack destination paths#1
ghzhost wants to merge 2 commits into
mxx1111:mainfrom
ghzhost:feat/strip-prefix

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 18, 2026

Copy link
Copy Markdown

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

  • New config key accepted by and registered in .
  • Applies to destination paths inside the pack only (keeps file allowlist & source resolution untouched).
  • A prefix that matches no files is a hard error ().
  • Path collisions resulting from stripping are caught and report both colliding paths.
  • Traversal / escape outside the pack root via or absolute paths is strictly rejected.
  • records post-strip paths, ensuring passes cleanly.
  • template documents usage.
  • README's "Limits worth knowing" section updated to remove the limitation paragraph.
  • Comprehensive tests in and (prefix applies, no match error, collision error, verify round-trip).
  • Full test suite (84 tests) passing.

Testing

All 84 unit and e2e tests passed.

@mxx1111 mxx1111 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.tssrc/types.ts, packages/api/tests/o.spec.tstests/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 pack

and 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。

@ghzhost

ghzhost commented Aug 18, 2026

Copy link
Copy Markdown
Author

Updated! Added stripPrefix to the sparepack.yaml configuration block in README and documented the destination path remapping behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] sparepack: 包内路径无法重映射,从 monorepo 根打包会带出 packages/api/src/...

2 participants