-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
82 lines (66 loc) · 1.67 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
module Tools
def mise_exec_prefix
'mise exec --'
end
def ci_mode?
ENV['CI'] == 'true'
end
def ci_debug_mode?
ENV['RUNNER_DEBUG'] == '1' || ENV['ACTIONS_RUNNER_DEBUG'] == 'true'
end
end
# Reference other rake files to avoid adding the -f parameter when executing the rake command
FileList['**/*.rb'].each { |rf| require_relative rf }
namespace :env do
include Tools
desc 'Init env'
task :init do
if File.exist?('.mise.toml')
install_mise
puts "mise installed: #{`mise --version`}"
sh "mise install"
end
if File.exist?('.pre-commit-config.yaml')
Rake::Task['env:githook'].invoke
end
end
desc 'Install git hook'
task :githook do
sh "#{mise_exec_prefix} pre-commit install"
end
def install_mise
output = `which mise >/dev/null 2>&1`
if $?.success?
return
end
puts "mise not found, installing..."
sh "curl https://mise.run | sh"
case ENV['SHELL']
when /bash/
sh 'echo "eval \"\$(~/.local/bin/mise activate bash)\"" >> ~/.bashrc'
sh "source ~/.bashrc"
when /zsh/
sh 'echo "eval \"\$(~/.local/bin/mise activate zsh)\"" >> ~/.zshrc'
sh "zsh -c 'source ~/.zshrc'"
else
puts "Unknown shell env!"
exit 1
end
end
end
namespace :swift do
FORMAT_COMMAND = 'swift package --allow-writing-to-package-directory format'
BUILD_COMMAND = 'xcodebuild -scheme RakuyoKit -destination'
desc 'Run Format'
task :format do
sh FORMAT_COMMAND
end
desc 'Run Lint'
task :lint do
sh FORMAT_COMMAND + ' --lint'
end
desc 'Build'
task :build do
sh BUILD_COMMAND + " 'platform=iOS Simulator,OS=17.4,name=iPhone 15 Pro'"
end
end