branch_io_cli 0.12.2 → 0.12.3
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.
- checksums.yaml +4 -4
- data/lib/branch_io_cli/cli.rb +1 -1
- data/lib/branch_io_cli/command/command.rb +5 -3
- data/lib/branch_io_cli/command/report_command.rb +12 -7
- data/lib/branch_io_cli/command/setup_command.rb +66 -48
- data/lib/branch_io_cli/configuration.rb +3 -0
- data/lib/branch_io_cli/configuration/configuration.rb +9 -2
- data/lib/branch_io_cli/configuration/report_configuration.rb +0 -80
- data/lib/branch_io_cli/configuration/report_options.rb +86 -0
- data/lib/branch_io_cli/configuration/setup_configuration.rb +1 -146
- data/lib/branch_io_cli/configuration/setup_options.rb +152 -0
- data/lib/branch_io_cli/configuration/validate_configuration.rb +0 -31
- data/lib/branch_io_cli/configuration/validate_options.rb +38 -0
- data/lib/branch_io_cli/configuration/xcode_settings.rb +12 -7
- data/lib/branch_io_cli/core_ext.rb +1 -0
- data/lib/branch_io_cli/core_ext/io.rb +34 -11
- data/lib/branch_io_cli/core_ext/regexp.rb +4 -0
- data/lib/branch_io_cli/{helper/xcodeproj_ext.rb → core_ext/xcodeproj.rb} +0 -0
- data/lib/branch_io_cli/format/markdown_format.rb +1 -3
- data/lib/branch_io_cli/format/shell_format.rb +1 -3
- data/lib/branch_io_cli/helper.rb +1 -1
- data/lib/branch_io_cli/helper/branch_helper.rb +0 -8
- data/lib/branch_io_cli/helper/ios_helper.rb +0 -319
- data/lib/branch_io_cli/helper/methods.rb +15 -11
- data/lib/branch_io_cli/helper/patch_helper.rb +6 -6
- data/lib/branch_io_cli/helper/report_helper.rb +5 -7
- data/lib/branch_io_cli/helper/tool_helper.rb +329 -0
- data/lib/branch_io_cli/rake_task.rb +14 -35
- data/lib/branch_io_cli/version.rb +1 -1
- metadata +22 -4
@@ -1,6 +1,5 @@
|
|
1
1
|
module BranchIOCLI
|
2
2
|
module Configuration
|
3
|
-
# rubocop: disable Metrics/ClassLength
|
4
3
|
class SetupConfiguration < Configuration
|
5
4
|
class << self
|
6
5
|
def summary
|
@@ -16,151 +15,6 @@ module BranchIOCLI
|
|
16
15
|
"Install using carthage bootstrap" => "branch_io --carthage-command \"bootstrap --no-use-binaries\""
|
17
16
|
}
|
18
17
|
end
|
19
|
-
|
20
|
-
def available_options
|
21
|
-
[
|
22
|
-
Option.new(
|
23
|
-
name: :live_key,
|
24
|
-
description: "Branch live key",
|
25
|
-
example: "key_live_xxxx",
|
26
|
-
type: String,
|
27
|
-
aliases: "-L"
|
28
|
-
),
|
29
|
-
Option.new(
|
30
|
-
name: :test_key,
|
31
|
-
description: "Branch test key",
|
32
|
-
example: "key_test_yyyy",
|
33
|
-
type: String,
|
34
|
-
aliases: "-T"
|
35
|
-
),
|
36
|
-
Option.new(
|
37
|
-
name: :domains,
|
38
|
-
description: "Comma-separated list of custom domain(s) or non-Branch domain(s)",
|
39
|
-
example: "example.com,www.example.com",
|
40
|
-
type: Array,
|
41
|
-
aliases: "-D",
|
42
|
-
confirm_symbol: :all_domains
|
43
|
-
),
|
44
|
-
Option.new(
|
45
|
-
name: :app_link_subdomain,
|
46
|
-
description: "Branch app.link subdomain, e.g. myapp for myapp.app.link",
|
47
|
-
example: "myapp",
|
48
|
-
type: String,
|
49
|
-
label: "app.link subdomain",
|
50
|
-
skip_confirmation: true
|
51
|
-
),
|
52
|
-
Option.new(
|
53
|
-
name: :uri_scheme,
|
54
|
-
description: "Custom URI scheme used in the Branch Dashboard for this app",
|
55
|
-
example: "myurischeme[://]",
|
56
|
-
type: String,
|
57
|
-
aliases: "-U",
|
58
|
-
label: "URI scheme"
|
59
|
-
),
|
60
|
-
Option.new(
|
61
|
-
name: :setting,
|
62
|
-
description: "Use a custom build setting for the Branch key (default: Use Info.plist)",
|
63
|
-
example: "BRANCH_KEY_SETTING",
|
64
|
-
type: String,
|
65
|
-
argument_optional: true,
|
66
|
-
aliases: "-s",
|
67
|
-
label: "User-defined setting for Branch key"
|
68
|
-
),
|
69
|
-
Option.new(
|
70
|
-
name: :test_configurations,
|
71
|
-
description: "List of configurations that use the test key with a user-defined setting (default: Debug configurations)",
|
72
|
-
example: "config1,config2",
|
73
|
-
type: Array,
|
74
|
-
negatable: true,
|
75
|
-
valid_values_proc: ->() { Configuration.current.xcodeproj.build_configurations.map(&:name) }
|
76
|
-
),
|
77
|
-
Option.new(
|
78
|
-
name: :xcodeproj,
|
79
|
-
description: "Path to an Xcode project to update",
|
80
|
-
example: "MyProject.xcodeproj",
|
81
|
-
type: String,
|
82
|
-
confirm_symbol: :xcodeproj_path,
|
83
|
-
validate_proc: ->(path) { Configuration.open_xcodeproj path }
|
84
|
-
),
|
85
|
-
Option.new(
|
86
|
-
name: :target,
|
87
|
-
description: "Name of a target to modify in the Xcode project",
|
88
|
-
example: "MyAppTarget",
|
89
|
-
type: String,
|
90
|
-
confirm_symbol: :target_name,
|
91
|
-
valid_values_proc: ->() { Configuration.current.xcodeproj.targets.map(&:name) }
|
92
|
-
),
|
93
|
-
Option.new(
|
94
|
-
name: :podfile,
|
95
|
-
description: "Path to the Podfile for the project",
|
96
|
-
example: "/path/to/Podfile",
|
97
|
-
type: String,
|
98
|
-
confirm_symbol: :podfile_path,
|
99
|
-
validate_proc: ->(path) { Configuration.open_podfile path }
|
100
|
-
),
|
101
|
-
Option.new(
|
102
|
-
name: :cartfile,
|
103
|
-
description: "Path to the Cartfile for the project",
|
104
|
-
example: "/path/to/Cartfile",
|
105
|
-
type: String,
|
106
|
-
confirm_symbol: :cartfile_path,
|
107
|
-
validate_proc: ->(path) { !path.nil? && File.exist?(path.to_s) },
|
108
|
-
convert_proc: ->(path) { Configuration.absolute_path(path.to_s) unless path.nil? }
|
109
|
-
),
|
110
|
-
Option.new(
|
111
|
-
name: :carthage_command,
|
112
|
-
description: "Command to run when installing from Carthage",
|
113
|
-
example: "<command>",
|
114
|
-
type: String,
|
115
|
-
default_value: "update --platform ios"
|
116
|
-
),
|
117
|
-
Option.new(
|
118
|
-
name: :frameworks,
|
119
|
-
description: "Comma-separated list of system frameworks to add to the project",
|
120
|
-
example: "AdSupport,CoreSpotlight,SafariServices",
|
121
|
-
type: Array
|
122
|
-
),
|
123
|
-
Option.new(
|
124
|
-
name: :pod_repo_update,
|
125
|
-
description: "Update the local podspec repo before installing",
|
126
|
-
default_value: true
|
127
|
-
),
|
128
|
-
Option.new(
|
129
|
-
name: :validate,
|
130
|
-
description: "Validate Universal Link configuration",
|
131
|
-
default_value: true
|
132
|
-
),
|
133
|
-
Option.new(
|
134
|
-
name: :force,
|
135
|
-
description: "Update project even if Universal Link validation fails",
|
136
|
-
default_value: false
|
137
|
-
),
|
138
|
-
Option.new(
|
139
|
-
name: :add_sdk,
|
140
|
-
description: "Add the Branch framework to the project",
|
141
|
-
default_value: true
|
142
|
-
),
|
143
|
-
Option.new(
|
144
|
-
name: :patch_source,
|
145
|
-
description: "Add Branch SDK calls to the AppDelegate",
|
146
|
-
default_value: true
|
147
|
-
),
|
148
|
-
Option.new(
|
149
|
-
name: :commit,
|
150
|
-
description: "Commit the results to Git if non-blank",
|
151
|
-
type: String,
|
152
|
-
example: "message",
|
153
|
-
argument_optional: true,
|
154
|
-
label: "Commit message"
|
155
|
-
),
|
156
|
-
Option.new(
|
157
|
-
name: :confirm,
|
158
|
-
description: "Confirm configuration before proceeding",
|
159
|
-
default_value: true,
|
160
|
-
skip_confirmation: true
|
161
|
-
)
|
162
|
-
]
|
163
|
-
end
|
164
18
|
end
|
165
19
|
|
166
20
|
APP_LINK_REGEXP = /\.app\.link$|\.test-app\.link$/
|
@@ -401,6 +255,7 @@ module BranchIOCLI
|
|
401
255
|
# Prompt the user:
|
402
256
|
selected = choose do |menu|
|
403
257
|
menu.header = "No Podfile or Cartfile specified or found. Here are your options"
|
258
|
+
menu.readline = true
|
404
259
|
|
405
260
|
SDK_OPTIONS.each_key { |k| menu.choice k }
|
406
261
|
|
@@ -0,0 +1,152 @@
|
|
1
|
+
module BranchIOCLI
|
2
|
+
module Configuration
|
3
|
+
class SetupOptions
|
4
|
+
class << self
|
5
|
+
def available_options
|
6
|
+
[
|
7
|
+
Option.new(
|
8
|
+
name: :live_key,
|
9
|
+
description: "Branch live key",
|
10
|
+
example: "key_live_xxxx",
|
11
|
+
type: String,
|
12
|
+
aliases: "-L"
|
13
|
+
),
|
14
|
+
Option.new(
|
15
|
+
name: :test_key,
|
16
|
+
description: "Branch test key",
|
17
|
+
example: "key_test_yyyy",
|
18
|
+
type: String,
|
19
|
+
aliases: "-T"
|
20
|
+
),
|
21
|
+
Option.new(
|
22
|
+
name: :domains,
|
23
|
+
description: "Comma-separated list of custom domain(s) or non-Branch domain(s)",
|
24
|
+
example: "example.com,www.example.com",
|
25
|
+
type: Array,
|
26
|
+
aliases: "-D",
|
27
|
+
confirm_symbol: :all_domains
|
28
|
+
),
|
29
|
+
Option.new(
|
30
|
+
name: :app_link_subdomain,
|
31
|
+
description: "Branch app.link subdomain, e.g. myapp for myapp.app.link",
|
32
|
+
example: "myapp",
|
33
|
+
type: String,
|
34
|
+
label: "app.link subdomain",
|
35
|
+
skip_confirmation: true
|
36
|
+
),
|
37
|
+
Option.new(
|
38
|
+
name: :uri_scheme,
|
39
|
+
description: "Custom URI scheme used in the Branch Dashboard for this app",
|
40
|
+
example: "myurischeme[://]",
|
41
|
+
type: String,
|
42
|
+
aliases: "-U",
|
43
|
+
label: "URI scheme"
|
44
|
+
),
|
45
|
+
Option.new(
|
46
|
+
name: :setting,
|
47
|
+
description: "Use a custom build setting for the Branch key (default: Use Info.plist)",
|
48
|
+
example: "BRANCH_KEY_SETTING",
|
49
|
+
type: String,
|
50
|
+
argument_optional: true,
|
51
|
+
aliases: "-s",
|
52
|
+
label: "User-defined setting for Branch key"
|
53
|
+
),
|
54
|
+
Option.new(
|
55
|
+
name: :test_configurations,
|
56
|
+
description: "List of configurations that use the test key with a user-defined setting (default: Debug configurations)",
|
57
|
+
example: "config1,config2",
|
58
|
+
type: Array,
|
59
|
+
negatable: true,
|
60
|
+
valid_values_proc: ->() { Configuration.current.xcodeproj.build_configurations.map(&:name) }
|
61
|
+
),
|
62
|
+
Option.new(
|
63
|
+
name: :xcodeproj,
|
64
|
+
description: "Path to an Xcode project to update",
|
65
|
+
example: "MyProject.xcodeproj",
|
66
|
+
type: String,
|
67
|
+
confirm_symbol: :xcodeproj_path,
|
68
|
+
validate_proc: ->(path) { Configuration.open_xcodeproj path }
|
69
|
+
),
|
70
|
+
Option.new(
|
71
|
+
name: :target,
|
72
|
+
description: "Name of a target to modify in the Xcode project",
|
73
|
+
example: "MyAppTarget",
|
74
|
+
type: String,
|
75
|
+
confirm_symbol: :target_name,
|
76
|
+
valid_values_proc: ->() { Configuration.current.xcodeproj.targets.map(&:name) }
|
77
|
+
),
|
78
|
+
Option.new(
|
79
|
+
name: :podfile,
|
80
|
+
description: "Path to the Podfile for the project",
|
81
|
+
example: "/path/to/Podfile",
|
82
|
+
type: String,
|
83
|
+
confirm_symbol: :podfile_path,
|
84
|
+
validate_proc: ->(path) { Configuration.open_podfile path }
|
85
|
+
),
|
86
|
+
Option.new(
|
87
|
+
name: :cartfile,
|
88
|
+
description: "Path to the Cartfile for the project",
|
89
|
+
example: "/path/to/Cartfile",
|
90
|
+
type: String,
|
91
|
+
confirm_symbol: :cartfile_path,
|
92
|
+
validate_proc: ->(path) { !path.nil? && File.exist?(path.to_s) },
|
93
|
+
convert_proc: ->(path) { Configuration.absolute_path(path.to_s) unless path.nil? }
|
94
|
+
),
|
95
|
+
Option.new(
|
96
|
+
name: :carthage_command,
|
97
|
+
description: "Command to run when installing from Carthage",
|
98
|
+
example: "<command>",
|
99
|
+
type: String,
|
100
|
+
default_value: "update --platform ios"
|
101
|
+
),
|
102
|
+
Option.new(
|
103
|
+
name: :frameworks,
|
104
|
+
description: "Comma-separated list of system frameworks to add to the project",
|
105
|
+
example: "AdSupport,CoreSpotlight,SafariServices",
|
106
|
+
type: Array
|
107
|
+
),
|
108
|
+
Option.new(
|
109
|
+
name: :pod_repo_update,
|
110
|
+
description: "Update the local podspec repo before installing",
|
111
|
+
default_value: true
|
112
|
+
),
|
113
|
+
Option.new(
|
114
|
+
name: :validate,
|
115
|
+
description: "Validate Universal Link configuration",
|
116
|
+
default_value: true
|
117
|
+
),
|
118
|
+
Option.new(
|
119
|
+
name: :force,
|
120
|
+
description: "Update project even if Universal Link validation fails",
|
121
|
+
default_value: false
|
122
|
+
),
|
123
|
+
Option.new(
|
124
|
+
name: :add_sdk,
|
125
|
+
description: "Add the Branch framework to the project",
|
126
|
+
default_value: true
|
127
|
+
),
|
128
|
+
Option.new(
|
129
|
+
name: :patch_source,
|
130
|
+
description: "Add Branch SDK calls to the AppDelegate",
|
131
|
+
default_value: true
|
132
|
+
),
|
133
|
+
Option.new(
|
134
|
+
name: :commit,
|
135
|
+
description: "Commit the results to Git if non-blank",
|
136
|
+
type: String,
|
137
|
+
example: "message",
|
138
|
+
argument_optional: true,
|
139
|
+
label: "Commit message"
|
140
|
+
),
|
141
|
+
Option.new(
|
142
|
+
name: :confirm,
|
143
|
+
description: "Confirm configuration before proceeding",
|
144
|
+
default_value: true,
|
145
|
+
skip_confirmation: true
|
146
|
+
)
|
147
|
+
]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -9,37 +9,6 @@ module BranchIOCLI
|
|
9
9
|
def return_value
|
10
10
|
"If validation passes, this command returns 0. If validation fails, it returns 1."
|
11
11
|
end
|
12
|
-
|
13
|
-
def available_options
|
14
|
-
[
|
15
|
-
Option.new(
|
16
|
-
name: :domains,
|
17
|
-
description: "Comma-separated list of domains to validate (Branch domains or non-Branch domains)",
|
18
|
-
type: Array,
|
19
|
-
example: "example.com,www.example.com",
|
20
|
-
aliases: "-D",
|
21
|
-
default_value: []
|
22
|
-
),
|
23
|
-
Option.new(
|
24
|
-
name: :xcodeproj,
|
25
|
-
description: "Path to an Xcode project to update",
|
26
|
-
type: String,
|
27
|
-
example: "MyProject.xcodeproj"
|
28
|
-
),
|
29
|
-
Option.new(
|
30
|
-
name: :target,
|
31
|
-
description: "Name of a target to validate in the Xcode project",
|
32
|
-
type: String,
|
33
|
-
example: "MyAppTarget"
|
34
|
-
),
|
35
|
-
Option.new(
|
36
|
-
name: :configurations,
|
37
|
-
description: "Comma-separated list of configurations to validate (default: all)",
|
38
|
-
type: Array,
|
39
|
-
example: "Debug,Release"
|
40
|
-
)
|
41
|
-
]
|
42
|
-
end
|
43
12
|
end
|
44
13
|
|
45
14
|
def initialize(options)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module BranchIOCLI
|
2
|
+
module Configuration
|
3
|
+
class ValidateOptions
|
4
|
+
class << self
|
5
|
+
def available_options
|
6
|
+
[
|
7
|
+
Option.new(
|
8
|
+
name: :domains,
|
9
|
+
description: "Comma-separated list of domains to validate (Branch domains or non-Branch domains)",
|
10
|
+
type: Array,
|
11
|
+
example: "example.com,www.example.com",
|
12
|
+
aliases: "-D",
|
13
|
+
default_value: []
|
14
|
+
),
|
15
|
+
Option.new(
|
16
|
+
name: :xcodeproj,
|
17
|
+
description: "Path to an Xcode project to update",
|
18
|
+
type: String,
|
19
|
+
example: "MyProject.xcodeproj"
|
20
|
+
),
|
21
|
+
Option.new(
|
22
|
+
name: :target,
|
23
|
+
description: "Name of a target to validate in the Xcode project",
|
24
|
+
type: String,
|
25
|
+
example: "MyAppTarget"
|
26
|
+
),
|
27
|
+
Option.new(
|
28
|
+
name: :configurations,
|
29
|
+
description: "Comma-separated list of configurations to validate (default: all)",
|
30
|
+
type: Array,
|
31
|
+
example: "Debug,Release"
|
32
|
+
)
|
33
|
+
]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -46,13 +46,18 @@ module BranchIOCLI
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def xcodebuild_cmd
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
[
|
50
|
+
"xcodebuild",
|
51
|
+
"-showBuildSettings",
|
52
|
+
"-project",
|
53
|
+
config.xcodeproj_path,
|
54
|
+
"-target",
|
55
|
+
config.target.name,
|
56
|
+
"-sdk",
|
57
|
+
config.sdk,
|
58
|
+
"-configuration",
|
59
|
+
configuration
|
60
|
+
].shelljoin
|
56
61
|
end
|
57
62
|
|
58
63
|
def load_settings_from_xcode
|
@@ -7,12 +7,11 @@ class IO
|
|
7
7
|
# status at the end in case of error. Returns a Process::Status
|
8
8
|
# object.
|
9
9
|
#
|
10
|
-
# @param command
|
11
|
-
def
|
12
|
-
|
13
|
-
write "$ #{command}\n\n"
|
10
|
+
# @param command a shell command to execute and report
|
11
|
+
def sh(*args)
|
12
|
+
write "$ #{IO.command_from_args(*args)}\n\n"
|
14
13
|
|
15
|
-
Open3.popen2e(
|
14
|
+
Open3.popen2e(*args) do |stdin, output, thread|
|
16
15
|
# output is stdout and stderr merged
|
17
16
|
while (line = output.gets)
|
18
17
|
puts line
|
@@ -33,14 +32,12 @@ end
|
|
33
32
|
# not redirected. Report the exit status at the end if nonzero.
|
34
33
|
# Returns a Process::Status object.
|
35
34
|
#
|
36
|
-
# @param command
|
37
|
-
def STDOUT.
|
38
|
-
command = command.map(&:to_s).map(&:shellescape).join(" ") if command.kind_of? Array
|
35
|
+
# @param command a shell command to execute and report
|
36
|
+
def STDOUT.sh(*args)
|
39
37
|
# TODO: Improve this implementation?
|
40
|
-
say "<%= color(%q{$ #{
|
38
|
+
say "<%= color(%q{$ #{IO.command_from_args(*args)}}, [MAGENTA, BOLD]) %>\n\n"
|
41
39
|
# May also write to stderr
|
42
|
-
|
43
|
-
system command
|
40
|
+
system(*args)
|
44
41
|
|
45
42
|
status = $?
|
46
43
|
if status == 0
|
@@ -50,3 +47,29 @@ def STDOUT.log_command(command)
|
|
50
47
|
end
|
51
48
|
status
|
52
49
|
end
|
50
|
+
|
51
|
+
def IO.command_from_args(*args)
|
52
|
+
raise ArgumentError, "sh requires at least one argument" unless args.count > 0
|
53
|
+
|
54
|
+
# Ignore any trailing options in the output
|
55
|
+
args.pop if args.last.kind_of?(Hash)
|
56
|
+
|
57
|
+
command = ""
|
58
|
+
|
59
|
+
# Optional initial environment Hash
|
60
|
+
if args.first.kind_of?(Hash)
|
61
|
+
command = args.shift.map { |k, v| "#{k}=#{v.shellescape}" }.join(" ") + " "
|
62
|
+
end
|
63
|
+
|
64
|
+
# Support [ "/usr/local/bin/foo", "foo" ], "-x", ...
|
65
|
+
if args.first.kind_of?(Array)
|
66
|
+
command += args.shift.first.shellescape + " " + args.shelljoin
|
67
|
+
command.chomp! " "
|
68
|
+
elsif args.count == 1 && args.first.kind_of?(String)
|
69
|
+
command += args.first
|
70
|
+
else
|
71
|
+
command += args.shelljoin
|
72
|
+
end
|
73
|
+
|
74
|
+
command
|
75
|
+
end
|