Sha256: d13a75459a66cec7635e060fadc7c4c3c5e20db51693b0c58f6318c9dd36ff53
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
module ShopifyCLI # The environment module provides an interface to get information from # the environment in which the CLI runs module Environment TRUTHY_ENV_VARIABLE_VALUES = ["1", "true", "TRUE", "yes", "YES"] def self.use_local_partners_instance?(env_variables: ENV) env_variable_truthy?( Constants::EnvironmentVariables::LOCAL_PARTNERS, env_variables: env_variables ) end def self.use_spin_partners_instance?(env_variables: ENV) env_variable_truthy?( Constants::EnvironmentVariables::SPIN_PARTNERS, env_variables: env_variables ) end def self.running_tests?(env_variables: ENV) env_variable_truthy?( Constants::EnvironmentVariables::RUNNING_TESTS, env_variables: env_variables ) end def self.partners_domain(env_variables: ENV) if use_local_partners_instance?(env_variables: env_variables) "partners.myshopify.io" elsif use_spin_partners_instance?(env_variables: env_variables) "partners.#{spin_url(env_variables: env_variables)}" else "partners.shopify.com" end end def self.spin_url(env_variables: ENV) spin_workspace = spin_workspace(env_variables: env_variables) spin_namespace = spin_namespace(env_variables: env_variables) spin_host = spin_host(env_variables: env_variables) "#{spin_workspace}.#{spin_namespace}.#{spin_host}" end def self.env_variable_truthy?(variable_name, env_variables: ENV) TRUTHY_ENV_VARIABLE_VALUES.include?(env_variables[variable_name.to_s]) end def self.spin_workspace(env_variables: ENV) env_variables[Constants::EnvironmentVariables::SPIN_WORKSPACE] end def self.spin_namespace(env_variables: ENV) env_variables[Constants::EnvironmentVariables::SPIN_NAMESPACE] end def self.spin_host(env_variables: ENV) env_variables[Constants::EnvironmentVariables::SPIN_HOST] || "us.spin.dev" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shopify-cli-2.5.0 | lib/shopify_cli/environment.rb |