Class: Xing::CLI::Generators::NewProject

Inherits:
Object
  • Object
show all
Includes:
Caliph::CommandLineDSL
Defined in:
lib/xing/cli/generators/new_project.rb

Constant Summary collapse

BASE_PROJECT_URL =
"[email protected]:XingFramework/xing-application-base.git"

Instance Method Summary collapse

Instance Method Details

#generate(options) ⇒ Object

For the moment, this is the simplest thing that can work. Zero templating is done so the project will still have the default module names etc.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/xing/cli/generators/new_project.rb', line 11

def generate(options)
  shell = Caliph.new()
  command = cmd('git', 'clone', '--depth=1', '--branch=master', BASE_PROJECT_URL, options[:name])
  result = shell.run(command)

  if result.succeeded?
    remove_git_directory(options[:name], shell)
  else
    raise "Attempt to clone base git repository failed!"
  end
end

#remove_git_directory(name, shell) ⇒ Object



23
24
25
26
27
28
# File 'lib/xing/cli/generators/new_project.rb', line 23

def remove_git_directory(name, shell)
  git_dir = File.join("#{name}", ".git")
  if File.exists?(git_dir)
    shell.run(cmd('rm -rf', git_dir))
  end
end