Sha256: 0c1816cfa52d450cc7ab00a7a40f10c7e1ac0dc992b70cea2bd1a0313c2e60ae

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

# frozen_string_literal: true

module Script
  module Commands
    class Push < ShopifyCli::Command
      options do |parser, flags|
        parser.on("--force") { |t| flags[:force] = t }
      end

      def call(_args, _name)
        Tasks::EnsureEnv.call(@ctx)

        api_key = Layers::Infrastructure::ScriptProjectRepository.new(ctx: @ctx).get.api_key
        return @ctx.puts(self.class.help) unless api_key

        Layers::Application::PushScript.call(ctx: @ctx, force: options.flags.key?(:force))
        @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
      rescue StandardError => e
        msg = @ctx.message("script.push.error.operation_failed", api_key: api_key)
        UI::ErrorHandler.pretty_print_and_raise(e, failed_op: msg)
      end

      def self.help
        ShopifyCli::Context.message("script.push.help", ShopifyCli::TOOL_NAME)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shopify-cli-1.13.0 lib/project_types/script/commands/push.rb
shopify-cli-1.12.0 lib/project_types/script/commands/push.rb
shopify-cli-1.11.0 lib/project_types/script/commands/push.rb
shopify-cli-1.10.0 lib/project_types/script/commands/push.rb