Skip to content

feat(cli): oa check reads pnpm-lock.yaml and yarn.lock - #484

Merged
M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:feat/lockfile-pnpm-yarn
Nov 14, 2026
Merged

M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:feat/lockfile-pnpm-yarn

Conversation

@orcamedia

Copy link
Copy Markdown
Contributor

oa check now reads pnpm-lock.yaml and yarn.lock, checked against an npm repository like package-lock.json (with --fetch and the REQUIRED BY column).

Formats

  • pnpm-lock.yaml, lockfile versions 5.4 (pnpm 7), 6.0 (pnpm 8) and 9.0 (pnpm 9 and 10). Versions 5 and 6 carry a dev flag per package. Version 9 does not, so a package is development-only when the importers' dependencies and optionalDependencies do not reach it through snapshots. 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.
  • yarn.lock, Yarn 1 (its own line format) and Yarn 2 and later (YAML, recognised by __metadata). Only npm: resolutions count; workspace, patch, git, file, link and portal resolutions are skipped, and workspaces are not counted as requirers.

--no-dev and yarn.lock

yarn.lock does not record which dependencies are development-only. Rather than silently checking everything, oa check --no-dev refuses a yarn.lock with an error saying so. Reading package.json to 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 to acme-* (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, so acme-react has no requirer there.

  • Fuzz targets FuzzPnpmLock and FuzzYarnLock; a minute of each locally found nothing.
  • TestCheckJSLockfiles runs both fixtures through oa check --fetch: one packument request per distinct package.
  • Error cases for malformed YAML and yarn input.

make lint, make deadcode, the race tests of internal/oacli and pkg/lockfile, and the oa import-graph test pass; go.yaml.in/yaml/v3 was already on the oa allowlist.

🤖 Generated with Claude Code

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]>
@M0Rf30
M0Rf30 merged commit 8c2f6e7 into openartifact:main Nov 14, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants