Repository navigation
feat(pacquet-cli): port the setup command - #12697
Conversation
Port pnpm's `setup` command to pacquet, making `pnpm` available for global use. Mirrors pnpm11/engine/pm/commands/src/setup/setup.ts and the `@pnpm/os.env.path-extender` package family it depends on. The command installs the CLI into the global packages directory (spawning `<exe> add -g --ignore-scripts file:<execDir>` with a temporary `@pnpm/exe` package.json, as pnpm does), writes the `pn` / `pnpx` / `pnx` alias scripts into `$PNPM_HOME/bin`, and persists `PNPM_HOME` plus `$PNPM_HOME/bin` into the user's environment — the current shell's rc file on POSIX (bash/zsh/ksh/dash/sh/fish/nushell) or the registry on Windows. The path-extender is inlined as a private module under the command. The shell rc-block create/append/skip/modify logic and the Windows `reg query` line parsing use plain string operations rather than a regex dependency. Error codes mirror pnpm's PnpmError codes (ERR_PNPM_BAD_SHELL_SECTION, ERR_PNPM_BAD_ENV_FOUND, ...), including the `--force` hints. Unit tests port the upstream path-extender-posix spec cases and cover the Windows registry parser/renderer and the output rendering.
|
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds a new Changespacquet setup flow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
PR Summary by QodoPort pnpm Description
Diagram
High-Level Assessment
Files changed (11)
|
Code Review by Qodo
1.
|
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit 8083c6e |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
pacquet/crates/cli/src/cli_args/setup/path_extender/posix.rs (1)
19-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftThread env/home discovery through the existing Host/Sys seam.
add_dir_to_posix_env_pathreaches into process-global env state viastd::envfor shell detection,$SHELL,$ENV, and$ZDOTDIR. That makes these user-visible setup branches hard to test deterministically and violates the pacquet convention for library logic that reads process state.As per path instructions, “Reading process state: avoid
std::env::var/current_dirdirectly in library logic; thread values via parameters or a DI seam.”Also applies to: 29-43, 106-113, 274-278
🤖 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/cli/src/cli_args/setup/path_extender/posix.rs` around lines 19 - 24, `add_dir_to_posix_env_path` and the shell-detection/update flow are reading process-global state directly via std::env, which should instead be threaded through the existing Host/Sys seam for deterministic testing. Refactor `detect_current_shell`, `update_shell`, and the code paths around shell env/home discovery so they accept the needed env/home values as parameters (or through the DI seam) rather than calling std::env for $SHELL, $ENV, and $ZDOTDIR internally. Keep the public behavior the same, but move all process-state access out of the library logic and into the seam/wrapper layer.Source: Path instructions
🤖 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/setup.rs`:
- Around line 126-128: The temporary package cleanup in setup.rs is swallowing
failures by ignoring the result of fs::remove_file, which can leave the
synthetic package.json behind and affect later behavior. Update the cleanup path
in the setup flow that uses created_pkg_json and pkg_json_path so the
remove_file error is handled and propagated instead of being discarded, keeping
the existing control flow but surfacing any cleanup failure to the caller.
- Around line 116-124: The PATH handling in setup logic is discarding non-UTF-8
values and can wipe out the caller’s ambient PATH when building the pnpm install
environment. Update the PATH construction in the setup flow around the
bin_dir/path_value logic to use an OsString-based approach with std::env::var_os
plus split_paths and join_paths, then pass that preserved value into
Command::env for the install command.
In `@pacquet/crates/cli/src/cli_args/setup/path_extender/posix.rs`:
- Around line 213-236: The rc-file update logic in the PathExtender POSIX flow
writes directly to the target file with fs::write, which is not crash-safe.
Update the code paths in the config-file creation, append, and replace flows to
write through a temporary file in the same directory, flush/sync it, and then
atomically rename it over the original. Keep the behavior centered around
find_section, replace_section, and the config_file write sites, but ensure every
overwrite of the shell rc file uses the atomic temp-file pattern.
- Around line 81-96: Escape all shell-interpolated path values before rendering
rc snippets: in render_posix_settings, and the related sh/fish/nu path
renderers, treat dir and proxy-derived entries as untrusted input and
quote/escape them with shell-appropriate escaping before inserting into PATH or
export statements. Update the helpers that build path_value/path_ref so they
cannot emit raw quotes, command substitutions, newlines, or metacharacters from
caller-provided paths. Ensure the fix is applied consistently across the
referenced renderer functions so the generated setup snippets remain safe for
shell rc files.
In `@pacquet/crates/cli/src/cli_args/setup/path_extender/windows.rs`:
- Around line 193-197: The refresh_env_vars function currently ignores whether
setx and reg delete actually succeed, so setup can report success even when the
environment refresh failed. Update refresh_env_vars to inspect the exit status
from both Command::new("setx") and Command::new("reg") in the windows path
extender flow, and return a PathExtenderError if either command fails. Keep the
failure handling local to refresh_env_vars so errors are propagated instead of
swallowed.
- Around line 138-140: `get_registry_output` and the code path in `add_to_path`
should not assume `run_capture` succeeded just because it returned stdout; check
the child process exit status before using the output. If `reg query` or `chcp
65001` exits non-zero, return the appropriate `PathExtenderError` (especially
`RegRead`) instead of letting empty/invalid stdout continue into path parsing.
Use the existing `get_registry_output` helper and the `add_to_path` flow to
propagate failures with the correct pnpm-compatible error code/message.
---
Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/setup/path_extender/posix.rs`:
- Around line 19-24: `add_dir_to_posix_env_path` and the shell-detection/update
flow are reading process-global state directly via std::env, which should
instead be threaded through the existing Host/Sys seam for deterministic
testing. Refactor `detect_current_shell`, `update_shell`, and the code paths
around shell env/home discovery so they accept the needed env/home values as
parameters (or through the DI seam) rather than calling std::env for $SHELL,
$ENV, and $ZDOTDIR internally. Keep the public behavior the same, but move all
process-state access out of the library logic and into the seam/wrapper layer.
🪄 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: c7cd98aa-0ab0-411e-84af-b2db6c4ef0f7
📒 Files selected for processing (11)
pacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/cli_command.rspacquet/crates/cli/src/cli_args/dispatch.rspacquet/crates/cli/src/cli_args/dispatch_query.rspacquet/crates/cli/src/cli_args/setup.rspacquet/crates/cli/src/cli_args/setup/path_extender.rspacquet/crates/cli/src/cli_args/setup/path_extender/posix.rspacquet/crates/cli/src/cli_args/setup/path_extender/posix/tests.rspacquet/crates/cli/src/cli_args/setup/path_extender/windows.rspacquet/crates/cli/src/cli_args/setup/path_extender/windows/tests.rspacquet/crates/cli/src/cli_args/setup/tests.rs
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12697 +/- ##
==========================================
- Coverage 85.88% 85.43% -0.46%
==========================================
Files 385 389 +4
Lines 59044 59609 +565
==========================================
+ Hits 50709 50926 +217
- Misses 8335 8683 +348 ☔ 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": 5.19012518934,
"stddev": 0.5937455854187318,
"median": 4.96649652284,
"user": 3.2449333599999997,
"system": 2.7083568,
"min": 4.62240387984,
"max": 6.63394201684,
"times": [
6.63394201684,
5.635676058840001,
5.0280991868400005,
5.49211333384,
4.92045569484,
4.85150963484,
4.62240387984,
4.81554140684,
4.88897332984,
5.01253735084
]
},
{
"command": "pacquet@main",
"mean": 4.702163533239999,
"stddev": 0.20277565527926592,
"median": 4.63451571384,
"user": 3.28164666,
"system": 2.6756789999999997,
"min": 4.43549523884,
"max": 5.00907933984,
"times": [
4.93382052784,
4.60871877384,
4.49956569184,
4.85388021884,
4.66031265384,
4.43549523884,
5.00907933984,
4.57488770384,
4.89538747684,
4.55048770684
]
},
{
"command": "pnpr@HEAD",
"mean": 3.1300609367399996,
"stddev": 0.20126824016132458,
"median": 3.0974081278399996,
"user": 2.2098837599999994,
"system": 2.3015782,
"min": 2.82102217584,
"max": 3.5338507418400003,
"times": [
3.5338507418400003,
3.12491391784,
3.04422266684,
2.95619981484,
2.82102217584,
2.99407373784,
3.23468740584,
3.06990233784,
3.23712812584,
3.28460844284
]
},
{
"command": "pnpr@main",
"mean": 3.12901122614,
"stddev": 0.22324120645017162,
"median": 3.08940396684,
"user": 2.2127291599999994,
"system": 2.2886444,
"min": 2.77917439184,
"max": 3.57530912784,
"times": [
2.94205423784,
3.23828762984,
2.77917439184,
3.24854284584,
3.04407150784,
3.13473642584,
3.57530912784,
3.03064426484,
3.30370301384,
2.99358881584
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6690666358399999,
"stddev": 0.043934632851556146,
"median": 0.65251899434,
"user": 0.31752737999999997,
"system": 1.0454858000000002,
"min": 0.63358316334,
"max": 0.75789969234,
"times": [
0.65179682834,
0.63664313334,
0.65324116034,
0.7373975203400001,
0.65796854334,
0.63880821534,
0.75789969234,
0.64160840934,
0.68171969234,
0.63358316334
]
},
{
"command": "pacquet@main",
"mean": 0.74900065364,
"stddev": 0.11469037518942783,
"median": 0.72441743234,
"user": 0.31514028,
"system": 1.0510556000000002,
"min": 0.63770964034,
"max": 0.94453765834,
"times": [
0.85551635234,
0.64302089234,
0.64992306634,
0.79339456734,
0.63770964034,
0.76423615934,
0.63845454834,
0.87861494634,
0.94453765834,
0.68459870534
]
},
{
"command": "pnpr@HEAD",
"mean": 0.8568754004400001,
"stddev": 0.11728080354687968,
"median": 0.81442888584,
"user": 0.32848157999999994,
"system": 1.0774044,
"min": 0.67719500934,
"max": 1.08221387234,
"times": [
1.08221387234,
0.80671593534,
0.78678372134,
0.92701536234,
0.82214183634,
0.67719500934,
0.78187447834,
0.90613937934,
0.98157642234,
0.79709798734
]
},
{
"command": "pnpr@main",
"mean": 0.8285150530400001,
"stddev": 0.12253368117914218,
"median": 0.82416734284,
"user": 0.3237338799999999,
"system": 1.0679750000000001,
"min": 0.68305316034,
"max": 1.06461483534,
"times": [
0.92512696234,
0.9222396083400001,
0.8385165263400001,
0.68305316034,
0.78083026634,
0.6861450033400001,
0.80981815934,
0.87027950934,
1.06461483534,
0.70452649934
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.79678020212,
"stddev": 0.1874320520970358,
"median": 4.79506327512,
"user": 3.1405884799999995,
"system": 2.6511214799999996,
"min": 4.583124821119999,
"max": 5.06770399112,
"times": [
4.631855177119999,
4.78565685712,
4.80446969312,
5.06770399112,
4.583124821119999,
4.82832604312,
5.0608830951199995,
4.61948304312,
4.60938430712,
4.97691499312
]
},
{
"command": "pacquet@main",
"mean": 4.786381796620001,
"stddev": 0.17300791223938852,
"median": 4.77795552862,
"user": 3.13687828,
"system": 2.66069698,
"min": 4.52261222512,
"max": 5.11915250512,
"times": [
4.79459912912,
4.76405336612,
5.11915250512,
4.79185769112,
4.71432027812,
4.758723048119999,
4.52261222512,
4.93167599012,
4.90044321212,
4.56638052112
]
},
{
"command": "pnpr@HEAD",
"mean": 3.08153808912,
"stddev": 0.11805269064067349,
"median": 3.03600497362,
"user": 2.26840878,
"system": 2.5029410800000003,
"min": 2.9811905441200004,
"max": 3.3365270441200003,
"times": [
2.98462786912,
2.9811905441200004,
3.12794934812,
3.04899363712,
2.9922602721200002,
3.3365270441200003,
3.21395653812,
2.99332947312,
3.02301631012,
3.1135298551200004
]
},
{
"command": "pnpr@main",
"mean": 3.32584992312,
"stddev": 0.22904079755755877,
"median": 3.32561512062,
"user": 2.3536282799999997,
"system": 2.55015438,
"min": 3.0548273811200004,
"max": 3.8277035721200003,
"times": [
3.29426384412,
3.4367376641200003,
3.2424731431200002,
3.08326999812,
3.11029772912,
3.8277035721200003,
3.41472248512,
3.43723701712,
3.0548273811200004,
3.3569663971200003
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.27900869616,
"stddev": 0.02522545123593971,
"median": 1.27208849406,
"user": 1.11943384,
"system": 1.3645871599999997,
"min": 1.25484708456,
"max": 1.33749416356,
"times": [
1.26304974456,
1.30869747956,
1.26462224556,
1.2748639365599999,
1.33749416356,
1.27520191356,
1.25484708456,
1.27892009856,
1.26307724356,
1.26931305156
]
},
{
"command": "pacquet@main",
"mean": 1.36718169706,
"stddev": 0.14700318326067346,
"median": 1.30828100106,
"user": 1.11739334,
"system": 1.4170931599999999,
"min": 1.25147411156,
"max": 1.68756657256,
"times": [
1.33880173756,
1.68756657256,
1.58984171056,
1.32605879456,
1.29736310056,
1.3139280415599999,
1.30263396056,
1.28500993056,
1.27913901056,
1.25147411156
]
},
{
"command": "pnpr@HEAD",
"mean": 1.43202303436,
"stddev": 0.15833678493433775,
"median": 1.3742771085599998,
"user": 0.47429383999999997,
"system": 1.2435524599999999,
"min": 1.30153835456,
"max": 1.7718965155600002,
"times": [
1.37876175956,
1.7718965155600002,
1.43023068056,
1.36979245756,
1.32231741956,
1.32339758356,
1.30153835456,
1.34543267756,
1.41114480156,
1.66571809356
]
},
{
"command": "pnpr@main",
"mean": 1.40269534296,
"stddev": 0.09121397784384148,
"median": 1.39392908106,
"user": 0.47741044,
"system": 1.23131986,
"min": 1.30049626456,
"max": 1.5381609135599998,
"times": [
1.49728158056,
1.33540525056,
1.36711385756,
1.50720956656,
1.44601805756,
1.4207443045600001,
1.30607457656,
1.30844905756,
1.5381609135599998,
1.30049626456
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.9373408480600003,
"stddev": 0.22769579961313524,
"median": 2.85772012226,
"user": 1.4914045799999998,
"system": 1.5893922,
"min": 2.77001803876,
"max": 3.49686142276,
"times": [
3.49686142276,
2.81515889676,
2.89216650476,
2.88512143876,
2.89164480176,
2.82764879376,
2.77001803876,
3.17748733876,
2.83031880576,
2.78698243876
]
},
{
"command": "pacquet@main",
"mean": 2.86697332426,
"stddev": 0.06266350628982105,
"median": 2.84753107576,
"user": 1.50504028,
"system": 1.6084963,
"min": 2.79500126976,
"max": 2.96351063476,
"times": [
2.79500126976,
2.95626675476,
2.80439326076,
2.85160546876,
2.96351063476,
2.83565412076,
2.8558009437600003,
2.82456085476,
2.8434566827600003,
2.93948325176
]
},
{
"command": "pnpr@HEAD",
"mean": 1.40319302776,
"stddev": 0.08439212418756853,
"median": 1.3745216997599998,
"user": 0.48068977999999996,
"system": 1.2495176000000001,
"min": 1.32342875176,
"max": 1.59906123776,
"times": [
1.59906123776,
1.35312172976,
1.35977619476,
1.49249247076,
1.42691062276,
1.35937309676,
1.38969742176,
1.32342875176,
1.33880154676,
1.3892672047599999
]
},
{
"command": "pnpr@main",
"mean": 1.4747641485599998,
"stddev": 0.1240188936647019,
"median": 1.43886272026,
"user": 0.48036187999999996,
"system": 1.2469807999999998,
"min": 1.33752514976,
"max": 1.67083937676,
"times": [
1.40494904776,
1.3477661377599999,
1.35317947176,
1.67083937676,
1.59269667376,
1.62400937976,
1.40427922176,
1.47277639276,
1.33752514976,
1.53962063376
]
}
]
} |
|
| Branch | pr/12697 |
| 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,796.78 ms(+0.76%)Baseline: 4,760.61 ms | 5,712.73 ms (83.97%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 2,937.34 ms(-3.58%)Baseline: 3,046.48 ms | 3,655.78 ms (80.35%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,279.01 ms(-5.86%)Baseline: 1,358.63 ms | 1,630.35 ms (78.45%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 5,190.13 ms(+7.25%)Baseline: 4,839.27 ms | 5,807.13 ms (89.38%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 669.07 ms(+2.00%)Baseline: 655.96 ms | 787.15 ms (85.00%) |
|
| Branch | pr/12697 |
| 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,081.54 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 1,403.19 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 1,432.02 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 3,130.06 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 856.88 ms |
Harden `pacquet setup` beyond pnpm's `@pnpm/os.env.path-extender`, which interpolates the pnpm home directory into the generated shell rc block and the Windows registry without escaping. POSIX: single-quote escape the directory before it is written into the sh-family / fish / nushell rc block, so a value containing `$(...)`, backticks, or `$VAR` cannot execute when the rc file is sourced. Windows: reject a pnpm home directory containing `;`, `%`, or newlines — characters that would split the persisted user `Path` into extra entries or break the `%PNPM_HOME%` indirection — with a dedicated `ERR_PNPM_INVALID_PNPM_HOME` error. `pnpm_home_dir` is resolved only from the user's own environment, so this is defense in depth rather than a cross-boundary fix; the equivalent change should also land in pnpm's path-extender package.
|
Code review by qodo was updated up to the latest commit 1e60108 |
… loud Address review findings on the setup port: - Write the POSIX shell rc block atomically (temp file in the same directory, flushed, then renamed over the target) so a crash or disk-full mid-write leaves the existing rc file intact instead of truncated. - Check command exit status in the Windows path-extender. `reg query`, `chcp`, `setx`, and the cleanup `reg delete` now surface a non-zero exit as an error instead of continuing with empty/invalid output, mirroring pnpm's `safe-execa` (which rejects on non-zero exit). - Build the child `PATH` for the global install as an `OsString`, preserving a non-UTF-8 ambient `PATH` verbatim. - Propagate failure to remove the temporary `@pnpm/exe` package.json instead of swallowing it, while keeping the install error's precedence.
|
Code review by qodo was updated up to the latest commit 1e60108 |
|
Code review by qodo was updated up to the latest commit cecd0a4 |
1 similar comment
|
Code review by qodo was updated up to the latest commit cecd0a4 |
… rc temp write Address two further review findings on the setup port: - Reject a POSIX pnpm home directory containing `:` (the PATH separator), a newline, or NUL before rendering the rc block. Single-quote escaping stops shell expansion but cannot stop a `:` in `$PNPM_HOME/bin` from splitting the colon-delimited PATH into extra entries. The Windows-specific error variant is generalized to `UnsafePnpmHome` and now covers both platforms. - Write the rc file through `pacquet_fs::ensure_file`, the repo's hardened atomic writer, instead of a hand-rolled temp-file writer. It opens a unique sibling temp file with `O_CREAT|O_EXCL`, so setup no longer follows a pre-seeded symlink at a predictable temp path (a local file-overwrite vector) — and reuses existing code rather than duplicating it.
|
Code review by qodo was updated up to the latest commit 78bc072 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 78bc072 |
`setup::handler` ran the global self-install and wrote the alias scripts before the path-extender validated `PNPM_HOME`, so an unsafe value could reach the install subprocess's `PATH` (which resolves external tools like `node` by name) and leave partial state even when setup later errored. Extract a shared `validate_pnpm_home_dir` (POSIX rejects `:` / newlines / NUL; Windows rejects `;` / `%` / newlines) and call it at the very start of the handler, before any side effect. The platform implementations keep their own check as defense in depth.
|
Code review by qodo was updated up to the latest commit 8fe181e |
1 similar comment
|
Code review by qodo was updated up to the latest commit 8fe181e |
Summary
Ports pnpm's
setupcommand to the pacquet (Rust) CLI, makingpnpmavailable for global use. It mirrors
pnpm11/engine/pm/commands/src/setup/setup.tsand the
@pnpm/os.env.path-extenderpackage family that command depends on.What
pacquet setupdoes, matching pnpm:<exe> add -g --ignore-scripts file:<execDir>(writing a temporary@pnpm/exepackage.json when none exists, then removing it).pn/pnpx/pnxalias scripts into$PNPM_HOME/bin(POSIX
shscripts everywhere, plus.cmd/.ps1on Windows).PNPM_HOMEand$PNPM_HOME/bininto the user's environment:the current shell's rc file on POSIX (bash/zsh/ksh/dash/sh/fish/nushell),
or the registry (
reg/chcp/setx) on Windows.Implementation notes:
shell rc-block create/append/skip/modify logic and the Windows
reg queryline parsing use plain string operations rather than adding a
regexdependency.
PnpmErrorcodes (ERR_PNPM_BAD_SHELL_SECTION,ERR_PNPM_BAD_ENV_FOUND,ERR_PNPM_UNKNOWN_SHELL, …), including the--forcehints.path-extender-posixspec cases and cover theWindows registry parser/renderer and the output rendering (26 tests).
No standalone end-to-end test for the full command: the flow always
self-installs via
add -g file:<execDir>, which on a dev build points at thebuild output directory — too heavy/side-effecting for a spawned-binary test.
This matches upstream, whose setup tests also skip the single-executable
branch. The Windows registry path is selected at runtime via
cfg!(windows)(so it compiles on all targets) but is only fully exercisable on Windows.
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.(TypeScript
setupalready exists; this is the pacquet-side port. pnpm isthe source of truth.)
Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit
New Features
setupcommand to configure the CLI for global use.pn,pnx, andpnpxlauncher scripts (with Windows equivalents).PATHpersistently, using shell rc/config blocks on Unix and the Windows user environment registry on Windows.--force/-foption to overwrite existing configuration.Bug Fixes
PNPM_HOME, preventing duplicatePATHentries, and escaping proxy values to avoid unintended shell expansion.