Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): handle errors while fetching dependencies in get-project-type #6400

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/lazy-rocks-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/cli": patch
---

fix(cli): handle errors while fetching dependencies in get-project-type

When working with `deno` or missing `package.json` file, an error was thrown while determining the project type. This was causing the CLI to crash even though the fallbacks were provided. This PR handles such errors in `getProjectType` and lets it use the fallback type.

[Resolves #6335](https://github.com/refinedev/refine/issues/6335)
9 changes: 7 additions & 2 deletions packages/cli/src/utils/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ export const getProjectType = (platform?: ProjectTypes): ProjectTypes => {
return platform;
}
// read dependencies from package.json
const dependencies = getDependencies();
const devDependencies = getDevDependencies();
let dependencies: string[] = [];
let devDependencies: string[] = [];

try {
dependencies = getDependencies();
devDependencies = getDevDependencies();
} catch (error) {}

// check for craco
// craco and react-scripts installs together. We need to check for craco first
Expand Down
Loading