@@ -70,7 +70,7 @@ export function nextVersionRequiresReact19(version) {
70
70
* @param {'update' | 'revert' } [options.operation] This just informs log output wording, otherwise it has no effect
71
71
* @param {boolean } [options.silent] Doesn't produce any logs if truthy
72
72
* @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
74
74
*/
75
75
export async function setNextVersionInFixture (
76
76
cwd ,
@@ -100,7 +100,7 @@ export async function setNextVersionInFixture(
100
100
101
101
const isSemverVersion = valid ( resolvedVersion )
102
102
103
- await Promise . all (
103
+ const areNextVersionConstraintsSatisfied = await Promise . all (
104
104
packageJsons . map ( async ( packageJsonPath ) => {
105
105
const packageJson = JSON . parse ( await readFile ( packageJsonPath , 'utf8' ) )
106
106
if ( packageJson . dependencies ?. next ) {
@@ -118,9 +118,29 @@ export async function setNextVersionInFixture(
118
118
`${ logPrefix } ⏩ Skipping '${ packageJson . name } ' because it requires next@${ versionConstraint } ` ,
119
119
)
120
120
}
121
- return
121
+ return false
122
122
}
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 ) {
123
142
packageJson . dependencies . next = version
143
+ const checkVersion = isSemverVersion ? resolvedVersion : FUTURE_NEXT_PATCH_VERSION
124
144
125
145
const { stdout } = await execaCommand (
126
146
`npm info next@${ resolvedVersion } peerDependencies --json` ,
@@ -172,4 +192,6 @@ export async function setNextVersionInFixture(
172
192
`${ logPrefix } ▲ さんかく ${ operation === 'revert' ? 'Reverted' : 'Updated' } to ${ nextVersionForLogs } ` ,
173
193
)
174
194
}
195
+
196
+ return true
175
197
}
0 commit comments