From b18b2635020661d22d6c83b5773e1b8ace188e13 Mon Sep 17 00:00:00 2001 From: hunnywar Date: Sun, 12 Jan 2025 13:29:26 +0530 Subject: [PATCH] feat: add support for VSCodium Insiders Signed-off-by: hunnywar --- cmd/daytona/config/const.go | 1 + docs/daytona_code.md | 2 +- docs/daytona_create.md | 2 +- hack/docs/daytona_code.yaml | 2 +- hack/docs/daytona_create.yaml | 2 +- pkg/cmd/ide.go | 5 +++ pkg/cmd/workspace/code.go | 2 ++ pkg/ide/vscodium-insiders.go | 67 +++++++++++++++++++++++++++++++++++ 8 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 pkg/ide/vscodium-insiders.go diff --git a/cmd/daytona/config/const.go b/cmd/daytona/config/const.go index 86c6886002..243a32683b 100644 --- a/cmd/daytona/config/const.go +++ b/cmd/daytona/config/const.go @@ -29,6 +29,7 @@ func GetIdeList() []Ide { {"browser", "VS Code - Browser"}, {"cursor", "Cursor"}, {"codium", "VSCodium"}, + {"codium-insiders", "VSCodium Insiders"}, {"ssh", "Terminal SSH"}, {"jupyter", "Jupyter"}, {"fleet", "Fleet"}, diff --git a/docs/daytona_code.md b/docs/daytona_code.md index 9da23b8960..a37f6d179b 100644 --- a/docs/daytona_code.md +++ b/docs/daytona_code.md @@ -9,7 +9,7 @@ daytona code [WORKSPACE] [PROJECT] [flags] ### Options ``` - -i, --ide string Specify the IDE (vscode, code-insiders, browser, cursor, codium, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + -i, --ide string Specify the IDE (vscode, code-insiders, browser, cursor, codium, codium-insiders, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) -y, --yes Automatically confirm any prompts ``` diff --git a/docs/daytona_create.md b/docs/daytona_create.md index b920343675..03f852d4df 100644 --- a/docs/daytona_create.md +++ b/docs/daytona_create.md @@ -17,7 +17,7 @@ daytona create [REPOSITORY_URL | PROJECT_CONFIG_NAME]... [flags] --devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value --env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...') --git-provider-config string Specify the Git provider configuration ID or alias - -i, --ide string Specify the IDE (vscode, code-insiders, browser, cursor, codium, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + -i, --ide string Specify the IDE (vscode, code-insiders, browser, cursor, codium, codium-insiders, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) --manual Manually enter the Git repository --multi-project Workspace with multiple projects/repos --name string Specify the workspace name diff --git a/hack/docs/daytona_code.yaml b/hack/docs/daytona_code.yaml index 408fb1f161..049123a7d7 100644 --- a/hack/docs/daytona_code.yaml +++ b/hack/docs/daytona_code.yaml @@ -5,7 +5,7 @@ options: - name: ide shorthand: i usage: | - Specify the IDE (vscode, code-insiders, browser, cursor, codium, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + Specify the IDE (vscode, code-insiders, browser, cursor, codium, codium-insiders, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) - name: "yes" shorthand: "y" default_value: "false" diff --git a/hack/docs/daytona_create.yaml b/hack/docs/daytona_create.yaml index ae77e59b35..d8afd7b6ab 100644 --- a/hack/docs/daytona_create.yaml +++ b/hack/docs/daytona_create.yaml @@ -28,7 +28,7 @@ options: - name: ide shorthand: i usage: | - Specify the IDE (vscode, code-insiders, browser, cursor, codium, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + Specify the IDE (vscode, code-insiders, browser, cursor, codium, codium-insiders, ssh, jupyter, fleet, positron, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) - name: manual default_value: "false" usage: Manually enter the Git repository diff --git a/pkg/cmd/ide.go b/pkg/cmd/ide.go index ff75569847..788415f1fb 100644 --- a/pkg/cmd/ide.go +++ b/pkg/cmd/ide.go @@ -56,6 +56,11 @@ var ideCmd = &cobra.Command{ if err != nil { log.Error(err) } + case "codium-insiders": + _, err := ide_util.GetCodiumInsidersBinaryPath() + if err != nil { + log.Error(err) + } case "cursor": _, err := ide_util.GetCursorBinaryPath() if err != nil { diff --git a/pkg/cmd/workspace/code.go b/pkg/cmd/workspace/code.go index 6203320c98..74e0fb4df3 100644 --- a/pkg/cmd/workspace/code.go +++ b/pkg/cmd/workspace/code.go @@ -189,6 +189,8 @@ func openIDE(ideId string, activeProfile config.Profile, workspaceId string, pro return ide.OpenBrowserIDE(activeProfile, workspaceId, projectName, projectProviderMetadata, gpgKey) case "codium": return ide.OpenVScodium(activeProfile, workspaceId, projectName, projectProviderMetadata, gpgKey) + case "codium-insiders": + return ide.OpenVScodiumInsiders(activeProfile, workspaceId, projectName, projectProviderMetadata, gpgKey) case "cursor": return ide.OpenCursor(activeProfile, workspaceId, projectName, projectProviderMetadata, gpgKey) case "jupyter": diff --git a/pkg/ide/vscodium-insiders.go b/pkg/ide/vscodium-insiders.go new file mode 100644 index 0000000000..214e72cdcc --- /dev/null +++ b/pkg/ide/vscodium-insiders.go @@ -0,0 +1,67 @@ +// Copyright 2024 Daytona Platforms Inc. +// SPDX-License-Identifier: Apache-2.0 + +package ide + +import ( + "errors" + "fmt" + "os/exec" + + "github.com/daytonaio/daytona/cmd/daytona/config" + "github.com/daytonaio/daytona/internal/util" + "github.com/daytonaio/daytona/pkg/build/devcontainer" +) + +func OpenVScodiumInsiders(activeProfile config.Profile, workspaceId string, projectName string, projectProviderMetadata string, gpgkey string) error { + path, err := GetCodiumInsidersBinaryPath() + if err != nil { + return err + } + // Install the extension if not installed + err = installExtension(path, requiredExtension) + if err != nil { + return err + } + projectHostname := config.GetProjectHostname(activeProfile.Id, workspaceId, projectName) + + projectDir, err := util.GetProjectDir(activeProfile, workspaceId, projectName, gpgkey) + if err != nil { + return err + } + + commandArgument := fmt.Sprintf("vscode-remote://ssh-remote+%s/%s", projectHostname, projectDir) + + codiumInsidersCommand := exec.Command(path, "--disable-extension", "ms-vscode-remote.remote-containers", "--folder-uri", commandArgument) + + err = codiumInsidersCommand.Run() + if err != nil { + return err + } + + if projectProviderMetadata == "" { + return nil + } + + return setupVSCodeCustomizations(projectHostname, projectProviderMetadata, devcontainer.Vscode, "*/.vscodium-server-insiders/*/bin/codium-server-insiders", "$HOME/.vscodium-server-insiders/data/Machine/settings.json", ".daytona-customizations-lock-codium-insiders") +} + +func GetCodiumInsidersBinaryPath() (string, error) { + path, err := exec.LookPath("codium-insiders") + if err == nil { + return path, err + } + + redBold := "\033[1;31m" // ANSI escape code for red and bold + reset := "\033[0m" // ANSI escape code to reset text formatting + + errorMessage := "Please install VScodium Insiders from https://github.com/VSCodium/vscodium-insiders\n\n" + infoMessage := ` +If you have already installed VScodium Insiders, please ensure it is added to your PATH environment variable. +You can verify this by running the following command in your terminal: + + codium-insiders +` + + return "", errors.New(redBold + errorMessage + reset + infoMessage) +}