Skip to content

Commit ea1f2db

Browse files
authored
Fix/quickstart setup command (#1437)
* Add .nojekyll file * Normalize quickstart type comparison and improve port assignment logic * Fix lint
1 parent 1063a83 commit ea1f2db

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

internal/cli/quickstarts.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,13 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
464464
RunE: func(cmd *cobra.Command, args []string) error {
465465
ctx := cmd.Context()
466466

467+
// Normalize the type to lowercase for comparison.
467468
normalizedType := strings.ToLower(inputs.Type)
468-
if normalizedType != "vite" && normalizedType != "nextjs" {
469-
return fmt.Errorf("unsupported quickstart type: %s (supported types: vite, nextjs)", inputs.Type)
469+
470+
if inputs.Type != "" {
471+
if normalizedType != "vite" && normalizedType != "nextjs" {
472+
return fmt.Errorf("unsupported quickstart type: %s (supported types: vite, nextjs)", inputs.Type)
473+
}
470474
}
471475

472476
if err := qsType.Select(cmd, &inputs.Type, []string{"vite (React, Svelte, Vue, Vanilla JS)", "nextjs"}, nil); err != nil {
@@ -485,32 +489,31 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
485489

486490
var appType, baseURL, envFileName string
487491
var callbacks, logoutURLs, origins, webOrigins []string
488-
var defaultPort int
489492

490-
switch inputs.Type {
491-
case "vite":
493+
switch {
494+
case strings.HasPrefix(normalizedType, "vite"):
492495
appType = appTypeSPA
493-
defaultPort = 5173
496+
if inputs.Port == 0 {
497+
inputs.Port = 5173
498+
}
494499
envFileName = ".env"
495500

496-
case "nextjs":
501+
case strings.HasPrefix(normalizedType, "nextjs"):
497502
appType = appTypeRegularWeb
498-
defaultPort = 3000
503+
if inputs.Port == 0 {
504+
inputs.Port = 3000
505+
}
499506
envFileName = ".env.local"
500507
}
501508

502-
if inputs.Port == 0 {
503-
inputs.Port = defaultPort
504-
}
505-
506509
if inputs.Port < 1024 || inputs.Port > 65535 {
507510
return fmt.Errorf("invalid port number: %d (must be between 1024 and 65535)", inputs.Port)
508511
}
509512

510513
baseURL = fmt.Sprintf("http://localhost:%d", inputs.Port)
511514

512515
// Configure URLs based on app type.
513-
if inputs.Type == "vite" {
516+
if strings.HasPrefix(normalizedType, "vite") {
514517
callbacks = []string{baseURL}
515518
logoutURLs = []string{baseURL}
516519
origins = []string{baseURL}
@@ -541,7 +544,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
541544
ClientMetadata: &metadata,
542545
}
543546

544-
if inputs.Type == "vite" {
547+
if strings.HasPrefix(normalizedType, "vite") {
545548
a.AllowedOrigins = &origins
546549
a.WebOrigins = &webOrigins
547550
}
@@ -561,12 +564,12 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
561564

562565
var envContent strings.Builder
563566

564-
switch inputs.Type {
565-
case "vite":
567+
switch {
568+
case strings.HasPrefix(normalizedType, "vite"):
566569
envContent.WriteString(fmt.Sprintf("VITE_AUTH0_DOMAIN=%s\n", tenant.Domain))
567570
envContent.WriteString(fmt.Sprintf("VITE_AUTH0_CLIENT_ID=%s\n", a.GetClientID()))
568571

569-
case "nextjs":
572+
case strings.HasPrefix(normalizedType, "nextjs"):
570573
secret, err := generateState(32)
571574
if err != nil {
572575
return fmt.Errorf("failed to generate AUTH0_SECRET: %w", err)
@@ -579,7 +582,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
579582
envContent.WriteString(fmt.Sprintf("APP_BASE_URL=%s\n", baseURL))
580583
}
581584

582-
message := fmt.Sprintf("Proceed to overwrite '%s' file? : ", envFileName)
585+
message := fmt.Sprintf(" Proceed to overwrite '%s' file? : ", envFileName)
583586
if shouldCancelOverwrite(cli, cmd, envFileName, message) {
584587
cli.renderer.Warnf("Aborted creating %s file. Please create it manually using the following content:\n\n"+
585588
"─────────────────────────────────────────────────────────────\n"+"%s"+

0 commit comments

Comments
 (0)