Sha256: d1aae2564765dadaf47a017a7b9eb82aea09a9e55bc03ba2644abc52e499b1b4

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

require 'shopify_cli'

module ShopifyCli
  module Tasks
    class EnsureDevStore < ShopifyCli::Task
      def call(ctx)
        @ctx = ctx
        return ctx.puts(ctx.message(
          'core.tasks.ensure_dev_store.could_not_verify_store', project.env.shop
        )) if shop.nil?
        return if shop['transferDisabled'] == true
        return unless CLI::UI::Prompt.confirm(
          ctx.message('core.tasks.ensure_dev_store.convert_to_dev_store', project.env.shop)
        )
        ShopifyCli::PartnersAPI.query(ctx, 'convert_dev_to_test_store', input: {
          organizationID: shop['orgID'].to_i,
          shopId: shop['shopId'],
        })
        ctx.puts(ctx.message('core.tasks.ensure_dev_store.transfer_disabled', project.env.shop))
      end

      private

      def project
        @project ||= ShopifyCli::Project.current
      end

      def shop
        @shop ||= begin
          current_domain = project.env.shop
          ShopifyCli::PartnersAPI::Organizations.fetch_all(@ctx).map do |org|
            org['stores'].find do |store|
              store['orgID'] = org['id']
              store['shopDomain'] == current_domain
            end
          end.compact.first
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shopify-cli-1.6.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.5.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.4.1 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.4.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.3.1 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.3.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.2.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.1.2 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.1.1 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.1.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.0.5 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.0.4 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.0.3 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.0.2 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.0.1 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-1.0.0 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-0.9.3 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-0.9.2 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-0.9.1 lib/shopify-cli/tasks/ensure_dev_store.rb
shopify-cli-0.9.0 lib/shopify-cli/tasks/ensure_dev_store.rb