Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
LichuAcu committed Sep 18, 2024
1 parent d7f5b3f commit 11f576c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
40 changes: 26 additions & 14 deletions packages/next-upgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,42 @@

Upgrade Next.js apps to newer or beta versions with one command.

# Build
```bash
npx @next/upgrade
```

## How to use it?

Simply run `npx @next/upgrade` in your project and follow the few prompts. This will let you choose between the latest canary, release candidate or stable version of Next.js.

To build the package locally, go to `packages/next-upgrade` and run:
You can also pass a specific Next.js version as an argument:

```bash
pnpm build && pnpm link --global
npx @next/upgrade 15.0.0-canary.148
```

In your Next.js app, add the following to your `package.json`:
`@next/upgrade` supports `pnpm`, `npm`, `yarn` and `bun`, and is compatible with monorepos.

```json
"dependencies": {
"@next/upgrade": "path/to/local/next.js/packages/next-upgrade"
}
```
## Why?

Finally, run:
Updating Next.js is not just merely running `pnpm update next` or its equivalent in your package manager of choice. It also involves updating `react`, `@types/react`, `react-dom`, `@types/react-dom`, and potentially other dependencies.

We noticed that trying out new or beta versions of Next.js was not as smooth as it could be, so we created this small tool that makes it easier.

## Contributing

To build the package locally, clone the [@vercel/next repo](https://github.com/vercel/next.js/), navigate to `packages/next-upgrade` and run:

```bash
pnpm i
pnpm build
```

Now you can use the package!
To test your local version of `@next/upgrade`, run `pnpm link --global` from the `@next/upgrade` directory and add the following to the `package.json` of your Next.js app:

```bash
npx @next/upgrade
```json
"dependencies": {
"@next/upgrade": "files:path/to/local/next.js/packages/next-upgrade"
}
```

Finally, run `pnpm i` and now you can use your local version of `@next/upgrade` with the standard `npx @next/upgrade` command.
4 changes: 0 additions & 4 deletions packages/next-upgrade/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ async function run(): Promise<void> {
stdio: 'inherit',
})

appPackageJson = JSON.parse(fs.readFileSync(appPackageJsonPath, 'utf8'))
appPackageJson.dependencies['next'] = targetVersionSpecifier
fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2))

console.log(
`\n${chalk.green('✔')} Your Next.js project has been upgraded successfully. ${chalk.bold('Time to ship! 🚢')}`
)
Expand Down

0 comments on commit 11f576c

Please sign in to comment.