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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a20ba2b482ea270782499a512f4058f1b022f2733d185f2e002f58c1d402b44
4
- data.tar.gz: 8fdce45af09af95b3bff7c89d20c742853945e500837a804c09f4932865b7f66
3
+ metadata.gz: 8ab3017f4d6818b4e46db9bfa55414452a87f71bc7d13dda423c34fab995262a
4
+ data.tar.gz: 26b691b159c54d5d438573c539454ddd58c0d0aa6063cd18cac4469bb873d9b9
5
5
  SHA512:
6
- metadata.gz: 3c2f0ac8ea5f4bbf6442c597a54ae5d9b64b7255430636803d1533a1cd0f33e8a58e4d0a673d902a0ad0c83f95eccea7e6ad2f5a091b45d4cbf9334ebddd7bf0
7
- data.tar.gz: 269d74c398731804261ee871adca6f2df7f1a4fb88371cd9111831f257693e2fa1170618f032b3f56e9b7c51ee0ce30fee90e33dc3b8be0ec00f8a6c032af086
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
- result[:output].each do |step|
192
- if step[:command].to_s.start_with?('upload:')
193
- puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}")
194
- elsif step[:command].to_s.start_with?('upload_template:')
195
- puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}")
196
- else
197
- puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}")
198
- if step[:output].is_a?(Hash) && step[:output][:stdout]
199
- step[:output][:stdout].each_line do |line|
200
- puts " > #{line.strip}" unless line.strip.empty?
201
- end
202
- elsif step[:output].is_a?(String)
203
- step[:output].each_line do |line|
204
- puts " > #{line.strip}" unless line.strip.empty?
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
- results.each do |host, result|
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(3)}")
231
- failed_str = pastel.red("failed=#{failed.to_s.ljust(3)}")
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)
@@ -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.cyan(" #{line.rstrip}") unless line.strip.empty? }
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
- result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
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
- executor.upload_template(command[:source], command[:destination], command[:variables])
72
- result[:output] << { command: "upload_template: #{command[:source]} -> #{command[:destination]}" }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.1.2'
4
+ VERSION = '1.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk