Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 3a4b03c

Browse files
authored
Merge pull request #39 from BranchMetrics/report-action
New action
2 parents a5dfe58 + bebd318 commit 3a4b03c

File tree

13 files changed

+332
-269
lines changed

13 files changed

+332
-269
lines changed

README.md

Lines changed: 113 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -29,197 +29,202 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To
2929
fastlane add_plugin branch
3030
```
3131

32-
## setup_branch action
32+
<!-- The following is generated. Do not edit by hand. Run fastlane readme to -->
33+
<!-- regenerate this section. -->
34+
<!-- BEGIN ACTION REFERENCE -->
35+
### setup_branch action
36+
37+
```Ruby
38+
setup_branch
39+
```
3340

3441
Integrates the Branch SDK into a native app project. This currently supports iOS only.
3542
It will infer the project location if there is exactly one .xcodeproj anywhere under
3643
the current directory, excluding any in a Pods or Carthage folder. Otherwise, specify
37-
the project location using the `--xcodeproj` option, or the CLI will prompt you for the
44+
the project location using the `xcodeproj` option, or the CLI will prompt you for the
3845
location.
3946

4047
If a Podfile or Cartfile is detected, the Branch SDK will be added to the relevant
4148
configuration file and the dependencies updated to include the Branch framework.
42-
This behavior may be suppressed using `--no-add-sdk`. If no Podfile or Cartfile
49+
This behavior may be suppressed using `no_add_sdk`. If no Podfile or Cartfile
4350
is found, and Branch.framework is not already among the project's dependencies,
4451
you will be prompted for a number of choices, including setting up CocoaPods or
4552
Carthage for the project or directly installing the Branch.framework.
4653

4754
By default, all supplied Universal Link domains are validated. If validation passes,
4855
the setup continues. If validation fails, no further action is taken. Suppress
49-
validation using `--no-validate` or force changes when validation fails using
50-
`--force`.
56+
validation using `no_validate` or force changes when validation fails using
57+
`force`.
5158

5259
By default, this command will look for the first app target in the project. Test
53-
targets are not supported. To set up an extension target, supply the `--target` option.
60+
targets are not supported. To set up an extension target, supply the `target` option.
5461

5562
All relevant target settings are modified. The Branch keys are added to the Info.plist,
56-
along with the `branch_universal_link_domains` key for custom domains (when `--domains`
63+
along with the `branch_universal_link_domains` key for custom domains (when `domains`
5764
is used). For app targets, all domains are added to the project's Associated Domains
5865
entitlement. An entitlements file is also added for app targets if none is found.
59-
Optionally, if `--frameworks` is specified, this command can add a list of system
66+
Optionally, if `frameworks` is specified, this command can add a list of system
6067
frameworks to the target's dependencies (e.g., AdSupport, CoreSpotlight, SafariServices).
6168

6269
A language-specific patch is applied to the AppDelegate (Swift or Objective-C).
63-
This can be suppressed using `--no-patch-source`.
70+
This can be suppressed using `no_patch_source`.
6471

6572
#### Prerequisites
6673

67-
Before using this command, make sure to set up your app in the [Branch Dashboard](https://dashboard.branch.io). See https://docs.branch.io/pages/dashboard/integrate/ for details. To use the `setup` command, you need:
74+
Before using this command, make sure to set up your app in the Branch Dashboard
75+
(https://dashboard.branch.io). See https://docs.branch.io/pages/dashboard/integrate/
76+
for details. To use the `setup` command, you need:
6877

6978
- Branch key(s), either live, test or both
7079
- Domain name(s) used for Branch links
7180
- Location of your Xcode project (may be inferred in simple projects)
7281

73-
If using the `--commit` option, `git` is required. If not using `--no-add-sdk`,
82+
If using the `commit` option, `git` is required. If not using `no_add_sdk`,
7483
the `pod` or `carthage` command may be required. If not found, the CLI will
7584
offer to install and set up these command-line tools for you. Alternately, you can arrange
7685
that the relevant commands are available in your `PATH`.
7786

78-
```ruby
87+
All parameters are optional. A live key or test key, or both is required, as well
88+
as at least one domain. Specify `live_key`, `test_key` or both and `app_link_subdomain`,
89+
`domains` or both. If these are not specified, this command will prompt you
90+
for this information.
91+
92+
See https://github.com/BranchMetrics/branch_io_cli#setup-command for more information.
93+
94+
95+
#### Options
96+
97+
|Fastfile key|description|Environment variable|type|default value|
98+
|---|---|---|---|---|
99+
|live_key|Branch live key|BRANCH_LIVE_KEY|Boolean||
100+
|test_key|Branch test key|BRANCH_TEST_KEY|Boolean||
101+
|domains|Comma-separated list of custom domain(s) or non-Branch domain(s)|BRANCH_DOMAINS|Boolean||
102+
|app_link_subdomain|Branch app.link subdomain, e.g. myapp for myapp.app.link|BRANCH_APP_LINK_SUBDOMAIN|Boolean||
103+
|uri_scheme|Custom URI scheme used in the Branch Dashboard for this app|BRANCH_URI_SCHEME|Boolean||
104+
|setting|Use a custom build setting for the Branch key (default: Use Info.plist)|BRANCH_SETTING|Boolean||
105+
|test_configurations|List of configurations that use the test key with a user-defined setting (default: Debug configurations)|BRANCH_TEST_CONFIGURATIONS|Boolean||
106+
|xcodeproj|Path to an Xcode project to update|BRANCH_XCODEPROJ|Boolean||
107+
|target|Name of a target to modify in the Xcode project|BRANCH_TARGET|Boolean||
108+
|podfile|Path to the Podfile for the project|BRANCH_PODFILE|Boolean||
109+
|cartfile|Path to the Cartfile for the project|BRANCH_CARTFILE|Boolean||
110+
|carthage_command|Command to run when installing from Carthage|BRANCH_CARTHAGE_COMMAND|Boolean|update --platform ios|
111+
|frameworks|Comma-separated list of system frameworks to add to the project|BRANCH_FRAMEWORKS|Boolean||
112+
|pod_repo_update|Update the local podspec repo before installing|BRANCH_POD_REPO_UPDATE||true|
113+
|validate|Validate Universal Link configuration|BRANCH_VALIDATE||true|
114+
|force|Update project even if Universal Link validation fails|BRANCH_FORCE||false|
115+
|add_sdk|Add the Branch framework to the project|BRANCH_ADD_SDK||true|
116+
|patch_source|Add Branch SDK calls to the AppDelegate|BRANCH_PATCH_SOURCE||true|
117+
|commit|Commit the results to Git if non-blank|BRANCH_COMMIT|Boolean||
118+
|confirm|Confirm configuration before proceeding|BRANCH_CONFIRM||true|
119+
120+
121+
#### Examples
122+
123+
```Ruby
79124
setup_branch(
80125
live_key: "key_live_xxxx",
81126
test_key: "key_test_yyyy",
82127
app_link_subdomain: "myapp",
83128
uri_scheme: "myscheme",
84129
xcodeproj: "MyIOSApp.xcodeproj"
85130
)
131+
86132
```
87133

88-
Use the `:domains` parameter to specify custom domains, including non-Branch domains
89-
```ruby
90-
setup_branch(
91-
live_key: "key_live_xxxx",
92-
domains: %w{example.com www.example.com}
93-
xcodeproj: "MyIOSApp.xcodeproj"
94-
)
134+
135+
136+
137+
### validate_universal_links action
138+
139+
```Ruby
140+
validate_universal_links
95141
```
96142

97-
Available options:
143+
This command validates all Universal Link domains configured in a project without making any
144+
modification. It validates both Branch and non-Branch domains. Unlike web-based Universal
145+
Link validators, this command operates directly on the project. It finds the bundle and
146+
signing team identifiers in the project as well as the app's Associated Domains. It requests
147+
the apple-app-site-association file for each domain and validates the file against the
148+
project's settings.
98149

99-
|Fastfile key|description|Environment variable|type|default value|
100-
|---|---|---|---|---|
101-
|:live_key|The Branch live key to use (:live_key or :test_key is required)|BRANCH_LIVE_KEY|string||
102-
|:test_key|The Branch test key to use (:live_key or :test_key is required)|BRANCH_TEST_KEY|string||
103-
|:app_link_subdomain|An app.link subdomain to use (:app_link_subdomain or :domains is required. The union of the two sets of domains will be used.)|BRANCH_APP_LINK_SUBDOMAIN|string||
104-
|:domains|A list of domains (custom domains or Branch domains) to use (:app_link_subdomain or :domains is required. The union of the two sets of domains will be used.)|BRANCH_DOMAINS|array of strings or comma-separated string||
105-
|:uri_scheme|A URI scheme to add to the manifest|BRANCH_URI_SCHEME|string||
106-
|:xcodeproj|Path to a .xcodeproj directory to use. (:xcodeproj, :android_project_path or :android_manifest_path is required.)|BRANCH_XCODEPROJ|string||
107-
|:target|Name of the target to use in the Xcode project (iOS only; optional)|BRANCH_TARGET|string||
108-
|:validate|Determines whether to validate the resulting Universal Link configuration before modifying the project|BRANCH_VALIDATE|boolean|true|
109-
|:force|Update project(s) even if Universal Link validation fails|BRANCH_FORCE_UPDATE|boolean|false|
110-
|:commit|Set to true to commit changes to Git; set to a string to commit with a custom message|BRANCH_COMMIT_CHANGES|boolean or string|false|
111-
|:frameworks|A list of system frameworks to add to the target that uses the Branch SDK (iOS only)|BRANCH_FRAMEWORKS|array|[]|
112-
|:add_sdk|Set to false to disable automatic integration of the Branch SDK|BRANCH_ADD_SDK|boolean|true|
113-
|:podfile|Path to a Podfile to update (iOS only)|BRANCH_PODFILE|string||
114-
|:patch_source|Set to false to disable automatic source-code patching|BRANCH_PATCH_SOURCE|boolean|true|
115-
|:pod_repo_update|Set to false to disable update of local podspec repo before pod install|BRANCH_POD_REPO_UPDATE|boolean|true|
116-
|:cartfile|Path to a Cartfile to update (iOS only)|BRANCH_CARTFILE|string||
117-
|:carthage_command|Command to use when installing with Carthage|BRANCH_CARTHAGE_COMMAND|string|update --platform ios|
150+
Only app targets are supported for this command. By default, it will validate the first.
151+
If your project has multiple app targets, specify the `target` option to validate other
152+
targets.
118153

119-
Individually, all parameters are optional, but the following conditions apply:
154+
All parameters are optional. If `domains` is specified, the list of Universal Link domains in
155+
the Associated Domains entitlement must exactly match this list, without regard to order. If
156+
no `domains` are provided, validation passes if at least one Universal Link domain is
157+
configured and passes validation, and no Universal Link domain is present that does not pass
158+
validation.
120159

121-
- :live_key or :test_key must be specified.
122-
- :app_link_subdomain or :domains must be specified.
160+
See https://github.com/BranchMetrics/branch_io_cli#validate-command for more information.
123161

124-
If these parameters are not specified, you will be prompted for them.
125162

126-
This action also supports an optional Branchfile to specify configuration options.
127-
See the sample [Branchfile](./fastlane/Branchfile) in the fastlane subdirectory of this repo.
163+
#### Options
128164

129-
## validate_universal_links action (iOS only)
165+
|Fastfile key|description|Environment variable|type|default value|
166+
|---|---|---|---|---|
167+
|domains|Comma-separated list of domains to validate (Branch domains or non-Branch domains)|BRANCH_DOMAINS|Boolean|[]|
168+
|xcodeproj|Path to an Xcode project to update|BRANCH_XCODEPROJ|Boolean||
169+
|target|Name of a target to validate in the Xcode project|BRANCH_TARGET|Boolean||
130170

131-
This action validates all Universal Link domains configured in a project without making any modification.
132-
It validates both Branch and non-Branch domains.
133171

172+
#### Examples
134173

135-
```ruby
174+
```Ruby
136175
validate_universal_links
137176
```
138177

139-
```ruby
178+
```Ruby
140179
validate_universal_links(xcodeproj: "MyProject.xcodeproj")
141180
```
142181

143-
```ruby
182+
```Ruby
144183
validate_universal_links(xcodeproj: "MyProject.xcodeproj", target: "MyProject")
145184
```
146185

147-
```ruby
186+
```Ruby
148187
validate_universal_links(domains: %w{example.com www.example.com})
149188
```
150189

151-
Available options:
152-
153-
|Fastfile key|description|Environment variable|type|default value|
154-
|---|---|---|---|---|
155-
|:xcodeproj|Path to a .xcodeproj directory to use|BRANCH_XCODEPROJ|string||
156-
|:target|Name of the target to use in the Xcode project|BRANCH_TARGET|string||
157-
|:domains|A list of domains (custom domains or Branch domains) that must be present in the project.|BRANCH_DOMAINS|array of strings or comma-separated string||
158-
159-
All parameters are optional. Without any parameters, the action looks for a single .xcodeproj
160-
folder (with the exception of a Pods project) and reports an error if none or more than one is found.
161-
It uses the first non-test, non-extension target in that project.
162-
163-
If the :domains parameter is not provided, validation will pass as long as there is at least
164-
one Universal Link domain configured for the target, and all Universal Link domains pass
165-
AASA validation. If the the :domains parameter is provided, the Universal Link domains in
166-
the project must also match the value of this parameter without regard to order.
167190

168-
This action does not use the Branchfile.
169191

170-
## Examples
171192

172-
There is an example [Fastfile](./fastlane/Fastfile) in this repo that defines a number of
173-
example lanes. Be sure to run `bundle install` before trying any of the examples.
174193

175-
### setup
194+
### branch_report action
176195

177-
This lane sets up the BranchPluginExample project
178-
in
179-
[examples/ios/BranchPluginExample](./examples/ios/BranchPluginExample).
180-
The Xcode project uses CocoaPods and Swift.
181-
182-
```bash
183-
bundle exec fastlane setup
196+
```Ruby
197+
branch_report
184198
```
185199

186-
### setup_and_commit
187-
188-
This lane sets up the BranchPluginExample projects and also commits the results to git.
200+
_Work in progress_
189201

190-
```bash
191-
bundle exec fastlane setup_and_commit
192-
```
202+
This command optionally cleans and then builds a workspace or project, generating a verbose
203+
report with additional diagnostic information suitable for opening a support ticket.
193204

194-
### setup_objc
195205

196-
This lane sets up the BranchPluginExampleObjc project
197-
in [examples/ios/BranchPluginExampleObjc](./examples/ios/BranchPluginExampleObjc).
198-
The project uses CocoaPods and Objective-C.
206+
#### Options
199207

200-
```bash
201-
bundle exec fastlane setup_objc
202-
```
203-
204-
### setup_carthage
205-
206-
This lane sets up the BranchPluginExampleCarthage project
207-
in [examples/ios/BranchPluginExampleCarthage](./examples/ios/BranchPluginExampleCarthage).
208-
The project uses Carthage and Swift.
208+
|Fastfile key|description|Environment variable|type|default value|
209+
|---|---|---|---|---|
210+
|workspace|Path to an Xcode workspace|BRANCH_WORKSPACE|Boolean||
211+
|xcodeproj|Path to an Xcode project|BRANCH_XCODEPROJ|Boolean||
212+
|scheme|A scheme from the project or workspace to build|BRANCH_SCHEME|Boolean||
213+
|target|A target to build|BRANCH_TARGET|Boolean||
214+
|configuration|The build configuration to use (default: Scheme-dependent)|BRANCH_CONFIGURATION|Boolean||
215+
|sdk|Passed as -sdk to xcodebuild|BRANCH_SDK|Boolean|iphonesimulator|
216+
|podfile|Path to the Podfile for the project|BRANCH_PODFILE|Boolean||
217+
|cartfile|Path to the Cartfile for the project|BRANCH_CARTFILE|Boolean||
218+
|clean|Clean before attempting to build|BRANCH_CLEAN||true|
219+
|header_only|Write a report header to standard output and exit|BRANCH_HEADER_ONLY||false|
220+
|pod_repo_update|Update the local podspec repo before installing|BRANCH_POD_REPO_UPDATE||true|
221+
|out|Report output path|BRANCH_REPORT_PATH|Boolean|./report.txt|
209222

210-
```bash
211-
bundle exec fastlane setup_carthage
212-
```
213223

214-
### validate
215224

216-
This lane validates the Universal Link configuration for the BranchPluginExample
217-
project in [examples/ios/BranchPluginExample](./examples/ios/BranchPluginExample).
218225

219-
```bash
220-
bundle exec fastlane validate
221-
```
222226

227+
<!-- END ACTION REFERENCE -->
223228

224229
## Run tests for this plugin
225230

actions/update_readme.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require "fastlane/plugin/branch/fastlane_format"
2+
3+
include Fastlane::Branch::FastlaneMarkdownFormat
4+
5+
module Fastlane
6+
module Actions
7+
class UpdateReadmeAction < Action
8+
class << self
9+
def run(params)
10+
[SetupBranchAction, ValidateUniversalLinksAction, BranchReportAction].inject("") do |docs, action|
11+
@action = action
12+
@action_name = action.name.sub(/^Fastlane::Actions::(\w+)Action$/, '\1').gsub(/([a-z])([A-Z])/, '\1_\2').downcase
13+
14+
if action == SetupBranchAction
15+
@command = BranchIOCLI::Command::SetupCommand
16+
elsif action == ValidateUniversalLinksAction
17+
@command = BranchIOCLI::Command::ValidateCommand
18+
elsif action == BranchReportAction
19+
@command = BranchIOCLI::Command::ReportCommand
20+
end
21+
22+
docs + local_render(:action)
23+
end
24+
end
25+
26+
def description
27+
"Update the contents of the README in this repo"
28+
end
29+
end
30+
end
31+
end
32+
end

assets/templates/action.erb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<%= header "#{@action_name} action", 3 %>
2+
3+
```Ruby
4+
<%= @action_name %>
5+
```
6+
7+
<%= render "#{@command.command_name}_description" %>
8+
9+
<%= header "Options", 4 %>
10+
11+
|Fastfile key|description|Environment variable|type|default value|
12+
|---|---|---|---|---|
13+
<%= table_options %>
14+
15+
<% if @action.respond_to?(:example_code) && !@action.example_code.blank? %>
16+
<%= header "Examples", 4 %>
17+
<% @action.example_code.each do |example| %>
18+
```Ruby
19+
<%= example %>
20+
```
21+
<% end %>
22+
<% end %>
23+
24+
<% if @command.respond_to?(:return_value) && !@command.return_value.nil? %>
25+
<% end %>

fastlane-plugin-branch.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
1717
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1818
spec.require_paths = ['lib']
1919

20-
spec.add_dependency 'branch_io_cli'
20+
spec.add_dependency 'branch_io_cli', '>= 0.12.0'
2121

2222
spec.add_development_dependency 'pry'
2323
spec.add_development_dependency 'bundler'

fastlane/Fastfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
actions_path("../actions")
2+
13
desc "Set up BranchPluginExample"
24
lane :setup do
35
setup_branch xcodeproj: "examples/BranchPluginExample/BranchPluginExample.xcodeproj"
@@ -38,3 +40,13 @@ lane :validate do
3840
xcodeproj: "examples/BranchPluginExample/BranchPluginExample.xcodeproj"
3941
)
4042
end
43+
44+
desc "Update the README in this repo"
45+
lane :readme do
46+
updated_dox = update_readme
47+
48+
patch regexp: /(\<!-- BEGIN ACTION REFERENCE --\>).*(\<!-- END ACTION REFERENCE --\>)/m,
49+
text: "\\1\n#{updated_dox}\n\\2",
50+
mode: :replace,
51+
files: "README.md"
52+
end

0 commit comments

Comments
 (0)