Skip to content

(nodejs plugin) add support for automatically shimming package managers with corepack enable#1118

Merged
jdx merged 7 commits intojdx:mainfrom
jasisk:js/feat/corepack-enable
Dec 8, 2023
Merged

(nodejs plugin) add support for automatically shimming package managers with corepack enable#1118
jdx merged 7 commits intojdx:mainfrom
jasisk:js/feat/corepack-enable

Conversation

@jasisk
Copy link
Copy Markdown
Contributor

@jasisk jasisk commented Dec 8, 2023

This is more to convey an idea than anything else—I'm not a rusty kind of person.

I use corepack—which has shipped with node since v14 and v16—since I bounce between a bunch of different nodejs codebases that use different package managers. Love rtx but I have to remember to reenable corepack every time I install a new version.

So this is my attempt at running corepack enable automatically after installing a new node version.

What do you think? Figured this might convey what I was thinking better than opening a discussion not necessarily because I think this code should be merged. 😄

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 8, 2023

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (40c7e82) 87.21% compared to head (a5eae18) 80.32%.
Report is 1 commits behind head on main.

Files Patch % Lines
src/plugins/core/node.rs 9.52% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1118      +/-   ##
==========================================
- Coverage   87.21%   80.32%   -6.90%     
==========================================
  Files         137      137              
  Lines       12593    12615      +22     
==========================================
- Hits        10983    10133     -850     
- Misses       1610     2482     +872     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

self.install_npm_shim(&ctx.tv)?;
self.test_npm(ctx.config, &ctx.tv, &ctx.pr)?;
self.install_default_packages(ctx.config, &ctx.tv, &ctx.pr)?;
if *env::RTX_NODE_COREPACK_ENABLE && self.corepack_path(&ctx.tv).exists() {
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.

I think we should check the version and if it's before corepack was released (not sure when that was) we should not try to enable it even if they set this to true

Copy link
Copy Markdown
Contributor Author

@jasisk jasisk Dec 8, 2023

Choose a reason for hiding this comment

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

Sounds good. It was introduced in two minors—v14.19.0 and v16.9.0—so I'll add a method to compare with versions that ship with corepack. Recommend I leave the exists() check in place even with the version check?

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.

oh sorry I didn't notice that, I think that check is sufficient

@jdx
Copy link
Copy Markdown
Owner

jdx commented Dec 8, 2023

in general looks good

@jdx jdx merged commit f0c1b8f into jdx:main Dec 8, 2023
@jasisk jasisk deleted the js/feat/corepack-enable branch December 8, 2023 17:48
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.

2 participants