Skip to content

Commit 1048576

Browse files
devjiwonchoipull[bot]
authored andcommitted
chore(next-upgrade): improve revision usage messages (vercel#71019)
### Why? WIthout specific usage example, it could be hard to do it right in the first time to pass the correct version (e.g. 15.0.0 instead of 15). Therefore improve messages and added help message usage.
1 parent 365f934 commit 1048576

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/next-codemod/bin/next-codemod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ program
4646
.description(
4747
'Upgrade Next.js apps to desired versions with a single command.'
4848
)
49-
5049
.argument(
5150
'[revision]',
52-
'NPM dist tag or exact version to upgrade to (e.g. "latest" or "15.0.0-canary.167"). Valid dist-tags are "latest", "canary" or "rc".',
51+
'Specify the target Next.js version using an NPM dist tag (e.g. "latest", "canary", "rc") or an exact version number (e.g. "15.0.0").',
5352
packageJson.version.includes('-canary.')
5453
? 'canary'
5554
: packageJson.version.includes('-rc.')
5655
? 'rc'
5756
: 'latest'
5857
)
58+
.usage('[revision] [options]')
5959
.option('--verbose', 'Verbose output', false)
6060
.action(runUpgrade)
6161

packages/next-codemod/bin/upgrade.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function runUpgrade(
5858
'peerDependencies' in targetNextPackageJson
5959
if (!validRevision) {
6060
console.error(
61-
`${pc.red('⨯')} ${pc.yellow(`next@${revision}`)} does not exist. Make sure you entered a valid Next.js version or dist-tag. Check available versions at ${pc.underline('https://www.npmjs.com/package/next?activeTab=versions')}.`
61+
`${pc.red('⨯')} Invalid revision provided: "${revision}". Please provide a valid Next.js version or dist-tag (e.g. "latest", "canary", "rc", or "15.0.0").\nCheck available versions at https://www.npmjs.com/package/next?activeTab=versions.`
6262
)
6363
process.exit(1)
6464
}
@@ -141,6 +141,7 @@ function getInstalledNextVersion(): string {
141141
).version
142142
} catch (error) {
143143
console.error(
144+
// TODO: Better monorepo handling
144145
`${pc.red('⨯')} Failed to get the installed Next.js version at "${process.cwd()}".\nIf you're using a monorepo, please run this command from the Next.js app directory.`
145146
)
146147
process.exit(1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy