Sha256: fe2e3c4d2fb487eb3af250a7cc58997bd527ab7ba7ca85805af0b118792582ba

Contents?: true

Size: 1.33 KB

Versions: 23

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require "shopify_cli/theme/theme"
require "shopify_cli/theme/syncer"
require "project_types/theme/commands/common/root_helper"

module Theme
  class Command
    class Share < ShopifyCLI::Command::SubCommand
      include Common::RootHelper

      recommend_default_ruby_range

      def call(_args, name)
        root = root_value(options, name)
        theme = create_theme(root)

        upload(theme)

        @ctx.done(done_message(theme))
      end

      def self.help
        tool = ShopifyCLI::TOOL_NAME
        @ctx.message("theme.share.help", tool, tool)
      end

      private

      def create_theme(root)
        ShopifyCLI::Theme::Theme.create_unpublished(@ctx, root: root)
      end

      def upload(theme)
        syncer = ShopifyCLI::Theme::Syncer.new(@ctx, theme: theme)
        syncer.start_threads

        CLI::UI::Frame.open(upload_message(theme)) do
          UI::SyncProgressBar.new(syncer).progress(:upload_theme!)
        end

        raise ShopifyCLI::AbortSilent if syncer.has_any_error?
      ensure
        syncer.shutdown
      end

      def upload_message(theme)
        @ctx.message("theme.share.upload", theme.name, theme.id, theme.shop)
      end

      def done_message(theme)
        @ctx.message("theme.share.done", theme.name, theme.preview_url, theme.editor_url)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
shopify-cli-2.31.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.30.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.29.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.28.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.27.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.26.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.25.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.24.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.23.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.22.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.21.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.20.1 lib/project_types/theme/commands/share.rb
shopify-cli-2.20.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.19.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.18.1 lib/project_types/theme/commands/share.rb
shopify-cli-2.18.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.17.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.16.1 lib/project_types/theme/commands/share.rb
shopify-cli-2.16.0 lib/project_types/theme/commands/share.rb
shopify-cli-2.15.6 lib/project_types/theme/commands/share.rb