kamal-backup 0.3.0.beta7 → 0.3.0.beta8

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: 841b29d2ee8cc4598cb1880da4a7bf884cef141816432a9d960ff400b7535d25
4
- data.tar.gz: 3784f1bfe50f1480f457bfb40a18e30ab5905db4a300a193fe5d68ac50d67f2f
3
+ metadata.gz: d920c58d8ff83794df465f0549d8599ea6a5e815b800221fa850ce024241abfa
4
+ data.tar.gz: feb8374a19862349d1fb0b3d55e3e697b45df66d58fc0c0f63ddba4767ed01f9
5
5
  SHA512:
6
- metadata.gz: 9929349441963b8297254c10faa1446cf4f7602638a7637ab655ffcadb32d31d012ea8827890fc29175dfc4e344a5afc1edacbf960cfe86d6aec2a83c88385c6
7
- data.tar.gz: fbfee00eae64424a92e5d039512ff51d01abecb6dd6a61d8d44ec97dc2e86208f06fd5c191947107a9c9adaa4da80a77a9eebabc9e9e12b96d7e60dcb0ce0e06
6
+ metadata.gz: 9e36489f2557dca0695be87b779a9b20f96148b141e67a9422bc8933c925ea68a17a73d221c56f4a51585258194752f0db4f0b6fed4a4845783334e6dc0d8e0e
7
+ data.tar.gz: f8bb63eb69f7da8bdfcc001e07c95495ac60fa6996eb4b4188cfb2a8bc453979176985703f897c8e5ac4a9b02faec5cf3d76aad15862b0c964d6c961c2910556
@@ -129,11 +129,13 @@ module KamalBackup
129
129
 
130
130
  def print_remote_version_status
131
131
  status = remote_version == VERSION ? "in sync" : "out of sync"
132
+ status_color = status == "in sync" ? :green : :red
133
+ status_output = CommandOutput.new(io: $stdout, env: command_env)
132
134
 
133
135
  puts("local: #{VERSION}")
134
136
  puts("remote: #{remote_version}")
135
- puts("status: #{status}")
136
- puts("fix: #{accessory_reboot_command}") if status == "out of sync"
137
+ puts("status: #{status_output.decorate(status, status_color, :bold)}")
138
+ puts("fix: #{status_output.decorate(accessory_reboot_command, :yellow, :bold)}") if status == "out of sync"
137
139
  end
138
140
 
139
141
  def validate_deploy_config
@@ -399,14 +401,17 @@ module KamalBackup
399
401
 
400
402
  def self.start(argv = ARGV, env: ENV)
401
403
  self.command_env = env
402
- Command.with_output(CommandOutput.new(io: $stderr)) do
404
+ output = CommandOutput.new(io: $stderr, env: env)
405
+ Command.with_output(output) do
403
406
  super(normalize_global_options(argv))
404
407
  end
405
408
  rescue Error => e
406
- warn("kamal-backup: #{Redactor.new(env: env).redact_string(e.message)}")
409
+ output ||= CommandOutput.new(io: $stderr, env: env)
410
+ output.error("(#{e.class}): #{e.message}", redactor: Redactor.new(env: env))
407
411
  exit(1)
408
412
  rescue Interrupt
409
- warn("kamal-backup: interrupted")
413
+ output ||= CommandOutput.new(io: $stderr, env: env)
414
+ output.error("(Interrupt): interrupted", redactor: Redactor.new(env: env))
410
415
  exit(130)
411
416
  ensure
412
417
  self.command_env = nil
@@ -72,6 +72,14 @@ module KamalBackup
72
72
  write_message("INFO", redactor.redact_string(message))
73
73
  end
74
74
 
75
+ def error(message, redactor:)
76
+ write_message("ERROR", colorize(redactor.redact_string(message), :red, :bold))
77
+ end
78
+
79
+ def decorate(value, color, mode = nil)
80
+ colorize(value, color, mode)
81
+ end
82
+
75
83
  def command_start(spec, redactor:)
76
84
  id = SecureRandom.hex(4)
77
85
  started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@@ -215,10 +215,10 @@ module KamalBackup
215
215
  end
216
216
 
217
217
  def capture_kamal(argv, stream: false)
218
- spec = CommandSpec.new(argv: argv)
218
+ spec = CommandSpec.new(argv: argv, env: kamal_stream_env(stream))
219
219
  options = {
220
220
  redactor: @redactor,
221
- log: false,
221
+ log: !stream,
222
222
  log_output: false,
223
223
  tee_stdout: stream ? @stdout : nil,
224
224
  tee_stderr: stream ? @stderr : nil
@@ -231,6 +231,20 @@ module KamalBackup
231
231
  end
232
232
  end
233
233
 
234
+ def kamal_stream_env(stream)
235
+ return {} unless stream
236
+
237
+ if @env["SSHKIT_COLOR"].to_s.empty?
238
+ stream_color? ? { "SSHKIT_COLOR" => "1" } : {}
239
+ else
240
+ { "SSHKIT_COLOR" => @env["SSHKIT_COLOR"] }
241
+ end
242
+ end
243
+
244
+ def stream_color?
245
+ [@stdout, @stderr].any? { |io| io.respond_to?(:tty?) && io.tty? }
246
+ end
247
+
234
248
  def parse_version_line(output)
235
249
  output.to_s.lines.map(&:strip).reverse.find { |line| line.match?(VERSION_LINE_PATTERN) }.to_s
236
250
  end
@@ -1,3 +1,3 @@
1
1
  module KamalBackup
2
- VERSION = "0.3.0.beta7"
2
+ VERSION = "0.3.0.beta8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamal-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.beta7
4
+ version: 0.3.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - crmne