Class: Theme::Command::Publish

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

Instance Attribute Summary

Attributes inherited from ShopifyCLI::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

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



44
45
46
# File 'lib/project_types/theme/commands/publish.rb', line 44

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

Instance Method Details

#call(args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/project_types/theme/commands/publish.rb', line 16

def call(args, *)
  theme = if (theme_id = args.first)
    ShopifyCLI::Theme::Theme.new(@ctx, id: theme_id)
  else
    form = Forms::Select.ask(
      @ctx,
      [],
      title: @ctx.message("theme.publish.select", shop),
      exclude_roles: ["live", "development", "demo"],
      cmd: :publish
    )
    return unless form
    form.theme
  end

  return unless Forms::ConfirmStore.ask(
    @ctx,
    [],
    title: @ctx.message("theme.publish.confirm", theme.name, theme.shop),
    force: options.flags[:force],
  ).confirmed?

  theme.publish
  @ctx.done(@ctx.message("theme.publish.done", theme.preview_url))
rescue ShopifyCLI::API::APIRequestNotFoundError
  @ctx.puts(@ctx.message("theme.publish.not_found", theme.id))
end