Repository: netlify/build
Pull request #3916 (2021-12-02 14:21:36)

fix(deps): update dependency @netlify/plugins-list to v6
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| @&#8203;netlify/plugins-list | [`^5.0.0` -> `^6.0.1`](https://renovatebot.com/diffs/npm/@netlify%2fplugins-list/5.0.0/6.0.1) | [![age](https://badges.renovateapi.com/packages/npm/@netlify%2fplugins-list/6.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@netlify%2fplugins-list/6.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@netlify%2fplugins-list/6.0.1/compatibility-slim/5.0.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@netlify%2fplugins-list/6.0.1/confidence-slim/5.0.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/netlify/build).


Patch:
diff --git a/package-lock.json b/package-lock.json
index d1064618e..958f28d89 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2335,9 +2335,9 @@
       }
     },
     "node_modules/@netlify/plugins-list": {
-      "version": "5.0.0",
-      "resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-5.0.0.tgz",
-      "integrity": "sha512-reoPM+p/1Sm85KAPIwKr4+WVIneSVJZIZbo54VqZqvQJwcm/4CmyB4kUTthBIkY+b7chPcYEmqfvZxY9EfplAQ==",
+      "version": "6.0.1",
+      "resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.0.1.tgz",
+      "integrity": "sha512-HD8YgP43GGpgSOowBIW8Yb9+IvFlRGYq+X7Ee7G0okgOjzmgLy0En6JZ1shl0lGpuO8UX5EtLwDiLst3m/UIvg==",
       "engines": {
         "node": "^12.20.0 || ^14.14.0 || >=16.0.0"
       }
@@ -15807,7 +15807,7 @@
     },
     "packages/build": {
       "name": "@netlify/build",
-      "version": "20.0.2",
+      "version": "20.0.3",
       "license": "MIT",
       "dependencies": {
         "@bugsnag/js": "^7.0.0",
@@ -15816,7 +15816,7 @@
         "@netlify/functions-utils": "^3.0.0",
         "@netlify/git-utils": "^3.0.0",
         "@netlify/plugin-edge-handlers": "^3.0.0",
-        "@netlify/plugins-list": "^5.0.0",
+        "@netlify/plugins-list": "^6.0.1",
         "@netlify/run-utils": "^3.0.0",
         "@netlify/zip-it-and-ship-it": "^5.2.0",
         "@sindresorhus/slugify": "^1.1.0",
@@ -17988,7 +17988,7 @@
         "@netlify/git-utils": "^3.0.0",
         "@netlify/nock-udp": "^1.0.0",
         "@netlify/plugin-edge-handlers": "^3.0.0",
-        "@netlify/plugins-list": "^5.0.0",
+        "@netlify/plugins-list": "^6.0.1",
         "@netlify/run-utils": "^3.0.0",
         "@netlify/zip-it-and-ship-it": "^5.2.0",
         "@sindresorhus/slugify": "^1.1.0",
@@ -18539,9 +18539,9 @@
       }
     },
     "@netlify/plugins-list": {
-      "version": "5.0.0",
-      "resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-5.0.0.tgz",
-      "integrity": "sha512-reoPM+p/1Sm85KAPIwKr4+WVIneSVJZIZbo54VqZqvQJwcm/4CmyB4kUTthBIkY+b7chPcYEmqfvZxY9EfplAQ=="
+      "version": "6.0.1",
+      "resolved": "https://registry.npmjs.org/@netlify/plugins-list/-/plugins-list-6.0.1.tgz",
+      "integrity": "sha512-HD8YgP43GGpgSOowBIW8Yb9+IvFlRGYq+X7Ee7G0okgOjzmgLy0En6JZ1shl0lGpuO8UX5EtLwDiLst3m/UIvg=="
     },
     "@netlify/run-utils": {
       "version": "file:packages/run-utils",
diff --git a/packages/build/package.json b/packages/build/package.json
index 7eaa7dff5..db2237843 100644
--- a/packages/build/package.json
+++ b/packages/build/package.json
@@ -59,7 +59,7 @@
     "@netlify/functions-utils": "^3.0.0",
     "@netlify/git-utils": "^3.0.0",
     "@netlify/plugin-edge-handlers": "^3.0.0",
-    "@netlify/plugins-list": "^5.0.0",
+    "@netlify/plugins-list": "^6.0.1",
     "@netlify/run-utils": "^3.0.0",
     "@netlify/zip-it-and-ship-it": "^5.2.0",
     "@sindresorhus/slugify": "^1.1.0",
diff --git a/packages/build/src/plugins/list.js b/packages/build/src/plugins/list.js
index 78c5a5624..ff36fef41 100644
--- a/packages/build/src/plugins/list.js
+++ b/packages/build/src/plugins/list.js
@@ -1,9 +1,11 @@
 'use strict'
 
-const { pluginsList: oldPluginsList, pluginsUrl } = require('@netlify/plugins-list')
 const got = require('got')
 const isPlainObj = require('is-plain-obj')
 
+// TODO: use static `import` after migrating this repository to pure ES modules
+const netlifyPluginsList = import('@netlify/plugins-list')
+
 const { logPluginsList } = require('../log/messages/plugins')
 const { logPluginsFetchError } = require('../log/messages/plugins')
 
@@ -16,14 +18,16 @@ const { CONDITIONS } = require('./compatibility')
 // make this request is somewhat ok (in the 100ms range).
 // We only fetch this plugins list when needed, i.e. we defer it as much as
 // possible.
-const getPluginsList = async function ({ debug, logs, testOpts: { pluginsListUrl = pluginsUrl } }) {
+const getPluginsList = async function ({ debug, logs, testOpts: { pluginsListUrl } }) {
   // We try not to mock in integration tests. However, sending a request for
   // each test would be too slow and make tests unreliable.
   if (pluginsListUrl === 'test') {
     return []
   }
 
-  const pluginsList = await fetchPluginsList({ logs, pluginsListUrl })
+  const { pluginsUrl } = await netlifyPluginsList
+  const pluginsListUrlA = pluginsListUrl === undefined ? pluginsUrl : pluginsListUrl
+  const pluginsList = await fetchPluginsList({ logs, pluginsListUrl: pluginsListUrlA })
   const pluginsListA = normalizePluginsList(pluginsList)
   logPluginsList({ pluginsList: pluginsListA, debug, logs })
   return pluginsListA
@@ -46,6 +50,7 @@ const fetchPluginsList = async function ({ logs, pluginsListUrl }) {
     //    buildbot release.
   } catch (error) {
     logPluginsFetchError(logs, error.message)
+    const { pluginsList: oldPluginsList } = await netlifyPluginsList
     return oldPluginsList
   }
 }


Test patch:
diff --git a/packages/build/tests/plugins/tests.js b/packages/build/tests/plugins/tests.js
index 1d6d1b62d..fb0d7806a 100644
--- a/packages/build/tests/plugins/tests.js
+++ b/packages/build/tests/plugins/tests.js
@@ -5,13 +5,15 @@ const { normalize } = require('path')
 const { platform } = require('process')
 const { promisify } = require('util')
 
-const { pluginsList } = require('@netlify/plugins-list')
 const test = require('ava')
 const cpy = require('cpy')
 const del = require('del')
 const pathExists = require('path-exists')
 const { spy } = require('sinon')
 
+// TODO: use static `import` after migrating this repository to pure ES modules
+const netlifyPluginsList = import('@netlify/plugins-list')
+
 const { removeDir } = require('../helpers/dir')
 const { runFixture, FIXTURES_DIR } = require('../helpers/main')
 const { startServer } = require('../helpers/server')
@@ -1054,15 +1056,11 @@ test('Do not allow overriding core plugins', async (t) => {
   await runFixture(t, 'core_override')
 })
 
-const runWithApiMock = async function (
-  t,
-  fixtureName,
-  { testPlugin, response = getPluginsList(testPlugin), ...flags } = {},
-  status = 200,
-) {
+const runWithApiMock = async function (t, fixtureName, { testPlugin, response, ...flags } = {}, status = 200) {
+  const responseA = response === undefined ? await getPluginsList(testPlugin) : response
   const { scheme, host, stopServer } = await startServer({
     path: PLUGINS_LIST_URL,
-    response,
+    response: responseA,
     status,
   })
   try {
@@ -1079,7 +1077,8 @@ const runWithApiMock = async function (
 
 // We use a specific plugin in tests. We hardcode its version to keep the tests
 // stable even when new versions of that plugin are published.
-const getPluginsList = function (testPlugin = DEFAULT_TEST_PLUGIN) {
+const getPluginsList = async function (testPlugin = DEFAULT_TEST_PLUGIN) {
+  const { pluginsList } = await netlifyPluginsList
   return pluginsList.map((plugin) => getPlugin(plugin, testPlugin))
 }
 
@@ -1380,7 +1379,7 @@ const getNodePath = function (nodeVersion) {
 const runWithUpdatePluginMock = async function (t, fixture, { flags, status, sendStatus = true, testPlugin } = {}) {
   const { scheme, host, requests, stopServer } = await startServer([
     { path: UPDATE_PLUGIN_PATH, status },
-    { path: PLUGINS_LIST_URL, response: getPluginsList(testPlugin), status: 200 },
+    { path: PLUGINS_LIST_URL, response: await getPluginsList(testPlugin), status: 200 },
   ])
   try {
     await runFixture(t, fixture, {
@@ -1464,7 +1463,7 @@ const runWithPluginRunsMock = async function (
 ) {
   const { scheme, host, requests, stopServer } = await startServer([
     { path: PLUGIN_RUNS_PATH, response: pluginRuns, status },
-    { path: PLUGINS_LIST_URL, response: getPluginsList(testPlugin), status: 200 },
+    { path: PLUGINS_LIST_URL, response: await getPluginsList(testPlugin), status: 200 },
   ])
   try {
     await runFixture(t, fixture, {