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

cli: introduce exclude id list for extension-packs #9956

Merged
merged 3 commits into from
Aug 26, 2021

Conversation

vince-fugnitto
Copy link
Member

@vince-fugnitto vince-fugnitto commented Aug 24, 2021

What it does

The pull-request introduces a mechanism to exclude extensions by id when resolving builtin extension-packs. The purpose is to allow application developers the flexibility to use extension-packs but still have the control to exclude problematic or unwanted extensions that may be referenced by the pack. Previously, post-processing would be necessary to remove such extensions, for example by deleting the plugin in the plugins directory before a build.

The changes introduce theiaPluginsExcludeIds which lists extensions by id and is used to exclude extensions when resolving extension-packs.

How to test

"theiaPlugins": {
  "pack": "https://github.com/vince-fugnitto/vscode-builtin-extensionPack/releases/download/0.0.1/builtin-extension-pack-1.45.1.vsix"
},
"theiaPluginsExcludeIds": [
  "vscode.cpp"
]
  • execute the cli command yarn download:plugins
  • confirm that the pack is downloaded, and individual extensions are resolved
  • confirm that vscode.cpp is logged as skipped
  • confirm that vscode.cpp is not present under the plugins folder
  • rm -rf plugins/
  • repeat the command with theiaPluginsExcludeIds being omitted from the package.json - the command should pass and all referenced extensions should resolve

Example:

image

Review checklist

Reminder for reviewers

Signed-off-by: vince-fugnitto vincent.fugnitto@ericsson.com

@vince-fugnitto vince-fugnitto added theia-cli issues related to the theia-cli builtins Issues related to VS Code builtin extensions labels Aug 24, 2021
@vince-fugnitto vince-fugnitto self-assigned this Aug 24, 2021
@marcdumais-work
Copy link
Contributor

Looks nice, thanks @vince-fugnitto .

Looking at how this works, I am reminded of another use-case, beyond extension packs. Let's say that there is an extension you like but for some reasons it's not working well ATM, or an extension already in package.json stops working correctly, the only way forward ATM is to not have it mentioned in package.json.

If this PR was made slightly more generic, so that the exclusion works when downloading extensions, not just extension packs, one could instead add it or keep it, and also exclude it, until it works as wanted. Then one needs only remove the exclusion instead of thinking adding the extension.

WDYT?

Copy link
Contributor

@alvsan09 alvsan09 left a comment

Choose a reason for hiding this comment

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

I have tested the CLI and validated that the plugins are successfully excluded.
exclude_extensions_from_pack

However, if I then try to start the IDE, I can see in the log entries that those plugins are downloaded to the tmp/.. folder and loaded from there, see:
deploying_plugins_

dev-packages/cli/README.md Show resolved Hide resolved
dev-packages/cli/src/download-plugins.ts Outdated Show resolved Hide resolved
@vince-fugnitto
Copy link
Member Author

Looking at how this works, I am reminded of another use-case, beyond extension packs. Let's say that there is an extension you like but for some reasons it's not working well ATM, or an extension already in package.json stops working correctly, the only way forward ATM is to not have it mentioned in package.json.

If this PR was made slightly more generic, so that the exclusion works when downloading extensions, not just extension packs, one could instead add it or keep it, and also exclude it, until it works as wanted. Then one needs only remove the exclusion instead of thinking adding the extension.

WDYT?

@marcdumais-work I was thinking of that use-case but I did not see a reason as to why they would list an extension under theiaPlugins but want to exclude it as part of theiaPluginsExcludeIds. It would make more sense to me to simply not reference it in the first place.

Also, we use a arbitrary name: url for theiaPlugins mapping so it means that we would first need to download the plugins under then delete them off the filesystem if we scan the extensions and see an id in the exclude lists.

@marcdumais-work
Copy link
Contributor

However, if I then try to start the IDE, I can see in the log entries that those plugins are downloaded to the tmp/.. folder and loaded from there, see:
deploying_plugins_

Good catch! I guess at runtime we resolve the pack again, and helpfully download anything that might have been missed at build-time :)

@marcdumais-work
Copy link
Contributor

Also, we use a arbitrary name: url for theiaPlugins mapping so it means that we would first need to download the plugins under then delete them off the filesystem if we scan the extensions and see an id in the exclude lists.

I have been thinking that the way we specify plugins by URL is a bit dated - we should maybe support by id, but that's for another PR.

@vince-fugnitto
Copy link
Member Author

vince-fugnitto commented Aug 24, 2021

Also, we use a arbitrary name: url for theiaPlugins mapping so it means that we would first need to download the plugins under then delete them off the filesystem if we scan the extensions and see an id in the exclude lists.

I have been thinking that the way we specify plugins by URL is a bit dated - we should maybe support by id, but that's for another PR.

@marcdumais-work we could, but it means that we can no longer reference a specific version of a builtin anymore. An application may choose to support a specific builtin version, and not have the framework resolve it to the latest API.

@vince-fugnitto vince-fugnitto force-pushed the vf/download-plugins-exclude branch 6 times, most recently from 8ad3a97 to 5448ab0 Compare August 25, 2021 16:43
@vince-fugnitto
Copy link
Member Author

@marcdumais-work @alvsan09 the pull-request is ready for another review.
I updated the functionality based on feedback (and refactored the methods for handling extension-packs) to hopefully make it clearer.

I also fixed the issue were extension-packs referenced as builtins are resolved at runtime by removing them from the plugins folder after we complete the resolvement and download of the ids they reference at buildtime.

@marcdumais-work
Copy link
Contributor

@alvsan09 If you can, please re-test and approve - I'd like to get this part of this month's release

Copy link
Contributor

@alvsan09 alvsan09 left a comment

Choose a reason for hiding this comment

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

I have validated the solution, it works as expected! 👍
The code refactoring looks good to me!
Thanks Vince !!

The commit introduces additional functionality when downloading
extension-packs so end-users have the ability to declare extensions (by
id) they wish to exclude when resolving packs. Previously no mechanism
was available to exclude extensions pulled by packs besides using
post-processing such as deleting plugins from the plugin directory
before building.

Extensions referenced by id in `theiaPluginsExcludeIds` will be excluded
when we resolve extension-packs.

Once `ids` of an extension-pack are resolved, the script will handle
removing them from the download folder so the framework does not attempt
to re-resolve them at runtime.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
@vince-fugnitto vince-fugnitto merged commit 5cc8eaf into master Aug 26, 2021
@vince-fugnitto vince-fugnitto deleted the vf/download-plugins-exclude branch August 26, 2021 16:03
@github-actions github-actions bot added this to the 1.17.0 milestone Aug 26, 2021
@vince-fugnitto vince-fugnitto mentioned this pull request Aug 26, 2021
1 task
RomanNikitenko pushed a commit that referenced this pull request Sep 16, 2021
The commit introduces the ability to declare the list of plugin ids which should be explicitly excluded when we perform a download. The list of excluded plugin ids are used when we attempt to resolve plugins declared in extension-packs (extension-packs refer to plugins they wish to pull by id) but we want to exclude some problematic or unwanted plugins. This gives users the flexibility to consume extension-packs as builtins, but also be able to explicitly exclude ids they do not wish to pull as part of their application.

The `download:plugins` script was also refactored in order to make things clearer, more robust with better performance:
- extension-pack plugins are resolved and downloaded in parallel.
- if a pack is previously downloaded (and moved under the download folder at `.packs`) we will not re-download it or resolve it.
- the framework will not attempt to re-resolve packs at runtime, meaning excluded plugins will not re-appear.
- improved logging of the overall download and operations.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
Co-authored-by: Paul Marechal <paul.marechal@ericsson.com>
RomanNikitenko pushed a commit that referenced this pull request Sep 16, 2021
The commit introduces the ability to declare the list of plugin ids which should be explicitly excluded when we perform a download. The list of excluded plugin ids are used when we attempt to resolve plugins declared in extension-packs (extension-packs refer to plugins they wish to pull by id) but we want to exclude some problematic or unwanted plugins. This gives users the flexibility to consume extension-packs as builtins, but also be able to explicitly exclude ids they do not wish to pull as part of their application.

The `download:plugins` script was also refactored in order to make things clearer, more robust with better performance:
- extension-pack plugins are resolved and downloaded in parallel.
- if a pack is previously downloaded (and moved under the download folder at `.packs`) we will not re-download it or resolve it.
- the framework will not attempt to re-resolve packs at runtime, meaning excluded plugins will not re-appear.
- improved logging of the overall download and operations.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
Co-authored-by: Paul Marechal <paul.marechal@ericsson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins Issues related to VS Code builtin extensions theia-cli issues related to the theia-cli
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants