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:
parent
7c8baee246
commit
190be5f515
4 changed files with 42 additions and 15 deletions
|
@ -36,16 +36,6 @@ Feature: Middleman CLI
|
|||
| config.rb |
|
||||
| config.ru |
|
||||
| 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
|
||||
When I run `middleman init MY_PROJECT --template=html5`
|
||||
|
|
|
@ -67,6 +67,7 @@ end
|
|||
|
||||
# Include the core CLI items
|
||||
require "middleman-core/cli/init"
|
||||
require "middleman-core/cli/bundler"
|
||||
require "middleman-core/cli/extension"
|
||||
require "middleman-core/cli/server"
|
||||
require "middleman-core/cli/build"
|
40
middleman-core/lib/middleman-core/cli/bundler.rb
Normal file
40
middleman-core/lib/middleman-core/cli/bundler.rb
Normal 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
|
|
@ -50,17 +50,13 @@ module Middleman::Templates
|
|||
template "shared/config.ru", File.join(location, "config.ru")
|
||||
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
|
||||
# @return [void]
|
||||
def generate_bundler!
|
||||
return unless options[:bundler]
|
||||
template "shared/Gemfile.tt", File.join(location, "Gemfile")
|
||||
|
||||
inside(location) do
|
||||
run('bundle install', :capture => true)
|
||||
::Middleman::Cli::Bundle.new.invoke(:bundle)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue