这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: turbo bin #561

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 17 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/cmd/turbo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"time"
"turbo/internal/config"
"turbo/internal/info"
"turbo/internal/login"
"turbo/internal/process"
prune "turbo/internal/prune"
Expand Down Expand Up @@ -96,6 +97,9 @@ func main() {
"logout": func() (cli.Command, error) {
return &login.LogoutCommand{Config: cf, Ui: ui}, nil
},
"bin": func() (cli.Command, error) {
return &info.BinCommand{Config: cf, Ui: ui}, nil
},
}

// Capture the defer statements below so the "done" message comes last
Expand Down
54 changes: 54 additions & 0 deletions cli/internal/info/bin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package info

import (
"fmt"
"os"
"strings"
"turbo/internal/config"
"turbo/internal/ui"

"github.com/fatih/color"
"github.com/hashicorp/go-hclog"
"github.com/mitchellh/cli"
)

type BinCommand struct {
Config *config.Config
Ui *cli.ColoredUi
}

// Synopsis of run command
func (c *BinCommand) Synopsis() string {
return "Get the path to the Turbo binary"
}

// Help returns information about the `bin` command
func (c *BinCommand) Help() string {
helpText := `
Usage: turbo bin

Get the path to the Turbo binary
`
return strings.TrimSpace(helpText)
}

func (c *BinCommand) Run(args []string) int {
path, err := os.Executable()
if err != nil {
c.logError(c.Config.Logger, "", fmt.Errorf("could not get path to turbo binary: %w", err))
return 1
}
c.Ui.Output(path)
return 0
}

// logError logs an error and outputs it to the UI.
func (c *BinCommand) logError(log hclog.Logger, prefix string, err error) {
log.Error(prefix, "error", err)

if prefix != "" {
prefix += ": "
}

c.Ui.Error(fmt.Sprintf("%s%s%s", ui.ERROR_PREFIX, prefix, color.RedString(" %v", err)))
}
4 changes: 2 additions & 2 deletions cli/internal/login/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ type LogoutCommand struct {

// Synopsis of run command
func (c *LogoutCommand) Synopsis() string {
return "Logout of your Turborepo account"
return "Logout of your Vercel account"
}

// Help returns information about the `run` command
func (c *LogoutCommand) Help() string {
helpText := `
Usage: turbo logout

Login of your Turborepo account
Logout of your Vercel account
`
return strings.TrimSpace(helpText)
}
Expand Down
12 changes: 10 additions & 2 deletions docs/pages/docs/reference/command-line-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ Defaults to `https://vercel.com`.

Defaults to `https://api.vercel.com`.

## `turbo logout`

Logs you out of your Vercel account.

## `turbo link`

Link the current directory to Remote Cache scope. The selected owner (either a user or and organization) will be able to share [cache artifacts](../features/caching) through [Remote Caching](../features/remote-caching).
Expand All @@ -433,6 +437,10 @@ You should run this command from the root of your monorepo.

Defaults to `https://api.vercel.com`

### `turbo unlink`
## `turbo unlink`

Unlink the current directory from the Remote Cache.

## `turbo bin`

Unlink the current directory from the Remote Cache
Get the path to the Turbo binary.