fix(cli): support pnpm 12 multi-document lockfiles [RED-939] [ship] - #1476
Merged
Merged
Conversation
pnpm 12 writes pnpm-lock.yaml as two YAML documents when package.json pins a packageManager: a leading environment document that records pnpm's own dependencies, then the application document. The `yaml` package rejects multi-document input, so every consumer needs the application document on its own. Add splitPnpmLockfileDocuments and joinPnpmLockfileDocuments, which mirror pnpm's own textual reader (leading `---` marks an environment document up to the next `---`), with a spec and a lockfile generated by pnpm 12.3.4 as a fixture. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pnpm 12 writes pnpm-lock.yaml as two YAML documents when package.json pins a packageManager: an environment document for pnpm itself, then the application document. Every consumer parsed the file as a single document, which the `yaml` package rejects, so on such a lockfile Playwright version detection silently fell back to node_modules, lockfile pruning was skipped, patched-dependency filtering became a no-op, and `bundle.packages.embed` failed with a fatal diagnostic. Parse only the application document at each site, and keep the environment document verbatim when the lockfile is rewritten after a prune. pnpm-workspace.yaml keeps going through the single-document rewrite, because a leading `---` there is an ordinary document-start marker rather than a separate document. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…D-939] The fixture is asserted to round-trip byte for byte through the document splitter, which normalizes CRLF to LF. Git's autocrlf on the Windows runner checked it out with CRLF, so the assertion could never hold there. Pin the fixture directory with `-text`, as the repo already does for patch files. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Linear: RED-939
pnpm 12 writes
pnpm-lock.yamlas two YAML documents whenpackage.jsonpins apackageManager: a leading environment document that records pnpm's own dependencies, then the application document. Every pnpm lockfile consumer in the CLI parsed the file as a single document, which theyamlpackage rejects withSource contains multiple documents. On such a lockfile:node_modulesinstead of the lockfile.bundle.packages.embedfailed with a fatal "Unsatisfied local prerequisites" diagnostic.The same bug in the Terraform provider was fixed in checkly/terraform-provider-checkly#393 (v1.29.0).
Changes
splitPnpmLockfileDocuments/joinPnpmLockfileDocumentshelper that mirrors pnpm's own textual reader: a leading---introduces an environment document up to the next---; everything after it is the application document.parsePnpmLockfileVersion,parsePnpmLockfilePackages, the pruner'sparseLockfileSnapshot, andreadLockfilePatchHashesnow parse only the application document.rewriteLockfileSection, which edits the application document and carries the environment document over verbatim so pnpm still finds it in the bundle.pnpm-workspace.yamlkeeps using the single-documentrewriteYamlSection, since a leading---there is an ordinary document-start marker.Affected Components
Notes for the Reviewer
checkly debug parse-projecton a pnpm 12 workspace: the Playwright version resolves from the lockfile, the bundled lockfile is pruned and still starts with the environment document, and embedded packages materialize with no diagnostic.-textin.gitattributes(like*.patchalready is), because the byte-for-byte round-trip cannot hold on an autocrlf checkout on Windows.pnpmauto-switching to the pinned version rather than honouringpackageManageritself.🤖 Generated with Claude Code