-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRakefile
More file actions
124 lines (108 loc) · 2.39 KB
/
Rakefile
File metadata and controls
124 lines (108 loc) · 2.39 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
# frozen_string_literal: true
HOME = ENV['HOME']
CWD = File.dirname __FILE__
BLACKLIST = %w[README.markdown Rakefile LICENSE bin].freeze
DOTFILES = FileList['*'] - BLACKLIST
XDG_ENTRIES = %w[
codebook
fish
fuzzel
fontconfig
foot
fzfrc
nvim
git
alacritty
rubocop
pacman
zathura
bat
pip
pylintrc
sequoia
uv
xh
yamllint
jj
].freeze
def xdg_target(name)
XDG_ENTRIES.include?(name) ? "#{HOME}/.config/#{name}" : nil
end
def regular_dotfile(name)
"#{HOME}/.#{name}"
end
def target_for(source)
xdg_target(source) or regular_dotfile(source)
end
def tildify_path(path)
path.sub(HOME, '~')
end
DOTFILES.each do |f|
desc "Install #{tildify_path(target_for(f))} by symlinking"
task f do |t|
source = "#{CWD}/#{t.name}"
target = target_for(t.name)
File.symlink source, target unless File.exist? target
end
end
task bashrc: :commonshrc
task commonshrc: :commonenv
desc 'Take a dotfile from $HOME'
task :take, :dotless_name do |_, args|
dotless = args[:dotless_name]
filename = ".#{dotless}"
full_path = "#{HOME}/#{filename}"
next unless File.exist? full_path
if File.symlink? full_path
puts "#{full_path} is a symlink, not taken."
next
end
mv full_path, dotless
end
NODE_PKGS = %w[
browser-sync
eslint
serve
eslint-config-airbnb
eslint-config-prettier
eslint-plugin-import
eslint-plugin-jsx-a11y
eslint-plugin-react
eslint-import-resolver-babel-plugin-root-import
import-js
javascript-typescript-langserver
neovim
].freeze
desc 'Install essential NodeJS packages'
task :npm do
sh(*%w[npm i -g wrangler])
end
desc 'Install every bin/* into ~/.local/bin'
task :bin do
FileList['bin/*'].each do |f|
ln f, "#{HOME}/.local/bin"
rescue Errno::EEXIST
puts "#{HOME}/.local/#{f} already exists" if verbose == true
else
true
end
end
desc 'Link a ~/.local/bin/<file> to ./bin'
task :lnbin, :fn do |_, args|
fn = args[:fn]
begin
ln "#{CWD}/bin/#{fn}", "#{HOME}/.local/bin/"
rescue Errno::EEXIST
puts "#{HOME}/.local/#{fn} already exists" if verbose == true
end
end
desc 'Update Neovim Plugins (probably needs https_proxy)'
task :update_nvim do
sh 'nvim', '--headless', \
"+lua vim.pack.update(nil, { target = 'lockfile', force = true })", \
"+lua require('nvim-treesitter').update():wait(600000)", \
'+qa'
end
desc 'Install everything'
task everything: DOTFILES + [:bin]
task default: :everything