Class: Dependabot::NpmAndYarn::UpdateChecker::DependencyFilesBuilder
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::UpdateChecker::DependencyFilesBuilder
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb
Instance Method Summary collapse
-
#initialize(dependency:, dependency_files:, credentials:) ⇒ DependencyFilesBuilder
constructor
A new instance of DependencyFilesBuilder.
- #lockfiles ⇒ Object
- #package_files ⇒ Object
- #package_locks ⇒ Object
- #pnpm_locks ⇒ Object
- #root_pnpm_lock ⇒ Object
- #root_yarn_lock ⇒ Object
- #shrinkwraps ⇒ Object
- #write_temporary_dependency_files ⇒ Object
- #yarn_locks ⇒ Object
Constructor Details
#initialize(dependency:, dependency_files:, credentials:) ⇒ DependencyFilesBuilder
23 24 25 26 27 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 23 def initialize(dependency:, dependency_files:, credentials:) @dependency = dependency @dependency_files = dependency_files @credentials = credentials end |
Instance Method Details
#lockfiles ⇒ Object
102 103 104 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 102 def lockfiles [*package_locks, *shrinkwraps, *yarn_locks, *pnpm_locks] end |
#package_files ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 107 def package_files @package_files ||= T.let( dependency_files .select { |f| f.name.end_with?("package.json") }, T.nilable(T::Array[Dependabot::DependencyFile]) ) end |
#package_locks ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 48 def package_locks @package_locks ||= T.let( dependency_files .select { |f| f.name.end_with?("package-lock.json") }, T.nilable(T::Array[Dependabot::DependencyFile]) ) end |
#pnpm_locks ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 66 def pnpm_locks @pnpm_locks ||= T.let( dependency_files .select { |f| f.name.end_with?("pnpm-lock.yaml") }, T.nilable(T::Array[Dependabot::DependencyFile]) ) end |
#root_pnpm_lock ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 84 def root_pnpm_lock @root_pnpm_lock ||= T.let( dependency_files .find { |f| f.name == "pnpm-lock.yaml" }, T.nilable(Dependabot::DependencyFile) ) end |
#root_yarn_lock ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 75 def root_yarn_lock @root_yarn_lock ||= T.let( dependency_files .find { |f| f.name == "yarn.lock" }, T.nilable(Dependabot::DependencyFile) ) end |
#shrinkwraps ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 93 def shrinkwraps @shrinkwraps ||= T.let( dependency_files .select { |f| f.name.end_with?("npm-shrinkwrap.json") }, T.nilable(T::Array[Dependabot::DependencyFile]) ) end |
#write_temporary_dependency_files ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 30 def write_temporary_dependency_files write_lockfiles if Helpers.yarn_berry?(yarn_locks.first) File.write(".yarnrc.yml", yarnrc_yml_content) if yarnrc_yml_file else File.write(".npmrc", npmrc_content) File.write(".yarnrc", yarnrc_content) if yarnrc_specifies_private_reg? end package_files.each do |file| path = file.name FileUtils.mkdir_p(Pathname.new(path).dirname) File.write(file.name, prepared_package_json_content(file)) end end |
#yarn_locks ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb', line 57 def yarn_locks @yarn_locks ||= T.let( dependency_files .select { |f| f.name.end_with?("yarn.lock") }, T.nilable(T::Array[Dependabot::DependencyFile]) ) end |