Sha256: c70543e3b01e0226234e677deee96a1257c2513ea4573990280faaa5376e89d1

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
require "shopify_cli/theme/dev_server"

module Theme
  class Command
    class Serve < ShopifyCLI::Command::SubCommand
      DEFAULT_HTTP_HOST = "127.0.0.1"

      options do |parser, flags|
        parser.on("--host=HOST") { |host| flags[:host] = host.to_s }
        parser.on("--port=PORT") { |port| flags[:port] = port.to_i }
        parser.on("--poll") { flags[:poll] = true }
      end

      def call(*)
        flags = options.flags.dup
        host = flags[:host] || DEFAULT_HTTP_HOST
        ShopifyCLI::Theme::DevServer.start(@ctx, ".", host: host, **flags) do |syncer|
          UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delay_low_priority_files: true)
        end
      rescue ShopifyCLI::Theme::DevServer::AddressBindingError
        raise ShopifyCLI::Abort,
          ShopifyCLI::Context.message("theme.serve.error.address_binding_error", ShopifyCLI::TOOL_NAME)
      end

      def self.help
        ShopifyCLI::Context.message("theme.serve.help", ShopifyCLI::TOOL_NAME)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shopify-cli-2.8.0 lib/project_types/theme/commands/serve.rb
shopify-cli-2.7.4 lib/project_types/theme/commands/serve.rb
shopify-cli-2.7.3 lib/project_types/theme/commands/serve.rb
shopify-cli-2.7.2 lib/project_types/theme/commands/serve.rb