2011-12-30 04:04:39 +01:00
|
|
|
require 'rubygems' unless defined?(Gem)
|
|
|
|
# require 'fileutils' unless defined?(FileUtils)
|
|
|
|
require 'rake'
|
2011-12-30 04:52:00 +01:00
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__)
|
2011-12-30 04:04:39 +01:00
|
|
|
|
2011-12-30 00:09:51 +01:00
|
|
|
ROOT = File.expand_path(File.dirname(__FILE__))
|
2011-12-30 04:04:39 +01:00
|
|
|
GEM_NAME = 'middleman'
|
2009-10-23 02:25:15 +02:00
|
|
|
|
2014-01-03 01:34:08 +01:00
|
|
|
middleman_gems = %w(middleman-core middleman-cli middleman)
|
2011-12-30 04:52:00 +01:00
|
|
|
GEM_PATHS = middleman_gems.freeze
|
|
|
|
|
|
|
|
def sh_rake(command)
|
|
|
|
sh "#{Gem.ruby} -S rake #{command}", :verbose => true
|
|
|
|
end
|
|
|
|
|
|
|
|
def say(text, color=:magenta)
|
|
|
|
n = { :bold => 1, :red => 31, :green => 32, :yellow => 33, :blue => 34, :magenta => 35 }.fetch(color, 0)
|
|
|
|
puts "\e[%dm%s\e[0m" % [n, text]
|
|
|
|
end
|
2013-10-20 00:59:12 +02:00
|
|
|
|
2011-12-30 04:52:00 +01:00
|
|
|
desc "Run 'install' for all projects"
|
|
|
|
task :install do
|
|
|
|
GEM_PATHS.each do |dir|
|
|
|
|
Dir.chdir(dir) { sh_rake(:install) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Clean pkg and other stuff'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :clean do
|
|
|
|
GEM_PATHS.each do |g|
|
|
|
|
%w[tmp pkg coverage].each { |dir| sh 'rm -rf %s' % File.join(g, dir) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Clean pkg and other stuff'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :uninstall do
|
2013-12-28 01:26:31 +01:00
|
|
|
sh 'gem search --no-version middleman | grep middleman | xargs gem uninstall -a'
|
2011-12-30 04:52:00 +01:00
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Displays the current version'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :version do
|
|
|
|
say "Current version: #{Middleman::VERSION}"
|
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Bumps the version number based on given version'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :bump, [:version] do |t, args|
|
2013-12-28 01:26:31 +01:00
|
|
|
raise 'Please specify version=x.x.x !' unless args.version
|
2011-12-30 04:52:00 +01:00
|
|
|
version_path = File.dirname(__FILE__) + '/middleman-core/lib/middleman-core/version.rb'
|
|
|
|
version_text = File.read(version_path).sub(/VERSION = '[\d\.\w]+'/, "VERSION = '#{args.version}'")
|
|
|
|
say "Updating Middleman to version #{args.version}"
|
|
|
|
File.open(version_path, 'w') { |f| f.write version_text }
|
|
|
|
sh 'git commit -a -m "Bumped version to %s"' % args.version
|
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Executes a fresh install removing all middleman version and then reinstall all gems'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :fresh => [:uninstall, :install, :clean]
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Pushes repository to GitHub'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :push do
|
2013-12-28 01:26:31 +01:00
|
|
|
say 'Pushing to github...'
|
2011-12-30 04:52:00 +01:00
|
|
|
sh "git tag v#{Middleman::VERSION}"
|
2013-12-28 01:26:31 +01:00
|
|
|
sh 'git push origin master'
|
2011-12-30 04:52:00 +01:00
|
|
|
sh "git push origin v#{Middleman::VERSION}"
|
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Release all middleman gems'
|
2011-12-30 04:52:00 +01:00
|
|
|
task :publish => :push do
|
2013-12-28 01:26:31 +01:00
|
|
|
say 'Pushing to rubygems...'
|
2011-12-30 04:52:00 +01:00
|
|
|
GEM_PATHS.each do |dir|
|
2013-12-28 01:26:31 +01:00
|
|
|
Dir.chdir(dir) { sh_rake('release') }
|
2011-12-30 04:52:00 +01:00
|
|
|
end
|
2013-12-28 01:26:31 +01:00
|
|
|
Rake::Task['clean'].invoke
|
2011-12-30 04:52:00 +01:00
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Generate documentation for all middleman gems'
|
2012-05-02 20:13:06 +02:00
|
|
|
task :doc do
|
|
|
|
GEM_PATHS.each do |g|
|
2013-06-07 17:19:47 +02:00
|
|
|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake yard" }
|
2012-05-02 20:13:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Run tests for all middleman gems'
|
2011-12-30 00:09:51 +01:00
|
|
|
task :test do
|
2011-12-30 04:52:00 +01:00
|
|
|
GEM_PATHS.each do |g|
|
2013-06-07 17:19:47 +02:00
|
|
|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" }
|
2011-12-30 00:09:51 +01:00
|
|
|
end
|
2011-12-30 04:04:39 +01:00
|
|
|
end
|
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Run specs for all middleman gems'
|
2013-02-10 00:45:45 +01:00
|
|
|
task :spec do
|
|
|
|
GEM_PATHS.each do |g|
|
2013-06-07 17:19:47 +02:00
|
|
|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake spec" }
|
2013-02-10 00:45:45 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-24 00:59:26 +02:00
|
|
|
begin
|
|
|
|
require 'cane/rake_task'
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Run cane to check quality metrics'
|
2013-05-24 00:59:26 +02:00
|
|
|
Cane::RakeTask.new(:quality) do |cane|
|
|
|
|
cane.no_style = true
|
|
|
|
cane.no_doc = true
|
2013-12-28 01:26:31 +01:00
|
|
|
cane.abc_glob = 'middleman*/lib/middleman*/**/*.rb'
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
end
|
|
|
|
|
|
|
|
begin
|
|
|
|
require 'rubocop/rake_task'
|
|
|
|
desc 'Run RuboCop to check code consistency'
|
|
|
|
Rubocop::RakeTask.new(:rubocop) do |task|
|
|
|
|
task.fail_on_error = false
|
2013-05-24 00:59:26 +02:00
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2012-08-14 00:39:06 +02:00
|
|
|
|
2013-12-28 01:26:31 +01:00
|
|
|
desc 'Run tests for all middleman gems'
|
2013-02-10 00:45:45 +01:00
|
|
|
task :default => :test
|