Class: Webbynode::Commands::Init

Inherits:
Webbynode::Command show all
Defined in:
lib/webbynode/commands/init.rb

Constant Summary

Constants inherited from Webbynode::Command

Webbynode::Command::Aliases, Webbynode::Command::CommandError, Webbynode::Command::InvalidCommand, Webbynode::Command::InvalidOption, Webbynode::Command::Settings

Instance Method Summary collapse

Methods inherited from Webbynode::Command

add_alias, #api, class_for, command, command_class_name, description, for, #gemfile, #git, help, inherited, #initialize, #io, #no?, #notify, option, #option, #options, options_help, #param, #param_values, parameter, #params, #params_hash, params_help, #pushand, #remote_executor, requires_initialization!, requires_options!, requires_pushed_application!, #run, #server, setting, #settings, summary, summary_help, usage, #validate_initialization, #validate_options, #yes?

Constructor Details

This class inherits a constructor from Webbynode::Command

Instance Method Details

#create_pushandObject



74
75
76
77
78
79
# File 'lib/webbynode/commands/init.rb', line 74

def create_pushand
  return if pushand_exists? && !@overwrite

  io.log ""
  pushand.create!(@app_name, @dns_entry)
end

#executeObject



13
14
15
16
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
# File 'lib/webbynode/commands/init.rb', line 13

def execute
  unless params.any?
    io.log help
    return
  end
  
  io.log "#{"Webbynode Rapp".color(:white).bright} - #{"http://rapp.webbynode.com".underline}"

  @overwrite   = false

  check_prerequisites
  check_initialized
  
  @webby       = param(:webby)
  @app_name    = spinner { io.app_name }
  @git_present = git.present?
  @dns_entry   = option(:dns) ? "#{option(:dns)}" : @app_name

  handle_trial
  
  check_git_clean if @git_present
  
  io.log "Initializing application #{@app_name.color(:yellow)} #{@dns_entry ? "with dns #{@dns_entry.color(:yellow)}" : ""}"
  
  detect_engine
  
  io.log ""
  io.log "Initializing directory structure..."
  
  create_pushand
  create_webbynode_tree
  create_git_commit unless @git_present
  create_git_remote
  
  handle_dns option(:dns) if option(:adddns)
  
  io.log "Application #{@app_name.color(:yellow)} ready for Rapid Deployment", :finish
  
rescue Net::SSH::HostKeyMismatch
  io.log ""
  io.log "Error pushing to your server:"
  io.log "  #{$!.to_s.color(:red)}"
  io.log ""
  io.log "This usually happens because you redeployed the server and the fingerprint changed."
  io.log ""
  io.log "To fix this error:"
  io.log "  1. Edit #{Webbynode::Io.home_dir}/.ssh/known_hosts file"
  io.log "     or the proper known hosts file for your SSH service."
  io.log "  2. Remove the line that starts with the IP #{@webby_ip}."
  io.log ""

rescue Webbynode::InvalidAuthentication
  io.log "Could not connect to webby: invalid authentication.".color(:red), true

rescue Webbynode::PermissionError
  io.log "Could not create an SSH key: permission error.".color(:red), true

rescue Webbynode::GitRemoteAlreadyExistsError
  io.log "Application already initialized.".color(:red)
end