Sha256: c647c0312b35a8d9f97b80266fef6bb3f6f8c581f65e912e73a786806655ed24

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

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, ShopifyCLI::Abort, ShopifyCLI::AbortSilent
        # Ignore since we can't delete it
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-2.24.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.23.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.22.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.21.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.20.1 lib/shopify_cli/commands/logout.rb
shopify-cli-2.20.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.19.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.18.1 lib/shopify_cli/commands/logout.rb
shopify-cli-2.18.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.17.0 lib/shopify_cli/commands/logout.rb
shopify-cli-2.16.1 lib/shopify_cli/commands/logout.rb