kdeploy 1.1.3 → 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: fb093825d57b14ed8e603e760f2561b6b0e78d3ffb907efd11fbb0a6eddb069e
4
- data.tar.gz: 679556c416416a010fca552c5dbbf656961dbbd8dc3a90180261a4f4addf9409
3
+ metadata.gz: 8ab3017f4d6818b4e46db9bfa55414452a87f71bc7d13dda423c34fab995262a
4
+ data.tar.gz: 26b691b159c54d5d438573c539454ddd58c0d0aa6063cd18cac4469bb873d9b9
5
5
  SHA512:
6
- metadata.gz: e03245531beafbb2010b4e00a466aea4e5f756b60628ce2206355387046ae70a2ec0aca1ec1a0e7243a2b240d9cf569168b243a9e67cea637fef0f5e0f26428e
7
- data.tar.gz: 129aa8dc62528d63bb99d0e60af780fc241691daafeb3fcb51940d4f2355902fca068d3bbcd60c0f2bd487228f859f58145f279c695c813b5f32d0f48ec4fb90
6
+ metadata.gz: 205246f7917997566e83cd15eacaad6d497aaf0ca6fb99de778277786abb0a71233f3782feb4f822efc7a023c0fad80f9193e9bcd970883ed2c523475d30e597
7
+ data.tar.gz: f0fa8718a2646fa053c3d3bb662b773cdf6c1e9f42e6a36f137f9a74bdb97bdef060832c745cec37883e026d5c3f367ee5f6587a4b51a338be76ab3827d0e779
data/lib/kdeploy/cli.rb CHANGED
@@ -189,24 +189,36 @@ module Kdeploy
189
189
 
190
190
  if %i[success changed].include?(result[:status])
191
191
  shown = {}
192
- result[:output].each do |step|
193
- key = [step[:command], step[:output]].hash
194
- next if shown[key]
195
-
196
- shown[key] = true
197
- if step[:command].to_s.start_with?('upload:')
198
- puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}")
199
- elsif step[:command].to_s.start_with?('upload_template:')
200
- puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}")
201
- else
202
- puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}")
203
- if step[:output].is_a?(Hash) && step[:output][:stdout]
204
- step[:output][:stdout].each_line do |line|
205
- puts " #{line.rstrip}" unless line.strip.empty?
206
- end
207
- elsif step[:output].is_a?(String)
208
- step[:output].each_line do |line|
209
- puts " #{line.rstrip}" unless line.strip.empty?
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
210
222
  end
211
223
  end
212
224
  end
@@ -49,7 +49,10 @@ 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? }
@@ -57,19 +60,26 @@ module Kdeploy
57
60
  if output[:stderr] && !output[:stderr].empty?
58
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.3'
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.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk