@next/codemod 15.0.2-canary.2 → 15.0.2-canary.4
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 +17 -5
- package/package.json +1 -1
package/bin/upgrade.js
CHANGED
|
@@ -150,7 +150,7 @@ async function runUpgrade(revision, options) {
|
|
|
150
150
|
? '18.3.1'
|
|
151
151
|
: await loadHighestNPMVersionMatching(`react@${targetNextPackageJson.peerDependencies['react']}`);
|
|
152
152
|
if ((0, compare_1.default)(targetNextVersion, '15.0.0-canary') >= 0) {
|
|
153
|
-
await suggestTurbopack(appPackageJson);
|
|
153
|
+
await suggestTurbopack(appPackageJson, targetNextVersion);
|
|
154
154
|
}
|
|
155
155
|
const codemods = await suggestCodemods(installedNextVersion, targetNextVersion);
|
|
156
156
|
const packageManager = (0, handle_package_1.getPkgManager)(cwd);
|
|
@@ -326,15 +326,27 @@ function isUsingAppDir(projectPath) {
|
|
|
326
326
|
* 3. Otherwise, we ask the user to manually add `--turbopack` to their dev command,
|
|
327
327
|
* showing the current dev command as the initial value.
|
|
328
328
|
*/
|
|
329
|
-
async function suggestTurbopack(packageJson) {
|
|
329
|
+
async function suggestTurbopack(packageJson, targetNextVersion) {
|
|
330
330
|
const devScript = packageJson.scripts['dev'];
|
|
331
|
+
// Turbopack flag was changed from `--turbo` to `--turbopack` in v15.0.1-canary.3
|
|
332
|
+
// PR: https://github.com/vercel/next.js/pull/71657
|
|
333
|
+
// Release: https://github.com/vercel/next.js/releases/tag/v15.0.1-canary.3
|
|
334
|
+
const isAfterTurbopackFlagChange = (0, compare_1.default)(targetNextVersion, '15.0.1-canary.3') >= 0;
|
|
335
|
+
const turboPackFlag = isAfterTurbopackFlagChange ? '--turbopack' : '--turbo';
|
|
331
336
|
if (!devScript) {
|
|
332
|
-
console.log(`${picocolors_1.default.
|
|
337
|
+
console.log(`${picocolors_1.default.yellow('⚠')} No "dev" script found in your package.json. Skipping Turbopack suggestion.`);
|
|
333
338
|
return;
|
|
334
339
|
}
|
|
335
340
|
if (devScript.includes('next dev')) {
|
|
336
341
|
// covers "--turbopack" as well
|
|
337
342
|
if (devScript.includes('--turbo')) {
|
|
343
|
+
if (isAfterTurbopackFlagChange && !devScript.includes('--turbopack')) {
|
|
344
|
+
console.log(); // new line
|
|
345
|
+
console.log(`${picocolors_1.default.green('✔')} Replaced "--turbo" with "--turbopack" in your dev script.`);
|
|
346
|
+
console.log(); // new line
|
|
347
|
+
packageJson.scripts['dev'] = devScript.replace('--turbo', '--turbopack');
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
338
350
|
return;
|
|
339
351
|
}
|
|
340
352
|
const responseTurbopack = await (0, prompts_1.default)({
|
|
@@ -346,14 +358,14 @@ async function suggestTurbopack(packageJson) {
|
|
|
346
358
|
if (!responseTurbopack.enable) {
|
|
347
359
|
return;
|
|
348
360
|
}
|
|
349
|
-
packageJson.scripts['dev'] = devScript.replace('next dev',
|
|
361
|
+
packageJson.scripts['dev'] = devScript.replace('next dev', `next dev ${turboPackFlag}`);
|
|
350
362
|
return;
|
|
351
363
|
}
|
|
352
364
|
console.log(`${picocolors_1.default.yellow('⚠')} Could not find "${picocolors_1.default.bold('next dev')}" in your dev script.`);
|
|
353
365
|
const responseCustomDevScript = await (0, prompts_1.default)({
|
|
354
366
|
type: 'text',
|
|
355
367
|
name: 'customDevScript',
|
|
356
|
-
message:
|
|
368
|
+
message: `Please manually add "${turboPackFlag}" to your dev command.`,
|
|
357
369
|
initial: devScript,
|
|
358
370
|
}, { onCancel: utils_1.onCancel });
|
|
359
371
|
packageJson.scripts['dev'] =
|