Misc fixes and improvements (#6143)

* `setup` command fixes and improvements

- Enable using the `./nodebb setup` command for auto-setup with a JSON argument
- Change CLI so package-install and dependency install are separate steps
- Fix #6142

* Prevent compiling templates multiple times

- Multiple requests for same template get pooled
- Hopefully fixes the "templateFunction is not a function" error which happens if site is restarted during high-traffic times

* More helpful upgrade template
This commit is contained in:
Peter Jaszkowiak
2017-12-04 13:49:44 -07:00
committed by Julian Lam
parent 3551d7d68e
commit fc19f3af61
6 changed files with 83 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ var winston = require('winston');
var nconf = require('nconf');
var utils = require('./utils.js');
var install = {};
var install = module.exports;
var questions = {};
questions.main = [
@@ -42,17 +42,15 @@ questions.optional = [
];
function checkSetupFlag(next) {
var setupVal;
var setupVal = install.values;
try {
if (nconf.get('setup')) {
setupVal = JSON.parse(nconf.get('setup'));
}
} catch (err) {
setupVal = undefined;
}
} catch (err) {}
if (setupVal && setupVal instanceof Object) {
if (setupVal && typeof setupVal === 'object') {
if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) {
install.values = setupVal;
next();
@@ -74,9 +72,8 @@ function checkSetupFlag(next) {
process.exit();
}
} else if (nconf.get('database')) {
install.values = {
database: nconf.get('database'),
};
install.values = install.values || {};
install.values.database = nconf.get('database');
next();
} else {
next();
@@ -549,11 +546,9 @@ install.save = function (server_conf, callback) {
console.log('Configuration Saved OK');
nconf.file({
file: path.join(__dirname, '..', 'config.json'),
file: serverConfigPath,
});
callback();
});
};
module.exports = install;