Sha256: 0b2a8fd841d7d459995b3f8c1eaf6d8b403f514ff99cd3180d89c57f4ec7634e

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true
require "shopify_cli/theme/theme"

module Theme
  class Command
    class Publish < ShopifyCLI::Command::SubCommand
      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"),
            exclude_roles: ["live", "development", "demo"],
          )
          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

10 entries across 10 versions & 1 rubygems

Version Path
shopify-cli-2.10.2 lib/project_types/theme/commands/publish.rb
shopify-cli-2.10.1 lib/project_types/theme/commands/publish.rb
shopify-cli-2.10.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.9.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.8.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.7.4 lib/project_types/theme/commands/publish.rb
shopify-cli-2.7.3 lib/project_types/theme/commands/publish.rb
shopify-cli-2.7.2 lib/project_types/theme/commands/publish.rb
shopify-cli-2.7.1 lib/project_types/theme/commands/publish.rb
shopify-cli-2.7.0 lib/project_types/theme/commands/publish.rb