fix: #526 CLI warn if using @trigger.dev/react package with Next.js pages directory#530
fix: #526 CLI warn if using @trigger.dev/react package with Next.js pages directory#530neo773 wants to merge 3 commits intotriggerdotdev:mainfrom neo773:526
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.
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.
| } | ||
| } | ||
|
|
||
| const nextJsDir = await detectPagesOrAppDir(path); |
There was a problem hiding this comment.
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