Init generator on Thor
This commit is contained in:
parent
c6b0723156
commit
260b7c9f1b
2
Rakefile
2
Rakefile
|
@ -7,4 +7,4 @@ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
|||
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
||||
end
|
||||
|
||||
task :default => :cucumber
|
||||
task :test => :cucumber
|
||||
|
|
45
bin/mm-init
45
bin/mm-init
|
@ -1,37 +1,30 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'middleman')
|
||||
require 'templater'
|
||||
require "thor"
|
||||
require "thor/group"
|
||||
|
||||
module Generators
|
||||
extend Templater::Manifold
|
||||
desc "Generator for streamlining staticmatic"
|
||||
|
||||
class NewSite < Templater::Generator
|
||||
desc "Creates a new middleman scaffold."
|
||||
first_argument :location, :required => true, :desc => "Project location"
|
||||
|
||||
option :css_dir, :desc => 'The path to the css files'
|
||||
option :js_dir, :desc => 'The path to the javascript files'
|
||||
option :images_dir, :desc => 'The path to the image files'
|
||||
|
||||
def destination_root
|
||||
File.expand_path(location)
|
||||
end
|
||||
module Middleman
|
||||
class Generator < ::Thor::Group
|
||||
include Thor::Actions
|
||||
|
||||
def self.source_root
|
||||
File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'template')
|
||||
end
|
||||
|
||||
template :config, "config.rb"
|
||||
glob! :views
|
||||
glob! :public
|
||||
argument :location, :type => :string, :desc => "New project location"
|
||||
|
||||
empty_directory :stylesheets, "public/stylesheets"#, File.join("public", css_dir)
|
||||
empty_directory :javascripts, "public/javascripts"#, File.join("public", js_dir)
|
||||
empty_directory :images, "public/images"#, File.join("public", images_dir)
|
||||
class_option :css_dir, :default => "stylesheets", :desc => 'The path to the css files'
|
||||
class_option :js_dir, :default => "javascripts", :desc => 'The path to the javascript files'
|
||||
class_option :images_dir, :default => "images", :desc => 'The path to the image files'
|
||||
|
||||
def create_project
|
||||
template "config.tt", File.join(location, "config.rb")
|
||||
directory "views", File.join(location, "views")
|
||||
empty_directory File.join(location, "public", options[:css_dir])
|
||||
empty_directory File.join(location, "public", options[:js_dir])
|
||||
empty_directory File.join(location, "public", options[:images_dir])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add :setup, NewSite
|
||||
end
|
||||
|
||||
Generators.run_cli(Dir.pwd, 'mm-init', 1, %w(setup).concat(ARGV))
|
||||
Middleman::Generator.start
|
|
@ -20,26 +20,26 @@ helpers do
|
|||
end
|
||||
end
|
||||
|
||||
<% if css_dir %>
|
||||
set :css_dir, "<%= css_dir -%>"
|
||||
<% else %>
|
||||
<% if options[:css_dir] != "stylesheets" -%>
|
||||
set :css_dir, "<%= options[:css_dir] -%>"
|
||||
<% else -%>
|
||||
# Change the CSS directory
|
||||
# set :css_dir, "alternative_css_directory"
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
<% if js_dir %>
|
||||
set :js_dir, "<%= js_dir -%>"
|
||||
<% else %>
|
||||
<% if options[:js_dir] != "javascripts" -%>
|
||||
set :js_dir, "<%= options[:js_dir] -%>"
|
||||
<% else -%>
|
||||
# Change the JS directory
|
||||
# set :js_dir, "alternative_js_directory"
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
<% if images_dir %>
|
||||
set :images_dir, "<%= images_dir -%>"
|
||||
<% else %>
|
||||
<% if options[:images_dir] != "images" -%>
|
||||
set :images_dir, "<%= options[:images_dir] -%>"
|
||||
<% else -%>
|
||||
# Change the images directory
|
||||
# set :images_dir, "alternative_image_directory"
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
# Build-specific configuration
|
||||
configure :build do
|
|
@ -22,22 +22,22 @@ Gem::Specification.new do |s|
|
|||
s.add_runtime_dependency("thin", ["~> 1.2.0"])
|
||||
s.add_runtime_dependency("shotgun", ["~> 0.8.0"])
|
||||
s.add_runtime_dependency("thor", ["~> 0.14.0"])
|
||||
s.add_runtime_dependency("tilt", ["~> 1.1"])
|
||||
s.add_runtime_dependency("sinatra", ["~> 1.0"])
|
||||
s.add_runtime_dependency("tilt", ["~> 1.2.0"])
|
||||
s.add_runtime_dependency("sinatra", ["~> 1.1.0"])
|
||||
s.add_runtime_dependency("padrino-core", ["~> 0.9.0"])
|
||||
s.add_runtime_dependency("padrino-helpers", ["~> 0.9.0"])
|
||||
s.add_runtime_dependency("rack-test", ["~> 0.5.0"])
|
||||
s.add_runtime_dependency("yui-compressor", ["~> 0.9.0"])
|
||||
s.add_runtime_dependency("haml", ["~> 3.0"])
|
||||
s.add_runtime_dependency("sass", ["3.1.0.alpha.218"])
|
||||
s.add_runtime_dependency("compass", ["0.11.beta.1"])
|
||||
s.add_runtime_dependency("oily_png")
|
||||
s.add_runtime_dependency("haml", [">= 3.1.0.alpha.147"])
|
||||
s.add_runtime_dependency("sass", [">= 3.1.0.alpha.218"])
|
||||
s.add_runtime_dependency("compass", ["0.11.beta.2"])
|
||||
s.add_runtime_dependency("oily_png", ["~> 0.3.0"])
|
||||
s.add_runtime_dependency("json_pure", ["~> 1.4.0"])
|
||||
s.add_runtime_dependency("smusher", ["~> 0.4.5"])
|
||||
s.add_runtime_dependency("compass-slickmap", ["~> 0.4.0"])
|
||||
s.add_runtime_dependency("coffee-script", ["~> 2.1.0"])
|
||||
s.add_runtime_dependency("less", ["~> 1.2.0"])
|
||||
s.add_development_dependency("cucumber", [">= 0"])
|
||||
s.add_development_dependency("cucumber", ["~> 0.10.0"])
|
||||
s.add_development_dependency("rspec", [">= 0"])
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue