branch_io_cli 0.12.2 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5aed004a45c8ab9ba1551d603e972affbc07660351c1495d378e9d08492452
|
4
|
+
data.tar.gz: 54786f9bcb72a71855dab1575482a964b26779c6a3b6fd4a8053cbe553c33507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 434932c0f1da70515c63b5d069a2171ea5bac2109cd47ad405b3a057a98bad4a145c52316616a12ff31bd8cff84761373ea47e5b51b918160070f9c3c418ae36
|
7
|
+
data.tar.gz: 4cfdc82ca1e78119bb0e3fa9a1d1a5c0b82eba4e38292f443aee726900e6f709cde5f22959aebf60637bee42ede08d00a81d0bc57a1ac9a025ca1dab0ed90185
|
data/lib/branch_io_cli/cli.rb
CHANGED
@@ -61,7 +61,7 @@ module BranchIOCLI
|
|
61
61
|
|
62
62
|
def class_for_command(name, type)
|
63
63
|
type_name = type.to_s.capitalize
|
64
|
-
type_module =
|
64
|
+
type_module = BranchIOCLI.const_get(type_name)
|
65
65
|
candidate = type_module.const_get("#{name.to_s.capitalize}#{type_name}")
|
66
66
|
return nil unless candidate
|
67
67
|
|
@@ -10,9 +10,7 @@ module BranchIOCLI
|
|
10
10
|
def configuration_class
|
11
11
|
root = command_name.capitalize
|
12
12
|
|
13
|
-
|
14
|
-
.const_get("Configuration")
|
15
|
-
.const_get("#{root}Configuration")
|
13
|
+
BranchIOCLI::Configuration.const_get("#{root}Configuration")
|
16
14
|
end
|
17
15
|
|
18
16
|
def available_options
|
@@ -47,6 +45,10 @@ module BranchIOCLI
|
|
47
45
|
def patch_helper
|
48
46
|
Helper::PatchHelper
|
49
47
|
end
|
48
|
+
|
49
|
+
def tool_helper
|
50
|
+
Helper::ToolHelper
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -40,13 +40,13 @@ module BranchIOCLI
|
|
40
40
|
report_helper.pod_install_if_required report
|
41
41
|
|
42
42
|
# run xcodebuild -list
|
43
|
-
report.
|
43
|
+
report.sh(*report_helper.base_xcodebuild_cmd, "-list")
|
44
44
|
|
45
45
|
# If using a workspace, -list all the projects as well
|
46
46
|
if config.workspace_path
|
47
47
|
config.workspace.file_references.map(&:path).each do |project_path|
|
48
48
|
path = File.join File.dirname(config.workspace_path), project_path
|
49
|
-
report.
|
49
|
+
report.sh "xcodebuild", "-list", "-project", path
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -57,13 +57,18 @@ module BranchIOCLI
|
|
57
57
|
|
58
58
|
base_cmd = report_helper.base_xcodebuild_cmd
|
59
59
|
# Add more options for the rest of the commands
|
60
|
-
base_cmd +=
|
61
|
-
|
62
|
-
|
60
|
+
base_cmd += [
|
61
|
+
"-scheme",
|
62
|
+
config.scheme,
|
63
|
+
"-configuration",
|
64
|
+
config.configuration || config.configurations_from_scheme.first,
|
65
|
+
"-sdk",
|
66
|
+
config.sdk
|
67
|
+
]
|
63
68
|
|
64
69
|
if config.clean
|
65
70
|
say "Cleaning"
|
66
|
-
if report.
|
71
|
+
if report.sh(*base_cmd, "clean").success?
|
67
72
|
say "Done ✅"
|
68
73
|
else
|
69
74
|
say "Clean failed."
|
@@ -71,7 +76,7 @@ module BranchIOCLI
|
|
71
76
|
end
|
72
77
|
|
73
78
|
say "Building"
|
74
|
-
if report.
|
79
|
+
if report.sh(*base_cmd, "-verbose").success?
|
75
80
|
say "Done ✅"
|
76
81
|
else
|
77
82
|
say "Build failed."
|
@@ -11,103 +11,119 @@ module BranchIOCLI
|
|
11
11
|
@domains = config.all_domains
|
12
12
|
end
|
13
13
|
|
14
|
-
# rubocop: disable Metrics/PerceivedComplexity
|
15
14
|
def run!
|
16
15
|
# Make sure the user stashes or commits before continuing.
|
17
|
-
check_repo_status
|
16
|
+
return 1 unless check_repo_status
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if is_app_target && config.validate &&
|
24
|
-
!helper.validate_team_and_bundle_ids_from_aasa_files(@domains)
|
25
|
-
say "Universal Link configuration failed validation."
|
26
|
-
helper.errors.each { |error| say " #{error}" }
|
27
|
-
return 1 unless config.force
|
28
|
-
elsif is_app_target && config.validate
|
29
|
-
say "Universal Link configuration passed validation. ✅"
|
18
|
+
# Validate Universal Link configuration in an application target.
|
19
|
+
if config.validate && config.target.symbol_type == :application
|
20
|
+
valid = validate_universal_links
|
21
|
+
return 1 unless valid || config.force
|
30
22
|
end
|
31
23
|
|
24
|
+
# Make sure we can resolve all build settings in a project using
|
25
|
+
# CocoaPods.
|
32
26
|
if config.podfile_path && File.exist?(config.podfile_path) && config.pod_install_required?
|
33
|
-
|
27
|
+
tool_helper.verify_cocoapods
|
34
28
|
say "Installing pods to resolve current build settings"
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
sh "pod install"
|
39
|
-
end
|
29
|
+
# We haven't modified anything yet. Don't use --repo-update at this stage.
|
30
|
+
# This is unlikely to fail.
|
31
|
+
sh "pod install", chdir: File.dirname(config.podfile_path)
|
40
32
|
end
|
41
33
|
|
42
|
-
|
34
|
+
# Add SDK via CocoaPods, Carthage or direct download (no-op if disabled).
|
35
|
+
add_sdk
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
helper.ensure_uri_scheme_in_info_plist if is_app_target # does nothing if already present
|
37
|
+
# Set up Universal Links and Branch key(s)
|
38
|
+
update_project_settings
|
47
39
|
|
48
|
-
if
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
# Patch source code if so instructed.
|
41
|
+
patch_helper.patch_source config.xcodeproj if config.patch_source
|
42
|
+
|
43
|
+
# Commit changes if so instructed.
|
44
|
+
commit_changes if config.commit
|
45
|
+
|
46
|
+
# Return success.
|
47
|
+
0
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate_universal_links
|
51
|
+
valid = helper.validate_team_and_bundle_ids_from_aasa_files @domains
|
52
|
+
if valid
|
53
|
+
say "Universal Link configuration passed validation. ✅"
|
54
|
+
else
|
55
|
+
say "Universal Link configuration failed validation."
|
56
|
+
helper.errors.each { |error| say " #{error}" }
|
53
57
|
end
|
58
|
+
valid
|
59
|
+
end
|
54
60
|
|
55
|
-
|
61
|
+
def update_project_settings
|
62
|
+
helper.add_custom_build_setting if config.setting
|
63
|
+
helper.add_keys_to_info_plist @keys
|
64
|
+
config.target.add_system_frameworks config.frameworks unless config.frameworks.blank?
|
65
|
+
|
66
|
+
return unless config.target.symbol_type == :application
|
56
67
|
|
57
|
-
|
68
|
+
helper.add_branch_universal_link_domains_to_info_plist @domains
|
69
|
+
helper.ensure_uri_scheme_in_info_plist
|
70
|
+
config.xcodeproj.build_configurations.each do |c|
|
71
|
+
new_path = helper.add_universal_links_to_project @domains, false, c.name
|
72
|
+
sh "git", "add", new_path if config.commit && new_path
|
73
|
+
end
|
74
|
+
ensure
|
75
|
+
config.xcodeproj.save
|
76
|
+
end
|
58
77
|
|
78
|
+
def add_sdk
|
59
79
|
case config.sdk_integration_mode
|
60
80
|
when :cocoapods
|
61
81
|
if File.exist? config.podfile_path
|
62
|
-
|
82
|
+
tool_helper.update_podfile config
|
63
83
|
else
|
64
|
-
|
84
|
+
tool_helper.add_cocoapods config
|
65
85
|
end
|
66
86
|
when :carthage
|
67
87
|
if File.exist? config.cartfile_path
|
68
|
-
|
88
|
+
tool_helper.update_cartfile config, config.xcodeproj
|
69
89
|
else
|
70
|
-
|
90
|
+
tool_helper.add_carthage config
|
71
91
|
end
|
72
92
|
when :direct
|
73
|
-
|
93
|
+
tool_helper.add_direct config
|
74
94
|
end
|
95
|
+
end
|
75
96
|
|
76
|
-
|
77
|
-
|
78
|
-
return 0 unless config.commit
|
79
|
-
|
97
|
+
def commit_changes
|
80
98
|
changes = helper.changes.to_a.map { |c| Pathname.new(File.expand_path(c)).relative_path_from(Pathname.pwd).to_s }
|
81
99
|
|
82
100
|
commit_message = config.commit if config.commit.kind_of?(String)
|
83
101
|
commit_message ||= "[branch_io_cli] Branch SDK integration #{config.relative_path(config.xcodeproj_path)} (#{config.target.name})"
|
84
102
|
|
85
|
-
sh
|
86
|
-
|
87
|
-
0
|
103
|
+
sh "git", "commit", "-qm", commit_message, *changes
|
88
104
|
end
|
89
|
-
# rubocop: enable Metrics/PerceivedComplexity
|
90
105
|
|
91
106
|
def check_repo_status
|
92
107
|
# If the git command is not installed, there's not much we can do.
|
93
108
|
# Don't want to use verify_git here, which will insist on installing
|
94
109
|
# the command. The logic of that method could change.
|
95
|
-
return if `which git`.empty? || !config.confirm
|
110
|
+
return true if `which git`.empty? || !config.confirm
|
96
111
|
|
97
112
|
unless Dir.exist? ".git"
|
98
113
|
`git rev-parse --git-dir > /dev/null 2>&1`
|
99
114
|
# Not a git repo
|
100
|
-
return unless $?.success?
|
115
|
+
return true unless $?.success?
|
101
116
|
end
|
102
117
|
|
103
118
|
`git diff-index --quiet HEAD --`
|
104
|
-
return if $?.success?
|
119
|
+
return true if $?.success?
|
105
120
|
|
106
121
|
# Show the user
|
107
122
|
sh "git status"
|
108
123
|
|
109
124
|
choice = choose do |menu|
|
110
125
|
menu.header = "There are uncommitted changes in this repo. It's best to stash or commit them before continuing."
|
126
|
+
menu.readline = true
|
111
127
|
menu.choice "Stash"
|
112
128
|
menu.choice "Commit (You will be prompted for a commit message.)"
|
113
129
|
menu.choice "Quit"
|
@@ -120,11 +136,13 @@ module BranchIOCLI
|
|
120
136
|
sh "git stash -q"
|
121
137
|
when /^Commit/
|
122
138
|
message = ask "Please enter a commit message: "
|
123
|
-
sh
|
139
|
+
sh "git", "commit", "-aqm", message
|
124
140
|
when /^Quit/
|
125
141
|
say "Please stash or commit your changes before continuing."
|
126
|
-
|
142
|
+
return false
|
127
143
|
end
|
144
|
+
|
145
|
+
true
|
128
146
|
end
|
129
147
|
end
|
130
148
|
end
|
@@ -2,6 +2,9 @@ require "branch_io_cli/configuration/configuration"
|
|
2
2
|
require "branch_io_cli/configuration/option"
|
3
3
|
require "branch_io_cli/configuration/option_wrapper"
|
4
4
|
require "branch_io_cli/configuration/report_configuration"
|
5
|
+
require "branch_io_cli/configuration/report_options"
|
5
6
|
require "branch_io_cli/configuration/setup_configuration"
|
7
|
+
require "branch_io_cli/configuration/setup_options"
|
6
8
|
require "branch_io_cli/configuration/validate_configuration"
|
9
|
+
require "branch_io_cli/configuration/validate_options"
|
7
10
|
require "branch_io_cli/configuration/xcode_settings"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "artii"
|
1
2
|
require "cocoapods-core"
|
2
3
|
require "pathname"
|
3
4
|
require "xcodeproj"
|
@@ -24,6 +25,11 @@ module BranchIOCLI
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
def available_options
|
29
|
+
root = name.gsub(/^.*::(\w+)Configuration$/, '\1')
|
30
|
+
BranchIOCLI::Configuration.const_get("#{root.capitalize}Options").available_options
|
31
|
+
end
|
32
|
+
|
27
33
|
def absolute_path(path)
|
28
34
|
return path unless current
|
29
35
|
current.absolute_path path
|
@@ -92,6 +98,7 @@ EOF
|
|
92
98
|
say <<EOF
|
93
99
|
<%= color("branch_io #{self.class.name.sub(/^.*::(.*?)Configuration$/, '\1').downcase} v. #{VERSION}", BOLD) %>
|
94
100
|
|
101
|
+
#{Artii::Base.new.asciify 'Branch'}
|
95
102
|
EOF
|
96
103
|
end
|
97
104
|
|
@@ -322,8 +329,8 @@ EOF
|
|
322
329
|
objc_paths = all_paths.grep(/\.m$/)
|
323
330
|
objc_paths += objc_paths.map { |p| p.sub(/\.m$/, '.h') }.select { |f| File.exist? f }
|
324
331
|
|
325
|
-
path = swift_paths.find { |f| /class.*:\s+MSMessagesAppViewController\s*{\n/m.match_file f } ||
|
326
|
-
objc_paths.find { |f| /@interface.*:\s+MSMessagesAppViewController/.match_file f }
|
332
|
+
path = swift_paths.find { |f| /class.*:\s+MSMessagesAppViewController\s*{\n/m.match_file? f } ||
|
333
|
+
objc_paths.find { |f| /@interface.*:\s+MSMessagesAppViewController/.match_file? f }
|
327
334
|
|
328
335
|
# If we found a .h, patch the corresponding .m.
|
329
336
|
path && path.sub(/\.h$/, '.m')
|
@@ -3,91 +3,11 @@ require "xcodeproj"
|
|
3
3
|
|
4
4
|
module BranchIOCLI
|
5
5
|
module Configuration
|
6
|
-
# rubocop: disable Metrics/ClassLength
|
7
6
|
class ReportConfiguration < Configuration
|
8
7
|
class << self
|
9
8
|
def summary
|
10
9
|
"Generate and optionally submit a build diagnostic report."
|
11
10
|
end
|
12
|
-
|
13
|
-
def available_options
|
14
|
-
[
|
15
|
-
Option.new(
|
16
|
-
name: :workspace,
|
17
|
-
description: "Path to an Xcode workspace",
|
18
|
-
type: String,
|
19
|
-
example: "MyProject.xcworkspace"
|
20
|
-
),
|
21
|
-
Option.new(
|
22
|
-
name: :xcodeproj,
|
23
|
-
description: "Path to an Xcode project",
|
24
|
-
type: String,
|
25
|
-
example: "MyProject.xcodeproj"
|
26
|
-
),
|
27
|
-
Option.new(
|
28
|
-
name: :scheme,
|
29
|
-
description: "A scheme from the project or workspace to build",
|
30
|
-
type: String,
|
31
|
-
example: "MyProjectScheme"
|
32
|
-
),
|
33
|
-
Option.new(
|
34
|
-
name: :target,
|
35
|
-
description: "A target to build",
|
36
|
-
type: String,
|
37
|
-
example: "MyProjectTarget"
|
38
|
-
),
|
39
|
-
Option.new(
|
40
|
-
name: :configuration,
|
41
|
-
description: "The build configuration to use (default: Scheme-dependent)",
|
42
|
-
type: String,
|
43
|
-
example: "Debug/Release/CustomConfigName"
|
44
|
-
),
|
45
|
-
Option.new(
|
46
|
-
name: :sdk,
|
47
|
-
description: "Passed as -sdk to xcodebuild",
|
48
|
-
type: String,
|
49
|
-
example: "iphoneos",
|
50
|
-
default_value: "iphonesimulator"
|
51
|
-
),
|
52
|
-
Option.new(
|
53
|
-
name: :podfile,
|
54
|
-
description: "Path to the Podfile for the project",
|
55
|
-
type: String,
|
56
|
-
example: "/path/to/Podfile"
|
57
|
-
),
|
58
|
-
Option.new(
|
59
|
-
name: :cartfile,
|
60
|
-
description: "Path to the Cartfile for the project",
|
61
|
-
type: String,
|
62
|
-
example: "/path/to/Cartfile"
|
63
|
-
),
|
64
|
-
Option.new(
|
65
|
-
name: :clean,
|
66
|
-
description: "Clean before attempting to build",
|
67
|
-
default_value: true
|
68
|
-
),
|
69
|
-
Option.new(
|
70
|
-
name: :header_only,
|
71
|
-
description: "Write a report header to standard output and exit",
|
72
|
-
default_value: false,
|
73
|
-
aliases: "-H"
|
74
|
-
),
|
75
|
-
Option.new(
|
76
|
-
name: :pod_repo_update,
|
77
|
-
description: "Update the local podspec repo before installing",
|
78
|
-
default_value: true
|
79
|
-
),
|
80
|
-
Option.new(
|
81
|
-
name: :out,
|
82
|
-
description: "Report output path",
|
83
|
-
default_value: "./report.txt",
|
84
|
-
aliases: "-o",
|
85
|
-
example: "./report.txt",
|
86
|
-
type: String,
|
87
|
-
env_name: "BRANCH_REPORT_PATH"
|
88
|
-
)
|
89
|
-
]
|
90
|
-
end
|
91
11
|
end
|
92
12
|
|
93
13
|
attr_reader :report_path
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module BranchIOCLI
|
2
|
+
module Configuration
|
3
|
+
class ReportOptions
|
4
|
+
class << self
|
5
|
+
def available_options
|
6
|
+
[
|
7
|
+
Option.new(
|
8
|
+
name: :workspace,
|
9
|
+
description: "Path to an Xcode workspace",
|
10
|
+
type: String,
|
11
|
+
example: "MyProject.xcworkspace"
|
12
|
+
),
|
13
|
+
Option.new(
|
14
|
+
name: :xcodeproj,
|
15
|
+
description: "Path to an Xcode project",
|
16
|
+
type: String,
|
17
|
+
example: "MyProject.xcodeproj"
|
18
|
+
),
|
19
|
+
Option.new(
|
20
|
+
name: :scheme,
|
21
|
+
description: "A scheme from the project or workspace to build",
|
22
|
+
type: String,
|
23
|
+
example: "MyProjectScheme"
|
24
|
+
),
|
25
|
+
Option.new(
|
26
|
+
name: :target,
|
27
|
+
description: "A target to build",
|
28
|
+
type: String,
|
29
|
+
example: "MyProjectTarget"
|
30
|
+
),
|
31
|
+
Option.new(
|
32
|
+
name: :configuration,
|
33
|
+
description: "The build configuration to use (default: Scheme-dependent)",
|
34
|
+
type: String,
|
35
|
+
example: "Debug/Release/CustomConfigName"
|
36
|
+
),
|
37
|
+
Option.new(
|
38
|
+
name: :sdk,
|
39
|
+
description: "Passed as -sdk to xcodebuild",
|
40
|
+
type: String,
|
41
|
+
example: "iphoneos",
|
42
|
+
default_value: "iphonesimulator"
|
43
|
+
),
|
44
|
+
Option.new(
|
45
|
+
name: :podfile,
|
46
|
+
description: "Path to the Podfile for the project",
|
47
|
+
type: String,
|
48
|
+
example: "/path/to/Podfile"
|
49
|
+
),
|
50
|
+
Option.new(
|
51
|
+
name: :cartfile,
|
52
|
+
description: "Path to the Cartfile for the project",
|
53
|
+
type: String,
|
54
|
+
example: "/path/to/Cartfile"
|
55
|
+
),
|
56
|
+
Option.new(
|
57
|
+
name: :clean,
|
58
|
+
description: "Clean before attempting to build",
|
59
|
+
default_value: true
|
60
|
+
),
|
61
|
+
Option.new(
|
62
|
+
name: :header_only,
|
63
|
+
description: "Write a report header to standard output and exit",
|
64
|
+
default_value: false,
|
65
|
+
aliases: "-H"
|
66
|
+
),
|
67
|
+
Option.new(
|
68
|
+
name: :pod_repo_update,
|
69
|
+
description: "Update the local podspec repo before installing",
|
70
|
+
default_value: true
|
71
|
+
),
|
72
|
+
Option.new(
|
73
|
+
name: :out,
|
74
|
+
description: "Report output path",
|
75
|
+
default_value: "./report.txt",
|
76
|
+
aliases: "-o",
|
77
|
+
example: "./report.txt",
|
78
|
+
type: String,
|
79
|
+
env_name: "BRANCH_REPORT_PATH"
|
80
|
+
)
|
81
|
+
]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|