def run
self.load_site
if options['list-deployers''list-deployers']
deployers = Nanoc::PluginRegistry.instance.find_all(Nanoc::Extra::Deployer)
deployer_names = deployers.keys.sort_by { |k| k.to_s }
puts "Available deployers:"
deployer_names.each do |name|
puts " #{name}"
end
return
end
deploy_configs = site.config.fetch(:deploy, {})
if options[:list]
if deploy_configs.empty?
puts "No deployment configurations."
else
puts "Available deployment configurations:"
deploy_configs.keys.each do |name|
puts " #{name}"
end
end
return
end
if deploy_configs.empty?
raise Nanoc::Errors::GenericTrivial, "The site has no deployment configurations."
end
target = options.fetch(:target, :default).to_sym
config = deploy_configs.fetch(target) do
raise Nanoc::Errors::GenericTrivial, "The site has no deployment configuration for #{target}."
end
names = Nanoc::Extra::Deployer.all.keys
name = config.fetch(:kind) do
$stderr.puts "Warning: The specified deploy target does not have a kind attribute. Assuming rsync."
'rsync'
end
deployer_class = Nanoc::Extra::Deployer.named(name)
if deployer_class.nil?
raise Nanoc::Errors::GenericTrivial, "The specified deploy target has an unrecognised kind “#{name}” (expected one of #{names.join(', ')})."
end
unless options['no-check''no-check']
runner = Nanoc::Extra::Checking::Runner.new(site)
if runner.has_dsl?
puts "Running issue checks…"
ok = runner.run_for_deploy
if !ok
puts "Issues found, deploy aborted."
return
end
puts "No issues found. Deploying!"
end
end
deployer = deployer_class.new(
site.config[:output_dir],
config,
:dry_run => options['dry-run''dry-run'])
deployer.run
end