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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# 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"
if File.file?(composer_path)
say "Installing dependencies", :green
system "cd #{project_path}; composer install"
end
npm_path = "#{project_path}/package.json"
if File.file?(npm_path)
say "Installing npm dependencies", :green
system "cd #{project_path}; npm install"
end
bower_path = "#{project_path}/bower.json"
if File.file?(bower_path)
say "Installing bower dependencies", :green
system "cd #{project_path}; bower 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
version_path = "#{project_path}/VERSION.md"
if File.file?(version_path)
content = File.read(version_path)
min_version = Gem::Version.new('3.6')
project_version = Gem::Version.new(content)
if project_version > min_version
if project_version < Gem::Version.new('3.7')
path = "/install/cache/installed.txt"
elsif project_version <= Gem::Version.new('3.8')
path = "/src/Install/Cache/installed.txt"
end
if path
say "Creating installed.txt", :green
system "touch #{project_path}#{path}"
end
end
end
say "Change location to the project", :green
say "#{project_path}"
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
|