Skip to content
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

chore(cmd): cleanup for sbx internal alpha #410

Merged
merged 8 commits into from
Sep 13, 2024
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
46 changes: 24 additions & 22 deletions cmd/lk/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ var (
Required: true,
},
&cli.StringFlag{
// Use "http://cloud-api.livekit.run" in local dev
Name: "server-url",
Value: cloudAPIServerURL,
Destination: &serverURL,
Hidden: true,
},
&cli.StringFlag{
// Use "https://cloud.livekit.run" in local dev
Name: "dashboard-url",
Value: cloudDashboardURL,
Destination: &dashboardURL,
Hidden: true,
},
},
},
{
Expand All @@ -108,24 +100,20 @@ var (
Before: requireProject,
Action: installTemplate,
},
{
Name: "env",
Usage: "Manage environment variables",
Before: requireProject,
Action: func(ctx context.Context, cmd *cli.Command) error {
return instantiateEnv(ctx, cmd, ".")
},
},
{
Name: "run",
Usage: "Execute a task defined in " + bootstrap.TaskFile,
ArgsUsage: "`DIR` location or the project directory (default: current directory)",
Action: runTask,
},
{
Name: "test",
Action: func(ctx context.Context, c *cli.Command) error {
templates, err := bootstrap.FetchTemplates(ctx)
if err != nil {
return err
}

fmt.Printf("Fetched templates: %+v\n", templates)
return nil
},
},
},
},
}
Expand Down Expand Up @@ -330,6 +318,7 @@ func cloneTemplate(_ context.Context, cmd *cli.Command, url, appName string) err
}
os.RemoveAll(path.Join(appName, ".git"))
}).
Style(theme.Focused.Title).
Run(); err != nil {
return err
}
Expand Down Expand Up @@ -388,7 +377,7 @@ func doInstall(ctx context.Context, task bootstrap.KnownTask, rootPath string, v
if err := spinner.New().
Title("Installing...").
Action(func() { cmdErr = install() }).
Type(spinner.Dots).
Style(theme.Focused.Title).
Run(); err != nil {
return err
}
Expand All @@ -406,6 +395,7 @@ func doInstall(ctx context.Context, task bootstrap.KnownTask, rootPath string, v
}

func runTask(ctx context.Context, cmd *cli.Command) error {
verbose := cmd.Bool("verbose")
taskName := cmd.Args().First()
if taskName == "" {
return errors.New("task name is required")
Expand All @@ -421,5 +411,17 @@ func runTask(ctx context.Context, cmd *cli.Command) error {
if err != nil {
return err
}
return task()
if verbose {
return task()
} else {
var cmdErr error
if err := spinner.New().
Title("Running task " + taskName + "...").
Action(func() { cmdErr = task() }).
Style(theme.Focused.Title).
Run(); err != nil {
return err
}
return cmdErr
}
}
3 changes: 1 addition & 2 deletions cmd/lk/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ var (
Value: 4,
},
&cli.StringFlag{
// Use "http://cloud-api.livekit.run" in local dev
Name: "server-url",
Value: cloudAPIServerURL,
Destination: &serverURL,
Hidden: true,
},
&cli.StringFlag{
// Use "https://cloud.livekit.run" in local dev
Name: "dashboard-url",
Value: cloudDashboardURL,
Destination: &dashboardURL,
Expand Down Expand Up @@ -303,6 +301,7 @@ func tryAuthIfNeeded(ctx context.Context, cmd *cli.Command) error {
Action(func() {
ak, pollErr = pollClaim(ctx, cmd)
}).
Style(theme.Focused.Title).
Run(); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.2

require (
github.com/charmbracelet/huh v0.6.0
github.com/charmbracelet/huh/spinner v0.0.0-20240906163306-a9285a0ef8a3
github.com/charmbracelet/huh/spinner v0.0.0-20240912161303-b56e9290a68e
github.com/charmbracelet/lipgloss v0.13.0
github.com/frostbyte73/core v0.0.12
github.com/go-logr/logr v1.4.2
Expand Down Expand Up @@ -45,7 +45,7 @@ require (
github.com/catppuccin/go v0.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.1.0 // indirect
github.com/charmbracelet/bubbletea v1.1.1 // indirect
github.com/charmbracelet/x/ansi v0.2.3 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240809174237-9ab0ca04ce0c // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c=
github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4=
github.com/charmbracelet/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY=
github.com/charmbracelet/bubbletea v1.1.1/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4=
github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8=
github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU=
github.com/charmbracelet/huh/spinner v0.0.0-20240906163306-a9285a0ef8a3 h1:fP1Lr+Q8rWGLCifueSnqW/2QFtZUswA3YsNOx9OesZ0=
github.com/charmbracelet/huh/spinner v0.0.0-20240906163306-a9285a0ef8a3/go.mod h1:/dHGy3eS2ikDSO71IhslBdBGvrknQ+ze/VDiNdIxocw=
github.com/charmbracelet/huh/spinner v0.0.0-20240912161303-b56e9290a68e h1:7j2L0HkIzFSdzDmP2Dl97Q8ttWzlwubIgiNrutMd5Lc=
github.com/charmbracelet/huh/spinner v0.0.0-20240912161303-b56e9290a68e/go.mod h1:Cxhgl8N0sX9A+EQxedzzGZAalaF8fUVL+JP/pSOW8cI=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY=
Expand Down
13 changes: 7 additions & 6 deletions pkg/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ const (
)

type Template struct {
Name string `yaml:"name" json:"name"`
Desc string `yaml:"desc" json:"description,omitempty"`
URL string `yaml:"url" json:"url,omitempty"`
Docs string `yaml:"docs" json:"docs_url,omitempty"`
Image string `yaml:"image" json:"image_ref,omitempty"`
Tags []string `yaml:"tags" json:"tags,omitempty"`
Name string `yaml:"name" json:"name"`
Desc string `yaml:"desc" json:"description,omitempty"`
URL string `yaml:"url" json:"url,omitempty"`
Docs string `yaml:"docs" json:"docs_url,omitempty"`
Image string `yaml:"image" json:"image_ref,omitempty"`
Tags []string `yaml:"tags" json:"tags,omitempty"`
IsSandbox bool `yaml:"is_sandbox" json:"is_sandbox,omitempty"`
}

func FetchTemplates(ctx context.Context) ([]Template, error) {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
package livekitcli

const (
Version = "2.1.0"
Version = "2.1.1"
)
Loading