Repository navigation
feat(cli): port set-script command to pacquet - #12618
Conversation
|
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 due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds a Changespacquet set-script command
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 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 |
PR Summary by QodoAdd pacquet Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
Context used✅ Tickets:
🎫 Rust Roadmap 1. Symlink clobber write
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/set_script.rs`:
- Around line 62-66: The save() method in PackageManifest uses
fs::File::create() which truncates the file immediately and can leave
package.json corrupted if the write or serialization fails mid-way. Replace the
file writing logic with an atomic write pattern by writing to a temporary file
first, then atomically renaming it to the target manifest path. Additionally,
the read_from_file() method does not validate that the parsed JSON root is an
object before it is used, though set_script() currently guards against
non-object roots via as_object_mut() check. Either add explicit validation in
read_from_file() to assert the root is a Value::Object, or clearly document this
invariant in the code comments to explain why set_script() relies on the
as_object_mut() guard for safety.
In `@pacquet/crates/cli/tests/set_script.rs`:
- Around line 99-117: Add a new test function to cover the case where pacquet
set-script is invoked with zero extra arguments (no name and no command), which
exercises a different code path in SetScriptArgs::run than the existing
fails_when_arguments_are_missing test. The new test should follow the same
pattern: initialize a CommandTempCwd, call pacquet.with_args with only
["set-script"], verify the command fails, and assert that the stderr contains
the appropriate error code for missing arguments.
🪄 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: b0608ff5-c807-4f86-aa79-91ea448a585c
📒 Files selected for processing (4)
pacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/set_script.rspacquet/crates/cli/src/cli_args/set_script/tests.rspacquet/crates/cli/tests/set_script.rs
|
Code review by qodo was updated up to the latest commit e549efd |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12618 +/- ##
=======================================
Coverage 88.49% 88.50%
=======================================
Files 335 336 +1
Lines 48823 48859 +36
=======================================
+ Hits 43207 43243 +36
Misses 5616 5616 ☔ 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.56229831844,
"stddev": 0.1418653813219754,
"median": 4.548023110339999,
"user": 3.652848060000001,
"system": 3.43228832,
"min": 4.363077522339999,
"max": 4.73078692134,
"times": [
4.72389569234,
4.5686775613399995,
4.73078692134,
4.5273686593399995,
4.7259568203399995,
4.46634627734,
4.436390193339999,
4.66842819034,
4.41205534634,
4.363077522339999
]
},
{
"command": "pacquet@main",
"mean": 4.530635929440001,
"stddev": 0.1385488359690996,
"median": 4.4941869608400005,
"user": 3.7326891599999996,
"system": 3.41959582,
"min": 4.35700035334,
"max": 4.78368675634,
"times": [
4.65834128434,
4.59673199634,
4.49269776334,
4.49567615834,
4.48817156234,
4.42586961934,
4.78368675634,
4.35700035334,
4.36082506134,
4.6473587393399995
]
},
{
"command": "pnpr@HEAD",
"mean": 2.94882781844,
"stddev": 0.12135075863783834,
"median": 2.9079885018400002,
"user": 2.69003006,
"system": 3.01913052,
"min": 2.8021174063400003,
"max": 3.1049728193400004,
"times": [
2.89684611934,
2.8224838983400002,
3.0666954463400002,
2.82648994434,
3.1049728193400004,
3.1013223553400002,
3.05684357434,
2.9191308843400003,
2.89137573634,
2.8021174063400003
]
},
{
"command": "pnpr@main",
"mean": 3.0373678705400002,
"stddev": 0.12171600460890923,
"median": 3.0960110733400006,
"user": 2.73284036,
"system": 3.0274566199999997,
"min": 2.8729445093400003,
"max": 3.2354442973400004,
"times": [
3.2354442973400004,
2.9323595353400003,
3.0875595873400004,
3.11414542934,
2.8729445093400003,
2.9085831693400004,
3.10594487034,
3.1044625593400004,
3.1058164673400004,
2.90641828034
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6383084500400001,
"stddev": 0.01066836219394596,
"median": 0.6395206740400001,
"user": 0.39721641999999996,
"system": 1.3165922799999996,
"min": 0.6185793115400001,
"max": 0.6507856715400001,
"times": [
0.64978569754,
0.6337534085400001,
0.64759504554,
0.62404554154,
0.6376824655400001,
0.6507856715400001,
0.6431704835400001,
0.6413588825400001,
0.63632799254,
0.6185793115400001
]
},
{
"command": "pacquet@main",
"mean": 0.6362741104400002,
"stddev": 0.008936069582235456,
"median": 0.6335017805400001,
"user": 0.40047151999999997,
"system": 1.3039994799999997,
"min": 0.62273901854,
"max": 0.6537815035400001,
"times": [
0.6431593655400001,
0.6320996765400001,
0.6283777705400001,
0.6537815035400001,
0.62273901854,
0.6346164775400001,
0.6419755665400001,
0.63175918854,
0.6323870835400001,
0.6418454535400001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6989595713400001,
"stddev": 0.014725117051366948,
"median": 0.7009563855400001,
"user": 0.41305421999999997,
"system": 1.3419978799999999,
"min": 0.6770729015400001,
"max": 0.7229933295400001,
"times": [
0.6770729015400001,
0.7044333325400001,
0.71100317154,
0.6783363135400001,
0.6910747115400001,
0.6915706435400001,
0.6977980195400001,
0.71119853854,
0.7229933295400001,
0.70411475154
]
},
{
"command": "pnpr@main",
"mean": 0.71417503464,
"stddev": 0.04238857688283934,
"median": 0.7038201220400001,
"user": 0.40175642,
"system": 1.3553849799999997,
"min": 0.6722658825400001,
"max": 0.82624156654,
"times": [
0.69154700554,
0.6883099545400001,
0.72307837354,
0.6722658825400001,
0.6997113085400001,
0.7063626865400001,
0.7012775575400001,
0.82624156654,
0.7250906275400001,
0.7078653835400001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.74972036158,
"stddev": 0.0649042183870086,
"median": 4.75624598658,
"user": 3.7941646799999993,
"system": 3.4066744399999997,
"min": 4.63116063958,
"max": 4.83599318058,
"times": [
4.73336017658,
4.80891165558,
4.77913179658,
4.83599318058,
4.8134788005799996,
4.78380469858,
4.71473781158,
4.70284580558,
4.63116063958,
4.69377905058
]
},
{
"command": "pacquet@main",
"mean": 4.78311660268,
"stddev": 0.050075098369475844,
"median": 4.79606100008,
"user": 3.86907198,
"system": 3.42119004,
"min": 4.71152904958,
"max": 4.85076656958,
"times": [
4.84822162258,
4.71152904958,
4.71918836458,
4.81257777058,
4.760499386579999,
4.796479370579999,
4.85076656958,
4.79564262958,
4.733657904579999,
4.80260335858
]
},
{
"command": "pnpr@HEAD",
"mean": 3.16520853938,
"stddev": 0.08628574603871386,
"median": 3.1759201360800002,
"user": 2.81040768,
"system": 3.1502794399999994,
"min": 3.00537714858,
"max": 3.28348807858,
"times": [
3.23313391158,
3.1088684955800003,
3.10141718658,
3.09672214758,
3.00537714858,
3.28348807858,
3.2211548205800002,
3.18933606058,
3.25008333258,
3.16250421158
]
},
{
"command": "pnpr@main",
"mean": 3.22138819388,
"stddev": 0.11802312907796873,
"median": 3.18114433458,
"user": 2.8721147799999995,
"system": 3.1548648399999997,
"min": 3.0831477835800003,
"max": 3.46363059258,
"times": [
3.13007864358,
3.27275579358,
3.14995720758,
3.46363059258,
3.32523059158,
3.14925210058,
3.2123314615800003,
3.12625805958,
3.0831477835800003,
3.30123970458
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.33571000702,
"stddev": 0.013526309843482732,
"median": 1.3420100215200002,
"user": 1.3259854999999998,
"system": 1.6951599199999996,
"min": 1.30463683052,
"max": 1.3518849745200001,
"times": [
1.3418235765200002,
1.3421964665200001,
1.3423696205200002,
1.33051517852,
1.34426609152,
1.3518849745200001,
1.30463683052,
1.3277075815200001,
1.32774411952,
1.34395563052
]
},
{
"command": "pacquet@main",
"mean": 1.37577342442,
"stddev": 0.0844377433389386,
"median": 1.3502418980200002,
"user": 1.3365293999999999,
"system": 1.7054184199999998,
"min": 1.32513275552,
"max": 1.61254877752,
"times": [
1.35161489052,
1.37406487652,
1.61254877752,
1.35109998552,
1.34371345552,
1.37066684152,
1.3394826205200001,
1.3400262305200001,
1.34938381052,
1.32513275552
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4165983158200002,
"stddev": 0.037146910091908986,
"median": 1.40784836852,
"user": 0.6129396,
"system": 1.5533675199999997,
"min": 1.38168650552,
"max": 1.5164282205200001,
"times": [
1.4087357015200002,
1.41002142552,
1.4031427735200002,
1.5164282205200001,
1.3929745345200002,
1.41979316852,
1.40696103552,
1.40165913552,
1.4245806575200002,
1.38168650552
]
},
{
"command": "pnpr@main",
"mean": 1.4197626678200002,
"stddev": 0.060114094369272876,
"median": 1.3992717890200002,
"user": 0.5991617999999999,
"system": 1.56382032,
"min": 1.38495026252,
"max": 1.58644925552,
"times": [
1.4286391975200001,
1.58644925552,
1.41613810452,
1.38795936352,
1.39530259652,
1.38495026252,
1.4088644355200002,
1.3913777255200002,
1.40324098152,
1.39470475552
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0203994687,
"stddev": 0.03804623749724153,
"median": 3.0119880483999997,
"user": 1.7904553800000003,
"system": 1.9380703999999997,
"min": 2.9866931438999997,
"max": 3.1162486099,
"times": [
2.9903051149,
3.0144596138999997,
2.9993487629,
2.9866931438999997,
3.0257294739,
3.0206660369,
3.0447360458999997,
2.9962914018999998,
3.1162486099,
3.0095164828999996
]
},
{
"command": "pacquet@main",
"mean": 3.0674776962,
"stddev": 0.05312754192078872,
"median": 3.0549300098999996,
"user": 1.80630618,
"system": 2.0125701,
"min": 3.0014314099,
"max": 3.2060981759,
"times": [
3.0625396139,
3.0401662258999997,
3.0849055589,
3.0550963179,
3.0539538219,
3.0519882098999997,
3.0014314099,
3.0547637019,
3.2060981759,
3.0638339259
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4060841628,
"stddev": 0.019780308701746917,
"median": 1.4040937359,
"user": 0.60602108,
"system": 1.5660829999999997,
"min": 1.3754063509,
"max": 1.4460607779,
"times": [
1.4460607779,
1.4187432759,
1.4065989489000001,
1.4244484139000002,
1.3926380179000002,
1.4058986929000001,
1.3916339529000001,
1.4022887789,
1.3754063509,
1.3971244179
]
},
{
"command": "pnpr@main",
"mean": 1.4305174268000003,
"stddev": 0.0639146563099218,
"median": 1.4098523324,
"user": 0.60670778,
"system": 1.5686136999999998,
"min": 1.3930790339,
"max": 1.6091655999,
"times": [
1.4310638839,
1.4109470129000001,
1.6091655999,
1.3950599489,
1.4220758269,
1.4087576519,
1.3930790339,
1.4051194639,
1.4067644659,
1.4231413799000001
]
}
]
} |
|
| Branch | pr/12618 |
| 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,749.72 ms(+2.18%)Baseline: 4,648.39 ms | 5,578.07 ms (85.15%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 3,020.40 ms(-0.83%)Baseline: 3,045.68 ms | 3,654.81 ms (82.64%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,335.71 ms(-1.15%)Baseline: 1,351.28 ms | 1,621.53 ms (82.37%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,562.30 ms(+1.37%)Baseline: 4,500.85 ms | 5,401.02 ms (84.47%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 638.31 ms(+1.60%)Baseline: 628.27 ms | 753.93 ms (84.66%) |
|
| Branch | pr/12618 |
| 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,165.21 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 1,406.08 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 1,416.60 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,948.83 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 698.96 ms |
|
Code review by qodo was updated up to the latest commit 9763b07 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 9763b07 |
9763b07 to
f7c6ad9
Compare
|
Code review by qodo was updated up to the latest commit f7c6ad9 |
1 similar comment
|
Code review by qodo was updated up to the latest commit f7c6ad9 |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Summary
Ports the
set-script/sscommand from the TypeScript pnpm CLI to the Rustpacquetport. It writes ascriptsentry into the project'spackage.json, mirroringpnpm11/pkg-manifest/commands/src/setScript.ts.Part of the Rust Roadmap — related to #11633.
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Summary by CodeRabbit
Release Notes
New Features
set-script(aliasss) to create or updatescriptsentries inpackage.jsonscriptswhen missing and replaces it when it’s not an object=)Bug Fixes
Security/Validation
__proto__,constructor, andprototypeTests