capistrano 2.15.0 → 2.15.1

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: 01115be3e8ab363fc0f9555eb6e3504e3e6eb709
4
- data.tar.gz: 9b8b1fc5f765d23f5a336f25c28c2a3078793806
3
+ metadata.gz: f526bf77fa9d58f9e652b765e48011b3aec097b6
4
+ data.tar.gz: ac5aac5e993b29a865778972655061a693e0f1c7
5
5
  SHA512:
6
- metadata.gz: 85916614f98a4f4d0f816b9ad2689e952fe05ec7ec3db49ff83e4ff08423c9d6b9e7a57cb84bdd401020172548a842ecf6bcc8458ed27438d3b9d727401dc8a0
7
- data.tar.gz: 9283b6c3631fe2be2884b826141be26944a6b1d4037a2f036c8fed81ed8e776a7fc02c80ffa2a353e97ac084fe793c7429410c95df9dd5dc82c0fdfd1adebcfc
6
+ metadata.gz: 092d19bf6fd529d8793e0f6058c9679c626d222a1d0dc22888cb5eb3cae2d427a28d92b7f90196ceab23d14bb7064747e44bdbe67106cd3d9462b9ecfd970033
7
+ data.tar.gz: 1a7564b0f8b876511cd37854177f9bd49265f77c08841fbc871797209f4aea2c95e8e87d1563819115ce1a9dee0285c5d4cb8a2eb8d339ed076ff29e85728285
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.15.1 / April 23 2013
2
+
3
+ * Support for Rails 4 (and other) randomised asset manifest names. (@jimryan)
4
+
1
5
  ## 2.15.0 / April 23 2013
2
6
 
3
7
  * New varaible :shared_assets_prefix to allow people to host somewhere other
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  load 'deploy' unless defined?(_cset)
2
4
 
3
5
  _cset :asset_env, "RAILS_GROUPS=assets"
@@ -14,6 +16,18 @@ before 'deploy:assets:precompile', 'deploy:assets:update_asset_mtimes'
14
16
  after 'deploy:cleanup', 'deploy:assets:clean_expired'
15
17
  after 'deploy:rollback:revision', 'deploy:assets:rollback'
16
18
 
19
+ def shared_manifest_path
20
+ @shared_manifest_path ||= capture("ls #{shared_path.shellescape}/#{shared_assets_prefix}/manifest*").strip
21
+ end
22
+
23
+ # Parses manifest and returns array of uncompressed and compressed asset filenames with and without digests
24
+ # "Intelligently" determines format of string - supports YAML and JSON
25
+ def parse_manifest(str)
26
+ assets_hash = str[0,1] == '{' ? JSON.parse(str)['assets'] : YAML.load(str)
27
+
28
+ assets_hash.to_a.flatten.map {|a| [a, "#{a}.gz"] }.flatten
29
+ end
30
+
17
31
  namespace :deploy do
18
32
  namespace :assets do
19
33
  desc <<-DESC
@@ -47,8 +61,19 @@ namespace :deploy do
47
61
  task :precompile, :roles => lambda { assets_role }, :except => { :no_release => true } do
48
62
  run <<-CMD.compact
49
63
  cd -- #{latest_release} &&
50
- #{rake} RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} assets:precompile &&
51
- cp -- #{shared_path.shellescape}/#{shared_assets_prefix}/manifest.yml #{current_release.to_s.shellescape}/assets_manifest.yml
64
+ #{rake} RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} assets:precompile
65
+ CMD
66
+
67
+ # Sync manifest filenames across servers if our manifest has a random filename
68
+ if shared_manifest_path =~ /manifest-.+\./
69
+ run <<-CMD.compact
70
+ [ -e #{shared_manifest_path.shellescape} ] || mv -- #{shared_path.shellescape}/#{shared_assets_prefix}/manifest* #{shared_manifest_path.shellescape}
71
+ CMD
72
+ end
73
+
74
+ # Copy manifest to release root (for clean_expired task)
75
+ run <<-CMD.compact
76
+ cp -- #{shared_manifest_path.shellescape} #{current_release.to_s.shellescape}/assets_manifest#{File.extname(shared_manifest_path)}
52
77
  CMD
53
78
  end
54
79
 
@@ -57,13 +82,11 @@ namespace :deploy do
57
82
  This task runs before assets:precompile.
58
83
  DESC
59
84
  task :update_asset_mtimes, :roles => lambda { assets_role }, :except => { :no_release => true } do
60
- # Fetch assets/manifest.yml contents.
61
- manifest_path = "#{shared_path}/#{shared_assets_prefix}/manifest.yml"
62
- manifest_yml = capture("[ -e #{manifest_path.shellescape} ] && cat #{manifest_path.shellescape} || echo").strip
85
+ # Fetch assets/manifest contents.
86
+ manifest_content = capture("[ -e #{shared_path.shellescape}/#{shared_assets_prefix}/manifest* ] && cat #{shared_path.shellescape}/#{shared_assets_prefix}/manifest* || echo").strip
63
87
 
64
- if manifest_yml != ""
65
- manifest = YAML.load(manifest_yml)
66
- current_assets = manifest.to_a.flatten.map {|a| [a, "#{a}.gz"] }.flatten
88
+ if manifest_content != ""
89
+ current_assets = parse_manifest(manifest_content)
67
90
  logger.info "Updating mtimes for ~#{current_assets.count} assets..."
68
91
  put current_assets.map{|a| "#{shared_path}/#{shared_assets_prefix}/#{a}" }.join("\n"), "#{deploy_to}/TOUCH_ASSETS", :via => :scp
69
92
  run <<-CMD.compact
@@ -97,24 +120,23 @@ namespace :deploy do
97
120
  an existing release.
98
121
  DESC
99
122
  task :clean_expired, :roles => lambda { assets_role }, :except => { :no_release => true } do
100
- # Fetch all assets_manifest.yml contents.
123
+ # Fetch all assets_manifest contents.
101
124
  manifests_output = capture <<-CMD.compact
102
- for manifest in #{releases_path.shellescape}/*/assets_manifest.yml; do
125
+ for manifest in #{releases_path.shellescape}/*/assets_manifest.*; do
103
126
  cat -- "$manifest" 2> /dev/null && printf ':::' || true;
104
127
  done
105
128
  CMD
106
129
  manifests = manifests_output.split(':::')
107
130
 
108
131
  if manifests.empty?
109
- logger.info "No manifests in #{releases_path}/*/assets_manifest.yml"
132
+ logger.info "No manifests in #{releases_path}/*/assets_manifest.*"
110
133
  else
111
- logger.info "Fetched #{manifests.count} manifests from #{releases_path}/*/assets_manifest.yml"
134
+ logger.info "Fetched #{manifests.count} manifests from #{releases_path}/*/assets_manifest.*"
112
135
  current_assets = Set.new
113
- manifests.each do |yaml|
114
- manifest = YAML.load(yaml)
115
- current_assets += manifest.to_a.flatten.map {|f| [f, "#{f}.gz"] }.flatten
136
+ manifests.each do |content|
137
+ current_assets += parse_manifest(content)
116
138
  end
117
- current_assets += %w(manifest.yml sources_manifest.yml)
139
+ current_assets += [File.basename(shared_manifest_path), "sources_manifest.yml"]
118
140
 
119
141
  # Write the list of required assets to server.
120
142
  logger.info "Writing required assets to #{deploy_to}/REQUIRED_ASSETS..."
@@ -144,18 +166,18 @@ namespace :deploy do
144
166
 
145
167
  desc <<-DESC
146
168
  Rolls back assets to the previous release by symlinking the release's manifest
147
- to shared/assets/manifest.yml, and finally recompiling or regenerating nondigest assets.
169
+ to shared/assets/manifest, and finally recompiling or regenerating nondigest assets.
148
170
  DESC
149
171
  task :rollback, :roles => lambda { assets_role }, :except => { :no_release => true } do
150
- previous_manifest = "#{previous_release}/assets_manifest.yml"
172
+ previous_manifest = capture("ls #{previous_release.shellescape}/assets_manifest.*").strip
151
173
  if capture("[ -e #{previous_manifest.shellescape} ] && echo true || echo false").strip != 'true'
152
174
  puts "#{previous_manifest} is missing! Cannot roll back assets. " <<
153
175
  "Please run deploy:assets:precompile to update your assets when the rollback is finished."
154
176
  else
155
177
  run <<-CMD.compact
156
178
  cd -- #{previous_release.shellescape} &&
157
- cp -f -- #{previous_manifest.shellescape} #{shared_path.shellescape}/#{shared_assets_prefix}/manifest.yml &&
158
- #{rake} RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} assets:precompile:nondigest
179
+ cp -f -- #{previous_manifest.shellescape} #{shared_manifest_path.shellescape} &&
180
+ [ -z "$(#{rake} -P | grep assets:precompile:nondigest)" ] || #{rake} RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} assets:precompile:nondigest
159
181
  CMD
160
182
  end
161
183
  end
@@ -2,7 +2,7 @@ module Capistrano
2
2
  class Version
3
3
  MAJOR = 2
4
4
  MINOR = 15
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  def self.to_s
8
8
  "#{MAJOR}.#{MINOR}.#{PATCH}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.0
4
+ version: 2.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck