Skip to content

Commit

Permalink
Add catalog check to pnpm_lock_changed (dependabot#11466)
Browse files Browse the repository at this point in the history
* add catalog check to pnpm_lock_changed

* fixing tests
  • Loading branch information
robaiken authored Feb 3, 2025
1 parent d08754e commit fa20d49
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
8 changes: 4 additions & 4 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def update_pnpm_workspace_and_locks
def update_pnpm_locks(is_catalog: false)
updated_files = []
pnpm_locks.each do |pnpm_lock|
next unless pnpm_lock_changed?(pnpm_lock)
next unless pnpm_lock_changed?(pnpm_lock, is_catalog: is_catalog)

updated_files << updated_file(
file: pnpm_lock,
Expand Down Expand Up @@ -282,9 +282,9 @@ def yarn_lock_changed?(yarn_lock)
yarn_lock.content != updated_yarn_lock_content(yarn_lock)
end

sig { params(pnpm_lock: Dependabot::DependencyFile).returns(T::Boolean) }
def pnpm_lock_changed?(pnpm_lock)
pnpm_lock.content != updated_pnpm_lock_content(pnpm_lock)
sig { params(pnpm_lock: Dependabot::DependencyFile, is_catalog: T::Boolean).returns(T::Boolean) }
def pnpm_lock_changed?(pnpm_lock, is_catalog: false)
pnpm_lock.content != updated_pnpm_lock_content(pnpm_lock, is_catalog: is_catalog)
end

sig { params(bun_lock: Dependabot::DependencyFile).returns(T::Boolean) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
file: "pnpm-workspace.yaml",
name: "prettier",
version: "3.3.0",
required_version: "3.3.3",
previous_required_version: "3.3.0"
required_version: "^3.3.3",
previous_required_version: "^3.3.0"
)
end

describe "#updated_pnmp_workspace" do
subject(:updated_package_json) { pnpm_workspace_updater.updated_pnpm_workspace }

its(:content) { is_expected.to include "prettier: 3.3.3" }
its(:content) { is_expected.to include "prettier: ^3.3.3" }

context("with multiple dependencies") do
let(:project_name) { "pnpm/catalog_multiple" }
Expand Down
14 changes: 7 additions & 7 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4151,16 +4151,16 @@
create_dependency(
file: "pnpm-workspace.yaml",
name: "prettier",
version: "3.3.0",
required_version: "3.3.3",
previous_required_version: "3.3.0"
version: "3.3.3",
required_version: "^3.3.3",
previous_required_version: "^3.3.0"
)
]
end

it "updates the workspace" do
expect(updated_files.map(&:name)).to eq(%w(pnpm-workspace.yaml pnpm-lock.yaml))
expect(updated_pnpm_workspace.content).to include("prettier: 3.3.3")
expect(updated_files.map(&:name)).to eq(%w(pnpm-workspace.yaml))
expect(updated_pnpm_workspace.content).to include("prettier: ^3.3.3")
end
end

Expand Down Expand Up @@ -4276,8 +4276,8 @@
file: "pnpm-workspace.yaml",
name: "prettier",
version: "3.3.0",
required_version: "3.3.3",
previous_required_version: "3.3.0"
required_version: "^3.3.3",
previous_required_version: "^3.3.0"
)
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"description": "",
"main": "index.js",
"author": "",
"packageManager": "[email protected]",
"dependencies": {
},
"devDependencies": {
"prettier": "catalog:"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ packages:
- packages/*

catalog:
prettier: 3.3.0
prettier: ^3.3.0

0 comments on commit fa20d49

Please sign in to comment.