🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

fix(autodiscovery/npm): keep exact dependency versions exact - #11288

Merged
olblak merged 2 commits into
updatecli:mainfrom
olblak:fix/npm-save-exact
Nov 13, 2026
Merged

olblak merged 2 commits into
updatecli:mainfrom
olblak:fix/npm-save-exact

Conversation

@olblak

@olblak olblak commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

The lock file targets update a dependency with "npm install", "pnpm add" or "yarn add", which save the new version with the package manager default range prefix. A dependency pinned to "2.1.2" was therefore updated to "^2.1.3", loosening the pin.

Pass --save-exact (npm, pnpm) or --exact (yarn) when the package.json version is a strict semantic version, so a pinned dependency stays pinned. Version ranges are unchanged.

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/autodiscovery/npm/
go test

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.
  • I have tested this pull request manually with a custom Updatecli build and it works as expected.

Tradeoff

Potential improvement

Summary by CodeRabbit

  • Bug Fixes
    • Commands generated for dependencies pinned to an exact semantic version now preserve that exact version when adding or updating packages with npm, Yarn, and pnpm.
    • Commands for version ranges continue to use range-based behavior.

The lock file targets update a dependency with "npm install", "pnpm add"
or "yarn add", which save the new version with the package manager
default range prefix. A dependency pinned to "2.1.2" was therefore
updated to "^2.1.3", loosening the pin.

Pass --save-exact (npm, pnpm) or --exact (yarn) when the package.json
version is a strict semantic version, so a pinned dependency stays
pinned. Version ranges are unchanged.

Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added autodiscovery All things related to the autodiscovery feature resource-npm labels Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5441ff97-0b09-4930-b2c8-c2b8c5b7410d
Commits

Reviewing files that changed from the base of the PR and between 306b1c8 and a8676e2.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Dependency discovery now checks whether each version is a strict semantic version and passes that status to the npm, Yarn, and pnpm command builders. Exact versions add the package manager’s exact-version flag; range commands retain their prior flags.

Changes: npm exact-version command generation

Layer / File(s) Summary
Detect exact versions and build commands
pkg/plugins/autodiscovery/npm/utils.go, pkg/plugins/autodiscovery/npm/utils_test.go
isExactVersion returns true when strict semantic-version parsing succeeds. Command builders add --save-exact for npm and pnpm, and --exact for Yarn, when the version is exact. Tests cover exact versions and ranges.
Pass exactness through dependency discovery
pkg/plugins/autodiscovery/npm/dependency.go, pkg/plugins/autodiscovery/npm/main_test.go
Dependency discovery passes the exact-version status to the npm, Yarn, and pnpm command builders. The pnpm test expectation includes --save-exact.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: loispostula

Merge Risk: Minimal · previous review 306b1

Pinned npm dependency versions now stay pinned when lock files are updated, and ranges are left unchanged. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: npm, pnpm, and yarn lock-file updates now keep exact dependency versions exact, using --save-exact or --exact. The title matches the changeset summary, which adds an e…
Description check Passed The description follows the repository template. It explains the problem (default range prefixes loosen pinned versions) and the fix (--save-exact or --exact for strict semantic versions, ranges uncha…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: npm, pnpm, and yarn lock-file updates now keep exact dependency versions exact, using --save-exact or --exact. The title matches the changeset summary, which adds an exact-version flag to getTargetCommand and an isExactVersion helper.

Full details: Description check

Explanation

The description follows the repository template. It explains the problem (default range prefixes loosen pinned versions) and the fix (--save-exact or --exact for strict semantic versions, ranges unchanged). It keeps the Fix #XXX line, the Test section with the correct go test directory, and the Checklist, Tradeoff, and Potential improvement sections. The 'Fix #XXX' placeholder still needs a real issue number. The checklist items are unchecked, and the description does not state whether manual testing was done. The Tradeoff and Potential improvement sections keep their template placeholder comments and have no content.

Resolution

Replace the 'Fix #XXX' placeholder with the linked issue number. Add or remove the optional Tradeoff and Potential improvement content. Mark the checklist items that apply, and state whether manual testing was done.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 154f4fda-e55c-498e-abd4-825623bbca3b
Commits

Reviewing files that changed from the base of the PR and between cfc0074 and 306b1c8.

Files selected for processing: 4

  • pkg/plugins/autodiscovery/npm/dependency.go
  • pkg/plugins/autodiscovery/npm/main_test.go
  • pkg/plugins/autodiscovery/npm/utils.go
  • pkg/plugins/autodiscovery/npm/utils_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@olblak
olblak enabled auto-merge (squash) November 13, 2026 20:47
@olblak olblak added the bug Something isn't working label Nov 13, 2026
@olblak
olblak merged commit a7da53c into updatecli:main Nov 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autodiscovery All things related to the autodiscovery feature bug Something isn't working resource-npm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant