Sha256: aaa95f3fe9e00bf8d68fec2e458fb0db1cdc2e2f49b254197d7a4745477e4721

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true
module Extension
  class Command
    class Connect < ExtensionCommand
      prerequisite_task :ensure_authenticated

      def call(args, _)
        with_connect_form(args) do |form|
          ExtensionProject.write_env_file(
            context: @ctx,
            api_key: form.app.api_key,
            api_secret: form.app.secret,
            registration_id: form.registration.id,
            registration_uuid: form.registration.uuid,
            title: form.registration.title
          )
          @ctx.done(@ctx.message("connect.connected", form.app.title, form.registration.title))
        end
      end

      def self.help
        ShopifyCli::Context.new.message("connect.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
      end

      private

      def with_connect_form(args)
        form = Forms::Connect.ask(@ctx, args, { type: specification_handler.identifier.downcase })
        return @ctx.puts(self.class.help) if form.nil?

        yield form
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shopify-cli-2.4.0 lib/project_types/extension/commands/connect.rb
shopify-cli-2.3.0 lib/project_types/extension/commands/connect.rb
shopify-cli-2.2.2 lib/project_types/extension/commands/connect.rb
shopify-cli-2.2.1 lib/project_types/extension/commands/connect.rb
shopify-cli-2.2.0 lib/project_types/extension/commands/connect.rb
shopify-cli-2.1.0 lib/project_types/extension/commands/connect.rb
shopify-cli-2.0.2 lib/project_types/extension/commands/connect.rb
shopify-cli-2.0.1 lib/project_types/extension/commands/connect.rb
shopify-cli-2.0.0 lib/project_types/extension/commands/connect.rb