This repository has been archived by the owner on Mar 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Rakefile
146 lines (124 loc) · 3.86 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
require 'xcinvoke'
desc 'Bootstraps the app'
task :bootstrap do
sh "bundle install"
end
begin
require 'bundler'
Bundler.require
require 'rubocop/rake_task'
require 'net/ssh'
require 'net/ssh/shell'
def run_ssh_commands commands
puts "Connecting to api.cocoadocs.org:"
Net::SSH.start('207.254.41.223', 'cocoadocs') do |ssh|
ssh.shell do |sh|
sh.execute 'cd cocoadocs.org'
commands.each do |command|
puts command.yellow
sh.execute command
end
sh.execute 'exit'
end
end
end
desc 'Starts the server via SSH'
desc 'Updates the server via SSH'
task :start do
run_ssh_commands [
'killall "foreman: master"',
'screen -d -m -S "cocoadocs" bundle exec foreman start'
]
end
desc 'Updates the server via SSH'
task :deploy do
run_ssh_commands [
'killall "foreman: master"',
'git stash',
'git pull',
'bundle install',
'screen -d -m -S "cocoadocs" bundle exec foreman start'
]
end
desc 'Check out the logs on the live server'
task :logs do
run_ssh_commands ["screen -r cocoadocs"]
end
desc 'Re-runs documentation for a CocoaPod via SSH'
task :doc, :name do |t, args|
run_ssh_commands ["bundle exec foreman run ruby cocoadocs.rb cocoadocs doc #{args.name} --verbose"]
end
desc 'Re-runs CP stuff for a CocoaPod via SSH'
task :pod, :name do |t, args|
run_ssh_commands ["bundle exec foreman run ruby cocoapods-simple.rb #{args.name} --verbose"]
end
desc 'Run a command on the server via SSH'
task :exec, :command do |t, args|
run_ssh_commands [args.command]
end
desc 'Re-runs x days worth of documentation for a CocoaPod via SSH'
task :days, :number do |t, args|
run_ssh_commands ["bundle exec foreman run ruby cocoadocs.rb cocoadocs days #{args.number} --verbose"]
end
desc 'Delete all docs for a pod'
task :cocoadocs_rm_pod, :pod do |t, args|
exit(1) if args.count != 1
exit(1) if args.first == "."
exit(1) if args.first == ".."
system "aws s3 rm --recursive s3://buddybuild-cocoadocs/docsets/#{args.pod}"
end
desc 'Delete docs for a pod versions'
task :cocoadocs_rm_pod_version, :pod, :version do |t, args|
exit(1) if args.count != 2
exit(1) if args.first == "."
exit(1) if args.first == ".."
system "aws s3 rm --recursive s3://buddybuild-cocoadocs/docsets/#{args.pod}/#{args.version}"
end
desc 'Sets up installation of apps for cocoadocs'
task :install_tools do
if `which brew`.length == 0
puts "Homebrew was not found, would you like us to install it for you? yes/no"
exit unless STDIN.gets.strip == 'yes'
`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
end
check_and_install "cloc"
check_and_install "appledoc"
check_and_install "carthage"
check_and_install "awscli"
end
def check_and_install app
if `which #{app}`.length == 0
Bundler.with_clean_env do
`brew install #{app}`
end
end
end
def specs(dir)
FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
end
desc 'Runs all the specs'
task :specs do
sh "bundle exec bacon #{specs('**')}"
end
desc 'Dump all available versions of swift'
task :swift_versions do
XCInvoke::Xcode.all.each do |xc|
puts "#{xc.developer_dir} - Swift version #{xc.swift_version}"
end
end
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['classes', 'spec']
end
# TODO: Put rubocop in by default
task :default => :specs
rescue LoadError => e
$stderr.puts "\033[0;31m" \
'[!] Some Rake tasks haven been disabled because the environment' \
' couldn’t be loaded. Be sure to run `rake bootstrap` first or use the ' \
"VERBOSE environment variable to see errors.\e[0m"
if ENV['VERBOSE']
$stderr.puts e.message
$stderr.puts e.backtrace
$stderr.puts
end
end