Skip to content
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

fix: show incompatible plugins for major changes as well #5549

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions packages/build/src/log/messages/compatibility.ts
@@ -1,7 +1,6 @@
import semver from 'semver'

import { isRuntime } from '../../utils/runtime.js'
import { isPreviousMajor } from '../../utils/semver.js'
import { getPluginOrigin } from '../description.js'
import { BufferedLogs, logArray, logSubHeader, logWarningArray, logWarningSubHeader } from '../logger.js'
import { THEME } from '../theme.js'
Expand Down Expand Up @@ -149,7 +148,7 @@ const getUpgradeInstruction = function (loadedFrom, origin) {
// Print a warning message when plugins are using a version that is too recent
// and does not meet some `compatibility` expectations.
// This can only happen when they are installed to `package.json`.
export const logIncompatiblePlugins = function (logs, pluginsOptions) {
export const logIncompatiblePlugins = function (logs: BufferedLogs, pluginsOptions) {
const incompatiblePlugins = pluginsOptions.filter(hasIncompatibleVersion).map(getIncompatiblePlugin)

if (incompatiblePlugins.length === 0) {
Expand All @@ -161,16 +160,7 @@ export const logIncompatiblePlugins = function (logs, pluginsOptions) {
}

const hasIncompatibleVersion = function ({ pluginPackageJson: { version }, compatibleVersion, compatWarning }) {
return (
compatWarning !== '' &&
version !== undefined &&
compatibleVersion !== undefined &&
// Using only the major version prevents printing this warning message when
Copy link
Member

Choose a reason for hiding this comment

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

Is this no longer a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sadly this code already dates back my knowledge, but based on the comment I would assume that this "race" condition is super rare.

It might occur still but the worst case in this scenario is that we show a misleading warning in those edge cases.

Where as in the case of the next.js runtime we don't show this warnings as all (as it's a newer major by design).

I think for all new major versions that we release on plugins we still want to show why it did not used the incompatible (new major) version?

// a site is using the right `compatibility` version, but is using the most
// recent version due to the time gap between `npm publish` and the
// `plugins.json` update
isPreviousMajor(compatibleVersion, version)
)
return compatWarning !== '' && version !== undefined && compatibleVersion !== undefined
}

const getIncompatiblePlugin = function ({
Expand Down
27 changes: 27 additions & 0 deletions packages/build/tests/plugins_list/snapshots/tests.js.md
Expand Up @@ -820,6 +820,9 @@ Generated by [AVA](https://avajs.dev).
> Loading plugins␊
- netlify-plugin-contextual-env 0-4-0 from netlify.toml and package.json (latest 0-4-0, expected 0-4-1, compatible 0-4-1)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-4-0: version 1.0.0 is the most recent version compatible with Node.js <100␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -937,6 +940,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-1-0: latest version is 0-3-0␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-1-0: version 1.0.0 is the most recent version compatible with Node.js <100␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -999,6 +1005,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-1-0: latest version is 0-3-0␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-1-0: version 1.0.0 is the most recent version compatible with Node.js <100␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -1185,6 +1194,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-2-0: latest version is 0-3-0␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-2-0: version 1.0.0 is the most recent version compatible with Node.js 6 - 120␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -1306,6 +1318,9 @@ Generated by [AVA](https://avajs.dev).
Migration guide: http://test.com␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-1-0: version 1.0.0 is the most recent version compatible with Node.js <100␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -1368,6 +1383,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-2-0: latest version is 0-3-0␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-2-0: version 1.0.0 is the most recent version compatible with ansi-styles@<3␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -1604,6 +1622,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-2-0: latest version is 0-3-0␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-2-0: version 1.0.0 is the most recent version compatible with ansi-styles@<3, Node.js <100␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -1666,6 +1687,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-2-0: latest version is 0-3-0␊
To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-2-0: version 1.0.0 is the most recent version compatible with @netlify/dependency-with-range@<10␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down Expand Up @@ -2627,6 +2651,9 @@ Generated by [AVA](https://avajs.dev).
- netlify-plugin-contextual-env 0-3-0: latest version is 1-0-0␊
To upgrade this plugin, please uninstall and re-install it from the Netlify plugins directory (https://app.netlify.com/plugins)␊
␊
> Incompatible plugins␊
- netlify-plugin-contextual-env 0-3-0: version 1.0.0 is the most recent version compatible with Node.js <100␊
␊
netlify-plugin-contextual-env (onPreBuild event) ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Expand Down
Binary file modified packages/build/tests/plugins_list/snapshots/tests.js.snap
Binary file not shown.