-
Notifications
You must be signed in to change notification settings - Fork 976
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update FatalErrorPage codemod to work with hybrid JS/TS projects (#5366)
Co-authored-by: Dominic Saadi <32992335+jtoar@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
124 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
...rorPage/__testfixtures__/typescript/input/web/src/pages/FatalErrorPage/FatalErrorPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// This page will be rendered when an error makes it all the way to the top of the | ||
// application without being handled by a Javascript catch statement or React error | ||
// boundary. | ||
// | ||
// You can modify this page as you wish, but it is important to keep things simple to | ||
// avoid the possibility that it will cause its own error. If it does, Redwood will | ||
// still render a generic error page, but your users will prefer something a bit more | ||
// thoughtful. =) | ||
|
||
export default () => ( | ||
<main> | ||
<style | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
html, body { | ||
margin: 0; | ||
} | ||
html * { | ||
box-sizing: border-box; | ||
} | ||
main { | ||
display: flex; | ||
align-items: center; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; | ||
text-align: center; | ||
background-color: #E2E8F0; | ||
height: 100vh; | ||
} | ||
section { | ||
background-color: white; | ||
border-radius: 0.25rem; | ||
width: 32rem; | ||
padding: 1rem; | ||
margin: 0 auto; | ||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); | ||
} | ||
h1 { | ||
font-size: 2rem; | ||
margin: 0; | ||
font-weight: 500; | ||
line-height: 1; | ||
color: #2D3748; | ||
} | ||
`, | ||
}} | ||
/> | ||
<section> | ||
<h1> | ||
<span>Something went wrong</span> | ||
</h1> | ||
</section> | ||
</main> | ||
) |
61 changes: 61 additions & 0 deletions
61
...orPage/__testfixtures__/typescript/output/web/src/pages/FatalErrorPage/FatalErrorPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// This page will be rendered when an error makes it all the way to the top of the | ||
// application without being handled by a Javascript catch statement or React error | ||
// boundary. | ||
// | ||
// You can modify this page as you wish, but it is important to keep things simple to | ||
// avoid the possibility that it will cause its own error. If it does, Redwood will | ||
// still render a generic error page, but your users will prefer something a bit more | ||
// thoughtful. =) | ||
|
||
// Ensures that production builds do not include the error page | ||
let RedwoodDevFatalErrorPage = undefined | ||
if (process.env.NODE_ENV === 'development') { | ||
RedwoodDevFatalErrorPage = | ||
require('@redwoodjs/web/dist/components/DevFatalErrorPage').DevFatalErrorPage | ||
} | ||
|
||
export default RedwoodDevFatalErrorPage || | ||
(() => ( | ||
<main> | ||
<style | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
html, body { | ||
margin: 0; | ||
} | ||
html * { | ||
box-sizing: border-box; | ||
} | ||
main { | ||
display: flex; | ||
align-items: center; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; | ||
text-align: center; | ||
background-color: #E2E8F0; | ||
height: 100vh; | ||
} | ||
section { | ||
background-color: white; | ||
border-radius: 0.25rem; | ||
width: 32rem; | ||
padding: 1rem; | ||
margin: 0 auto; | ||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); | ||
} | ||
h1 { | ||
font-size: 2rem; | ||
margin: 0; | ||
font-weight: 500; | ||
line-height: 1; | ||
color: #2D3748; | ||
} | ||
`, | ||
}} | ||
/> | ||
<section> | ||
<h1> | ||
<span>Something went wrong</span> | ||
</h1> | ||
</section> | ||
</main> | ||
)) |
8 changes: 6 additions & 2 deletions
8
...ds/src/codemods/v0.50.x/updateDevFatalErrorPage/__tests__/updateDevFatalErrorPage.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { updateDevFatalErrorPage } from '../updateDevFatalErrorPage' | ||
|
||
describe('updateDevFatalErrorPage', () => { | ||
it('Replaces the FatalErrorPage with a new version that includes development info', async () => { | ||
await matchFolderTransform(updateDevFatalErrorPage, 'default') | ||
it('Replaces the JS FatalErrorPage with a new version that includes development info', async () => { | ||
await matchFolderTransform(updateDevFatalErrorPage, 'javascript') | ||
}) | ||
|
||
it('Replaces the TS FatalErrorPage with a new version that includes development info', async () => { | ||
await matchFolderTransform(updateDevFatalErrorPage, 'typescript') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters