Class: BranchIOCLI::Command::SetupCommand
- Defined in:
- lib/branch_io_cli/command/setup_command.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Attributes inherited from Command
Instance Method Summary collapse
-
#check_repo_status ⇒ Object
rubocop: enable Metrics/PerceivedComplexity.
-
#initialize(options) ⇒ SetupCommand
constructor
A new instance of SetupCommand.
-
#run! ⇒ Object
rubocop: disable Metrics/PerceivedComplexity.
Methods inherited from Command
Constructor Details
#initialize(options) ⇒ SetupCommand
Returns a new instance of SetupCommand.
9 10 11 12 13 14 |
# File 'lib/branch_io_cli/command/setup_command.rb', line 9 def initialize() super @config = Configuration::SetupConfiguration.new @keys = config.keys @domains = config.all_domains end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/branch_io_cli/command/setup_command.rb', line 7 def config @config end |
Instance Method Details
#check_repo_status ⇒ Object
rubocop: enable Metrics/PerceivedComplexity
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 |
# File 'lib/branch_io_cli/command/setup_command.rb', line 73 def check_repo_status # If the git command is not installed, there's not much we can do. # Don't want to use verify_git here, which will insist on installing # the command. The logic of that method could change. return if `which git`.empty? unless Dir.exist? ".git" `git rev-parse --git-dir > /dev/null 2>&1` # Not a git repo return unless $?.success? end `git diff-index --quiet HEAD --` return if $?.success? # Show the user sh "git status" choice = choose do || .header = "There are uncommitted changes in this repo. It's best to stash or commit them before continuing." .choice "Stash" .choice "Commit (you will be prompted for a commit message)" .choice "Quit" .prompt = "Please enter one of the options above: " end case choice when /^Stash/ sh "git stash -q" when /^Commit/ = ask "Please enter a commit message: " sh "git commit -aqm #{Shellwords.escape()}" else say "Please stash or commit your changes before continuing." exit(-1) end end |
#run! ⇒ Object
rubocop: disable Metrics/PerceivedComplexity
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/branch_io_cli/command/setup_command.rb', line 17 def run! # Make sure the user stashes or commits before continuing. check_repo_status xcodeproj = config.xcodeproj is_app_target = !config.target.extension_target_type? if is_app_target && .validate && !helper.validate_team_and_bundle_ids_from_aasa_files(@domains) say "Universal Link configuration failed validation." helper.errors.each { |error| say " #{error}" } return unless .force elsif is_app_target && .validate say "Universal Link configuration passed validation. ✅" end # the following calls can all raise IOError helper.add_keys_to_info_plist @keys helper.add_branch_universal_link_domains_to_info_plist @domains if is_app_target helper.ensure_uri_scheme_in_info_plist if is_app_target # does nothing if already present new_path = helper.add_universal_links_to_project @domains, false if is_app_target sh "git add #{Shellwords.escape(new_path)}" if .commit && new_path config_helper.target.add_system_frameworks .frameworks unless .frameworks.nil? || .frameworks.empty? xcodeproj.save case config.sdk_integration_mode when :cocoapods if File.exist? config.podfile_path helper.update_podfile else helper.add_cocoapods end when :carthage if File.exist? config.cartfile_path helper.update_cartfile , xcodeproj else helper.add_carthage end when :direct helper.add_direct end patch_helper.patch_source xcodeproj if .patch_source return unless .commit changes = helper.changes.to_a.map { |c| Pathname.new(File.(c)).relative_path_from(Pathname.pwd).to_s } sh "git commit -qm '[branch_io_cli] Branch SDK integration' #{changes.join(' ')}" end |