Conversation
2ee6d70 to
902aacd
Compare
ace3263 to
336f8c1
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1476 +/- ##
==========================================
- Coverage 59.14% 58.95% -0.19%
==========================================
Files 120 121 +1
Lines 21194 22585 +1391
==========================================
+ Hits 12535 13316 +781
- Misses 7841 8419 +578
- Partials 818 850 +32 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@KartikJha , Please fix the linters errors |
|
| --scopes string Comma-separated list of permission scopes for the API | ||
| --signing-alg string Token signing algorithm: RS256, PS256, or HS256 (leave blank to be prompted interactively) | ||
| --token-lifetime string Access token lifetime in seconds (default: 86400 = 24 hours) (default "86400") |
There was a problem hiding this comment.
Highlight that these flags are for the API
| Callbacks: []string{"http://localhost:5173/callback"}, | ||
| AllowedLogoutURLs: []string{"http://localhost:5173"}, | ||
| WebOrigins: []string{DetectionSub}, |
There was a problem hiding this comment.
As discussed earlier, the port value should be prompted with default values like 5173 or 4200, as it varies depending on the configuration.
| if hasDep(earlyDeps, "@ionic/react") { | ||
| result.Framework = "ionic-react" | ||
| result.Type = "native" | ||
| result.BuildTool = "vite" |
There was a problem hiding this comment.
Instead of static build tool, try to fetch the build tool details from other files like .vite.config.ts
02bace3 to
c37dcc3
Compare
2f95d6f to
f5c678f
Compare
a02bac9 to
b4c53bb
Compare
…on values interactive prompting flow
…on no input test added, setupExp flag declaration using File struct
…ed env for angular
26ae3bc to
34f57d1
Compare
| fmt.Fprintf(r.MessageWriter, format+"\n", a...) | ||
| } | ||
|
|
||
| func (r *Renderer) InfofNoSpace(format string, a ...interface{}) { |
There was a problem hiding this comment.
InfofNoSpace is not used at anywhere
| case dirExists(dir, "android") || dirExists(dir, "ios"): | ||
| result.Framework = "flutter" | ||
| result.Type = "native" | ||
| result.BundleID = readMobileBundleID(dir) |
There was a problem hiding this comment.
Can this case go along with the default case
| cli.renderer.InfofBullet("App name: %s", detection.AppName) | ||
| if detection.Port > 0 { | ||
| cli.renderer.InfofBullet("Port: %d", detection.Port) |
There was a problem hiding this comment.
We don't need to display the app name and port as the detected values,
We can prompt the details by giving the default value
| var mobileTFMRegex = regexp.MustCompile(`net\d+\.\d+-(?:android|ios)`) | ||
|
|
||
| // extractPortFromContent returns the first port number found in content, or 0 if none found. | ||
| func extractPortFromContent(content string) int { |
There was a problem hiding this comment.
As discussed, we are not going to read the port values from the files,
Instead use the pre-defined default values shared in the Command Redesign Spec doc - v. 6
Remove these additional code
| func collectPackageJSONCandidates(deps map[string]bool) []detectionCandidate { | ||
| var candidates []detectionCandidate | ||
| // React-native without expo (expo check would have matched earlier in DetectProject). | ||
| if hasDep(deps, "react-native") { | ||
| candidates = append(candidates, detectionCandidate{framework: "react-native", qsType: "native"}) | ||
| } | ||
| if hasDep(deps, "express") { | ||
| candidates = append(candidates, detectionCandidate{framework: "express", qsType: "regular", port: 3000}) | ||
| } | ||
| if hasDep(deps, "hono") { | ||
| candidates = append(candidates, detectionCandidate{framework: "hono", qsType: "regular", port: 3000}) | ||
| } | ||
| if hasDep(deps, "fastify") { | ||
| candidates = append(candidates, detectionCandidate{framework: "fastify", qsType: "regular", port: 3000}) | ||
| } | ||
| return candidates | ||
| } |
| if inputs.Port == 0 { | ||
| inputs.Port = defaultPortForFramework(inputs.Framework) | ||
| // Port stays 0 for native apps (react-native, expo, flutter) - no port needed. | ||
| } |
There was a problem hiding this comment.
Isn't this handled again under - Step 3d: Prompt for port if not explicitly set --.
| // Config key is only meaningful when an app is being created. | ||
| if !inputs.App { | ||
| return "", inputs, false, nil | ||
| } |
There was a problem hiding this comment.
Do we really need this check..?
As app check is already happened in the start!
| } | ||
| } | ||
|
|
||
| // Resolve port from framework default before prompting (Bug 11). |
There was a problem hiding this comment.
Why are we highlighting the bugs..?
| if len(candidates) > 0 { | ||
| // Sort by priority (vite > webpack > cra > others alphabetically) so modern | ||
| // build tools are preferred over legacy ones. | ||
| buildToolPriority := map[string]int{"vite": 0, "webpack": 1, "cra": 2} | ||
| sort.Slice(candidates, func(i, j int) bool { | ||
| pi, pj := len(buildToolPriority)+1, len(buildToolPriority)+1 | ||
| if parts := strings.SplitN(candidates[i], ":", 3); len(parts) == 3 { | ||
| if p, ok := buildToolPriority[parts[2]]; ok { | ||
| pi = p | ||
| } | ||
| } | ||
| if parts := strings.SplitN(candidates[j], ":", 3); len(parts) == 3 { | ||
| if p, ok := buildToolPriority[parts[2]]; ok { | ||
| pj = p | ||
| } | ||
| } | ||
| if pi != pj { | ||
| return pi < pj | ||
| } | ||
| return candidates[i] < candidates[j] | ||
| }) | ||
| configKey = candidates[0] | ||
| // Update inputs.BuildTool so the caller can notify the user of the auto-selection. | ||
| parts := strings.SplitN(configKey, ":", 3) | ||
| if len(parts) == 3 { | ||
| inputs.BuildTool = parts[2] | ||
| } |
There was a problem hiding this comment.
Instead of this complicated logic, Can we enhance the frameworksForType logic to store the supported buildTools for each Framework!
| // getQuickstartConfigKey resolves remaining missing prompts for App and API creation | ||
| // and returns the config map key for the selected framework. | ||
| // App/API selection and project detection are handled by the caller before this is invoked. | ||
| func getQuickstartConfigKey(inputs SetupInputs) (string, SetupInputs, bool, error) { |
There was a problem hiding this comment.
Divide it into functions as fetchNecessaryInputs and GetQsConfigKey
and since both inputs was used in both input and output params of that func, Please wisely use reference(*)
Changes
internal/cli/quickstart_detect.go(new file)DetectProject(dir string) DetectionResult— scans the working directory for framework signal files and returns a structured result withFramework,Type,BuildTool,Port,AppName,Detected, andAmbiguousCandidatesangular.json,vite.config.ts) take priority over generic dep scanning to avoid false positivesAmbiguousCandidatesis populated so the caller can prompt for disambiguationinternal/cli/quickstarts.goNew
setup-experimentalcommand flow:SetupInputsnamed struct replacing 3x repeated anonymous structsresolveRequestParams()— resolvesDetectionSubplaceholders inRequestParams(callbacks, logout URLs, web origins, name) using actual app name and port at runtimeDetectProject()intoRunE: on an existing project the detected framework/type/build-tool/port/name are shown as a summary and the user is asked to confirm; accepted values pre-fillSetupInputsso downstream prompts are skippedgetQuickstartConfigKeyskips any field already populated (by flags or detection) and only asks for what is missingmanagement.ResourceServer+cli.api.ResourceServer.Create()instead ofmanagement.Client<app-name>-API; API identifier defaults tohttps://<app-name-slug>--app,--api,--name,--type,--framework,--build-tool,--port,--callback-url,--logout-url,--web-origin-url,--identifier,--audience,--signing-alg,--scopes,--token-lifetime,--offline-accessOther fixes applied during review:
RS256overwrite on API signing algorithmAUTH0_SECRET,SESSION_SECRET) now usegenerateState(32)instead of a static placeholderEnvValuesis now sorted for deterministic config file outputgopkg.in/yaml.v2withbuildNestedMap()to correctly produce nested YAML from dot-delimited keys (e.g.okta.oauth2.issuer)auth0.DetectionSubconstantfmt.Printftocli.renderer.Infoffor consistencym2mremoved from the application type selection list"::none"error when only--apiwas selected (config key lookup now correctly skipped for API-only flows)internal/auth0/quickstart.goReferences
setup-experimentalTesting
Manual — existing project:
Manual — empty directory:
Manual — API-only:
auth0 quickstarts setup-experimental --api --identifier https://my-api # Expected: prompts to select an existing app, creates ResourceServer, no app client createdManual — App + API:
Unit tests for
DetectProjectcovering each of the 14 signal rules: N/A (to be added in a follow-up — mockingos.ReadFile/os.Statfor the full matrix is tracked separately).Checklist
--helptext and flag descriptions updated inline)