forked from samueleaton/sentry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.cr
51 lines (40 loc) · 1.37 KB
/
install.cr
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
require "uri"
require "http/client"
require "file_utils"
print "🤖 Fetching sentry files..."
# Fetch sentry.cr
sentry_uri = "https://raw.githubusercontent.com/samueleaton/sentry/master/src/sentry.cr"
fetch_sentry_response = HTTP::Client.get sentry_uri
if fetch_sentry_response.status_code > 299
puts "HTTP request error. Could not fetch #{sentry_uri}"
puts fetch_sentry_response.body
exit 1
end
sentry_code = fetch_sentry_response.body
# Fetch sentry_cli.cr
sentry_cli_uri = "https://raw.githubusercontent.com/samueleaton/sentry/master/src/sentry_cli.cr"
fetch_cli_response = HTTP::Client.get sentry_cli_uri
if fetch_cli_response.status_code > 299
puts "HTTP request error. Could not fetch #{sentry_cli_uri}"
puts fetch_cli_response.body
exit 1
end
sentry_cli_code = fetch_cli_response.body
puts " success"
# Write files to dev directory
FileUtils.mkdir_p "./dev"
File.write "./dev/sentry.cr", sentry_code
File.write "./dev/sentry_cli.cr", sentry_cli_code
# compile sentry files
puts "🤖 Compiling sentry using --release flag..."
build_args = ["build", "--release", "./dev/sentry_cli.cr", "-o", "./sentry"]
compile_success = system "crystal", build_args
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