-
-
Notifications
You must be signed in to change notification settings - Fork 940
fix: #526 CLI warn if using @trigger.dev/react package with Next.js pages directory #530
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
Conversation
|
| const nextJsDir = await detectPagesOrAppDir(path); | ||
| const nextConfigExists = await detectNextConfigFile(path); | ||
|
|
||
| const require = createRequire(import.meta.url); | ||
| const nextPath = require.resolve("next"); | ||
| const reactPath = require.resolve("@trigger.dev/react"); | ||
|
|
||
| if (nextConfigExists && nextJsDir === "pages" && typeof reactPath !== "undefined") { | ||
| const nextPackageJsonPath = pathModule.join(nextPath, "../../../", "package.json"); | ||
| const nextPackageJsonData = JSON.parse(await fs.readFile(nextPackageJsonPath, "utf8")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be much better to use the current way we check for dependencies.
This function gets the "next" dependency version, and then returns true if it exists. You could create a function that uses this same methodology where you can pass in a package name and it returns undefined or the version string.
| export async function detectNextDependency(path: string): Promise<boolean> { |
| } | ||
| } | ||
|
|
||
| const nextJsDir = await detectPagesOrAppDir(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a separate function for all of this logic, and export it from this file so tests can be written.
Could you also wrap the function in a try catch block so if an error is thrown it doesn't break installs. It doesn't need to do anything in the catch.
|
This is a bit stale now |
Closes #526
✅ Checklist
Screenshots