Class: Dependabot::Hex::FileUpdater::LockfileUpdater

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/hex/file_updater/lockfile_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependencies:, dependency_files:, credentials:) ⇒ LockfileUpdater

Returns a new instance of LockfileUpdater.



28
29
30
31
32
# File 'lib/dependabot/hex/file_updater/lockfile_updater.rb', line 28

def initialize(dependencies:, dependency_files:, credentials:)
  @dependencies = T.let(dependencies, T::Array[Dependabot::Dependency])
  @dependency_files = T.let(dependency_files, T::Array[Dependabot::DependencyFile])
  @credentials = T.let(credentials, T::Array[Dependabot::Credential])
end

Instance Method Details

#updated_lockfile_contentObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/dependabot/hex/file_updater/lockfile_updater.rb', line 35

def updated_lockfile_content
  @updated_lockfile_content = T.let(@updated_lockfile_content, T.nilable(String))
  @updated_lockfile_content ||=
    SharedHelpers.in_a_temporary_directory do
      write_temporary_dependency_files
      FileUtils.cp(elixir_helper_do_update_path, "do_update.exs")

      SharedHelpers.with_git_configured(credentials: credentials) do
        SharedHelpers.run_helper_subprocess(
          env: mix_env,
          command: "mix run #{elixir_helper_path}",
          function: "get_updated_lockfile",
          args: [Dir.pwd, dependency.name, CredentialHelpers.hex_credentials(credentials)]
        )
      end
    end

  post_process_lockfile(@updated_lockfile_content)
rescue SharedHelpers::HelperSubprocessFailed => e
  handle_hex_errors(e)
end