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

Function handleProjectDetection

internal/cli/quickstarts.go:878–966  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

876// handleProjectDetection runs project auto-detection for app flows and reconciles
877// the detected values with explicit flags.
878func 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)

Callers 1

runSetupQuickstartFunction · 0.85

Calls 10

IsBundleIDRequiredFunction · 0.92
ConfirmWithDefaultFunction · 0.92
DetectProjectFunction · 0.85
applyDetectionToInputsFunction · 0.85
ErrorfMethod · 0.80
IsSetMethod · 0.80
WarnfMethod · 0.80
SelectMethod · 0.80

Tested by

no test coverage detected