Class: Extension::Command::Push

Inherits:
ShopifyCLI::Command::SubCommand show all
Defined in:
lib/project_types/extension/commands/push.rb

Constant Summary collapse

TIME_DISPLAY_FORMAT =
"%B %d, %Y %H:%M:%S %Z"

Instance Attribute Summary

Attributes inherited from ShopifyCLI::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

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



58
59
60
# File 'lib/project_types/extension/commands/push.rb', line 58

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

Instance Method Details

#call(args, name) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/project_types/extension/commands/push.rb', line 21

def call(args, name)
  project = Extension::Loaders::Project.load(
    context: @ctx,
    directory: Dir.pwd,
    api_key: options.flags[:api_key],
    api_secret: options.flags[:api_secret],
    registration_id: options.flags[:registration_id]
  )
  # on ci, registration id must be present
  registration_id = options.flags[:registration_id]
  check_registration(registration_id: registration_id, context: @ctx)

  specification_handler = Extension::Loaders::SpecificationHandler.load(project: project, context: @ctx)
  register_if_necessary(project: project, args: args, name: name)

  Command::Build.new(@ctx).call(args, name) unless specification_handler.specification.options[:skip_build]
  CLI::UI::Frame.open(@ctx.message("push.frame_title")) do
    updated_draft_version = update_draft(project: project, specification_handler: specification_handler)
    show_message(updated_draft_version, project: project)
  end
end

#check_registration(registration_id:, context:) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/project_types/extension/commands/push.rb', line 49

def check_registration(registration_id:, context:)
  if !ShopifyCLI::Environment.interactive? && (!registration_id || registration_id.empty?)
    message = context.message("errors.missing_push_options_ci", "--registration-id")
    message += context.message("errors.missing_push_options_ci_solution", ShopifyCLI::TOOL_NAME)
    raise ShopifyCLI::Abort,
      message
  end
end

#register_if_necessary(project:, args:, name:) ⇒ Object



43
44
45
46
47
# File 'lib/project_types/extension/commands/push.rb', line 43

def register_if_necessary(project:, args:, name:)
  if ShopifyCLI::Environment.interactive? && !project.registered?
    Command::Register.new(@ctx).call(args, name)
  end
end