Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
feat: support Gatsby 3.x (#36)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Requires Node@>=12.13.x
BREAKING CHANGE: Requires Gatsby@^3.x
  • Loading branch information
MichaelDeBoey authored Apr 15, 2021
1 parent 7684232 commit 8432152
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
61 changes: 25 additions & 36 deletions src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -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),
});
1 change: 0 additions & 1 deletion tests/setup-env.js

This file was deleted.

0 comments on commit 8432152

Please sign in to comment.