From 6d5d4a28f1ed2b150eece0a7d6957690ed04e708 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Wed, 1 Nov 2023 12:54:08 -0600 Subject: [PATCH] feat: add plugins reset cmd --- src/commands/plugins/reset.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/commands/plugins/reset.ts diff --git a/src/commands/plugins/reset.ts b/src/commands/plugins/reset.ts new file mode 100644 index 00000000..c4552a35 --- /dev/null +++ b/src/commands/plugins/reset.ts @@ -0,0 +1,20 @@ +import {Command} from '@oclif/core' +import chalk from 'chalk' + +import Plugins from '../../plugins.js' + +export default class Reset extends Command { + static summary = 'Remove all user-installed and linked plugins.' + + async run(): Promise { + const plugins = new Plugins(this.config) + const userPlugins = await plugins.list() + + this.log(`Uninstalling ${userPlugins.length} plugin${userPlugins.length === 0 ? '' : 's'}`) + for (const plugin of userPlugins) { + this.log(`• ${plugin.name} ${chalk.dim(`(${plugin.type})`)}`) + } + + await Promise.all(userPlugins.map(async (plugin) => plugins.uninstall(plugin.name))) + } +}