Sha256: eb2326b76143d7dcddb299afd487b484e038708cc5775ebb33876d92750669a0

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true
require "shopify_cli"

module Extension
  module Models
    class DevelopmentServerRequirements
      SUPPORTED_EXTENSION_TYPES = [
        "checkout_ui_extension",
      ]

      UNIX_NAME = "shopify-extensions"
      WINDOWS_NAME = "shopify-extensions.exe"

      class << self
        def supported?(type)
          binary_installed? && type_supported?(type) && beta_enabled?
        end

        private

        def binary_installed?
          extension_dir = File.join(ShopifyCLI::ROOT, "ext", "shopify-extensions")
          File.exist?(File.join(extension_dir, UNIX_NAME)) || File.exist?(File.join(extension_dir, WINDOWS_NAME))
        end

        def type_supported?(type)
          SUPPORTED_EXTENSION_TYPES.include?(type.downcase)
        end

        def beta_enabled?
          ShopifyCLI::Shopifolk.check && ShopifyCLI::Feature.enabled?(:extension_server_beta)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-cli-2.5.0 lib/project_types/extension/models/development_server_requirements.rb