Sha256: ed042b978f334a4b0636a26ba553c8994857f2b5b722f21d6d4059f2af1ac0f8

Contents?: true

Size: 1.06 KB

Versions: 36

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Theme
  class Command
    class Init < ShopifyCLI::Command::SubCommand
      recommend_default_ruby_range

      options do |parser, flags|
        parser.on("-u", "--clone-url URL") { |url| flags[:clone_url] = url }
      end

      prerequisite_task :ensure_git_dependency

      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

36 entries across 36 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.35.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.34.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.33.1 lib/project_types/theme/commands/init.rb
shopify-cli-2.33.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.32.1 lib/project_types/theme/commands/init.rb
shopify-cli-2.32.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.31.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.30.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.29.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.28.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.27.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.26.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.25.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.24.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.23.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.22.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.21.0 lib/project_types/theme/commands/init.rb
shopify-cli-2.20.1 lib/project_types/theme/commands/init.rb
shopify-cli-2.20.0 lib/project_types/theme/commands/init.rb