-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby): log config validation errors #23620
Conversation
linkPrefix: Joi.forbidden().error( | ||
new Error(`"linkPrefix" should be changed to "pathPrefix"`) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved from
gatsby/packages/gatsby/src/redux/reducers/config.js
Lines 21 to 23 in 874088c
if (normalizedPayload.linkPrefix) { | |
console.log(`"linkPrefix" should be changed to "pathPrefix"`) | |
} |
const action = setSiteConfig({}) | ||
expect(action.payload.pathPrefix).toBe(``) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are tests that previously were reducer tests adjusted to be action creator test (same scenarios)
@@ -47,6 +47,9 @@ export interface IGatsbyConfig { | |||
title?: string | |||
author?: string | |||
description?: string | |||
sireUrl?: string | |||
// siteMetadata is free form | |||
[key: string]: unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean - in context of gatsby core it doesn't matter much, because core doesn't make use of those fields really
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it might matter when we use those types for public index.d.ts
declaration instead of hand written one like we do right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, doesn't matter at all
Just weird to see those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed it here I think for tests in particular which were setting random thing (really random):
setSiteConfig({
someRandomThing: `hi people`,
plugins: [],
})
---edit - that was wrong example - see comment below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
above was wrong one - that one was failing - it was for this one:
const action = setSiteConfig({
siteMetadata: {
hi: true,
},
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
someRandomThing: `hi people`
This is almost as good as your house is on fire
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
@@ -47,6 +47,9 @@ export interface IGatsbyConfig { | |||
title?: string | |||
author?: string | |||
description?: string | |||
sireUrl?: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here... siteUrl
--> #24488
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈 Thanks!
Description
This fixes error that hides actual gatsby-config validation error.
It also converts config reducer to TS, adds typed action creator and converts validation error to structured one.
Before (
yarn build
- this one was hiding actual error):Before (
gatsby build
- this was "fine" - bit weirdly formatted - for the most part this PR just changes it to structured error in this case)After (both
yarn build
andgatsby build
):Related Issues
Fixes: #22812
Helps with #23468 (doesn't fix it, but makes it easier to see actual error)