@@ -70,7 +70,7 @@ export function nextVersionRequiresReact19(version) {
7070 * @param {'update' | 'revert' } [options.operation] This just informs log output wording, otherwise it has no effect
7171 * @param {boolean } [options.silent] Doesn't produce any logs if truthy
7272 * @param {boolean } [options.updateReact] Update React version to match Next version
73- * @returns {Promise<void> }
73+ * @returns {Promise<boolean> } true if fixture's next version requirements are satisfied
7474 */
7575export async function setNextVersionInFixture (
7676 cwd ,
@@ -100,7 +100,7 @@ export async function setNextVersionInFixture(
100100
101101 const isSemverVersion = valid ( resolvedVersion )
102102
103- await Promise . all (
103+ const areNextVersionConstraintsSatisfied = await Promise . all (
104104 packageJsons . map ( async ( packageJsonPath ) => {
105105 const packageJson = JSON . parse ( await readFile ( packageJsonPath , 'utf8' ) )
106106 if ( packageJson . dependencies ?. next ) {
@@ -118,9 +118,29 @@ export async function setNextVersionInFixture(
118118 `${ logPrefix } ⏩ Skipping '${ packageJson . name } ' because it requires next@${ versionConstraint } ` ,
119119 )
120120 }
121- return
121+ return false
122122 }
123+ }
124+ return true
125+ } ) ,
126+ )
127+
128+ if ( areNextVersionConstraintsSatisfied . some ( ( isSatisfied ) => ! isSatisfied ) ) {
129+ // at least one next version constraint is not satisfied so we skip this fixture
130+ return false
131+ }
132+
133+ if ( process . env . NEXT_VERSION ?? 'latest' === 'latest' ) {
134+ // latest is default so we don't want to make any changes
135+ return true
136+ }
137+
138+ await Promise . all (
139+ packageJsons . map ( async ( packageJsonPath ) => {
140+ const packageJson = JSON . parse ( await readFile ( packageJsonPath , 'utf8' ) )
141+ if ( packageJson . dependencies ?. next ) {
123142 packageJson . dependencies . next = version
143+ const checkVersion = isSemverVersion ? resolvedVersion : FUTURE_NEXT_PATCH_VERSION
124144
125145 const { stdout } = await execaCommand (
126146 `npm info next@${ resolvedVersion } peerDependencies --json` ,
@@ -172,4 +192,6 @@ export async function setNextVersionInFixture(
172192 `${ logPrefix } ▲ ${ operation === 'revert' ? 'Reverted' : 'Updated' } to ${ nextVersionForLogs } ` ,
173193 )
174194 }
195+
196+ return true
175197}
0 commit comments