unjs / nypm

🌈 Unified Package Manager for Node.js and Bun
MIT License
474 stars 17 forks source link

feat!: refactor detection to support multi versions #42

Closed Intevel closed 1 year ago

Intevel commented 1 year ago

This PR is a bit of a breaking change, but one that makes sense in my eyes.

Before we had a very simple structure, the package manager name was also the command, for a lock file there was an extra type. However, this causes problems if you want to provide support for multiple Package Manager versions, as an example yarn berry but also pnpm 6.

Because I can't just add "yarn" or "pnpm" to the package manager array again.


With this PR everything is brought together, there is an array with the Package Manager objects which contain the name, the version, the command and a lockFile.

12

After this PR we can also solve #11, and we can add similiar situations with package Manager versions more easier in the future.

codecov[bot] commented 1 year ago

Codecov Report

Merging #42 (5c7c666) into main (6db58c4) will decrease coverage by 1.46%. The diff coverage is 93.54%.

:exclamation: Current head 5c7c666 differs from pull request most recent head 6120ab6. Consider uploading reports for the commit 6120ab6 to get more accurate results

@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
- Coverage   97.32%   95.86%   -1.46%     
==========================================
  Files           5        5              
  Lines         112      121       +9     
  Branches       29       31       +2     
==========================================
+ Hits          109      116       +7     
- Misses          3        5       +2     
Impacted Files Coverage Δ
src/detect.ts 94.64% <88.88%> (-3.51%) :arrow_down:
src/api.ts 100.00% <100.00%> (ø)
src/types.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

pi0 commented 1 year ago

Thanks for working on this PR @Intevel and sorry for delay i needed a moment to check it locally.

I love the overall direction. Have added few refactors, to generalize idea of supporting same package manager with multiple versions. For yarn, we have two detectors for instance now.