Skip to content

Commit

Permalink
feat: add force flag to plugin install in cli (#11089)
Browse files Browse the repository at this point in the history
  • Loading branch information
oplik0 committed Dec 16, 2022
1 parent 14091de commit d447236
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
11 changes: 9 additions & 2 deletions src/cli/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down

0 comments on commit d447236

Please sign in to comment.