Skip to content

Commit

Permalink
update deploy prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Nov 30, 2015
1 parent 6cfcc06 commit 0d25e1f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
23 changes: 18 additions & 5 deletions bin/deploy-prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ function getLocalDeployDirChoices(){

// Add repo-name
var dirs_with_basename = dirs.map(function(dir){
return [LOCAL_FOLDER, dir].join('>>'); // Use this as the file delimiter to avoid os-mismatch between client and server
return ['.', dir].join('/'); // Kestrel server will run with `/` file paths for Linux
})
return [LOCAL_FOLDER].concat(dirs_with_basename);
return ['./'].concat(dirs_with_basename);
}

function getConfigRemotePath(){
Expand All @@ -54,7 +54,7 @@ function getConfigRemotePath(){
var default_deploy = {
bucket_environment: 'staging',
trigger_type: 'sync',
local_path: LOCAL_FOLDER,
local_path: './',
remote_path: getConfigRemotePath() + '/' + LOCAL_FOLDER,
when: 'now'
};
Expand All @@ -72,14 +72,27 @@ var questions = [
type: 'list',
name: 'trigger_type',
message: 'Deploy method?',
choices: ['sync', 'hard'],
choices: function(){
var choices = ['sync']
if (!config.server.hard_deploy.enabled) {
choices.push('hard')
}
return choices
},
default: default_deploy.trigger_type
},{
type: 'list',
name: 'local_path',
message: 'Deploy from directory:',
choices: getLocalDeployDirChoices(),
default: default_deploy.local_path
default: './',
filter: function(input){
if (input == './') {
return LOCAL_FOLDER
} else {
return input.replace('.', LOCAL_FOLDER)
}
}
},{
type: 'input',
name: 'remote_path',
Expand Down
17 changes: 6 additions & 11 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,9 @@ function checkDeployInfo(dplySettings){
}

// Make sure your sub-directory exists
var full_local_path = path.join(LOCAL_FOLDER, local_path);
if ( !io.existsSync(full_local_path) ) {
throw chalk.red.bold('Error: Local directory `') + chalk.yellow.bold(local_path) + chalk.red('` does not exist.');
}

// Make sure you specified a bucket environment
if (bucket_environment != 'prod' && bucket_environment != 'staging') {
throw chalk.red.bold('Error: Bucket environment must be either `prod` or `staging`.');
// var full_local_path = path.join(LOCAL_FOLDER, local_path);
if ( !io.existsSync(local_path.replace(LOCAL_FOLDER, '.')) ) {
throw chalk.red.bold('Error:') + ' Local directory `' + chalk.bold(local_path) + '` does not exist.';
}

// Make sure your date is a proper date, unless it's `now`
Expand Down Expand Up @@ -246,12 +241,12 @@ function promptFor(target, dplySettings){
console.log(chalk.red('\n\nCancelled.'));
} else {
if (target == 'deploy') {
deploy(answers);
commands.deploy(answers);
writeDeploySettings(answers);
} else if (target == 'archive'){
archive(answers);
commands.archive(answers);
} else if (target == 'unschedule'){
unschedule(answers);
commands.unschedule(answers);
}
}
})
Expand Down

0 comments on commit 0d25e1f

Please sign in to comment.