-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·228 lines (199 loc) · 4.9 KB
/
install.sh
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/usr/bin/env bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -uo pipefail
# Basic dependencies
source ./helpers.sh
# $DOTF will be the directory this repo is cloned
DOTF=`dirname ${BASH_SOURCE[0]-$0}`
export DOTF=`cd $DOTF && pwd`
title "Running install script"
info "Currently in: ${DOTF}"
# Parse input parameters
export DRY_RUN=false
export VERBOSE=false
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
# TODO: Add 'help' option
# TODO: Add option to install only specific folder
-d|--dry-run)
DRY_RUN=true
shift # pass argument
;;
-v|--verbose)
VERBOSE=true
shift # pass argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # pass argument
;;
esac
done
info "DRY_RUN = ${DRY_RUN}"
info "VERBOSE = ${VERBOSE}"
export BE_QUIET="&>/dev/null"
if [ $VERBOSE == true ]; then
BE_QUIET=""
fi
#
# Check if brew is installed
#
echo ""
check "Checking if brew is installed"
which -s brew
if [ $? != 0 ]; then
info "Brew is missing"
info "Installing brew..."
if ! $DRY_RUN; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
success "Done installing brew"
else
success "Brew is installed"
info "Making sure brew is up to date"
if ! $DRY_RUN; then
brew update
fi
success "Done updating brew"
fi
if [ $? -ne 0 ]; then
error "Failed to install or update brew"
exit 1
fi
#
# Install nodejs & npm (using 'n')
#
echo ""
check "Checking if node is installed"
which -s n
if [ $? != 0 ]; then
info "Node is missing"
info "Installing node (with 'n')..."
if ! $DRY_RUN; then
brew install n
fi
success "node installed"
fi
info "Making sure you have latest version of node"
if ! $DRY_RUN; then
sudo n latest
fi
success "Latest node version installed"
if [ $? -eq 0 ]; then
success "Done installing/updating nodejs"
else
error "Failed to install/update nodejs"
exit 1
fi
# Install some global node packages
echo ""
info "Installing global node packages..."
NODE_PACKAGES=('webpack' \
'webpack-cli' \
'typescript' \
'ts-node' \
'typescript-language-server' \
'eslint' \
'jest' \
'concurrently' \
'neovim' \
'pyright' \
'next' \
'serve' \
'@gillyb/nrun' \
)
# for package in "${NODE_PACKAGES[@]}"; do
# minor "Installing '${package}'"
# if ! $DRY_RUN; then
# eval "sudo npm install -g ${package} ${BE_QUIET}"
# if [ $? -eq 0 ]; then
# success "Installed ${package}"
# else
# error "Failed to install '${package}'"
# error "You can try running this script again with --verbose"
# pause
# fi
# fi
# done
# Go through various installations
# Start with some basic utilities
echo ""
info "Installing some basic utils with brew"
BREW_UTILS=( \
'tmux' \
'fzf' \
'bat' \
'fd' \
'ripgrep' \
'jq' \
'python' \
'htop' \
'diff-so-fancy' \
'ncdu' \
'deno' \
'yarn' \
)
for package in "${BREW_UTILS[@]}"; do
minor "Installing '${package}'"
if ! $DRY_RUN; then
eval "brew install ${package} ${BE_QUIET}"
if [ $? -eq 0 ]; then
success "Installed '${package}'"
else
error "Failed to install '${package}'"
error "You can try running this script again with --verbose"
pause
fi
fi
done
echo ""
info "Installing some basic utils with brew-cask"
BREW_CASK_UTILS=( \
'google-chrome' \
'sublime-text' \
'iterm2' \
'ngrok' \
'font-hack-nerd-font' \
'whatsapp' \
'visual-studio-code' \
'github' \
'spotify' \
'prusaslicer' \
'notion' \
'font-monaspace' \
'docker' \
)
brew tap homebrew/cask-fonts
for package in "${BREW_CASK_UTILS[@]}"; do
minor "Installing '${package}'"
if ! $DRY_RUN; then
eval "brew install ${package} ${BE_QUIET}"
if [ $? -eq 0 ]; then
success "Installed '${package}'"
else
error "Failed to install '${package}'"
error "You can try running this script again with --verbose"
pause
fi
fi
done
# Now use node to install the rest
echo ""
echo ""
echo ""
info " Starting app installations.. "
echo ""
node node/install.js
if [ $? != 0 ]; then
error "\nFailed to run node installations.."
exit 1
end
echo ""
echo ""
success "Installation is complete :)"
echo ""
echo ""
exit 0