diff --git a/deploy/lib/deployer/errors.rb b/deploy/lib/deployer/errors.rb index 1847096..424acd6 100644 --- a/deploy/lib/deployer/errors.rb +++ b/deploy/lib/deployer/errors.rb @@ -46,4 +46,16 @@ class AutoMergeFailure < BaseError class VersionCompareFailure < BaseError end + + class RequirementsNotMet < BaseError + def initialize(version) + super(build_message(version)) + end + + def build_message(version) + "Upgrade does not satisfy requirements. The latest upgradable verison is #{version}. " \ + "Verify that the requirement allows for an upgrade to this version and check that all " \ + "peer dependencies are satisfied." + end + end end diff --git a/deploy/lib/deployer/repo/dependabot_pull_request_updater.rb b/deploy/lib/deployer/repo/dependabot_pull_request_updater.rb index 3f6fc4d..c49a479 100644 --- a/deploy/lib/deployer/repo/dependabot_pull_request_updater.rb +++ b/deploy/lib/deployer/repo/dependabot_pull_request_updater.rb @@ -5,6 +5,7 @@ class Repo class DependabotPullRequestUpdater < PullRequestUpdater def run setup_runner + verify_upgrade_satisfies create_pr automerge_pr if config.automerge end @@ -198,6 +199,18 @@ def sanitize_yarnrc_yml(fetcher) yarnrc_yml_file.content = yarnrc_yml_file.content.gsub("yarnPath:", "# yarnPath:") end + + def verify_upgrade_satisfies + if Gem::Version.new(resolvable_version) >= Gem::Version.new(version) + return + end + + raise RequirementsNotMet, resolvable_version + end + + def resolvable_version + checker.latest_resolvable_version + end end end end