Class: Dependabot::UpdateCheckers::JavaScript::NpmAndYarn::RegistryFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/update_checkers/java_script/npm_and_yarn/registry_finder.rb

Constant Summary collapse

NPM_AUTH_TOKEN_REGEX =
%r{//(?<registry>.*)/:_authToken=(?<token>.*)$}.freeze
NPM_GLOBAL_REGISTRY_REGEX =
/^registry\s*=\s*(?<registry>.*)$/.freeze
YARN_GLOBAL_REGISTRY_REGEX =
/^registry\s+['"](?<registry>.*)['"]/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, credentials:, npmrc_file: nil, yarnrc_file: nil) ⇒ RegistryFinder

Returns a new instance of RegistryFinder.



19
20
21
22
23
24
25
# File 'lib/dependabot/update_checkers/java_script/npm_and_yarn/registry_finder.rb', line 19

def initialize(dependency:, credentials:, npmrc_file: nil,
               yarnrc_file: nil)
  @dependency = dependency
  @credentials = credentials
  @npmrc_file = npmrc_file
  @yarnrc_file = yarnrc_file
end

Instance Method Details

#auth_headersObject



31
32
33
# File 'lib/dependabot/update_checkers/java_script/npm_and_yarn/registry_finder.rb', line 31

def auth_headers
  auth_header_for(auth_token)
end

#dependency_urlObject



35
36
37
# File 'lib/dependabot/update_checkers/java_script/npm_and_yarn/registry_finder.rb', line 35

def dependency_url
  "#{registry_url.gsub(%r{/+$}, '')}/#{escaped_dependency_name}"
end

#registryObject



27
28
29
# File 'lib/dependabot/update_checkers/java_script/npm_and_yarn/registry_finder.rb', line 27

def registry
  locked_registry || first_registry_with_dependency_details
end