-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
109 lines (89 loc) · 2.34 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
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
# frozen_string_literal: true
REDMINE_URL = 'http://localhost:3000'
MAILHOG_URL = 'http://localhost:8025'
desc 'Reset the database.'
task :reset do
rails_env = ENV.fetch('RAILS_ENV') do
abort('Env var RAILS_ENV cannot be empty')
end
commands = [
'db:drop',
'db:create',
'db:migrate',
'redmine:plugins:migrate'
]
commands << 'db:seed' if rails_env == 'development'
commands.each do |command|
sh "cd ../.. && RAILS_ENV=#{rails_env} rake #{command}"
end
puts "The env '#{rails_env}' has been reset."
end
desc 'Setup Tracky.'
task :setup do
puts 'Setting up tracky...'
sh 'bin/setup'
Rake::Task[:info].invoke
end
desc 'Dev env info.'
task :info do
puts <<~INFO
USERS
----------------------------------------------------
Login | Email address | Password
----------------------------------------------------
admin | [email protected] | admin
jsmith | [email protected] | jsmith
----------------------------------------------------
URLS
----------------------------------------------------
Redmine | #{REDMINE_URL}/
Redmine Tracky | #{REDMINE_URL}/tracky
Mailhog | #{MAILHOG_URL}/
----------------------------------------------------
INFO
end
desc 'Run code.'
task :run do
sh 'cd ../.. && rails s'
end
desc 'Lint all code.'
task :lint do
Rake::Task['lint_ruby'].execute
Rake::Task['lint_javascript'].execute
end
desc 'Lint Ruby code.'
task :lint_ruby do
sh 'bundle exec rubocop -c .rubocop.yml'
sh 'bundle exec brakeman -q -z --no-summary --no-pager'
end
desc 'Format Ruby code.'
task :format do
sh 'bundle exec rubocop -c .rubocop.yml . -A'
end
desc 'Lint JavaScript code.'
task :lint_javascript do
sh 'cd assets.src && npm run lint'
end
desc 'Test all code.'
task :test do
Rake::Task['test_ruby'].execute
Rake::Task['test_javascript'].execute
end
desc 'Test Ruby code.'
task :test_ruby do
file = ENV.fetch('TEST', nil)
file = "test/#{file}" if file
sh "cd ../.. && RAILS_ENV=test rake test TEST=plugins/redmine_tracky/#{file}"
end
desc 'Test JavaScript code.'
task :test_javascript do
# TODO: sh 'cd assets.src && npm run test'
end
desc 'Compile CSS and JS assets.'
task :build do
sh 'cd assets.src && npm run build'
end
desc 'Watch and compile CSS and JS assets.'
task :watch do
sh 'cd assets.src && npm run watch'
end