|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
/* eslint-disable import/order */
|
|
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
const fs = require('fs');
|
|
|
@ -35,13 +37,13 @@ try {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
fs.accessSync(path.join(paths.nodeModules, 'semver/package.json'), fs.constants.R_OK);
|
|
|
|
fs.accessSync(path.join(paths.nodeModules, 'semver/package.json'), fs.constants.R_OK);
|
|
|
|
|
|
|
|
|
|
|
|
var semver = require('semver');
|
|
|
|
const semver = require('semver');
|
|
|
|
var defaultPackage = require('../../install/package.json');
|
|
|
|
const defaultPackage = require('../../install/package.json');
|
|
|
|
|
|
|
|
|
|
|
|
var checkVersion = function (packageName) {
|
|
|
|
const checkVersion = function (packageName) {
|
|
|
|
var version = JSON.parse(fs.readFileSync(path.join(paths.nodeModules, packageName, 'package.json'), 'utf8')).version;
|
|
|
|
const version = JSON.parse(fs.readFileSync(path.join(paths.nodeModules, packageName, 'package.json'), 'utf8')).version;
|
|
|
|
if (!semver.satisfies(version, defaultPackage.dependencies[packageName])) {
|
|
|
|
if (!semver.satisfies(version, defaultPackage.dependencies[packageName])) {
|
|
|
|
var e = new TypeError('Incorrect dependency version: ' + packageName);
|
|
|
|
const e = new TypeError('Incorrect dependency version: ' + packageName);
|
|
|
|
e.code = 'DEP_WRONG_VERSION';
|
|
|
|
e.code = 'DEP_WRONG_VERSION';
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -67,14 +69,13 @@ try {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
require('colors');
|
|
|
|
require('colors');
|
|
|
|
// eslint-disable-next-line
|
|
|
|
const nconf = require('nconf');
|
|
|
|
var nconf = require('nconf');
|
|
|
|
const { program } = require('commander');
|
|
|
|
// eslint-disable-next-line
|
|
|
|
const yargs = require('yargs');
|
|
|
|
var program = require('commander');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pkg = require('../../package.json');
|
|
|
|
const pkg = require('../../package.json');
|
|
|
|
var file = require('../file');
|
|
|
|
const file = require('../file');
|
|
|
|
var prestart = require('../prestart');
|
|
|
|
const prestart = require('../prestart');
|
|
|
|
|
|
|
|
|
|
|
|
program
|
|
|
|
program
|
|
|
|
.name('./nodebb')
|
|
|
|
.name('./nodebb')
|
|
|
@ -86,19 +87,23 @@ program
|
|
|
|
.option('-d, --dev', 'Development mode, including verbose logging', false)
|
|
|
|
.option('-d, --dev', 'Development mode, including verbose logging', false)
|
|
|
|
.option('-l, --log', 'Log subprocess output to console', false);
|
|
|
|
.option('-l, --log', 'Log subprocess output to console', false);
|
|
|
|
|
|
|
|
|
|
|
|
nconf.argv().env({
|
|
|
|
// provide a yargs object ourselves
|
|
|
|
|
|
|
|
// otherwise yargs will consume `--help` or `help`
|
|
|
|
|
|
|
|
// and `nconf` will exit with useless usage info
|
|
|
|
|
|
|
|
const opts = yargs(process.argv.slice(2)).help(false).exitProcess(false);
|
|
|
|
|
|
|
|
nconf.argv(opts).env({
|
|
|
|
separator: '__',
|
|
|
|
separator: '__',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var env = program.dev ? 'development' : (process.env.NODE_ENV || 'production');
|
|
|
|
const env = program.dev ? 'development' : (process.env.NODE_ENV || 'production');
|
|
|
|
process.env.NODE_ENV = env;
|
|
|
|
process.env.NODE_ENV = env;
|
|
|
|
global.env = env;
|
|
|
|
global.env = env;
|
|
|
|
|
|
|
|
|
|
|
|
prestart.setupWinston();
|
|
|
|
prestart.setupWinston();
|
|
|
|
|
|
|
|
|
|
|
|
// Alternate configuration file support
|
|
|
|
// Alternate configuration file support
|
|
|
|
var configFile = path.resolve(paths.baseDir, nconf.get('config') || 'config.json');
|
|
|
|
const configFile = path.resolve(paths.baseDir, nconf.get('config') || 'config.json');
|
|
|
|
var configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database'));
|
|
|
|
const configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database'));
|
|
|
|
|
|
|
|
|
|
|
|
prestart.loadConfig(configFile);
|
|
|
|
prestart.loadConfig(configFile);
|
|
|
|
prestart.versionCheck();
|
|
|
|
prestart.versionCheck();
|
|
|
@ -195,7 +200,7 @@ program
|
|
|
|
require('./manage').build(targets.length ? targets : true, options);
|
|
|
|
require('./manage').build(targets.length ? targets : true, options);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('--help', function () {
|
|
|
|
.on('--help', function () {
|
|
|
|
require('./manage').buildTargets();
|
|
|
|
require('../meta/aliases').buildTargets();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
program
|
|
|
|
program
|
|
|
|
.command('activate [plugin]')
|
|
|
|
.command('activate [plugin]')
|
|
|
@ -223,7 +228,7 @@ program
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// reset
|
|
|
|
// reset
|
|
|
|
var resetCommand = program.command('reset');
|
|
|
|
const resetCommand = program.command('reset');
|
|
|
|
|
|
|
|
|
|
|
|
resetCommand
|
|
|
|
resetCommand
|
|
|
|
.description('Reset plugins, themes, settings, etc')
|
|
|
|
.description('Reset plugins, themes, settings, etc')
|
|
|
@ -233,7 +238,7 @@ resetCommand
|
|
|
|
.option('-s, --settings', 'Reset settings to their default values')
|
|
|
|
.option('-s, --settings', 'Reset settings to their default values')
|
|
|
|
.option('-a, --all', 'All of the above')
|
|
|
|
.option('-a, --all', 'All of the above')
|
|
|
|
.action(function (options) {
|
|
|
|
.action(function (options) {
|
|
|
|
var valid = ['theme', 'plugin', 'widgets', 'settings', 'all'].some(function (x) {
|
|
|
|
const valid = ['theme', 'plugin', 'widgets', 'settings', 'all'].some(function (x) {
|
|
|
|
return options[x];
|
|
|
|
return options[x];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (!valid) {
|
|
|
|
if (!valid) {
|
|
|
@ -295,10 +300,11 @@ program
|
|
|
|
return program.help();
|
|
|
|
return program.help();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var command = program.commands.find(function (command) { return command._name === name; });
|
|
|
|
const command = program.commands.find(function (command) { return command._name === name; });
|
|
|
|
if (command) {
|
|
|
|
if (command) {
|
|
|
|
command.help();
|
|
|
|
command.help();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.log(`error: unknown command '${command}'.`);
|
|
|
|
program.help();
|
|
|
|
program.help();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -311,4 +317,4 @@ if (process.argv.length === 2) {
|
|
|
|
|
|
|
|
|
|
|
|
program.executables = false;
|
|
|
|
program.executables = false;
|
|
|
|
|
|
|
|
|
|
|
|
program.parse(process.argv);
|
|
|
|
program.parse();
|
|
|
|