-
Notifications
You must be signed in to change notification settings - Fork 8
/
Rakefile
executable file
·49 lines (39 loc) · 1.53 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
#!/usr/bin/env rake
# Load demo application environment.
#
require File.expand_path('../demo_app/my_platform/config/application', __FILE__)
# Do not load the application tasks for the moment, which would
# invoke test:prepare, which has been dropped.
#
# # MyPlatform::Application.load_tasks
task :tests => [:prepare_tests] do
sh "bundle exec rspec spec/models"
end
task test: :tests
task default: :tests
task :prepare_tests do
sh "bundle install"
sh "cd demo_app/my_platform && bundle install && bundle exec rails db:create db:migrate"
sh "cd demo_app/my_platform && bundle exec rake your_platform:install:node_modules || echo 'task not found'"
sh "cd demo_app/my_platform && bin/rails assets:precompile"
end
# Version bumping mechanism.
# See: https://gist.github.com/grosser/1261469
#
# - rake version:bump:major
# - rake version:bump:minor
# - rake version:bump:patch
#
rule /^version:bump:.*/ do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(t.name.split(':').last)
file = 'lib/your_platform/version.rb'
version_file = File.read(file)
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
version_parts[index] = version_parts[index].to_i + 1
version_parts[2] = 0 if index < 2
version_parts[1] = 0 if index < 1
new_version = version_parts * '.'
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}.'"
end