sumodev 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sumodev/commands/project.rb +153 -85
- data/lib/sumodev/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75e56e45f005b1a47199fe2d1536b262e551e34a
|
4
|
+
data.tar.gz: e1e8d4cc9fc7d0d059d268bf162b00a029d4c783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b9d0ea709daf3d8b2b5509e81d912cccfc6d62792029a46db9fde01b8df611847f95322bcaacc5011966ac8dd448544174246d3f8f8d8f815dc96d27fd68f12
|
7
|
+
data.tar.gz: 9d9020a6c3246fdeaa32828005acd57e69789c0357fb6a99f9cf919fd96bf828cbbf275c3969d6a319cd877460d002c622ed21b46edab8df421bc7b47c053bbe
|
@@ -4,7 +4,49 @@ require 'sumodev/config'
|
|
4
4
|
class Sumodev::Commands::Project < Sumodev::Command
|
5
5
|
namespace :project
|
6
6
|
|
7
|
+
option :only_clone, :type => :boolean, :default => false, :desc => "only clone the project"
|
8
|
+
option :bundles, :type => :boolean, :default => true, :desc => "install bundles"
|
9
|
+
option :node_modules, :type => :boolean, :default => true, :desc => "install node-modules"
|
10
|
+
option :bower, :type => :boolean, :default => true, :desc => "install bower packages"
|
11
|
+
option :composer, :type => :boolean, :default => true, :desc => "install composer packages"
|
12
|
+
option :composer_run_scripts, :type => :boolean, :default => true, :desc => "run composer scripts"
|
13
|
+
option :fetch_data, :type => :boolean, :default => true, :desc => "fetch the data"
|
14
|
+
option :mark_as_installed, :type => :boolean, :default => true, :desc => "mark the Fork install as installed"
|
15
|
+
option :project_path, :desc => "the path where the project should be placed"
|
16
|
+
|
7
17
|
desc 'get REPO stage', "fetches a project"
|
18
|
+
def get(repo, stage="staging")
|
19
|
+
begin
|
20
|
+
tmp_path = File.expand_path(Sumodev::Config.get('SUMO_TEMP_PATH'));
|
21
|
+
capfile_path = "#{tmp_path}/temp_project/Capfile"
|
22
|
+
sites_path = File.expand_path(Sumodev::Config.get('SUMO_SITES_PATH'))
|
23
|
+
|
24
|
+
clone_repo(repo, "#{tmp_path}/temp_project")
|
25
|
+
|
26
|
+
if options[:project_path].nil?
|
27
|
+
client, project = process_capfile(capfile_path)
|
28
|
+
project_path = File.expand_path("#{sites_path}/#{client}/#{project}")
|
29
|
+
else
|
30
|
+
project_path = File.expand_path(options[:project_path])
|
31
|
+
end
|
32
|
+
|
33
|
+
move_project("#{tmp_path}/temp_project", project_path)
|
34
|
+
|
35
|
+
if !options[:only_clone]
|
36
|
+
install_bundles(project_path) if options[:bundles]
|
37
|
+
install_node_modules(project_path) if options[:node_modules]
|
38
|
+
install_bower_packages(project_path) if options[:bower]
|
39
|
+
install_composer_packages(project_path, options[:composer_run_scripts]) if options[:composer]
|
40
|
+
fetch_data(project_path, stage) if options[:fetch_data]
|
41
|
+
mark_as_installed(project_path) if options[:mark_as_installed]
|
42
|
+
end
|
43
|
+
|
44
|
+
change_location(project_path)
|
45
|
+
say "All done", :green
|
46
|
+
rescue Exception => e
|
47
|
+
say e.message, :red
|
48
|
+
end
|
49
|
+
end
|
8
50
|
|
9
51
|
no_commands do
|
10
52
|
def get_client(path)
|
@@ -18,105 +60,131 @@ class Sumodev::Commands::Project < Sumodev::Command
|
|
18
60
|
def get_var(path, field)
|
19
61
|
File.readlines(path).each do |line|
|
20
62
|
# match = Regexp.new(":''#{field},\s*\"(.*?)\"").match(line)
|
21
|
-
match = Regexp.new(":#{field},\s
|
63
|
+
match = Regexp.new(":#{field},\s*[\"|\'](.*?)[\"|\']").match(line)
|
22
64
|
if match != nil && match.length > 0
|
23
65
|
return match[1]
|
24
66
|
end
|
25
67
|
end
|
26
68
|
|
27
|
-
|
69
|
+
raise "Field #{field} not found"
|
28
70
|
end
|
29
|
-
end
|
30
71
|
|
31
|
-
|
32
|
-
|
72
|
+
def clone_repo(repo, destination)
|
73
|
+
say "Cloning repo #{repo}", :green
|
74
|
+
system "rm -rf #{destination}"
|
75
|
+
system "git clone -q #{repo} #{destination} > /dev/null"
|
76
|
+
end
|
33
77
|
|
34
|
-
|
78
|
+
def process_capfile(path)
|
79
|
+
unless File.file?(path)
|
80
|
+
raise "No Capfile found"
|
81
|
+
end
|
35
82
|
|
36
|
-
|
37
|
-
system "git clone -q #{repo} #{tmp_path}/temp_project > /dev/null"
|
83
|
+
content = File.read(path)
|
38
84
|
|
39
|
-
|
40
|
-
|
41
|
-
|
85
|
+
unless content.include?("set :client")
|
86
|
+
raise "No client found in the Capfile"
|
87
|
+
end
|
42
88
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
sites_path = File.expand_path(Sumodev::Config.get('SUMO_SITES_PATH'))
|
47
|
-
project_path = File.expand_path("#{sites_path}/#{client}/#{project}")
|
89
|
+
unless content.include?("set :project")
|
90
|
+
raise "No project found in the Capfile"
|
91
|
+
end
|
48
92
|
|
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
|
-
min_version = Gem::Version.new('3.6')
|
93
|
-
project_version = Gem::Version.new(content)
|
94
|
-
|
95
|
-
if project_version > min_version
|
96
|
-
if project_version < Gem::Version.new('3.7')
|
97
|
-
path = "/install/cache/installed.txt"
|
98
|
-
elsif project_version <= Gem::Version.new('3.8')
|
99
|
-
path = "/src/Install/Cache/installed.txt"
|
100
|
-
end
|
101
|
-
|
102
|
-
if path
|
103
|
-
say "Creating installed.txt", :green
|
104
|
-
system "touch #{project_path}#{path}"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
say "Change location to the project", :green
|
110
|
-
say "#{project_path}"
|
111
|
-
Dir.chdir project_path # @todo defv this doesn't work
|
112
|
-
|
113
|
-
say "All done", :green
|
114
|
-
end
|
93
|
+
return [
|
94
|
+
get_client(path),
|
95
|
+
get_project(path)
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
def install_bundles(path)
|
100
|
+
unless File.file?("#{path}/Gemfile")
|
101
|
+
return
|
102
|
+
end
|
103
|
+
|
104
|
+
say "Installing gems", :green
|
105
|
+
system "cd #{path}; bundle install"
|
106
|
+
end
|
107
|
+
|
108
|
+
def install_node_modules(path)
|
109
|
+
unless File.file?("#{path}/package.json")
|
110
|
+
return
|
111
|
+
end
|
112
|
+
|
113
|
+
say "Installing node modules", :green
|
114
|
+
system "cd #{path}; npm install"
|
115
|
+
end
|
116
|
+
|
117
|
+
def install_bower_packages(path)
|
118
|
+
unless File.file?("#{path}/bower.json")
|
119
|
+
return
|
120
|
+
end
|
121
|
+
|
122
|
+
say "Installing bower packages", :green
|
123
|
+
system "cd #{path}; bower install"
|
124
|
+
end
|
125
|
+
|
126
|
+
def install_composer_packages(path, run_scripts)
|
127
|
+
unless File.file?("#{path}/composer.json")
|
128
|
+
puts "foo"
|
129
|
+
return
|
130
|
+
end
|
131
|
+
|
132
|
+
say "Installing dependencies", :green
|
133
|
+
|
134
|
+
if run_scripts
|
135
|
+
system "cd #{path}; composer install"
|
115
136
|
else
|
116
|
-
|
137
|
+
system "cd #{path}; composer install --no-scripts"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def move_project(source, destination)
|
142
|
+
if File.directory?(destination)
|
143
|
+
raise "Project folder already exists."
|
117
144
|
end
|
118
|
-
|
119
|
-
say "
|
145
|
+
|
146
|
+
say "Creating and moving everything into place", :green
|
147
|
+
system "mkdir -p #{destination}; cd #{destination}"
|
148
|
+
system "shopt -s dotglob; mv #{source}/* #{destination}"
|
149
|
+
end
|
150
|
+
|
151
|
+
def fetch_data(path, stage)
|
152
|
+
say "Grabbing data", :green
|
153
|
+
|
154
|
+
if File.file?("#{path}/Gemfile")
|
155
|
+
system "cd #{path}; bundle exec cap #{stage} sumodev:db:get"
|
156
|
+
system "cd #{path}; bundle exec cap #{stage} sumodev:files:get"
|
157
|
+
else
|
158
|
+
system "cd #{path}; cap #{stage} sumodev:db:get"
|
159
|
+
system "cd #{path}; cap #{stage} sumodev:files:get"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def mark_as_installed(path)
|
164
|
+
unless File.file?("#{path}/VERSION.md")
|
165
|
+
return
|
166
|
+
end
|
167
|
+
|
168
|
+
content = File.read(version_path)
|
169
|
+
min_version = Gem::Version.new('3.6')
|
170
|
+
project_version = Gem::Version.new(content)
|
171
|
+
|
172
|
+
if project_version > min_version
|
173
|
+
if project_version < Gem::Version.new('3.7')
|
174
|
+
file_path = "/install/cache/installed.txt"
|
175
|
+
elsif project_version <= Gem::Version.new('3.8')
|
176
|
+
file_path = "/src/Install/Cache/installed.txt"
|
177
|
+
end
|
178
|
+
|
179
|
+
if file_path
|
180
|
+
say "Creating installed.txt", :green
|
181
|
+
system "touch #{path}#{file_path}"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def change_location(destination)
|
187
|
+
say "Your project is located in:\n#{destination}"
|
120
188
|
end
|
121
189
|
end
|
122
190
|
end
|
data/lib/sumodev/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sumodev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan De Poorter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|