kdeploy 1.0.4 → 1.0.6

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: '03944aa593bff10b74d9e759c5228c3d67ee1d755581634621fe177c603067be'
4
- data.tar.gz: 4217dec1ce5d68aafc9bddafd0bb73d7033c30453c9479642c116dff2bc035d7
3
+ metadata.gz: 0acb567d3c34e2937de6f0f4c455928ab071d9b0951499ba34c3dd10fc39b6dc
4
+ data.tar.gz: 96d62a683a09abcbce1b309294ccf8584ddb275fa4ed68f5ca09bb7efa1ee611
5
5
  SHA512:
6
- metadata.gz: 519644cfb036c05fb4939f0c104fdf73dde83b51de13856a7d6d1d1b42590e03bc9114b2736217187fa91e2582a78a28d68bc1b2bb82034cf74773ea64a1eda4
7
- data.tar.gz: e6f0f513e91dd14f85a8b859ef47015cb6710a8cb9b00ba07e971b8c59453c1d0e51584cc94a89d2290ce147a5f42fe38413a221dc82cb273e6a2ff8afc363fb
6
+ metadata.gz: fdbc032e54d7915bc5d56d271ca54244d555f7d5b6200ee4b76dd9a6c6f060c5bc50408cd7e870cf2978f95901efd1ecd4805a2de3488df4fad95c6310b2bfdd
7
+ data.tar.gz: d629aaa50931b626de2fd11e8d4c4286f984dbff82a8f8e0fb8146ded23b5fbbb30536e031ec859a6558bcd75176198f55cb98a098c70b327bf3b9dd6b2d5cad
data/lib/kdeploy/cli.rb CHANGED
@@ -118,7 +118,8 @@ module Kdeploy
118
118
  exit 1
119
119
  end
120
120
 
121
- self.class.class_eval(File.read(file), file)
121
+ # 用 instance_eval 并传递顶层 binding,兼容 heredoc
122
+ self.class.module_eval(File.read(file), file)
122
123
  end
123
124
 
124
125
  def filter_hosts(limit, task_hosts)
@@ -19,15 +19,22 @@ module Kdeploy
19
19
  stdout = String.new
20
20
  stderr = String.new
21
21
 
22
- ssh.exec!(command) do |_channel, stream, data|
23
- case stream
24
- when :stdout
25
- stdout << data
26
- when :stderr
27
- stderr << data
22
+ ssh.open_channel do |channel|
23
+ channel.exec(command) do |_ch, success|
24
+ raise "Could not execute command: #{command}" unless success
25
+
26
+ channel.on_data do |_ch, data|
27
+ print data # 实时输出
28
+ stdout << data
29
+ end
30
+
31
+ channel.on_extended_data do |_ch, _type, data|
32
+ print data # 实时输出
33
+ stderr << data
34
+ end
28
35
  end
29
36
  end
30
-
37
+ ssh.loop
31
38
  {
32
39
  stdout: stdout.strip,
33
40
  stderr: stderr.strip,
@@ -24,12 +24,16 @@ module Kdeploy
24
24
  task[:block].call.each do |command|
25
25
  case command[:type]
26
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? }
27
29
  output = executor.execute(command[:command])
28
30
  result[:output] << { command: command[:command], output: output }
29
31
  when :upload
32
+ puts "[#{name}] upload: #{command[:source]} -> #{command[:destination]}"
30
33
  executor.upload(command[:source], command[:destination])
31
34
  result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
32
35
  when :upload_template
36
+ puts "[#{name}] upload_template: #{command[:source]} -> #{command[:destination]}"
33
37
  executor.upload_template(command[:source], command[:destination], command[:variables])
34
38
  result[:output] << { command: "upload_template: #{command[:source]} -> #{command[:destination]}" }
35
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.6'
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.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk