Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

class ShopifyCli::Shopifolk

Melanie Wang edited this page Jan 28, 2021 · 1 revision

ShopifyCli::Shopifolk contains the logic to determine if the user appears to be a Shopify staff

The Shopifolk Feature flag will persist between runs so if the flag is enabled or disabled, it will still be in that same state until the next class invocation.

Constants

  • GCLOUD_CONFIG_FILE
  • DEV_PATH
  • SECTION
  • FEATURE_NAME

Attributes

  • acting_as_shopify_organization

Class Methods

check

check() will return if the user appears to be a Shopify employee, based on several heuristics

Returns

  • is_shopifolk - returns true if the user is a Shopify Employee

Example

ShopifyCli::Shopifolk.check
see source

# File lib/shopify-cli/shopifolk.rb, line 27
def check
  return false unless ShopifyCli::Config.get_bool('shopifolk-beta', 'enabled')

  ShopifyCli::Shopifolk.new.shopifolk?
end

act_as_shopify_organization

act_as_shopify_organization()

see source

# File lib/shopify-cli/shopifolk.rb, line 33
def act_as_shopify_organization
  @acting_as_shopify_organization = true
end

acting_as_shopify_organization?

acting_as_shopify_organization?()

see source

# File lib/shopify-cli/shopifolk.rb, line 37
def acting_as_shopify_organization?
  !!@acting_as_shopify_organization || (Project.has_current? && Project.current.config['shopify_organization'])
end

reset

reset()

see source

# File lib/shopify-cli/shopifolk.rb, line 41
def reset
  @acting_as_shopify_organization = nil
end

Instance Methods

shopifolk?

shopifolk?() will return if the user is a Shopify employee

Returns

  • is_shopifolk - returns true if the user has dev installed and

a valid google cloud config file with email ending in "@shopify.com"

see source

# File lib/shopify-cli/shopifolk.rb, line 54
def shopifolk?
  return false unless ShopifyCli::Config.get_bool('shopifolk-beta', 'enabled')
  return true if Feature.enabled?(FEATURE_NAME)

  if shopifolk_by_gcloud? && shopifolk_by_dev?
    ShopifyCli::Feature.enable(FEATURE_NAME)
    true
  else
    ShopifyCli::Feature.disable(FEATURE_NAME)
    false
  end
end

Clone this wiki locally