2011-12-29 22:04:39 -05:00
|
|
|
require 'rubygems' unless defined?(Gem)
|
|
|
|
# require 'fileutils' unless defined?(FileUtils)
|
|
|
|
require 'rake'
|
2011-12-29 22:52:00 -05:00
|
|
|
|
|
|
|
require File.expand_path("../middleman-core/lib/middleman-core/version.rb", __FILE__)
|
2011-12-29 22:04:39 -05:00
|
|
|
|
2011-12-29 18:09:51 -05:00
|
|
|
ROOT = File.expand_path(File.dirname(__FILE__))
|
2011-12-29 22:04:39 -05:00
|
|
|
GEM_NAME = 'middleman'
|
2009-10-22 20:25:15 -04:00
|
|
|
|
2012-01-02 13:41:38 -05:00
|
|
|
middleman_gems = %w(middleman-core middleman-more middleman)
|
2011-12-29 22:52:00 -05: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
|
2011-12-29 22:04:39 -05:00
|
|
|
|
2011-12-29 22:52:00 -05:00
|
|
|
desc "Run 'install' for all projects"
|
|
|
|
task :install do
|
|
|
|
GEM_PATHS.each do |dir|
|
|
|
|
Dir.chdir(dir) { sh_rake(:install) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Clean pkg and other stuff"
|
|
|
|
task :clean do
|
|
|
|
GEM_PATHS.each do |g|
|
|
|
|
%w[tmp pkg coverage].each { |dir| sh 'rm -rf %s' % File.join(g, dir) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Clean pkg and other stuff"
|
|
|
|
task :uninstall do
|
|
|
|
sh "gem search --no-version middleman | grep middleman | xargs gem uninstall -a"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Displays the current version"
|
|
|
|
task :version do
|
|
|
|
say "Current version: #{Middleman::VERSION}"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Bumps the version number based on given version"
|
|
|
|
task :bump, [:version] do |t, args|
|
|
|
|
raise "Please specify version=x.x.x !" unless args.version
|
|
|
|
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
|
|
|
|
|
|
|
|
desc "Executes a fresh install removing all middleman version and then reinstall all gems"
|
|
|
|
task :fresh => [:uninstall, :install, :clean]
|
|
|
|
|
|
|
|
desc "Pushes repository to GitHub"
|
|
|
|
task :push do
|
|
|
|
say "Pushing to github..."
|
|
|
|
sh "git tag v#{Middleman::VERSION}"
|
|
|
|
sh "git push origin master"
|
|
|
|
sh "git push origin v#{Middleman::VERSION}"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Release all middleman gems"
|
|
|
|
task :publish => :push do
|
|
|
|
say "Pushing to rubygems..."
|
|
|
|
GEM_PATHS.each do |dir|
|
|
|
|
Dir.chdir(dir) { sh_rake("release") }
|
|
|
|
end
|
|
|
|
Rake::Task["clean"].invoke
|
|
|
|
end
|
|
|
|
|
2012-05-02 14:13:06 -04:00
|
|
|
desc "Generate documentation for all middleman gems"
|
|
|
|
task :doc do
|
|
|
|
GEM_PATHS.each do |g|
|
|
|
|
sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S rake yard"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-29 22:04:39 -05:00
|
|
|
desc "Run tests for all middleman gems"
|
2011-12-29 18:09:51 -05:00
|
|
|
task :test do
|
2011-12-29 22:52:00 -05:00
|
|
|
GEM_PATHS.each do |g|
|
|
|
|
sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S rake test"
|
2011-12-29 18:09:51 -05:00
|
|
|
end
|
2011-12-29 22:04:39 -05:00
|
|
|
end
|
|
|
|
|
2013-02-09 18:45:45 -05:00
|
|
|
desc "Run specs for all middleman gems"
|
|
|
|
task :spec do
|
|
|
|
GEM_PATHS.each do |g|
|
|
|
|
sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S rake spec"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-15 02:33:16 -05:00
|
|
|
# desc "Rune cane for all middleman gems"
|
|
|
|
# task :cane do
|
|
|
|
# GEM_PATHS.each do |g|
|
|
|
|
# sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S cane"
|
|
|
|
# end
|
|
|
|
# end
|
2012-08-13 18:39:06 -04:00
|
|
|
|
2011-12-29 22:04:39 -05:00
|
|
|
desc "Run tests for all middleman gems"
|
2013-02-09 18:45:45 -05:00
|
|
|
task :default => :test
|