Class: Dependabot::NpmAndYarn::UpdateChecker::RegistryFinder
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::UpdateChecker::RegistryFinder
- Defined in:
- lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb
Constant Summary collapse
- CENTRAL_REGISTRIES =
%w( https://registry.npmjs.org http://registry.npmjs.org https://registry.yarnpkg.com http://registry.yarnpkg.com ).freeze
- NPM_AUTH_TOKEN_REGEX =
%r{//(?<registry>.*)/:_authToken=(?<token>.*)$}
- NPM_GLOBAL_REGISTRY_REGEX =
/^registry\s*=\s*['"]?(?<registry>.*?)['"]?$/
- YARN_GLOBAL_REGISTRY_REGEX =
/^(?:--)?registry\s+((['"](?<registry>.*)['"])|(?<registry>.*))/
- NPM_SCOPED_REGISTRY_REGEX =
/^(?<scope>@[^:]+)\s*:registry\s*=\s*['"]?(?<registry>.*?)['"]?$/
- YARN_SCOPED_REGISTRY_REGEX =
/['"](?<scope>@[^:]+):registry['"]\s((['"](?<registry>.*)['"])|(?<registry>.*))/
Class Method Summary collapse
Instance Method Summary collapse
- #auth_headers ⇒ Object
- #dependency_url ⇒ Object
-
#initialize(dependency:, credentials:, npmrc_file: nil, yarnrc_file: nil, yarnrc_yml_file: nil) ⇒ RegistryFinder
constructor
A new instance of RegistryFinder.
- #registry ⇒ Object
- #registry_from_rc(dependency_name) ⇒ Object
- #tarball_url(version) ⇒ Object
Constructor Details
#initialize(dependency:, credentials:, npmrc_file: nil, yarnrc_file: nil, yarnrc_yml_file: nil) ⇒ RegistryFinder
Returns a new instance of RegistryFinder.
24 25 26 27 28 29 30 31 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 24 def initialize(dependency:, credentials:, npmrc_file: nil, yarnrc_file: nil, yarnrc_yml_file: nil) @dependency = dependency @credentials = credentials @npmrc_file = npmrc_file @yarnrc_file = yarnrc_file @yarnrc_yml_file = yarnrc_yml_file end |
Class Method Details
.central_registry?(registry) ⇒ Boolean
52 53 54 55 56 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 52 def self.central_registry?(registry) CENTRAL_REGISTRIES.any? do |r| r.include?(registry) end end |
Instance Method Details
#auth_headers ⇒ Object
37 38 39 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 37 def auth_headers auth_header_for(auth_token) end |
#dependency_url ⇒ Object
41 42 43 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 41 def dependency_url "#{registry_url}/#{escaped_dependency_name}" end |
#registry ⇒ Object
33 34 35 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 33 def registry @registry ||= locked_registry || configured_registry || first_registry_with_dependency_details end |
#registry_from_rc(dependency_name) ⇒ Object
58 59 60 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 58 def registry_from_rc(dependency_name) explicit_registry_from_rc(dependency_name) || global_registry end |
#tarball_url(version) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb', line 45 def tarball_url(version) = version.to_s.gsub(/\+.*/, "") # Dependency name needs to be unescaped since tarball URLs don't always work with escaped slashes "#{registry_url}/#{dependency.name}/-/#{scopeless_name}-#{}.tgz" end |