-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[autoconfig] Bump Next.js minimum versions & provide an automatic upgrade path #14892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| "@cloudflare/autoconfig": minor | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Bump Next.js minimum versions and provide an automatic upgrade path | ||
|
|
||
| `@opennextjs/cloudflare` declares a Next.js peer range of `>=15.5.21 <16 || >=16.2.11`, so projects on earlier 15.x or 16.x releases sit outside the versions the adapter supports. | ||
|
|
||
| Autoconfig previously ran `@opennextjs/cloudflare migrate --force-install`. That flag just passes `--force` to the package manager. The peer dependency error becomes a warning buried in the install output, Next.js stays on its unsupported version, and setup finishes with a success message. | ||
|
|
||
| Autoconfig now recognises the supported floors and offers to update an unsupported project in place, staying within its existing major version. The update is listed in the setup summary before you confirm, and is applied before any other project changes are made. `--force-install` is no longer passed, so a real dependency conflict is reported rather than forced. | ||
|
|
||
| Two cases are not updated automatically and ask you to update Next.js yourself. Next.js 14 now falls outside the adapter's peer range entirely, and Next.js 15.0.x cannot be updated in place because `create-next-app` pinned React to a 19 prerelease before Next.js 15.1, which no supported Next.js version accepts as a peer. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,26 @@ | ||
| import { brandColor, dim } from "@cloudflare/cli-shared-helpers/colors"; | ||
| import { runCommand } from "@cloudflare/cli-shared-helpers/command"; | ||
| import { installPackages } from "@cloudflare/cli-shared-helpers/packages"; | ||
| import { Framework } from "./framework-class"; | ||
| import type { | ||
| ConfigurationOptions, | ||
| ConfigurationResults, | ||
| FrameworkVersionUpgradeOptions, | ||
| } from "./framework-class"; | ||
|
|
||
| export class NextJs extends Framework { | ||
| async upgradeFrameworkVersion({ | ||
| upgradeTo, | ||
| packageManager, | ||
| isWorkspaceRoot, | ||
| }: FrameworkVersionUpgradeOptions): Promise<void> { | ||
| await installPackages(packageManager.type, [`next@${upgradeTo}`], { | ||
| isWorkspaceRoot, | ||
| startText: `Updating Next.js to ${upgradeTo}`, | ||
| doneText: `${brandColor("updated")} ${dim(`Next.js to ${upgradeTo}`)}`, | ||
| }); | ||
| } | ||
|
Comment on lines
+18
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Framework version update can be applied to the wrong directory when the project is not the current directory The Next.js update is installed in whatever directory the command happens to be running in ( Mechanism: installPackages resolves the install target from process.cwd(), while the rest of autoconfig uses autoConfigDetails.projectPath
Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think this is how it's done in all the other framework files – they use don't use |
||
|
|
||
| async configure({ | ||
| dryRun, | ||
| projectPath, | ||
|
|
@@ -14,20 +29,9 @@ export class NextJs extends Framework { | |
| const { npx, dlx } = packageManager; | ||
|
|
||
| if (!dryRun) { | ||
| await runCommand( | ||
| [ | ||
| ...dlx, | ||
| "@opennextjs/cloudflare", | ||
| "migrate", | ||
| // Note: we force-install so that even if an incompatible version of | ||
| // Next.js is used this installation still succeeds, moving users | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given the intent of this comment, should we fallback to force installing if someone is on a version of nextjs that we can't upgrade for them? this way they'll still have all the cloudflare config files etc. and we can tell them to sort out the framework version later
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For next 14 and 15.0.x? can do, but I think that will require a bit of a refactor as currently anything below I feel like an alternative might be a custom error message when next 14 is detected which tells people how to use the next codemod to upgrade. then, they upgrade first and |
||
| // (hopefully) in right direction (instead of failing at this step) | ||
| "--force-install", | ||
| ], | ||
| { | ||
| cwd: projectPath, | ||
| } | ||
| ); | ||
| await runCommand([...dlx, "@opennextjs/cloudflare", "migrate"], { | ||
| cwd: projectPath, | ||
| }); | ||
| } | ||
|
|
||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not use semiver which is already installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do but it can't handle
satisfiesstrings, only individual comparisons, so configuration would have to be a bit more wordydoes something like this work, and then semiver can be used: