Sha256: 80617ea8ca58fe08b25deb85a64f53020958d4105fedc1a23185c399b823e490

Contents?: true

Size: 1003 Bytes

Versions: 32

Compression:

Stored size: 1003 Bytes

Contents

require "shopify_cli"
require "shopify_cli/theme/development_theme"

module ShopifyCLI
  module Commands
    class Logout < ShopifyCLI::Command
      def call(*)
        try_delete_development_theme
        ShopifyCLI::IdentityAuth.delete_tokens_and_keys
        ShopifyCLI::DB.del(:shop) if has_shop?
        ShopifyCLI::DB.del(:organization_id) if has_organization_id?
        ShopifyCLI::Shopifolk.reset
        @ctx.puts(@ctx.message("core.logout.success"))
      end

      def self.help
        ShopifyCLI::Context.message("core.logout.help", ShopifyCLI::TOOL_NAME)
      end

      private

      def has_shop?
        ShopifyCLI::DB.exists?(:shop)
      end

      def has_organization_id?
        ShopifyCLI::DB.exists?(:organization_id)
      end

      def try_delete_development_theme
        return unless has_shop?

        ShopifyCLI::Theme::DevelopmentTheme.delete(@ctx)
      rescue ShopifyCLI::API::APIRequestError
        # Ignore since we can't delete it
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
shopify-cli-2.7.3 lib/shopify_cli/commands/logout.rb
shopify-cli-2.7.2 lib/shopify_cli/commands/logout.rb
shopify-cli-2.7.1 lib/shopify_cli/commands/logout.rb
shopify-cli-2.7.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.6 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.5 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.4 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.3 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.2 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.1 lib/shopify_cli/commands/logout.rb
shopify-cli-2.6.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.5.0 lib/shopify_cli/commands/logout.rb