Sha256: 65d4336b7075e17a42b25acdd0d79f914b03959097b3fb008559d169a751f4e4

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true
require "shopify_cli/theme/theme"
require "project_types/theme/commands/common/shop_helper"

module Theme
  class Command
    class Publish < ShopifyCLI::Command::SubCommand
      include Common::ShopHelper

      recommend_default_ruby_range

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

      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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.35.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.34.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.33.1 lib/project_types/theme/commands/publish.rb
shopify-cli-2.33.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.32.1 lib/project_types/theme/commands/publish.rb
shopify-cli-2.32.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.31.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.30.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.29.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.28.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.27.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.26.0 lib/project_types/theme/commands/publish.rb