-
Notifications
You must be signed in to change notification settings - Fork 95
/
mac
124 lines (92 loc) · 3.17 KB
/
mac
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
#!/usr/bin/env bash
# Install Rails
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
create_zshrc_and_set_it_as_shell_file() {
if [ ! -f "$HOME/.zshrc" ]; then
touch "$HOME/.zshrc"
fi
shell_file="$HOME/.zshrc"
shell_profile="$HOME/.zprofile"
}
create_bashrc_and_set_it_as_shell_file() {
if [ ! -f "$HOME/.bashrc" ]; then
touch "$HOME/.bashrc"
fi
shell_file="$HOME/.bashrc"
shell_profile="$HOME/.bash_profile"
}
case "$SHELL" in
*/zsh) :
create_zshrc_and_set_it_as_shell_file
;;
*)
create_bashrc_and_set_it_as_shell_file
;;
esac
log_info() {
printf "\n\e[0;35m $1\e[0m\n\n"
}
if ! command -v brew &>/dev/null; then
log_info "Installing Homebrew, a good OS X package manager ..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> $shell_profile
eval "$(/opt/homebrew/bin/brew shellenv)"
else
log_info "Homebrew already installed. Skipping ..."
fi
log_info "Updating Homebrew formulas ..."
brew update
log_info "Installing Homebrew Services"
brew tap homebrew/services
log_info "Installing Postgres, a good open source relational database ..."
brew install postgresql@13
log_info "Starting Postgres ..."
brew services start postgresql@13
log_info "Adding Postgres to PATH ..."
echo 'export PATH="/opt/homebrew/opt/postgresql@13/bin:$PATH"' >> ~/.zshrc
log_info "Installing Redis, a good key-value database ..."
brew install redis
log_info "Starting Redis ..."
brew services start redis
log_info "Installing and linking ImageMagick, to crop and resize images ..."
brew install imagemagick
log_info "Installing rbenv, to change Ruby versions ..."
brew install rbenv
if ! grep -qs "rbenv init" $shell_file; then
printf '\n# load rbenv\n' >> $shell_file
printf 'export PATH="$HOME/.rbenv/bin:$PATH"\n' >> $shell_file
printf 'eval "$(rbenv init - --no-rehash)"\n' >> $shell_file
log_info "Enable shims and autocompletion ..."
eval "$(rbenv init -)"
fi
export PATH="$HOME/.rbenv/bin:$PATH"
log_info "Installing ruby-build, to install Rubies ..."
brew install ruby-build
log_info "Upgrading and linking OpenSSL ..."
brew install openssl@1.1
brew link openssl@1.1 --force
log_info "Installing image libs ..."
brew install advancecomp jhead jpegoptim jpeg optipng oxipng pngcrush pngquant
log_info "Installing coreutils ..."
brew install coreutils
ruby_version="3.2.1"
log_info "Installing Ruby $ruby_version ..."
rbenv install "$ruby_version"
log_info "Setting $ruby_version as global default Ruby ..."
rbenv global "$ruby_version"
log_info "Updating to latest Rubygems version ..."
gem update --system
log_info "Installing Bundler to install project-specific Ruby gems ..."
gem install bundler
log_info "Configuring Bundler for faster, parallel gem installation ..."
number_of_cores=$(sysctl -n hw.ncpu)
bundle config --global jobs $((number_of_cores - 1))
log_info "Installing Rails ..."
gem install rails
log_info "Installing MailHog ..."
brew install mailhog
log_info "Installing Node ..."
brew install node
log_info "Installing pnpm ..."
npm install -g pnpm