Repository navigation
feat(cli): oa check reads pnpm-lock.yaml and yarn.lock - #484
Merged
Merged
Conversation
pkg/lockfile gains two parsers, checked against npm repositories like package-lock.json: - pnpm-lock.yaml of lockfile versions 5.4 (pnpm 7), 6.0 (pnpm 8) and 9.0 (pnpm 9 and 10). Versions 5 and 6 mark development-only packages; for version 9, which does not, a package is development-only when the importers' dependencies and optional dependencies do not reach it through the snapshots. Git, directory and tarball-URL packages and links are left out; peer suffixes are stripped; aliases resolve to the package they install. - yarn.lock of Yarn 1 (its own line format) and Yarn 2+ (YAML, recognised by __metadata). Only npm-protocol resolutions count: workspaces, patches, git, file, link and portal are not served by a registry, and workspaces are not requirers. yarn.lock records no development dependencies, so oa check refuses --no-dev for it instead of silently checking everything. The fixtures are real lockfiles of one project (direct, transitive, dev, peer, alias, scoped, GitHub and file: dependencies) generated by npm, pnpm 7, 8 and 9, Yarn 1 and Yarn 4, with the package names renamed to acme-*. All six parse to the same packages; the pnpm ones to the same dev flags as npm. Fuzz targets for both formats. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
oa checknow readspnpm-lock.yamlandyarn.lock, checked against an npm repository likepackage-lock.json(with--fetchand the REQUIRED BY column).Formats
devflag per package. Version 9 does not, so a package is development-only when the importers'dependenciesandoptionalDependenciesdo not reach it throughsnapshots. Git, directory and tarball-URL packages and links are left out, peer suffixes (([email protected]),[email protected]) are stripped, and aliases resolve to the package they install.__metadata). Onlynpm:resolutions count; workspace, patch, git, file, link and portal resolutions are skipped, and workspaces are not counted as requirers.--no-devand yarn.lockyarn.lockdoes not record which dependencies are development-only. Rather than silently checking everything,oa check --no-devrefuses ayarn.lockwith an error saying so. Readingpackage.jsonto work it out would be possible, but it's a separate change; I'd rather ask first.Tests
The fixtures are real lockfiles of one small project, generated by npm, pnpm 7, 8 and 9, Yarn 1 and Yarn 4. The project has direct, transitive, dev-only, peer, aliased, scoped, GitHub and
file:dependencies, and the package names are renamed toacme-*(Trivy flagged real names before). All six files parse to the same 13 packages; the three pnpm files also give the same dev flags as npm. The only difference: Yarn 1 doesn't record peer dependencies, soacme-reacthas no requirer there.FuzzPnpmLockandFuzzYarnLock; a minute of each locally found nothing.TestCheckJSLockfilesruns both fixtures throughoa check --fetch: one packument request per distinct package.make lint,make deadcode, the race tests ofinternal/oacliandpkg/lockfile, and theoaimport-graph test pass;go.yaml.in/yaml/v3was already on theoaallowlist.🤖 Generated with Claude Code