branch_io_cli 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/branch_io_cli/cli.rb +3 -3
- data/lib/branch_io_cli/command.rb +7 -89
- data/lib/branch_io_cli/helper.rb +1 -0
- data/lib/branch_io_cli/helper/configuration_helper.rb +102 -0
- data/lib/branch_io_cli/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78fa18c46004f307435a9372ca7d86f870188b4b
|
4
|
+
data.tar.gz: be9a50a0308af7b2f6b1525d686915dc44b8da91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19c8b3558ae9c7d08574bc71ac2c71bdd6300ba9d38fa79aa39700de9540537f3a30c51a283abf4b8e84706d79787fbbb1001f57c30efbcc3bea2fe69ecfa92
|
7
|
+
data.tar.gz: 2d7605b8ffabd835c76ff53652f54f4397f3471220eeff601f9dff77e9569bed777c3ef8b485674ec7cf8dc5fe708054afb5003686437cc84558ad745793bc1c
|
data/README.md
CHANGED
@@ -61,7 +61,7 @@ This can be suppressed using `--no_patch_source`.
|
|
61
61
|
|
62
62
|
#### Prerequisites
|
63
63
|
|
64
|
-
Before using this
|
64
|
+
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:
|
65
65
|
|
66
66
|
- Branch key(s), either live, test or both
|
67
67
|
- Domain name(s) used for Branch links
|
@@ -87,8 +87,9 @@ Before using this action, make sure to set up your app in the [Branch Dashboard]
|
|
87
87
|
|--no_patch_source|Don't add Branch SDK calls to the AppDelegate|
|
88
88
|
|--commit|Commit the results to Git|
|
89
89
|
|
90
|
-
All parameters are optional
|
91
|
-
|
90
|
+
All parameters are optional. A live key or test key, or both is required, as well as at least one domain.
|
91
|
+
Specify --live_key, --test_key or both and --app_link_subdomain, --domains or both. If these are not
|
92
|
+
specified, this command will prompt you for this information.
|
92
93
|
|
93
94
|
### Validate command
|
94
95
|
|
data/lib/branch_io_cli/cli.rb
CHANGED
@@ -11,7 +11,7 @@ module BranchIOCLI
|
|
11
11
|
program :description, "More to come"
|
12
12
|
|
13
13
|
command :setup do |c|
|
14
|
-
c.syntax = "branch_io setup"
|
14
|
+
c.syntax = "branch_io setup [OPTIONS]"
|
15
15
|
c.description = "Set up an iOS project to use the Branch SDK."
|
16
16
|
|
17
17
|
# Required Branch params
|
@@ -39,8 +39,8 @@ module BranchIOCLI
|
|
39
39
|
end
|
40
40
|
|
41
41
|
command :validate do |c|
|
42
|
-
c.syntax = "branch_io validate"
|
43
|
-
c.description = "Validate the Universal Link configuration for an Xcode project"
|
42
|
+
c.syntax = "branch_io validate [OPTIONS]"
|
43
|
+
c.description = "Validate the Universal Link configuration for an Xcode project."
|
44
44
|
|
45
45
|
c.option "--xcodeproj MyProject.xcodeproj", String, "Path to an Xcode project to update"
|
46
46
|
c.option "--target MyAppTarget", String, "Name of a target to modify in the Xcode project"
|
@@ -4,27 +4,12 @@ module BranchIOCLI
|
|
4
4
|
class Command
|
5
5
|
class << self
|
6
6
|
def setup(options)
|
7
|
-
|
8
|
-
@keys = keys options
|
7
|
+
options = Helper::ConfigurationHelper.validate_setup_options options
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if @domains.empty?
|
16
|
-
say "Please specify --app_link_subdomain or --domains or both."
|
17
|
-
return
|
18
|
-
end
|
19
|
-
|
20
|
-
@xcodeproj_path = xcodeproj_path options
|
21
|
-
unless @xcodeproj_path
|
22
|
-
say "Please specify the --xcodeproj option."
|
23
|
-
return
|
24
|
-
end
|
25
|
-
|
26
|
-
# raises
|
27
|
-
xcodeproj = Xcodeproj::Project.open @xcodeproj_path
|
9
|
+
@keys = Helper::ConfigurationHelper.keys
|
10
|
+
@domains = Helper::ConfigurationHelper.all_domains
|
11
|
+
@xcodeproj_path = options.xcodeproj
|
12
|
+
xcodeproj = Helper::ConfigurationHelper.xcodeproj
|
28
13
|
|
29
14
|
update_podfile(options) || update_cartfile(options, xcodeproj)
|
30
15
|
|
@@ -57,14 +42,10 @@ module BranchIOCLI
|
|
57
42
|
end
|
58
43
|
|
59
44
|
def validate(options)
|
60
|
-
|
61
|
-
unless path
|
62
|
-
say "Please specify the --xcodeproj option."
|
63
|
-
return
|
64
|
-
end
|
45
|
+
options = Helper::ConfigurationHelper.validate_validation_options options
|
65
46
|
|
66
47
|
# raises
|
67
|
-
xcodeproj =
|
48
|
+
xcodeproj = Helper::ConfigurationHelper.xcodeproj
|
68
49
|
|
69
50
|
valid = true
|
70
51
|
|
@@ -102,69 +83,6 @@ module BranchIOCLI
|
|
102
83
|
BranchIOCLI::Helper::BranchHelper
|
103
84
|
end
|
104
85
|
|
105
|
-
def xcodeproj_path(options)
|
106
|
-
return options.xcodeproj if options.xcodeproj
|
107
|
-
|
108
|
-
repo_path = "."
|
109
|
-
|
110
|
-
all_xcodeproj_paths = Dir[File.expand_path(File.join(repo_path, '**/*.xcodeproj'))]
|
111
|
-
# find an xcodeproj (ignoring the Pods and Carthage folders)
|
112
|
-
# TODO: Improve this filter
|
113
|
-
xcodeproj_paths = all_xcodeproj_paths.reject { |p| p =~ /Pods|Carthage/ }
|
114
|
-
|
115
|
-
# no projects found: error
|
116
|
-
say 'Could not find a .xcodeproj in the current repository\'s working directory.' and return nil if xcodeproj_paths.count == 0
|
117
|
-
|
118
|
-
# too many projects found: error
|
119
|
-
if xcodeproj_paths.count > 1
|
120
|
-
repo_pathname = Pathname.new repo_path
|
121
|
-
relative_projects = xcodeproj_paths.map { |e| Pathname.new(e).relative_path_from(repo_pathname).to_s }.join("\n")
|
122
|
-
say "Found multiple .xcodeproj projects in the current repository's working directory. Please specify your app's main project: \n#{relative_projects}"
|
123
|
-
return nil
|
124
|
-
end
|
125
|
-
|
126
|
-
# one project found: great
|
127
|
-
xcodeproj_paths.first
|
128
|
-
end
|
129
|
-
|
130
|
-
def app_link_subdomains(options)
|
131
|
-
app_link_subdomain = options.app_link_subdomain
|
132
|
-
live_key = options.live_key
|
133
|
-
test_key = options.test_key
|
134
|
-
return [] if live_key.nil? and test_key.nil?
|
135
|
-
return [] if app_link_subdomain.nil?
|
136
|
-
|
137
|
-
domains = []
|
138
|
-
unless live_key.nil?
|
139
|
-
domains += [
|
140
|
-
"#{app_link_subdomain}.app.link",
|
141
|
-
"#{app_link_subdomain}-alternate.app.link"
|
142
|
-
]
|
143
|
-
end
|
144
|
-
unless test_key.nil?
|
145
|
-
domains += [
|
146
|
-
"#{app_link_subdomain}.test-app.link",
|
147
|
-
"#{app_link_subdomain}-alternate.test-app.link"
|
148
|
-
]
|
149
|
-
end
|
150
|
-
domains
|
151
|
-
end
|
152
|
-
|
153
|
-
def all_domains(options)
|
154
|
-
app_link_subdomains = app_link_subdomains options
|
155
|
-
custom_domains = options.domains || []
|
156
|
-
(app_link_subdomains + custom_domains).uniq
|
157
|
-
end
|
158
|
-
|
159
|
-
def keys(options)
|
160
|
-
live_key = options.live_key
|
161
|
-
test_key = options.test_key
|
162
|
-
keys = {}
|
163
|
-
keys[:live] = live_key unless live_key.nil?
|
164
|
-
keys[:test] = test_key unless test_key.nil?
|
165
|
-
keys
|
166
|
-
end
|
167
|
-
|
168
86
|
def podfile_path(options)
|
169
87
|
# Disable Podfile update if add_sdk: false is present
|
170
88
|
return nil if options.no_add_sdk
|
data/lib/branch_io_cli/helper.rb
CHANGED
@@ -0,0 +1,102 @@
|
|
1
|
+
require "xcodeproj"
|
2
|
+
|
3
|
+
module BranchIOCLI
|
4
|
+
module Helper
|
5
|
+
class ConfigurationHelper
|
6
|
+
class << self
|
7
|
+
attr_accessor :xcodeproj
|
8
|
+
attr_accessor :keys
|
9
|
+
attr_accessor :all_domains
|
10
|
+
|
11
|
+
def validate_setup_options(options)
|
12
|
+
options.xcodeproj = xcodeproj_path options
|
13
|
+
validate_keys_from_setup_options options
|
14
|
+
validate_all_domains options
|
15
|
+
options
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_validation_options(options)
|
19
|
+
options.xcodeproj = xcodeproj_path options
|
20
|
+
options
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate_keys_from_setup_options(options)
|
24
|
+
live_key = options.live_key
|
25
|
+
test_key = options.test_key
|
26
|
+
@keys = {}
|
27
|
+
@keys[:live] = live_key unless live_key.nil?
|
28
|
+
@keys[:test] = test_key unless test_key.nil?
|
29
|
+
|
30
|
+
while @keys.empty?
|
31
|
+
say "A live key, a test key or both is required."
|
32
|
+
live_key = ask "Please enter your live Branch key or use --live_key [enter for none]: "
|
33
|
+
test_key = ask "Please enter your test Branch key or use --test_key [enter for none]: "
|
34
|
+
|
35
|
+
@keys[:live] = live_key unless live_key == ""
|
36
|
+
@keys[:test] = test_key unless test_key == ""
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_all_domains(options)
|
41
|
+
app_link_subdomains = app_link_subdomains options
|
42
|
+
custom_domains = options.domains || []
|
43
|
+
@all_domains = (app_link_subdomains + custom_domains).uniq
|
44
|
+
|
45
|
+
while @all_domains.empty?
|
46
|
+
@all_domains = ask "Please enter domains as a comma-separated list: ", ->(str) { str.split "," }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# 1. Look for options.xcodeproj.
|
51
|
+
# 2. If not specified, look for projects under . (excluding anything in Pods or Carthage folder).
|
52
|
+
# 3. If none or more than one found, prompt the user.
|
53
|
+
def xcodeproj_path(options)
|
54
|
+
if options.xcodeproj
|
55
|
+
path = options.xcodeproj
|
56
|
+
else
|
57
|
+
all_xcodeproj_paths = Dir[File.expand_path(File.join(".", "**/*.xcodeproj"))]
|
58
|
+
# find an xcodeproj (ignoring the Pods and Carthage folders)
|
59
|
+
# TODO: Improve this filter
|
60
|
+
xcodeproj_paths = all_xcodeproj_paths.reject { |p| p =~ /Pods|Carthage/ }
|
61
|
+
|
62
|
+
path = xcodeproj_paths.first if xcodeproj_paths.count == 1
|
63
|
+
end
|
64
|
+
|
65
|
+
loop do
|
66
|
+
path = ask "Please enter the path to your Xcode project or use --xcodeproj: " if path.nil?
|
67
|
+
# TODO: Allow the user to choose if xcodeproj_paths.count > 0
|
68
|
+
begin
|
69
|
+
@xcodeproj = Xcodeproj::Project.open path
|
70
|
+
return path
|
71
|
+
rescue StandardError => e
|
72
|
+
say e.message
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def app_link_subdomains(options)
|
78
|
+
app_link_subdomain = options.app_link_subdomain
|
79
|
+
live_key = options.live_key
|
80
|
+
test_key = options.test_key
|
81
|
+
return [] if live_key.nil? and test_key.nil?
|
82
|
+
return [] if app_link_subdomain.nil?
|
83
|
+
|
84
|
+
domains = []
|
85
|
+
unless live_key.nil?
|
86
|
+
domains += [
|
87
|
+
"#{app_link_subdomain}.app.link",
|
88
|
+
"#{app_link_subdomain}-alternate.app.link"
|
89
|
+
]
|
90
|
+
end
|
91
|
+
unless test_key.nil?
|
92
|
+
domains += [
|
93
|
+
"#{app_link_subdomain}.test-app.link",
|
94
|
+
"#{app_link_subdomain}-alternate.test-app.link"
|
95
|
+
]
|
96
|
+
end
|
97
|
+
domains
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
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.
|
4
|
+
version: 0.2.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-10-
|
12
|
+
date: 2017-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: pry
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +96,7 @@ dependencies:
|
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
99
|
+
name: rake
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
102
|
- - ">="
|
@@ -110,7 +124,7 @@ dependencies:
|
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
127
|
+
name: rspec_junit_formatter
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
130
|
- - ">="
|
@@ -184,6 +198,7 @@ files:
|
|
184
198
|
- lib/branch_io_cli/helper.rb
|
185
199
|
- lib/branch_io_cli/helper/android_helper.rb
|
186
200
|
- lib/branch_io_cli/helper/branch_helper.rb
|
201
|
+
- lib/branch_io_cli/helper/configuration_helper.rb
|
187
202
|
- lib/branch_io_cli/helper/ios_helper.rb
|
188
203
|
- lib/branch_io_cli/version.rb
|
189
204
|
homepage: http://github.com/BranchMetrics/branch_io_cli
|