feat(repository): Expose flat lockfile package list for metrics (#13859)
Add `Workspace.lockfilePackages()` to `@turbo/repository`, returning the
external packages referenced by a workspace's lockfile as a flat,
sorted,
deduplicated list of `{ name, version }` structs plus any reasons the
lockfile could not be fully parsed.
Unlike the existing `packagesFromLockfile()` (which returns
`npm/<name>@<version>` strings and throws when no lockfile is found),
this
method:
- returns structured `{ name, version }` entries
- strips pnpm peer-dependency closures so `${name}@${version}` is always
a
plain `pkg@1.2.3` identity, never `pkg@1.2.3(other@4.5.6)`
- never throws: a missing or unparseable lockfile yields empty
`packages`
and a populated `errors` list, so callers can emit metrics on both
success and failure
Parse-failure reasons are surfaced from the JavaScript external
resolution
domain via a new `PackageGraph::javascript_external_resolution()`
accessor
that distinguishes a resolved (possibly empty) listing from an
unavailable
one carrying a machine-readable reason code and message.
Also expose the declared package manager version on
`Workspace.packageManager.version`, read from the root package.json
`packageManager` field or `devEngines.packageManager.version`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4aXLMDTSWLPEzFbdvMz22
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>