Sha256: dde9714895fd6d7a7fee662350858f583cffd08478db0a38cdf171f14cd171fa

Contents?: true

Size: 1.3 KB

Versions: 21

Compression:

Stored size: 1.3 KB

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",
        "web_pixel_extension",
        "pos_ui_extension",
      ]

      class << self
        def supported?(type)
          if type_supported?(type) && beta_enabled?
            return true if binary_installed?
            warn_about_missing_binary
          end

          false
        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

        def warn_about_missing_binary
          CLI::UI::Frame.open(message("errors.development_server_binary_not_found.title"), color: :yellow) do
            context.puts(message("errors.development_server_binary_not_found.message"))
          end
        end

        def message(key)
          context.message(key)
        end

        def context
          @context ||= ShopifyCLI::Context.new
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.35.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.34.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.33.1 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.33.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.32.1 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.32.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.31.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.30.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.29.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.28.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.27.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.26.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.25.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.24.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.23.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.22.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.21.0 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.20.1 lib/project_types/extension/models/development_server_requirements.rb
shopify-cli-2.20.0 lib/project_types/extension/models/development_server_requirements.rb