31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/sumodev/commands/project.rb', line 31
def get(repo, stage="staging")
say "Cloning repo #{repo}", :green
tmp_path = File.expand_path(Sumodev::Config.get('SUMO_TEMP_PATH'));
system "rm -rf #{tmp_path}/temp_project"
system "git clone -q #{repo} #{tmp_path}/temp_project > /dev/null"
capfile_path = "#{tmp_path}/temp_project/Capfile"
if File.file?(capfile_path)
content = File.read(capfile_path)
if content.include?("set :client") and content.include?("set :project")
client = get_client(capfile_path)
project = get_project(capfile_path)
sites_path = File.expand_path(Sumodev::Config.get('SUMO_SITES_PATH'))
project_path = File.expand_path("#{sites_path}/#{client}/#{project}")
if File.directory?(project_path)
say "Project folder already exists, so can't continue", :red
else
say "Creating and moving everything into place", :green
system "mkdir -p #{project_path}; cd #{project_path}"
system "shopt -s dotglob; mv #{tmp_path}/temp_project/* #{project_path}"
gemfile_path = "#{project_path}/Gemfile"
if File.file?(gemfile_path)
say "Installing gems", :green
system "cd #{project_path}; bundle install"
end
composer_path = "#{project_path}/composer.json"
say if File.file?(composer_path)
say "Installing dependencies", :green
system "cd #{project_path}; composer install"
end
say "Grabbing data", :green
if File.file?(gemfile_path)
system "cd #{project_path}; bundle exec cap #{stage} sumodev:db:get"
system "cd #{project_path}; bundle exec cap #{stage} sumodev:files:get"
else
system "cd #{project_path}; cap #{stage} sumodev:db:get"
system "cd #{project_path}; cap #{stage} sumodev:files:get"
end
say "Change location to the project", :green
Dir.chdir project_path
say "All done", :green
end
else
say "No client/project defined, so can't continue", :red
end
else
say "No Capfile, so can't continue", :red
end
end
|