From 8432152129a8418d71e508631d837b57b92f9e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 15 Apr 2021 14:22:59 +0200 Subject: [PATCH] feat: support Gatsby 3.x (#36) BREAKING CHANGE: Requires Node@>=12.13.x BREAKING CHANGE: Requires Gatsby@^3.x --- .github/workflows/validate.yml | 2 +- package.json | 6 ++-- src/gatsby-node.js | 61 ++++++++++++++-------------------- tests/setup-env.js | 1 - 4 files changed, 29 insertions(+), 41 deletions(-) delete mode 100644 tests/setup-env.js diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index db064fa..539fa5a 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -16,7 +16,7 @@ jobs: if: ${{ !contains(github.head_ref, 'all-contributors') }} strategy: matrix: - node: [10.13, 10, 12, 14] + node: [12.13, 12, 14, 15] runs-on: ubuntu-latest steps: - name: 🛑 Cancel Previous Runs diff --git a/package.json b/package.json index b0d6178..7dcb8da 100644 --- a/package.json +++ b/package.json @@ -36,14 +36,14 @@ "@babel/runtime": "^7.13.10" }, "devDependencies": { - "gatsby-plugin-utils": "^0.9.0", + "gatsby-plugin-utils": "^1.2.0", "kcd-scripts": "^9.0.0" }, "peerDependencies": { - "gatsby": "^2.20.0" + "gatsby": "^3.0.0" }, "engines": { - "node": ">=10.13.0", + "node": ">=12.13.0", "npm": ">=6" } } diff --git a/src/gatsby-node.js b/src/gatsby-node.js index a413adf..565c0bb 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -1,37 +1,26 @@ -if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) { - const getDeprecatedOptions = ({ Joi }) => - ["round", "tall"].reduce( - (allOptions, option) => ({ - ...allOptions, - [option]: Joi.boolean() - .forbidden() - .messages({ - "any.unknown": `'${option}' is no longer supported. Use 'saveButton.${option}' instead by setting it to the same value you had before on '${option}'.`, - }), - }), - {}, - ); +const getDeprecatedOptions = ({ Joi }) => + ["round", "tall"].reduce( + (allOptions, option) => ({ + ...allOptions, + [option]: Joi.boolean() + .forbidden() + .messages({ + "any.unknown": `'${option}' is no longer supported. Use 'saveButton.${option}' instead by setting it to the same value you had before on '${option}'.`, + }), + }), + {}, + ); - exports.pluginOptionsSchema = ({ Joi }) => - Joi.object({ - ...getDeprecatedOptions({ Joi }), - saveButton: Joi.alternatives() - .try( - Joi.boolean(), - Joi.object({ - round: Joi.boolean().default(false), - tall: Joi.boolean().default(true), - }), - ) - .default(false), - }); -} else { - const deprecationWarning = `[gatsby-plugin-pinterest] From now on, you should use the 'saveButton' option to show Pinterest's save button on images. -See https://github.com/robinmetral/gatsby-plugin-pinterest#usage`; - - exports.onPreInit = ({ reporter }, { round, tall } = {}) => { - if (round || tall) { - reporter.warn(deprecationWarning); - } - }; -} +exports.pluginOptionsSchema = ({ Joi }) => + Joi.object({ + ...getDeprecatedOptions({ Joi }), + saveButton: Joi.alternatives() + .try( + Joi.boolean(), + Joi.object({ + round: Joi.boolean().default(false), + tall: Joi.boolean().default(true), + }), + ) + .default(false), + }); diff --git a/tests/setup-env.js b/tests/setup-env.js deleted file mode 100644 index 1eaf066..0000000 --- a/tests/setup-env.js +++ /dev/null @@ -1 +0,0 @@ -process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION = "true";