Sha256: 30a34de8c9c69d3c7e4e76091da724d52097251e1f7df57968ac5013ccc977da

Contents?: true

Size: 1.43 KB

Versions: 39

Compression:

Stored size: 1.43 KB

Contents

# CLI Module
module Middleman::Cli
  # A thor task for creating new projects
  class Extension < Thor::Group
    include Thor::Actions

    check_unknown_options!

    # Required path for the new project to be generated
    argument :name, type: :string

    # Template files are relative to this file
    # @return [String]
    def self.source_root
      File.join(File.dirname(__FILE__), 'templates')
    end

    class_option 'skip-git',
                 type: :boolean,
                 default: false,
                 desc: 'Skip Git ignores and keeps'

    # Output a .gitignore file
    class_option :git, type: :boolean, default: true

    # The extension task
    # @param [String] name
    def extension
      copy_file 'extension/gitignore', File.join(name, '.gitignore') unless options[:'skip-git']
      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/lib.rb', File.join(name, 'lib', "#{name}.rb")
      template 'extension/lib/lib/extension.rb', File.join(name, 'lib', name, 'extension.rb')
      template 'extension/features/support/env.rb', File.join(name, 'features', 'support', 'env.rb')
      empty_directory File.join(name, 'fixtures')
    end

    # Add to CLI
    Base.register(self, 'extension', 'extension [options]', 'Create a new Middleman extension')
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
middleman-cli-4.5.1 lib/middleman-cli/extension.rb
middleman-cli-4.5.0 lib/middleman-cli/extension.rb
middleman-cli-4.4.3 lib/middleman-cli/extension.rb
middleman-cli-4.4.2 lib/middleman-cli/extension.rb
middleman-cli-4.4.0 lib/middleman-cli/extension.rb
middleman-cli-4.3.11 lib/middleman-cli/extension.rb
middleman-cli-4.3.10 lib/middleman-cli/extension.rb
middleman-cli-4.3.8 lib/middleman-cli/extension.rb
middleman-cli-4.3.7 lib/middleman-cli/extension.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-cli-4.3.3/lib/middleman-cli/extension.rb
middleman-cli-4.3.6 lib/middleman-cli/extension.rb
middleman-cli-4.3.5 lib/middleman-cli/extension.rb
middleman-cli-4.3.4 lib/middleman-cli/extension.rb
middleman-cli-4.3.3 lib/middleman-cli/extension.rb
middleman-cli-4.3.2 lib/middleman-cli/extension.rb
middleman-cli-4.3.1 lib/middleman-cli/extension.rb
middleman-cli-4.3.0 lib/middleman-cli/extension.rb
middleman-cli-4.3.0.rc.4 lib/middleman-cli/extension.rb
middleman-cli-4.3.0.rc.3 lib/middleman-cli/extension.rb
middleman-cli-4.3.0.rc.2 lib/middleman-cli/extension.rb