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.36.0 lib/shopify_cli/connect.rb
shopify-cli-2.35.0 lib/shopify_cli/connect.rb
shopify-cli-2.34.0 lib/shopify_cli/connect.rb
shopify-cli-2.33.1 lib/shopify_cli/connect.rb
shopify-cli-2.33.0 lib/shopify_cli/connect.rb
shopify-cli-2.32.1 lib/shopify_cli/connect.rb
shopify-cli-2.32.0 lib/shopify_cli/connect.rb
shopify-cli-2.31.0 lib/shopify_cli/connect.rb
shopify-cli-2.30.0 lib/shopify_cli/connect.rb
shopify-cli-2.29.0 lib/shopify_cli/connect.rb
shopify-cli-2.28.0 lib/shopify_cli/connect.rb
shopify-cli-2.27.0 lib/shopify_cli/connect.rb
shopify-cli-2.26.0 lib/shopify_cli/connect.rb
shopify-cli-2.25.0 lib/shopify_cli/connect.rb
shopify-cli-2.24.0 lib/shopify_cli/connect.rb
shopify-cli-2.23.0 lib/shopify_cli/connect.rb
shopify-cli-2.22.0 lib/shopify_cli/connect.rb
shopify-cli-2.21.0 lib/shopify_cli/connect.rb
shopify-cli-2.20.1 lib/shopify_cli/connect.rb
shopify-cli-2.20.0 lib/shopify_cli/connect.rb