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,8 +61,9 @@ async function loadHighestNPMVersionMatching(query: string) { ...@@ -60,8 +61,9 @@ async function loadHighestNPMVersionMatching(query: string) {
return versionOrVersions return versionOrVersions
} }
function endMessage() { function endMessage(targetNextVersion: string) {
console.log() console.log()
if (major(targetNextVersion) === 15) {
console.log( console.log(
pc.white( pc.white(
pc.bold( pc.bold(
...@@ -74,6 +76,7 @@ function endMessage() { ...@@ -74,6 +76,7 @@ function endMessage() {
'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