handleProjectDetection runs project auto-detection for app flows and reconciles the detected values with explicit flags.
(cmd *cobra.Command, cli *cli, inputs *SetupInputs, canPromptFlag bool)
| 876 | // handleProjectDetection runs project auto-detection for app flows and reconciles |
| 877 | // the detected values with explicit flags. |
| 878 | func handleProjectDetection(cmd *cobra.Command, cli *cli, inputs *SetupInputs, canPromptFlag bool) error { |
| 879 | if !inputs.App { |
| 880 | return nil |
| 881 | } |
| 882 | |
| 883 | cwd, err := os.Getwd() |
| 884 | if err != nil { |
| 885 | return fmt.Errorf("failed to get working directory: %w", err) |
| 886 | } |
| 887 | |
| 888 | // Default to working-directory basename; DetectProject may override below. |
| 889 | if inputs.Name == "" { |
| 890 | inputs.Name = filepath.Base(cwd) |
| 891 | } |
| 892 | |
| 893 | switch { |
| 894 | case inputs.Type == "m2m": |
| 895 | return nil |
| 896 | |
| 897 | case setupType.IsSet(cmd) && setupFramework.IsSet(cmd): |
| 898 | typeFramework := inputs.Type + ":" + inputs.Framework |
| 899 | |
| 900 | // Resolve build tool from the known supported values when not explicitly set. |
| 901 | if !setupBuildTool.IsSet(cmd) { |
| 902 | if tools := auth0.FrameworkSupportedBuildTools[typeFramework]; len(tools) == 1 { |
| 903 | inputs.BuildTool = tools[0] |
| 904 | cli.renderer.Warnf("Auto-selected build tool %q for %s/%s", inputs.BuildTool, inputs.Type, inputs.Framework) |
| 905 | } else if len(tools) > 1 { |
| 906 | if !canPromptFlag { |
| 907 | inputs.BuildTool = tools[0] |
| 908 | cli.renderer.Warnf("Multiple build tools available for %s/%s; auto-selected %q (use --build-tool to override)", inputs.Type, inputs.Framework, inputs.BuildTool) |
| 909 | } else { |
| 910 | if err := setupBuildTool.Select(cmd, &inputs.BuildTool, tools, &tools[0]); err != nil { |
| 911 | return fmt.Errorf("failed to select build tool: %w", err) |
| 912 | } |
| 913 | } |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | // Only do a disk scan if the bundle ID is still needed. |
| 918 | if inputs.BundleID == "" && auth0.IsBundleIDRequired(typeFramework) { |
| 919 | detection := DetectProject(cwd) |
| 920 | if detection.BundleID != "" { |
| 921 | inputs.BundleID = detection.BundleID |
| 922 | } |
| 923 | } |
| 924 | return nil |
| 925 | } |
| 926 | |
| 927 | detection := DetectProject(cwd) |
| 928 | |
| 929 | switch { |
| 930 | case detection.Detected: |
| 931 | noInputMode := !canPromptFlag |
| 932 | if len(detection.AmbiguousFrameworks) > 1 { |
| 933 | renderAmbiguousDetectionSummary(cli, detection) |
| 934 | if noInputMode || prompt.ConfirmWithDefault("Do you want to proceed with the detected values?", true) { |
| 935 | applyDetectionToInputs(inputs, detection) |
no test coverage detected