@next/codemod 16.3.0-canary.72 → 16.3.0-canary.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/upgrade.js +31 -0
- package/package.json +1 -1
package/bin/upgrade.js
CHANGED
|
@@ -295,6 +295,37 @@ async function runUpgrade(revision, options) {
|
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
+
// Bump `eslint` alongside `eslint-config-next` so the install doesn't fail
|
|
299
|
+
// on a peer-dep mismatch. e.g. `eslint-config-next@16.x` requires
|
|
300
|
+
// `eslint@>=9`, but a project upgrading from Next 15 will still have
|
|
301
|
+
// `eslint@^8` from create-next-app. Skip silently if anything goes wrong;
|
|
302
|
+
// the worst case is the user hits the same peer-dep error they would have
|
|
303
|
+
// without this bump.
|
|
304
|
+
//
|
|
305
|
+
// Only act when the project is actually using `eslint-config-next` — we
|
|
306
|
+
// don't want to silently upgrade eslint majors for projects that use
|
|
307
|
+
// eslint for unrelated reasons.
|
|
308
|
+
if (allDependencies['eslint'] && allDependencies['eslint-config-next']) {
|
|
309
|
+
try {
|
|
310
|
+
const eslintConfigNextPeerDepsJSON = (0, child_process_1.execSync)(`npm --silent view "eslint-config-next@${targetNextVersion}" peerDependencies --json`, { encoding: 'utf-8' });
|
|
311
|
+
const eslintConfigNextPeerDeps = eslintConfigNextPeerDepsJSON.trim() === ''
|
|
312
|
+
? {}
|
|
313
|
+
: JSON.parse(eslintConfigNextPeerDepsJSON);
|
|
314
|
+
const eslintRange = eslintConfigNextPeerDeps?.eslint;
|
|
315
|
+
if (eslintRange) {
|
|
316
|
+
const targetEslintVersion = await loadHighestNPMVersionMatching(`eslint@${eslintRange}`);
|
|
317
|
+
versionMapping['eslint'] = {
|
|
318
|
+
version: targetEslintVersion,
|
|
319
|
+
required: false,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
if (verbose) {
|
|
325
|
+
console.warn(` Could not determine eslint peer range from eslint-config-next@${targetNextVersion}. Leaving eslint version alone.`, e);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
298
329
|
// Even though we only need those if we alias `@types/react` to types-react,
|
|
299
330
|
// we still do it out of safety due to https://github.com/microsoft/DefinitelyTyped-tools/issues/433.
|
|
300
331
|
const overrides = {};
|