sumodev 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef48117fa94a767a3c5f55bfe2ed981e3a687944
4
- data.tar.gz: 3399aa8d52a219c5d19fc2a30ef2603a2f9198a5
3
+ metadata.gz: 75e56e45f005b1a47199fe2d1536b262e551e34a
4
+ data.tar.gz: e1e8d4cc9fc7d0d059d268bf162b00a029d4c783
5
5
  SHA512:
6
- metadata.gz: 05989af948f70252f4d8726ac3a2bc30376a6578d7edf41f929dfbdb5e0d6f7ddec7aa0c060cb5f160119f78b375cf948be677b10b2ab2f773803b00ec8ca755
7
- data.tar.gz: 96cb80380823c33a3af1019b55bc09f8012f61e9343707c0b0a391efca4db9706c71d91df5749a7f2cb88d05632354007d0e3c342b10900be87fa13e4e644b50
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*\"(.*?)\"").match(line)
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
- return false
69
+ raise "Field #{field} not found"
28
70
  end
29
- end
30
71
 
31
- def get(repo, stage="staging")
32
- say "Cloning repo #{repo}", :green
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
- tmp_path = File.expand_path(Sumodev::Config.get('SUMO_TEMP_PATH'));
78
+ def process_capfile(path)
79
+ unless File.file?(path)
80
+ raise "No Capfile found"
81
+ end
35
82
 
36
- system "rm -rf #{tmp_path}/temp_project"
37
- system "git clone -q #{repo} #{tmp_path}/temp_project > /dev/null"
83
+ content = File.read(path)
38
84
 
39
- capfile_path = "#{tmp_path}/temp_project/Capfile"
40
- if File.file?(capfile_path)
41
- content = File.read(capfile_path)
85
+ unless content.include?("set :client")
86
+ raise "No client found in the Capfile"
87
+ end
42
88
 
43
- if content.include?("set :client") and content.include?("set :project")
44
- client = get_client(capfile_path)
45
- project = get_project(capfile_path)
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
- if File.directory?(project_path)
50
- say "Project folder already exists, so can't continue", :red
51
- else
52
- say "Creating and moving everything into place", :green
53
- system "mkdir -p #{project_path}; cd #{project_path}"
54
- system "shopt -s dotglob; mv #{tmp_path}/temp_project/* #{project_path}"
55
-
56
- gemfile_path = "#{project_path}/Gemfile"
57
- if File.file?(gemfile_path)
58
- say "Installing gems", :green
59
- system "cd #{project_path}; bundle install"
60
- end
61
-
62
- composer_path = "#{project_path}/composer.json"
63
- if File.file?(composer_path)
64
- say "Installing dependencies", :green
65
- system "cd #{project_path}; composer install"
66
- end
67
-
68
- npm_path = "#{project_path}/package.json"
69
- if File.file?(npm_path)
70
- say "Installing npm dependencies", :green
71
- system "cd #{project_path}; npm install"
72
- end
73
-
74
- bower_path = "#{project_path}/bower.json"
75
- if File.file?(bower_path)
76
- say "Installing bower dependencies", :green
77
- system "cd #{project_path}; bower install"
78
- end
79
-
80
- say "Grabbing data", :green
81
- if File.file?(gemfile_path)
82
- system "cd #{project_path}; bundle exec cap #{stage} sumodev:db:get"
83
- system "cd #{project_path}; bundle exec cap #{stage} sumodev:files:get"
84
- else
85
- system "cd #{project_path}; cap #{stage} sumodev:db:get"
86
- system "cd #{project_path}; cap #{stage} sumodev:files:get"
87
- end
88
-
89
- version_path = "#{project_path}/VERSION.md"
90
- if File.file?(version_path)
91
- content = File.read(version_path)
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
- say "No client/project defined, so can't continue", :red
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
- else
119
- say "No Capfile, so can't continue", :red
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
@@ -1,3 +1,3 @@
1
1
  module Sumodev
2
- VERSION = "0.11.1"
2
+ VERSION = "0.12.0"
3
3
  end
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.11.1
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-04-23 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport