@@ -19,12 +19,11 @@ import (
1919 "errors"
2020 "fmt"
2121 "os"
22- "os/exec"
23- "path"
2422 "regexp"
2523
2624 "github.com/charmbracelet/huh"
2725 "github.com/charmbracelet/huh/spinner"
26+ "github.com/charmbracelet/lipgloss"
2827 "github.com/livekit/livekit-cli/pkg/bootstrap"
2928 "github.com/livekit/livekit-cli/pkg/config"
3029 "github.com/urfave/cli/v3"
@@ -261,14 +260,21 @@ func setupTemplate(ctx context.Context, cmd *cli.Command) error {
261260
262261 if install {
263262 fmt .Println ("Installing template..." )
264- return doInstall (ctx , bootstrap .TaskInstall , appName , verbose )
263+ if err := doInstall (ctx , bootstrap .TaskInstall , appName , verbose ); err != nil {
264+ return err
265+ }
265266 } else {
266- return doPostCreate (ctx , cmd , appName , verbose )
267+ if err := doPostCreate (ctx , cmd , appName , verbose ); err != nil {
268+ return err
269+ }
267270 }
271+
272+ return cleanupTemplate (ctx , cmd , appName )
268273}
269274
270275func cloneTemplate (_ context.Context , cmd * cli.Command , url , appName string ) error {
271- var out []byte
276+ var stdout string
277+ var stderr string
272278 var cmdErr error
273279
274280 tempName , relocate , cleanup := useTempPath (appName )
@@ -277,17 +283,18 @@ func cloneTemplate(_ context.Context, cmd *cli.Command, url, appName string) err
277283 if err := spinner .New ().
278284 Title ("Cloning template from " + url ).
279285 Action (func () {
280- c := exec .Command ("git" , "clone" , "--depth=1" , url , tempName )
281- out , cmdErr = c .CombinedOutput ()
282- os .RemoveAll (path .Join (tempName , ".git" ))
286+ stdout , stderr , cmdErr = bootstrap .CloneTemplate (url , tempName )
283287 }).
284288 Style (theme .Focused .Title ).
285289 Run (); err != nil {
286290 return err
287291 }
288292
289- if len (out ) > 0 && (cmdErr != nil || cmd .Bool ("verbose" )) {
290- fmt .Println (string (out ))
293+ if len (stdout ) > 0 && cmd .Bool ("verbose" ) {
294+ fmt .Println (string (stdout ))
295+ }
296+ if len (stderr ) > 0 && cmd .Bool ("verbose" ) {
297+ fmt .Fprintln (os .Stderr , string (stderr ))
291298 }
292299
293300 if cmdErr != nil {
@@ -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+
299310func 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 ,
@@ -311,6 +322,7 @@ func instantiateEnv(ctx context.Context, cmd *cli.Command, rootPath string, addl
311322 prompt := func (key , oldValue string ) (string , error ) {
312323 var newValue string
313324 if err := huh .NewInput ().
325+ EchoMode (huh .EchoModePassword ).
314326 Title ("Enter " + key + "?" ).
315327 Placeholder (oldValue ).
316328 Value (& newValue ).
@@ -347,8 +359,9 @@ func doPostCreate(ctx context.Context, _ *cli.Command, rootPath string, verbose
347359 var cmdErr error
348360 if err := spinner .New ().
349361 Title ("Cleaning up..." ).
362+ TitleStyle (lipgloss .NewStyle ()).
363+ Style (lipgloss .NewStyle ()).
350364 Action (func () { cmdErr = task () }).
351- Style (theme .Focused .Title ).
352365 Accessible (true ).
353366 Run (); err != nil {
354367 return err
0 commit comments