Sha256: d8db89bc4ad66eab3a756747f1d7573739768a67f8725ec4e4bddf1d2a06f4b9

Contents?: true

Size: 868 Bytes

Versions: 57

Compression:

Stored size: 868 Bytes

Contents

require "shopify_cli"

module ShopifyCLI
  class Connect
    def initialize(ctx)
      @ctx = ctx
    end

    def default_connect(project_type)
      if Project.current&.env
        @ctx.puts(@ctx.message("core.connect.already_connected_warning"))
      end
      org = ShopifyCLI::Tasks::EnsureEnv.call(@ctx, regenerate: true)
      write_cli_yml(project_type, org["id"]) unless Project.has_current?
      api_key = Project.current(force_reload: true).env["api_key"]
      get_app(org["apps"], api_key).first["title"]
    end

    def write_cli_yml(project_type, org_id)
      ShopifyCLI::Project.write(
        @ctx,
        project_type: project_type,
        organization_id: org_id,
      )
      @ctx.done(@ctx.message("core.connect.cli_yml_saved"))
    end

    def get_app(apps, api_key)
      apps.select { |app| app["apiKey"] == api_key }
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
shopify-cli-2.19.0 lib/shopify_cli/connect.rb
shopify-cli-2.18.1 lib/shopify_cli/connect.rb
shopify-cli-2.18.0 lib/shopify_cli/connect.rb
shopify-cli-2.17.0 lib/shopify_cli/connect.rb
shopify-cli-2.16.1 lib/shopify_cli/connect.rb
shopify-cli-2.16.0 lib/shopify_cli/connect.rb
shopify-cli-2.15.6 lib/shopify_cli/connect.rb
shopify-cli-2.15.5 lib/shopify_cli/connect.rb
shopify-cli-2.15.4 lib/shopify_cli/connect.rb
shopify-cli-2.15.3 lib/shopify_cli/connect.rb
shopify-cli-2.15.2 lib/shopify_cli/connect.rb
shopify-cli-2.15.1 lib/shopify_cli/connect.rb
shopify-cli-2.15.0 lib/shopify_cli/connect.rb
shopify-cli-2.14.0 lib/shopify_cli/connect.rb
shopify-cli-2.13.0 lib/shopify_cli/connect.rb
shopify-cli-2.12.0 lib/shopify_cli/connect.rb
shopify-cli-2.11.2 lib/shopify_cli/connect.rb
shopify-cli-2.11.1 lib/shopify_cli/connect.rb
shopify-cli-2.11.0 lib/shopify_cli/connect.rb
shopify-cli-2.10.2 lib/shopify_cli/connect.rb