diff --git a/CHANGELOG.md b/CHANGELOG.md index de7befb1..02e856b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ master === +* Remove 'upgrade' and 'install' CLI commands. +* Gemfile may be in a parent directory of your Middleman project root (where 'config.rb' is). +* All dependencies for your Middleman project must be expressed in `Gemfile` - Bundler is no longer optional. * Asciidoc information now available with the `asciidoc` local, which is a normal hash. * Remove `page` template local. Use `current_resource` instead. * Dropped support for providing a block to `page` & `proxy`. diff --git a/Gemfile b/Gemfile index 83cd68cc..6b365575 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,6 @@ platforms :ruby do gem 'therubyracer' gem 'redcarpet', '~> 3.1' gem 'pry', :require => false, :group => :development - gem 'pry-debugger', :require => false, :group => :development end platforms :jruby do diff --git a/middleman-cli/lib/middleman-cli.rb b/middleman-cli/lib/middleman-cli.rb index ee02429d..48fb1b2d 100644 --- a/middleman-cli/lib/middleman-cli.rb +++ b/middleman-cli/lib/middleman-cli.rb @@ -88,7 +88,6 @@ end # Include the core CLI items require 'middleman-cli/init' -require 'middleman-cli/bundler' require 'middleman-cli/extension' require 'middleman-cli/server' require 'middleman-cli/build' diff --git a/middleman-cli/lib/middleman-cli/bundler.rb b/middleman-cli/lib/middleman-cli/bundler.rb deleted file mode 100644 index 43a0d862..00000000 --- a/middleman-cli/lib/middleman-cli/bundler.rb +++ /dev/null @@ -1,40 +0,0 @@ -# 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')#, :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 diff --git a/middleman-core/lib/middleman-core/load_paths.rb b/middleman-core/lib/middleman-core/load_paths.rb index 673563f6..968e61ec 100644 --- a/middleman-core/lib/middleman-core/load_paths.rb +++ b/middleman-core/lib/middleman-core/load_paths.rb @@ -8,35 +8,16 @@ module Middleman @_is_setup ||= begin # Only look for config.rb if MM_ROOT isn't set - if !ENV['MM_ROOT'] && found_path = locate_root + if !ENV['MM_ROOT'] && (found_path = findup('config.rb')) ENV['MM_ROOT'] = found_path end - is_bundler_setup = false - # If we've found the root, try to setup Bundler if ENV['MM_ROOT'] - - root_gemfile = File.expand_path('Gemfile', ENV['MM_ROOT']) - ENV['BUNDLE_GEMFILE'] ||= root_gemfile - - if !File.exists?(ENV['BUNDLE_GEMFILE']) - git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + 'Gemfile' - ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s - end - - if File.exists?(ENV['BUNDLE_GEMFILE']) - is_bundler_setup = true - require 'bundler/setup' - end - end - - # Automatically discover extensions in RubyGems - require 'middleman-core/extensions' - - if is_bundler_setup - Bundler.require + setup_bundler else + # Automatically discover extensions in RubyGems + require 'middleman-core/extensions' ::Middleman.load_extensions_in_path end @@ -44,11 +25,29 @@ module Middleman end end - # Recursive method to find config.rb - def locate_root(cwd = Pathname.new(Dir.pwd)) - return cwd.to_s if (cwd + 'config.rb').exist? + private + + # Set BUNDLE_GEMFILE and run Bundler setup. Raises an exception if there is no Gemfile + def setup_bundler + ENV['BUNDLE_GEMFILE'] ||= findup('Gemfile', ENV['MM_ROOT']) + + if !File.exists?(ENV['BUNDLE_GEMFILE']) + ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__) + end + + if File.exists?(ENV['BUNDLE_GEMFILE']) + require 'bundler/setup' + Bundler.require + else + raise "Couldn't find your Gemfile. Middleman projects require a Gemfile for specifying dependencies." + end + end + + # Recursive method to find a file in parent directories + def findup(filename, cwd = Pathname.new(Dir.pwd)) + return cwd.to_s if (cwd + filename).exist? return false if cwd.root? - locate_root(cwd.parent) + findup(filename, cwd.parent) end end