update some deps
This commit is contained in:
commit
a769ddec2f
|
@ -1,3 +1,7 @@
|
|||
2.0.13
|
||||
====
|
||||
middleman build --clean keeps the build directory clean of leftover files
|
||||
|
||||
2.0.12
|
||||
====
|
||||
Sinatra 1.3.1 and Padrino 0.10.4
|
||||
|
|
10
features/clean_build.feature
Normal file
10
features/clean_build.feature
Normal file
|
@ -0,0 +1,10 @@
|
|||
Feature: Build Clean
|
||||
Scenario: Build and Clean an app
|
||||
Given app "clean-app" is using config "empty"
|
||||
And a built app at "clean-app"
|
||||
And app "clean-app" is using config "complications"
|
||||
And a built app at "clean-app" with flags "--clean"
|
||||
Then "should_be_ignored.html" should not exist at "clean-app"
|
||||
And "should_be_ignored2.html" should not exist at "clean-app"
|
||||
And "should_be_ignored3.html" should not exist at "clean-app"
|
||||
And cleanup built app at "clean-app"
|
|
@ -1,5 +1,13 @@
|
|||
require 'fileutils'
|
||||
|
||||
Given /^app "([^"]*)" is using config "([^"]*)"$/ do |path, config_name|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path)
|
||||
config_path = File.join(target, "config-#{config_name}.rb")
|
||||
config_dest = File.join(target, "config.rb")
|
||||
FileUtils.cp(config_path, config_dest)
|
||||
end
|
||||
|
||||
Given /^a built app at "([^"]*)"$/ do |path|
|
||||
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
target = File.join(root, "fixtures", path)
|
||||
|
|
11
fixtures/clean-app/config-complications.rb
Normal file
11
fixtures/clean-app/config-complications.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
page "/fake.html", :proxy => "/real.html", :layout => false
|
||||
|
||||
ignore "/should_be_ignored.html"
|
||||
page "/should_be_ignored2.html", :ignore => true
|
||||
page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true
|
||||
|
||||
%w(one two).each do |num|
|
||||
page "/fake/#{num}.html", :proxy => "/real/index.html" do
|
||||
@num = num
|
||||
end
|
||||
end
|
0
fixtures/clean-app/config-empty.rb
Normal file
0
fixtures/clean-app/config-empty.rb
Normal file
11
fixtures/clean-app/config.rb
Normal file
11
fixtures/clean-app/config.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
page "/fake.html", :proxy => "/real.html", :layout => false
|
||||
|
||||
ignore "/should_be_ignored.html"
|
||||
page "/should_be_ignored2.html", :ignore => true
|
||||
page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true
|
||||
|
||||
%w(one two).each do |num|
|
||||
page "/fake/#{num}.html", :proxy => "/real/index.html" do
|
||||
@num = num
|
||||
end
|
||||
end
|
6
fixtures/clean-app/source/index.html.haml
Executable file
6
fixtures/clean-app/source/index.html.haml
Executable file
|
@ -0,0 +1,6 @@
|
|||
%h1 Welcome
|
||||
|
||||
:markdown
|
||||
## H2
|
||||
|
||||
Paragraph
|
6
fixtures/clean-app/source/layout.haml
Normal file
6
fixtures/clean-app/source/layout.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
%html
|
||||
%head
|
||||
%title My Sample Site
|
||||
/ Comment in layout
|
||||
%body
|
||||
= yield
|
5
fixtures/clean-app/source/layouts/custom.haml
Executable file
5
fixtures/clean-app/source/layouts/custom.haml
Executable file
|
@ -0,0 +1,5 @@
|
|||
%html
|
||||
%head
|
||||
%title Custom Layout
|
||||
%body
|
||||
= yield
|
1
fixtures/clean-app/source/real.html
Normal file
1
fixtures/clean-app/source/real.html
Normal file
|
@ -0,0 +1 @@
|
|||
I am real
|
5
fixtures/clean-app/source/real/index.html.erb
Normal file
5
fixtures/clean-app/source/real/index.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
layout: false
|
||||
---
|
||||
|
||||
I am real: <%= @num %>
|
1
fixtures/clean-app/source/should_be_ignored.html
Normal file
1
fixtures/clean-app/source/should_be_ignored.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Ignore me!</h1>
|
1
fixtures/clean-app/source/should_be_ignored2.html
Normal file
1
fixtures/clean-app/source/should_be_ignored2.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Ignore me! 2</h1>
|
1
fixtures/clean-app/source/should_be_ignored3.html
Normal file
1
fixtures/clean-app/source/should_be_ignored3.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Ignore me! 3</h1>
|
1
fixtures/clean-app/source/static.html
Executable file
1
fixtures/clean-app/source/static.html
Executable file
|
@ -0,0 +1 @@
|
|||
Static, no code!
|
|
@ -1,6 +1,7 @@
|
|||
require "thor"
|
||||
require "thor/group"
|
||||
require 'rack/test'
|
||||
require 'find'
|
||||
|
||||
SHARED_SERVER = Middleman.server
|
||||
SHARED_SERVER.set :environment, :build
|
||||
|
@ -22,12 +23,61 @@ module Middleman
|
|||
request_path.gsub!(/\s/, "%20")
|
||||
response = Middleman::Builder.shared_rack.get(request_path)
|
||||
|
||||
dequeue_file_from destination if cleaning?
|
||||
|
||||
create_file destination, nil, config do
|
||||
response.body
|
||||
end if response.status == 200
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def clean!(destination)
|
||||
return unless cleaning?
|
||||
queue_current_paths_from destination
|
||||
add_clean_up_callback
|
||||
end
|
||||
|
||||
def cleaning?
|
||||
options.has_key?("clean") && options["clean"]
|
||||
end
|
||||
|
||||
def add_clean_up_callback
|
||||
clean_up_callback = lambda do
|
||||
files = @cleaning_queue.select { |q| File.file? q }
|
||||
directories = @cleaning_queue.select { |q| File.directory? q }
|
||||
|
||||
files.each { |f| remove_file f, :force => true }
|
||||
|
||||
directories = directories.sort_by {|d| d.length }.reverse!
|
||||
|
||||
directories.each do |d|
|
||||
remove_file d, :force => true if directory_empty? d
|
||||
end
|
||||
end
|
||||
self.class.after_run :clean_up_callback do
|
||||
clean_up_callback.call
|
||||
end
|
||||
end
|
||||
|
||||
def directory_empty?(directory)
|
||||
Dir["#{directory}/*"].empty?
|
||||
end
|
||||
|
||||
def queue_current_paths_from(destination)
|
||||
@cleaning_queue = []
|
||||
Find.find(destination) do |path|
|
||||
unless path == destination
|
||||
@cleaning_queue << path.sub(destination, destination[/([^\/]+?)$/])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def dequeue_file_from(destination)
|
||||
@cleaning_queue.delete_if {|q| q == destination }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Builder < Thor::Group
|
||||
|
@ -102,6 +152,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def invoke!
|
||||
base.clean! destination
|
||||
execute!
|
||||
end
|
||||
|
||||
|
@ -198,5 +249,6 @@ module Middleman
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -58,6 +58,7 @@ module Middleman
|
|||
|
||||
desc "build", "Builds the static site for deployment"
|
||||
method_option :relative, :type => :boolean, :aliases => "-r", :default => false, :desc => 'Override the config.rb file and force relative urls'
|
||||
method_option :clean, :type => :boolean, :aliases => "-c", :default => false, :desc => 'Builds a clean project removing any orpahand files or directories'
|
||||
method_option :glob, :type => :string, :aliases => "-g", :default => nil, :desc => 'Build a subset of the project'
|
||||
def build
|
||||
v1_check
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Middleman
|
||||
VERSION = "2.0.12"
|
||||
VERSION = "2.0.13"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue