-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
106 lines (90 loc) · 2.43 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
require 'json'
require 'pathname'
def get_json(relpath)
JSON.parse(File.read(relpath))
end
def expand(partial_path)
Pathname(partial_path).expand_path
end
def git_pull(dir = Dir.pwd)
Dir.chdir(dir) do
%x{git checkout master}
status = %x{git pull}
puts status unless status =~ /Already up-to-date\./
end
end
namespace :dotfiles do
def symlink_manifest
get_json("./manifest/symlink.json")
end
def contains_dotfiles(path)
path.to_s.match(/dotfiles/)
end
task :create_dotfile_dirs do
symlink_manifest["directories"].each do |dirname|
name = expand dirname
Dir.mkdir name unless Dir.exist? name
end
end
task :symlink_dotfiles => [:create_dotfile_dirs] do
symlink_manifest["dotfiles"].each do |symlink|
dotfile_path = expand(symlink[0])
symlink_path = expand(symlink[1])
if !contains_dotfiles(symlink_path)
if File.symlink?(symlink_path) || File.exists?(symlink_path)
puts "removing :: #{symlink_path}"
system "rm #{symlink_path}"
end
end
puts "symlinking :: #{dotfile_path} -> #{symlink_path}"
system "ln -s #{dotfile_path} #{symlink_path}"
end
end
task :initialize_submodules do
sh "git submodule init"
sh "git submodule update"
end
end
namespace :brew do
task :install_homebrew do
puts "checking for homebrew installation..."
sh "which brew" do |ok|
if ok
puts "homebrew already installed!"
else
puts "installing homebrew..."
sh '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
end
end
puts "done installing homebrew"
end
task :bundle do
sh "brew bundle"
end
task :install => [:install_homebrew, :bundle] do
puts "done installing homebrew and packages!"
end
end
namespace :vim do
task :copy_vim_plug do
sh "curl -fLo \"${XDG_DATA_HOME:-$HOME/.local/share}\"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
end
task :install_packages do
sh "pip3 install --user pynvim"
sh "nvim +PlugInstall +qall"
end
task :update do
sh "nvim +PlugUpdate +qall"
end
task :setup => [:copy_vim_plug, :install_packages] do
puts "Vim setup complete!"
end
end
task vim: ["vim:setup"]
task default: [
"dotfiles:symlink_dotfiles",
"dotfiles:initialize_submodules",
"brew:install",
"vim:setup",
]