clarion/lib/tasks/bootstrap.rake
2014-07-28 13:17:48 +03:00

35 lines
1.0 KiB
Ruby

require 'fileutils'
require 'yaml'
require 'securerandom'
namespace :bootstrap do
desc 'Copy over initial db config'
task :db_config do
example_config_file = File.join(Rails.root, 'config', 'database.yml.example')
new_config_file = File.join(Rails.root, 'config', 'database.yml')
FileUtils.cp example_config_file, new_config_file
end
desc 'Generate new secret tokens'
task :secret_tokens do
secret_tokens_file = File.join Rails.root, 'config', 'secrets.yml'
secrets = {
'development' => {'secret_key_base' => SecureRandom.hex(64)},
'test' => {'secret_key_base' => SecureRandom.hex(64)},
'production' => {'secret_key_base' => '<%= ENV["SECRET_KEY_BASE"] %>'}
}
File.open(secret_tokens_file, 'w') do |f|
f.puts secrets.to_yaml
end
end
end
desc 'Perform initial setup of the application'
task bootstrap: ['bootstrap:secret_tokens',
'bootstrap:db_config',
'db:create',
'db:migrate',
'db:test:prepare']