Sha256: d5b08da3460213c26c1f7deb4b983d3b00e691c79b6bdb80c7dbd4a26e9f60b7

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 KB

Contents

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

module Theme
  class Command
    class Publish < ShopifyCLI::Command::SubCommand
      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"),
            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

10 entries across 10 versions & 1 rubygems

Version Path
shopify-cli-2.25.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.24.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.23.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.22.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.21.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.20.1 lib/project_types/theme/commands/publish.rb
shopify-cli-2.20.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.19.0 lib/project_types/theme/commands/publish.rb
shopify-cli-2.18.1 lib/project_types/theme/commands/publish.rb
shopify-cli-2.18.0 lib/project_types/theme/commands/publish.rb