|
|
@ -54,12 +54,29 @@ var async = require('async'),
|
|
|
|
setup: function (callback) {
|
|
|
|
setup: function (callback) {
|
|
|
|
async.series([
|
|
|
|
async.series([
|
|
|
|
function(next) {
|
|
|
|
function(next) {
|
|
|
|
// prompt prepends "prompt: " to questions, let's clear that.
|
|
|
|
// Check if the `--setup` flag contained values we can work with
|
|
|
|
prompt.start();
|
|
|
|
var setupVal;
|
|
|
|
prompt.message = '';
|
|
|
|
try {
|
|
|
|
prompt.delimiter = '';
|
|
|
|
setupVal = JSON.parse(nconf.get('setup'));
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
setupVal = undefined;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
prompt.get(install.questions, function (err, config) {
|
|
|
|
if (setupVal && setupVal instanceof Object) {
|
|
|
|
|
|
|
|
if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:email']) {
|
|
|
|
|
|
|
|
install.values = setupVal;
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
winston.error('Required values are missing for automated setup:');
|
|
|
|
|
|
|
|
if (!setupVal['admin:username']) winston.error(' admin:username');
|
|
|
|
|
|
|
|
if (!setupVal['admin:password']) winston.error(' admin:password');
|
|
|
|
|
|
|
|
if (!setupVal['admin:email']) winston.error(' admin:email');
|
|
|
|
|
|
|
|
process.exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else next();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (next) {
|
|
|
|
|
|
|
|
var success = function(err, config) {
|
|
|
|
if (!config) {
|
|
|
|
if (!config) {
|
|
|
|
return next(new Error('aborted'));
|
|
|
|
return next(new Error('aborted'));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,7 +111,24 @@ var async = require('async'),
|
|
|
|
server_conf.relative_path = relative_path;
|
|
|
|
server_conf.relative_path = relative_path;
|
|
|
|
|
|
|
|
|
|
|
|
install.save(server_conf, client_conf, next);
|
|
|
|
install.save(server_conf, client_conf, next);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prompt prepends "prompt: " to questions, let's clear that.
|
|
|
|
|
|
|
|
prompt.start();
|
|
|
|
|
|
|
|
prompt.message = '';
|
|
|
|
|
|
|
|
prompt.delimiter = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!install.values) prompt.get(install.questions, success);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
// Use provided values, fall back to defaults
|
|
|
|
|
|
|
|
var config = {},
|
|
|
|
|
|
|
|
question, x, numQ;
|
|
|
|
|
|
|
|
for(x=0,numQ=install.questions.length;x<numQ;x++) {
|
|
|
|
|
|
|
|
question = install.questions[x];
|
|
|
|
|
|
|
|
config[question.name] = install.values[question.name] || question['default'] || '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
success(null, config);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
// Applying default database configs
|
|
|
|
// Applying default database configs
|
|
|
@ -238,8 +272,7 @@ var async = require('async'),
|
|
|
|
hidden: true,
|
|
|
|
hidden: true,
|
|
|
|
type: 'string'
|
|
|
|
type: 'string'
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
getAdminInfo = function (callback) {
|
|
|
|
success = function(err, results) {
|
|
|
|
prompt.get(questions, function (err, results) {
|
|
|
|
|
|
|
|
if (!results) {
|
|
|
|
if (!results) {
|
|
|
|
return callback(new Error('aborted'));
|
|
|
|
return callback(new Error('aborted'));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -261,10 +294,18 @@ var async = require('async'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
getAdminInfo(callback);
|
|
|
|
if (!install.values) prompt.get(questions, success);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
var results = {
|
|
|
|
|
|
|
|
username: install.values['admin:username'],
|
|
|
|
|
|
|
|
email: install.values['admin:email'],
|
|
|
|
|
|
|
|
password: install.values['admin:password']
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
success(null, results);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
save: function (server_conf, client_conf, callback) {
|
|
|
|
save: function (server_conf, client_conf, callback) {
|
|
|
|
// Server Config
|
|
|
|
// Server Config
|
|
|
|