Skip to content

Commit

Permalink
feat: Add rust implementation of Yarn3+ lockfile (#4589)
Browse files Browse the repository at this point in the history
### Description

Adds a new Berry lockfile implementation that correctly handles
[resolutions](https://yarnpkg.com/configuration/manifest/#resolutions).
See the description of #2019 for an overview of the berry lockfile
format.

Note for reviewers:
- I suggest reviewing `identifiers.rs` first as `Ident`, `Descriptor`,
and `Locator` are the building blocks for most of the lockfile logic
- We cannot use `serde_yaml` for serialization as berry expects some
strings to be quoted that are not necessarily required to be quoted by
the YAML spec.
- The underlying lockfile data is passed into the struct that contains
the lockfile logic, this allows us to borrow from the data when building
up the internal data structures. Down the road this could be changed to
use `Pin` if this proves to be painful from an ergonomics perspective


### Testing Instructions

Ported existing unit tests and added new ones for the resolutions logic.
The PR that switches this Rust impl on will include instructions on how
to do e2e testing.

---------

Co-authored-by: Alexander Lyon <arlyon@me.com>
  • Loading branch information
chris-olszewski and arlyon committed Apr 24, 2023
1 parent fd52579 commit 86f0072
Show file tree
Hide file tree
Showing 15 changed files with 8,390 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/turborepo-lockfiles/Cargo.toml
Expand Up @@ -7,6 +7,14 @@ license = "MPL-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
pest = "2.5.6"
pest_derive = "2.5.6"
regex = "1"
semver = "1.0.17"
serde = { version = "1.0.126", features = ["derive"] }
serde_json = "1.0.86"
serde_yaml = "0.9"
thiserror = "1.0.38"

[dev-dependencies]
pretty_assertions = "1.3"

0 comments on commit 86f0072

Please sign in to comment.