Skip to content

fix: read npm-shrinkwrap.json as an npm lockfile - #611

Open
vibgrate-team wants to merge 1 commit into
mainfrom
cursor/npm-shrinkwrap-lockfile-53b0
Open

vibgrate-team wants to merge 1 commit into
mainfrom
cursor/npm-shrinkwrap-lockfile-53b0

Conversation

@vibgrate-team

Copy link
Copy Markdown
Contributor

Summary

loadNpmLockIndex only opened pnpm-lock.yaml, package-lock.json, and yarn.lock, so a project that ships only npm-shrinkwrap.json fell through to registry range guessing. Shrinkwrap is the same JSON as a package-lock, so this change reads it with parsePackageLock / parsePackageLockGraph and with the existing SBOM and pin readers. When both files are present, package-lock.json wins and a truncated package-lock still fails instead of falling through.

Related issues

Closes #605

Checklist

  • pnpm test passes
  • pnpm lint is clean
  • pnpm typecheck is clean
  • Docs updated (README / DOCS / ARCHITECTURE) where behavior changed
  • Determinism preserved — identical input still produces identical graph.json / report output (content-hashed IDs, stable sorts; no time, randomness, or filesystem-order dependence)
  • No proprietary or internal references — public, Apache-2.0 content only
  • Commits use Conventional Commits and are signed off (git commit -s, DCO)

Notes for reviewers

  • Fixture: test/fixtures/npm-shrinkwrap-only/ contains only npm-shrinkwrap.json. Scan and SBOM resolution use the pinned left-pad@1.3.0 and once@1.4.0 entries.
  • Invalid shrinkwrap JSON uses the same lockfile parse error as package-lock.json.
  • DOCS.md lists npm-shrinkwrap.json next to the other npm lockfiles.
Open in Web Open in Cursor 

Projects that only ship npm-shrinkwrap.json fell through to registry
range guessing. Reuse the package-lock parser for that filename, and
prefer package-lock.json when both files are present.

Closes #605

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
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.

Enhancement: treat npm-shrinkwrap.json as an SBOM/scan lockfile like package-lock.json

2 participants