fix: solution for issue #19 - #26
Open
adityawaghamare04 wants to merge 1 commit into
Open
Conversation
6 tasks
|
这个 PR 已经 7 天没有新提交、作者也没有回复,它关联任务上的托管因此一直被占着,既不结算也不释放。
PR 不会被关闭——这是你的工作,随时可以接着做。被释放的只是任务上的认领,任务重新开放给其他人。 如果你还在做,回一句就行。 No commits or author replies for 7 days. The claim is released; this PR stays open. |
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.
Fix & Proposed Solution
Closes #19
🛠️ Proposed Solution (by Aditya Waghamare)
Analysis
The
stripPrefixfeature insparepackallows stripping a single leading directory prefix from destination paths. However, in monorepos or projects with distinct directory structures (e.g., source, test, config separated without a common root), stripping a single prefix is insufficient.Generalizing
stripPrefixintoremapprovides an ordered array of{ from, to }path mapping rules (first match wins). Under the hood,stripPrefixbecomes syntactic sugar for a single{ from: prefix, to: "" }rule. Additionally, traversal checks must be strictly applied to both the configured values (from,to) and the resulting destination paths, while retaining collision detection and hard-erroring on unusedfrommappings.Fix & Implementation Plan
Config Validation (
src/config.mjs):remapinKNOWN_KEYS.stripPrefixintoremap: [{ from: stripPrefix, to: "" }]ifremapis not explicitly set.remapformat (must be an array of{ from, to }objects).fromandtovalues (rejecting paths with..relative segments).Path Mapping & Processing (
src/pack.mjs):frommapping matches zero source files.MANIFEST.jsonstores post-remap destination paths.Template & Documentation (
src/init.mjs,README.md):sparepack inittemplate and documentation withremapoptions.Implementation
src/config.mjssrc/pack.mjssrc/init.mjstest/remap.test.mjsTesting & Verification
npm testacross unit and integration test suites.stripPrefixconfiguration files producing byte-identical archives.from,to) and rendered destination paths.Submitted by Aditya Waghamare
💰 Payout Address (Base L2 / EVM):
0xb61dBcdBc3407F71EaCb64D4CBFAcf9FFfe2415C