Sha256: 2087728da7c5dd1fa4412e29a8d45449f1fdc890f183c41bea18072952b5232e

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Script
  class Command
    class Push < ShopifyCLI::SubCommand
      prerequisite_task ensure_project_type: :script

      options do |parser, flags|
        parser.on("--force") { |t| flags[:force] = t }
      end

      def call(_args, _name)
        fresh_env = Tasks::EnsureEnv.call(@ctx)
        force = options.flags.key?(:force) || !!fresh_env

        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: force)
        @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
      rescue StandardError => e
        msg = if api_key
          @ctx.message("script.push.error.operation_failed_with_api_key", api_key: api_key)
        else
          @ctx.message("script.push.error.operation_failed_no_api_key")
        end
        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

8 entries across 8 versions & 1 rubygems

Version Path
shopify-cli-2.6.6 lib/project_types/script/commands/push.rb
shopify-cli-2.6.5 lib/project_types/script/commands/push.rb
shopify-cli-2.6.4 lib/project_types/script/commands/push.rb
shopify-cli-2.6.3 lib/project_types/script/commands/push.rb
shopify-cli-2.6.2 lib/project_types/script/commands/push.rb
shopify-cli-2.6.1 lib/project_types/script/commands/push.rb
shopify-cli-2.6.0 lib/project_types/script/commands/push.rb
shopify-cli-2.5.0 lib/project_types/script/commands/push.rb