Skip to content

feat: rename next.js adapter package #6896

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/utils/init/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const formatTitle = (title: string) => chalk.cyan(title)
* @returns
*/
export const getPluginsToAutoInstall = (
command: BaseCommand,
_command: BaseCommand,
pluginsInstalled: string[] = [],
pluginsRecommended: string[] = [],
) => {
const nextRuntime = '@netlify/plugin-nextjs'
const nextRuntime = '@opennextjs/netlify'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me a while to understand — this is part of 'init' i.e. used in ntl init and related scenarios, and its purpose is to literally auto-install the plugin on the site via the Netlify API if it isn't already installed and we've detected that it should be. So it's OK to just update this name and not "handle" the old name in any way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... although, wait, isn't there a case like this?

  1. next.js site exists today with @netlify/plugin-nextjs installed
  2. we release this cli change
  3. user clones their repo, runs ntl init, it checks and finds that @opennextjs/netlify is not auto-installed (even though @netlify/plugin-nextjs is) and auto-installs @opennextjs/netlify.
  4. user has both plugins installed

const pluginsToAlwaysInstall = new Set([nextRuntime])
return pluginsRecommended.reduce(
(acc, plugin) =>
Expand Down Expand Up @@ -100,10 +100,10 @@ export const getBuildSettings = async ({ command, config }: { command: BaseComma
// eslint-disable-next-line unicorn/explicit-length-check
const setting: Partial<Settings> = settings.length > 0 ? settings[0] : {}
const { defaultBaseDir, defaultBuildCmd, defaultBuildDir, defaultFunctionsDir, recommendedPlugins } =
await normalizeSettings(setting, config, command)
normalizeSettings(setting, config, command)

if (recommendedPlugins.length !== 0 && setting.framework?.name) {
log(`Configuring ${formatTitle(setting.framework.name)} runtime...`)
log(`Configuring ${formatTitle(setting.framework.name)}...`)
log()
}

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/commands/init/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe.concurrent('commands/init', () => {
method: 'patch',
response: { deploy_hook: 'deploy_hook' },
requestBody: {
plugins: [{ package: '@netlify/plugin-nextjs' }],
plugins: [{ package: '@opennextjs/netlify' }],
repo: {
allowed_branches: ['main'],
cmd: command,
Expand Down Expand Up @@ -377,7 +377,7 @@ describe.concurrent('commands/init', () => {
method: 'patch',
response: { deploy_hook: 'deploy_hook' },
requestBody: {
plugins: [{ package: '@netlify/plugin-nextjs' }],
plugins: [{ package: '@opennextjs/netlify' }],
repo: {
allowed_branches: ['main'],
cmd: command,
Expand Down Expand Up @@ -466,7 +466,7 @@ describe.concurrent('commands/init', () => {
method: 'patch',
response: { deploy_hook: 'deploy_hook' },
requestBody: {
plugins: [{ package: '@netlify/plugin-lighthouse' }, { package: '@netlify/plugin-nextjs' }],
plugins: [{ package: '@netlify/plugin-lighthouse' }, { package: '@opennextjs/netlify' }],
repo: {
allowed_branches: ['main'],
cmd: command,
Expand Down
Loading