Node.js based forum software built for the modern web
feat: better output for cli plugins list, closes #8075
Julian Lam4fc6944377e7
diff --git a/src/cli/manage.js b/src/cli/manage.jsindex eb215982db..22ae9fe432 100644--- a/src/cli/manage.js+++ b/src/cli/manage.js@@ -92,21 +92,39 @@ function activate(plugin) {});}-function listPlugins() {- async.waterfall([- function (next) {- db.init(next);- },- function (next) {- db.getSortedSetRange('plugins:active', 0, -1, next);- },- function (plugins) {- winston.info('Active plugins: \n\t - ' + plugins.join('\n\t - '));- process.exit();- },- ], function (err) {- throw err;+async function listPlugins() {+ await db.init();+ const installed = await plugins.showInstalled();+ const installedList = installed.map(plugin => plugin.name);+ const active = await db.getSortedSetRange('plugins:active', 0, -1);++ // Merge the two sets, defer to plugins in `installed` if already present+ let combined = installed.concat(active.reduce((memo, cur) => {+ if (!installedList.includes(cur)) {+ memo.push({+ id: cur,+ active: true,+ installed: false,+ });+ }++ return memo;+ }, []));++ // Alphabetical sort+ combined = combined.sort((a, b) => (a.id > b.id ? 1 : -1));++ // Pretty output+ process.stdout.write('Active plugins:\n');+ combined.forEach((plugin) => {+ process.stdout.write('\t* ' + plugin.id + ' (');+ process.stdout.write(plugin.installed ? 'installed'.green : 'not installed'.red);+ process.stdout.write(', ');+ process.stdout.write(plugin.active ? 'enabled'.green : 'disabled'.yellow);+ process.stdout.write(')\n');});++ process.exit();}function listEvents(count) {