kdeploy 1.1.3 → 1.1.5

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: 9583a9a5362b5bf116325f3e9f930ff19be72c76d82060869284921079f93b19
4
+ data.tar.gz: cbfa824d6defd7511a71d985073de549442a34ed4e165093e422543e33c1e321
5
5
  SHA512:
6
- metadata.gz: e03245531beafbb2010b4e00a466aea4e5f756b60628ce2206355387046ae70a2ec0aca1ec1a0e7243a2b240d9cf569168b243a9e67cea637fef0f5e0f26428e
7
- data.tar.gz: 129aa8dc62528d63bb99d0e60af780fc241691daafeb3fcb51940d4f2355902fca068d3bbcd60c0f2bd487228f859f58145f279c695c813b5f32d0f48ec4fb90
6
+ metadata.gz: b20ac3a10b3de646fe5c23a96cebae09a0fb825fde88b3698a3a7beb2715abf7e05076ca2b4cc04715ee54935053cb23d1b392f8f726af79c15c244c7bed32a7
7
+ data.tar.gz: 446eb1df1186929fc9576e55b558c869b01cfa7466f53a09e65836a59b365b5e3cb88bf98616393efd9181d84bc08b45b7e8348f89fa07ee75d5b9a53f9af173
data/lib/kdeploy/cli.rb CHANGED
@@ -189,24 +189,46 @@ 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
+ steps.each do |step|
198
+ key = [step[:command], type].hash
199
+ next if shown[key]
200
+
201
+ shown[key] = true
202
+ duration_str = step[:duration] ? pastel.dim(" [#{'%.2f' % step[:duration]}s]") : ''
203
+ puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}#{duration_str}")
204
+ end
205
+ when :upload_template
206
+ puts pastel.yellow(' === Template ===')
207
+ steps.each do |step|
208
+ key = [step[:command], type].hash
209
+ next if shown[key]
210
+
211
+ shown[key] = true
212
+ duration_str = step[:duration] ? pastel.dim(" [#{'%.2f' % step[:duration]}s]") : ''
213
+ puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}#{duration_str}")
214
+ end
215
+ when :run
216
+ puts pastel.cyan(' === Run ===')
217
+ steps.each do |step|
218
+ key = [step[:command], type].hash
219
+ next if shown[key]
220
+
221
+ shown[key] = true
222
+ duration_str = step[:duration] ? pastel.dim(" [#{'%.2f' % step[:duration]}s]") : ''
223
+ puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}#{duration_str}")
224
+ if step[:output].is_a?(Hash) && step[:output][:stdout]
225
+ step[:output][:stdout].each_line do |line|
226
+ puts " #{line.rstrip}" unless line.strip.empty?
227
+ end
228
+ elsif step[:output].is_a?(String)
229
+ step[:output].each_line do |line|
230
+ puts " #{line.rstrip}" unless line.strip.empty?
231
+ end
210
232
  end
211
233
  end
212
234
  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.5'
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk