Class: Dependabot::NpmAndYarn::FileUpdater::PnpmLockfileUpdater

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

Overview

rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(dependencies:, dependency_files:, repo_contents_path:, credentials:) ⇒ PnpmLockfileUpdater

Returns a new instance of PnpmLockfileUpdater.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb', line 27

def initialize(dependencies:, dependency_files:, repo_contents_path:, credentials:)
  @dependencies = dependencies
  @dependency_files = dependency_files
  @repo_contents_path = repo_contents_path
  @credentials = credentials
  @error_handler = T.let(
    PnpmErrorHandler.new(
      dependencies: dependencies,
      dependency_files: dependency_files
    ),
    PnpmErrorHandler
  )
end

Instance Method Details

#updated_pnpm_lock_content(pnpm_lock, updated_pnpm_workspace_content: nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb', line 47

def updated_pnpm_lock_content(pnpm_lock, updated_pnpm_workspace_content: nil)
  @updated_pnpm_lock_content ||= T.let(
    {},
    T.nilable(T::Hash[String, String])
  )
  return T.must(@updated_pnpm_lock_content[pnpm_lock.name]) if @updated_pnpm_lock_content[pnpm_lock.name]

  new_content = run_pnpm_update(
    pnpm_lock: pnpm_lock,
    updated_pnpm_workspace_content: updated_pnpm_workspace_content
  )
  @updated_pnpm_lock_content[pnpm_lock.name] = new_content
rescue SharedHelpers::HelperSubprocessFailed => e
  handle_pnpm_lock_updater_error(e, pnpm_lock)
end