forked from BranchMetrics/branch_io_cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
107 lines (87 loc) · 2.67 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
require 'branch_io_cli/rake_task'
require 'branch_io_cli/format'
BranchIOCLI::RakeTask.new
require 'pattern_patch'
task default: [:spec, :rubocop]
#
# Example tasks
#
desc "Run setup, validate, report and report:full in order"
task all: [:setup, :validate, :report, "report:full"]
IOS_REPO_DIR = File.expand_path "../../ios-branch-deep-linking", __FILE__
def all_projects
projects = Dir[File.expand_path("../examples/*Example*", __FILE__)]
if Dir.exist? IOS_REPO_DIR
projects += Dir[File.expand_path("{Branch-TestBed*,Examples/*}", IOS_REPO_DIR)].reject { |p| p =~ /Xcode-7|README/ }
end
projects
end
desc "Set up all repo examples"
task :setup do
projects = Dir[File.expand_path("../examples/*Example*", __FILE__)]
Rake::Task["branch:setup"].invoke(
projects,
live_key: "key_live_xxxx",
test_key: "key_test_yyyy",
domains: %w(k272.app.link),
validate: true,
pod_repo_update: false,
setting: true,
confirm: false
)
end
desc "Validate repo examples"
task :validate do
projects = Dir[File.expand_path("../examples/*Example*", __FILE__)]
Rake::Task["branch:validate"].invoke(
projects,
domains: %w(
k272.app.link
k272-alternate.app.link
k272.test-app.link
k272-alternate.test-app.link
)
)
end
desc "Report on all examples in repo"
task :report do
Rake::Task["branch:report"].invoke all_projects, header_only: true
end
desc "Perform a full build of all examples in the repo"
task "report:full" do
Rake::Task["branch:report"].invoke all_projects, pod_repo_update: false, confirm: false
end
#
# Repo maintenance
#
desc "Regenerate reference documentation in the repo"
task "readme" do
include BranchIOCLI::Format::MarkdownFormat
text = "\\1\n"
text += %i(setup validate report).inject("") do |t, command|
t + render_command(command)
end
text += "\n\\2"
PatternPatch::Patch.new(
regexp: /(\<!-- BEGIN COMMAND REFERENCE --\>).*(\<!-- END COMMAND REFERENCE --\>)/m,
text: text,
mode: :replace
).apply File.expand_path("../README.md", __FILE__)
Rake::Task["completions"].invoke
end
desc "Generate completion scripts"
task "completions" do
require "erb"
include BranchIOCLI::Format::ShellFormat
%w(bash zsh).each do |shell|
template = File.expand_path(File.join("..", "lib", "assets", "templates", "completion.#{shell}.erb"), __FILE__)
script = File.expand_path(File.join("..", "lib", "assets", "completions", "completion.#{shell}"), __FILE__)
output = ERB.new(File.read(template)).result binding
File.write script, output
end
end