Class: Nanoc::CLI::Commands::Deploy
- Inherits:
-
Nanoc::CLI::CommandRunner
- Object
- Cri::CommandRunner
- Nanoc::CLI::CommandRunner
- Nanoc::CLI::Commands::Deploy
- Defined in:
- lib/nanoc/cli/commands/deploy.rb
Instance Method Summary (collapse)
Methods inherited from Nanoc::CLI::CommandRunner
#call, call, #debug?, #in_site_dir?, #load_site, #require_site, #site
Instance Method Details
- (Object) run
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nanoc/cli/commands/deploy.rb', line 17 def run load_site # List deployers if [:list-deployers'] deployers = Nanoc::PluginRegistry.instance.find_all(Nanoc::Extra::Deployer) deployer_names = deployers.keys.sort_by(&:to_s) puts 'Available deployers:' deployer_names.each do |name| puts " #{name}" end return end # Get & list configs deploy_configs = site.config.fetch(:deploy, {}) if [: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 # Can't proceed further without a deploy config if deploy_configs.empty? raise Nanoc::Errors::GenericTrivial, 'The site has no deployment configurations.' end # Get target target = .fetch(:target, :default).to_sym config = deploy_configs.fetch(target) do raise Nanoc::Errors::GenericTrivial, "The site has no deployment configuration for #{target}." end # Get deployer 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 # Check unless [:no-check'] runner = Nanoc::Extra::Checking::Runner.new(site) if runner.dsl_present? puts 'Running issue checks…' ok = runner.run_for_deploy unless ok puts 'Issues found, deploy aborted.' return end puts 'No issues found. Deploying!' end end # Run deployer = deployer_class.new( site.config[:output_dir], config, dry_run: [:dry-run']) deployer.run end |