Skip to content

feat(scripts): add yarn-lockfile-surgeon for minimum-version lockfile bumps#4638

Open
jonkoops wants to merge 1 commit intoredhat-developer:mainfrom
jonkoops:add-yarn-lockfile-surgeon
Open

feat(scripts): add yarn-lockfile-surgeon for minimum-version lockfile bumps#4638
jonkoops wants to merge 1 commit intoredhat-developer:mainfrom
jonkoops:add-yarn-lockfile-surgeon

Conversation

@jonkoops
Copy link
Copy Markdown
Contributor

@jonkoops jonkoops commented Apr 20, 2026

yarn-lockfile-surgeon is a CLI tool for surgically bumping packages in Yarn Berry lockfiles. Unlike yarn up, which resolves dependency ranges to the latest matching version, this tool resolves to the minimum satisfying version — keeping lockfile diffs as small as possible when applying security patches on LTS branches.

The tool uses Yarn's own @yarnpkg/parsers and @yarnpkg/core to parse, manipulate, and serialize the lockfile. It walks transitive dependencies, adding new entries only when existing lockfile resolutions don't satisfy the updated ranges. Range aliases are collected to prevent yarn install from re-resolving covered ranges.

@openshift-ci openshift-ci Bot requested review from josephca and kadel April 20, 2026 10:47
@github-actions
Copy link
Copy Markdown
Contributor

Image was built and published successfully. It is available at:

@github-actions
Copy link
Copy Markdown
Contributor

Image was built and published successfully. It is available at:

@polasudo
Copy link
Copy Markdown
Member

Nice One, but one thing I think is missing is the printout (conslo log or something) which would look like this "old version → new version" for each bumped package. The old version is right there in the lockfile
entry before it gets deleted, but it's never printed. I would like to see something like this eg: "@scope/pkg: 1.0.0 → 1.2.0" it would make it much easier to see what actually changed at 1st sight. Right now I would just need to run it and then go in and take a look if it changed everything it should.

@jonkoops jonkoops force-pushed the add-yarn-lockfile-surgeon branch 2 times, most recently from e62b61c to e7501d2 Compare April 20, 2026 15:00
@jonkoops
Copy link
Copy Markdown
Contributor Author

@polasudo Done, I added a bit nicer output so it is easier to see what the script does 👍

@github-actions
Copy link
Copy Markdown
Contributor

The container image build workflow finished with status: cancelled.

… bumps

Adds a CLI tool that surgically bumps packages in Yarn Berry lockfiles
to their minimum satisfying versions, unlike `yarn up` which resolves
to the latest. Useful for applying security patches on LTS branches
with minimal lockfile impact.
@jonkoops jonkoops force-pushed the add-yarn-lockfile-surgeon branch from e7501d2 to b560264 Compare April 20, 2026 15:03
@github-actions
Copy link
Copy Markdown
Contributor

The container image build workflow finished with status: cancelled.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 20, 2026

Quality Gate Passed Quality Gate passed

Issues
0 New issues
8 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Comment on lines +120 to +122
const lock = parseSyml(
readFileSync(lockfilePath, "utf-8"),
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add here some consolle log if there is something wrong with the path ?

@github-actions
Copy link
Copy Markdown
Contributor

Image was built and published successfully. It is available at:

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