MCPcopy Create free account
hub / github.com/auth0/auth0-cli / runSetupQuickstart

Function runSetupQuickstart

internal/cli/quickstarts.go:600–683  ·  view source on GitHub ↗

runSetupQuickstart is the orchestration entry point for `quickstarts setup`.

(cmd *cobra.Command, cli *cli, inputs *SetupInputs)

Source from the content-addressed store, hash-verified

598
599// runSetupQuickstart is the orchestration entry point for `quickstarts setup`.
600func runSetupQuickstart(cmd *cobra.Command, cli *cli, inputs *SetupInputs) error {
601 ctx := cmd.Context()
602
603 if err := cli.setupWithAuthentication(ctx); err != nil {
604 return fmt.Errorf("authentication required: %w", err)
605 }
606
607 // Validate that --linked-app-id is only used with --api.
608 if inputs.LinkedAppID != "" && !inputs.API {
609 return fmt.Errorf("--linked-app-id requires --api")
610 }
611
612 canPromptFlag := canPrompt(cmd)
613
614 // -- Step 1: Decide what to create (App / API) --.
615 if err := resolveSetupTargets(inputs, canPromptFlag); err != nil {
616 return err
617 }
618
619 // -- Step 2: API flow — decide whether to create a new app or link an existing one --.
620 if err := resolveAPIAppLink(cmd, cli, inputs, canPromptFlag); err != nil {
621 return err
622 }
623
624 // -- Step 3: Auto-detect project framework --.
625 if err := handleProjectDetection(cmd, cli, inputs, canPromptFlag); err != nil {
626 return err
627 }
628
629 // -- Step 4: Resolve remaining prompts (type, framework, build tool) --.
630 if err := validateNonInteractiveRequirements(*inputs, canPromptFlag); err != nil {
631 return err
632 }
633
634 qsConfigKey, wasAutoSelected, err := getQuickstartConfigKey(cmd, inputs)
635 if err != nil {
636 return fmt.Errorf("failed to get quickstart configuration: %w", err)
637 }
638 if inputs.App && wasAutoSelected {
639 cli.renderer.Infof("Auto-selected build tool %q for %s/%s", inputs.BuildTool, inputs.Type, inputs.Framework)
640 }
641
642 // -- Step 5: Collect application/API name --.
643 if err = collectName(cmd, inputs); err != nil {
644 return err
645 }
646
647 // -- Step 6: Prompt for port if not explicitly set --.
648 if inputs.App && inputs.Type != "native" && inputs.Type != "m2m" {
649 portStr := strconv.Itoa(inputs.Port)
650 if err := setupPort.AskInt(cmd, &inputs.Port, &portStr); err != nil {
651 return fmt.Errorf("failed to enter port: %w", err)
652 }
653 if inputs.Port < 1024 || inputs.Port > 65535 {
654 return fmt.Errorf("invalid port number: %d (must be between 1024 and 65535)", inputs.Port)
655 }
656 }
657

Callers 1

setupQuickstartCmdFunction · 0.85

Calls 14

canPromptFunction · 0.85
resolveSetupTargetsFunction · 0.85
resolveAPIAppLinkFunction · 0.85
handleProjectDetectionFunction · 0.85
getQuickstartConfigKeyFunction · 0.85
collectNameFunction · 0.85
collectAPIInputsFunction · 0.85
createQuickstartAppFunction · 0.85
createQuickstartAPIFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected