Class: Dependabot::NpmAndYarn::RegistryHelper
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::RegistryHelper
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/npm_and_yarn/registry_helper.rb
Constant Summary collapse
- REGISTRY_KEY =
Keys for configurations
"registry"- AUTH_KEY =
"authToken"- NPM_AUTH_TOKEN_KEY_FOR_YARN =
Yarn-specific keys
"npmAuthToken"- NPM_SCOPE_KEY_FOR_YARN =
"npmScopes"- NPM_REGISTER_KEY_FOR_YARN =
"npmRegistryServer"- COREPACK_NPM_REGISTRY_ENV =
Environment variable keys
"COREPACK_NPM_REGISTRY"- NPM_CONFIG_REGISTRY_ENV =
For Corepack
"npm_config_registry"- COREPACK_NPM_TOKEN_ENV =
For npm
"COREPACK_NPM_TOKEN"- DEFAULT_NPM_REGISTRY =
Default npm registry - no need to set env vars for this
"https://registry.npmjs.org"
Instance Method Summary collapse
- #find_corepack_env_variables ⇒ Object
-
#initialize(registry_config_files, credentials) ⇒ RegistryHelper
constructor
A new instance of RegistryHelper.
Constructor Details
#initialize(registry_config_files, credentials) ⇒ RegistryHelper
Returns a new instance of RegistryHelper.
36 37 38 39 |
# File 'lib/dependabot/npm_and_yarn/registry_helper.rb', line 36 def initialize(registry_config_files, credentials) @registry_config_files = T.let(registry_config_files, T::Hash[Symbol, T.nilable(Dependabot::DependencyFile)]) @credentials = T.let(credentials, T.nilable(T::Array[Dependabot::Credential])) end |
Instance Method Details
#find_corepack_env_variables ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dependabot/npm_and_yarn/registry_helper.rb', line 42 def find_corepack_env_variables registry_info = find_registry_and_token env_variables = {} if registry_info[:registry] # Prevent the https from being stripped in the process registry = registry_info[:registry] registry = "https://#{T.must(registry)}" unless T.must(registry).start_with?("http://", "https://") # Set both in the env_variables hash unless registry == DEFAULT_NPM_REGISTRY env_variables[COREPACK_NPM_REGISTRY_ENV] = registry # For Corepack env_variables[NPM_CONFIG_REGISTRY_ENV] = registry # For npm env_variables[REGISTRY_KEY] = registry end end env_variables[COREPACK_NPM_TOKEN_ENV] = registry_info[:auth_token] if registry_info[:auth_token] env_variables end |