Sha256: 1867e3f93a51e75e4fd95d12508f387518c65a347452b2df13a16d3f7698fea4

Contents?: true

Size: 1020 Bytes

Versions: 25

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

require "shopify_cli/thread_pool"

require_relative "app_extensions/job"

module ShopifyCLI
  class PartnersAPI
    class AppExtensions
      class << self
        def fetch_apps_extensions(ctx, org, type)
          jobs = apps(org).map { |app| AppExtensions::Job.new(ctx, app, type) }

          consume_jobs!(jobs)
          patch_apps_with_extensions!(jobs)

          org
        end

        private

        def apps(org)
          (org && org["apps"]) || []
        end

        def consume_jobs!(jobs)
          thread_pool = ShopifyCLI::ThreadPool.new(pool_size: 1)
          jobs.each do |job|
            thread_pool.schedule(job)
          end
          thread_pool.shutdown

          raise_if_any_error(jobs)
        end

        def patch_apps_with_extensions!(jobs)
          jobs.each(&:patch_app_with_extensions!)
        end

        def raise_if_any_error(jobs)
          jobs.find(&:error?).tap { |job| raise job.error if job }
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.35.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.34.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.33.1 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.33.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.32.1 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.32.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.31.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.30.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.29.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.28.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.27.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.26.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.25.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.24.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.23.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.22.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.21.0 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.20.1 lib/shopify_cli/partners_api/app_extensions.rb
shopify-cli-2.20.0 lib/shopify_cli/partners_api/app_extensions.rb