mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: add force flag to plugin install in cli (#11089)
This commit is contained in:
@@ -175,9 +175,10 @@ program
|
||||
program
|
||||
.command('install [plugin]')
|
||||
.description('Launch the NodeBB web installer for configuration setup or install a plugin')
|
||||
.action((plugin) => {
|
||||
.option('-f, --force', 'Force plugin installation even if it may be incompatible with currently installed NodeBB version')
|
||||
.action((plugin, options) => {
|
||||
if (plugin) {
|
||||
require('./manage').install(plugin);
|
||||
require('./manage').install(plugin, options);
|
||||
} else {
|
||||
require('./setup').webInstall();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ const analytics = require('../analytics');
|
||||
const reset = require('./reset');
|
||||
const { pluginNamePattern, themeNamePattern, paths } = require('../constants');
|
||||
|
||||
async function install(plugin) {
|
||||
async function install(plugin, options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
try {
|
||||
await db.init();
|
||||
if (!pluginNamePattern.test(plugin)) {
|
||||
@@ -31,7 +34,11 @@ async function install(plugin) {
|
||||
const nbbVersion = require(paths.currentPackage).version;
|
||||
const suggested = await plugins.suggest(plugin, nbbVersion);
|
||||
if (!suggested.version) {
|
||||
throw new Error(suggested.message);
|
||||
if (!options.force) {
|
||||
throw new Error(suggested.message);
|
||||
}
|
||||
winston.warn(`${suggested.message} Proceeding with installation anyway due to force option being provided`);
|
||||
suggested.version = 'latest';
|
||||
}
|
||||
winston.info('Installing Plugin `%s@%s`', plugin, suggested.version);
|
||||
await plugins.toggleInstall(plugin, suggested.version);
|
||||
|
||||
Reference in New Issue
Block a user