-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vscode): retry mechanism for extensions installation
- Loading branch information
Showing
2 changed files
with
78 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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,76 @@ | ||
#!/bin/bash | ||
|
||
# Number of retries | ||
retries=3 | ||
# Wait time between retries | ||
wait_time=10 | ||
|
||
# Function to install an extension with retries | ||
install_extension() { | ||
local extension=$1 | ||
local attempt=1 | ||
|
||
while [ $attempt -le $retries ]; do | ||
code-server --install-extension $extension && break | ||
echo "Failed to install $extension. Attempt $attempt/$retries. Retrying in $wait_time seconds..." | ||
attempt=$((attempt + 1)) | ||
sleep $wait_time | ||
done | ||
|
||
if [ $attempt -gt $retries ]; then | ||
echo "Failed to install $extension after $retries attempts." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Install base extensions | ||
base_extensions=( | ||
"ms-toolsai.jupyter" | ||
"ms-kubernetes-tools.vscode-kubernetes-tools" | ||
"mhutchie.git-graph" | ||
"hediet.vscode-drawio" | ||
"streetsidesoftware.code-spell-checker" | ||
"streetsidesoftware.code-spell-checker-french" | ||
) | ||
for extension in "${base_extensions[@]}"; do | ||
install_extension $extension | ||
done | ||
|
||
# Python-specific configuration | ||
python_extensions=( | ||
"ms-python.python" | ||
"ms-python.flake8" | ||
) | ||
if command -v python &> /dev/null; then | ||
for extension in "${python_extensions[@]}"; do | ||
install_extension $extension | ||
done | ||
python_path=$(which python) | ||
jq --arg pythonPath "$python_path" '.["python.defaultInterpreterPath"] = $pythonPath' ${REMOTE_CONFIG_DIR}/settings.json > tmp.json && mv tmp.json ${REMOTE_CONFIG_DIR}/settings.json | ||
fi | ||
|
||
# R-specific configuration | ||
r_extensions=( | ||
"reditorsupport.r" | ||
"RDebugger.r-debugger" | ||
) | ||
if command -v R &> /dev/null; then | ||
for extension in "${r_extensions[@]}"; do | ||
install_extension $extension | ||
done | ||
R -e "install.packages(c('languageserver', 'rmarkdown', 'httpgd'))" | ||
R -e "remotes::install_github('ManuelHentschel/vscDebugger')" | ||
pip install radian | ||
r_path=$(which radian) | ||
jq --arg rPath "$r_path" '.["r.rterm.linux"] = $rPath' ${REMOTE_CONFIG_DIR}/settings.json > tmp.json && mv tmp.json ${REMOTE_CONFIG_DIR}/settings.json | ||
fi | ||
|
||
# Julia-specific configuration | ||
if command -v julia &> /dev/null; then | ||
install_extension "julialang.language-julia" | ||
fi | ||
|
||
# Quarto-specific configuration | ||
if command -v quarto &> /dev/null; then | ||
install_extension "quarto.quarto" | ||
fi |
This file contains 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