Class: Dependabot::NpmAndYarn::DependencyGrapher::YarnRelationshipResolver
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::DependencyGrapher::YarnRelationshipResolver
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/npm_and_yarn/dependency_grapher/yarn_relationship_resolver.rb
Instance Method Summary collapse
-
#initialize(lockfile) ⇒ YarnRelationshipResolver
constructor
A new instance of YarnRelationshipResolver.
- #relationships ⇒ Object
Constructor Details
#initialize(lockfile) ⇒ YarnRelationshipResolver
Returns a new instance of YarnRelationshipResolver.
14 15 16 |
# File 'lib/dependabot/npm_and_yarn/dependency_grapher/yarn_relationship_resolver.rb', line 14 def initialize(lockfile) @lockfile = lockfile end |
Instance Method Details
#relationships ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dependabot/npm_and_yarn/dependency_grapher/yarn_relationship_resolver.rb', line 19 def relationships parsed = FileParser::YarnLock.new(@lockfile).parsed parsed.each_with_object({}) do |(req, details), rels| next unless details.is_a?(Hash) version = details["version"] parent_name = T.must(req.split(/(?<=\w)\@/).first) children = details.fetch("dependencies", {}) next if children.nil? || children.empty? key = "#{parent_name}@#{version}" resolved_children = resolve_children(children, parsed) rels[key] ||= [] rels[key].concat(resolved_children).uniq! end end |