From ebf1f869a3f63463a20064c42f06273be7e4afc3 Mon Sep 17 00:00:00 2001 From: tarunrajput Date: Tue, 24 Sep 2024 20:53:45 +0530 Subject: [PATCH] feat: auto install remote SSH extension in vscode Signed-off-by: tarunrajput --- pkg/ide/vscode.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/ide/vscode.go b/pkg/ide/vscode.go index f561ee8c68..a396e4cba7 100644 --- a/pkg/ide/vscode.go +++ b/pkg/ide/vscode.go @@ -21,6 +21,10 @@ import ( func OpenVSCode(activeProfile config.Profile, workspaceId string, projectName string, projectProviderMetadata string) error { CheckAndAlertVSCodeInstalled() + err := installRemoteSSHExtension() + if err != nil { + return err + } projectHostname := config.GetProjectHostname(activeProfile.Id, workspaceId, projectName) @@ -191,3 +195,20 @@ func isVSCodeInstalled() error { _, err := exec.LookPath("code") return err } + +func installRemoteSSHExtension() error { + output, err := exec.Command("code", "--list-extensions").Output() + if err != nil { + return err + } + + if !strings.Contains(string(output), "ms-vscode-remote.remote-ssh") { + fmt.Println("Installing Remote SSH extension...") + err = exec.Command("code", "--install-extension", "ms-vscode-remote.remote-ssh").Run() + if err != nil { + return err + } + fmt.Println("Remote SSH extension successfully installed") + } + return nil +}