@next/codemod 15.0.2-canary.0 → 15.0.2-canary.10
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 -13
- 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,28 +326,46 @@ 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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}, { onCancel: utils_1.onCancel });
|
|
339
|
-
if (!responseTurbopack.enable) {
|
|
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';
|
|
336
|
+
if (!devScript) {
|
|
337
|
+
console.log(`${picocolors_1.default.yellow('⚠')} No "dev" script found in your package.json. Skipping Turbopack suggestion.`);
|
|
340
338
|
return;
|
|
341
339
|
}
|
|
342
340
|
if (devScript.includes('next dev')) {
|
|
343
|
-
|
|
341
|
+
// covers "--turbopack" as well
|
|
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
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const responseTurbopack = await (0, prompts_1.default)({
|
|
353
|
+
type: 'confirm',
|
|
354
|
+
name: 'enable',
|
|
355
|
+
message: `Enable Turbopack for ${picocolors_1.default.bold('next dev')}?`,
|
|
356
|
+
initial: true,
|
|
357
|
+
}, { onCancel: utils_1.onCancel });
|
|
358
|
+
if (!responseTurbopack.enable) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
packageJson.scripts['dev'] = devScript.replace('next dev', `next dev ${turboPackFlag}`);
|
|
344
362
|
return;
|
|
345
363
|
}
|
|
346
364
|
console.log(`${picocolors_1.default.yellow('⚠')} Could not find "${picocolors_1.default.bold('next dev')}" in your dev script.`);
|
|
347
365
|
const responseCustomDevScript = await (0, prompts_1.default)({
|
|
348
366
|
type: 'text',
|
|
349
367
|
name: 'customDevScript',
|
|
350
|
-
message:
|
|
368
|
+
message: `Please manually add "${turboPackFlag}" to your dev command.`,
|
|
351
369
|
initial: devScript,
|
|
352
370
|
}, { onCancel: utils_1.onCancel });
|
|
353
371
|
packageJson.scripts['dev'] =
|