Add enumerator for yarn berry versions #423
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #419
This PR adds basic support for yarn v2+ with the
node-modules
linker strategy that expects that package archives have already been expanded to folders undernode_modules
. Support for PnP or other strategies can be added as future iterations.The majority change in this PR is figuring out a strategy for having multiple implementations on a single source type and then migrating the existing yarn source to match the new pattern. To accomplish this I've created a new
full_type
method that's used by all of the tooling and infrastructure in the repo for things like running tests using shorthand commands likescript/test ...
. Thefull_type
method will return both the external source type, which remains unchanged as well as the version - e.g. both yarn sources in this implementation havetype == "yarn"
, but have differentfull_type
values ofyarn/v1
andyarn/berry
.The distinction between internal and external identifiers is to allow continuity for end users - migrating from yarn v1 to v2 shouldn't result in an entirely separate cache if the dependencies themselves (as reported by yarn) haven't changed.
Each source enumerator implementation continues to determine if it can run via the
enabled?
method. The two implementations have mutually exclusive version requirements so that only one will run in a given environment.The yarn berry version implementation is pretty straightforward, it's simpler than the v1 implementation due to the changes in the CLI that make data gathering easier. To note though, it doesn't look like the berry implementation supports limiting the output to non-dev dependencies which is a change from v1 and could result in significantly more license files being created. I'm not sure a way around this at the moment.
I've added some new documentation that explains at a high level how to migrate from having a single source enumerator implementation to having multiple.