fix: Make turbo prune resolve Yarn dependencies whose lockfile reference carries params (#15107)
A Yarn Berry lockfile records `link:`, `portal:` and `file:`
dependencies with a `::locator=<workspace>` params suffix, and a patched
dependency adds `::version=..&hash=..`. The manifest declares the same
dependency without any of that, so `turbo prune` could not match a
workspace's dependency edge to its lockfile entry and stopped with
`Unable to find any locator for repo-utils@link:./scripts/repo-utils`.
Pruning now falls back to the entry whose reference matches once those
params are dropped, and writes that entry back exactly as Yarn had it,
so a frozen install of the pruned repo accepts the lockfile unchanged. A
`patch:` dependency declared directly by a workspace failed the same way
and is covered by the same fallback.
Fixes #15094
<details><summary>Validation and details</summary>
### Validation
- `cargo build -p turbo --profile dev` passed.
- `cargo check -p turbo` passed.
- `cargo check -p turborepo-lockfiles` passed.
- `cargo clippy -p turborepo-lockfiles --all-targets` passed with no
warnings.
- `cargo test -p turborepo-lockfiles` passed, 373 tests, including the
new `berry::test::test_prune_with_link_dependency`.
- `cargo test -p turborepo-prune` passed, 33 tests.
- `cargo test -p turborepo-lockfile-hash` passed.
- `cargo fmt -p turborepo-lockfiles -- --check` passed.
- End to end: `turbo prune a` on the reproduction now finishes,
`out/yarn.lock` is identical to the repository's `yarn.lock`, and `yarn
install --immutable` in the pruned output succeeds once the link target
directory is present, which `turbo prune` does not copy.
### Details
Exact descriptor lookups still run first and unchanged, so nothing about
plain `npm:` entries moves. Only a lookup that misses retries against an
index built while loading the lockfile, from each reference truncated at
its first `::` to the entry that carries the params. Where two entries
differ only by params, which happens when two workspaces declare the
same `file:` dependency, the first in lockfile key order wins.
Reproduced on `main` with the reporter's repository: the command exited
1 with the reported error. The new test fails without the change with
`MissingLocator(Descriptor { ident: Ident { scope: None, name:
"repo-utils" }, range: "link:./scripts/repo-utils" })`. A synthetic root
`file:` dependency produced the equivalent lockfile entry
(`local-lib@file:./vendor/local-lib#./vendor/local-lib::hash=0d368e&locator=filedep%40workspace%3A.`)
and now prunes as well.
Building `turbo` here needed `protobuf-compiler`, `capnproto` and Zig
0.17.0 alongside the toolchain in `rust-toolchain.toml`; the Rust checks
above run against that toolchain.
</details>
---------
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>