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 +4 -4
- data/CHANGELOG +4 -0
- data/lib/capistrano/recipes/deploy/assets.rb +42 -20
- data/lib/capistrano/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f526bf77fa9d58f9e652b765e48011b3aec097b6
|
4
|
+
data.tar.gz: ac5aac5e993b29a865778972655061a693e0f1c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 092d19bf6fd529d8793e0f6058c9679c626d222a1d0dc22888cb5eb3cae2d427a28d92b7f90196ceab23d14bb7064747e44bdbe67106cd3d9462b9ecfd970033
|
7
|
+
data.tar.gz: 1a7564b0f8b876511cd37854177f9bd49265f77c08841fbc871797209f4aea2c95e8e87d1563819115ce1a9dee0285c5d4cb8a2eb8d339ed076ff29e85728285
|
data/CHANGELOG
CHANGED
@@ -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
|
-
|
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
|
61
|
-
|
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
|
65
|
-
|
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
|
123
|
+
# Fetch all assets_manifest contents.
|
101
124
|
manifests_output = capture <<-CMD.compact
|
102
|
-
for manifest in #{releases_path.shellescape}/*/assets_manifest
|
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
|
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
|
134
|
+
logger.info "Fetched #{manifests.count} manifests from #{releases_path}/*/assets_manifest.*"
|
112
135
|
current_assets = Set.new
|
113
|
-
manifests.each do |
|
114
|
-
|
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 +=
|
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
|
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.
|
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} #{
|
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
|
data/lib/capistrano/version.rb
CHANGED