Class: Dependabot::NpmAndYarn::UpdateChecker::RegistryFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/npm_and_yarn/update_checker/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.



18
19
20
21
22
23
24
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 18

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



30
31
32
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 30

def auth_headers
  auth_header_for(auth_token)
end

#dependency_urlObject



34
35
36
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 34

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

#registryObject



26
27
28
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 26

def registry
  locked_registry || first_registry_with_dependency_details
end