var plan = require('flightplan');
var config = require('./config')

plan.target('production', [
  {
    host: config.app_server.ssh_host,
    username: config.app_server.ssh_user,
    agent: process.env.SSH_AUTH_SOCK
  }
]);

plan.local(function(local)) {

  // confirm deployment to production, as we don't want to do this accidentally
  if(plan.runtime.target === 'production') {
    var input = local.prompt('Deploy to production? [yes]');
    if(input.indexOf('yes') === -1) {
      local.abort('deployment cancelled by user.'); // this will stop the flightplan right away.
    }
  }

  // TODO: compile CSS
  // TODO: package JS, CSS, assets (Webpack)
  // TODO: transfer files to temp directory
}

// REMOTE APPS SERVER
plan.remote(function(remote) {
  // TODO: copy project folder to release directory
  // TODO: download and install NPM dependencies
  // TODO: point 'current' symlink to new project folder
  // TODO: delete any outdated release folders
  // TODO: reload node application
})

// REMOTE RPS SERVER
plan.remote(function(remote) {
  // TODO: add/edit block config
  // TODO: activate host with symlink
  // TODO: reload nginx server
})

// REMOTE DB SERVER
plan.remote(function(remote) {
  // TODO: apply schema revisions?
});

// TODO: send summary notifications or alerts
