Class: Theme::Command::Push

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

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 included from Common::ShopHelper

#shop

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

.helpObject



91
92
93
# File 'lib/project_types/theme/commands/push.rb', line 91

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

Instance Method Details

#call(_args, name) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/project_types/theme/commands/push.rb', line 48

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

  development_theme_id = options.flags[:development_theme_id]
  ShopifyCLI::DB.set(development_theme_id: development_theme_id) unless development_theme_id.nil?

  delete = !options.flags[:nodelete]
  theme = find_theme(root, **options.flags)
  return if theme.nil?

  if theme.live? && !options.flags[:allow_live]
    question = @ctx.message("theme.push.live")
    question += @ctx.message("theme.push.theme", theme.name, theme.id) if options.flags[:live]
    return unless CLI::UI::Prompt.confirm(question)
  end

  include_filter = ShopifyCLI::Theme::IncludeFilter.new(root, options.flags[:includes])
  ignore_filter = ShopifyCLI::Theme::IgnoreFilter.from_path(root)
  ignore_filter.add_patterns(options.flags[:ignores]) if options.flags[:ignores]

  syncer = ShopifyCLI::Theme::Syncer.new(@ctx, theme: theme,
    include_filter: include_filter,
    ignore_filter: ignore_filter,
    stable: options.flags[:stable])
  begin
    syncer.start_threads
    if options.flags[:json]
      syncer.standard_reporter.disable!
      syncer.upload_theme!(delete: delete)
    else
      CLI::UI::Frame.open(@ctx.message("theme.push.info.pushing", theme.name, theme.id, theme.shop)) do
        UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delete: delete)
      end
    end
    push_completion_handler(theme, syncer.has_any_error?)
  ensure
    syncer.shutdown
  end
rescue ShopifyCLI::API::APIRequestNotFoundError
  @ctx.abort(@ctx.message("theme.push.theme_not_found", "##{theme.id}"))
end