Class: Theme::Command::Serve

Inherits:
ShopifyCLI::Command::SubCommand show all
Includes:
Common::RootHelper
Defined in:
lib/project_types/theme/commands/serve.rb

Constant Summary collapse

DEFAULT_HTTP_HOST =
"127.0.0.1"

Instance Attribute Summary

Attributes inherited from ShopifyCLI::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::RootHelper

#exist_and_not_empty?, #root_value, #valid_theme_directory?

Methods inherited from ShopifyCLI::Command::SubCommand

call

Methods inherited from ShopifyCLI::Command

call, call_help, check_node_version, check_ruby_version, check_version, #initialize, options, prerequisite_task, recommend_default_node_range, recommend_default_ruby_range, recommend_node, recommend_ruby, run_prerequisites, subcommand, subcommand_registry

Methods included from ShopifyCLI::Feature::Set

#hidden?, #hidden_feature

Constructor Details

This class inherits a constructor from ShopifyCLI::Command

Class Method Details

.as_reload_mode(mode) ⇒ Object



55
56
57
# File 'lib/project_types/theme/commands/serve.rb', line 55

def self.as_reload_mode(mode)
  ShopifyCLI::Theme::DevServer::ReloadMode.get!(mode)
end

.helpObject



59
60
61
# File 'lib/project_types/theme/commands/serve.rb', line 59

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

Instance Method Details

#call(_args, name) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/project_types/theme/commands/serve.rb', line 41

def call(_args, name)
  valid_authentication_method!

  root = root_value(options, name)
  return unless valid_theme_directory?(root)

  flags = options.flags.dup
  host = flags[:host] || DEFAULT_HTTP_HOST

  ShopifyCLI::Theme::DevServer.start(@ctx, root, host: host, **flags) do |syncer|
    UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delay_low_priority_files: true)
  end
end