-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·241 lines (209 loc) · 5.33 KB
/
install.sh
File metadata and controls
executable file
·241 lines (209 loc) · 5.33 KB
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
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/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}"
# 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
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
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 'nvm')
#
echo ""
check "Checking if nvm is installed"
which -s nvm
if [ $? != 0 ]; then
info "nvm is missing"
info "Installing nvm"
if ! $DRY_RUN; then
PROFILE=/dev/null bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
fi
success "nvm installed"
info "Installing node with nvm"
nvm install node
success "node installed"
info "Configuring npm global prefix"
mkdir -p ~/.npm-global/lib
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
fi
if [ $? -eq 0 ]; then
success "Done installing/updating node"
else
error "Failed to install/update node"
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 "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' \
'python@3.9' \
'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' \
'wezterm' \
'ngrok' \
'font-hack-nerd-font' \
'whatsapp' \
'telegram' \
'visual-studio-code' \
'github' \
'spotify' \
'prusaslicer' \
'notion' \
'font-monaspace' \
'docker' \
'chatgpt' \
'slack' \
)
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 some node installations.."
exit 1
end
echo ""
echo ""
success "Installation is complete :)"
echo ""
echo ""
exit 0