luban 0.9.14 → 0.9.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b48ab79759b45ca7eb28235f9fc0304494de75a1
4
- data.tar.gz: 1fdd55e4c8908e2beeb10a3b8ac7e96a03de8de2
3
+ metadata.gz: 33000a33b27913c0433ef4a5c597ea5586b111cf
4
+ data.tar.gz: 1ce53ac76b5ad8fe85c6ec3552b0506db817223c
5
5
  SHA512:
6
- metadata.gz: 48eeeed19d760c788ac0430214ff36033eaf94db0d42db075949f07fb9491ee8417fbe1d2c9fd2388883a6cf1388611eedb58a98d71edd61f13bafcd0b2c0700
7
- data.tar.gz: 2bdc3adacaad25386a30be00d59667c41cb5c011b85e25d6bcedc0fc474b98dd5c45e8aa07c75424591e5b9894ab36a5be2c507c6a400706813ceade898ea6fb
6
+ metadata.gz: 90e6d4a88b8336bea742037a7415dacaa0955e3aff0be3c4f64246e395211559b689fecd80bab9dd47dd404deec7c0247a731731a3ab524579e0fa785efdbb27
7
+ data.tar.gz: 90ef31818a038040f3d784fe310aaa6bafb6a6da0b0d5e214b6e63ffdb1bfd401f254f023b23b5b0a26f5b6c98bf05deba4ffa1485f2190896a3ebfce348064c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.9.15 (Nov 06, 2016)
4
+
5
+ Minor enhancements:
6
+ * Refactored md5 calculation utilities
7
+
8
+ Bug fixes:
9
+ * Properly synced git-based bundled gems to app servers
10
+
3
11
  ## Version 0.9.14 (Oct 31, 2016)
4
12
 
5
13
  Minor enhancements:
@@ -85,7 +85,7 @@ module Luban
85
85
 
86
86
  def after_publish
87
87
  create_symlinks
88
- bundle_gems unless gems.empty?
88
+ bundle_gems unless locked_gemfile.nil?
89
89
  end
90
90
 
91
91
  protected
@@ -167,13 +167,14 @@ module Luban
167
167
  end
168
168
 
169
169
  def sync_gems_cache
170
- capture(:ls, '-xt', gems_cache_path).split.each do |gem_name|
171
- rm(gems_cache_path.join(gem_name)) unless gems.has_key?(gem_name)
172
- end
173
170
  gems.each_pair do |gem_name, md5|
174
171
  gem_path = gems_cache_path.join(gem_name)
175
172
  unless md5_matched?(gem_path, md5)
176
- upload!(gems_source.join(gem_name).to_s, gem_path.to_s)
173
+ if file?(gem_file = gems_source[:path].join(gem_name))
174
+ upload!(gem_file.to_s, gem_path.to_s)
175
+ else
176
+ upload!("#{gem_file.to_s}/", gem_path.to_s, recursive: true)
177
+ end
177
178
  end
178
179
  end
179
180
  end
@@ -23,6 +23,10 @@ module Luban
23
23
  @workspace_path ||= app_path.join('.luban')
24
24
  end
25
25
 
26
+ def gems_path
27
+ @gems_path ||= workspace_path.join('gems')
28
+ end
29
+
26
30
  def clone_path
27
31
  @clone_path ||= workspace_path.join('repositories', type)
28
32
  end
@@ -170,46 +174,58 @@ module Luban
170
174
  end
171
175
  end
172
176
 
177
+ def release_with_gemfile?(gemfile_path)
178
+ test(:tar, "-tzf #{release_package_path} #{gemfile_path} > /dev/null 2>&1")
179
+ end
180
+
173
181
  def bundle_gems
174
182
  gemfile_path = Pathname.new(release_tag).join('Gemfile')
175
183
  gems_cache = Pathname.new('vendor').join('cache')
176
184
  bundle_path = Pathname.new('vendor').join('bundle')
185
+ if release_with_gemfile?(gemfile_path)
186
+ assure_dirs(gems_path)
187
+ bundle_gems!(gemfile_path, gems_cache, bundle_path)
188
+ else
189
+ {}
190
+ end
191
+ end
192
+
193
+ def bundle_gems!(gemfile_path, gems_cache, bundle_path)
177
194
  bundled_gems = {}
178
195
  gems = bundled_gems[:gems] = {}
179
- if test(:tar, "-tzf #{release_package_path} #{gemfile_path} > /dev/null 2>&1")
180
- within(workspace_path) do
181
- paths_to_extract = [gemfile_path, "#{gemfile_path}.lock", "#{release_tag}/vendor/gems"]
182
- execute(:tar, "--strip-components=1 -xzf #{release_package_path} #{paths_to_extract.join(' ')} > /dev/null 2>&1; true")
183
- options = []
184
- options << "--path #{bundle_path}"
185
- unless test(bundle_cmd, :check, *options)
186
- unless bundle_without.include?(stage.to_s)
187
- options << "--without #{bundle_without.join(' ')}"
188
- end
189
- options << "--quiet"
190
- execute(bundle_cmd, :install, *options)
191
- info "Package gems bundled in Gemfile"
192
- execute(bundle_cmd, :package, "--all --quiet")
193
- end
194
- gem_files = capture(:ls, '-xt', gems_cache.join('*.gem')).split
195
- gem_files.each do |gem_file|
196
- gem_name = File.basename(gem_file)
197
- md5_file = "#{gem_file}.md5"
198
- gems[gem_name] =
199
- if file?(workspace_path.join(md5_file))
200
- gems[gem_name] = capture(:cat, md5_file)
201
- else
202
- md5_for_file(gem_file).tap { |md5|
203
- execute(:echo, "#{md5} > #{md5_file}")
204
- }
205
- end
196
+ within(gems_path) do
197
+ paths_to_extract = [gemfile_path, "#{gemfile_path}.lock", "#{release_tag}/vendor/gems"]
198
+ execute(:tar, "--strip-components=1 -xzf #{release_package_path} #{paths_to_extract.join(' ')} > /dev/null 2>&1; true")
199
+ options = []
200
+ options << "--path #{bundle_path}"
201
+ unless test(bundle_cmd, :check, *options)
202
+ unless bundle_without.include?(stage.to_s)
203
+ options << "--without #{bundle_without.join(' ')}"
206
204
  end
205
+ options << "--quiet"
206
+ execute(bundle_cmd, :install, *options)
207
+ info "Package gems bundled in Gemfile"
208
+ execute(bundle_cmd, :package, "--all --quiet")
207
209
  end
208
- bundled_gems[:gems_cache] = workspace_path.join(gems_cache)
209
- workspace_path.join('Gemfile.lock').tap do |p|
210
- bundled_gems[:locked_gemfile] = { path: p, md5: md5_for_file(p) }
210
+
211
+ gem_files = capture(:ls, '-xtd', "#{gems_cache.join('*')} | grep -v \"md5$\"").split
212
+ gem_files.each do |gem_file|
213
+ gem_name = File.basename(gem_file)
214
+ md5_file = "#{gem_file}.md5"
215
+ gems[gem_name] =
216
+ if file?(md5_file)
217
+ gems[gem_name] = capture(:cat, md5_file)
218
+ else
219
+ md5_for(gem_file).tap { |md5| execute(:echo, "#{md5} > #{md5_file}") }
220
+ end
211
221
  end
212
222
  end
223
+ gems_path.join(gems_cache).tap do |p|
224
+ bundled_gems[:gems_cache] = { path: p, md5: md5_for_dir(p) }
225
+ end
226
+ gems_path.join('Gemfile.lock').tap do |p|
227
+ bundled_gems[:locked_gemfile] = { path: p, md5: md5_for_file(p) }
228
+ end
213
229
  bundled_gems
214
230
  end
215
231
  end
@@ -88,10 +88,19 @@ module Luban
88
88
  capture("$(type -p readlink greadlink|head -1) #{source_file}")
89
89
  end
90
90
 
91
+ def md5_for(path)
92
+ file?(path) ? md5_for_file(path) : md5_for_dir(path)
93
+ end
94
+
91
95
  def md5_for_file(file)
92
96
  capture(:cat, "#{file} 2>/dev/null | openssl md5")[/\h+$/]
93
97
  end
94
98
 
99
+ def md5_for_dir(dir)
100
+ #capture(:tar, "-cf - #{dir} 2>/dev/null | openssl md5")[/\h+$/]
101
+ capture(:find, "#{dir} -type f 2>/dev/null | LC_ALL=C sort -u | xargs cat | openssl md5")[/\h+$/]
102
+ end
103
+
95
104
  def sudo(*args)
96
105
  execute(:sudo, *args)
97
106
  end
@@ -165,8 +174,8 @@ module Luban
165
174
  backend.capture(*args, raise_on_non_zero_exit: false, &blk).chomp
166
175
  end
167
176
 
168
- def md5_matched?(file_path, md5)
169
- file?(file_path) and md5 == md5_for_file(file_path)
177
+ def md5_matched?(path, md5)
178
+ file?(path) ? md5 == md5_for_file(path) : md5 == md5_for_dir(path)
170
179
  end
171
180
 
172
181
  #def execute(*args, &blk)
@@ -1,5 +1,5 @@
1
1
  module Luban
2
2
  module Deployment
3
- VERSION = "0.9.14"
3
+ VERSION = "0.9.15"
4
4
  end
5
5
  end
@@ -43,7 +43,7 @@ module Luban
43
43
  end
44
44
 
45
45
  def current_app_path
46
- @app_symlink ||= app_path.join('app')
46
+ @current_app_path ||= app_path.join('app')
47
47
  end
48
48
 
49
49
  def app_bin_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.9.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubyist Lei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban-cli