branch_io_cli 0.9.8 → 0.9.9

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
  SHA256:
3
- metadata.gz: '091b67267f6d542453cd8903adf229f0caeec5b763b33ab2474c308a2bfcb6cb'
4
- data.tar.gz: 421065a8099c0d6e1087c641dea2d303b21aab989e53f9ae3825ab58ccaeb8f2
3
+ metadata.gz: d9193658d454dcab2a74341807a6594a25baaa647ec46eac3e44043ee632a696
4
+ data.tar.gz: afb073e2385911619802a78066f281f9b36fef02d5613cba141ccaf8498dcd11
5
5
  SHA512:
6
- metadata.gz: 24ff573c11e248b4d9501e1e8d464d37980b3dc998e2150796979714be12c9d1a415946387a4cc8c1df86f532b8297b1e11a908c464cc712c5d8b6016d680890
7
- data.tar.gz: 991c8328c42eaf101c7fa780b4b7e18150fd25db9237e0a97b0218f0ba7ca4a5a73af89cc4b3672765940753d832cb0c0f412234c9aa185a9c0b5fc514ba41ba
6
+ metadata.gz: cfb723a5edc92d5eaae87c3b2673cc1c41cc38aaf694dd19cec96e26a53fd3cb275559de3e442fbcd58c18cf1a5768b790a47643875b21f868b4e4bd21eac74a
7
+ data.tar.gz: d134244741fe80706d32662edfb08d9212c80428b70aada33d90b2954b77ebe5ad6e88e080809b9d2e3685ce47758a37d03f15cb088dfded0e83aac849fda5ec
@@ -6,7 +6,10 @@ module BranchIOCLI
6
6
  def run!
7
7
  say "\n"
8
8
 
9
- unless xcode_settings.valid?
9
+ say "Loading settings from Xcode"
10
+ if xcode_settings.valid?
11
+ say "Done ✅"
12
+ else
10
13
  say "Failed to load settings from Xcode. Some information may be missing.\n"
11
14
  end
12
15
 
@@ -15,37 +18,13 @@ module BranchIOCLI
15
18
  exit 0
16
19
  end
17
20
 
18
- # Only if a Podfile is detected/supplied at the command line.
19
- if config.pod_install_required?
20
- say "pod install required in order to build."
21
- install = ask %{Run "pod install" now (Y/n)? }
22
- if install.downcase =~ /^n/
23
- say %{Please run "pod install" or "pod update" first in order to continue.}
24
- exit(-1)
25
- end
26
-
27
- helper.verify_cocoapods
28
-
29
- install_command = "pod install"
30
-
31
- if config.pod_repo_update
32
- install_command += " --repo-update"
33
- else
34
- say <<EOF
35
- You have disabled "pod repo update". This can cause "pod install" to fail in
36
- some cases. If that happens, please rerun without --no-pod-repo-update or run
37
- "pod install --repo-update" manually.
38
- EOF
39
- end
40
-
41
- sh install_command
42
- end
43
-
44
21
  File.open config.report_path, "w" do |report|
45
22
  report.write "Branch.io Xcode build report v #{VERSION} #{DateTime.now}\n\n"
46
23
  report.write "#{config.report_configuration}\n"
47
24
  report.write "#{report_helper.report_header}\n"
48
25
 
26
+ report_helper.pod_install_if_required report
27
+
49
28
  # run xcodebuild -list
50
29
  report.log_command "#{report_helper.base_xcodebuild_cmd} -list"
51
30
 
@@ -68,13 +47,19 @@ EOF
68
47
 
69
48
  if config.clean
70
49
  say "Cleaning"
71
- report.log_command "#{base_cmd} clean"
50
+ if report.log_command("#{base_cmd} clean").success?
51
+ say "Done ✅"
52
+ else
53
+ say "Clean failed."
54
+ end
72
55
  end
73
56
 
74
57
  say "Building"
75
- report.log_command "#{base_cmd} -verbose"
76
-
77
- say "Done ✅"
58
+ if report.log_command("#{base_cmd} -verbose").success?
59
+ say "Done ✅"
60
+ else
61
+ say "Build failed."
62
+ end
78
63
  end
79
64
 
80
65
  say "Report generated in #{config.report_path}"
@@ -30,6 +30,17 @@ module BranchIOCLI
30
30
  say "Universal Link configuration passed validation. ✅"
31
31
  end
32
32
 
33
+ if @keys.count > 1 && helper.has_multiple_info_plists? &&
34
+ !File.exist?(File.join(File.dirname(config.podfile_path), 'Pods'))
35
+ # Work around a potential crash for now. The PBXBuildConfiguration#debug?
36
+ # method may raise in this case.
37
+ helper.verify_cocoapods
38
+ say "Installing pods to resolve current build settings"
39
+ # We haven't modified anything yet. Don't use --repo-update at this stage.
40
+ # This is unlikely to fail.
41
+ sh "pod install"
42
+ end
43
+
33
44
  # the following calls can all raise IOError
34
45
  helper.add_keys_to_info_plist @keys
35
46
  helper.add_branch_universal_link_domains_to_info_plist @domains if is_app_target
@@ -29,10 +29,12 @@ module Xcodeproj
29
29
  end
30
30
 
31
31
  schemes.uniq!
32
- if schemes.empty?
32
+ if schemes.empty? && File.exist?(project_path)
33
33
  # Open the project, get all targets. Add one scheme per target.
34
34
  project = self.open project_path
35
35
  schemes += project.targets.reject(&:test_target_type?).map(&:name)
36
+ elsif schemes.empty?
37
+ schemes << File.basename(project_path, '.xcodeproj')
36
38
  end
37
39
  schemes
38
40
  end
@@ -3,12 +3,13 @@ require "pattern_patch"
3
3
  module BranchIOCLI
4
4
  module Helper
5
5
  class PatchHelper
6
- class << self
7
- def load_patch(name)
8
- path = File.expand_path(File.join('..', '..', '..', 'assets', 'patches', "#{name}.yml"), __FILE__)
9
- PatternPatch::Patch.from_yaml path
10
- end
6
+ # Adds patch_dir class attr and patch class method
7
+ extend PatternPatch::Methods
11
8
 
9
+ # Set the patch_dir for PatternPatch
10
+ @patch_dir = File.expand_path(File.join('..', '..', '..', 'assets', 'patches'), __FILE__)
11
+
12
+ class << self
12
13
  def config
13
14
  Configuration::Configuration.current
14
15
  end
@@ -25,6 +26,13 @@ module BranchIOCLI
25
26
  config.keys.count > 1 && !helper.has_multiple_info_plists?
26
27
  end
27
28
 
29
+ def swift_file_includes_branch?(path)
30
+ # Can't just check for the import here, since there may be a bridging header.
31
+ # This may match branch.initSession (if the Branch instance is stored) or
32
+ # Branch.getInstance().initSession, etc.
33
+ !/branch.*initsession|^\s*import\s+branch/i.match_file(path).nil?
34
+ end
35
+
28
36
  def patch_bridging_header
29
37
  unless config.bridging_header_path
30
38
  say "Modules not available and bridging header not found. Cannot import Branch."
@@ -46,13 +54,13 @@ module BranchIOCLI
46
54
 
47
55
  if /^\s*(#import|#include|@import)/.match_file config.bridging_header_path
48
56
  # Add among other imports
49
- load_patch(:objc_import).apply config.bridging_header_path
57
+ patch(:objc_import).apply config.bridging_header_path
50
58
  elsif /\n\s*#ifndef\s+(\w+).*\n\s*#define\s+\1.*?\n/m.match_file config.bridging_header_path
51
59
  # Has an include guard. Add inside.
52
- load_patch(:objc_import_include_guard).apply config.bridging_header_path
60
+ patch(:objc_import_include_guard).apply config.bridging_header_path
53
61
  else
54
62
  # No imports, no include guard. Add at the end.
55
- load_patch(:objc_import_at_end).apply config.bridging_header_path
63
+ patch(:objc_import_at_end).apply config.bridging_header_path
56
64
  end
57
65
  helper.add_change config.bridging_header_path
58
66
  end
@@ -61,21 +69,15 @@ module BranchIOCLI
61
69
  return false unless config.patch_source
62
70
  app_delegate_swift_path = config.app_delegate_swift_path
63
71
 
64
- return false unless app_delegate_swift_path
65
-
66
- app_delegate = File.read app_delegate_swift_path
72
+ return false if app_delegate_swift_path.nil? ||
73
+ swift_file_includes_branch?(app_delegate_swift_path)
67
74
 
68
- # Can't just check for the import here, since there may be a bridging header.
69
- # This may match branch.initSession (if the Branch instance is stored) or
70
- # Branch.getInstance().initSession, etc.
71
- return false if app_delegate =~ /(import\s+branch|branch\.*initsession)/i
75
+ say "Patching #{app_delegate_swift_path}"
72
76
 
73
77
  unless config.bridging_header_required?
74
- load_patch(:swift_import).apply app_delegate_swift_path
78
+ patch(:swift_import).apply app_delegate_swift_path
75
79
  end
76
80
 
77
- say "Patching #{app_delegate_swift_path}"
78
-
79
81
  patch_did_finish_launching_method_swift app_delegate_swift_path
80
82
  patch_continue_user_activity_method_swift app_delegate_swift_path
81
83
  patch_open_url_method_swift app_delegate_swift_path
@@ -95,7 +97,7 @@ module BranchIOCLI
95
97
 
96
98
  say "Patching #{app_delegate_objc_path}"
97
99
 
98
- load_patch(:objc_import).apply app_delegate_objc_path
100
+ patch(:objc_import).apply app_delegate_objc_path
99
101
 
100
102
  patch_did_finish_launching_method_objc app_delegate_objc_path
101
103
  patch_continue_user_activity_method_objc app_delegate_objc_path
@@ -110,11 +112,11 @@ module BranchIOCLI
110
112
 
111
113
  is_new_method = app_delegate_swift !~ /didFinishLaunching[^\n]+?\{/m
112
114
  if is_new_method
113
- patch = load_patch :did_finish_launching_new_swift
115
+ patch_name = :did_finish_launching_new_swift
114
116
  else
115
- patch = load_patch :did_finish_launching_swift
117
+ patch_name = :did_finish_launching_swift
116
118
  end
117
- patch.apply app_delegate_swift_path, binding: binding
119
+ patch(patch_name).apply app_delegate_swift_path, binding: binding
118
120
  end
119
121
 
120
122
  def patch_did_finish_launching_method_objc(app_delegate_objc_path)
@@ -122,11 +124,11 @@ module BranchIOCLI
122
124
 
123
125
  is_new_method = app_delegate_objc !~ /didFinishLaunchingWithOptions/m
124
126
  if is_new_method
125
- patch = load_patch :did_finish_launching_new_objc
127
+ patch_name = :did_finish_launching_new_objc
126
128
  else
127
- patch = load_patch :did_finish_launching_objc
129
+ patch_name = :did_finish_launching_objc
128
130
  end
129
- patch.apply app_delegate_objc_path, binding: binding
131
+ patch(patch_name).apply app_delegate_objc_path, binding: binding
130
132
  end
131
133
 
132
134
  def patch_open_url_method_swift(app_delegate_swift_path)
@@ -134,27 +136,27 @@ module BranchIOCLI
134
136
 
135
137
  if app_delegate_swift =~ /application.*open\s+url.*options/
136
138
  # Has application:openURL:options:
137
- patch = load_patch :open_url_swift
139
+ patch_name = :open_url_swift
138
140
  elsif app_delegate_swift =~ /application.*open\s+url.*sourceApplication/
139
141
  # Has application:openURL:sourceApplication:annotation:
140
142
  # TODO: This method is deprecated.
141
- patch = load_patch :open_url_source_application_swift
143
+ patch_name = :open_url_source_application_swift
142
144
  else
143
145
  # Has neither
144
- patch = load_patch :open_url_new_swift
146
+ patch_name = :open_url_new_swift
145
147
  end
146
- patch.apply app_delegate_swift_path
148
+ patch(patch_name).apply app_delegate_swift_path
147
149
  end
148
150
 
149
151
  def patch_continue_user_activity_method_swift(app_delegate_swift_path)
150
152
  app_delegate_swift = File.read app_delegate_swift_path
151
153
 
152
154
  if app_delegate_swift =~ /application:.*continue userActivity:.*restorationHandler:/
153
- patch = load_patch :continue_user_activity_swift
155
+ patch_name = :continue_user_activity_swift
154
156
  else
155
- patch = load_patch :continue_user_activity_new_swift
157
+ patch_name = :continue_user_activity_new_swift
156
158
  end
157
- patch.apply app_delegate_swift_path
159
+ patch(patch_name).apply app_delegate_swift_path
158
160
  end
159
161
 
160
162
  def patch_open_url_method_objc(app_delegate_objc_path)
@@ -162,27 +164,27 @@ module BranchIOCLI
162
164
 
163
165
  if app_delegate_objc =~ /application:.*openURL:.*options/
164
166
  # Has application:openURL:options:
165
- patch = load_patch :open_url_objc
167
+ patch_name = :open_url_objc
166
168
  elsif app_delegate_objc =~ /application:.*openURL:.*sourceApplication/
167
169
  # Has application:openURL:sourceApplication:annotation:
168
- patch = load_patch :open_url_source_annotation_objc
170
+ patch_name = :open_url_source_annotation_objc
169
171
  # TODO: This method is deprecated.
170
172
  else
171
173
  # Has neither
172
- patch = load_patch :open_url_new_objc
174
+ patch_name = :open_url_new_objc
173
175
  end
174
- patch.apply app_delegate_objc_path
176
+ patch(patch_name).apply app_delegate_objc_path
175
177
  end
176
178
 
177
179
  def patch_continue_user_activity_method_objc(app_delegate_objc_path)
178
180
  app_delegate_swift = File.read app_delegate_objc_path
179
181
 
180
182
  if app_delegate_swift =~ /application:.*continueUserActivity:.*restorationHandler:/
181
- patch = load_patch :continue_user_activity_objc
183
+ patch_name = :continue_user_activity_objc
182
184
  else
183
- patch = load_patch :continue_user_activity_new_objc
185
+ patch_name = :continue_user_activity_new_objc
184
186
  end
185
- patch.apply app_delegate_objc_path
187
+ patch(patch_name).apply app_delegate_objc_path
186
188
  end
187
189
 
188
190
  def patch_messages_view_controller
@@ -193,10 +195,10 @@ module BranchIOCLI
193
195
  when nil
194
196
  return false
195
197
  when /\.swift$/
196
- return false if /branch.*initSession/m.match_file path
198
+ return false if swift_file_includes_branch?(path)
197
199
 
198
200
  unless config.bridging_header_required?
199
- load_patch(:swift_import).apply path
201
+ patch(:swift_import).apply path
200
202
  end
201
203
 
202
204
  is_new_method = !/didBecomeActive\(with.*?\{[^\n]*\n/m.match_file(path)
@@ -204,7 +206,7 @@ module BranchIOCLI
204
206
  else
205
207
  return false if %r{^\s+#import\s+<Branch/Branch.h>|^\s+@import\s+Branch\s*;}.match_file(path)
206
208
 
207
- load_patch(:objc_import).apply path
209
+ patch(:objc_import).apply path
208
210
 
209
211
  is_new_method = !/didBecomeActiveWithConversation.*?\{[^\n]*\n/m.match_file(path)
210
212
  patch_name += "#{is_new_method ? 'new_' : ''}objc"
@@ -212,7 +214,7 @@ module BranchIOCLI
212
214
 
213
215
  say "Patching #{path}"
214
216
 
215
- load_patch(patch_name).apply path, binding: binding
217
+ patch(patch_name).apply path, binding: binding
216
218
 
217
219
  helper.add_change(path)
218
220
  true
@@ -260,7 +262,7 @@ module BranchIOCLI
260
262
 
261
263
  say "Adding \"Branch\" to #{cartfile_path}"
262
264
 
263
- load_patch(:cartfile).apply cartfile_path
265
+ patch(:cartfile).apply cartfile_path
264
266
 
265
267
  true
266
268
  end
@@ -181,6 +181,39 @@ module BranchIOCLI
181
181
 
182
182
  report
183
183
  end
184
+
185
+ def pod_install_if_required(report)
186
+ return unless config.pod_install_required?
187
+ # Only if a Podfile is detected/supplied at the command line.
188
+ say "pod install required in order to build."
189
+ install = ask %{Run "pod install" now (Y/n)? }
190
+ if install.downcase =~ /^n/
191
+ say %{Please run "pod install" or "pod update" first in order to continue.}
192
+ exit(-1)
193
+ end
194
+
195
+ helper.verify_cocoapods
196
+
197
+ install_command = "pod install"
198
+
199
+ if config.pod_repo_update
200
+ install_command += " --repo-update"
201
+ else
202
+ say <<-EOF
203
+ You have disabled "pod repo update". This can cause "pod install" to fail in
204
+ some cases. If that happens, please rerun without --no-pod-repo-update or run
205
+ "pod install --repo-update" manually.
206
+ EOF
207
+ end
208
+
209
+ say "Running #{install_command.inspect}"
210
+ if report.log_command(install_command).success?
211
+ say "Done ✅"
212
+ else
213
+ say "pod install failed. See report for details."
214
+ exit(-1)
215
+ end
216
+ end
184
217
  end
185
218
  end
186
219
  end
@@ -1,3 +1,3 @@
1
1
  module BranchIOCLI
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branch_io_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Branch
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-14 00:00:00.000000000 Z
12
+ date: 2017-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: CFPropertyList
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 0.5.1
62
+ version: 0.5.3
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.5.1
69
+ version: 0.5.3
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: plist
72
72
  requirement: !ruby/object:Gem::Requirement