1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Bundler CLI commands

This commit is contained in:
Thomas Reynolds 2012-05-10 14:47:29 -07:00
parent 7c8baee246
commit 190be5f515
4 changed files with 42 additions and 15 deletions

View file

@ -37,16 +37,6 @@ Feature: Middleman CLI
| config.ru | | config.ru |
| Gemfile | | Gemfile |
Scenario: Create a new project without Bundler
When I run `middleman init MY_PROJECT --no-bundler`
Then a directory named "MY_PROJECT" should exist
When I cd to "MY_PROJECT"
Then the following files should exist:
| config.rb |
Then the following files should not exist:
| Gemfile |
| config.ru |
Scenario: Create a new HTML5 project Scenario: Create a new HTML5 project
When I run `middleman init MY_PROJECT --template=html5` When I run `middleman init MY_PROJECT --template=html5`
Then a directory named "MY_PROJECT" should exist Then a directory named "MY_PROJECT" should exist

View file

@ -67,6 +67,7 @@ end
# Include the core CLI items # Include the core CLI items
require "middleman-core/cli/init" require "middleman-core/cli/init"
require "middleman-core/cli/bundler"
require "middleman-core/cli/extension" require "middleman-core/cli/extension"
require "middleman-core/cli/server" require "middleman-core/cli/server"
require "middleman-core/cli/build" require "middleman-core/cli/build"

View file

@ -0,0 +1,40 @@
# CLI Module
module Middleman::Cli
# A initializing Bundler
class Bundle < Thor
include Thor::Actions
check_unknown_options!
namespace :bundle
desc "bundle", "Setup initial bundle", :hide => true
# The setup task
def bundle
run('bundle install --without development test', :capture => true)
end
end
# A upgrading Bundler
class Upgrade < Thor
include Thor::Actions
check_unknown_options!
namespace :upgrade
desc "upgrade", "Upgrade installed bundle"
# The upgrade task
def upgrade
inside(ENV["MM_ROOT"]) do
run('bundle update', :capture => true)
end
end
end
# Map "u" to "upgrade"
Base.map({
"u" => "upgrade"
})
end

View file

@ -50,17 +50,13 @@ module Middleman::Templates
template "shared/config.ru", File.join(location, "config.ru") template "shared/config.ru", File.join(location, "config.ru")
end end
# Output a Gemfile file for Bundler if --bundler is passed
class_option :bundler, :type => :boolean, :default => true
# Write a Bundler Gemfile file for project # Write a Bundler Gemfile file for project
# @return [void] # @return [void]
def generate_bundler! def generate_bundler!
return unless options[:bundler]
template "shared/Gemfile.tt", File.join(location, "Gemfile") template "shared/Gemfile.tt", File.join(location, "Gemfile")
inside(location) do inside(location) do
run('bundle install', :capture => true) ::Middleman::Cli::Bundle.new.invoke(:bundle)
end end
end end