mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 09:25:45 +01:00
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:
committed by
Julian Lam
parent
3551d7d68e
commit
fc19f3af61
@@ -9,14 +9,30 @@ var dirname = require('./paths').baseDir;
|
||||
// check to make sure dependencies are installed
|
||||
try {
|
||||
fs.readFileSync(path.join(dirname, 'package.json'));
|
||||
fs.readFileSync(path.join(dirname, 'node_modules/async/package.json'));
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
console.warn('package.json not found.');
|
||||
console.log('Populating package.json...\n');
|
||||
|
||||
packageInstall.updatePackageFile();
|
||||
packageInstall.preserveExtraneousPlugins();
|
||||
|
||||
console.log('OK'.green + '\n'.reset);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fs.readFileSync(path.join(dirname, 'node_modules/async/package.json'), 'utf8');
|
||||
fs.readFileSync(path.join(dirname, 'node_modules/commander/package.json'), 'utf8');
|
||||
fs.readFileSync(path.join(dirname, 'node_modules/colors/package.json'), 'utf8');
|
||||
fs.readFileSync(path.join(dirname, 'node_modules/nconf/package.json'), 'utf8');
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
console.warn('Dependencies not yet installed.');
|
||||
console.log('Installing them now...\n');
|
||||
|
||||
packageInstall.updatePackageFile();
|
||||
packageInstall.preserveExtraneousPlugins();
|
||||
packageInstall.npmInstallProduction();
|
||||
|
||||
require('colors');
|
||||
@@ -121,10 +137,20 @@ program
|
||||
|
||||
// management commands
|
||||
program
|
||||
.command('setup')
|
||||
.description('Run the NodeBB setup script')
|
||||
.action(function () {
|
||||
require('./setup').setup();
|
||||
.command('setup [config]')
|
||||
.description('Run the NodeBB setup script, or setup with an initial config')
|
||||
.action(function (initConfig) {
|
||||
if (initConfig) {
|
||||
try {
|
||||
initConfig = JSON.parse(initConfig);
|
||||
} catch (e) {
|
||||
console.warn('Invalid JSON passed as initial config value.'.red);
|
||||
console.log('If you meant to pass in an initial config value, please try again.\n');
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
require('./setup').setup(initConfig);
|
||||
});
|
||||
|
||||
program
|
||||
|
||||
Reference in New Issue
Block a user