Skip to content

Instantly share code, notes, and snippets.

@ramon-sg
Last active February 6, 2019 13:20
Show Gist options
  • Save ramon-sg/ebe02f47fb42ffe5151fd5093fbc5e10 to your computer and use it in GitHub Desktop.
Save ramon-sg/ebe02f47fb42ffe5151fd5093fbc5e10 to your computer and use it in GitHub Desktop.
require "uri"
require "http/client"
require "file_utils"
print "🤖 Fetching sentry files..."
# Fetch sentry.cr
sentry_uri = "https://raw.githubusercontent.com/samueleaton/sentry/49a9a9cf1cdd87f0156206322df198c988132b6f/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/49a9a9cf1cdd87f0156206322df198c988132b6f/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."
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment