Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/native_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,21 @@ def self.run_pnpm_audit_fix_command
sig { params(dependency_name: String, recursive: T::Boolean).returns(String) }
def self.run_pnpm_deep_update_command(dependency_name, recursive: false)
# `pnpm update --depth Infinity <dep>` traverses the full dependency
# graph, allowing transitive dependencies to be updated in the lockfile
# without modifying any package.json (unlike `pnpm audit --fix`).
# `-r --include-workspace-root` is required for workspace repos so the
# update is applied across all packages.
# graph so transitive dependencies can be updated in the lockfile.
# `--no-save` is required: without it, pnpm rewrites caret ranges in
# `package.json` and the matching `specifier:` lines in
# `pnpm-lock.yaml` to `^<currently-resolved-version>` for every
# direct dependency whose resolved version is newer than its
# declared range floor. Dependabot only returns the lockfile from
# this flow, so those package.json mutations are discarded while
# the lockfile keeps `specifier:` entries that no longer match the
# manifest, which a downstream frozen-lockfile install rejects.
# `-r --include-workspace-root` is required for workspace repos so
# the update is applied across all packages.
flags = recursive ? "-r --include-workspace-root " : ""
Helpers.run_pnpm_command(
"#{flags}update #{dependency_name} --depth Infinity --lockfile-only",
fingerprint: "#{flags}update <dependency_name> --depth Infinity --lockfile-only"
"#{flags}update #{dependency_name} --depth Infinity --lockfile-only --no-save",
fingerprint: "#{flags}update <dependency_name> --depth Infinity --lockfile-only --no-save"
Comment on lines +88 to +89
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

--no-save is already used by dependabot-core on the primary pnpm update path in three places:

  • file_updater/pnpm_lockfile_updater.rb:192 (run_pnpm_update_packages)
  • update_checker/subdependency_version_resolver.rb:256 (pnpm_update_command when a target version is known)

All ship the same --no-save flag. The flag is supported on pnpm 7-10 (the versions the npm_and_yarn ecosystem documents support for); this PR brings the deep-update fallback in line with what the primary path already does, no new minimum-version requirement is introduced.

)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,9 @@
.ordered
expect(Dependabot::NpmAndYarn::Helpers).to receive(:run_pnpm_command)
.with(
"-r --include-workspace-root update prettier --depth Infinity --lockfile-only",
{ fingerprint: "-r --include-workspace-root update <dependency_name> --depth Infinity --lockfile-only" }
"-r --include-workspace-root update prettier --depth Infinity --lockfile-only --no-save",
{ fingerprint: "-r --include-workspace-root update <dependency_name> " \
"--depth Infinity --lockfile-only --no-save" }
)
.ordered
.and_return("")
Expand Down
Loading