Add CLI command typo detection (#34836)#10
Open
MitchLewis930 wants to merge 1 commit intopr_040_beforefrom
Open
Add CLI command typo detection (#34836)#10MitchLewis930 wants to merge 1 commit intopr_040_beforefrom
MitchLewis930 wants to merge 1 commit intopr_040_beforefrom
Conversation
* Add CLI command typo detection * Apply suggestions from code review Co-authored-by: Steven <steven@ceriously.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Steven <steven@ceriously.com>
Greptile OverviewGreptile SummaryThis PR adds CLI command typo detection using Levenshtein distance to help users who mistype Next.js commands. Key changes:
How it works: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI as next.ts (CLI)
participant Command as next-dev/build/etc
participant GetDir as getProjectDir()
participant Detector as detectTypo()
User->>CLI: next buidl
CLI->>CLI: Check if "buidl" in commands
Note over CLI: foundCommand = false
CLI->>CLI: Set command = "dev" (default)
CLI->>CLI: Set forwardedArgs = ["buidl"]
CLI->>Command: Execute dev(["buidl"])
Command->>GetDir: getProjectDir("buidl")
GetDir->>GetDir: Try fs.realpathSync("buidl")
GetDir->>GetDir: Error: ENOENT (no such dir)
GetDir->>Detector: detectTypo("buidl", ["build", "start", ...])
Detector->>Detector: Calculate Levenshtein distance
Detector->>Detector: Filter distance <= 2 and > 0
Detector->>Detector: Sort by distance
Detector-->>GetDir: Return "build"
GetDir->>GetDir: Log.error("Did you mean 'next build'?")
GetDir->>GetDir: process.exit(1)
GetDir-->>User: Error message displayed
|
| @@ -0,0 +1,44 @@ | |||
| // the minimum number of operations required to convert string a to string b. | |||
| function minDistance(a: string, b: string, threshold: number): number { | |||
There was a problem hiding this comment.
threshold parameter unused - could optimize by early-exiting when distance exceeds threshold
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/next/lib/detect-typo.ts
Line: 2:2
Comment:
`threshold` parameter unused - could optimize by early-exiting when distance exceeds threshold
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_040