Skip to content
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

Support version for installExtension, support uninstall cmd #14298

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dhuebner
Copy link
Member

What it does

Allows to use version when executing workbench.extensions.installExtension command in format <extensionId>@<version> #13795
Adds support for workbench.extensions.uninstallExtension command #13796

How to test

Run uninstall on some installed extension. extension.uninstall now uses the new workbench.extensions.uninstallExtension under the hood.

Install command workbench.extensions.installExtension is currently not used in Theia with a string parameter, one need to create a separate command.

Follow-ups

Review checklist

Reminder for reviewers

@dhuebner dhuebner requested a review from tsmaeder October 11, 2024 13:50
@@ -81,4 +81,31 @@ export namespace PluginIdentifiers {
}
return { id: probablyId.slice(0, endOfName) as UnversionedId, version: probablyId.slice(endOfName + 1) };
}

const EXTENSION_IDENTIFIER_WITH_VERSION_REGEX = /^([^.]+\..+)@((prerelease)|(\d+\.\d+\.\d+(-.*)?))$/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessarily restrictve, IMO: all we need to know here is what is before the '@' and what is after the '@'. Why introduce the added complexity? Also, regexes should always have a comment that describes what they are supposed to detect, Because no-one understands Regexes at first sight. If the id does not match the expression, you end up with the exact same result as before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same RegEx that is also used in vs-code, I thought it is a good idea to do the same.
I will add a comment to describe what is expected by this RegEx.

if (!id) {
throw new Error(nls.localizeByDefault('Extension id required.'));
}
if (!PluginIdentifiers.isVersionedId(id)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this makes sense from a user's perspective: while technically, we can have multiple versions of the same plugin installed, that's not how it's presented to the user: for them, you either have a plugin installed, or not, independent of the version, so we should probably pass a naked id here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PluginServer.uninstall() expects PluginIdentifiers.VersionedId parameter which is typed as ${string}.${string}@${string} that why it the code above makes sense to me.

that's not how it's presented to the user: for them, you either have a plugin installed, or not

The UNINSTALL_EXTENSION command is not presented to the user, but is used in theia/packages/vsx-registry/src/browser/vsx-extension.tsx where the versioned extension id is given.
I would prefer to keep require versioned id here.

@@ -324,8 +325,10 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
if (plugin) {
await this.progressService.withProgress(
nls.localizeByDefault('Uninstalling {0}...', this.id), 'extensions',
() => this.pluginServer.uninstall(PluginIdentifiers.componentsToVersionedId(plugin.metadata.model))
);
async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why go through the command here? Why stringify/destringify the id?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why go through the command here? Why stringify/destringify the id?

The implementation is moved to a command to resolve #13796 , now calling the new command to reduce code duplicates.

@tsmaeder
Copy link
Contributor

@dhuebner still some open questions on this one.

@dhuebner
Copy link
Member Author

@tsmaeder
Yes, I need to go through and answer. Will do it this week.

@dhuebner dhuebner force-pushed the dhuebner/install-with-version-13795 branch 2 times, most recently from 5dfc23e to 255a41e Compare December 6, 2024 11:38
@dhuebner dhuebner force-pushed the dhuebner/install-with-version-13795 branch from f9a0ca7 to ad3cd23 Compare December 6, 2024 11:50
@dhuebner
Copy link
Member Author

dhuebner commented Dec 6, 2024

@tsmaeder
Please find my answers above.
I removed the organize imports changes and added comments to the RegEx. Also re-based on current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

2 participants