fix(cli): honored dry-run in plugin uninstall
handleUninstall dropped the parsed dryRun flag and unconditionally called mktMgr.uninstallPlugin / manager.uninstall, so `omp plugin uninstall <plugin> --dry-run` removed the plugin on both the marketplace and npm routes. Propagate dryRun into handleUninstall and short-circuit before both removal calls, reporting the resolved removal (with its source) instead of mutating state. Fixes #8178
This commit is contained in:
@@ -464,7 +464,7 @@ async function handleInstall(
|
||||
async function handleUninstall(
|
||||
manager: PluginManager,
|
||||
packages: string[],
|
||||
flags: { json?: boolean; scope?: "user" | "project" },
|
||||
flags: { json?: boolean; dryRun?: boolean; scope?: "user" | "project" },
|
||||
): Promise<void> {
|
||||
if (packages.length === 0) {
|
||||
console.error(chalk.red(`Usage: ${APP_NAME} plugin uninstall <package> ...`));
|
||||
@@ -477,7 +477,26 @@ async function handleUninstall(
|
||||
const installedPlugins = new Set((await mktMgr.listInstalledPlugins()).map(p => p.id));
|
||||
|
||||
for (const name of packages) {
|
||||
if (installedPlugins.has(name)) {
|
||||
const viaMarketplace = installedPlugins.has(name);
|
||||
|
||||
if (flags.dryRun) {
|
||||
// Dry-run is non-mutating: report the resolved removal without touching state.
|
||||
if (flags.json) {
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
dryRun: true,
|
||||
action: "uninstall",
|
||||
plugin: name,
|
||||
source: viaMarketplace ? "marketplace" : "npm",
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.dim(`[dry-run] Would uninstall ${name}`));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viaMarketplace) {
|
||||
// Exact match against installed marketplace plugin IDs (name@marketplace)
|
||||
try {
|
||||
await mktMgr.uninstallPlugin(name, flags.scope);
|
||||
|
||||
Reference in New Issue
Block a user