-
Notifications
You must be signed in to change notification settings - Fork 54
[WIP] Complete package manager command class refactoring #1621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
edvilme
wants to merge
44
commits into
main
Choose a base branch
from
package-manager-command-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
720bede
temp
edvilme d9f2cf2
Implement three-level class-based package manager command architecture
edvilme d08b7bd
Integrate command classes with pipPackageManager - Phase 1: Pip/UV
edvilme f3bd8f9
Remove unused executor pattern and old pip management code
edvilme 5e5c45d
Implement conda install/uninstall commands and remove managePackages …
edvilme 7179cf0
Refactor pipPackageManager to use command classes for all operations
edvilme 2a80488
Complete conda integration with List, Version, and AvailableVersions …
edvilme 5569d50
Integrate Poetry command classes into poetryPackageManager
edvilme cf49062
Add documentation comments to Poetry command classes with parsed comm…
edvilme 76a598f
Move JSDoc comments from interfaces to command classes
edvilme 1890ef3
Add documentation comments to all command classes across all package …
edvilme 83d6bc6
Refactor utils to use command classes directly instead of helper func…
edvilme 1c0fe0e
Expose base command classes to public API
edvilme 790fef6
Remove CommandType and CommandSettings from command classes
edvilme a0bc056
Add timeout and config properties to base command classes
edvilme e5d22c6
Centralize ephemeral arguments to base command classes
edvilme 1edb7dd
Make execute methods conform to ephemeral argument interfaces
edvilme 4b9e8d2
Lint
edvilme 7521fcc
Rename ephemeralArgs to executeArgs for clarity
edvilme 279fcd0
Rename commandSettings.ts to packageManagerCommand.ts and remove unus…
edvilme 5db7455
Move timeout default to PackageManagerCommand base class
edvilme 4264f04
Centralize configuration loading to PackageManagerCommand base class
edvilme 42f9347
Centralize CommandConstructorOptions at method level for install/unin…
edvilme 8246246
Refactor package manager command execution args and cancellation toke…
edvilme 0858f85
runPython: Do not return error
edvilme 15ab7f3
Remove unnecessary params
edvilme 4e2eefb
Extract showProgress
edvilme 0157a2a
Remove unused method
edvilme cae697f
Use uv directly for builtin commands
edvilme d577bcc
Refactor base commands to use static config sections
edvilme 34a1c29
Lint
edvilme 493bc79
Lint
edvilme 52cda03
Move runPoetry to poetryUtils to avoid circular dependencies
edvilme 42e1dde
Conda/getPackageAvailableVersions sort
edvilme 39984bd
Potential fix for pull request finding
edvilme 14afd71
Honow cwd on poetry show
edvilme b2fe44b
Address PR review comments for package manager command refactor
edvilme cebca53
Remove package manager command class exports from public api.ts
edvilme 3851bdd
Refactor
edvilme cbdbc91
Remove SETTINGS_ARCHITECTURE.md
edvilme 8b0dd64
Merge branch 'main' into package-manager-command-refactor
edvilme ada417f
Remove unused file
edvilme 349101c
Address PR Comments
edvilme 9b2683e
Restore optional settings property
edvilme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { BaseExecuteArgs, PackageManagerCommand } from './packageManagerCommand'; | ||
|
|
||
| /** | ||
| * Arguments for available versions command execution (change per execution). | ||
| */ | ||
| export interface AvailableVersionsExecuteArgs extends BaseExecuteArgs { | ||
| packageName: string; | ||
| pythonVersion: string; | ||
| includePrerelease?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Template class for availableVersions commands. | ||
| * Subclasses implement concrete package-manager-specific logic. | ||
| */ | ||
| export abstract class AvailableVersionsCommand extends PackageManagerCommand { | ||
| protected static readonly configSection = 'availableVersionsCommandArgs'; | ||
|
|
||
| protected abstract buildCommand(executeArgs: AvailableVersionsExecuteArgs): string[]; | ||
|
|
||
| abstract execute(executeArgs: AvailableVersionsExecuteArgs): Promise<string[]>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export { AvailableVersionsCommand, type AvailableVersionsExecuteArgs } from './availableVersions'; | ||
| export { InstallCommand, type InstallExecuteArgs } from './install'; | ||
| export { ListCommand } from './list'; | ||
| export { ListDirectNamesCommand } from './listDirectNames'; | ||
| export { BaseExecuteArgs, CommandConstructorOptions, PackageManagerCommand } from './packageManagerCommand'; | ||
| export { UninstallCommand, type UninstallExecuteArgs } from './uninstall'; | ||
| export { VersionCommand } from './version'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { BaseExecuteArgs, PackageManagerCommand } from './packageManagerCommand'; | ||
|
|
||
| /** | ||
| * Arguments for install command execution (change per execution). | ||
| */ | ||
| export interface InstallExecuteArgs extends BaseExecuteArgs { | ||
| packages: { packageName: string; version?: string }[]; | ||
| upgrade?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Template class for install commands. | ||
| * Subclasses implement concrete package-manager-specific logic. | ||
| */ | ||
| export abstract class InstallCommand extends PackageManagerCommand { | ||
| protected static readonly configSection = 'installCommandArgs'; | ||
|
|
||
| protected abstract buildCommand(executeArgs: InstallExecuteArgs): string[]; | ||
|
|
||
| abstract execute(executeArgs: InstallExecuteArgs): Promise<void>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { PackageInfo } from '../../../api'; | ||
| import { BaseExecuteArgs, PackageManagerCommand } from './packageManagerCommand'; | ||
|
|
||
| /** | ||
| * Template class for list commands. | ||
| * Subclasses implement concrete package-manager-specific logic. | ||
| */ | ||
| export abstract class ListCommand extends PackageManagerCommand { | ||
| protected static readonly configSection = 'listCommandArgs'; | ||
|
|
||
| abstract execute(executeArgs?: BaseExecuteArgs): Promise<PackageInfo[]>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { BaseExecuteArgs, PackageManagerCommand } from './packageManagerCommand'; | ||
|
|
||
| /** | ||
| * Template class for listDirectNames commands. | ||
| * Subclasses implement concrete package-manager-specific logic. | ||
| */ | ||
| export abstract class ListDirectNamesCommand extends PackageManagerCommand { | ||
| protected static readonly configSection = 'listDirectNamesCommandArgs'; | ||
|
|
||
| abstract execute(executeArgs?: BaseExecuteArgs): Promise<string[]>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { CancellationToken, l10n, LogOutputChannel, ProgressLocation, window, WorkspaceConfiguration } from 'vscode'; | ||
| import { getConfiguration } from '../../../common/workspace.apis'; | ||
|
|
||
| /** | ||
| * Base interface for all command execute arguments. | ||
| * Provides optional cancellation token that all commands can use. | ||
| */ | ||
| export interface BaseExecuteArgs { | ||
| cancellationToken?: CancellationToken; | ||
| showProgress?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Constructor options shared by all package manager commands. | ||
| */ | ||
| export interface CommandConstructorOptions { | ||
| pythonExecutable: string; | ||
| configSection?: string; | ||
| log?: LogOutputChannel; | ||
| } | ||
|
|
||
| /** | ||
| * Base class for all package manager commands. | ||
| * Provides common properties and minimal interface for subclasses. | ||
| */ | ||
| export abstract class PackageManagerCommand { | ||
| protected static readonly configSection?: string; | ||
|
|
||
| protected pythonExecutable: string; | ||
| protected log?: LogOutputChannel; | ||
| protected timeout: number = 300000; | ||
| protected config?: WorkspaceConfiguration; | ||
|
|
||
| constructor(options: CommandConstructorOptions) { | ||
| this.pythonExecutable = options.pythonExecutable; | ||
| this.log = options.log; | ||
| const configSection = options.configSection ?? (this.constructor as typeof PackageManagerCommand).configSection; | ||
| this.config = configSection ? getConfiguration(`python-envs.packageManager.${configSection}`) : undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Executes this command and optionally wraps execution with a progress indicator. | ||
| */ | ||
| public executeWithProgress<T = unknown, A extends BaseExecuteArgs = BaseExecuteArgs>( | ||
| executeArgs?: A, | ||
| title?: string, | ||
| ): Promise<T> { | ||
| if (!executeArgs?.showProgress) { | ||
| return this.execute(executeArgs) as Promise<T>; | ||
| } | ||
|
|
||
| return Promise.resolve( | ||
| window.withProgress( | ||
| { | ||
| location: ProgressLocation.Notification, | ||
| title: title ?? l10n.t('Running package manager command'), | ||
| cancellable: true, | ||
| }, | ||
| (_progress, token) => | ||
| this.execute({ | ||
| ...executeArgs, | ||
| cancellationToken: executeArgs.cancellationToken ?? token, | ||
| }) as Promise<T>, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Subclasses implement command execution. | ||
| */ | ||
| abstract execute(executeArgs?: BaseExecuteArgs): Promise<unknown>; | ||
|
|
||
| /** | ||
| * Subclasses implement to build the command arguments. | ||
| */ | ||
| protected abstract buildCommand(executeArgs: BaseExecuteArgs): string[]; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { BaseExecuteArgs, PackageManagerCommand } from './packageManagerCommand'; | ||
|
|
||
| /** | ||
| * Arguments for uninstall command execution (change per execution). | ||
| */ | ||
| export interface UninstallExecuteArgs extends BaseExecuteArgs { | ||
| packages: { packageName: string; version?: string }[]; | ||
| } | ||
|
|
||
| /** | ||
| * Template class for uninstall commands. | ||
| * Subclasses implement concrete package-manager-specific logic. | ||
| */ | ||
| export abstract class UninstallCommand extends PackageManagerCommand { | ||
| protected static readonly configSection = 'uninstallCommandArgs'; | ||
|
|
||
| protected abstract buildCommand(executeArgs: UninstallExecuteArgs): string[]; | ||
|
|
||
| abstract execute(executeArgs: UninstallExecuteArgs): Promise<void>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { Pep440Version } from '@renovatebot/pep440'; | ||
| import { BaseExecuteArgs, PackageManagerCommand } from './packageManagerCommand'; | ||
|
|
||
| /** | ||
| * Template class for version commands. | ||
| * Subclasses implement concrete package-manager-specific logic. | ||
| */ | ||
| export abstract class VersionCommand extends PackageManagerCommand { | ||
| protected static readonly configSection = 'versionCommandArgs'; | ||
|
|
||
| abstract execute(executeArgs?: BaseExecuteArgs): Promise<Pep440Version | undefined>; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.