kdeploy 1.0.6 → 1.0.8
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 +4 -4
- data/exe/kdeploy +13 -0
- data/lib/kdeploy/cli.rb +48 -39
- data/lib/kdeploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71b80d4b4cf5194def86c21793e7a284f524288f06e215fd6d44f0fa408dfe18
|
4
|
+
data.tar.gz: d8f28a18304adc12256633567c872d1368a29a644c9e4b1f2cdd44e5ba3d9413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2e3a70987d5390dc53c4c68091533dfb6f8e9e9b695f03aeaa5c5e1c48c7d646cac698ac5760bb30d5a32a7c1b0ee51ca720e2d9507253d87b2ac01ea0a19ce
|
7
|
+
data.tar.gz: b6908b7720edda9e4ff81a2b5f2d679e5ffe7774d62d33de91dd191b5773590020ec49c43b45d58d520da6d7ef6193bca6120e6b7dd1d46b84344081081d80fa
|
data/exe/kdeploy
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
# 自动修复常见 gem 扩展
|
5
|
+
%w[debug rbs].zip(%w[1.7.1 2.8.2]).each do |gem_name, version|
|
6
|
+
require gem_name
|
7
|
+
rescue LoadError
|
8
|
+
warn "[Kdeploy] 自动修复 #{gem_name}-#{version} ..."
|
9
|
+
system("gem pristine #{gem_name} --version #{version}")
|
10
|
+
begin
|
11
|
+
require gem_name
|
12
|
+
rescue LoadError
|
13
|
+
warn "[Kdeploy] 依然无法加载 #{gem_name}-#{version},请手动修复。"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
4
17
|
require 'kdeploy'
|
5
18
|
|
6
19
|
Kdeploy::CLI.start(ARGV)
|
data/lib/kdeploy/cli.rb
CHANGED
@@ -79,6 +79,13 @@ module Kdeploy
|
|
79
79
|
method_option :parallel, type: :numeric, default: 5, desc: 'Number of parallel executions'
|
80
80
|
method_option :dry_run, type: :boolean, desc: 'Show what would be done'
|
81
81
|
def execute(task_file, task_name = nil)
|
82
|
+
# 只在最前面输出一次 banner
|
83
|
+
@banner_printed ||= false
|
84
|
+
unless @banner_printed
|
85
|
+
puts Kdeploy::Banner.show
|
86
|
+
@banner_printed = true
|
87
|
+
end
|
88
|
+
|
82
89
|
load_task_file(task_file)
|
83
90
|
|
84
91
|
tasks_to_run = if task_name
|
@@ -169,55 +176,57 @@ module Kdeploy
|
|
169
176
|
end
|
170
177
|
|
171
178
|
def print_results(results, task_name)
|
172
|
-
puts Kdeploy::Banner.show
|
173
179
|
pastel = Pastel.new
|
174
|
-
|
175
|
-
puts "#{pastel.bright_cyan('Task:')} #{pastel.bright_white(task_name)}"
|
176
|
-
puts
|
180
|
+
puts pastel.cyan("\nPLAY [#{task_name}] " + ('*' * 64))
|
177
181
|
|
178
182
|
results.each do |host, result|
|
179
|
-
status = result[:status]
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
puts " #{pastel.bright_yellow('>')} #{line.strip}"
|
193
|
-
end
|
183
|
+
status = case result[:status]
|
184
|
+
when :success then pastel.green('ok')
|
185
|
+
when :changed then pastel.yellow('changed')
|
186
|
+
else pastel.red('failed')
|
187
|
+
end
|
188
|
+
puts pastel.bright_white("\n#{host.ljust(24)} : #{status}")
|
189
|
+
|
190
|
+
if %i[success changed].include?(result[:status])
|
191
|
+
result[:output].each do |step|
|
192
|
+
if step[:command].to_s.start_with?('upload:')
|
193
|
+
puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}")
|
194
|
+
elsif step[:command].to_s.start_with?('upload_template:')
|
195
|
+
puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}")
|
194
196
|
else
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
puts " #{line.rstrip}"
|
205
|
-
end
|
206
|
-
|
207
|
-
# 显示错误输出
|
208
|
-
if cmd[:output].is_a?(Hash) && !cmd[:output][:stderr].empty?
|
209
|
-
cmd[:output][:stderr].each_line do |line|
|
210
|
-
puts " #{pastel.red(line.rstrip)}" unless line.strip.empty?
|
197
|
+
puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}")
|
198
|
+
if step[:output].is_a?(Hash) && step[:output][:stdout]
|
199
|
+
step[:output][:stdout].each_line do |line|
|
200
|
+
puts " > #{line.strip}" unless line.strip.empty?
|
201
|
+
end
|
202
|
+
elsif step[:output].is_a?(String)
|
203
|
+
step[:output].each_line do |line|
|
204
|
+
puts " > #{line.strip}" unless line.strip.empty?
|
205
|
+
end
|
211
206
|
end
|
212
207
|
end
|
213
|
-
|
214
|
-
puts
|
215
208
|
end
|
216
209
|
else
|
217
|
-
|
218
|
-
|
210
|
+
# 失败主机高亮错误
|
211
|
+
err = result[:error] || (if result[:output].is_a?(Array)
|
212
|
+
result[:output].map do |o|
|
213
|
+
o[:output][:stderr] if o[:output].is_a?(Hash)
|
214
|
+
end.compact.join("\n")
|
215
|
+
else
|
216
|
+
result[:output].to_s
|
217
|
+
end)
|
218
|
+
puts pastel.red(" ERROR: #{err}")
|
219
219
|
end
|
220
220
|
end
|
221
|
+
|
222
|
+
# summary
|
223
|
+
puts pastel.cyan("\nPLAY RECAP #{'*' * 64}")
|
224
|
+
results.each do |host, result|
|
225
|
+
ok = %i[success changed].include?(result[:status]) ? result[:output].size : 0
|
226
|
+
failed = result[:status] == :failed ? 1 : 0
|
227
|
+
changed = result[:status] == :changed ? result[:output].size : 0
|
228
|
+
puts "#{host.ljust(24)} : ok=#{ok} changed=#{changed} failed=#{failed}"
|
229
|
+
end
|
221
230
|
end
|
222
231
|
end
|
223
232
|
end
|
data/lib/kdeploy/version.rb
CHANGED