Class: Dependabot::NpmAndYarn::FileParser::JsonLock
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::FileParser::JsonLock
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/npm_and_yarn/file_parser/json_lock.rb
Instance Method Summary collapse
- #dependencies ⇒ Object
- #details(dependency_name, _requirement, manifest_name) ⇒ Object
-
#initialize(dependency_file) ⇒ JsonLock
constructor
A new instance of JsonLock.
- #parsed ⇒ Object
Constructor Details
#initialize(dependency_file) ⇒ JsonLock
Returns a new instance of JsonLock.
16 17 18 |
# File 'lib/dependabot/npm_and_yarn/file_parser/json_lock.rb', line 16 def initialize(dependency_file) @dependency_file = dependency_file end |
Instance Method Details
#dependencies ⇒ Object
29 30 31 |
# File 'lib/dependabot/npm_and_yarn/file_parser/json_lock.rb', line 29 def dependencies recursively_fetch_dependencies(parsed) end |
#details(dependency_name, _requirement, manifest_name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dependabot/npm_and_yarn/file_parser/json_lock.rb', line 37 def details(dependency_name, _requirement, manifest_name) if Helpers.npm8?(@dependency_file) # NOTE: npm 8 sometimes doesn't install workspace dependencies in the # workspace folder so we need to fallback to checking top-level nested_details = parsed.dig("packages", node_modules_path(manifest_name, dependency_name)) details = nested_details || parsed.dig("packages", "node_modules/#{dependency_name}") details&.slice("version", "resolved", "integrity", "dev") else parsed.dig("dependencies", dependency_name) end end |
#parsed ⇒ Object
21 22 23 24 25 26 |
# File 'lib/dependabot/npm_and_yarn/file_parser/json_lock.rb', line 21 def parsed json_obj = JSON.parse(T.must(@dependency_file.content)) @parsed ||= T.let(json_obj, T.untyped) rescue JSON::ParserError raise Dependabot::DependencyFileNotParseable, @dependency_file.path end |