Skip to content

Add extensions support for vscode-web #154

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

Merged
merged 21 commits into from
Feb 23, 2024
Merged

Add extensions support for vscode-web #154

merged 21 commits into from
Feb 23, 2024

Conversation

matifali
Copy link
Member

@matifali matifali commented Feb 13, 2024

This pull request adds support for installing extensions in vscode-web.
closes #153

  • Test
  • fix tests merging without tests for now.

How to test

module "vscode-web" {
  source         = "git::https://github.com/coder/modules.git//vscode-web?ref=vscode-web-extensions"
  agent_id       = coder_agent.example.id
  extensions     = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
  accept_license = true
}

@matifali matifali self-assigned this Feb 13, 2024
@matifali matifali marked this pull request as draft February 13, 2024 11:13
@matifali matifali marked this pull request as ready for review February 13, 2024 12:23
Comment on lines +34 to +44
IFS=',' read -r -a EXTENSIONLIST <<< "$${EXTENSIONS}"
for extension in "$${EXTENSIONLIST[@]}"; do
if [ -z "$extension" ]; then
continue
fi
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
output=$($VSCODE_SERVER --install-extension "$extension" --force)
if [ $? -ne 0 ]; then
echo "Failed to install extension: $extension: $output"
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

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

Given:

EXTENSIONS="foo,bar,baz"

I would suggest the following posix way, so we don't need to rely on bash/arrays.

Suggested change
IFS=',' read -r -a EXTENSIONLIST <<< "$${EXTENSIONS}"
for extension in "$${EXTENSIONLIST[@]}"; do
if [ -z "$extension" ]; then
continue
fi
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
output=$($VSCODE_SERVER --install-extension "$extension" --force)
if [ $? -ne 0 ]; then
echo "Failed to install extension: $extension: $output"
exit 1
fi
extension=
while [ "$${extension}" != "$${EXTENSIONS}" ]; do
extension=$${EXTENSIONS%%,*}
EXTENSIONS=$${EXTENSIONS#*,}
if [ -z "$${extension}" ]; then
continue
fi
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n"
output=$("$${VSCODE_SERVER}" --install-extension "$${extension}" --force)
if [ $? -ne 0 ]; then
echo "Failed to install extension: $${extension}: $${output}"
exit 1
fi

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 section is borrowed from code-server, and I did not try to improve it as code-server is our top downloaded module and well tested. But I agree and we can update.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mafredri, any second thoughts? Otherwise I should also update code-server module.

matifali and others added 5 commits February 13, 2024 15:47
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
@matifali matifali merged commit 4b04d18 into main Feb 23, 2024
@matifali matifali deleted the vscode-web-extensions branch February 23, 2024 12:02
@matifali
Copy link
Member Author

@mafredri I removed the tests as our modification to run commands was causing many other tests to fail.
We can add tests again in a separate PR.

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

Successfully merging this pull request may close these issues.

update vscode-web module to support installing extensions.
2 participants