Class: Fastlane::Actions::SetupBranchAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::SetupBranchAction
- Defined in:
- lib/fastlane/plugin/branch/actions/setup_branch_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
-
.description ⇒ Object
rubocop: enable Metrics/PerceivedComplexity.
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
-
.run(params) ⇒ Object
rubocop: disable Metrics/PerceivedComplexity.
Class Method Details
.authors ⇒ Object
86 87 88 89 90 91 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 86 def self. [ "Branch <[email protected]>", "Jimmy Dee <[email protected]>" ] end |
.available_options ⇒ Object
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 146 147 148 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 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 115 def self. [ FastlaneCore::ConfigItem.new(key: :xcodeproj, env_name: "BRANCH_XCODEPROJ", description: "Path to an Xcode project to modify", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :android_project_path, env_name: "BRANCH_ANDROID_PROJECT_PATH", description: "Path to an Android project to modify", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :android_manifest_path, env_name: "BRANCH_ANDROID_MANIFEST_PATH", description: "Path to and Android manifest to modify", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :live_key, env_name: "BRANCH_LIVE_KEY", description: "The Branch live key for your app", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :test_key, env_name: "BRANCH_TEST_KEY", description: "The Branch test key for your app", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :domains, env_name: "BRANCH_DOMAINS", description: "Branch (and/or non-Branch) Universal Link/App Link domains to add (comma-separated list or array)", optional: true, is_string: false), FastlaneCore::ConfigItem.new(key: :app_link_subdomain, env_name: "BRANCH_APP_LINK_SUBDOMAIN", description: "app.link subdomain", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :uri_scheme, env_name: "BRANCH_URI_SCHEME", description: "Custom URI scheme used with Branch (Android only)", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :activity_name, env_name: "BRANCH_ACTIVITY_NAME", description: "Name of the Activity in the manifest containing Branch intent-filers (Android only)", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :target, env_name: "BRANCH_TARGET", description: "Name of the target in the Xcode project to modify (iOS only)", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :update_bundle_and_team_ids, env_name: "BRANCH_UPDATE_BUNDLE_AND_TEAM_IDS", description: "If set to true, updates the bundle and team identifiers to match the AASA file (iOS only)", optional: true, default_value: false, is_string: false), FastlaneCore::ConfigItem.new(key: :remove_existing_domains, env_name: "BRANCH_REMOVE_EXISTING_DOMAINS", description: "If set to true, removes any existing domains before adding Branch domains", optional: true, default_value: false, is_string: false), FastlaneCore::ConfigItem.new(key: :validate, env_name: "BRANCH_VALIDATE", description: "Determines whether to validate the resulting Universal Link configuration before modifying the project", default_value: true, is_string: false), FastlaneCore::ConfigItem.new(key: :force, env_name: "BRANCH_FORCE_UPDATE", description: "Update project(s) even if Universal Link validation fails", optional: true, default_value: false, is_string: false), FastlaneCore::ConfigItem.new(key: :commit, env_name: "BRANCH_COMMIT_CHANGES", description: "Set to true to commit changes to Git; set to a string to commit with a custom message", optional: true, default_value: false, is_string: false) ] end |
.category ⇒ Object
203 204 205 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 203 def self.category :project end |
.description ⇒ Object
rubocop: enable Metrics/PerceivedComplexity
82 83 84 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 82 def self.description "Adds Branch keys, custom URI schemes and domains to iOS and Android projects." end |
.details ⇒ Object
93 94 95 96 97 98 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 93 def self.details "This action automatically configures Xcode and Android projects that use the Branch SDK " \ "for Universal Links, App Links and custom URI handling. It modifies Xcode project settings and " \ "entitlements as well as Info.plist and AndroidManifest.xml files. It also validates the Universal Link " \ "configuration for Xcode projects." end |
.example_code ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 100 def self.example_code [ <<-EOF setup_branch( live_key: "key_live_xxxx", test_key: "key_test_yyyy", app_link_subdomain: "myapp", uri_scheme: "myscheme", # Android only android_project_path: "MyAndroidApp", # MyAndroidApp/src/main/AndroidManifest.xml xcodeproj: "MyIOSApp.xcodeproj" ) EOF ] end |
.is_supported?(platform) ⇒ Boolean
199 200 201 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 199 def self.is_supported?(platform) [:ios, :android].include? platform end |
.run(params) ⇒ Object
rubocop: disable Metrics/PerceivedComplexity
8 9 10 11 12 13 14 15 16 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 71 72 73 74 75 76 77 78 79 |
# File 'lib/fastlane/plugin/branch/actions/setup_branch_action.rb', line 8 def self.run(params) # First augment with any defaults from Branchfile, if present params.load_configuration_file("Branchfile") helper = Helper::BranchHelper keys = helper.keys_from_params params raise "Must specify :live_key or :test_key." if keys.empty? domains = helper.domains_from_params params raise "Cannot determine domains to add to project. Specify :app_link_subdomain or :domains." if domains.empty? if params[:xcodeproj].nil? and params[:android_project_path].nil? and params[:android_manifest_path].nil? raise ":xcodeproj, :android_manifest_path or :android_project_path is required" end UI. "live key: #{keys[:live]}" unless keys[:live].nil? UI. "test key: #{keys[:test]}" unless keys[:test].nil? UI. "domains: #{domains}" if params[:xcodeproj] # raises xcodeproj = Xcodeproj::Project.open params[:xcodeproj] target = params[:target] # may be nil if params[:update_bundle_and_team_ids] helper.update_team_and_bundle_ids_from_aasa_file xcodeproj, target, domains.first elsif params[:validate] && helper.validate_team_and_bundle_ids_from_aasa_files(xcodeproj, target, domains, params[:remove_existing_domains]) UI. "Universal Link configuration passed validation. ✅" elsif params[:validate] UI.error "Universal Link configuration failed validation." helper.errors.each { |error| UI.error " #{error}" } return unless params[:force] end # the following calls can all raise IOError helper.add_keys_to_info_plist xcodeproj, target, keys helper.add_branch_universal_link_domains_to_info_plist xcodeproj, target, domains new_path = helper.add_universal_links_to_project xcodeproj, target, domains, params[:remove_existing_domains] other_action.git_add path: new_path if params[:commit] && new_path xcodeproj.save end if params[:android_project_path] || params[:android_manifest_path] # :android_manifest_path overrides :android_project_path manifest_path = params[:android_manifest_path] || "#{params[:android_project_path]}/app/src/main/AndroidManifest.xml" manifest = File.open(manifest_path) { |f| REXML::Document.new f } helper.add_keys_to_android_manifest manifest, keys # :activity_name and :uri_scheme may be nil. :remove_existing_domains defaults to false helper.add_intent_filters_to_android_manifest manifest, domains, params[:uri_scheme], params[:activity_name], params[:remove_existing_domains] File.open(manifest_path, "w") do |f| manifest.write f, 4 end helper.add_change File.(manifest_path, Bundler.root) end if params[:commit] = params[:commit].kind_of?(String) ? params[:commit] : "[Fastlane] Branch SDK integration" other_action.git_commit path: helper.changes.to_a, message: end rescue => e UI.user_error! "Error in SetupBranchAction: #{e.}\n#{e.backtrace}" end |