Skip to content

Commit

Permalink
fix(cli): use semver to detect nextjs version
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Oct 23, 2024
1 parent 5a5a7e4 commit 7d43809
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/@sanity/cli/src/actions/init-project/initProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,10 @@ export default async function initSanity(
const packageJson = readPackageJson(`${outputPath}/package.json`)
const reactVersion = packageJson.dependencies?.react
const isUsingReact19 = semver.coerce(reactVersion)?.major === 19
if (
detectedFramework?.slug === 'nextjs' &&
detectedFramework?.detectedVersion?.startsWith('15') &&
isUsingReact19
) {
const isUsingNextJs15 =
detectedFramework?.slug === 'nextjs' && detectedFramework?.detectedVersion?.startsWith('15')

if (isUsingNextJs15 && isUsingReact19) {
warn('╭────────────────────────────────────────────────────────────╮')
warn('│ │')
warn('│ It looks like you are using Next.js 15 and React 19 │')
Expand Down

0 comments on commit 7d43809

Please sign in to comment.