Class: BranchIOCLI::Helper::ReportHelper
- Inherits:
-
Object
- Object
- BranchIOCLI::Helper::ReportHelper
- Extended by:
- Methods
- Defined in:
- lib/branch_io_cli/helper/report_helper.rb
Class Method Summary collapse
- .base_xcodebuild_cmd ⇒ Object
- .carthage_bootstrap_if_required(report) ⇒ Object
- .config ⇒ Object
- .helper ⇒ Object
- .pod_install_if_required(report) ⇒ Object
-
.report_branch ⇒ Object
String containing information relevant to Branch setup.
-
.report_header ⇒ Object
rubocop: disable Metrics/PerceivedComplexity.
- .report_imports ⇒ Object
- .report_scheme ⇒ Object
- .xcode_settings ⇒ Object
Methods included from Methods
Class Method Details
.base_xcodebuild_cmd ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 33 def base_xcodebuild_cmd if config.workspace_path ["xcodebuild", "-workspace", config.workspace_path] else ["xcodebuild", "-project", config.xcodeproj_path] end end |
.carthage_bootstrap_if_required(report) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 254 def carthage_bootstrap_if_required(report) return unless config.cartfile_path return if Dir.exist?(File.join(File.dirname(config.cartfile_path), "Carthage", "Build", "iOS")) say "carthage checkout required in order to build." if config.confirm install = confirm 'Run "carthage checkout && carthage build --platform ios" now?', true unless install say 'Please build your Carthage dependencies first in order to continue.' exit(-1) end end ToolHelper.verify_carthage install_command = "carthage checkout && carthage build --platform ios" say "Running #{install_command.inspect}" if report.sh(install_command).success? say "Done ✅" else say "#{install_command.inspect} failed. See report for details." exit(-1) end end |
.config ⇒ Object
21 22 23 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 21 def config Configuration::Configuration.current end |
.helper ⇒ Object
25 26 27 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 25 def helper BranchHelper end |
.pod_install_if_required(report) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 217 def pod_install_if_required(report) return unless config.pod_install_required? # Only if a Podfile is detected/supplied at the command line. say "pod install required in order to build." if config.confirm install = confirm 'Run "pod install" now?', true unless install say 'Please run "pod install" or "pod update" first in order to continue.' exit(-1) end end ToolHelper.verify_cocoapods install_command = "pod install" if config.pod_repo_update install_command += " --repo-update" else say "You have disabled \"pod repo update\". This can cause \"pod install\" to fail in\nsome cases. If that happens, please rerun without --no-pod-repo-update or run\n\"pod install --repo-update\" manually.\n" end say "Running #{install_command.inspect}" if report.sh(install_command).success? say "Done ✅" else say "#{install_command.inspect} failed. See report for details." exit(-1) end end |
.report_branch ⇒ Object
String containing information relevant to Branch setup
149 150 151 152 153 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 149 def report_branch report = "Branch configuration:\n" configurations = config.configuration ? [config.configuration] : config.configurations_from_scheme configurations.each do |configuration| report += " #{configuration}:\n" infoplist_path = config.target. "INFOPLIST_FILE", configuration infoplist_path = File. infoplist_path, File.dirname(config.xcodeproj_path) begin info_plist = File.open(infoplist_path) { |f| Plist.parse_xml f } branch_key = info_plist["branch_key"] if config.branch_key_setting_from_info_plist(configuration) annotation = "[#{File.basename infoplist_path}:$(#{config.branch_key_setting_from_info_plist})]" else annotation = "(#{File.basename infoplist_path})" end report += " Branch key(s) #{annotation}:\n" if branch_key.kind_of? Hash branch_key.each_key do |key| resolved_key = config.target. branch_key[key], configuration report += " #{key.capitalize}: #{resolved_key}\n" end elsif branch_key resolved_key = config.target. branch_key, configuration report += " #{resolved_key}\n" else report += " (none found)\n" end branch_universal_link_domains = info_plist["branch_universal_link_domains"] if branch_universal_link_domains if branch_universal_link_domains.kind_of? Array report += " branch_universal_link_domains (Info.plist):\n" branch_universal_link_domains.each do |domain| report += " #{domain}\n" end else report += " branch_universal_link_domains (Info.plist): #{branch_universal_link_domains}\n" end end rescue StandardError => e report += " (Failed to open Info.plist: #{e.message})\n" end end unless config.target.extension_target_type? begin configurations = config.configuration ? [config.configuration] : config.configurations_from_scheme configurations.each do |configuration| domains = helper.domains_from_project configuration report += " Universal Link domains (entitlements:#{configuration}):\n" domains.each do |domain| report += " #{domain}\n" end end rescue StandardError => e report += " (Failed to get Universal Link domains from entitlements file: #{e.message})\n" end end report += report_imports report end |
.report_header ⇒ Object
rubocop: disable Metrics/PerceivedComplexity
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 49 def report_header header = "cocoapods-core: #{Pod::CORE_VERSION}\n" header += `xcodebuild -version` header += "SDK: #{xcode_settings['SDK_NAME']}\n" if xcode_settings header += report_scheme configuration = config.configuration || config.configurations_from_scheme.first configurations = config.configuration ? [config.configuration] : config.configurations_from_scheme bundle_identifier = config.target. "PRODUCT_BUNDLE_IDENTIFIER", configuration dev_team = config.target. "DEVELOPMENT_TEAM", configuration header += "\nTarget #{config.target.name}:\n" header += " Bundle identifier: #{bundle_identifier || '(none)'}\n" header += " Development team: #{dev_team || '(none)'}\n" header += " Deployment target: #{config.target.deployment_target}\n" header += " Modules #{config.modules_enabled? ? '' : 'not '}enabled\n" header += " Swift #{config.swift_version}\n" if config.swift_version header += " Bridging header: #{config.relative_path(config.bridging_header_path)}\n" if config.bridging_header_path header += " Info.plist\n" configurations.each do |c| header += " #{c}: #{config.target.expanded_build_setting 'INFOPLIST_FILE', c}\n" end header += " Entitlements file\n" configurations.each do |c| header += " #{c}: #{config.target.expanded_build_setting 'CODE_SIGN_ENTITLEMENTS', c}\n" end if config.podfile_path begin cocoapods_version = `pod --version`.chomp rescue Errno::ENOENT header += "\n(pod command not found)\n" end if File.exist?("#{config.podfile_path}.lock") podfile_lock = Pod::Lockfile.from_file Pathname.new "#{config.podfile_path}.lock" end if cocoapods_version || podfile_lock header += "\nUsing CocoaPods v. " if cocoapods_version header += "#{cocoapods_version} (CLI) " end if podfile_lock header += "#{podfile_lock.cocoapods_version} (Podfile.lock)" end header += "\n" end target_definition = config.podfile.target_definitions[config.target.name] if target_definition branch_deps = target_definition.dependencies.select { |p| p.name =~ %r{^(Branch|Branch-SDK)(/.*)?$} } header += "Podfile target #{target_definition.name}:" header += "\n use_frameworks!" if target_definition.uses_frameworks? header += "\n platform: #{target_definition.platform}" header += "\n build configurations: #{target_definition.build_configurations}" header += "\n inheritance: #{target_definition.inheritance}" branch_deps.each do |dep| header += "\n pod '#{dep.name}', '#{dep.requirement}'" header += ", #{dep.external_source}" if dep.external_source header += "\n" end else header += "Target #{config.target.name.inspect} not found in Podfile.\n" end header += "\npod install #{config.pod_install_required? ? '' : 'not '}required.\n" end if config.cartfile_path begin carthage_version = `carthage version`.chomp header += "\nUsing Carthage v. #{carthage_version}\n" rescue Errno::ENOENT header += "\n(carthage command not found)\n" end end cartfile_requirement = config.requirement_from_cartfile header += "\nFrom Cartfile:\n#{cartfile_requirement}\n" if cartfile_requirement version = config.branch_version if version header += "\nBranch SDK v. #{version}\n" else header += "\nBranch SDK not found.\n" end header += "\n#{report_branch}" header end |
.report_imports ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 11 def report_imports report = "Branch imports:\n" config.branch_imports.each_key do |path| report += " #{config.relative_path path}:\n" report += " #{config.branch_imports[path].join("\n ")}" report += "\n" end report end |
.report_scheme ⇒ Object
41 42 43 44 45 46 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 41 def report_scheme report = "\nScheme #{config.scheme}:\n" report += " Configurations:\n" report += " #{config.configurations_from_scheme.join("\n ")}\n" report end |
.xcode_settings ⇒ Object
29 30 31 |
# File 'lib/branch_io_cli/helper/report_helper.rb', line 29 def xcode_settings Configuration::XcodeSettings.settings end |