Skip to content
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 enumerator for yarn berry versions #423

Merged
merged 6 commits into from
Nov 29, 2021
Merged

Add enumerator for yarn berry versions #423

merged 6 commits into from
Nov 29, 2021

Conversation

jonabc
Copy link
Contributor

@jonabc jonabc commented Nov 27, 2021

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 under node_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 like script/test .... The full_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 have type == "yarn", but have different full_type values of yarn/v1 and yarn/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.

these changes enable sources to have different
implementations for breaking changes between
versions, e.g. if the CLI changes

implementations for a source are expected to be
mutually exclusive and never overlap.  checks
need to be added to `#enabled?` to ensure that
only one implementation will run per `licensed`
tool execution
@jonabc jonabc mentioned this pull request Nov 27, 2021
@jonabc jonabc merged commit 5519dcb into master Nov 29, 2021
@jonabc jonabc deleted the yarn-berry branch November 29, 2021 14:56
jonabc added a commit that referenced this pull request Dec 14, 2021
## 3.4.0

2021-12-14

### Added

- New Yarn enumerator with support for berry versions (#423)

### Fixed

- Error handling cases return correct values in the Yarn enumerator (#425)
- Fixed link in command documentation (:tada: @chibicco #416)
- Fixed minor backwards compatibility issue for Ruby 2.3 support (:tada: @dzunk #414)

### Changed

- Licensed's own dependencies are cached in the repository and kept up to date with GitHub Actions (#421)
@jonabc jonabc mentioned this pull request Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

yarn: Support 2/3 (berry)
1 participant