Last active
October 7, 2019 03:26
-
-
Save nerijunior/3ac4a5b09ab804e8e892cc7541719a4c to your computer and use it in GitHub Desktop.
Brand New Mac Installation Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
system("gem", "install", "tty-prompt") | |
system("xcode-select", "--install") | |
require "tty-prompt" | |
class Installer | |
def initialize(prompt) | |
@prompt = prompt | |
@versions = { | |
erlang: "22.1", | |
elixir: "1.9.1", | |
golang: "1.13", | |
java: "adopt-openjdk-8u222-b10", | |
nodejs: "10.16.3", | |
php: "7.3.9", | |
python: "3.7.4", | |
ruby: "2.6.3", | |
yarn: "1.18.0", | |
} | |
end | |
def exec(*args) | |
puts "exec: #{args}" | |
raise "Failed during #{args}" unless Kernel.system(*args) | |
end | |
def brew | |
@prompt.say("Installing Homebrew...", color: :yellow) | |
self.exec('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"') | |
self.exec("brew", "install", "git", "dnsmask", "tree", "git-flow", "awscli", "httpie", "htop", "asdf", "coreutils", "gpg") | |
@prompt.say("Homebrew installed!", color: :green) | |
end | |
def install_language(language) | |
@prompt.say("Installing #{language.capitalize}", color: :yellow) | |
version = @versions[language.to_sym] | |
begin | |
self.exec("asdf", "plugin-add", "erlang") | |
rescue => exception | |
@prompt.say(exception) | |
end | |
self.exec("asdf", "install", language, version) | |
@prompt.say("#{language.capitalize} installed!", color: :green) | |
end | |
def apps | |
self.exec("brew", "cask", "install", "appcleaner") | |
self.exec("brew", "cask", "install", "android-file-transfer") | |
self.exec("brew", "cask", "install", "discord") | |
self.exec("brew", "cask", "install", "firefox") | |
self.exec("brew", "cask", "install", "intellij-idea-ce") | |
self.exec("brew", "cask", "install", "macdown") | |
self.exec("brew", "cask", "install", "obs") | |
self.exec("brew", "cask", "install", "opera") | |
self.exec("brew", "cask", "install", "postman") | |
self.exec("brew", "cask", "install", "reaper") | |
self.exec("brew", "cask", "install", "spectacle") | |
self.exec("brew", "cask", "install", "spotify") | |
self.exec("brew", "cask", "install", "skype") | |
self.exec("brew", "cask", "install", "slack") | |
self.exec("brew", "cask", "install", "skyfonts") | |
self.exec("brew", "cask", "install", "the-unarchiver") | |
self.exec("brew", "cask", "install", "visual-studio-code") | |
self.exec("brew", "cask", "install", "vlc") | |
end | |
end | |
def title(prompt, text, color = :cyan) | |
prompt.say("-" * 80, color: color) | |
prompt.say(text, color: :cyan) | |
prompt.say("-" * 80, color: :cyan) | |
end | |
prompt = TTY::Prompt.new(active_color: :cyan) | |
# ========== | |
# ==========> Let the games begin! | |
# ========== | |
installer = Installer.new(prompt) | |
title(prompt, "Let's install all the stuff we need to do a greate job.") | |
interactive = prompt.yes?("Do you want to be an interactive experience?", color: :yellow) | |
if interactive | |
if prompt.yes?("Install Homebrew?") | |
installer.brew() | |
end | |
else | |
installer.brew() | |
end | |
if interactive | |
languages = %w(erlang elixir golang java nodejs php python ruby yarn) | |
selected_languages = prompt.multi_select("What languages to install?", languages) | |
if selected_languages.length > 0 | |
selected_languages.each do |language| | |
puts "install #{language}" | |
installer.install_language(language) | |
end | |
end | |
else | |
installer.all_languages() | |
end | |
if interactive && prompt.yes?("Install Apps?") | |
installer.apps() | |
else | |
installer.apps() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment