Class: Dependabot::UpdateCheckers::JavaScript::NpmAndYarn::SubdependencyVersionResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/update_checkers/java_script/npm_and_yarn/subdependency_version_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, credentials:, dependency_files:, ignored_versions:) ⇒ SubdependencyVersionResolver

Returns a new instance of SubdependencyVersionResolver.



18
19
20
21
22
23
24
# File 'lib/dependabot/update_checkers/java_script/npm_and_yarn/subdependency_version_resolver.rb', line 18

def initialize(dependency:, credentials:, dependency_files:,
               ignored_versions:)
  @dependency       = dependency
  @credentials      = credentials
  @dependency_files = dependency_files
  @ignored_versions = ignored_versions
end

Instance Method Details

#latest_resolvable_versionObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dependabot/update_checkers/java_script/npm_and_yarn/subdependency_version_resolver.rb', line 26

def latest_resolvable_version
  raise "Not a subdependency!" if dependency.requirements.any?

  lockfiles = [*package_locks, *shrinkwraps, *yarn_locks]
  updated_lockfiles = lockfiles.map do |lockfile|
    updated_content = update_subdependency_in_lockfile(lockfile)
    updated_lockfile = lockfile.dup
    updated_lockfile.content = updated_content
    updated_lockfile
  end

  version_from_updated_lockfiles(updated_lockfiles)
rescue SharedHelpers::HelperSubprocessFailed
  # TODO: Move error handling logic from the FileUpdater to this class

  # Return nil (no update possible) if an unknown error occurred
  nil
end