kdeploy 1.1.2 → 1.1.4
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/kdeploy/cli.rb +39 -18
- data/lib/kdeploy/runner.rb +15 -5
- data/lib/kdeploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab3017f4d6818b4e46db9bfa55414452a87f71bc7d13dda423c34fab995262a
|
4
|
+
data.tar.gz: 26b691b159c54d5d438573c539454ddd58c0d0aa6063cd18cac4469bb873d9b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205246f7917997566e83cd15eacaad6d497aaf0ca6fb99de778277786abb0a71233f3782feb4f822efc7a023c0fad80f9193e9bcd970883ed2c523475d30e597
|
7
|
+
data.tar.gz: f0fa8718a2646fa053c3d3bb662b773cdf6c1e9f42e6a36f137f9a74bdb97bdef060832c745cec37883e026d5c3f367ee5f6587a4b51a338be76ab3827d0e779
|
data/lib/kdeploy/cli.rb
CHANGED
@@ -188,20 +188,37 @@ module Kdeploy
|
|
188
188
|
puts pastel.bright_white("\n#{host.ljust(24)} : #{status}")
|
189
189
|
|
190
190
|
if %i[success changed].include?(result[:status])
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
191
|
+
shown = {}
|
192
|
+
grouped = result[:output].group_by { |step| step[:type] || :run }
|
193
|
+
grouped.each do |type, steps|
|
194
|
+
case type
|
195
|
+
when :upload
|
196
|
+
puts pastel.green(' === Upload ===')
|
197
|
+
when :upload_template
|
198
|
+
puts pastel.yellow(' === Template ===')
|
199
|
+
when :run
|
200
|
+
puts pastel.cyan(' === Run ===')
|
201
|
+
end
|
202
|
+
steps.each do |step|
|
203
|
+
key = [step[:command], step[:output]].hash
|
204
|
+
next if shown[key]
|
205
|
+
|
206
|
+
shown[key] = true
|
207
|
+
duration_str = step[:duration] ? pastel.dim(" [#{'%.2f' % step[:duration]}s]") : ''
|
208
|
+
if step[:command].to_s.start_with?('upload:')
|
209
|
+
puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}#{duration_str}")
|
210
|
+
elsif step[:command].to_s.start_with?('upload_template:')
|
211
|
+
puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}#{duration_str}")
|
212
|
+
else
|
213
|
+
puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}#{duration_str}")
|
214
|
+
if step[:output].is_a?(Hash) && step[:output][:stdout]
|
215
|
+
step[:output][:stdout].each_line do |line|
|
216
|
+
puts " #{line.rstrip}" unless line.strip.empty?
|
217
|
+
end
|
218
|
+
elsif step[:output].is_a?(String)
|
219
|
+
step[:output].each_line do |line|
|
220
|
+
puts " #{line.rstrip}" unless line.strip.empty?
|
221
|
+
end
|
205
222
|
end
|
206
223
|
end
|
207
224
|
end
|
@@ -222,13 +239,17 @@ module Kdeploy
|
|
222
239
|
# summary
|
223
240
|
puts pastel.cyan("\nPLAY RECAP #{'*' * 64}")
|
224
241
|
max_host_len = results.keys.map(&:length).max || 16
|
225
|
-
|
242
|
+
ok_w = 7
|
243
|
+
changed_w = 11
|
244
|
+
failed_w = 10
|
245
|
+
results.keys.sort.each do |host|
|
246
|
+
result = results[host]
|
226
247
|
ok = %i[success changed].include?(result[:status]) ? result[:output].size : 0
|
227
248
|
failed = result[:status] == :failed ? 1 : 0
|
228
249
|
changed = result[:status] == :changed ? result[:output].size : 0
|
229
|
-
ok_str = pastel.green("ok=#{ok.to_s.ljust(3)}")
|
230
|
-
changed_str = pastel.yellow("changed=#{changed.to_s.ljust(
|
231
|
-
failed_str = pastel.red("failed=#{failed.to_s.ljust(
|
250
|
+
ok_str = pastel.green("ok=#{ok.to_s.ljust(ok_w - 3)}")
|
251
|
+
changed_str = pastel.yellow("changed=#{changed.to_s.ljust(changed_w - 8)}")
|
252
|
+
failed_str = pastel.red("failed=#{failed.to_s.ljust(failed_w - 7)}")
|
232
253
|
line = "#{host.ljust(max_host_len)} : #{ok_str} #{changed_str} #{failed_str}"
|
233
254
|
if failed.positive?
|
234
255
|
puts pastel.red(line)
|
data/lib/kdeploy/runner.rb
CHANGED
@@ -49,27 +49,37 @@ module Kdeploy
|
|
49
49
|
puts pastel.bright_white("\n#{name.ljust(24)} : ")
|
50
50
|
puts pastel.cyan(" [run] #{command[:command].lines.first.strip}")
|
51
51
|
command[:command].lines[1..].each { |line| puts " > #{line.strip}" unless line.strip.empty? }
|
52
|
+
t1 = Time.now
|
52
53
|
output = executor.execute(command[:command])
|
54
|
+
t2 = Time.now
|
55
|
+
duration = t2 - t1
|
53
56
|
# 统一输出命令结果
|
54
57
|
if output[:stdout] && !output[:stdout].empty?
|
55
58
|
output[:stdout].each_line { |line| puts " #{line.rstrip}" unless line.strip.empty? }
|
56
59
|
end
|
57
60
|
if output[:stderr] && !output[:stderr].empty?
|
58
|
-
output[:stderr].each_line { |line| puts pastel.
|
61
|
+
output[:stderr].each_line { |line| puts pastel.green(" #{line.rstrip}") unless line.strip.empty? }
|
59
62
|
end
|
60
|
-
result[:output] << { command: command[:command], output: output }
|
63
|
+
result[:output] << { command: command[:command], output: output, duration: duration, type: :run }
|
61
64
|
when :upload
|
62
65
|
pastel = Pastel.new
|
63
66
|
puts pastel.bright_white("\n#{name.ljust(24)} : ")
|
64
67
|
puts pastel.green(" [upload] #{command[:source]} -> #{command[:destination]}")
|
68
|
+
t1 = Time.now
|
65
69
|
executor.upload(command[:source], command[:destination])
|
66
|
-
|
70
|
+
t2 = Time.now
|
71
|
+
duration = t2 - t1
|
72
|
+
result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}", duration: duration, type: :upload }
|
67
73
|
when :upload_template
|
68
74
|
pastel = Pastel.new
|
69
75
|
puts pastel.bright_white("\n#{name.ljust(24)} : ")
|
70
76
|
puts pastel.yellow(" [template] #{command[:source]} -> #{command[:destination]}")
|
71
|
-
|
72
|
-
|
77
|
+
t1 = Time.now
|
78
|
+
executor.upload_template(command[:source], command[:destination], command[:vars])
|
79
|
+
t2 = Time.now
|
80
|
+
duration = t2 - t1
|
81
|
+
result[:output] << { command: "upload_template: #{command[:source]} -> #{command[:destination]}", duration: duration,
|
82
|
+
type: :upload_template }
|
73
83
|
end
|
74
84
|
end
|
75
85
|
end
|
data/lib/kdeploy/version.rb
CHANGED