-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for yarn-berry lockfiles #28
Conversation
Been a whike since i looked into berry, but yes i think it can be solved to some degree with config instead, although at potentially higher maintenance cost. Btw, have you looked into this package that seems to support both formats? https://www.npmjs.com/package/@yarnpkg/parsers |
That works even better, good idea! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth mentioning in README that it supports berry maybe?
|
||
it('should parse a yarn berry descriptor with scope', () => { | ||
expect(parseYarnDescriptor('@snel/[email protected]')).toEqual({ | ||
packageName: '@snel/hest', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
* @param {string} descriptor - The yarn berry descriptor to parse. | ||
* @returns {ParsedDescriptor} The parsed descriptor. | ||
*/ | ||
function parseYarnDescriptor(descriptor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function parseYarnDescriptor(descriptor) { | |
function parseBerryDescriptor(descriptor) { |
Maybe? I was worried this regex would slow down non-berry users at first glance. Speaking of that, how's the perf with a large berry workspace like yours?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance looks good. Only adds ~4% increase in time in a large project
Before PR:
Time (mean ± σ): 4.028 s ± 0.101 s [User: 3.634 s, System: 0.342 s]
Range (min … max): 3.935 s … 4.207 s 10 runs
After PR:
Time (mean ± σ): 4.121 s ± 0.152 s [User: 3.748 s, System: 0.328 s]
Range (min … max): 3.975 s … 4.453 s 10 runs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the suggestion, this function parses both yarn v1 and berry descriptors. At the time of calling it we don't know which version of yarn lockfile we are parsing. Unless of course we interpret the "metadata" value in the parse result, but that's a bit messy.
I can clarify that this parses both descriptors in the JSDoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, makes sense!
Co-authored-by: Joel Arvidsson <[email protected]>
@mikeduminy Need to update lock file too. |
@oblador done! |
Added support for parsing yarn-berry lockfiles (they are pure yaml).
We can no longer look up dependencies by
package@version
because berry adds additional things like a protocol (e.g.package@protocol:version
), so there's now a regex (with tests) that strips out the protocol.An argument could be made that this should be a separate command, like npm and yarn. Let me know what feels best.
Also, maybe this could be a berry plugin? I'm not sure what the capabilities are.