fastlane_core 0.19.0 → 0.20.0

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
  SHA1:
3
- metadata.gz: 9e67c862d0011ece1cac8c986476f38347917df1
4
- data.tar.gz: d945f27fe8f0799e73915c914af7aef164f8e8c7
3
+ metadata.gz: 198c318bada63eb8b0c957b85a4242f20c22fc2c
4
+ data.tar.gz: af7fabd6cb12541ef31d1b90a2f708b5324f5b50
5
5
  SHA512:
6
- metadata.gz: 23bbba2dc74a198d68a2dd0898d6a28e19f1367a788ce066a38096cbaf9c2501c5689cbe7cdb76c3981dadcebca7c6eafe5c2c79451d6ec6805d7642ae6cb7dc
7
- data.tar.gz: 30003541ce54583e9a05a4e657eaff9d0ccced802badc667beabfa46047bd8de43b3e6dc49bb8f6e894b227a3a48fc7e326fe6311c889e05a26501ad26c8c997
6
+ metadata.gz: 829ca1ec310c39e252ef7f12e3aa7a3ad0cf34bd5c5b03e7a886ea10a1fa17edb42d260616d040a6fd589e37d91ff030fee038f7c51c812876976f33ecba9508
7
+ data.tar.gz: 5030dcd70f2316fa458490660eb4cb76f6980da73a2c76e5499a3939e10d792f033689affc4d8921f479be6abd96d4bccec299d04f7cb8e28cdbb374a989a95a
data/lib/fastlane_core.rb CHANGED
@@ -12,6 +12,7 @@ require 'fastlane_core/provisioning_profile'
12
12
  require 'fastlane_core/command_executor'
13
13
  require 'fastlane_core/ipa_upload_package_builder'
14
14
  require 'fastlane_core/print_table'
15
+ require 'fastlane_core/project'
15
16
 
16
17
  # Third Party code
17
18
  require 'colored'
@@ -6,17 +6,25 @@ module FastlaneCore
6
6
  # @param print_all [Boolean] Do we want to print out the command output while running?
7
7
  # @param print_command [Boolean] Should we print the command that's being executed
8
8
  # @param error [Block] A block that's called if an error occurs
9
+ # @param prefix [Array] An array containg a prefix + block which might get applied to the output
10
+ # @param loading [String] A loading string that is shown before the first output
9
11
  # @return [String] All the output as string
10
- def execute(command: nil, print_all: false, print_command: true, error: nil)
12
+ def execute(command: nil, print_all: false, print_command: true, error: nil, prefix: nil, loading: nil)
11
13
  print_all = true if $verbose
14
+ prefix ||= {}
12
15
 
13
16
  output = []
14
17
  command = command.join(" ")
15
18
  Helper.log.info command.yellow.strip if print_command
16
19
 
17
20
  puts "\n-----".cyan if print_all
21
+ if loading
22
+ print(loading.cyan + "\r")
23
+ last_length = loading.length
24
+ else
25
+ last_length = 0
26
+ end
18
27
 
19
- last_length = 0
20
28
  begin
21
29
  PTY.spawn(command) do |stdin, stdout, pid|
22
30
  stdin.each do |l|
@@ -25,9 +33,16 @@ module FastlaneCore
25
33
 
26
34
  next unless print_all
27
35
 
36
+ line = line.cyan
37
+
38
+ # Prefix the current line with a string
39
+ prefix.each do |element|
40
+ line = element[:prefix] + line if element[:block] && element[:block].call(line)
41
+ end
42
+
28
43
  current_length = line.length
29
44
  spaces = [last_length - current_length, 0].max
30
- print((line + " " * spaces + "\r").cyan)
45
+ print(line + " " * spaces + "\r")
31
46
  last_length = current_length
32
47
  end
33
48
  Process.wait(pid)
@@ -39,7 +54,7 @@ module FastlaneCore
39
54
  output << ex.to_s
40
55
  o = output.join("\n")
41
56
  puts o
42
- error.call(o)
57
+ error.call(o, nil)
43
58
  end
44
59
 
45
60
  # Exit status for build command, should be 0 if build succeeded
@@ -48,8 +63,10 @@ module FastlaneCore
48
63
  o = output.join("\n")
49
64
  puts o # the user has the right to see the raw output
50
65
  Helper.log.info "Exit status: #{status}"
51
- error.call(o)
66
+ error.call(o, status)
52
67
  end
68
+
69
+ return output.join("\n")
53
70
  end
54
71
  end
55
72
  end
@@ -11,6 +11,7 @@ module FastlaneCore
11
11
  @block_for_missing = block_for_missing
12
12
  content = File.read(path)
13
13
 
14
+ # From https://github.com/orta/danger/blob/master/lib/danger/Dangerfile.rb
14
15
  if content.tr!('“”‘’‛', %(""'''))
15
16
  Helper.log.error "Your #{File.basename(path)} has had smart quotes sanitised. " \
16
17
  'To avoid issues in the future, you should not use ' \
@@ -0,0 +1,200 @@
1
+ module FastlaneCore
2
+ # Represents an Xcode project
3
+ class Project
4
+ # Path to the project/workspace
5
+ attr_accessor :path
6
+
7
+ # Is this project a workspace?
8
+ attr_accessor :is_workspace
9
+
10
+ # The config object containing the scheme, configuration, etc.
11
+ attr_accessor :options
12
+
13
+ def initialize(options)
14
+ self.options = options
15
+ self.path = File.expand_path(options[:workspace] || options[:project])
16
+ self.is_workspace = (options[:workspace].to_s.length > 0)
17
+
18
+ if !path or !File.directory?(path)
19
+ raise "Could not find project at path '#{path}'".red
20
+ end
21
+ end
22
+
23
+ def workspace?
24
+ self.is_workspace
25
+ end
26
+
27
+ # Get all available schemes in an array
28
+ def schemes
29
+ results = []
30
+ output = raw_info.split("Schemes:").last.split(":").first
31
+
32
+ if raw_info.include?("There are no schemes in workspace") or raw_info.include?("This project contains no schemes")
33
+ return results
34
+ end
35
+
36
+ output.split("\n").each do |current|
37
+ current = current.strip
38
+
39
+ next if current.length == 0
40
+ results << current
41
+ end
42
+
43
+ results
44
+ end
45
+
46
+ # Let the user select a scheme
47
+ def select_scheme
48
+ if options[:scheme].to_s.length > 0
49
+ # Verify the scheme is available
50
+ unless schemes.include?(options[:scheme].to_s)
51
+ Helper.log.error "Couldn't find specified scheme '#{options[:scheme]}'.".red
52
+ options[:scheme] = nil
53
+ end
54
+ end
55
+
56
+ return if options[:scheme].to_s.length > 0
57
+
58
+ if schemes.count == 1
59
+ options[:scheme] = schemes.last
60
+ elsif schemes.count > 1
61
+ if Helper.is_ci?
62
+ Helper.log.error "Multiple schemes found but you haven't specified one.".red
63
+ Helper.log.error "Since this is a CI, please pass one using the `scheme` option".red
64
+ raise "Multiple schemes found".red
65
+ else
66
+ puts "Select Scheme: "
67
+ options[:scheme] = choose(*(schemes))
68
+ end
69
+ else
70
+ Helper.log.error "Couldn't find any schemes in this project, make sure that the scheme is shared if you are using a workspace".red
71
+ Helper.log.error "Open Xcode, click on `Manage Schemes` and check the `Shared` box for the schemes you want to use".red
72
+
73
+ raise "No Schemes found".red
74
+ end
75
+ end
76
+
77
+ # Get all available configurations in an array
78
+ def configurations
79
+ results = []
80
+ splitted = raw_info.split("Configurations:")
81
+ return [] if splitted.count != 2 # probably a CocoaPods project
82
+
83
+ output = splitted.last.split(":").first
84
+ output.split("\n").each_with_index do |current, index|
85
+ current = current.strip
86
+
87
+ if current.length == 0
88
+ next if index == 0
89
+ break # as we want to break on the empty line
90
+ end
91
+
92
+ results << current
93
+ end
94
+
95
+ results
96
+ end
97
+
98
+ def app_name
99
+ # WRAPPER_NAME: Example.app
100
+ # WRAPPER_SUFFIX: .app
101
+ name = build_settings(key: "WRAPPER_NAME")
102
+
103
+ return name.gsub(build_settings(key: "WRAPPER_SUFFIX"), "") if name
104
+ return "App" # default value
105
+ end
106
+
107
+ def mac?
108
+ # Some projects have different values... we have to look for all of them
109
+ return true if build_settings(key: "PLATFORM_NAME") == "macosx"
110
+ return true if build_settings(key: "PLATFORM_DISPLAY_NAME") == "OS X"
111
+ false
112
+ end
113
+
114
+ def ios?
115
+ !mac?
116
+ end
117
+
118
+ def xcodebuild_parameters
119
+ proj = []
120
+ proj << "-workspace '#{options[:workspace]}'" if options[:workspace]
121
+ proj << "-scheme '#{options[:scheme]}'" if options[:scheme]
122
+ proj << "-project '#{options[:project]}'" if options[:project]
123
+
124
+ return proj
125
+ end
126
+
127
+ #####################################################
128
+ # @!group Raw Access
129
+ #####################################################
130
+
131
+ # Get the build settings for our project
132
+ # this is used to properly get the DerivedData folder
133
+ # @param [String] The key of which we want the value for (e.g. "PRODUCT_NAME")
134
+ def build_settings(key: nil, optional: true, silent: false)
135
+ unless @build_settings
136
+ # We also need to pass the workspace and scheme to this command
137
+ command = "xcrun xcodebuild -showBuildSettings #{xcodebuild_parameters.join(' ')}"
138
+ Helper.log.info command.yellow unless silent
139
+ @build_settings = `#{command}`
140
+ end
141
+
142
+ begin
143
+ result = @build_settings.split("\n").find { |c| c.include? key }
144
+ return result.split(" = ").last
145
+ rescue => ex
146
+ return nil if optional # an optional value, we really don't care if something goes wrong
147
+
148
+ Helper.log.error caller.join("\n\t")
149
+ Helper.log.error "Could not fetch #{key} from project file: #{ex}"
150
+ end
151
+
152
+ nil
153
+ end
154
+
155
+ def raw_info(silent: false)
156
+ # Examples:
157
+
158
+ # Standard:
159
+ #
160
+ # Information about project "Example":
161
+ # Targets:
162
+ # Example
163
+ # ExampleUITests
164
+ #
165
+ # Build Configurations:
166
+ # Debug
167
+ # Release
168
+ #
169
+ # If no build configuration is specified and -scheme is not passed then "Release" is used.
170
+ #
171
+ # Schemes:
172
+ # Example
173
+ # ExampleUITests
174
+
175
+ # CococaPods
176
+ #
177
+ # Example.xcworkspace
178
+ # Information about workspace "Example":
179
+ # Schemes:
180
+ # Example
181
+ # HexColors
182
+ # Pods-Example
183
+
184
+ return @raw if @raw
185
+
186
+ # Unfortunately since we pass the workspace we also get all the
187
+ # schemes generated by CocoaPods
188
+
189
+ options = xcodebuild_parameters.delete_if { |a| a.to_s.include? "scheme" }
190
+ command = "xcrun xcodebuild -list #{options.join(' ')}"
191
+ Helper.log.info command.yellow unless silent
192
+
193
+ @raw = `#{command}`.to_s
194
+
195
+ raise "Error parsing xcode file using `#{command}`".red if @raw.length == 0
196
+
197
+ return @raw
198
+ end
199
+ end
200
+ end
@@ -1,3 +1,3 @@
1
1
  module FastlaneCore
2
- VERSION = "0.19.0"
2
+ VERSION = "0.20.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.19.0
4
+ version: 0.20.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: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -310,6 +310,34 @@ dependencies:
310
310
  - - ">="
311
311
  - !ruby/object:Gem::Version
312
312
  version: '0'
313
+ - !ruby/object:Gem::Dependency
314
+ name: fastlane
315
+ requirement: !ruby/object:Gem::Requirement
316
+ requirements:
317
+ - - ">="
318
+ - !ruby/object:Gem::Version
319
+ version: '0'
320
+ type: :development
321
+ prerelease: false
322
+ version_requirements: !ruby/object:Gem::Requirement
323
+ requirements:
324
+ - - ">="
325
+ - !ruby/object:Gem::Version
326
+ version: '0'
327
+ - !ruby/object:Gem::Dependency
328
+ name: rubocop
329
+ requirement: !ruby/object:Gem::Requirement
330
+ requirements:
331
+ - - "~>"
332
+ - !ruby/object:Gem::Version
333
+ version: '0.34'
334
+ type: :development
335
+ prerelease: false
336
+ version_requirements: !ruby/object:Gem::Requirement
337
+ requirements:
338
+ - - "~>"
339
+ - !ruby/object:Gem::Version
340
+ version: '0.34'
313
341
  description: Contains all shared code/dependencies of the fastlane.tools
314
342
  email:
315
343
  - fastlanecore@krausefx.com
@@ -338,6 +366,7 @@ files:
338
366
  - lib/fastlane_core/itunes_transporter.rb
339
367
  - lib/fastlane_core/languages.rb
340
368
  - lib/fastlane_core/print_table.rb
369
+ - lib/fastlane_core/project.rb
341
370
  - lib/fastlane_core/provisioning_profile.rb
342
371
  - lib/fastlane_core/update_checker.rb
343
372
  - lib/fastlane_core/version.rb
@@ -361,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
390
  version: '0'
362
391
  requirements: []
363
392
  rubyforge_project:
364
- rubygems_version: 2.4.6
393
+ rubygems_version: 2.4.5
365
394
  signing_key:
366
395
  specification_version: 4
367
396
  summary: Contains all shared code/dependencies of the fastlane.tools