kdeploy 1.0.9 → 1.1.1

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: '079548e82a360553e00c1aecb5967fd7d57320dbf5d89684a992885444e0e5ac'
4
- data.tar.gz: 4b639818b4116f7111fe44ef3d983abf8fdc0c24ac0ee558f35e09d9d3592722
3
+ metadata.gz: 0203e26e85d3910ae62da516f229355cc3c19f360f2dd56abfda06e616195258
4
+ data.tar.gz: 20ab1369c1b7906d6fbe51191c7b999e617e65f1572014ada58eb12f52f5b143
5
5
  SHA512:
6
- metadata.gz: f07494332413308f446e39e91f75f856ee1b0484c662ac299d2c2300e01b5ece8d32e072cd727371b53d0542df48a1e8678d0de5889696b09903bda6438005a5
7
- data.tar.gz: 91ecd8ede72319bf7693424fe6e2efcee9f9ddb7e82ce2db28ae52f69ed622ec57ba019c49c70d3a7aacbc5357b02d4b5c9861dc294fdd4b15e55540b324fa83
6
+ metadata.gz: 912c3c3eb78ac13a8294f1e1468875bbc45a375701e6312054a51afb37e986eb7bb85061efe16f44a2ed48e2421235b47eedb2f9db6aee8616640e314610bb8c
7
+ data.tar.gz: 2e502450ba52305c98b294fd0bde975f494d066e9720bcbd504f13b61a9cc6d21930f0b510874e2e18bc27bb637c6d092401a1e13f9f18503e10febe0b2caa69
data/lib/kdeploy/cli.rb CHANGED
@@ -229,7 +229,14 @@ module Kdeploy
229
229
  ok_str = pastel.green("ok=#{ok.to_s.ljust(3)}")
230
230
  changed_str = pastel.yellow("changed=#{changed.to_s.ljust(3)}")
231
231
  failed_str = pastel.red("failed=#{failed.to_s.ljust(3)}")
232
- puts "#{host.ljust(max_host_len)} : #{ok_str} #{changed_str} #{failed_str}"
232
+ line = "#{host.ljust(max_host_len)} : #{ok_str} #{changed_str} #{failed_str}"
233
+ if failed.positive?
234
+ puts pastel.red(line)
235
+ elsif ok.positive? && failed.zero?
236
+ puts pastel.green(line)
237
+ else
238
+ puts line
239
+ end
233
240
  end
234
241
  end
235
242
  end
@@ -24,12 +24,10 @@ module Kdeploy
24
24
  raise "Could not execute command: #{command}" unless success
25
25
 
26
26
  channel.on_data do |_ch, data|
27
- print data # 实时输出
28
27
  stdout << data
29
28
  end
30
29
 
31
30
  channel.on_extended_data do |_ch, _type, data|
32
- print data # 实时输出
33
31
  stderr << data
34
32
  end
35
33
  end
@@ -21,28 +21,56 @@ 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
- # 美化输出
28
- pastel = Pastel.new
29
- puts pastel.bright_white("\n#{name.ljust(24)} : ")
30
- puts pastel.cyan(" [run] #{command[:command].lines.first.strip}")
31
- command[:command].lines[1..].each { |line| puts " > #{line.strip}" unless line.strip.empty? }
32
- output = executor.execute(command[:command])
33
- result[:output] << { command: command[:command], output: output }
34
- when :upload
35
- pastel = Pastel.new
36
- puts pastel.bright_white("\n#{name.ljust(24)} : ")
37
- puts pastel.green(" [upload] #{command[:source]} -> #{command[:destination]}")
38
- executor.upload(command[:source], command[:destination])
39
- result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
40
- when :upload_template
41
- pastel = Pastel.new
42
- puts pastel.bright_white("\n#{name.ljust(24)} : ")
43
- puts pastel.yellow(" [template] #{command[:source]} -> #{command[:destination]}")
44
- executor.upload_template(command[:source], command[:destination], command[:variables])
45
- 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
+ # 统一输出命令结果
54
+ if output[:stdout] && !output[:stdout].empty?
55
+ output[:stdout].each_line { |line| puts " #{line.rstrip}" unless line.strip.empty? }
56
+ end
57
+ if output[:stderr] && !output[:stderr].empty?
58
+ output[:stderr].each_line { |line| puts pastel.red(" #{line.rstrip}") unless line.strip.empty? }
59
+ end
60
+ result[:output] << { command: command[:command], output: output }
61
+ when :upload
62
+ pastel = Pastel.new
63
+ puts pastel.bright_white("\n#{name.ljust(24)} : ")
64
+ puts pastel.green(" [upload] #{command[:source]} -> #{command[:destination]}")
65
+ executor.upload(command[:source], command[:destination])
66
+ result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
67
+ when :upload_template
68
+ pastel = Pastel.new
69
+ puts pastel.bright_white("\n#{name.ljust(24)} : ")
70
+ 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]}" }
73
+ end
46
74
  end
47
75
  end
48
76
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.0.9'
4
+ VERSION = '1.1.1'
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.9
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk