branch_io_cli 0.10.0 → 0.11.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 +78 -30
- data/lib/assets/completions/completion.bash +1 -1
- data/lib/assets/completions/completion.zsh +1 -1
- data/lib/assets/templates/command.erb +31 -0
- data/lib/assets/templates/program_description.erb +2 -0
- data/lib/assets/templates/report_description.erb +4 -0
- data/lib/assets/templates/setup_description.erb +52 -0
- data/lib/assets/templates/validate_description.erb +18 -0
- data/lib/branch_io_cli.rb +1 -0
- data/lib/branch_io_cli/cli.rb +50 -147
- data/lib/branch_io_cli/command/command.rb +28 -6
- data/lib/branch_io_cli/command/report_command.rb +1 -1
- data/lib/branch_io_cli/command/setup_command.rb +4 -7
- data/lib/branch_io_cli/command/validate_command.rb +0 -2
- data/lib/branch_io_cli/configuration.rb +2 -0
- data/lib/branch_io_cli/configuration/configuration.rb +27 -1
- data/lib/branch_io_cli/configuration/option.rb +28 -0
- data/lib/branch_io_cli/configuration/option_wrapper.rb +33 -0
- data/lib/branch_io_cli/configuration/report_configuration.rb +83 -7
- data/lib/branch_io_cli/configuration/setup_configuration.rb +142 -9
- data/lib/branch_io_cli/configuration/validate_configuration.rb +30 -1
- data/lib/branch_io_cli/core_ext/io.rb +5 -2
- data/lib/branch_io_cli/format.rb +15 -0
- data/lib/branch_io_cli/format/commander_format.rb +21 -0
- data/lib/branch_io_cli/format/markdown_format.rb +60 -0
- data/lib/branch_io_cli/helper/ios_helper.rb +14 -14
- data/lib/branch_io_cli/helper/methods.rb +2 -2
- data/lib/branch_io_cli/rake_task.rb +26 -54
- data/lib/branch_io_cli/version.rb +1 -1
- metadata +12 -2
@@ -1,7 +1,36 @@
|
|
1
1
|
module BranchIOCLI
|
2
2
|
module Configuration
|
3
3
|
class ValidateConfiguration < Configuration
|
4
|
-
|
4
|
+
class << self
|
5
|
+
def return_value
|
6
|
+
"If validation passes, this command returns 0. If validation fails, it returns 1."
|
7
|
+
end
|
8
|
+
|
9
|
+
def available_options
|
10
|
+
[
|
11
|
+
Option.new(
|
12
|
+
name: :domains,
|
13
|
+
description: "Comma-separated list of domains to validate (Branch domains or non-Branch domains)",
|
14
|
+
type: Array,
|
15
|
+
example: "example.com,www.example.com",
|
16
|
+
aliases: "-D",
|
17
|
+
default_value: []
|
18
|
+
),
|
19
|
+
Option.new(
|
20
|
+
name: :xcodeproj,
|
21
|
+
description: "Path to an Xcode project to update",
|
22
|
+
type: String,
|
23
|
+
example: "MyProject.xcodeproj"
|
24
|
+
),
|
25
|
+
Option.new(
|
26
|
+
name: :target,
|
27
|
+
description: "Name of a target to validate in the Xcode project",
|
28
|
+
type: String,
|
29
|
+
example: "MyAppTarget"
|
30
|
+
)
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
5
34
|
|
6
35
|
def initialize(options)
|
7
36
|
super
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "open3"
|
2
|
+
require "shellwords"
|
2
3
|
|
3
4
|
class IO
|
4
5
|
# Report the command. Execute the command, capture stdout
|
@@ -6,8 +7,9 @@ class IO
|
|
6
7
|
# status at the end in case of error. Returns a Process::Status
|
7
8
|
# object.
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# @param command [String, Array] a shell command to execute and report
|
10
11
|
def log_command(command)
|
12
|
+
command = command.map(&:to_s).map(&:shellescape).join(" ") if command.kind_of? Array
|
11
13
|
write "$ #{command}\n\n"
|
12
14
|
|
13
15
|
Open3.popen2e(command) do |stdin, output, thread|
|
@@ -31,8 +33,9 @@ end
|
|
31
33
|
# not redirected. Report the exit status at the end if nonzero.
|
32
34
|
# Returns a Process::Status object.
|
33
35
|
#
|
34
|
-
#
|
36
|
+
# @param command [String, Array] a shell command to execute and report
|
35
37
|
def STDOUT.log_command(command)
|
38
|
+
command = command.map(&:to_s).map(&:shellescape).join(" ") if command.kind_of? Array
|
36
39
|
# TODO: Improve this implementation?
|
37
40
|
say "<%= color(%q{$ #{command}}, [MAGENTA, BOLD]) %>\n\n"
|
38
41
|
# May also write to stderr
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "branch_io_cli/format/commander_format"
|
2
|
+
require "branch_io_cli/format/markdown_format"
|
3
|
+
|
4
|
+
module BranchIOCLI
|
5
|
+
module Format
|
6
|
+
def render(template)
|
7
|
+
path = File.expand_path(File.join("..", "..", "assets", "templates", "#{template}.erb"), __FILE__)
|
8
|
+
ERB.new(File.read(path)).result binding
|
9
|
+
end
|
10
|
+
|
11
|
+
def option(opt)
|
12
|
+
highlight "--#{opt.to_s.gsub(/_/, '-')}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
module BranchIOCLI
|
4
|
+
module Format
|
5
|
+
module CommanderFormat
|
6
|
+
include Format
|
7
|
+
|
8
|
+
def header(text, level = 1)
|
9
|
+
highlight text
|
10
|
+
end
|
11
|
+
|
12
|
+
def highlight(text)
|
13
|
+
"<%= color('#{text}', BOLD) %>"
|
14
|
+
end
|
15
|
+
|
16
|
+
def italics(text)
|
17
|
+
highlight text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module BranchIOCLI
|
2
|
+
module Format
|
3
|
+
module MarkdownFormat
|
4
|
+
include Format
|
5
|
+
|
6
|
+
def header(text, level = 1)
|
7
|
+
"#" * level + " #{text}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def highlight(text)
|
11
|
+
"`#{text}`"
|
12
|
+
end
|
13
|
+
|
14
|
+
def italics(text)
|
15
|
+
"_#{text}_"
|
16
|
+
end
|
17
|
+
|
18
|
+
def table_options
|
19
|
+
@command.available_options.map { |o| table_option o }.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def table_option(option)
|
23
|
+
text = "|#{option.aliases.join(', ')}"
|
24
|
+
text += ", " unless option.aliases.blank?
|
25
|
+
|
26
|
+
text += "--"
|
27
|
+
text += "[no-]" if option.negatable
|
28
|
+
text += option.name.to_s.gsub(/_/, '-')
|
29
|
+
|
30
|
+
if option.example
|
31
|
+
text += " "
|
32
|
+
text += "[" if option.argument_optional
|
33
|
+
text += option.example
|
34
|
+
text += "]" if option.argument_optional
|
35
|
+
end
|
36
|
+
|
37
|
+
text += "|#{option.description}"
|
38
|
+
|
39
|
+
if option.type.nil?
|
40
|
+
default_value = option.default_value ? "yes" : "no"
|
41
|
+
else
|
42
|
+
default_value = option.default_value
|
43
|
+
end
|
44
|
+
|
45
|
+
if default_value
|
46
|
+
text += " (default: #{default_value})"
|
47
|
+
end
|
48
|
+
text += "|"
|
49
|
+
text
|
50
|
+
end
|
51
|
+
|
52
|
+
def render_command(name)
|
53
|
+
@command = Object.const_get("BranchIOCLI")
|
54
|
+
.const_get("Command")
|
55
|
+
.const_get("#{name.to_s.capitalize}Command")
|
56
|
+
render :command
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -489,11 +489,14 @@ module BranchIOCLI
|
|
489
489
|
add_change pods_folder_path
|
490
490
|
add_change workspace_path
|
491
491
|
|
492
|
-
|
493
|
-
"
|
494
|
-
"
|
495
|
-
|
496
|
-
|
492
|
+
sh [
|
493
|
+
"git",
|
494
|
+
"add",
|
495
|
+
podfile_pathname,
|
496
|
+
"#{podfile_pathname}.lock",
|
497
|
+
pods_folder_path,
|
498
|
+
workspace_path
|
499
|
+
]
|
497
500
|
end
|
498
501
|
|
499
502
|
def add_carthage(options)
|
@@ -543,10 +546,7 @@ EOF
|
|
543
546
|
carthage_folder_path = Pathname.new(File.expand_path("../Carthage", cartfile_path)).relative_path_from(Pathname.pwd)
|
544
547
|
cartfile_pathname = Pathname.new(cartfile_path).relative_path_from Pathname.pwd
|
545
548
|
add_change carthage_folder_path
|
546
|
-
|
547
|
-
"#{Shellwords.escape(cartfile_pathname)}.resolved " \
|
548
|
-
"#{Shellwords.escape(carthage_folder_path)}"
|
549
|
-
sh cmd
|
549
|
+
sh ["git", "add", cartfile_pathname, "#{cartfile_pathname}.resolved", carthage_folder_path]
|
550
550
|
end
|
551
551
|
|
552
552
|
def add_direct(options)
|
@@ -601,7 +601,7 @@ EOF
|
|
601
601
|
|
602
602
|
add_change config.xcodeproj_path
|
603
603
|
add_change framework_path
|
604
|
-
sh "git add
|
604
|
+
sh ["git", "add", framework_path] if options.commit
|
605
605
|
|
606
606
|
say "Done. ✅"
|
607
607
|
end
|
@@ -646,12 +646,12 @@ EOF
|
|
646
646
|
|
647
647
|
# 4. Check if Pods folder is under SCM
|
648
648
|
pods_folder_path = Pathname.new(File.expand_path("../Pods", podfile_path)).relative_path_from Pathname.pwd
|
649
|
-
`git ls-files #{pods_folder_path} --error-unmatch > /dev/null 2>&1`
|
649
|
+
`git ls-files #{pods_folder_path.to_s.shellescape} --error-unmatch > /dev/null 2>&1`
|
650
650
|
return true unless $?.exitstatus == 0
|
651
651
|
|
652
652
|
# 5. If so, add the Pods folder to the commit (in case :commit param specified)
|
653
653
|
add_change pods_folder_path
|
654
|
-
sh "git add
|
654
|
+
sh ["git", "add", pods_folder_path] if options.commit
|
655
655
|
|
656
656
|
true
|
657
657
|
end
|
@@ -693,12 +693,12 @@ EOF
|
|
693
693
|
|
694
694
|
# 6. Check if Carthage folder is under SCM
|
695
695
|
carthage_folder_path = Pathname.new(File.expand_path("../Carthage", cartfile_path)).relative_path_from Pathname.pwd
|
696
|
-
`git ls-files #{carthage_folder_path} --error-unmatch > /dev/null 2>&1`
|
696
|
+
`git ls-files #{carthage_folder_path.to_s.shellescape} --error-unmatch > /dev/null 2>&1`
|
697
697
|
return true unless $?.exitstatus == 0
|
698
698
|
|
699
699
|
# 7. If so, add the Carthage folder to the commit (in case :commit param specified)
|
700
700
|
add_change carthage_folder_path
|
701
|
-
sh "git add
|
701
|
+
sh ["git", "add", carthage_folder_path] if options.commit
|
702
702
|
|
703
703
|
true
|
704
704
|
end
|
@@ -19,8 +19,8 @@ module BranchIOCLI
|
|
19
19
|
# other cases, both stdout and stderr are redirected to output.
|
20
20
|
# In these cases, formatting (colors, highlights) may be lost.
|
21
21
|
#
|
22
|
-
#
|
23
|
-
#
|
22
|
+
# @param command [String, Array] A shell command to execute
|
23
|
+
# @param output [IO] An optional IO object to receive stdout and stderr from the command
|
24
24
|
def sh(command, output = STDOUT)
|
25
25
|
status = output.log_command command
|
26
26
|
raise CommandError, [%{Error executing "#{command}": #{status}.}, status] unless status.success?
|
@@ -5,29 +5,13 @@ require "highline/import"
|
|
5
5
|
|
6
6
|
module BranchIOCLI
|
7
7
|
class RakeTask < Rake::TaskLib
|
8
|
-
ReportOptions = Struct.new(
|
9
|
-
:cartfile,
|
10
|
-
:clean,
|
11
|
-
:configuration,
|
12
|
-
:header_only,
|
13
|
-
:out,
|
14
|
-
:pod_repo_update,
|
15
|
-
:podfile,
|
16
|
-
:scheme,
|
17
|
-
:sdk,
|
18
|
-
:target,
|
19
|
-
:xcodeproj,
|
20
|
-
:workspace
|
21
|
-
)
|
22
|
-
|
23
8
|
attr_reader :defaults
|
24
9
|
|
25
|
-
def initialize(
|
26
|
-
|
27
|
-
@defaults[:report] ||= {}
|
28
|
-
|
29
|
-
namespace :branch do
|
10
|
+
def initialize(name = :branch, &b)
|
11
|
+
namespace name do
|
30
12
|
report_task
|
13
|
+
setup_task
|
14
|
+
validate_task
|
31
15
|
end
|
32
16
|
end
|
33
17
|
|
@@ -39,50 +23,38 @@ module BranchIOCLI
|
|
39
23
|
|
40
24
|
paths.each do |path|
|
41
25
|
Dir.chdir(path) do |p|
|
42
|
-
Command::ReportCommand.new(
|
26
|
+
Command::ReportCommand.new(Configuration::ReportConfiguration.wrapper(args[:options] || {})).run!
|
43
27
|
end
|
44
28
|
end
|
45
29
|
end
|
46
30
|
end
|
47
31
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
32
|
+
def setup_task
|
33
|
+
desc "Set a project up with the Branch SDK"
|
34
|
+
task :setup, %i{paths options} do |task, args|
|
35
|
+
paths = args[:paths]
|
36
|
+
paths = [paths] unless paths.respond_to?(:each)
|
52
37
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
38
|
+
paths.each do |path|
|
39
|
+
Dir.chdir(path) do |p|
|
40
|
+
Command::SetupCommand.new(Configuration::SetupConfiguration.wrapper(args[:options] || {})).run!
|
41
|
+
end
|
42
|
+
end
|
57
43
|
end
|
44
|
+
end
|
58
45
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
46
|
+
def validate_task
|
47
|
+
desc "Validate universal links in one or more projects"
|
48
|
+
task :validate, %i{paths options} do |task, args|
|
49
|
+
paths = args[:paths]
|
50
|
+
paths = [paths] unless paths.respond_to?(:each)
|
64
51
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
52
|
+
paths.each do |path|
|
53
|
+
Dir.chdir(path) do |p|
|
54
|
+
Command::ValidateCommand.new(Configuration::ValidateConfiguration.wrapper(args[:options] || {})).run!
|
55
|
+
end
|
56
|
+
end
|
69
57
|
end
|
70
|
-
|
71
|
-
ReportOptions.new(
|
72
|
-
options[:cartfile] || defs[:cartfile],
|
73
|
-
clean,
|
74
|
-
options[:configuration] || defs[:configuration],
|
75
|
-
header_only,
|
76
|
-
options[:out] || defs[:out] || "./report.txt",
|
77
|
-
repo_update,
|
78
|
-
options[:podfile] || defs[:podfile],
|
79
|
-
options[:scheme] || defs[:scheme],
|
80
|
-
options[:sdk] || defs[:sdk] || "iphonesimulator",
|
81
|
-
options[:target] || defs[:target],
|
82
|
-
options[:xcodeproj] || defs[:xcodeproj],
|
83
|
-
options[:workspace] || defs[:workspace]
|
84
|
-
)
|
85
58
|
end
|
86
|
-
# rubocop: enable Metrics/PerceivedComplexity
|
87
59
|
end
|
88
60
|
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.11.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-11-
|
12
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: CFPropertyList
|
@@ -287,6 +287,11 @@ files:
|
|
287
287
|
- lib/assets/patches/open_url_source_application_swift.yml
|
288
288
|
- lib/assets/patches/open_url_swift.yml
|
289
289
|
- lib/assets/patches/swift_import.yml
|
290
|
+
- lib/assets/templates/command.erb
|
291
|
+
- lib/assets/templates/program_description.erb
|
292
|
+
- lib/assets/templates/report_description.erb
|
293
|
+
- lib/assets/templates/setup_description.erb
|
294
|
+
- lib/assets/templates/validate_description.erb
|
290
295
|
- lib/branch_io_cli.rb
|
291
296
|
- lib/branch_io_cli/cli.rb
|
292
297
|
- lib/branch_io_cli/command.rb
|
@@ -296,6 +301,8 @@ files:
|
|
296
301
|
- lib/branch_io_cli/command/validate_command.rb
|
297
302
|
- lib/branch_io_cli/configuration.rb
|
298
303
|
- lib/branch_io_cli/configuration/configuration.rb
|
304
|
+
- lib/branch_io_cli/configuration/option.rb
|
305
|
+
- lib/branch_io_cli/configuration/option_wrapper.rb
|
299
306
|
- lib/branch_io_cli/configuration/report_configuration.rb
|
300
307
|
- lib/branch_io_cli/configuration/setup_configuration.rb
|
301
308
|
- lib/branch_io_cli/configuration/validate_configuration.rb
|
@@ -303,6 +310,9 @@ files:
|
|
303
310
|
- lib/branch_io_cli/core_ext.rb
|
304
311
|
- lib/branch_io_cli/core_ext/io.rb
|
305
312
|
- lib/branch_io_cli/core_ext/regexp.rb
|
313
|
+
- lib/branch_io_cli/format.rb
|
314
|
+
- lib/branch_io_cli/format/commander_format.rb
|
315
|
+
- lib/branch_io_cli/format/markdown_format.rb
|
306
316
|
- lib/branch_io_cli/helper.rb
|
307
317
|
- lib/branch_io_cli/helper/android_helper.rb
|
308
318
|
- lib/branch_io_cli/helper/branch_helper.rb
|