Sha256: dd7ca7663fde8da10c4ad0eecf74486d3504066ee7c6f6c8ecf84abd83d895bd

Contents?: true

Size: 1000 Bytes

Versions: 10

Compression:

Stored size: 1000 Bytes

Contents

# frozen_string_literal: true

module Theme
  class Command
    class Init < ShopifyCLI::Command::SubCommand
      options do |parser, flags|
        parser.on("-u", "--clone-url URL") { |url| flags[:clone_url] = url }
      end

      DEFAULT_CLONE_URL = "https://github.com/Shopify/dawn.git"

      def call(args, _name)
        name = args.first || ask_name
        clone_url = options.flags[:clone_url] || DEFAULT_CLONE_URL
        clone(clone_url, name)
      end

      def self.help
        ShopifyCLI::Context.message("theme.init.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
      end

      private

      def ask_name
        CLI::UI::Prompt.ask(@ctx.message("theme.init.ask_name"))
      end

      def clone(url, name)
        ShopifyCLI::Git.clone(url, name)

        @ctx.root = File.join(@ctx.root, name)

        begin
          @ctx.rm_r(".git")
          @ctx.rm_r(".github")
        rescue Errno::ENOENT => e
          @ctx.debug(e)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shopify-cli-2.10.2 lib/project_types/theme/commands/init.rb
shopify-cli-2.10.1 lib/project_types/theme/commands/init.rb
shopify-cli-2.10.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.9.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.8.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.7.4 lib/project_types/theme/commands/init.rb
shopify-cli-2.7.3 lib/project_types/theme/commands/init.rb
shopify-cli-2.7.2 lib/project_types/theme/commands/init.rb
shopify-cli-2.7.1 lib/project_types/theme/commands/init.rb
shopify-cli-2.7.0 lib/project_types/theme/commands/init.rb