-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
271 lines (216 loc) · 7.26 KB
/
Rakefile
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
require_relative 'installer.rb'
require_relative 'linker.rb'
require_relative 'logger.rb'
logger = Logger.new
installer = Installer.new
linker = Linker.new
oh_my_zsh_install_command = 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"'
homebrew_install_command = '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
def lines_from_file(file)
return File::readlines(file).map { |line| line.chomp } # We want to remove the "\n"
end
yarn_packages = lines_from_file('./definitions/yarn_packages')
cargo_packages = lines_from_file('./definitions/cargo_packages')
namespace :install do
desc 'Start step'
task :start do
logger.vizion_started '1.0.0'
end
desc 'Install command line developer tools, Oh My Zshell, Brew'
task :base do
logger.step 'Base', 'Installing oh-my-zsh and brew'
_, stderr, status = installer.sh 'ls -a ~ | grep .oh-my-zsh'
if status.success?
logger.oh_my_zsh_skipped
else
_, stderr, status = installer.sh oh_my_zsh_install_command
if status.success?
installer.shell 'echo "source ~/.zshrc.aliases" >> ~/.zshrc', true
logger.oh_my_zsh_installed
else
logger.oh_my_zsh_not_installed
end
end
end
desc 'Install brew packages'
task :brew_packages do
installer.shell 'brew bundle install', true
logger.write "Brew packages installed"
end
desc 'Install Yarn global packages'
task :yarn_packages do
logger.step 'Yarn', 'Installing Yarn global packages'
stdout, _, status = installer.sh 'yarn global upgrade'
if status.success?
logger.yarn_package_installed 'packages' # hack
else
logger.yarn_package_not_installed 'packages' # hack
end
end
desc 'Install Cargo global packages'
task :cargo_packages do
cargo_packages.each do |package|
installer.sh "cargo install #{package} --quiet"
end
logger.write "Installed Cargo packages"
end
desc 'Install Tmux Plugin Manager'
task :tmux_plugin_manager do
logger.step 'TPM', 'Installing Tmux Plugin Manager'
_, _, status = installer.sh 'ls ~/.config/tmux/plugins/tpm'
if status.success?
logger.tmux_plugin_manager_skipped
else
installer.shell('git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm')
logger.tmux_plugin_manager_installed
end
end
desc 'Install Tmux plugins'
task :tmux_plugins do
logger.step 'Tmux Plugins', 'Installing Tmux plugins'
installer.sh '~/.config/tmux/plugins/tpm/bin/install_plugins'
logger.tmux_plugins_installed
end
desc 'Install nvim plugs'
task :nvim_plugs do
logger.step 'nvim plugs', 'Installing nvim plugs'
installer.sh 'nvim --headless +PlugInstall +qall'
logger.nvim_plugs_installed
end
desc 'Install nvim providers'
task :nvim_providers do
logger.step 'nvim providers', 'Installing nvim providers'
installer.sh './scripts/install_nvim_providers.sh'
end
desc 'Link dotfiles'
task :dotfiles do
logger.step 'Dotfiles', 'Linking dotfiles to the home folder'
projectDir = File.dirname(__FILE__)
dotfiles = Dir.entries('./dotfiles').select {|f| !File.directory? f}
logger.dotfile_count dotfiles.count
dotfiles.each do |dotfile|
if linker.link("#{projectDir}/dotfiles/#{dotfile}", "#{Dir.home}/#{dotfile}")
logger.dotfile_linked dotfile
else
logger.dotfile_not_linked dotfile
end
end
end
desc 'Link directories'
task :directories do
logger.step 'Directories', 'Linking directories to the home folder'
projectDir = File.dirname(__FILE__)
directories = Dir.entries('./directories').select {|f| !(f =='.' || f == '..')}
logger.directory_count directories.count
directories.each do |directory|
if linker.link("#{projectDir}/directories/#{directory}", "#{Dir.home}/#{directory}")
logger.directory_linked directory
else
logger.directory_not_linked directory
end
end
end
desc 'Link oh-my-zsh Themes'
task :oh_my_zsh_themes do
logger.step 'oh-my-zsh', 'Linking oh-my-zsh themes'
themesDir = "#{Dir.home}/.oh-my-zsh/custom/themes"
themes = Dir.glob 'oh-my-zsh-themes/**/*.zsh-theme', File::FNM_DOTMATCH
FileUtils.mkdir_p themesDir
logger.oh_my_zsh_theme_count themes.count
themes.each do |themePath|
theme = File.basename(themePath)
if linker.link "#{Dir.pwd}/#{themePath}", "#{themesDir}/#{theme}"
logger.oh_my_zsh_theme_linked theme
else
logger.oh_my_zsh_theme_not_linked theme
end
end
end
desc 'Sets up iTerm2 profile'
task :iterm2_profile do
logger.step 'iTerm2', 'Setting iTerm2 profile'
installer.sh 'defaults write com.googlecode.iterm2.plist NoSyncNeverRemindPrefsChangesLostForFile_selection -int 0'
installer.sh 'defaults write com.googlecode.iterm2.plist LoadPrefsFromCustomFolder -bool true'
installer.sh 'defaults write com.googlecode.iterm2.plist PrefsCustomFolder -string "~/.iterm2"'
logger.iterm2_configured
end
desc 'Set up visuals'
task :visuals do
logger.step 'Visuals', 'Setting up visuals'
installer.sh 'tic -x ~/.iterm2/files/xterm-256color-italic.terminfo'
installer.sh 'tic -x ~/.iterm2/files/tmux-256color.terminfo'
logger.true_colors_and_italics_configured
end
desc 'Grip settings'
task :grip_settings do
installer.shell './scripts/setup_grip.sh', false
logger.write "Grip settings configured"
end
desc 'Gitconfig setup'
task :gitconfig_setup do
installer.shell './scripts/setup_gitconfig.sh local', true
logger.write "Gitconfig configured"
end
desc 'Setup github tokens and rhubarb'
task :github_tokens_and_rhubarb do
installer.shell './scripts/setup_tokens.sh', false
installer.shell './scripts/setup_rhubarb.sh', false
logger.write "Gitconfig local configured"
end
desc 'Setup SSH keys'
task :setup_ssh_keys do
installer.shell './scripts/setup_ssh_keys.sh', true
logger.write "SSH keys configured"
end
desc 'End step'
task :end do
logger.blank_line
logger.vizion_ended
end
task :all => [
:start,
:base,
# These 2 need to be installed before anything else so that config dirs are not altered
:dotfiles,
:directories,
:brew_packages,
:yarn_packages,
:cargo_packages,
:oh_my_zsh_themes,
:tmux_plugin_manager,
:tmux_plugins,
:nvim_plugs,
:nvim_providers,
:iterm2_profile,
:visuals,
:grip_settings,
:gitconfig_setup,
:github_tokens_and_rhubarb,
:setup_ssh_keys,
:end
]
end
namespace :uninstall do
desc 'dotfiles'
task :dotfiles do
logger.write('Unlinking dotfiles')
dotfiles = Dir.entries('./dotfiles').select {|f| !File.directory? f}
dotfiles.each do |filename|
unless linker.unlink("#{Dir.home}/#{filename}")
logger.write("Unable to link #{filename}, it doesn't exist.")
end
end
end
desc 'directories'
task :directories do
logger.write('Unlinking directories')
directories = Dir.children('./directories')
directories.each do |dirname|
unless linker.unlink("#{Dir.home}/#{dirname}")
logger.write("Unable to unlink #{dirname}, it doesn't exist.")
end
end
end
end
task :default => 'install:all'
task :test => 'test:all'