Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat(code-server): install extensions from .vscode/extensions.json #231

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Apr 19, 2024

Add a new flag auto_install_extensions which auto installed the recommended extensions found in .vscode/extensions.json

Example .vscode/extensions.json

{
    "recommendations": [
        "hashicorp.terraform"
    ]
}

Example terraform template snippet

module "code-server" {
 source                   = "registry.coder.com/modules/code-server/coder"
  version                 = "1.0.13"
  agent_id                = coder_agent.main.id
  folder                  = "/home/${local.username}/modules"
  install_prefix          = "/home/${local.username}/.code-server"
  extensions_dir          = "/home/${local.username}/.code-server/extensions"
  use_cached              = true
  auto_install_extensions = true
}

Example output

Screenshot 2024-04-18 at 11 03 07 PM

NOTES

  • This does require jq to be installed on the workspace
  • This will look in the $HOME directory for .vscode/extensions.json if folder is not set
  • For performance of restarts (using use_cached and extensions_dir together helps)

closes #206

@michaelbrewer michaelbrewer changed the title feat(code-server): auto install extensions feat(code-server): install .vscode/extensions.json Apr 23, 2024
@michaelbrewer michaelbrewer changed the title feat(code-server): install .vscode/extensions.json feat(code-server): install extensions from .vscode/extensions.json Apr 23, 2024
@matifali matifali requested a review from code-asher April 24, 2024 16:47
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Neat!

fi

if ! command -v jq > /dev/null; then
echo "jq is required to install extensions from a workspace file."
Copy link
Member

@code-asher code-asher Apr 24, 2024

Choose a reason for hiding this comment

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

Not sure if this is overkill, but we could use the Node bundled with code-server.

extensions=$("$INSTALL_PREFIX/lib/node" -e "require(\"$WORKSPACE_DIR/.vscode/extensions.json\").recommendations.forEach((r) => console.log(r))")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I do like jq, but if we know the path to node and it should always be present, then it makes sense.

@michaelbrewer
Copy link
Contributor Author

@code-asher i am not 100% convinced about the flag auto_install_extensions, if it makes sense i will keep it,

I will back port these features to the vscode-web module to people can easily switch between the 2 versions.

@code-asher
Copy link
Member

i am not 100% convinced about the flag auto_install_extensions, if it makes sense i will keep it,

I think code-server/VS Code already offers to install the recommended extensions after you open a project, right? But this can cut down on the perceived time it takes to get coding, so I feel it is a worthwhile addition.

@michaelbrewer
Copy link
Contributor Author

More of the naming of the flag.

I like the intention of this, as it allows for the get repo to specify what it wants.

@matifali matifali merged commit b686f2d into coder:main Apr 26, 2024
2 checks passed
@code-asher
Copy link
Member

More of the naming of the flag.

Ohh yeah I see, I think the name is good.

@michaelbrewer michaelbrewer deleted the feat/code-server-extension-auto branch April 27, 2024 05:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(code-server): option to auto-install recommended extensions from extensions.json
3 participants