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

#982: Add recommendation feature and clean setup option to vscode #990

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/ide[devonf

Release with small but important bugfixes:

* https://github.com/devonfw/ide/issues/982[#982]: Add recommendation feature and clean setup option to vscode
* https://github.com/devonfw/ide/issues/966[#966]: npm detection not reliable and redundant
* https://github.com/devonfw/ide/issues/954[#954]: First install removes all folders from user path
* https://github.com/devonfw/ide/issues/956[#956]: no matches found error if software folder missing
Expand Down
5 changes: 3 additions & 2 deletions documentation/vscode.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ You may also supply additional arguments as `devon vscode «args»`. These are e
|`ws-re[verse]` |reverse merge changes from workspace into settings
|`ws-reverse-add`|reverse merge adding new properties
|`create-script` |create launch script for this IDE, your current workspace and your OS
|`clean-setup` |clean VSCode setup without plugins and recommendations
|=======================


Expand All @@ -42,7 +43,7 @@ The variables are defined as following:

In general you should try to stick with the configuration pre-defined by your project. But some plugins may be considered as personal flavor and are typically not predefined by the project config. Such plugins should be shipped with your link:settings.asciidoc[settings] as described above with `plugin_active=false` allowing you to easily install it manually. Surely, you can easily add plugins via the UI of VS code. However, be aware that some plugins may collect sensitive data or could introduce other vulnerabilities. So consider the governance of your project and talk to your technical lead before installing additional plugins that are not pre-defined in your link:settings.asciidoc[settings].

As maintainer of the link:settings.asciidoc[settings] for your project you should avoid to ship too many plugins that may waste resources but are not used by every developer. By configuring additional plugins with `plugin_active=false` you can give your developers the freedom to install some additional plugins easily.
As maintainer of the link:settings.asciidoc[settings] for your project you should avoid to ship too many plugins that may waste resources but are not used by every developer. By configuring additional plugins with `plugin_active=false` you can give your developers the freedom to install some additional plugins easily. In addition, deactivated plugins are recommended to the user by an existing link:https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions[feature] of VS Code via prompt.

=== cleaning plugins on update

Expand All @@ -51,4 +52,4 @@ If you want to strictly manage the plugins for `VS code` in your project, you ca
clean_plugins_on_update=true
```

This will wipe all plugins when an update of `VS code` is performed (e.g. via `devon ide update`) and reinstall all configured plugins. While this gives you more control over the governance of the plugins and allows to remove a plugin later during project lifecycle. However, this will delete all manually installed plugins automatically without asking.
This will wipe all plugins when an update of `VS code` is performed (e.g. via `devon ide update`) and reinstall all configured plugins. While this gives you more control over the governance of the plugins and allows to remove a plugin later during project lifecycle. However, this will delete all manually installed plugins automatically without asking.
30 changes: 30 additions & 0 deletions scripts/src/main/resources/scripts/command/vscode
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ function doSetup() {
fi
}

function doCleanSetup() {
doInstall "vscode" "${VSCODE_VERSION}" "${1}"
}

function cleanupPlugins() {
clean_plugins_on_update="false"
doLoadProperties "${SETTINGS_PATH}"/vscode/vscode.properties
Expand All @@ -48,6 +52,7 @@ function cleanupPlugins() {
function doAddPlugins() {
local file
local pluginsToInstall=()
local pluginsToRecommend=()
for file in "${SETTINGS_PATH}"/vscode/plugins/*.properties
do
if [ -f "${file}" ]
Expand All @@ -61,13 +66,20 @@ function doAddPlugins() {
elif [ "${plugin_active}" = "true" ]
then
pluginsToInstall+=("${plugin_id}")
else
pluginsToRecommend+=("\"${plugin_id}\"")
fi
fi
done
if [ "${#pluginsToInstall}" -gt 0 ]
then
doAddPlugin "${pluginsToInstall[@]}"
fi
if [ "${#pluginsToRecommend}" -gt 0 ]
then
local IFS=,
doAddRecommendations "${pluginsToRecommend[*]}"
fi
}

function doAddPlugin() {
Expand Down Expand Up @@ -126,6 +138,18 @@ function doStartVsCode() {
doRunVsCode "${WORKSPACE_PATH}"
}

function doAddRecommendations() {
doEcho "add recommendations..."
local extensions="${WORKSPACE_PATH}/.vscode/extensions.json"
if [ -f "${extensions}" ]
then
rm "${extensions}"
echo "{\"recommendations\":[${1}]}" >> "${extensions}"
else
echo "{\"recommendations\":[${1}]}" >> "${extensions}"
fi
}

# CLI
if [ "${1}" = "-h" ] || [ "${1}" = "help" ]
then
Expand All @@ -140,6 +164,7 @@ then
echo " ws-re[verse] reverse merge changes from workspace into settings"
echo " ws-reverse-add reverse merge adding new properties"
echo " create-script create vscode-${WORKSPACE} script if not already exists"
echo " clean-setup clean VSCode setup without plugins and recommendations"
exit
fi
if [ -z "${1}" ]
Expand Down Expand Up @@ -180,6 +205,11 @@ do
shift
doAddPlugin "${@}"
exit ${?}
elif [ "${1}" = "clean-setup" ]
then
doCleanSetup "${2}"
doStartVsCode
exit
else
doFail "Undefined argument: ${1}"
fi
Expand Down