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.
-
.buildlog_path ⇒ Object
Logs base directory.
-
.bundler? ⇒ boolean
True if executing with bundler (like ‘bundle exec fastlane [action]’).
-
.ci? ⇒ boolean
True if building in a known CI environment.
-
.colors_disabled? ⇒ Boolean
Do we want to disable the colored output?.
-
.contained_fastlane? ⇒ Boolean
Do we run from a bundled fastlane, which contains Ruby and OpenSSL? Usually this means the fastlane directory is ~/.fastlane/bin/ We set this value via the environment variable ‘FASTLANE_SELF_CONTAINED`.
- .fastlane_enabled? ⇒ Boolean
-
.gem_path(gem_name) ⇒ Object
DEPRECATED: Use the ‘ROOT` constant from the appropriate tool module instead e.g.
- .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.
- .keychain_path(name) ⇒ Object
- .linux? ⇒ Boolean
-
.log ⇒ Object
This method is deprecated, use the ‘UI` class github.com/fastlane/fastlane/blob/master/fastlane/docs/UI.md.
-
.mac? ⇒ Boolean
Is the currently running computer a Mac?.
-
.mac_stock_terminal? ⇒ Boolean
Does the user use the Mac stock terminal.
-
.strip_ansi_colors(str) ⇒ Object
removes ANSI colors from string.
-
.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
- .windows? ⇒ Boolean
-
.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
16 17 18 19 20 21 |
# File 'lib/fastlane_core/helper.rb', line 16 def self.backticks(command, print: true) UI.command(command) if print result = `#{command}` UI.command_output(result) if print return result end |
.buildlog_path ⇒ Object
Logs base directory
101 102 103 |
# File 'lib/fastlane_core/helper.rb', line 101 def self.buildlog_path return ENV["FL_BUILDLOG_PATH"] || "~/Library/Logs" end |
.bundler? ⇒ boolean
Returns true if executing with bundler (like ‘bundle exec fastlane [action]’).
34 35 36 37 38 39 40 |
# File 'lib/fastlane_core/helper.rb', line 34 def self.bundler? # Bundler environment variable ['BUNDLE_BIN_PATH', 'BUNDLE_GEMFILE'].each do |current| return true if ENV.key?(current) end return false end |
.ci? ⇒ boolean
Returns true if building in a known CI environment.
50 51 52 53 54 55 56 |
# File 'lib/fastlane_core/helper.rb', line 50 def self.ci? # Check for Jenkins, Travis CI, ... environment variables ['JENKINS_HOME', '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?
86 87 88 |
# File 'lib/fastlane_core/helper.rb', line 86 def self.colors_disabled? ENV["FASTLANE_DISABLE_COLORS"] end |
.contained_fastlane? ⇒ Boolean
Do we run from a bundled fastlane, which contains Ruby and OpenSSL? Usually this means the fastlane directory is ~/.fastlane/bin/ We set this value via the environment variable ‘FASTLANE_SELF_CONTAINED`
45 46 47 |
# File 'lib/fastlane_core/helper.rb', line 45 def self.contained_fastlane? ENV["FASTLANE_SELF_CONTAINED"].to_s == "true" end |
.fastlane_enabled? ⇒ Boolean
195 196 197 198 |
# File 'lib/fastlane_core/helper.rb', line 195 def self.fastlane_enabled? # This is called from the root context on the first start @enabled ||= (File.directory?("./fastlane") || File.directory?("./.fastlane")) end |
.gem_path(gem_name) ⇒ Object
DEPRECATED: Use the ‘ROOT` constant from the appropriate tool module instead e.g. File.join(Sigh::ROOT, ’lib’, ‘assets’, ‘resign.sh’)
Path to the installed gem to load resources (e.g. resign.sh)
204 205 206 207 208 209 210 211 212 |
# File 'lib/fastlane_core/helper.rb', line 204 def self.gem_path(gem_name) UI.deprecated('`Helper.gem_path` is deprecated. Use the `ROOT` constant from the appropriate tool module instead.') 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
77 78 79 |
# File 'lib/fastlane_core/helper.rb', line 77 def self.is_ci? ci? end |
.is_mac? ⇒ Boolean
81 82 83 |
# File 'lib/fastlane_core/helper.rb', line 81 def self.is_mac? self.mac? end |
.is_test? ⇒ Boolean
Use Helper.test? and Helper.ci? instead (legacy calls)
73 74 75 |
# File 'lib/fastlane_core/helper.rb', line 73 def self.is_test? self.test? end |
.iterm? ⇒ Boolean
Does the user use iTerm?
96 97 98 |
# File 'lib/fastlane_core/helper.rb', line 96 def self.iterm? !!ENV["ITERM_SESSION_ID"] end |
.itms_path ⇒ Object
Returns the full path to the iTMSTransporter executable.
181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/fastlane_core/helper.rb', line 181 def self.itms_path return ENV["FASTLANE_ITUNES_TRANSPORTER_PATH"] if ENV["FASTLANE_ITUNES_TRANSPORTER_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 |
.keychain_path(name) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/fastlane_core/helper.rb', line 154 def self.keychain_path(name) # Existing code expects that a keychain name will be expanded into a default path to Libary/Keychains # in the user's home directory. However, this will not allow the user to pass an absolute path # for the keychain value # # So, if the passed value can't be resolved as a file in Library/Keychains, just use it as-is # as the keychain path. # # We need to expand each path because File.exist? won't handle directories including ~ properly # # We also try to append `-db` at the end of the file path, as with Sierra the default Keychain name # has changed for some users: https://github.com/fastlane/fastlane/issues/5649 # keychain_paths = [ File.join(Dir.home, 'Library', 'Keychains', name), File.join(Dir.home, 'Library', 'Keychains', "#{name}-db"), name, "#{name}-db" ].map { |path| File.(path) } keychain_path = keychain_paths.find { |path| File.exist?(path) } UI.user_error!("Could not locate the provided keychain. Tried:\n\t#{keychain_paths.join("\n\t")}") unless keychain_path keychain_path end |
.linux? ⇒ Boolean
63 64 65 |
# File 'lib/fastlane_core/helper.rb', line 63 def self.linux? (/linux/ =~ RUBY_PLATFORM) != nil end |
.log ⇒ Object
This method is deprecated, use the ‘UI` class github.com/fastlane/fastlane/blob/master/fastlane/docs/UI.md
9 10 11 12 |
# File 'lib/fastlane_core/helper.rb', line 9 def self.log UI.deprecated "Helper.log is deprecated. Use `UI` class instead" UI.current.log end |
.mac? ⇒ Boolean
Is the currently running computer a Mac?
68 69 70 |
# File 'lib/fastlane_core/helper.rb', line 68 def self.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end |
.mac_stock_terminal? ⇒ Boolean
Does the user use the Mac stock terminal
91 92 93 |
# File 'lib/fastlane_core/helper.rb', line 91 def self.mac_stock_terminal? !!ENV["TERM_PROGRAM_VERSION"] end |
.strip_ansi_colors(str) ⇒ Object
removes ANSI colors from string
29 30 31 |
# File 'lib/fastlane_core/helper.rb', line 29 def self.strip_ansi_colors(str) str.gsub(/\e\[([;\d]+)?m/, '') end |
.test? ⇒ Boolean
Returns true if the currently running program is a unit test.
24 25 26 |
# File 'lib/fastlane_core/helper.rb', line 24 def self.test? defined? SpecHelper end |
.transporter_java_executable_path ⇒ Object
129 130 131 |
# File 'lib/fastlane_core/helper.rb', line 129 def self.transporter_java_executable_path return File.join(self.transporter_java_path, 'bin', 'java') end |
.transporter_java_ext_dir ⇒ Object
133 134 135 |
# File 'lib/fastlane_core/helper.rb', line 133 def self.transporter_java_ext_dir return File.join(self.transporter_java_path, 'lib', 'ext') end |
.transporter_java_jar_path ⇒ Object
137 138 139 |
# File 'lib/fastlane_core/helper.rb', line 137 def self.transporter_java_jar_path return File.join(self.itms_path, 'lib', 'itmstransporter-launcher.jar') end |
.transporter_java_path ⇒ Object
145 146 147 |
# File 'lib/fastlane_core/helper.rb', line 145 def self.transporter_java_path return File.join(self.itms_path, 'java') end |
.transporter_path ⇒ Object
Returns the full path to the iTMSTransporter executable.
150 151 152 |
# File 'lib/fastlane_core/helper.rb', line 150 def self.transporter_path return File.join(self.itms_path, 'bin', 'iTMSTransporter') end |
.transporter_user_dir ⇒ Object
141 142 143 |
# File 'lib/fastlane_core/helper.rb', line 141 def self.transporter_user_dir return File.join(self.itms_path, 'bin') end |
.windows? ⇒ Boolean
58 59 60 61 |
# File 'lib/fastlane_core/helper.rb', line 58 def self.windows? # taken from: http://stackoverflow.com/a/171011/1945875 (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end |
.xcode_path ⇒ Object
Returns the full path to the Xcode developer tools of the currently running system.
110 111 112 113 |
# File 'lib/fastlane_core/helper.rb', line 110 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”).
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/fastlane_core/helper.rb', line 116 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 |