-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
60 lines (51 loc) · 1.8 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
require "peppermint/rake"
task default: :fmt
desc "build npm sub-projects"
task :build_npm do
%w[share-location photo-gallery chikorita freebee].each do |i|
sh "mkdir", "-pv", File.join("dist", i)
sh "bun", "i", "--cwd", File.join(__dir__, i)
sh "bun", "run", "--cwd", File.join(__dir__, i), "build"
end
sh "rsync", "-rv", "--delete", File.join(__dir__, "freebee", "api") + "/", File.join(__dir__, "dist", "freebee", "api") + "/"
end
task :compress do
Dir.glob(File.join(__dir__, "dist") + "**/*") do |path|
next if File.directory?(path)
next if /.*\.(gz|zst)$/.match?(path)
sh "gzip", "-fk", path
sh "zstd", "-fk", path
if File.size(path) <= File.size(path + ".gz")
File.delete(path + ".gz")
end
if File.size(path) <= File.size(path + ".zst")
File.delete(path + ".zst")
end
end
end
desc "build markdown writeups"
task :build_md do
sh "bash", File.join(__dir__, "writeups", "compile")
end
desc "copy static files to dist"
task :cp_static do
sh "rsync", "-rv", File.join(__dir__, "static") + "/", File.join(__dir__, "dist") + "/"
end
desc "build project to ./dist"
task build: %i[build_npm build_md cp_static compress]
desc "deploy the static web server (dry run)"
task :deploy_test do
ENV["ANSIBLE_CONFIG"] = File.join(__dir__, "ansible", "ansible.cfg")
sh "ansible-playbook", "--ask-vault-pass", "--diff", "--check", "-v",
File.join(__dir__, "ansible", "playbooks", "deploy.json")
end
desc "deploy the static web server"
task deploy: :build do
ENV["ANSIBLE_CONFIG"] = File.join(__dir__, "ansible", "ansible.cfg")
sh "ansible-playbook", "--ask-vault-pass",
File.join(__dir__, "ansible", "playbooks", "deploy.json")
end
desc "run the development web server"
task :dev do
sh "python3", "-m", "http.server", "-d", File.join(__dir__, "dist"), "50000"
end