Class: FluidCLI::Commands::Theme::Push

Inherits:
FluidCLI::Command show all
Includes:
Common::CompanyHelper, Common::RootHelper
Defined in:
lib/fluid_cli/commands/theme/push.rb

Constant Summary

Constants included from Common::RootHelper

Common::RootHelper::REQUIRED_FOLDERS

Instance Attribute Summary

Attributes inherited from FluidCLI::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::CompanyHelper

#company

Methods included from Common::RootHelper

#exist_and_not_empty?, #root_value, #valid_theme_directory?

Methods inherited from FluidCLI::Command

call, call_help, #initialize, options, subcommand, subcommand_registry

Constructor Details

This class inherits a constructor from FluidCLI::Command

Class Method Details

.helpObject



67
68
69
# File 'lib/fluid_cli/commands/theme/push.rb', line 67

def self.help
  "Pushes local theme files to a company's theme."
end

Instance Method Details

#call(_args, name) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fluid_cli/commands/theme/push.rb', line 31

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

  development_theme_id = options.flags[:development_theme_id]
  FluidCLI::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

  syncer = FluidCLI::Theme::Syncer.new(@ctx, theme: theme, force: options.flags[:force])
  begin
    syncer.start_threads
    if options.flags[:json]
      syncer.standard_reporter.disable!
      syncer.upload_theme!(delete: delete)
    else
      CLI::UI::Frame.open("Pushing #{theme.name} (##{theme.id}) to #{theme.company}") do
        FluidCLI::Theme::UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delete: delete)
      end
    end
    push_completion_handler(theme, syncer.has_any_error?)
  ensure
    syncer.shutdown
  end
rescue FluidCLI::API::APIRequestNotFoundError
  @ctx.abort("No theme found with ID: ##{theme.id}")
end