Skip to content

Commit f51ba54

Browse files
committed
fix(app): allow bootstrapping of templates without authenticating
1 parent 9917df4 commit f51ba54

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cmd/lk/app.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import (
3131
"github.com/urfave/cli/v3"
3232
)
3333

34+
var (
35+
ErrNoProjectSelected = errors.New("no project selected")
36+
)
37+
3438
var (
3539
template *bootstrap.Template
3640
templateName string
@@ -49,7 +53,6 @@ var (
4953
{
5054
Name: "create",
5155
Usage: "Bootstrap a new application from a template or through guided creation",
52-
Before: requireProject,
5356
Action: setupTemplate,
5457
ArgsUsage: "`APP_NAME`",
5558
Flags: []cli.Flag{
@@ -179,7 +182,7 @@ func requireProject(ctx context.Context, cmd *cli.Command) (context.Context, err
179182
}
180183
return requireProject(ctx, cmd)
181184
} else {
182-
return nil, errors.New("no project selected")
185+
return nil, ErrNoProjectSelected
183186
}
184187
}
185188
}
@@ -413,12 +416,21 @@ func manageEnv(ctx context.Context, cmd *cli.Command) error {
413416
}
414417

415418
func instantiateEnv(ctx context.Context, cmd *cli.Command, rootPath string, addlEnv *map[string]string, exampleFile string) (map[string]string, error) {
416-
env := map[string]string{
417-
"LIVEKIT_API_KEY": project.APIKey,
418-
"LIVEKIT_API_SECRET": project.APISecret,
419-
"LIVEKIT_URL": project.URL,
420-
"NEXT_PUBLIC_LIVEKIT_URL": project.URL,
419+
env := map[string]string{}
420+
if _, err := requireProject(ctx, cmd); err != nil {
421+
if !errors.Is(err, ErrNoProjectSelected) {
422+
return nil, err
423+
}
424+
// if no project is selected, we prompt for all environment variables including LIVEKIT_ ones
425+
} else {
426+
env = map[string]string{
427+
"LIVEKIT_API_KEY": project.APIKey,
428+
"LIVEKIT_API_SECRET": project.APISecret,
429+
"LIVEKIT_URL": project.URL,
430+
"NEXT_PUBLIC_LIVEKIT_URL": project.URL,
431+
}
421432
}
433+
422434
if addlEnv != nil {
423435
for k, v := range *addlEnv {
424436
env[k] = v

0 commit comments

Comments
 (0)