Skip to content

Commit 379a9fe

Browse files
committed
Remove withProgress options from commands for separation of concerns
1 parent b17b529 commit 379a9fe

7 files changed

Lines changed: 40 additions & 358 deletions

File tree

‎SETTINGS_ARCHITECTURE.md‎

Lines changed: 0 additions & 301 deletions
This file was deleted.

‎src/managers/base/commands/packageManagerCommand.ts‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CancellationToken, l10n, LogOutputChannel, ProgressLocation, window, WorkspaceConfiguration } from 'vscode';
1+
import { CancellationToken, LogOutputChannel, WorkspaceConfiguration } from 'vscode';
22
import { getConfiguration } from '../../../common/workspace.apis';
33

44
/**
@@ -7,7 +7,6 @@ import { getConfiguration } from '../../../common/workspace.apis';
77
*/
88
export interface BaseExecuteArgs {
99
cancellationToken?: CancellationToken;
10-
showProgress?: boolean;
1110
}
1211

1312
/**
@@ -37,38 +36,6 @@ export abstract class PackageManagerCommand {
3736
this.config = configSection ? getConfiguration(`python-envs.packageManager.${configSection}`) : undefined;
3837
}
3938

40-
/**
41-
* Executes this command and optionally wraps execution with a progress indicator.
42-
*/
43-
public executeWithProgress<T = unknown, A extends BaseExecuteArgs = BaseExecuteArgs>(
44-
executeArgs?: A,
45-
title?: string,
46-
): Promise<T> {
47-
if (!executeArgs?.showProgress) {
48-
return this.execute(executeArgs) as Promise<T>;
49-
}
50-
51-
return Promise.resolve(
52-
window.withProgress(
53-
{
54-
location: ProgressLocation.Notification,
55-
title: title ?? l10n.t('Running package manager command'),
56-
cancellable: true,
57-
},
58-
(_progress, token) =>
59-
this.execute({
60-
...executeArgs,
61-
cancellationToken: executeArgs.cancellationToken ?? token,
62-
}) as Promise<T>,
63-
),
64-
);
65-
}
66-
67-
/**
68-
* Subclasses implement command execution.
69-
*/
70-
abstract execute(executeArgs?: BaseExecuteArgs): Promise<unknown>;
71-
7239
/**
7340
* Subclasses implement to build the command arguments.
7441
*/

‎src/managers/builtin/pipPackageManager.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
PythonEnvironment,
2222
PythonEnvironmentApi,
2323
} from '../../api';
24+
import { withProgress } from '../../common/window.apis';
2425
import { CommandConstructorOptions } from '../base/commands/index';
2526
import { updatePackagesAndNotify } from '../common/packageChanges';
2627
import { createPipOrUvCommand } from './commands/factory';
@@ -100,7 +101,10 @@ export class PipPackageManager implements PackageManager, Disposable {
100101
UvUninstallCommand,
101102
);
102103
const packages = parsePackageSpecs(toUninstall);
103-
await uninstallCmd.executeWithProgress({ packages, showProgress: true }, 'Installing packages');
104+
await withProgress(
105+
{ location: ProgressLocation.Notification, title: 'Installing packages', cancellable: true },
106+
(_progress, token) => uninstallCmd.execute({ packages, cancellationToken: token }),
107+
);
104108
}
105109

106110
// Execute install if needed
@@ -111,9 +115,10 @@ export class PipPackageManager implements PackageManager, Disposable {
111115
UvInstallCommand,
112116
);
113117
const packages = parsePackageSpecs(toInstall);
114-
await installCmd.executeWithProgress(
115-
{ packages, upgrade: options.upgrade, showProgress: true },
116-
'Installing packages',
118+
await withProgress(
119+
{ location: ProgressLocation.Notification, title: 'Installing packages', cancellable: true },
120+
(_progress, token) =>
121+
installCmd.execute({ packages, upgrade: options.upgrade, cancellationToken: token }),
117122
);
118123
}
119124

‎src/managers/builtin/pipUtils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export async function getWorkspacePackagesToInstall(
284284
PipListCommand,
285285
UvListCommand,
286286
);
287-
const data = await listCmd.executeWithProgress<{ name: string }[]>({ showProgress: true });
287+
const data = await listCmd.execute();
288288
installed = data?.map((pkg) => pkg.name);
289289
}
290290
common = mergePackages(common, installed ?? []);

0 commit comments

Comments
 (0)