-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
73 lines (60 loc) · 2.04 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
task :boot do
require File.expand_path 'config/boot', __dir__
end
task :sequel do
require File.expand_path 'config/database', __dir__
end
desc 'Start Debugger Console'
task :console => :boot do
# these 3 lines make $rack.get('/') etc available.
require 'racksh/session'
rack_app = Rack::Builder.parse_file('config.ru').first
$rack = Rack::Shell::Session.new(rack_app)
require 'pry'
env_color = (RACK_ENV == 'production' ? "\e[31m\e[1m" : "\e[36m\e[1m")
puts "\nPry #{Pry::VERSION} started in #{env_color}#{RACK_ENV}\e[0m environment\n\n"
Pry.start
end
desc 'Run scss-lint'
task :scss_lint do
require 'scss_lint'
require 'scss_lint/cli'
SCSSLint::CLI.new.run(['app/assets/css/app.scss'])
end
task :browserlist => :boot do
require File.expand_path 'app/app', __dir__
puts AutoprefixerRails.processor(browsers: Nabu::BROWSERLIST).info
end
namespace :db do
desc 'Load the seed data from db/seeds.rb'
task :seed => :boot do
load File.expand_path 'db/seeds.rb', __dir__
end
namespace :migrate do
desc "Perform migration up/down to VERSION"
task :to, [:version] => :sequel do |t, args|
version = (args[:version] || ENV['VERSION']).to_s.strip
raise "No VERSION was provided" if version.empty?
migrate = File.expand_path 'db/migrate', __dir__
::Sequel::Migrator.apply(Sequel::Model.db, migrate, version.to_i)
puts "<= db:migrate:to[#{version}] executed"
end
desc "Perform migration up to latest migration available"
task :up => :sequel do
migrate = File.expand_path 'db/migrate', __dir__
::Sequel::Migrator.run Sequel::Model.db, migrate
puts "<= db:migrate:up executed"
end
desc "Perform migration down (erase all data, DANGEROUS)"
task :down => :sequel do
migrate = File.expand_path 'db/migrate', __dir__
puts "5 seconds to abort this data-destroying operation.."
sleep 5
::Sequel::Migrator.run Sequel::Model.db, migrate, :target => 0
puts "<= db:migrate:down executed"
end
end
desc "Perform migration up to latest migration available"
task :migrate => 'db:migrate:up'
end # }}}
task :seed => 'db:seed'