fastlane_core 0.35.1 → 0.36.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaceeb34f89395634665eca09896c384e21802c7
4
- data.tar.gz: ef02fb14918ce867d9f326e50e626afdacd674f7
3
+ metadata.gz: 62180ad56d4720bae4f2d9abad31ff128076f028
4
+ data.tar.gz: 41fc0d18208d64f7259e3c23e0495fc0075514b6
5
5
  SHA512:
6
- metadata.gz: 01d65cf15b15403797671a3001e39377bfbdffb46187aa12226c10dcbe1f93b892aaefe3d1e2b89614aa4dc8f83f7509378665dc2e91246e8c706c0eff53ea63
7
- data.tar.gz: 8d8588d6c0186c239645e7d24c43aba913d4e390faf1981dd9ee558d9b76e14084c538983b56ce6a6d8e7823205628e2ac245875d527ce5f1a00580fcf396485
6
+ metadata.gz: 9b8e60d5f10e816fa27706a3f93f3565974ccd7cd1f9182e2a330d2d07ec2e68cea8f1767656b2aa7057feedabd19d8db43d20b61263067ee32ab6cd7ef953de
7
+ data.tar.gz: 12aff2f4ecddbcd5e0f7963434f9e365c2b82629b14b285b3c9183724a4482f03ae144b818279a6f869af5967320d705dc2793a020160700d7138585a4dd255f
data/README.md CHANGED
@@ -46,6 +46,9 @@ This gem contains all shared classes and code:
46
46
 
47
47
  You can hide the inline changelog by setting the `FASTLANE_HIDE_CHANGELOG` environment variable
48
48
 
49
+ # Code of Conduct
50
+ Help us keep `fastlane` open and inclusive. Please read and follow our [Code of Conduct](https://github.com/fastlane/code-of-conduct).
51
+
49
52
  # License
50
53
  This project is licensed under the terms of the MIT license. See the LICENSE file.
51
54
 
data/lib/fastlane_core.rb CHANGED
@@ -24,5 +24,8 @@ require 'fastlane_core/ui/ui'
24
24
  require 'colored'
25
25
  require 'commander'
26
26
 
27
+ # after commander import
28
+ require 'fastlane_core/ui/fastlane_runner' # monkey patch
29
+
27
30
  module FastlaneCore
28
31
  end
@@ -52,7 +52,7 @@ module FastlaneCore
52
52
 
53
53
  # This will raise an exception if the value is not valid
54
54
  def verify!(value)
55
- raise "Invalid value '#{value}' for option '#{self}'".red unless valid? value
55
+ UI.user_error!("Invalid value '#{value}' for option '#{self}'") unless valid? value
56
56
  true
57
57
  end
58
58
 
@@ -63,15 +63,15 @@ module FastlaneCore
63
63
  if value
64
64
  # Verify that value is the type that we're expecting, if we are expecting a type
65
65
  if data_type && !value.kind_of?(data_type)
66
- raise "'#{self.key}' value must be a #{data_type}! Found #{value.class} instead.".red
66
+ UI.user_error!("'#{self.key}' value must be a #{data_type}! Found #{value.class} instead.")
67
67
  end
68
68
 
69
69
  if @verify_block
70
70
  begin
71
71
  @verify_block.call(value)
72
72
  rescue => ex
73
- Helper.log.fatal "Error setting value '#{value}' for option '#{@key}'".red
74
- raise ex
73
+ UI.error "Error setting value '#{value}' for option '#{@key}'"
74
+ raise Interface::FastlaneError.new, ex.to_s
75
75
  end
76
76
  end
77
77
  end
@@ -82,7 +82,6 @@ module FastlaneCore
82
82
  # Returns an updated value type (if necessary)
83
83
  def auto_convert_value(value)
84
84
  # Weird because of https://stackoverflow.com/questions/9537895/using-a-class-object-in-case-statement
85
-
86
85
  case
87
86
  when data_type == Array
88
87
  return value.split(',') if value.kind_of?(String)
@@ -43,11 +43,11 @@ module FastlaneCore
43
43
  end
44
44
 
45
45
  def verify_input_types
46
- raise "available_options parameter must be an array of ConfigItems but is #{@available_options.class}".red unless @available_options.kind_of? Array
46
+ UI.user_error!("available_options parameter must be an array of ConfigItems but is #{@available_options.class}") unless @available_options.kind_of? Array
47
47
  @available_options.each do |item|
48
- raise "available_options parameter must be an array of ConfigItems. Found #{item.class}.".red unless item.kind_of? ConfigItem
48
+ UI.user_error!("available_options parameter must be an array of ConfigItems. Found #{item.class}.") unless item.kind_of? ConfigItem
49
49
  end
50
- raise "values parameter must be a hash".red unless @values.kind_of? Hash
50
+ UI.user_error!("values parameter must be a hash") unless @values.kind_of? Hash
51
51
  end
52
52
 
53
53
  def verify_value_exists
@@ -59,7 +59,7 @@ module FastlaneCore
59
59
  if option
60
60
  option.verify!(value) # Call the verify block for it too
61
61
  else
62
- raise "Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}".red
62
+ UI.user_error!("Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}")
63
63
  end
64
64
  end
65
65
  end
@@ -68,11 +68,11 @@ module FastlaneCore
68
68
  # Make sure a key was not used multiple times
69
69
  @available_options.each do |current|
70
70
  count = @available_options.count { |option| option.key == current.key }
71
- raise "Multiple entries for configuration key '#{current.key}' found!".red if count > 1
71
+ UI.user_error!("Multiple entries for configuration key '#{current.key}' found!") if count > 1
72
72
 
73
73
  unless current.short_option.to_s.empty?
74
74
  count = @available_options.count { |option| option.short_option == current.short_option }
75
- raise "Multiple entries for short_option '#{current.short_option}' found!".red if count > 1
75
+ UI.user_error!("Multiple entries for short_option '#{current.short_option}' found!") if count > 1
76
76
  end
77
77
  end
78
78
  end
@@ -101,7 +101,7 @@ module FastlaneCore
101
101
  raise ex
102
102
  end
103
103
  else
104
- raise "Unresolved conflict between options: '#{current.key}' and '#{conflicting_option.key}'".red
104
+ UI.user_error!("Unresolved conflict between options: '#{current.key}' and '#{conflicting_option.key}'")
105
105
  end
106
106
  end
107
107
  end
@@ -118,7 +118,7 @@ module FastlaneCore
118
118
  end
119
119
  rescue => ex
120
120
  Helper.log.fatal ex
121
- raise "Invalid default value for #{item.key}, doesn't match verify_block".red
121
+ UI.user_error!("Invalid default value for #{item.key}, doesn't match verify_block")
122
122
  end
123
123
  end
124
124
  end
@@ -155,10 +155,10 @@ module FastlaneCore
155
155
  # Returns the value for a certain key. fastlane_core tries to fetch the value from different sources
156
156
  # if 'ask' is true and the value is not present, the user will be prompted to provide a value
157
157
  def fetch(key, ask: true)
158
- raise "Key '#{key}' must be a symbol. Example :app_id.".red unless key.kind_of?(Symbol)
158
+ UI.user_error!("Key '#{key}' must be a symbol. Example :app_id.") unless key.kind_of?(Symbol)
159
159
 
160
160
  option = option_for_key(key)
161
- raise "Could not find option for key :#{key}. Available keys: #{@available_options.collect(&:key).join(', ')}".red unless option
161
+ UI.user_error!("Could not find option for key :#{key}. Available keys: #{@available_options.collect(&:key).join(', ')}") unless option
162
162
 
163
163
  value = @values[key]
164
164
 
@@ -181,7 +181,7 @@ module FastlaneCore
181
181
  # to raise the exception that is shown when the user passes an invalid value
182
182
  set(key, '')
183
183
  # If this didn't raise an exception, just raise a default one
184
- raise "No value found for '#{key}'"
184
+ UI.user_error!("No value found for '#{key}'")
185
185
  end
186
186
 
187
187
  while ask && value.nil?
@@ -202,11 +202,11 @@ module FastlaneCore
202
202
  # Overwrites or sets a new value for a given key
203
203
  # @param key [Symbol] Must be a symbol
204
204
  def set(key, value)
205
- raise "Key '#{key}' must be a symbol. Example :#{key}.".red unless key.kind_of? Symbol
205
+ UI.user_error!("Key '#{key}' must be a symbol. Example :#{key}.") unless key.kind_of? Symbol
206
206
  option = option_for_key(key)
207
207
 
208
208
  unless option
209
- raise "Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}".red
209
+ UI.user_error!("Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}")
210
210
  end
211
211
 
212
212
  option.verify!(value)
@@ -27,7 +27,6 @@ module FastlaneCore
27
27
  puts "😨 An error occured. Please enable crash reports using `fastlane enable_crash_reporting`.".yellow
28
28
  puts "👍 This makes resolving issues much easier and helps improve fastlane.".yellow
29
29
  puts "🔒 The reports will be stored securely on getsentry.com.".yellow
30
- puts "✨ Once crash reporting is enabled, you get a clean output when something goes wrong.".yellow
31
30
  puts "🙊 More information about privacy: https://github.com/fastlane/fastlane/releases/tag/1.33.3".yellow
32
31
  puts "-------------------------------------------------------------------------------------------".yellow
33
32
  end
@@ -40,7 +39,6 @@ module FastlaneCore
40
39
  puts "😃 Enable crash reporting when fastlane experiences a problem?".yellow
41
40
  puts "👍 This makes resolving issues much easier and helps improve fastlane.".yellow
42
41
  puts "🔒 The reports will be stored securely on getsentry.com".yellow
43
- puts "✨ Once crash reporting is enabled, you get a clean output when something goes wrong".yellow
44
42
  puts "🙊 More information about privacy: https://github.com/fastlane/fastlane/releases/tag/1.33.3".yellow
45
43
  puts "🌴 You can always disable crash reports at anytime `fastlane disable_crash_reporting`".yellow
46
44
  puts "-------------------------------------------------------------------------------------------".yellow
@@ -52,13 +50,10 @@ module FastlaneCore
52
50
  def handle_crash(ex)
53
51
  unless enabled?
54
52
  show_message
55
- raise ex
56
53
  end
57
54
 
58
55
  raise ex if Helper.test?
59
-
60
56
  send_crash(ex)
61
- Kernel.abort # => return status 1, we could pass a message here too, but this would end up with duplicates
62
57
  end
63
58
 
64
59
  def send_crash(ex)
@@ -63,7 +63,7 @@ module FastlaneCore
63
63
  # @return [boolean] true if building in a known CI environment
64
64
  def self.ci?
65
65
  # Check for Jenkins, Travis CI, ... environment variables
66
- ['JENKINS_URL', 'TRAVIS', 'CIRCLECI', 'CI', 'TEAMCITY_VERSION', 'GO_PIPELINE_NAME', 'bamboo_buildKey'].each do |current|
66
+ ['JENKINS_URL', 'TRAVIS', 'CIRCLECI', 'CI', 'TEAMCITY_VERSION', 'GO_PIPELINE_NAME', 'bamboo_buildKey', 'GITLAB_CI'].each do |current|
67
67
  return true if ENV.key?(current)
68
68
  end
69
69
  return false
@@ -19,25 +19,23 @@ module FastlaneCore
19
19
 
20
20
  def self.fetch_info_plist_file(path)
21
21
  Zip::File.open(path) do |zipfile|
22
- zipfile.each do |file|
23
- next if file.name.match(%r{\.app/.+\.app/Info.plist$})
24
- next unless file.name.include? '.plist' and !['.bundle', '.framework'].any? { |a| file.name.include? a }
22
+ file = zipfile.glob('**/Payload/*.app/Info.plist').first
23
+ return nil unless file
25
24
 
26
- # We can not be completely sure, that's the correct plist file, so we have to try
27
- begin
28
- # The XML file has to be properly unpacked first
29
- tmp_path = "/tmp/deploytmp.plist"
30
- File.write(tmp_path, zipfile.read(file))
31
- system("plutil -convert xml1 #{tmp_path}")
32
- result = Plist.parse_xml(tmp_path)
33
- File.delete(tmp_path)
25
+ # We can not be completely sure, that's the correct plist file, so we have to try
26
+ begin
27
+ # The XML file has to be properly unpacked first
28
+ tmp_path = "/tmp/deploytmp.plist"
29
+ File.write(tmp_path, zipfile.read(file))
30
+ system("plutil -convert xml1 #{tmp_path}")
31
+ result = Plist.parse_xml(tmp_path)
32
+ File.delete(tmp_path)
34
33
 
35
- if result['CFBundleIdentifier'] or result['CFBundleVersion']
36
- return result
37
- end
38
- rescue
39
- # We don't really care, look for another XML file
34
+ if result['CFBundleIdentifier'] or result['CFBundleVersion']
35
+ return result
40
36
  end
37
+ rescue
38
+ # We don't really care, look for another XML file
41
39
  end
42
40
  end
43
41
 
@@ -56,12 +56,7 @@ module FastlaneCore
56
56
  if result and File.directory? itmsp_path
57
57
  Helper.log.info "Successfully downloaded the latest package from iTunesConnect.".green
58
58
  else
59
- # rubocop:disable Style/CaseEquality
60
- unless /^[0-9a-zA-Z\.\$\_]*$/ === @password
61
- Helper.log.error "Password contains special characters, which may not be handled properly by iTMSTransporter. If you experience problems uploading to iTunes Connect, please consider changing your password to something with only alphanumeric characters."
62
- end
63
- # rubocop:enable Style/CaseEquality
64
- Helper.log.fatal "Could not download metadata from iTunes Connect! It's probably related to your password or your internet connection."
59
+ handle_error(@password)
65
60
  end
66
61
 
67
62
  result
@@ -90,6 +85,8 @@ module FastlaneCore
90
85
  Helper.log.info(("-" * 102).green)
91
86
 
92
87
  FileUtils.rm_rf(dir) unless Helper.is_test? # we don't need the package any more, since the upload was successful
88
+ else
89
+ handle_error(@password)
93
90
  end
94
91
 
95
92
  result
@@ -97,6 +94,15 @@ module FastlaneCore
97
94
 
98
95
  private
99
96
 
97
+ def handle_error(password)
98
+ # rubocop:disable Style/CaseEquality
99
+ unless /^[0-9a-zA-Z\.\$\_]*$/ === password
100
+ Helper.log.error "Password contains special characters, which may not be handled properly by iTMSTransporter. If you experience problems uploading to iTunes Connect, please consider changing your password to something with only alphanumeric characters."
101
+ end
102
+ # rubocop:enable Style/CaseEquality
103
+ Helper.log.fatal "Could not download/upload from iTunes Connect! It's probably related to your password or your internet connection."
104
+ end
105
+
100
106
  def execute_transporter(command)
101
107
  @errors = []
102
108
  @warnings = []
@@ -0,0 +1,53 @@
1
+ module Commander
2
+ # This class override the run method with our custom stack trace handling
3
+ # In particular we want to distinguish between user_error! and crash! (one with, one without stack trace)
4
+ class Runner
5
+ # Code taken from https://github.com/commander-rb/commander/blob/master/lib/commander/runner.rb#L50
6
+ def run!
7
+ require_program :version, :description
8
+ trap('INT') { abort program(:int_message) } if program(:int_message)
9
+ trap('INT') { program(:int_block).call } if program(:int_block)
10
+ global_option('-h', '--help', 'Display help documentation') do
11
+ args = @args - %w(-h --help)
12
+ command(:help).run(*args)
13
+ return
14
+ end
15
+ global_option('-v', '--version', 'Display version information') do
16
+ say version
17
+ return
18
+ end
19
+ parse_global_options
20
+ remove_global_options options, @args
21
+
22
+ begin
23
+ run_active_command
24
+ rescue InvalidCommandError => e
25
+ abort "#{e}. Use --help for more information"
26
+ rescue Interrupt => ex
27
+ # We catch it so that the stack trace is hidden by default when using ctrl + c
28
+ if $verbose
29
+ raise ex
30
+ else
31
+ puts "\nCancelled... use --verbose to show the stack trace"
32
+ end
33
+ rescue \
34
+ OptionParser::InvalidOption,
35
+ OptionParser::InvalidArgument,
36
+ OptionParser::MissingArgument => e
37
+ abort e.to_s
38
+ rescue FastlaneCore::Interface::FastlaneError => e # user_error!
39
+ error_message = "\n[!] #{e}".red
40
+ if $verbose # with stack trace
41
+ raise e, "[!] #{e.message}".red, e.backtrace
42
+ else
43
+ abort error_message # without stack trace
44
+ end
45
+ rescue => e # high chance this is actually FastlaneCore::Interface::FastlaneCrash, but can be anything else
46
+ FastlaneCore::CrashReporting.handle_crash(ex)
47
+ # From https://stackoverflow.com/a/4789702/445598
48
+ # We do this to make the actual error message red and therefore more visible
49
+ raise e, "[!] #{e.message}".red, e.backtrace
50
+ end
51
+ end
52
+ end
53
+ end
@@ -102,36 +102,6 @@ module FastlaneCore
102
102
  ask(message.yellow) { |q| q.echo = "*" }
103
103
  end
104
104
 
105
- #####################################################
106
- # @!group Errors: Different kinds of exceptions
107
- #####################################################
108
-
109
- def crash!(exception)
110
- if exception.kind_of?(String)
111
- raise exception.red
112
- elsif exception.kind_of?(Exception)
113
- # From https://stackoverflow.com/a/4789702/445598
114
- # We do this to make the actual error message red and therefore more visible
115
- begin
116
- raise exception
117
- rescue => ex
118
- raise $!, "[!] #{ex.message}".red, $!.backtrace
119
- end
120
- else
121
- raise exception # we're just raising whatever we have here #yolo
122
- end
123
- end
124
-
125
- def user_error!(error_message)
126
- error_message = "\n[!] #{error_message}".red
127
- if $verbose
128
- # On verbose we want to see the full stack trace
129
- raise error_message
130
- else
131
- abort(error_message)
132
- end
133
- end
134
-
135
105
  private
136
106
 
137
107
  def verify_interactive!(message)
@@ -104,23 +104,32 @@ module FastlaneCore
104
104
  # @!group Errors: Different kinds of exceptions
105
105
  #####################################################
106
106
 
107
+ # raised from crash!
108
+ class FastlaneCrash < StandardError
109
+ end
110
+
111
+ # raised from user_error!
112
+ class FastlaneError < StandardError
113
+ end
114
+
107
115
  # Pass an exception to this method to exit the program
108
116
  # using the given exception
109
117
  # Use this method instead of user_error! if this error is
110
118
  # unexpected, e.g. an invalid server response that shouldn't happen
111
- def crash!(_exception)
112
- not_implemented(__method__)
119
+ def crash!(exception)
120
+ raise FastlaneCrash.new, exception.to_s
113
121
  end
114
122
 
115
123
  # Use this method to exit the program because of an user error
116
124
  # e.g. app doesn't exist on the given Developer Account
117
125
  # or invalid user credentials
126
+ # or scan tests fail
118
127
  # This will show the error message, but doesn't show the full
119
128
  # stack trace
120
129
  # Basically this should be used when you actively catch the error
121
130
  # and want to show a nice error message to the user
122
- def user_error!(_error_message)
123
- not_implemented(__method__)
131
+ def user_error!(error_message)
132
+ raise FastlaneError.new, error_message.to_s
124
133
  end
125
134
 
126
135
  #####################################################
@@ -1,3 +1,3 @@
1
1
  module FastlaneCore
2
- VERSION = "0.35.1"
2
+ VERSION = "0.36.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.1
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: commander
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 4.3.5
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.3.5
83
83
  - !ruby/object:Gem::Dependency
@@ -356,6 +356,7 @@ files:
356
356
  - lib/fastlane_core/provisioning_profile.rb
357
357
  - lib/fastlane_core/simulator.rb
358
358
  - lib/fastlane_core/ui/disable_colors.rb
359
+ - lib/fastlane_core/ui/fastlane_runner.rb
359
360
  - lib/fastlane_core/ui/implementations/shell.rb
360
361
  - lib/fastlane_core/ui/interface.rb
361
362
  - lib/fastlane_core/ui/ui.rb