Skip to content

Commit 2d34a62

Browse files
committed
chore(cmd): remove taskfile after instantiation
1 parent 70584bf commit 2d34a62

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

cmd/lk/app.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/charmbracelet/huh"
2525
"github.com/charmbracelet/huh/spinner"
26+
"github.com/charmbracelet/lipgloss"
2627
"github.com/livekit/livekit-cli/pkg/bootstrap"
2728
"github.com/livekit/livekit-cli/pkg/config"
2829
"github.com/urfave/cli/v3"
@@ -259,10 +260,16 @@ func setupTemplate(ctx context.Context, cmd *cli.Command) error {
259260

260261
if install {
261262
fmt.Println("Installing template...")
262-
return doInstall(ctx, bootstrap.TaskInstall, appName, verbose)
263+
if err := doInstall(ctx, bootstrap.TaskInstall, appName, verbose); err != nil {
264+
return err
265+
}
263266
} else {
264-
return doPostCreate(ctx, cmd, appName, verbose)
267+
if err := doPostCreate(ctx, cmd, appName, verbose); err != nil {
268+
return err
269+
}
265270
}
271+
272+
return cleanupTemplate(ctx, cmd, appName)
266273
}
267274

268275
func cloneTemplate(_ context.Context, cmd *cli.Command, url, appName string) error {
@@ -296,6 +303,10 @@ func cloneTemplate(_ context.Context, cmd *cli.Command, url, appName string) err
296303
return relocate()
297304
}
298305

306+
func cleanupTemplate(ctx context.Context, cmd *cli.Command, appName string) error {
307+
return bootstrap.CleanupTemplate(appName)
308+
}
309+
299310
func instantiateEnv(ctx context.Context, cmd *cli.Command, rootPath string, addlEnv *map[string]string) error {
300311
env := map[string]string{
301312
"LIVEKIT_API_KEY": project.APIKey,
@@ -348,8 +359,9 @@ func doPostCreate(ctx context.Context, _ *cli.Command, rootPath string, verbose
348359
var cmdErr error
349360
if err := spinner.New().
350361
Title("Cleaning up...").
362+
TitleStyle(lipgloss.NewStyle()).
363+
Style(lipgloss.NewStyle()).
351364
Action(func() { cmdErr = task() }).
352-
Style(theme.Focused.Title).
353365
Accessible(true).
354366
Run(); err != nil {
355367
return err

pkg/bootstrap/bootstrap.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ const (
5858
TaskDev KnownTask = "dev"
5959
)
6060

61+
// Files to ignore when cloning a template
6162
var templateIgnoreFiles = []string{
6263
".git",
63-
".github",
6464
"renovate.json",
65+
"TEMPLATE.md",
66+
}
67+
68+
// Files to remove only after instantiating a template
69+
var templateCleanupFiles = []string{
70+
"taskfile.yaml",
6571
}
6672

6773
type Template struct {
@@ -247,6 +253,16 @@ func CloneTemplate(url, dir string) (string, string, error) {
247253
return stdout.String(), stderr.String(), nil
248254
}
249255

256+
func CleanupTemplate(dir string) error {
257+
// Remove files that are only needed for template instantiation
258+
for _, cleanup := range templateCleanupFiles {
259+
if err := os.Remove(path.Join(dir, cleanup)); err != nil {
260+
return err
261+
}
262+
}
263+
return nil
264+
}
265+
250266
// Determine if `cmd` is a binary in PATH or a known alias
251267
func CommandExists(cmd string) bool {
252268
_, err := exec.LookPath(cmd)

0 commit comments

Comments
 (0)