2011-07-27 00:06:24 -04:00
|
|
|
#!/usr/bin/env ruby
|
2020-08-16 15:08:50 -04:00
|
|
|
# frozen_string_literal: true
|
2011-07-27 02:19:43 -04:00
|
|
|
|
2012-07-19 01:10:02 -04:00
|
|
|
require 'middleman-core/profiling'
|
2018-11-08 15:38:26 -05:00
|
|
|
Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new if ARGV.include? '--profile'
|
2012-07-19 01:10:02 -04:00
|
|
|
|
2018-09-11 14:43:07 -04:00
|
|
|
require 'middleman-core/load_paths'
|
2012-07-16 20:24:13 -04:00
|
|
|
Middleman.setup_load_paths
|
2012-05-24 14:03:58 -04:00
|
|
|
|
2016-05-25 13:54:49 -04:00
|
|
|
require 'dotenv'
|
|
|
|
::Dotenv.load
|
|
|
|
|
2016-03-12 16:55:25 -05:00
|
|
|
require 'middleman-core'
|
|
|
|
require 'middleman-core/logger'
|
|
|
|
|
|
|
|
module Middleman::Cli
|
|
|
|
class << self
|
|
|
|
attr_accessor :config
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.import_config(base)
|
|
|
|
::Middleman::Cli.config.all_settings.each do |setting|
|
|
|
|
if setting.default.is_a?(String) || setting.default.is_a?(NilClass)
|
|
|
|
base.class_option setting.key,
|
|
|
|
type: :string,
|
|
|
|
desc: setting.description
|
|
|
|
elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass)
|
|
|
|
base.class_option setting.key,
|
|
|
|
type: :boolean,
|
|
|
|
desc: setting.description
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-11 14:43:07 -04:00
|
|
|
require 'middleman-cli'
|
2012-05-26 17:15:36 -04:00
|
|
|
|
2012-07-16 20:24:13 -04:00
|
|
|
# Change directory to the root
|
2018-09-11 14:43:07 -04:00
|
|
|
Dir.chdir(ENV['MM_ROOT']) if ENV['MM_ROOT']
|
2011-12-29 01:52:51 -05:00
|
|
|
|
2015-01-04 15:23:35 -05:00
|
|
|
# Default command is server
|
2018-11-08 15:38:26 -05:00
|
|
|
ARGV.unshift('server') if ARGV[0] != 'help' && (ARGV.empty? || ARGV.first.include?('-'))
|
2015-01-04 15:23:35 -05:00
|
|
|
|
2016-03-12 16:55:25 -05:00
|
|
|
::Middleman::Logger.singleton(3)
|
|
|
|
::Middleman::Cli.config = ::Middleman::Application.new do
|
2016-05-25 13:54:49 -04:00
|
|
|
config[:environment] = (ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development').to_sym
|
2016-03-20 19:31:15 -04:00
|
|
|
config[:mode] = :config
|
2016-03-12 16:55:25 -05:00
|
|
|
config[:exit_before_ready] = true
|
2016-03-17 16:23:36 -04:00
|
|
|
config[:watcher_disable] = true
|
|
|
|
config[:disable_sitemap] = true
|
2016-03-12 16:55:25 -05:00
|
|
|
end.config
|
|
|
|
|
|
|
|
# Require the Middleman version
|
|
|
|
require 'middleman-core/version'
|
|
|
|
|
|
|
|
# Include the core CLI items
|
|
|
|
require 'middleman-cli/init'
|
|
|
|
require 'middleman-cli/extension'
|
|
|
|
require 'middleman-cli/server'
|
|
|
|
require 'middleman-cli/build'
|
|
|
|
require 'middleman-cli/console'
|
|
|
|
require 'middleman-cli/config'
|
|
|
|
|
2019-02-18 13:29:01 -05:00
|
|
|
# Support NO_COLOR: https://no-color.org
|
|
|
|
ENV['THOR_SHELL'] = 'Basic' if ENV['NO_COLOR']
|
|
|
|
|
2012-05-24 14:03:58 -04:00
|
|
|
# Start the CLI
|
2015-01-04 15:23:35 -05:00
|
|
|
Middleman::Cli::Base.start(ARGV)
|