branch_io_cli 0.11.0 → 0.12.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.
@@ -25,8 +25,24 @@ module BranchIOCLI
25
25
  status = output.log_command command
26
26
  raise CommandError, [%{Error executing "#{command}": #{status}.}, status] unless status.success?
27
27
  end
28
+
29
+ # Clear the screen and move the cursor to the top using highline
30
+ def clear
31
+ say "\e[2J\e[H"
32
+ end
33
+
34
+ # Ask a yes/no question with a default
35
+ def confirm(question, default_value)
36
+ yn_opts = default_value ? "Y/n" : "y/N"
37
+ value = ask "#{question} (#{yn_opts}) ", nil
38
+
39
+ # Convert to true/false
40
+ dummy_option = Configuration::Option.new({})
41
+ value = dummy_option.convert(value)
42
+
43
+ return default_value if value.nil? || value.kind_of?(String)
44
+ value
45
+ end
28
46
  end
29
47
  end
30
48
  end
31
-
32
- include BranchIOCLI::Helper::Methods
@@ -6,6 +6,8 @@ module BranchIOCLI
6
6
  module Helper
7
7
  class ReportHelper
8
8
  class << self
9
+ include Methods
10
+
9
11
  def report_imports
10
12
  report = "Branch imports:\n"
11
13
  config.branch_imports.each_key do |path|
@@ -57,9 +59,9 @@ module BranchIOCLI
57
59
  configuration = config.configuration || config.configurations_from_scheme.first
58
60
  configurations = config.configuration ? [config.configuration] : config.configurations_from_scheme
59
61
 
60
- bundle_identifier = helper.expanded_build_setting config.target, "PRODUCT_BUNDLE_IDENTIFIER", configuration
61
- dev_team = helper.expanded_build_setting config.target, "DEVELOPMENT_TEAM", configuration
62
- entitlements_path = helper.expanded_build_setting config.target, "CODE_SIGN_ENTITLEMENTS", configuration
62
+ bundle_identifier = config.target.expanded_build_setting "PRODUCT_BUNDLE_IDENTIFIER", configuration
63
+ dev_team = config.target.expanded_build_setting "DEVELOPMENT_TEAM", configuration
64
+ entitlements_path = config.target.expanded_build_setting "CODE_SIGN_ENTITLEMENTS", configuration
63
65
 
64
66
  header += "\nTarget #{config.target.name}:\n"
65
67
  header += " Bundle identifier: #{bundle_identifier || '(none)'}\n"
@@ -71,7 +73,7 @@ module BranchIOCLI
71
73
 
72
74
  header += " Info.plist\n"
73
75
  configurations.each do |c|
74
- header += " #{c}: #{helper.expanded_build_setting config.target, 'INFOPLIST_FILE', c}\n"
76
+ header += " #{c}: #{config.target.expanded_build_setting 'INFOPLIST_FILE', c}\n"
75
77
  end
76
78
 
77
79
  header += " Entitlements file: #{config.relative_path(entitlements_path) || '(none)'}\n"
@@ -151,7 +153,7 @@ module BranchIOCLI
151
153
 
152
154
  configurations.each do |configuration|
153
155
  report += " #{configuration}:\n"
154
- infoplist_path = helper.expanded_build_setting config.target, "INFOPLIST_FILE", configuration
156
+ infoplist_path = config.target.expanded_build_setting "INFOPLIST_FILE", configuration
155
157
  infoplist_path = File.expand_path infoplist_path, File.dirname(config.xcodeproj_path)
156
158
 
157
159
  begin
@@ -215,9 +217,10 @@ module BranchIOCLI
215
217
  return unless config.pod_install_required?
216
218
  # Only if a Podfile is detected/supplied at the command line.
217
219
  say "pod install required in order to build."
218
- install = ask %{Run "pod install" now (Y/n)? }
219
- if install.downcase =~ /^n/
220
- say %{Please run "pod install" or "pod update" first in order to continue.}
220
+ install = confirm 'Run "pod install" now?', true
221
+
222
+ unless install
223
+ say 'Please run "pod install" or "pod update" first in order to continue.'
221
224
  exit(-1)
222
225
  end
223
226
 
@@ -0,0 +1,7 @@
1
+ module BranchIOCLI
2
+ module Helper
3
+ class Util
4
+ extend Methods
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,126 @@
1
+ require "xcodeproj"
2
+
3
+ module Xcodeproj
4
+ class Project
5
+ # Local override to allow for user schemes.
6
+ #
7
+ # Get list of shared and user schemes in project
8
+ #
9
+ # @param [String] path
10
+ # project path
11
+ #
12
+ # @return [Array]
13
+ #
14
+ def self.schemes(project_path)
15
+ base_dirs = [File.join(project_path, 'xcshareddata', 'xcschemes'),
16
+ File.join(project_path, 'xcuserdata', "#{ENV['USER']}.xcuserdatad", 'xcschemes')]
17
+
18
+ # Take any .xcscheme file from base_dirs
19
+ schemes = base_dirs.inject([]) { |memo, dir| memo + Dir[File.join dir, '*.xcscheme'] }
20
+ .map { |f| File.basename(f, '.xcscheme') }
21
+
22
+ # Include any scheme defined in the xcschememanagement.plist, if it exists.
23
+ base_dirs.map { |d| File.join d, 'xcschememanagement.plist' }
24
+ .select { |f| File.exist? f }.each do |plist_path|
25
+ plist = File.open(plist_path) { |f| ::Plist.parse_xml f }
26
+ scheme_user_state = plist["SchemeUserState"]
27
+ schemes += scheme_user_state.keys.map { |k| File.basename k, '.xcscheme' }
28
+ end
29
+
30
+ schemes.uniq!
31
+ if schemes.empty? && File.exist?(project_path)
32
+ # Open the project, get all targets. Add one scheme per target.
33
+ project = self.open project_path
34
+ schemes += project.targets.reject(&:test_target_type?).map(&:name)
35
+ elsif schemes.empty?
36
+ schemes << File.basename(project_path, '.xcodeproj')
37
+ end
38
+ schemes
39
+ end
40
+
41
+ module Object
42
+ class PBXNativeTarget
43
+ # List of build settings with values not present in the configuration.
44
+ #
45
+ # @return [Hash] A hash of fixed build settings
46
+ def fixed_build_settings
47
+ {
48
+ "SRCROOT" => ".",
49
+ "TARGET_NAME" => name
50
+ }
51
+ end
52
+
53
+ # Layer on top of #resolved_build_setting to recursively expand all
54
+ # build settings as they would be resolved in Xcode. Calls
55
+ # #expand_build_settings on the value returned by
56
+ # #resolved_build_setting, with the exception of anything defined
57
+ # in #fixed_build_settings. Those settings are returned directly.
58
+ #
59
+ # @param setting_name [String] Name of any valid build setting for this target
60
+ # @param configuration [String] Name of any valid configuration for this target
61
+ # @return [String, nil] The build setting value with all embedded settings expanded or nil if not found
62
+ def expanded_build_setting(setting_name, configuration)
63
+ fixed_setting = fixed_build_settings[setting_name]
64
+ return fixed_setting.clone if fixed_setting
65
+
66
+ # second arg true means if there is an xcconfig, also consult that
67
+ begin
68
+ setting_value = resolved_build_setting(setting_name, true)[configuration]
69
+ rescue Errno::ENOENT
70
+ # If not found, look up without it. Unresolved settings will be passed
71
+ # unmodified, e.g. $(UNRESOLVED_SETTING_NAME).
72
+ setting_value = resolved_build_setting(setting_name, false)[configuration]
73
+ end
74
+
75
+ return if setting_value.nil?
76
+
77
+ expand_build_settings setting_value, configuration
78
+ end
79
+
80
+ # Recursively resolves build settings in any string for the given
81
+ # configuration. This includes xcconfig expansion and handling for the
82
+ # :rfc1034identifier. Unresolved settings are passed unchanged, e.g.
83
+ # $(UNRESOLVED_SETTING_NAME).
84
+ #
85
+ # @param string [String] Any string that may include build settings to be resolved
86
+ # @param configuration [String] Name of any valid configuration for this target
87
+ # @return [String] A copy of the original string with all embedded build settings expanded
88
+ def expand_build_settings(string, configuration)
89
+ search_position = 0
90
+ string = string.clone
91
+
92
+ # HACK: When matching against an xcconfig, as here, sometimes the macro is just returned
93
+ # without delimiters, e.g. TARGET_NAME or BUILT_PRODUCTS_DIR/Branch.framework. We allow
94
+ # these two patterns for now.
95
+ while (matches = %r{\$\(([^(){}]*)\)|\$\{([^(){}]*)\}|^([A-Z_]+)(/.*)?$}.match(string, search_position))
96
+ original_macro = matches[1] || matches[2] || matches[3]
97
+ delimiter_length = matches[3] ? 0 : 3 # $() or ${}
98
+ delimiter_offset = matches[3] ? 0 : 2 # $( or ${
99
+ search_position = string.index(original_macro) - delimiter_offset
100
+
101
+ if (m = /^(.+):(.+)$/.match original_macro)
102
+ macro_name = m[1]
103
+ modifier = m[2]
104
+ else
105
+ macro_name = original_macro
106
+ end
107
+
108
+ expanded_macro = expanded_build_setting macro_name, configuration
109
+
110
+ search_position += original_macro.length + delimiter_length and next if expanded_macro.nil?
111
+
112
+ # From the Apple dev portal when creating a new app ID:
113
+ # You cannot use special characters such as @, &, *, ', "
114
+ # From trial and error with Xcode, it appears that only letters, digits and hyphens are allowed.
115
+ # Everything else becomes a hyphen, including underscores.
116
+ expanded_macro.gsub!(/[^A-Za-z0-9-]/, '-') if modifier == "rfc1034identifier"
117
+
118
+ string.gsub!(/\$\(#{original_macro}\)|\$\{#{original_macro}\}|^#{original_macro}/, expanded_macro)
119
+ search_position += expanded_macro.length
120
+ end
121
+ string
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -23,7 +23,7 @@ module BranchIOCLI
23
23
 
24
24
  paths.each do |path|
25
25
  Dir.chdir(path) do |p|
26
- Command::ReportCommand.new(Configuration::ReportConfiguration.wrapper(args[:options] || {})).run!
26
+ Command::ReportCommand.new(Configuration::ReportConfiguration.wrapper(args[:options])).run!
27
27
  end
28
28
  end
29
29
  end
@@ -37,7 +37,7 @@ module BranchIOCLI
37
37
 
38
38
  paths.each do |path|
39
39
  Dir.chdir(path) do |p|
40
- Command::SetupCommand.new(Configuration::SetupConfiguration.wrapper(args[:options] || {})).run!
40
+ Command::SetupCommand.new(Configuration::SetupConfiguration.wrapper(args[:options])).run!
41
41
  end
42
42
  end
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module BranchIOCLI
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
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.11.0
4
+ version: 0.12.0
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-17 00:00:00.000000000 Z
12
+ date: 2017-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: CFPropertyList
@@ -311,7 +311,7 @@ files:
311
311
  - lib/branch_io_cli/core_ext/io.rb
312
312
  - lib/branch_io_cli/core_ext/regexp.rb
313
313
  - lib/branch_io_cli/format.rb
314
- - lib/branch_io_cli/format/commander_format.rb
314
+ - lib/branch_io_cli/format/highline_format.rb
315
315
  - lib/branch_io_cli/format/markdown_format.rb
316
316
  - lib/branch_io_cli/helper.rb
317
317
  - lib/branch_io_cli/helper/android_helper.rb
@@ -320,6 +320,8 @@ files:
320
320
  - lib/branch_io_cli/helper/methods.rb
321
321
  - lib/branch_io_cli/helper/patch_helper.rb
322
322
  - lib/branch_io_cli/helper/report_helper.rb
323
+ - lib/branch_io_cli/helper/util.rb
324
+ - lib/branch_io_cli/helper/xcodeproj_ext.rb
323
325
  - lib/branch_io_cli/rake_task.rb
324
326
  - lib/branch_io_cli/version.rb
325
327
  homepage: http://github.com/BranchMetrics/branch_io_cli