Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn Auto Fix - Use Recommended Patch Version #699

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions lib/salus/auto_fix/yarn_audit_v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def update_package_definition(blocks, parts)
updated_resolved = "resolved " + '"' + fixed_package_info["data"]["dist"]["tarball"] \
+ "#" + fixed_package_info["data"]["dist"]["shasum"] + '"'
updated_integrity = "integrity " + fixed_package_info['data']['dist']['integrity']
updated_name = package_name + "@^" + version_to_update_to
updated_name = package_name + "@^" + versions.first[:patch].tr(">=", "").tr(">", "")
Copy link
Contributor

@saikat056 saikat056 Sep 21, 2022

Choose a reason for hiding this comment

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

Can we add some unit tests for this change?


parts.each_with_index do |part, index|
current_v = parts[index].match(/(("|)version("|).*)/)
Expand Down Expand Up @@ -160,7 +160,7 @@ def update_sub_parent_resolution(blocks, parts)
if part.include?(source) && !match.nil? && !is_major_bump(
match.to_s.split(" ").last, version_to_update_to
)
replace = target + ' "^' + version_to_update_to + '"'
replace = target + ' "^' + patch.first[:patch].tr(">=", "").tr(">", "") + '"'
part.sub!(/("|)(!:|#{target})("| ).*/, replace)
parts[index] = part
end
Expand Down