Merge branch 'develop' into bootstrap5

This commit is contained in:
Julian Lam
2022-11-24 20:18:38 -05:00
7 changed files with 84 additions and 8 deletions

View File

@@ -176,11 +176,16 @@ program
});
program
.command('install')
.description('Launch the NodeBB web installer for configuration setup')
.action(() => {
require('./setup').webInstall();
.command('install [plugin]')
.description('Launch the NodeBB web installer for configuration setup or install a plugin')
.action((plugin) => {
if (plugin) {
require('./manage').install(plugin);
} else {
require('./setup').webInstall();
}
});
program
.command('build [targets...]')
.description(`Compile static assets ${chalk.red('(JS, CSS, templates, languages)')}`)

View File

@@ -12,7 +12,36 @@ const plugins = require('../plugins');
const events = require('../events');
const analytics = require('../analytics');
const reset = require('./reset');
const { pluginNamePattern, themeNamePattern } = require('../constants');
const { pluginNamePattern, themeNamePattern, paths } = require('../constants');
async function install(plugin) {
try {
await db.init();
if (!pluginNamePattern.test(plugin)) {
// Allow omission of `nodebb-plugin-`
plugin = `nodebb-plugin-${plugin}`;
}
plugin = await plugins.autocomplete(plugin);
const isInstalled = await plugins.isInstalled(plugin);
if (isInstalled) {
throw new Error('plugin already installed');
}
const nbbVersion = require(paths.currentPackage).version;
const suggested = await plugins.suggest(plugin, nbbVersion);
if (!suggested.version) {
throw new Error(suggested.message);
}
winston.info('Installing Plugin `%s@%s`', plugin, suggested.version);
await plugins.toggleInstall(plugin, suggested.version);
process.exit(0);
} catch (err) {
winston.error(`An error occurred during plugin installation\n${err.stack}`);
process.exit(1);
}
}
async function activate(plugin) {
if (themeNamePattern.test(plugin)) {
@@ -166,6 +195,7 @@ async function buildWrapper(targets, options) {
}
exports.build = buildWrapper;
exports.install = install;
exports.activate = activate;
exports.listPlugins = listPlugins;
exports.listEvents = listEvents;