kdeploy 1.0.8 → 1.1.0

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: 71b80d4b4cf5194def86c21793e7a284f524288f06e215fd6d44f0fa408dfe18
4
- data.tar.gz: d8f28a18304adc12256633567c872d1368a29a644c9e4b1f2cdd44e5ba3d9413
3
+ metadata.gz: 361d3e4177d88e983400481dbfcbd8ae4c3e6e4f7964e547cdfb9fbdf333ba6c
4
+ data.tar.gz: d9c0aa6de6a5741f15cc175dffdc247903b4070fbd3ccfe66bb39bdcf8d52181
5
5
  SHA512:
6
- metadata.gz: f2e3a70987d5390dc53c4c68091533dfb6f8e9e9b695f03aeaa5c5e1c48c7d646cac698ac5760bb30d5a32a7c1b0ee51ca720e2d9507253d87b2ac01ea0a19ce
7
- data.tar.gz: b6908b7720edda9e4ff81a2b5f2d679e5ffe7774d62d33de91dd191b5773590020ec49c43b45d58d520da6d7ef6193bca6120e6b7dd1d46b84344081081d80fa
6
+ metadata.gz: b24732771d9e0cbee179aeffcc83b2c3f99a9711c4730b00b33a7a7536ac5cf362dbf8462940c91a0314c4bb7b2547880c04dd402e6b2eba36ca355aa7973657
7
+ data.tar.gz: b64dcf2f6498fd6b5f6d53c1738dbe719be7d033925e8e0b046bd5a6be5d2d93915e87ac4860079bb356d080b1e4170ec5398f10309dc0e2733c2a40147a3f46
data/lib/kdeploy/cli.rb CHANGED
@@ -221,11 +221,23 @@ module Kdeploy
221
221
 
222
222
  # summary
223
223
  puts pastel.cyan("\nPLAY RECAP #{'*' * 64}")
224
+ max_host_len = results.keys.map(&:length).max || 16
224
225
  results.each do |host, result|
225
226
  ok = %i[success changed].include?(result[:status]) ? result[:output].size : 0
226
227
  failed = result[:status] == :failed ? 1 : 0
227
228
  changed = result[:status] == :changed ? result[:output].size : 0
228
- puts "#{host.ljust(24)} : ok=#{ok} changed=#{changed} failed=#{failed}"
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)}")
232
+ line = "#{host.ljust(max_host_len)} : #{ok_str} #{changed_str} #{failed_str}"
233
+ case result[:status]
234
+ when :success
235
+ puts pastel.green(line)
236
+ when :changed
237
+ puts pastel.yellow(line)
238
+ else
239
+ puts pastel.red(line)
240
+ end
229
241
  end
230
242
  end
231
243
  end
@@ -21,21 +21,49 @@ module Kdeploy
21
21
  executor = Executor.new(config)
22
22
  result = { status: :success, output: [] }
23
23
 
24
- task[:block].call.each do |command|
25
- case command[:type]
26
- when :run
27
- puts "[#{name}] $ #{command[:command].lines.first.strip}" # 实时输出主机和命令
28
- command[:command].lines[1..].each { |line| puts "[#{name}] > #{line.strip}" unless line.strip.empty? }
29
- output = executor.execute(command[:command])
30
- result[:output] << { command: command[:command], output: output }
31
- when :upload
32
- puts "[#{name}] upload: #{command[:source]} -> #{command[:destination]}"
33
- executor.upload(command[:source], command[:destination])
34
- result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
35
- when :upload_template
36
- puts "[#{name}] upload_template: #{command[:source]} -> #{command[:destination]}"
37
- executor.upload_template(command[:source], command[:destination], command[:variables])
38
- result[:output] << { command: "upload_template: #{command[:source]} -> #{command[:destination]}" }
24
+ task[:block].call.group_by do |cmd|
25
+ cmd[:type].to_s + (if cmd[:type] == :upload
26
+ cmd[:source].to_s
27
+ else
28
+ cmd[:type] == :run ? cmd[:command].to_s.lines.first.strip : ''
29
+ end)
30
+ end.each_value do |commands|
31
+ # 生成 TASK 横幅
32
+ pastel = Pastel.new
33
+ first_cmd = commands.first
34
+ task_desc = case first_cmd[:type]
35
+ when :upload
36
+ "upload #{first_cmd[:source]}"
37
+ when :upload_template
38
+ "template #{first_cmd[:source]}"
39
+ when :run
40
+ first_cmd[:command].to_s.lines.first.strip
41
+ else
42
+ first_cmd[:type].to_s
43
+ end
44
+ puts pastel.cyan("\nTASK [#{task_desc}] " + ('*' * 64))
45
+ commands.each do |command|
46
+ case command[:type]
47
+ when :run
48
+ pastel = Pastel.new
49
+ puts pastel.bright_white("\n#{name.ljust(24)} : ")
50
+ puts pastel.cyan(" [run] #{command[:command].lines.first.strip}")
51
+ command[:command].lines[1..].each { |line| puts " > #{line.strip}" unless line.strip.empty? }
52
+ output = executor.execute(command[:command])
53
+ result[:output] << { command: command[:command], output: output }
54
+ when :upload
55
+ pastel = Pastel.new
56
+ puts pastel.bright_white("\n#{name.ljust(24)} : ")
57
+ puts pastel.green(" [upload] #{command[:source]} -> #{command[:destination]}")
58
+ executor.upload(command[:source], command[:destination])
59
+ result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
60
+ when :upload_template
61
+ pastel = Pastel.new
62
+ puts pastel.bright_white("\n#{name.ljust(24)} : ")
63
+ puts pastel.yellow(" [template] #{command[:source]} -> #{command[:destination]}")
64
+ executor.upload_template(command[:source], command[:destination], command[:variables])
65
+ result[:output] << { command: "upload_template: #{command[:source]} -> #{command[:destination]}" }
66
+ end
39
67
  end
40
68
  end
41
69
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.0.8'
4
+ VERSION = '1.1.0'
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.0.8
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk