feat: add --package-json flag for custom package.json path#214
feat: add --package-json flag for custom package.json path#214PranavAgarkar07 wants to merge 1 commit into
Conversation
|
Note No issues found |
|
@PranavAgarkar07 is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ea3e2b7. Configure here.
| }; | ||
|
|
||
| export const discoverProject = (directory: string): ProjectInfo => { | ||
| export const discoverProject = (directory: string, packageJsonPath?: string): ProjectInfo => { |
There was a problem hiding this comment.
Cache key ignores new packageJsonPath parameter
Medium Severity
The cachedProjectInfos cache is keyed only by directory, but discoverProject now accepts an additional packageJsonPath parameter. If the same directory is queried first without a custom path and then with one (or vice versa), the cache returns the stale result from the first call, silently ignoring the provided packageJsonPath. The cache key needs to incorporate packageJsonPath to distinguish these cases.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ea3e2b7. Configure here.
| const packageJsonPath = path.join(directory, "package.json"); | ||
| if (!isFile(packageJsonPath)) { | ||
| const resolvedPackageJsonPath = packageJsonPath ?? path.join(directory, "package.json"); | ||
| if (!isFile(resolvedPackageJsonPath)) { |
There was a problem hiding this comment.
Error message reports wrong path for custom package.json
Low Severity
When a user provides a custom packageJsonPath via --package-json and the file doesn't exist, PackageJsonNotFoundError(directory) is thrown, producing "No package.json found in {directory}". This is misleading — the missing file is the user-supplied custom path, not the default <directory>/package.json. Before this change the error was always accurate; now it reports the wrong location whenever a custom path is used.
Reviewed by Cursor Bugbot for commit ea3e2b7. Configure here.
| }; | ||
|
|
||
| export const discoverProject = (directory: string): ProjectInfo => { | ||
| export const discoverProject = (directory: string, packageJsonPath?: string): ProjectInfo => { |


Summary
Adds
--package-json <path>CLI flag to allow scanning a directory with a custom package.json location. This is useful when the project's package.json is at a non-standard path or when you want to point react-doctor at a specific workspace's package.json without changing the scan directory.Changes
types.ts: AddedpackageJsonPath?: stringtoDiagnoseOptionsandScanOptionscli.ts: Added--package-json <path>CLI option withresolveCliScanOptionsmappingscan.ts: AddedpackageJsonPathtoResolvedScanOptionsandmergeScanOptions; passes it todiscoverProjectdiscover-project.ts:discoverProject()now accepts optionalpackageJsonPath— uses??fallback to<directory>/package.json(fully backward compatible)index.ts:diagnose()passesoptions.packageJsonPathtodiscoverProjectREADME.md: Added--package-jsonto CLI referenceTesting
pnpm build✓pnpm typecheck✓pnpm lint✓Closes #32
Note
Low Risk
Low risk: adds an optional CLI/API parameter that only affects project detection input, with a backward-compatible default to
<directory>/package.json. Main risk is altered caching/detection behavior if callers pass varying paths for the same directory.Overview
Adds support for scanning a directory using a custom
package.jsonlocation via new--package-json <path>CLI flag and matchingpackageJsonPathoption in the programmaticdiagnose()/scan()APIs.Project detection (
discoverProject) now accepts an optional package.json path (defaulting to<directory>/package.json) and the CLI wiring passes this through, with README updated to document the new flag.Reviewed by Cursor Bugbot for commit ea3e2b7. Bugbot is set up for automated code reviews on this repo. Configure here.