Unverified Commit 48e84aac authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Version gate migration docs link (#84740)

Currently, it always logs 15 migration docs when upgrading, so version
gate it.

```
Results:
0 errors
41 unmodified
0 skipped
0 ok
Time elapsed: 2.276seconds

✔ Codemods have been applied successfully.

Please review the local changes and read the Next.js 15 migration guide to complete the migration.
https://nextjs.org/docs/canary/app/building-your-application/upgrading/version-15
```
parent f766f9b0
...@@ -4,6 +4,7 @@ import fs from 'fs' ...@@ -4,6 +4,7 @@ import fs from 'fs'
import { import {
satisfies as satisfiesVersionRange, satisfies as satisfiesVersionRange,
compare as compareVersions, compare as compareVersions,
major,
} from 'semver' } from 'semver'
import { execSync } from 'child_process' import { execSync } from 'child_process'
import path from 'path' import path from 'path'
...@@ -60,20 +61,22 @@ async function loadHighestNPMVersionMatching(query: string) { ...@@ -60,20 +61,22 @@ async function loadHighestNPMVersionMatching(query: string) {
return versionOrVersions return versionOrVersions
} }
function endMessage() { function endMessage(targetNextVersion: string) {
console.log() console.log()
console.log( if (major(targetNextVersion) === 15) {
pc.white( console.log(
pc.bold( pc.white(
`Please review the local changes and read the Next.js 15 migration guide to complete the migration.` pc.bold(
`Please review the local changes and read the Next.js 15 migration guide to complete the migration.`
)
) )
) )
) console.log(
console.log( pc.underline(
pc.underline( 'https://nextjs.org/docs/canary/app/building-your-application/upgrading/version-15'
'https://nextjs.org/docs/canary/app/building-your-application/upgrading/version-15' )
) )
) }
} }
const cwd = process.cwd() const cwd = process.cwd()
...@@ -118,14 +121,14 @@ export async function runUpgrade( ...@@ -118,14 +121,14 @@ export async function runUpgrade(
console.log( console.log(
`${pc.green('✓')} Current Next.js version is already on the target version "v${targetNextVersion}".` `${pc.green('✓')} Current Next.js version is already on the target version "v${targetNextVersion}".`
) )
endMessage() endMessage(targetNextVersion)
return return
} }
if (compareVersions(installedNextVersion, targetNextVersion) > 0) { if (compareVersions(installedNextVersion, targetNextVersion) > 0) {
console.log( console.log(
`${pc.green('✓')} Current Next.js version is higher than the target version "v${targetNextVersion}".` `${pc.green('✓')} Current Next.js version is higher than the target version "v${targetNextVersion}".`
) )
endMessage() endMessage(targetNextVersion)
return return
} }
...@@ -361,7 +364,7 @@ export async function runUpgrade( ...@@ -361,7 +364,7 @@ export async function runUpgrade(
warnDependenciesOutOfRange(appPackageJson, versionMapping) warnDependenciesOutOfRange(appPackageJson, versionMapping)
endMessage() endMessage(targetNextVersion)
} }
function getInstalledNextVersion(): string { function getInstalledNextVersion(): string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment