From c520137096eac73ea6bdbf0e675f9fe8cd7726ac Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Fri, 16 Dec 2022 09:28:35 -0500 Subject: [PATCH 1/4] chore: remove plugins_break_builds_with_unsupported_plugin_versions feature flag --- packages/build/src/core/feature_flags.js | 3 - .../build/src/log/messages/compatibility.ts | 3 - .../tests/plugins_list/snapshots/tests.js.md | 59 ------------------- packages/build/tests/plugins_list/tests.js | 6 -- 4 files changed, 71 deletions(-) diff --git a/packages/build/src/core/feature_flags.js b/packages/build/src/core/feature_flags.js index a8462cfc03..e5186506d6 100644 --- a/packages/build/src/core/feature_flags.js +++ b/packages/build/src/core/feature_flags.js @@ -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, } diff --git a/packages/build/src/log/messages/compatibility.ts b/packages/build/src/log/messages/compatibility.ts index 9ea29591d2..fd57d4c609 100644 --- a/packages/build/src/log/messages/compatibility.ts +++ b/packages/build/src/log/messages/compatibility.ts @@ -92,9 +92,6 @@ export const logOutdatedPlugins = function (logs: BufferedLogs, pluginsOptions, 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) } diff --git a/packages/build/tests/plugins_list/snapshots/tests.js.md b/packages/build/tests/plugins_list/snapshots/tests.js.md index a293c05103..0f21d8fe0a 100644 --- a/packages/build/tests/plugins_list/snapshots/tests.js.md +++ b/packages/build/tests/plugins_list/snapshots/tests.js.md @@ -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'` diff --git a/packages/build/tests/plugins_list/tests.js b/packages/build/tests/plugins_list/tests.js index b10683882e..b4846b93a9 100644 --- a/packages/build/tests/plugins_list/tests.js +++ b/packages/build/tests/plugins_list/tests.js @@ -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 }, - }) -}) From ca088a3917e4462ab00dac72eedf970b6c795b30 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Fri, 16 Dec 2022 10:09:27 -0500 Subject: [PATCH 2/4] chore: more cleanup --- .../build/src/log/messages/compatibility.ts | 32 +------------------ packages/build/src/plugins/spawn.ts | 2 +- .../netlify.toml | 2 -- .../@netlify/plugin-nextjs/index.js | 3 -- .../@netlify/plugin-nextjs/manifest.yml | 2 -- .../@netlify/plugin-nextjs/package.json | 8 ----- .../package.json | 11 ------- 7 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/netlify.toml delete mode 100644 packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/index.js delete mode 100644 packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/manifest.yml delete mode 100644 packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/package.json delete mode 100644 packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/package.json diff --git a/packages/build/src/log/messages/compatibility.ts b/packages/build/src/log/messages/compatibility.ts index fd57d4c609..df51bd44cc 100644 --- a/packages/build/src/log/messages/compatibility.ts +++ b/packages/build/src/log/messages/compatibility.ts @@ -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' @@ -84,8 +83,7 @@ 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) { @@ -148,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 !== '' && diff --git a/packages/build/src/plugins/spawn.ts b/packages/build/src/plugins/spawn.ts index b7ce1991c8..7fd076acf0 100644 --- a/packages/build/src/plugins/spawn.ts +++ b/packages/build/src/plugins/spawn.ts @@ -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( diff --git a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/netlify.toml b/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/netlify.toml deleted file mode 100644 index eb9150bcd4..0000000000 --- a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/netlify.toml +++ /dev/null @@ -1,2 +0,0 @@ -[[plugins]] - package = "@netlify/plugin-nextjs" diff --git a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/index.js b/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/index.js deleted file mode 100644 index f7e96fc421..0000000000 --- a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export const onPreBuild = function () { - console.log('test') -} diff --git a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/manifest.yml b/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/manifest.yml deleted file mode 100644 index ce91925386..0000000000 --- a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/manifest.yml +++ /dev/null @@ -1,2 +0,0 @@ -name: '@netlify/plugin-nextjs' -inputs: [] diff --git a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/package.json b/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/package.json deleted file mode 100644 index f31a6cfa7b..0000000000 --- a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/node_modules/@netlify/plugin-nextjs/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "@netlify/plugin-nextjs", - "version": "4.16.0", - "type": "module", - "description": "test", - "license": "MIT", - "repository": "test" -} diff --git a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/package.json b/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/package.json deleted file mode 100644 index 3376c2e2af..0000000000 --- a/packages/build/tests/plugins_list/fixtures/plugins_unsupported_version_package_json/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "test", - "version": "0.0.1", - "type": "module", - "description": "test", - "license": "MIT", - "repository": "test", - "dependencies": { - "@netlify/plugin-nextjs": "4.16.0" - } -} From 4906b19f0bb0f958e398a5237a7094cec2d44e08 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Fri, 16 Dec 2022 10:26:23 -0500 Subject: [PATCH 3/4] chore: forgot to add the removal of a fixture --- .../fixtures/functions_package_json_invalid/package.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 packages/build/tests/functions/fixtures/functions_package_json_invalid/package.json diff --git a/packages/build/tests/functions/fixtures/functions_package_json_invalid/package.json b/packages/build/tests/functions/fixtures/functions_package_json_invalid/package.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/packages/build/tests/functions/fixtures/functions_package_json_invalid/package.json +++ /dev/null @@ -1 +0,0 @@ -{} From a6eaa8ef48f1decd3ef2c5bc4d37bae1724e9324 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Fri, 16 Dec 2022 10:31:31 -0500 Subject: [PATCH 4/4] docs: update CONTRIBUTING.md to include info on how to run tests locally --- CONTRIBUTING.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0535f4f5e..702e23d470 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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= +``` + +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