-
Notifications
You must be signed in to change notification settings - Fork 27
/
install.rb
46 lines (37 loc) · 1.29 KB
/
install.rb
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
require "net/http"
require "uri"
require 'fileutils'
sentry_uri = URI.parse("https://raw.githubusercontent.com/samueleaton/sentry/master/src/sentry.cr")
req = Net::HTTP.new(sentry_uri.host, sentry_uri.port)
req.use_ssl = (sentry_uri.scheme == "https")
response = req.request(Net::HTTP::Get.new(sentry_uri.request_uri))
if response.code.to_i > 299
puts "HTTP request error"
puts response.msg
exit 1
end
sentry_code = response.body
sentry_cli_uri = URI.parse("https://raw.githubusercontent.com/samueleaton/sentry/master/src/sentry_cli.cr")
req = Net::HTTP.new(sentry_cli_uri.host, sentry_cli_uri.port)
req.use_ssl = (sentry_cli_uri.scheme == "https")
response = req.request(Net::HTTP::Get.new(sentry_cli_uri.request_uri))
if response.code.to_i > 299
puts "HTTP request error"
puts response.msg
exit 1
end
sentry_cli_code = response.body
FileUtils.mkdir_p "./dev"
File.write "./dev/sentry.cr", sentry_code
File.write "./dev/sentry_cli.cr", sentry_cli_code
puts "Compiling sentry using --release flag..."
compile_success = system "crystal build --release ./dev/sentry_cli.cr -o ./sentry"
if compile_success
puts "🤖 sentry installed!"
puts "\nTo execute sentry, do:
./sentry\n"
puts "\nTo see options:
./sentry --help\n\n"
else
puts "🤖 Bzzt. There was an error compiling sentry."
end