Skip to content

Commit 70da540

Browse files
committed
feat: Add Rakefile
1 parent 479d38c commit 70da540

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Rakefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
namespace :env do
2+
MISE_EXEC_PREFIX = 'mise exec --'
3+
4+
desc 'Init env'
5+
task :init do
6+
if File.exist?('.mise.toml')
7+
install_mise
8+
puts "mise installed: #{`mise --version`}"
9+
sh "mise install"
10+
end
11+
12+
if File.exist?('.pre-commit-config.yaml')
13+
Rake::Task['env:githook'].invoke
14+
end
15+
end
16+
17+
desc 'Install git hook'
18+
task :githook do
19+
sh "#{MISE_EXEC_PREFIX} pre-commit install"
20+
end
21+
22+
def install_mise
23+
output = `which mise >/dev/null 2>&1`
24+
if $?.success?
25+
return
26+
end
27+
28+
puts "mise not found, installing..."
29+
sh "curl https://mise.run | sh"
30+
31+
case ENV['SHELL']
32+
when /bash/
33+
sh 'echo "eval \"\$(~/.local/bin/mise activate bash)\"" >> ~/.bashrc'
34+
sh "source ~/.bashrc"
35+
36+
when /zsh/
37+
sh 'echo "eval \"\$(~/.local/bin/mise activate zsh)\"" >> ~/.zshrc'
38+
sh "zsh -c 'source ~/.zshrc'"
39+
40+
else
41+
puts "Unknown shell env!"
42+
exit 1
43+
end
44+
end
45+
end
46+
47+
namespace :swift do
48+
FORMAT_COMMAND = 'swift package --allow-writing-to-package-directory format'
49+
TEST_COMMAND = 'xcodebuild -scheme RakuyoKit -destination'
50+
51+
desc 'Run Format'
52+
task :format do
53+
sh FORMAT_COMMAND
54+
end
55+
56+
desc 'Run Lint'
57+
task :lint do
58+
sh FORMAT_COMMAND + ' --lint'
59+
end
60+
61+
desc 'Test'
62+
task :test do
63+
sh TEST_COMMAND + " 'platform=iOS Simulator,OS=17.4,name=iPhone 15 Pro'"
64+
end
65+
end

0 commit comments

Comments
 (0)