Skip to content
Merged
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
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ To speed up CI, we load balance the tests across multiple machines. The informat
is stored in `tests-metadata.json`, and later used by our test [runner](ava.config.js#L10). To regenerate the data (e.g.
when adding a new test file) run `npm test:measure` and commit the changes to GitHub.

### Testing locally

The `@netlify/testing` package will need to be built regardless of which package you are working on. In order to do this
run the following from the root directory:

```
npm run build -- --scope=@netlify/testing
```

If you wish to build all of the projects for whatever reason, the command is `npm run build`.

From there, you can run tests for a particular package by running:

```
npm run test -- --scope=<name of package as it appears in 'name' field in package.json>
```

For example, if you wished to run tests for the `build` package:

```
npm run test -- --scope=@netlify/build
```

## Releasing

For more details, please refer to the
Expand Down
3 changes: 0 additions & 3 deletions packages/build/src/core/feature_flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ export const DEFAULT_FEATURE_FLAGS = {
buildbot_zisi_esbuild_parser: false,
edge_functions_cache_cli: false,
edge_functions_system_logger: false,
// TODO: remove this flag once rolled out to everyone
// FF link: https://app.launchdarkly.com/default/production/features/plugins_break_builds_with_unsupported_plugin_versions/targeting
plugins_break_builds_with_unsupported_plugin_versions: false,
}
35 changes: 1 addition & 34 deletions packages/build/src/log/messages/compatibility.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import semver from 'semver'

import { addErrorInfo } from '../../error/info.js'
import { isRuntime } from '../../utils/runtime.js'
import { isPreviousMajor } from '../../utils/semver.js'
import { getPluginOrigin } from '../description.js'
Expand Down Expand Up @@ -84,17 +83,13 @@ const getVersionField = function ([versionFieldName, version]) {

// Print a warning message when old versions plugins are used.
// This can only happen when they are installed to `package.json`.
// Also throws an error if the Next runtime is >= 4.0.0 || < 4.26.0
export const logOutdatedPlugins = function (logs: BufferedLogs, pluginsOptions, featureFlags) {
export const logOutdatedPlugins = function (logs: BufferedLogs, pluginsOptions) {
const outdatedPlugins = pluginsOptions.filter(hasOutdatedVersion).map(getOutdatedPlugin)

if (outdatedPlugins.length === 0) {
return
}

// TODO: remove feature flag once fully rolled out
if (featureFlags.plugins_break_builds_with_unsupported_plugin_versions)
throwIfUnsupportedPluginVersion(pluginsOptions.filter(hasOutdatedVersion))
logWarningSubHeader(logs, 'Outdated plugins')
logWarningArray(logs, outdatedPlugins)
}
Expand Down Expand Up @@ -151,34 +146,6 @@ export const logIncompatiblePlugins = function (logs, pluginsOptions) {
logWarningArray(logs, incompatiblePlugins)
}

// Throws an error if the Next runtime is >= 4.0.0 || < 4.26.0, otherwise returns.
const throwIfUnsupportedPluginVersion = function (outdatedPlugins: any[]) {
let packageName
let version
let latestVersion
const nextOutdatedV4Plugin = outdatedPlugins.find((plugin) => {
packageName = plugin.pluginPackageJson.name
version = plugin.pluginPackageJson.version
latestVersion = plugin.latestVersion
// https://github.com/npm/node-semver#hyphen-ranges-xyz---abc
// semver hyphen range is inclusive 4.0.0 - 4.25.0 is same as >= 4.0.0 || < 4.26.0;
return (
packageName === '@netlify/plugin-nextjs' &&
semver.satisfies(version, '4.0.0 - 4.25.0', { includePrerelease: true })
)
})

if (!nextOutdatedV4Plugin) {
return
}

const error = new Error(
`This site cannot be built because it is using an outdated version of the Next.js Runtime: ${packageName}@${version}. Versions greater than 4.26.0 are recommended. To upgrade this plugin, please update its version in "package.json" to the latest version: ${latestVersion}. If you cannot use a more recent version, please contact support at https://www.netlify.com/support for guidance.`,
)
addErrorInfo(error, { type: 'pluginUnsupportedVersion' })
throw error
}

const hasIncompatibleVersion = function ({ pluginPackageJson: { version }, compatibleVersion, compatWarning }) {
return (
compatWarning !== '' &&
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/plugins/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CHILD_MAIN_FILE = fileURLToPath(new URL('child/main.js', import.meta.url))
const tStartPlugins = async function ({ pluginsOptions, buildDir, childEnv, logs, debug, featureFlags }) {
logRuntime(logs, pluginsOptions)
logLoadingPlugins(logs, pluginsOptions, debug)
logOutdatedPlugins(logs, pluginsOptions, featureFlags)
logOutdatedPlugins(logs, pluginsOptions)
logIncompatiblePlugins(logs, pluginsOptions)

const childProcesses = await Promise.all(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

59 changes: 0 additions & 59 deletions packages/build/tests/plugins_list/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -3405,62 +3405,3 @@ Generated by [AVA](https://avajs.dev).
␊
(Netlify Build completed in 1ms)␊
Build step duration: Netlify Build completed in 1ms`

## Errors if unsupported Next.js Runtime plugin version is installed in package.json

> Snapshot 1

`␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
Netlify Build ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
> Version␊
@netlify/build 1.0.0␊
␊
> Flags␊
debug: true␊
featureFlags:␊
- plugins_break_builds_with_unsupported_plugin_versions␊
repositoryRoot: packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json␊
testOpts:␊
pluginsListUrl: /test/socket␊
silentLingeringProcesses: true␊
␊
> Current directory␊
packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json␊
␊
> Config file␊
packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/netlify.toml␊
␊
> Resolved config␊
build:␊
publish: packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json␊
publishOrigin: default␊
plugins:␊
- inputs: {}␊
origin: config␊
package: '@netlify/plugin-nextjs'␊
␊
> Context␊
production␊
␊
> Available plugins␊
␊
> Using Next.js Runtime - v1.0.0␊
␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
Unsupported plugin version detected ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Error message␊
This site cannot be built because it is using an outdated version of the Next.js Runtime: @netlify/plugin-nextjs@1.0.0 Versions greater than 1.0.0 are recommended. To upgrade this plugin, please update its version in "package.json" to the latest version: 1.0.0. If you cannot use a more recent version, please contact support at https://www.netlify.com/support for guidance.␊
␊
Resolved config␊
build:␊
publish: packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json␊
publishOrigin: default␊
plugins:␊
- inputs: {}␊
origin: config␊
package: '@netlify/plugin-nextjs'`
6 changes: 0 additions & 6 deletions packages/build/tests/plugins_list/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,3 @@ test('`getExpectedVersion` matches prerelease versions', async (t) => {
t.is(version1, '1.0.0')
t.is(version2, '0.3.1-rc.1')
})

test('Errors if unsupported Next.js Runtime plugin version is installed in package.json', async (t) => {
await runWithApiMock(t, 'plugins_unsupported_version_package_json', {
featureFlags: { plugins_break_builds_with_unsupported_plugin_versions: true },
})
})