-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
71 lines (62 loc) · 1.59 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
# frozen_string_literal: true
task "configure:nginx" do
puts "Configuring Nginx..."
base = File.read("./nginx.base.conf")
inject = +""
%w[api test/sonolus sonolus rails admin/sidekiq test].each do |route|
if route.is_a?(Array)
from = route[0]
to = route[1]
else
from = route
to = route
end
inject << <<~NGINX
location /#{from}/ {
proxy_pass http://back/#{to}/;
}
NGINX
end
base.gsub!("# inject", inject.gsub("\n", "\n "))
File.write("./nginx.conf", base)
end
task "configure" do
require "yaml"
require "json"
config_env = {}
def search_env(config_env, content, parents = [])
content.each do |key, value|
if value.is_a?(Hash)
search_env(config_env, value, parents + [key])
else
env_key = (parents + [key]).join("_").upcase
config_env[env_key] = (value.is_a?(String) ? value : JSON.dump(value))
end
end
end
search_env(config_env, YAML.load_file("./config.yml"))
File.write(
".env",
config_env
.map { |key, value| "#{key}=#{value && value.inspect}" }
.join("\n")
)
puts "Built .env"
end
task "install" do
sh "cd backend && bundle install"
sh "cd sub-audio && poetry install"
sh "cd sub-chart && pnpm install"
end
task "format" do
sh "cd frontend && pnpm run lint:fix"
sh "cd backend && bundle exec rubocop -a"
sh "cd sub-audio && poetry run black ."
sh "cd sub-chart && pnpm run lint:fix"
sh "cd sub-image && cargo fmt"
end
task "secret" do
require "securerandom"
secret = SecureRandom.hex(64)
puts %(secret_key_base: "#{secret}")
end