Class: Dependabot::NpmAndYarn::FileParser::LockfileParser
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::FileParser::LockfileParser
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb
Instance Method Summary collapse
-
#initialize(dependency_files:) ⇒ LockfileParser
constructor
A new instance of LockfileParser.
- #lockfile_details(dependency_name:, requirement:, manifest_name:) ⇒ Object
- #parse ⇒ Object
- #parse_set ⇒ Object
Constructor Details
#initialize(dependency_files:) ⇒ LockfileParser
Returns a new instance of LockfileParser.
20 21 22 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 20 def initialize(dependency_files:) @dependency_files = dependency_files end |
Instance Method Details
#lockfile_details(dependency_name:, requirement:, manifest_name:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 48 def lockfile_details(dependency_name:, requirement:, manifest_name:) details = T.let(nil, T.nilable(T::Hash[String, T.untyped])) potential_lockfiles_for_manifest(manifest_name).each do |lockfile| details = lockfile_for(lockfile).details(dependency_name, requirement, manifest_name) break if details end details end |
#parse ⇒ Object
40 41 42 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 40 def parse Helpers.(parse_set) end |
#parse_set ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb', line 25 def parse_set dependency_set = Dependabot::FileParsers::Base::DependencySet.new # NOTE: The DependencySet will de-dupe our dependencies, so they # end up unique by name. That's not a perfect representation of # the nested nature of JS resolution, but it makes everything work # comparably to other flat-resolution strategies (yarn_locks + pnpm_locks + package_locks + shrinkwraps).each do |file| dependency_set += lockfile_for(file).dependencies end dependency_set end |