Repository navigation
feat(pacquet): pack - #12567
feat(pacquet): pack#12567
pack#12567Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesPacklist extraction
Packaging flow
Estimated code review effort🎯 5 (Critical) | ⏱️ ~90+ minutes Possibly related PRs
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12567 +/- ##
==========================================
- Coverage 88.01% 87.91% -0.11%
==========================================
Files 354 363 +9
Lines 52699 53909 +1210
==========================================
+ Hits 46382 47393 +1011
- Misses 6317 6516 +199 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.818283289759998,
"stddev": 0.2524710998210471,
"median": 4.76579017966,
"user": 3.7977214399999992,
"system": 3.5568199,
"min": 4.559745267159999,
"max": 5.43050208916,
"times": [
4.91031298416,
5.43050208916,
4.80255300516,
4.85582813916,
4.729027354159999,
4.58724687616,
4.9552739911599994,
4.702555782159999,
4.64978740916,
4.559745267159999
]
},
{
"command": "pacquet@main",
"mean": 4.721725602459999,
"stddev": 0.1745581142928822,
"median": 4.64299306266,
"user": 3.8514385399999993,
"system": 3.5460103000000003,
"min": 4.57734702616,
"max": 5.104182864159999,
"times": [
4.95595931116,
4.59963846516,
4.6588029961599995,
4.6115044761599995,
5.104182864159999,
4.761759813159999,
4.57734702616,
4.62718312916,
4.700340833159999,
4.62053711016
]
},
{
"command": "pnpr@HEAD",
"mean": 3.0687110876600006,
"stddev": 0.09998086385900747,
"median": 3.03589146716,
"user": 2.7258462399999996,
"system": 3.083205,
"min": 2.9705051831600002,
"max": 3.24902882816,
"times": [
3.07206685016,
3.23660530516,
2.9705051831600002,
3.0507673411600003,
2.97169493616,
3.0027161701600003,
3.0946783781600002,
3.24902882816,
3.01803229116,
3.02101559316
]
},
{
"command": "pnpr@main",
"mean": 3.09028119006,
"stddev": 0.15054331352460024,
"median": 3.07037035416,
"user": 2.76708944,
"system": 3.0601330000000004,
"min": 2.91587294816,
"max": 3.28203773416,
"times": [
2.96203204516,
3.28203773416,
3.2668895511600002,
2.91587294816,
3.17320544016,
2.92831813316,
3.15773881916,
2.98300188916,
3.25571367116,
2.97800166916
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.66487958674,
"stddev": 0.018152349959152877,
"median": 0.66588089214,
"user": 0.3833767,
"system": 1.36246278,
"min": 0.64081307964,
"max": 0.69464667764,
"times": [
0.69464667764,
0.66800607164,
0.64651808464,
0.64520700164,
0.65725999364,
0.66375571264,
0.67039925164,
0.68977533364,
0.64081307964,
0.67241466064
]
},
{
"command": "pacquet@main",
"mean": 0.6708993666399998,
"stddev": 0.04539854405966071,
"median": 0.65373158514,
"user": 0.38940830000000004,
"system": 1.3524408799999998,
"min": 0.63862211464,
"max": 0.79303685764,
"times": [
0.64370856164,
0.66803315564,
0.64427693764,
0.65301240664,
0.63862211464,
0.65413807064,
0.68503113064,
0.67580933164,
0.65332509964,
0.79303685764
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7511101786400001,
"stddev": 0.06896352521801143,
"median": 0.73669386414,
"user": 0.3974447,
"system": 1.3879250799999996,
"min": 0.68188245164,
"max": 0.93801100864,
"times": [
0.68188245164,
0.74271064464,
0.74569452764,
0.74532293364,
0.71475241364,
0.72874345164,
0.72541453364,
0.93801100864,
0.75789273764,
0.73067708364
]
},
{
"command": "pnpr@main",
"mean": 0.7328957081399999,
"stddev": 0.07013901672800892,
"median": 0.7174527151400001,
"user": 0.3950961,
"system": 1.3791165799999998,
"min": 0.68381628464,
"max": 0.92500460364,
"times": [
0.68764707064,
0.69631072764,
0.72123697564,
0.72095251364,
0.70958695364,
0.68381628464,
0.71700862964,
0.74949652164,
0.71789680064,
0.92500460364
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.78044431292,
"stddev": 0.039201069502306625,
"median": 4.78254198392,
"user": 3.8458849199999996,
"system": 3.42796408,
"min": 4.70414921442,
"max": 4.84602145642,
"times": [
4.79985075142,
4.81205634142,
4.7499805974200004,
4.76054995342,
4.76203315542,
4.70414921442,
4.8047176914200005,
4.78856232742,
4.84602145642,
4.77652164042
]
},
{
"command": "pacquet@main",
"mean": 4.80207257792,
"stddev": 0.037656878914231764,
"median": 4.80427335192,
"user": 3.8795756199999993,
"system": 3.4531103799999996,
"min": 4.7570559804200006,
"max": 4.892432863420001,
"times": [
4.892432863420001,
4.80402979742,
4.78023500942,
4.80499538142,
4.80903769942,
4.81319872542,
4.7588142414200005,
4.7570559804200006,
4.79640917442,
4.80451690642
]
},
{
"command": "pnpr@HEAD",
"mean": 3.2410603697200004,
"stddev": 0.12954404801358707,
"median": 3.2025156689200003,
"user": 2.79017802,
"system": 3.25479228,
"min": 3.11870266842,
"max": 3.56827472442,
"times": [
3.1723279104200004,
3.28939335642,
3.56827472442,
3.26988702042,
3.28158709342,
3.2111211194200004,
3.11870266842,
3.19391021842,
3.1717524064200004,
3.13364717942
]
},
{
"command": "pnpr@main",
"mean": 3.23196099292,
"stddev": 0.08929612716736715,
"median": 3.1986339919200004,
"user": 2.8264762199999995,
"system": 3.21722178,
"min": 3.1214203144200003,
"max": 3.3432513794200003,
"times": [
3.17675061742,
3.3391513444200003,
3.1214203144200003,
3.3388743394200002,
3.2104142934200004,
3.2977154424200004,
3.1228516514200004,
3.18232685642,
3.3432513794200003,
3.1868536904200004
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.3673306006999997,
"stddev": 0.016687573512783962,
"median": 1.3702102098,
"user": 1.3235422399999999,
"system": 1.7443512399999996,
"min": 1.3284046903,
"max": 1.3854058853,
"times": [
1.3630267573,
1.3774155363,
1.3592933723,
1.3841557153,
1.3770242073,
1.3711488942999999,
1.3284046903,
1.3692715253,
1.3581594232999998,
1.3854058853
]
},
{
"command": "pacquet@main",
"mean": 1.3444437686,
"stddev": 0.018001705824036013,
"median": 1.3383604808,
"user": 1.31457064,
"system": 1.7032926400000001,
"min": 1.3259565673,
"max": 1.3838776973,
"times": [
1.3317221822999998,
1.3657705702999998,
1.3525887303,
1.3374840403,
1.3838776973,
1.3259565673,
1.3392369213,
1.3413146603,
1.3337340763,
1.3327522402999998
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4237813761,
"stddev": 0.03905546746864626,
"median": 1.4072800138,
"user": 0.58439804,
"system": 1.57617684,
"min": 1.3950719542999999,
"max": 1.5221062313,
"times": [
1.4401856723,
1.5221062313,
1.4177940713,
1.4489392803,
1.3998193292999999,
1.4051069913,
1.3977946913,
1.3950719542999999,
1.4015425033,
1.4094530363
]
},
{
"command": "pnpr@main",
"mean": 1.4473329338999998,
"stddev": 0.0525165297882918,
"median": 1.4281290398,
"user": 0.58107434,
"system": 1.5884936399999998,
"min": 1.4072186553,
"max": 1.5812149413,
"times": [
1.4229593133,
1.4914054023,
1.5812149413,
1.4293515093,
1.4449258862999999,
1.4210732573,
1.4350873753,
1.4072186553,
1.4269065703,
1.4131864283
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0265392595800003,
"stddev": 0.02504284558838877,
"median": 3.02931996258,
"user": 1.7969002399999998,
"system": 1.9848798200000002,
"min": 2.9884146560800002,
"max": 3.05980538708,
"times": [
3.04288609708,
3.0186283020799998,
3.01522180208,
2.99882020208,
2.9884146560800002,
3.04001162308,
3.00361339708,
3.04056134708,
3.05980538708,
3.05742978208
]
},
{
"command": "pacquet@main",
"mean": 3.01013986818,
"stddev": 0.038063025007062094,
"median": 3.01725657058,
"user": 1.79160304,
"system": 1.9671561199999998,
"min": 2.93933305408,
"max": 3.06708910008,
"times": [
2.95779121708,
3.01595423508,
2.93933305408,
2.99352051808,
3.01922775908,
3.03730772808,
3.01370750408,
3.06708910008,
3.03890866008,
3.01855890608
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4226467681800001,
"stddev": 0.01573521376561741,
"median": 1.42100941358,
"user": 0.5879443400000001,
"system": 1.58571612,
"min": 1.3921263020799999,
"max": 1.44770786408,
"times": [
1.42274855808,
1.43792499508,
1.43299457608,
1.44770786408,
1.41010457808,
1.41391287708,
1.4187682020799999,
1.43090946008,
1.3921263020799999,
1.41927026908
]
},
{
"command": "pnpr@main",
"mean": 1.42439205648,
"stddev": 0.028294427991169973,
"median": 1.4245638330800001,
"user": 0.58476824,
"system": 1.57771352,
"min": 1.39049332208,
"max": 1.48362891308,
"times": [
1.42531991208,
1.42380775408,
1.44538664608,
1.48362891308,
1.44414795808,
1.3915038230799999,
1.40723533008,
1.39049332208,
1.4263106320799999,
1.40608627408
]
}
]
} |
|
| Branch | pr/12567 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,780.44 ms(+0.73%)Baseline: 4,745.69 ms | 5,694.82 ms (83.94%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 3,026.54 ms(+0.12%)Baseline: 3,022.92 ms | 3,627.50 ms (83.43%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,367.33 ms(+1.61%)Baseline: 1,345.73 ms | 1,614.87 ms (84.67%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,818.28 ms(+2.66%)Baseline: 4,693.56 ms | 5,632.27 ms (85.55%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 664.88 ms(+4.15%)Baseline: 638.38 ms | 766.05 ms (86.79%) |
|
| Branch | pr/12567 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 3,241.06 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 1,422.65 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 1,423.78 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 3,068.71 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 751.11 ms |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pacquet/crates/cli/src/cli_args/pack.rs`:
- Around line 111-145: The recursive packing loop in CliArgs::run ignores the
global project selectors, so --filter and --filter-prod are not applied before
packing. Update the workspace project iteration path around
find_workspace_projects, create_projects_graph, and the for chunk/root loop to
skip any project that does not match the active selectors from Config before
calling pack_options/api. Ensure the filtering logic is applied consistently for
recursive targets so pack -r respects the same selection rules as non-recursive
runs.
- Around line 57-59: The `pack_gzip_level` CLI argument is documented as
supporting only `0`–`9`, but the `Pack` args field currently accepts any `u32`.
Update the `pack_gzip_level` definition in the `Pack` CLI args to add a
`value_parser` range constraint so invalid values fail at argument parsing time,
keeping the validation at the CLI boundary.
- Around line 128-133: The manifest filter in the pack recursion currently
treats any string as valid because it only checks `as_str().is_some()`, which
lets empty `name` and `version` values slip through. Update the `has_name` and
`has_version` checks in the `pack` logic to require non-empty strings so they
match the `pacquet_pack::api` precondition before calling `api`, and keep
skipping manifests that fail this stricter validation.
In `@pacquet/crates/exportable-manifest/src/create.rs`:
- Around line 153-156: The `create` flow in `exportable-manifest/src/create.rs`
is coercing present-but-non-object `peerDependencies` into an empty object via
`make_publish_dependencies()` and `unwrap_or_else`, unlike the other dependency
fields. Update the `peerDependencies` handling in `create` so it preserves any
non-object input as-is and only rewrites when the value is actually a dependency
object, using the existing `make_publish_dependencies`/`publish.insert` path
without defaulting `None` to `{}`.
In `@pacquet/crates/exportable-manifest/src/transform.rs`:
- Around line 46-55: `transform_required_fields` is too strict compared to
pnpm’s `if (!manifest.name)` behavior: it currently only accepts non-empty
strings via `Value::as_str()`. Update the validation to match upstream
truthiness semantics by treating any present, non-null value as valid unless it
is an empty string, and keep `TransformError::MissingRequiredField` only for
truly missing/falsy values. Use the existing `transform_required_fields` and
`MissingRequiredField` logic to make the check type-agnostic and preserve pnpm
parity.
In `@pacquet/crates/pack/src/lib.rs`:
- Around line 379-384: The bundled-dependencies guard in the manifest handling
logic is too broad because the check in the loop over bundledDependencies and
bundleDependencies treats false as enabled; update the validation in lib.rs to
only reject the enabled forms (true or an array) before raising
PackError::BundledDependenciesWithoutHoisted, and add a regression test covering
bundleDependencies: false so it passes under the default non-hoisted node
linker.
- Around line 546-551: The workspace LICENSE injection logic in the code that
iterates `read_dir(workspace_dir)` should only add regular files, not
directories or symlinks. Update the `entries.flatten()` loop in the workspace
license handling path to check the `DirEntry` metadata or file type before
calling `is_license_filename(&name)` and inserting into `files_map`, so the
extra `package/{name}` entry is only created for actual files.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2a99c5aa-66b1-492f-83b2-3f3f5f17615c
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (25)
Cargo.tomlpacquet/crates/cli/Cargo.tomlpacquet/crates/cli/README.mdpacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/pack.rspacquet/crates/exportable-manifest/Cargo.tomlpacquet/crates/exportable-manifest/src/create.rspacquet/crates/exportable-manifest/src/create/tests.rspacquet/crates/exportable-manifest/src/lib.rspacquet/crates/exportable-manifest/src/transform.rspacquet/crates/exportable-manifest/src/transform/tests.rspacquet/crates/fs-packlist/Cargo.tomlpacquet/crates/fs-packlist/src/lib.rspacquet/crates/fs-packlist/src/tests.rspacquet/crates/git-fetcher/Cargo.tomlpacquet/crates/git-fetcher/src/error.rspacquet/crates/git-fetcher/src/fetcher.rspacquet/crates/git-fetcher/src/lib.rspacquet/crates/git-fetcher/src/tarball_fetcher.rspacquet/crates/pack/Cargo.tomlpacquet/crates/pack/src/capabilities.rspacquet/crates/pack/src/lib.rspacquet/crates/pack/src/manifest_entry.rspacquet/crates/pack/src/tarball.rspacquet/crates/pack/src/tests.rs
Port `pnpm pack` to Rust: create a reproducible gzipped tarball from a project, running the prepack / prepare / postpack lifecycle scripts, building the publish manifest, computing the file list, and writing the archive. - Extract npm-packlist into a shared `pacquet-fs-packlist` crate so the git and directory fetchers and the new pack command share one copy, matching pnpm's standalone `@pnpm/fs.packlist` package. - Extend `pacquet-exportable-manifest` with the full createExportableManifest: manifest obfuscation, workspace / catalog / jsr specifier rewriting, publishConfig hoisting, README embedding, and the bin / peerDependenciesMeta / repository transform. - Add the `pacquet-pack` crate (single-project api plus JSON / text output) and wire `pacquet pack` into the CLI, including the recursive (-r) workspace sweep in topological order. The dependency-converter composition is a straight function sequence rather than upstream's higher-order combineConverters, and the tarball write phase uses the capability-trait DI seam (a Host provider plus Fs* traits) so its filesystem error branches stay testable without process-global mutation. Ported from https://github.com/pnpm/pnpm/blob/cab1c11c69/releasing/commands/src/publish/pack.ts https://github.com/pnpm/pnpm/blob/ef87f3ccff/releasing/exportable-manifest/src/index.ts Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
Apply `cargo fmt` to the `fixture` helper's `package.json` write, which drifted after a manual edit. No behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
- Add trailing commas to two multi-line macro invocations in the transform tests (perfectionist::macro_trailing_comma). - Replace a Unicode ellipsis with ASCII "..." in a create.rs doc comment (perfectionist::unicode_ellipsis_in_docs). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
- Rename the reporter generic `R` to `Reporter` (bounded `self::Reporter`) in pack's `api` / `run_scripts_if_present` and the CLI `pack` command, matching the convention already used in executor, git-fetcher, and package-manager (perfectionist::single_letter_generic). - Rename `locale_compare_en`'s `a` / `b` parameters to `left` / `right` (perfectionist::single_letter_function_param). - Move the inline `transform` test module into an external `transform/tests.rs` (perfectionist::unit_test_file_layout). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
Port pnpm's `pack: runs prepack, prepare, and postpack` (releasing/commands/test/publish/pack.ts) so `run_scripts_if_present` and `script_body` are exercised. The existing pack tests all pass `ignore_scripts: true`, so that branch was never entered. - runs_prepack_prepare_and_postpack (Unix-gated, like the executor's other script-running tests): with scripts enabled, each of prepack / prepare / postpack runs and leaves a marker file. - pack_succeeds_when_scripts_enabled_but_absent: an empty `prepack` makes `script_body` yield `None` and `run_scripts_if_present` return early, so packing still succeeds without shelling out. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
…ests Port the in-scope pnpm pack / createExportableManifest tests that close coverage holes in this PR's new code: - pack: bundleDependencies (array) and bundleDependencies: true cover the fs-packlist bundle recursion and the node_linker: hoisted allow-path. - pack: publishConfig.directory covers reading the manifest from the build-output dir while resolving workspace: deps against the project root's node_modules. - createExportableManifest: a peerDependencies workspace: rewrite and a jsr: specifier without a version selector. Ported from releasing/commands/test/publish/pack.ts and releasing/exportable-manifest/test/index.test.ts. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
The `cab1c11c69` SHA the crate docs referenced does not exist upstream. Repoint every `pack.ts` source link in `pack`'s module docs to `54c5c0e028`, where pnpm's releasing command now lives under `pnpm11/releasing/commands/...`, so the citations resolve.
Port pnpm's `pack: bundles transitive dependencies of bundled dependencies (hoisted)` test. `top` is the only directly-bundled package, but it depends on `nested`, which is hoisted to the root `node_modules`; both must end up in the tarball. This exercises `fs-packlist`'s transitive bundled-closure walk that landed via #12620 (resolving #12602) and arrived on this branch through the latest merge from `main`. Also repoint the existing pack-test citations to the valid `54c5c0e028` SHA, matching the docs fix in the surrounding crate.
Add a `pacquet pack` section to the CLI README listing its flag support (`--dry-run`, `--pack-destination`, `--json`, `--out`, `--pack-gzip-level`, `--skip-manifest-obfuscation`, recursive mode), so the new command ships with the same flag-status table the other commands carry. Also pin the last `pack.ts` citation in `cli_args/pack` to the valid `54c5c0e028` SHA, matching the rest of the crate.
Mutation-testing the pack tests surfaced that `pack_succeeds_when_scripts_enabled_but_absent` did not actually guard the behavior its name and doc claim. It asserted only that packing succeeds with an empty `prepack` script — but an empty lifecycle script runs as a successful no-op, so removing `script_body`'s `.filter(|s| !s.is_empty())` left the test green while the empty script was now executed. Record the emitted log events with the crate's `RecordingReporter` idiom and assert no `pnpm:lifecycle` event fires, pinning the "returns early without shelling out" half of the contract. With the empty-string filter removed the empty `prepack` shells out and emits a lifecycle event, so the test now fails — making it a real regression guard for `script_body`.
…ection Address review feedback on the pack port: - Validate `--pack-gzip-level` against 0-9 at the CLI boundary. - Skip recursive-pack targets whose name/version are empty strings, so they match the pacquet_pack::api precondition. - Stop coercing a non-object peerDependencies into an empty object in create_exportable_manifest; leave it in place like the other dep fields. - Gate transform_required_fields on JavaScript truthiness to match upstream's `if (!manifest.name)` check instead of requiring a non-empty string. - Gate the bundledDependencies guard on JS truthiness so an explicit `false` packs cleanly under the default non-hoisted linker. - Only inject a workspace LICENSE when the entry resolves to a regular file, mirroring fast-glob's onlyFiles default and avoiding an "Is a directory" failure in the later read/size pass.
e8ffde6 to
f81941b
Compare
Code Review by Qodo
1. Symlinked manifest read
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pacquet/crates/exportable-manifest/src/transform/tests.rs`:
- Around line 29-33: Update the falsy regression coverage in
falsy_version_is_rejected so it also exercises version: "" alongside the
existing falsy values. The transform_required_fields behavior applies the same
truthiness check to version as to name, so add the empty-string version case to
the run(json!({ "name": "foo", "version": falsy })) loop and keep asserting
MissingRequiredField for version using the existing run and TransformError
symbols.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c933cf0-599c-49f1-8fa7-c38324d4a10a
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (25)
Cargo.tomlpacquet/crates/cli/Cargo.tomlpacquet/crates/cli/README.mdpacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/pack.rspacquet/crates/exportable-manifest/Cargo.tomlpacquet/crates/exportable-manifest/src/create.rspacquet/crates/exportable-manifest/src/create/tests.rspacquet/crates/exportable-manifest/src/lib.rspacquet/crates/exportable-manifest/src/transform.rspacquet/crates/exportable-manifest/src/transform/tests.rspacquet/crates/fs-packlist/Cargo.tomlpacquet/crates/fs-packlist/src/lib.rspacquet/crates/fs-packlist/src/tests.rspacquet/crates/git-fetcher/Cargo.tomlpacquet/crates/git-fetcher/src/error.rspacquet/crates/git-fetcher/src/fetcher.rspacquet/crates/git-fetcher/src/lib.rspacquet/crates/git-fetcher/src/tarball_fetcher.rspacquet/crates/pack/Cargo.tomlpacquet/crates/pack/src/capabilities.rspacquet/crates/pack/src/lib.rspacquet/crates/pack/src/manifest_entry.rspacquet/crates/pack/src/tarball.rspacquet/crates/pack/src/tests.rs
✅ Files skipped from review due to trivial changes (6)
- pacquet/crates/git-fetcher/src/fetcher.rs
- pacquet/crates/git-fetcher/src/tarball_fetcher.rs
- pacquet/crates/exportable-manifest/src/lib.rs
- Cargo.toml
- pacquet/crates/fs-packlist/Cargo.toml
- pacquet/crates/cli/README.md
🚧 Files skipped from review as they are similar to previous changes (17)
- pacquet/crates/pack/src/manifest_entry.rs
- pacquet/crates/pack/src/capabilities.rs
- pacquet/crates/exportable-manifest/Cargo.toml
- pacquet/crates/pack/Cargo.toml
- pacquet/crates/cli/src/cli_args.rs
- pacquet/crates/pack/src/tarball.rs
- pacquet/crates/git-fetcher/Cargo.toml
- pacquet/crates/exportable-manifest/src/transform.rs
- pacquet/crates/git-fetcher/src/lib.rs
- pacquet/crates/git-fetcher/src/error.rs
- pacquet/crates/cli/Cargo.toml
- pacquet/crates/cli/src/cli_args/pack.rs
- pacquet/crates/pack/src/tests.rs
- pacquet/crates/exportable-manifest/src/create.rs
- pacquet/crates/exportable-manifest/src/create/tests.rs
- pacquet/crates/fs-packlist/src/lib.rs
- pacquet/crates/pack/src/lib.rs
A symlinked workspace-root LICENSE was followed via fs::metadata, so a symlink pointing outside the workspace could leak its target's bytes into a sub-package's tarball. Use DirEntry::file_type (which does not follow symlinks) so only a regular file is injected, mirroring the symlink-skipping read_readme_file in exportable-manifest. Add a unix regression test. Also pin the empty-string version case in the required-field truthiness test.
|
Code review by qodo was updated up to the latest commit f81941b |
|
Re: Qodo finding #3 — "Tarball built in memory" ( Thanks — valid observation, tracking it as a follow-up rather than fixing it in this PR.
Written by an agent (Claude Code, claude-opus-4-8). |
|
Code review by qodo was updated up to the latest commit 384d827 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pacquet/crates/fs-packlist/src/tests.rs (1)
720-743: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSolid regression test — it fails without the containment check (the old
is_file()onpkg_dir.join("../secret.js")would resolve to the existing outside file and force-include it).Optional: the symlink branch of
is_regular_file(amain/binsymlinking to a file outside the package) is not yet exercised. A second case writing an outside file and symlinkingpkg/link.js → ../secret.jswould lock in that protection too.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pacquet/crates/fs-packlist/src/tests.rs` around lines 720 - 743, Add a regression test around escaping_main_and_bin_fields_are_not_force_included to cover the symlink path too: create a package-local symlink for a main/bin target that points outside the package and assert packlist does not force-include the બહાર file. Use the existing packlist setup in this test to verify the containment behavior exercised by is_regular_file and the main/bin resolution logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pacquet/crates/fs-packlist/src/lib.rs`:
- Around line 596-601: The current `is_regular_file`/`is_contained_field_path`
checks do not protect against intermediate symlink traversal, so `main` and
`bin` can still resolve outside the package root. Update the validation in
`build_files_map` (or the helper it uses) to canonicalize the candidate path and
verify the resolved absolute file is strictly within the canonical package
directory before including it. Keep the final regular-file check, but replace or
augment `is_contained_field_path` with this containment check for the
`main`/`bin` path handling.
---
Nitpick comments:
In `@pacquet/crates/fs-packlist/src/tests.rs`:
- Around line 720-743: Add a regression test around
escaping_main_and_bin_fields_are_not_force_included to cover the symlink path
too: create a package-local symlink for a main/bin target that points outside
the package and assert packlist does not force-include the બહાર file. Use the
existing packlist setup in this test to verify the containment behavior
exercised by is_regular_file and the main/bin resolution logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ce319d28-6b0b-4108-a2ed-d02aa7db2c59
📒 Files selected for processing (4)
pacquet/crates/fs-packlist/src/lib.rspacquet/crates/fs-packlist/src/tests.rspacquet/crates/pack/src/lib.rspacquet/crates/pack/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pacquet/crates/pack/src/lib.rs
- pacquet/crates/pack/src/tests.rs
|
Code review by qodo was updated up to the latest commit 384d827 |
Recursive pack resolved a shared destination before `api` ran, so the `--out` branch silently dropped `pack_destination` and the mutually- exclusive pair was accepted — unlike single-project pack, which rejects it with ERR_PNPM_INVALID_OPTION. Validate the pair up front in the recursive path so both modes behave the same.
|
Code review by qodo was updated up to the latest commit 878dc37 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 878dc37 |
Address the remaining Qodo findings on the pack port: - Stream the gzip+tar archive into the atomic temp file instead of buffering the whole archive in a Vec, so peak memory no longer scales with the packed size. Per-file reads stay in memory, matching pnpm's readFileSync. The FsWrite seam becomes FsAtomicWrite, taking a streaming write body. - Thread Config.unsafe_perm into PackOptions instead of hardcoding unsafe_perm = true for prepack/prepare/postpack, so packing honors the same policy (and TMPDIR isolation) as pnpm. - Strip control characters from the text pack output, so a filename with raw ANSI escapes can't spoof the terminal. JSON output is left as data. - Reject an --out value that resolves to no file name (., .., "") up front instead of failing later with a confusing OS write error. - Sort the contents list with one cached lowercase key per item instead of recomputing to_lowercase on both sides per comparison, and check bin executability against a HashSet instead of a linear scan. Add regression tests for the --out and control-character cases.
|
Disposition of the remaining findings in Qodo's review summary (these were summary-only, with no inline threads):
(#2/#3/#4/#6 were resolved via their inline threads; #5 Written by an agent (Claude Code, claude-opus-4-8). |
|
Code review by qodo was updated up to the latest commit 67bcd63 |
Two follow-ups from review: - The main/bin force-include verified containment only on the path string, so an intermediate symlinked directory (subdir -> /outside) could still resolve a host file into the packlist. Verify the canonical resolved path is strictly inside the canonical package root instead, which also follows symlinks that stay in-package (matching npm-packlist) while failing closed on any escape. - The atomic tarball write read the destination's mode with metadata (follows symlinks), so a symlink at the output path could donate its target's or a directory's mode to the archive. Use symlink_metadata and only inherit from an existing regular file, and set the mode before syncing so content and metadata flush together.
|
Code review by qodo was updated up to the latest commit 67bcd63 |
|
Code review by qodo was updated up to the latest commit 676729d |
|
Code review by qodo was updated up to the latest commit 676729d |
…tering Hardening the shared packlist to drop `..`-escaping main/bin fields means patch-commit's `prepare_pkg_files_for_diff` no longer receives an escaping entry, so the old integration test's `expect_err` no longer fires. Unit-test patch-commit's own `safe_package_file_path` guard directly (defense in depth), and rework the integration test to assert the escaping `main` is filtered and never materialized into the diff view.
|
Code review by qodo was updated up to the latest commit a5fce12 |
| /// Read the raw manifest under `dir`, erroring when it is absent. | ||
| fn read_manifest(dir: &Path) -> Result<Value, PackError> { | ||
| match safe_read_package_json_from_dir(dir) { | ||
| Ok(Some(manifest)) => Ok(manifest), | ||
| Ok(None) => Err(PackError::ManifestNotFound { dir: dir.display().to_string() }), | ||
| Err(source) => Err(PackError::ReadManifest(source)), | ||
| } |
There was a problem hiding this comment.
1. Symlinked manifest read 🐞 Bug ⛨ Security
pacquet_pack::read_manifest() reads <dir>/package.json via safe_read_package_json_from_dir(), which uses fs::read_to_string and follows symlinks. An attacker-controlled repo can replace package.json with a symlink to an out-of-tree JSON file, causing pack to publish attacker-chosen manifest contents (and potentially leak local JSON data) despite other symlink-hardening in this PR.
Agent Prompt
## Issue description
`pacquet_pack::read_manifest()` accepts a symlinked `package.json` because `safe_read_package_json_from_dir()` reads it via `fs::read_to_string` (symlinks followed). This allows an untrusted repo to point `package.json` outside the project and have `pack` embed attacker-chosen manifest JSON into the produced tarball.
## Issue Context
This PR already explicitly avoids symlink reads for other embedded files (README/license), so `package.json` should follow the same rule.
## Fix Focus Areas
- pacquet/crates/pack/src/lib.rs[403-409]
- pacquet/crates/package-manifest/src/lib.rs[561-569]
## Suggested fix
- Add a non-following check before reading `package.json`:
- Use `std::fs::symlink_metadata(dir.join("package.json"))` and require `file_type().is_file()` **and** `!file_type().is_symlink()` (or equivalently, reject when `is_symlink()`), returning `Ok(None)`/a typed error if it’s not a regular file.
- Prefer fixing this in `safe_read_package_json_from_dir()` so all call sites (including `pack`) get the same protection, and adjust any tests accordingly.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit a5fce12 |
Summary by CodeRabbit
packcommand to generate publishable tarballs from a project, including recursive workspace packing.publishConfighoisting).main/binhandling to prevent path traversal and tightened file/symlink inclusion behavior.publishConfig.directorybehavior.packCLI documentation and options.