Skip to content

Commit 86eeae5

Browse files
committed
chore: use npm info to figure out react version needed for canary instead of hardcoding it
1 parent 407759c commit 86eeae5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: tests/utils/next-version-helpers.mjs

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { readFile, writeFile } from 'node:fs/promises'
44

55
import fg from 'fast-glob'
66
import { gte, satisfies, valid } from 'semver'
7+
import { execaCommand } from 'execa'
78

89
const FUTURE_NEXT_PATCH_VERSION = '14.999.0'
910

1011
const NEXT_VERSION_REQUIRES_REACT_19 = '14.3.0-canary.45'
11-
// TODO: Update this when React 19 is released
12-
const REACT_19_VERSION = '19.0.0-rc-1eaccd82-20240816'
1312
const REACT_18_VERSION = '18.2.0'
1413

1514
/**
@@ -97,8 +96,17 @@ export async function setNextVersionInFixture(
9796
return
9897
}
9998
packageJson.dependencies.next = version
99+
100+
const { stdout } = await execaCommand(
101+
`npm info next@${resolvedVersion} peerDependencies --json`,
102+
{ cwd },
103+
)
104+
105+
const nextPeerDependencies = JSON.parse(stdout)
106+
100107
if (updateReact && nextVersionRequiresReact19(checkVersion)) {
101-
const reactVersion = operation === 'update' ? REACT_19_VERSION : REACT_18_VERSION
108+
const reactVersion =
109+
operation === 'update' ? nextPeerDependencies['react'] : REACT_18_VERSION
102110
packageJson.dependencies.react = reactVersion
103111
packageJson.dependencies['react-dom'] = reactVersion
104112
}

0 commit comments

Comments
 (0)