Module: FastlaneCore::Helper
- Defined in:
- lib/fastlane_core/helper.rb
Overview
rubocop:disable Metrics/ModuleLength
Class Method Summary collapse
-
.backticks(command, print: true) ⇒ Object
Runs a given command using backticks (‘) and prints them out using the UI.command method.
-
.ci? ⇒ boolean
True if building in a known CI environment.
-
.colors_disabled? ⇒ Boolean
Do we want to disable the colored output?.
- .fastlane_enabled? ⇒ Boolean
-
.gem_path(gem_name) ⇒ Object
Path to the installed gem to load resources (e.g. resign.sh).
- .is_ci? ⇒ Boolean
- .is_mac? ⇒ Boolean
-
.is_test? ⇒ Boolean
Use Helper.test? and Helper.ci? instead (legacy calls).
-
.iterm? ⇒ Boolean
Does the user use iTerm?.
-
.itms_path ⇒ Object
The full path to the iTMSTransporter executable.
-
.log ⇒ Object
Logging happens using this method.
-
.log_alert(text) ⇒ Object
This method can be used to add nice lines around the actual log Use this to log more important things The logs will be green automatically.
-
.mac? ⇒ Boolean
Is the currently running computer a Mac?.
-
.mac_stock_terminal? ⇒ Boolean
Does the user use the Mac stock terminal.
-
.test? ⇒ Boolean
True if the currently running program is a unit test.
- .transporter_java_executable_path ⇒ Object
- .transporter_java_ext_dir ⇒ Object
- .transporter_java_jar_path ⇒ Object
- .transporter_java_path ⇒ Object
-
.transporter_path ⇒ Object
The full path to the iTMSTransporter executable.
- .transporter_user_dir ⇒ Object
-
.xcode_path ⇒ Object
The full path to the Xcode developer tools of the currently running system.
-
.xcode_version ⇒ Object
The version of the currently used Xcode installation (e.g. “7.0”).
Class Method Details
.backticks(command, print: true) ⇒ Object
Runs a given command using backticks (‘) and prints them out using the UI.command method
49 50 51 52 53 54 |
# File 'lib/fastlane_core/helper.rb', line 49 def self.backticks(command, print: true) UI.command(command) if print result = `#{command}` UI.command_output(result) if print return result end |
.ci? ⇒ boolean
Returns true if building in a known CI environment.
62 63 64 65 66 67 68 |
# File 'lib/fastlane_core/helper.rb', line 62 def self.ci? # Check for Jenkins, Travis CI, ... environment variables ['JENKINS_URL', 'TRAVIS', 'CIRCLECI', 'CI', 'TEAMCITY_VERSION', 'GO_PIPELINE_NAME', 'bamboo_buildKey', 'GITLAB_CI', 'XCS'].each do |current| return true if ENV.key?(current) end return false end |
.colors_disabled? ⇒ Boolean
Do we want to disable the colored output?
89 90 91 |
# File 'lib/fastlane_core/helper.rb', line 89 def self.colors_disabled? ENV["FASTLANE_DISABLE_COLORS"] end |
.fastlane_enabled? ⇒ Boolean
166 167 168 169 |
# File 'lib/fastlane_core/helper.rb', line 166 def self.fastlane_enabled? # This is called from the root context on the first start @enabled ||= File.directory? "./fastlane" end |
.gem_path(gem_name) ⇒ Object
Path to the installed gem to load resources (e.g. resign.sh)
172 173 174 175 176 177 178 |
# File 'lib/fastlane_core/helper.rb', line 172 def self.gem_path(gem_name) if !Helper.is_test? and Gem::Specification.find_all_by_name(gem_name).any? return Gem::Specification.find_by_name(gem_name).gem_dir else return './' end end |
.is_ci? ⇒ Boolean
80 81 82 |
# File 'lib/fastlane_core/helper.rb', line 80 def self.is_ci? ci? end |
.is_mac? ⇒ Boolean
84 85 86 |
# File 'lib/fastlane_core/helper.rb', line 84 def self.is_mac? self.mac? end |
.is_test? ⇒ Boolean
Use Helper.test? and Helper.ci? instead (legacy calls)
76 77 78 |
# File 'lib/fastlane_core/helper.rb', line 76 def self.is_test? self.test? end |
.iterm? ⇒ Boolean
Does the user use iTerm?
99 100 101 |
# File 'lib/fastlane_core/helper.rb', line 99 def self.iterm? !!ENV["ITERM_SESSION_ID"] end |
.itms_path ⇒ Object
Returns the full path to the iTMSTransporter executable.
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/fastlane_core/helper.rb', line 153 def self.itms_path return '' unless self.is_mac? # so tests work on Linx too [ "../Applications/Application Loader.app/Contents/MacOS/itms", "../Applications/Application Loader.app/Contents/itms" ].each do |path| result = File.(File.join(self.xcode_path, path)) return result if File.exist?(result) end UI.user_error!("Could not find transporter at #{self.xcode_path}. Please make sure you set the correct path to your Xcode installation.") end |
.log ⇒ Object
Logging happens using this method
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fastlane_core/helper.rb', line 8 def self.log $stdout.sync = true if is_test? @log ||= Logger.new(nil) # don't show any logs when running tests else @log ||= Logger.new($stdout) end @log.formatter = proc do |severity, datetime, progname, msg| string = "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: " if $verbose string = "[#{datetime.strftime('%H:%M:%S')}]: " unless $verbose second = "#{msg}\n" if severity == "DEBUG" string = string.magenta elsif severity == "INFO" string = string.white elsif severity == "WARN" string = string.yellow elsif severity == "ERROR" string = string.red elsif severity == "FATAL" string = string.red.bold end [string, second].join("") end @log end |
.log_alert(text) ⇒ Object
This method can be used to add nice lines around the actual log Use this to log more important things The logs will be green automatically
43 44 45 |
# File 'lib/fastlane_core/helper.rb', line 43 def self.log_alert(text) UI.header(text) end |
.mac? ⇒ Boolean
Is the currently running computer a Mac?
71 72 73 |
# File 'lib/fastlane_core/helper.rb', line 71 def self.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end |
.mac_stock_terminal? ⇒ Boolean
Does the user use the Mac stock terminal
94 95 96 |
# File 'lib/fastlane_core/helper.rb', line 94 def self.mac_stock_terminal? !!ENV["TERM_PROGRAM_VERSION"] end |
.test? ⇒ Boolean
Returns true if the currently running program is a unit test.
57 58 59 |
# File 'lib/fastlane_core/helper.rb', line 57 def self.test? defined?SpecHelper end |
.transporter_java_executable_path ⇒ Object
127 128 129 |
# File 'lib/fastlane_core/helper.rb', line 127 def self.transporter_java_executable_path return File.join(self.transporter_java_path, 'bin', 'java') end |
.transporter_java_ext_dir ⇒ Object
131 132 133 |
# File 'lib/fastlane_core/helper.rb', line 131 def self.transporter_java_ext_dir return File.join(self.transporter_java_path, 'lib', 'ext') end |
.transporter_java_jar_path ⇒ Object
135 136 137 |
# File 'lib/fastlane_core/helper.rb', line 135 def self.transporter_java_jar_path return File.join(self.itms_path, 'lib', 'itmstransporter-launcher.jar') end |
.transporter_java_path ⇒ Object
143 144 145 |
# File 'lib/fastlane_core/helper.rb', line 143 def self.transporter_java_path return File.join(self.itms_path, 'java') end |
.transporter_path ⇒ Object
Returns the full path to the iTMSTransporter executable.
148 149 150 |
# File 'lib/fastlane_core/helper.rb', line 148 def self.transporter_path return File.join(self.itms_path, 'bin', 'iTMSTransporter') end |
.transporter_user_dir ⇒ Object
139 140 141 |
# File 'lib/fastlane_core/helper.rb', line 139 def self.transporter_user_dir return File.join(self.itms_path, 'bin') end |
.xcode_path ⇒ Object
Returns the full path to the Xcode developer tools of the currently running system.
108 109 110 111 |
# File 'lib/fastlane_core/helper.rb', line 108 def self.xcode_path return "" if self.is_test? and !self.is_mac? `xcode-select -p`.delete("\n") + "/" end |
.xcode_version ⇒ Object
Returns The version of the currently used Xcode installation (e.g. “7.0”).
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/fastlane_core/helper.rb', line 114 def self.xcode_version return @xcode_version if @xcode_version begin output = `DEVELOPER_DIR='' "#{xcode_path}/usr/bin/xcodebuild" -version` @xcode_version = output.split("\n").first.split(' ')[1] rescue => ex UI.error(ex) UI.error("Error detecting currently used Xcode installation") end @xcode_version end |