Sha256: 9c73bfef4524aabdc05de69f09376bce0bf3f30ff0d5b88231f747ff07244f2e

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

# frozen_string_literal: true

require "shopify_cli"

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

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

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

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

        private

        def binary_installed?
          Models::DevelopmentServer.new.executable_installed?
        end

        # Some types are enabled unconditionally; others require beta_enabled
        def type_enabled?(type)
          beta_enabled? || "checkout_ui_extension" == type.downcase
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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