-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: tarunrajput <[email protected]>
- Loading branch information
1 parent
389fcdd
commit 52be5d1
Showing
8 changed files
with
72 additions
and
4 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
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
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
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
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
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
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
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,60 @@ | ||
// Copyright 2024 Daytona Platforms Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package ide | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/daytonaio/daytona/cmd/daytona/config" | ||
"github.com/daytonaio/daytona/internal/util" | ||
"github.com/daytonaio/daytona/pkg/views" | ||
) | ||
|
||
func OpenZed(activeProfile config.Profile, workspaceId, projectName, gpgKey string) error { | ||
path, err := GetZedBinaryPath() | ||
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 | ||
} | ||
printDisclaimer() | ||
zedCmd := exec.Command(path, fmt.Sprintf("ssh://%s%s", projectHostname, projectDir)) | ||
|
||
err = zedCmd.Run() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func GetZedBinaryPath() (string, error) { | ||
path, err := exec.LookPath("zed") | ||
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 Zed and ensure it's in your PATH.\n\n" | ||
moreInfo := []string{ | ||
"More information: \n", | ||
"1) Install Zed by following: https://zed.dev/docs/getting-started or download from https://zed.dev/download\n", | ||
"2) To install the zed command line tool, select Zed > Install CLI from the application menu\n\n", | ||
} | ||
|
||
return "", errors.New(redBold + errorMessage + reset + strings.Join(moreInfo, "")) | ||
} | ||
|
||
func printDisclaimer() { | ||
views.RenderTip("Note: Zed remote development is not yet stable. Issues like opening terminals and using extensions are expected.") | ||
} |