Class: Dependabot::Elm::UpdateChecker::Elm19LatestVersionFinder

Inherits:
Package::PackageLatestVersionFinder
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/elm/update_checker/latest_version_finder.rb

Overview

ELM19 version finder ######

Defined Under Namespace

Classes: UnrecoverableState

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, cooldown_options: nil) ⇒ Elm19LatestVersionFinder



123
124
125
126
127
128
129
130
# File 'lib/dependabot/elm/update_checker/latest_version_finder.rb', line 123

def initialize(dependency:, dependency_files:, cooldown_options: nil)
  @dependency = dependency
  @dependency_files = dependency_files
  @cooldown_options = cooldown_options

   = T.let(nil, T.nilable(T::Hash[String, Dependabot::Elm::Version]))
  @original_dependency_details ||= T.let(nil, T.nilable(T::Array[Dependabot::Dependency]))
end

Instance Method Details

#latest_resolvable_version(unlock_requirement:) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
# File 'lib/dependabot/elm/update_checker/latest_version_finder.rb', line 133

def latest_resolvable_version(unlock_requirement:)
  raise "Invalid unlock setting: #{unlock_requirement}" unless i(none own all).include?(unlock_requirement)

  # Elm has no lockfile, so we will never create an update PR if
  # unlock requirements are `none`. Just return the current version.
  return current_version if unlock_requirement == :none

  # Otherwise, we gotta check a few conditions to see if bumping
  # wouldn't also bump other deps in elm.json
  fetch_latest_resolvable_version(unlock_requirement)
end

#updated_dependencies_after_full_unlockObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/dependabot/elm/update_checker/latest_version_finder.rb', line 146

def updated_dependencies_after_full_unlock
  changed_deps = 

  original_dependency_details.filter_map do |original_dep|
    new_version = changed_deps.fetch(original_dep.name, nil)
    next unless new_version

    old_reqs = original_dep.requirements.map do |req|
      requirement_class.new(req[:requirement])
    end

    next if old_reqs.all? { |req| req.satisfied_by?(new_version) }

    new_requirements =
      RequirementsUpdater.new(
        requirements: original_dep.requirements,
        latest_resolvable_version: new_version.to_s
      ).updated_requirements

    Dependency.new(
      name: original_dep.name,
      version: new_version.to_s,
      requirements: new_requirements,
      previous_version: original_dep.version,
      previous_requirements: original_dep.requirements,
      package_manager: original_dep.package_manager
    )
  end
end