Class: Fastlane::Helper::SentryHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/sentry/helper/sentry_helper.rb

Class Method Summary collapse

Class Method Details

.bin_folder(filename) ⇒ Object

Get path for files in bin folder. Paths are resolved relative to this file, for which there are also unit tests.



81
82
83
# File 'lib/fastlane/plugin/sentry/helper/sentry_helper.rb', line 81

def self.bin_folder(filename)
  File.expand_path("../../../../../bin/#{filename}", File.dirname(__FILE__))
end

.bundled_sentry_cli_pathObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/sentry/helper/sentry_helper.rb', line 62

def self.bundled_sentry_cli_path
  if OS.mac?
    self.bin_folder('sentry-cli-Darwin-universal')
  elsif OS.windows?
    if OS.bits == 64
      self.bin_folder('sentry-cli-Windows-x86_64.exe')
    else
      self.bin_folder('sentry-cli-Windows-i686.exe')
    end
  else
    if OS.bits == 64
      self.bin_folder('sentry-cli-Linux-x86_64')
    else
      self.bin_folder('sentry-cli-Linux-i686')
    end
  end
end

.call_sentry_cli(params, sub_command) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fastlane/plugin/sentry/helper/sentry_helper.rb', line 22

def self.call_sentry_cli(params, sub_command)
  sentry_path = self.find_and_check_sentry_cli_path!(params)
  command = [sentry_path] + sub_command
  UI.message "Starting sentry-cli..."
  require 'open3'

  final_command = command.map { |arg| Shellwords.escape(arg) }.join(" ")

  if FastlaneCore::Globals.verbose?
    UI.command(final_command)
  end

  Open3.popen3(final_command) do |stdin, stdout, stderr, status_thread|
    out_reader = Thread.new do
      output = []

      stdout.each_line do |line|
        l = line.strip!
        UI.message(l)
        output << l
      end

      output.join
    end

    err_reader = Thread.new do
      stderr.each_line do |line|
        UI.message(line.strip!)
      end
    end

    unless status_thread.value.success?
      UI.user_error!('Error while calling Sentry CLI')
    end

    err_reader.join
    out_reader.value
  end
end

.find_and_check_sentry_cli_path!(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/plugin/sentry/helper/sentry_helper.rb', line 6

def self.find_and_check_sentry_cli_path!(params)
  bundled_sentry_cli_path = self.bundled_sentry_cli_path
  bundled_sentry_cli_version = Gem::Version.new(`#{bundled_sentry_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)

  sentry_cli_path = params[:sentry_cli_path] || bundled_sentry_cli_path

  sentry_cli_version = Gem::Version.new(`#{sentry_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)

  if sentry_cli_version < bundled_sentry_cli_version
    UI.user_error!("Your sentry-cli is outdated, please upgrade to at least version #{bundled_sentry_cli_version} and start your lane again!")
  end

  UI.success("Using sentry-cli #{sentry_cli_version}")
  sentry_cli_path
end