2012-05-02 15:59:36 -07:00
|
|
|
# CLI Module
|
|
|
|
module Middleman::Cli
|
2012-08-13 15:39:06 -07:00
|
|
|
|
2012-05-02 15:59:36 -07:00
|
|
|
# A thor task for creating new projects
|
|
|
|
class Extension < Thor
|
|
|
|
include Thor::Actions
|
2012-08-13 15:39:06 -07:00
|
|
|
|
2012-05-02 15:59:36 -07:00
|
|
|
check_unknown_options!
|
2012-08-13 15:39:06 -07:00
|
|
|
|
2012-05-02 15:59:36 -07:00
|
|
|
namespace :extension
|
2012-08-13 15:39:06 -07:00
|
|
|
|
2012-05-02 15:59:36 -07:00
|
|
|
# Required path for the new project to be generated
|
|
|
|
argument :name, :type => :string
|
2013-12-28 18:14:15 +00:00
|
|
|
|
2012-08-20 19:37:10 -07:00
|
|
|
# Template files are relative to this file
|
|
|
|
# @return [String]
|
|
|
|
def self.source_root
|
2014-01-02 16:34:08 -08:00
|
|
|
File.join(File.dirname(__FILE__), 'templates')
|
2012-08-20 19:37:10 -07:00
|
|
|
end
|
2013-12-28 18:14:15 +00:00
|
|
|
|
2013-12-28 00:26:31 +00:00
|
|
|
desc 'extension [options]', 'Create Middleman extension scaffold NAME'
|
2014-01-02 16:34:08 -08:00
|
|
|
method_option 'skip-git',
|
|
|
|
:type => :boolean,
|
|
|
|
:default => false,
|
|
|
|
:desc => 'Skip Git ignores and keeps'
|
2012-08-13 15:39:06 -07:00
|
|
|
|
2012-05-02 15:59:36 -07:00
|
|
|
# The extension task
|
|
|
|
# @param [String] name
|
|
|
|
def extension
|
2014-03-11 11:08:41 +00:00
|
|
|
copy_file 'extension/gitignore', File.join(name, '.gitignore') unless options[:'skip-git']
|
2014-01-02 16:34:08 -08:00
|
|
|
template 'extension/Rakefile', File.join(name, 'Rakefile')
|
|
|
|
template 'extension/gemspec', File.join(name, "#{name}.gemspec")
|
|
|
|
template 'extension/Gemfile', File.join(name, 'Gemfile')
|
|
|
|
template 'extension/lib/middleman_extension.rb', File.join(name, 'lib', 'middleman_extension.rb')
|
|
|
|
template 'extension/lib/lib.rb', File.join(name, 'lib', "#{name}.rb")
|
|
|
|
template 'extension/features/support/env.rb', File.join(name, 'features', 'support', 'env.rb')
|
2013-12-28 00:26:31 +00:00
|
|
|
empty_directory File.join(name, 'fixtures')
|
2012-05-02 15:59:36 -07:00
|
|
|
end
|
2012-08-13 15:39:06 -07:00
|
|
|
|
2012-08-20 19:37:10 -07:00
|
|
|
# Output a .gitignore file
|
|
|
|
class_option :git, :type => :boolean, :default => true
|
|
|
|
|
2012-05-02 15:59:36 -07:00
|
|
|
end
|
|
|
|
end
|