Sha256: 3b23d3c8e8dc73e846e7f62602d49efd6e1a9dff36a76d3ef212d3bdec186503

Contents?: true

Size: 943 Bytes

Versions: 3

Compression:

Stored size: 943 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)
        ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])

        api_key = ScriptProject.current.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: ShopifyCli::Project.current.env.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

3 entries across 3 versions & 1 rubygems

Version Path
shopify-cli-1.8.0 lib/project_types/script/commands/push.rb
shopify-cli-1.7.1 lib/project_types/script/commands/push.rb
shopify-cli-1.7.0 lib/project_types/script/commands/push.rb