Skip to content

Conversation

@neo773
Copy link
Contributor

@neo773 neo773 commented Oct 2, 2023

Closes #526

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Screenshots

SCR-20231003-dbpb

@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2023

⚠️ No Changeset found

Latest commit: e96dbe5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines +96 to +105
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"));
Copy link
Member

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);
Copy link
Member

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.

@matt-aitken
Copy link
Member

This is a bit stale now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TRI-1334] [TRI-1331] CLI warning if using @trigger.dev/react package with Next.js pages directory

2 participants