+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.mock.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.mock.js
new file mode 100644
index 000000000000..6db709e2edb6
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.mock.js
@@ -0,0 +1,6 @@
+// Define your own mock data here:
+export const standard = (/* vars, { ctx, req } */) => ({
+ test: {
+ id: 42,
+ },
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.stories.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.stories.js
new file mode 100644
index 000000000000..198bb1ca9df2
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.stories.js
@@ -0,0 +1,20 @@
+import { Loading, Empty, Failure, Success } from './TestCell'
+import { standard } from './TestCell.mock'
+
+export const loading = () => {
+ return Loading ? : <>>
+}
+
+export const empty = () => {
+ return Empty ? : <>>
+}
+
+export const failure = (args) => {
+ return Failure ? : <>>
+}
+
+export const success = (args) => {
+ return Success ? : <>>
+}
+
+export default { title: 'Cells/TestCell' }
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.test.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.test.js
new file mode 100644
index 000000000000..daee05047212
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestCell/TestCell.test.js
@@ -0,0 +1,41 @@
+import { render } from '@redwoodjs/testing/web'
+import { Loading, Empty, Failure, Success } from './TestCell'
+import { standard } from './TestCell.mock'
+
+// Generated boilerplate tests do not account for all circumstances
+// and can fail without adjustments, e.g. Float and DateTime types.
+// Please refer to the RedwoodJS Testing Docs:
+// https://redwoodjs.com/docs/testing#testing-cells
+// https://redwoodjs.com/docs/testing#jest-expect-type-considerations
+
+describe('TestCell', () => {
+ it('renders Loading successfully', () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+
+ it('renders Empty successfully', async () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+
+ it('renders Failure successfully', async () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+
+ // When you're ready to test the actual output of your component render
+ // you could test that, for example, certain text is present:
+ //
+ // 1. import { screen } from '@redwoodjs/testing/web'
+ // 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument()
+
+ it('renders Success successfully', async () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.js
new file mode 100644
index 000000000000..0dca58476b8e
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.js
@@ -0,0 +1,10 @@
+const TestComponent = () => {
+ return (
+
+
{'TestComponent'}
+
{'Find me in ./web/src/components/TestComponent/TestComponent.js'}
+
+ )
+}
+
+export default TestComponent
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.stories.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.stories.js
new file mode 100644
index 000000000000..1c3ee40e258b
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.stories.js
@@ -0,0 +1,21 @@
+// When you've added props to your component,
+// pass Storybook's `args` through this story to control it from the addons panel:
+//
+// ```jsx
+// export const generated = (args) => {
+// return
+// }
+// ```
+//
+// See https://storybook.js.org/docs/react/writing-stories/args.
+
+import TestComponent from './TestComponent'
+
+export const generated = () => {
+ return
+}
+
+export default {
+ title: 'Components/TestComponent',
+ component: TestComponent,
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.test.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.test.js
new file mode 100644
index 000000000000..0bc0a7cad920
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/components/TestComponent/TestComponent.test.js
@@ -0,0 +1,14 @@
+import { render } from '@redwoodjs/testing/web'
+
+import TestComponent from './TestComponent'
+
+// Improve this test with help from the Redwood Testing Doc:
+// https://redwoodjs.com/docs/testing#testing-components
+
+describe('TestComponent', () => {
+ it('renders successfully', () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/index.css b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/index.css
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/index.html b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/index.html
new file mode 100644
index 000000000000..e240b8eb8c54
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.js
new file mode 100644
index 000000000000..f46b6ceba653
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.js
@@ -0,0 +1,5 @@
+const TestLayout = ({ children }) => {
+ return <>{children}>
+}
+
+export default TestLayout
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.stories.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.stories.js
new file mode 100644
index 000000000000..03ee1ff33b19
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.stories.js
@@ -0,0 +1,10 @@
+import TestLayout from './TestLayout'
+
+export const generated = (args) => {
+ return
+}
+
+export default {
+ title: 'Layouts/TestLayout',
+ component: TestLayout,
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.test.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.test.js
new file mode 100644
index 000000000000..ad9336038eb1
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/layouts/TestLayout/TestLayout.test.js
@@ -0,0 +1,14 @@
+import { render } from '@redwoodjs/testing/web'
+
+import TestLayout from './TestLayout'
+
+// Improve this test with help from the Redwood Testing Doc:
+// https://redwoodjs.com/docs/testing#testing-pages-layouts
+
+describe('TestLayout', () => {
+ it('renders successfully', () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/pages/FatalErrorPage/FatalErrorPage.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/pages/FatalErrorPage/FatalErrorPage.js
new file mode 100644
index 000000000000..7ff31af1a7f4
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/input/web/src/pages/FatalErrorPage/FatalErrorPage.js
@@ -0,0 +1,62 @@
+// 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 ||
+ (() => (
+
+
+
+
+
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.mock.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.mock.js
new file mode 100644
index 000000000000..6db709e2edb6
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.mock.js
@@ -0,0 +1,6 @@
+// Define your own mock data here:
+export const standard = (/* vars, { ctx, req } */) => ({
+ test: {
+ id: 42,
+ },
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.stories.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.stories.jsx
new file mode 100644
index 000000000000..198bb1ca9df2
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.stories.jsx
@@ -0,0 +1,20 @@
+import { Loading, Empty, Failure, Success } from './TestCell'
+import { standard } from './TestCell.mock'
+
+export const loading = () => {
+ return Loading ? : <>>
+}
+
+export const empty = () => {
+ return Empty ? : <>>
+}
+
+export const failure = (args) => {
+ return Failure ? : <>>
+}
+
+export const success = (args) => {
+ return Success ? : <>>
+}
+
+export default { title: 'Cells/TestCell' }
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.test.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.test.jsx
new file mode 100644
index 000000000000..daee05047212
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestCell/TestCell.test.jsx
@@ -0,0 +1,41 @@
+import { render } from '@redwoodjs/testing/web'
+import { Loading, Empty, Failure, Success } from './TestCell'
+import { standard } from './TestCell.mock'
+
+// Generated boilerplate tests do not account for all circumstances
+// and can fail without adjustments, e.g. Float and DateTime types.
+// Please refer to the RedwoodJS Testing Docs:
+// https://redwoodjs.com/docs/testing#testing-cells
+// https://redwoodjs.com/docs/testing#jest-expect-type-considerations
+
+describe('TestCell', () => {
+ it('renders Loading successfully', () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+
+ it('renders Empty successfully', async () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+
+ it('renders Failure successfully', async () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+
+ // When you're ready to test the actual output of your component render
+ // you could test that, for example, certain text is present:
+ //
+ // 1. import { screen } from '@redwoodjs/testing/web'
+ // 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument()
+
+ it('renders Success successfully', async () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.jsx
new file mode 100644
index 000000000000..0dca58476b8e
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.jsx
@@ -0,0 +1,10 @@
+const TestComponent = () => {
+ return (
+
+
{'TestComponent'}
+
{'Find me in ./web/src/components/TestComponent/TestComponent.js'}
+
+ )
+}
+
+export default TestComponent
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.stories.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.stories.jsx
new file mode 100644
index 000000000000..1c3ee40e258b
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.stories.jsx
@@ -0,0 +1,21 @@
+// When you've added props to your component,
+// pass Storybook's `args` through this story to control it from the addons panel:
+//
+// ```jsx
+// export const generated = (args) => {
+// return
+// }
+// ```
+//
+// See https://storybook.js.org/docs/react/writing-stories/args.
+
+import TestComponent from './TestComponent'
+
+export const generated = () => {
+ return
+}
+
+export default {
+ title: 'Components/TestComponent',
+ component: TestComponent,
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.test.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.test.jsx
new file mode 100644
index 000000000000..0bc0a7cad920
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/components/TestComponent/TestComponent.test.jsx
@@ -0,0 +1,14 @@
+import { render } from '@redwoodjs/testing/web'
+
+import TestComponent from './TestComponent'
+
+// Improve this test with help from the Redwood Testing Doc:
+// https://redwoodjs.com/docs/testing#testing-components
+
+describe('TestComponent', () => {
+ it('renders successfully', () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/index.css b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/index.css
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/index.html b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/index.html
new file mode 100644
index 000000000000..e240b8eb8c54
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/index.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.jsx
new file mode 100644
index 000000000000..f46b6ceba653
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.jsx
@@ -0,0 +1,5 @@
+const TestLayout = ({ children }) => {
+ return <>{children}>
+}
+
+export default TestLayout
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.stories.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.stories.jsx
new file mode 100644
index 000000000000..03ee1ff33b19
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.stories.jsx
@@ -0,0 +1,10 @@
+import TestLayout from './TestLayout'
+
+export const generated = (args) => {
+ return
+}
+
+export default {
+ title: 'Layouts/TestLayout',
+ component: TestLayout,
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.test.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.test.jsx
new file mode 100644
index 000000000000..ad9336038eb1
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/layouts/TestLayout/TestLayout.test.jsx
@@ -0,0 +1,14 @@
+import { render } from '@redwoodjs/testing/web'
+
+import TestLayout from './TestLayout'
+
+// Improve this test with help from the Redwood Testing Doc:
+// https://redwoodjs.com/docs/testing#testing-pages-layouts
+
+describe('TestLayout', () => {
+ it('renders successfully', () => {
+ expect(() => {
+ render()
+ }).not.toThrow()
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/pages/FatalErrorPage/FatalErrorPage.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/pages/FatalErrorPage/FatalErrorPage.jsx
new file mode 100644
index 000000000000..7ff31af1a7f4
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/example/output/web/src/pages/FatalErrorPage/FatalErrorPage.jsx
@@ -0,0 +1,62 @@
+// 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 ||
+ (() => (
+
+
+
+
+
+// }
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withJSX/input/router.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withJSX/input/router.js
new file mode 100644
index 000000000000..f4e5f389c80a
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withJSX/input/router.js
@@ -0,0 +1,21 @@
+// In this file, all Page components from 'src/pages` are auto-imported. Nested
+// directories are supported, and should be uppercase. Each subdirectory will be
+// prepended onto the component name.
+//
+// Examples:
+//
+// 'src/pages/HomePage/HomePage.js' -> HomePage
+// 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage
+
+import { Router, Route } from '@redwoodjs/router'
+
+const Routes = () => {
+ return (
+
+
+
+
+ )
+}
+
+export default Routes
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withJSX/output/router.jsx b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withJSX/output/router.jsx
new file mode 100644
index 000000000000..f4e5f389c80a
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withJSX/output/router.jsx
@@ -0,0 +1,21 @@
+// In this file, all Page components from 'src/pages` are auto-imported. Nested
+// directories are supported, and should be uppercase. Each subdirectory will be
+// prepended onto the component name.
+//
+// Examples:
+//
+// 'src/pages/HomePage/HomePage.js' -> HomePage
+// 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage
+
+import { Router, Route } from '@redwoodjs/router'
+
+const Routes = () => {
+ return (
+
+
+
+
+ )
+}
+
+export default Routes
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withoutJSX/input/util.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withoutJSX/input/util.js
new file mode 100644
index 000000000000..847712658b6c
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withoutJSX/input/util.js
@@ -0,0 +1,4 @@
+// This doesn't have JSX like
content
or <>content>
+export function logTime(){
+ console.log(new Date().toISOString())
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withoutJSX/output/util.js b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withoutJSX/output/util.js
new file mode 100644
index 000000000000..847712658b6c
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__testfixtures__/withoutJSX/output/util.js
@@ -0,0 +1,4 @@
+// This doesn't have JSX like
content
or <>content>
+export function logTime(){
+ console.log(new Date().toISOString())
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__tests__/convertJsToJsx.test.ts b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__tests__/convertJsToJsx.test.ts
new file mode 100644
index 000000000000..01579ccd2046
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/__tests__/convertJsToJsx.test.ts
@@ -0,0 +1,20 @@
+describe('convertJsToJsx', () => {
+ it('Converts an example project correctly', async () => {
+ await matchFolderTransform('convertJsToJsx', 'example', {
+ useJsCodeshift: true,
+ targetPathsGlob: 'web/src/**/*.js',
+ })
+ })
+
+ it('Converts a js file containing jsx', async () => {
+ await matchFolderTransform('convertJsToJsx', 'withJSX', {
+ useJsCodeshift: true,
+ })
+ })
+
+ it('Ignores a js file not containing jsx', async () => {
+ await matchFolderTransform('convertJsToJsx', 'withoutJSX', {
+ useJsCodeshift: true,
+ })
+ })
+})
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.ts b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.ts
new file mode 100644
index 000000000000..2b02f44862ec
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.ts
@@ -0,0 +1,24 @@
+import fs from 'fs'
+
+import type { FileInfo, API } from 'jscodeshift'
+
+export default function transform(file: FileInfo, api: API) {
+ const j = api.jscodeshift
+ const ast = j(file.source)
+
+ const containsJSX =
+ ast.find(j.JSXElement).length !== 0 ||
+ ast.find(j.JSXFragment).length !== 0 ||
+ ast.find(j.JSXText).length !== 0
+
+ if (containsJSX) {
+ fs.renameSync(
+ file.path,
+ file.path.substring(0, file.path.lastIndexOf('.')) + '.jsx'
+ )
+ }
+
+ // NOTE:
+ // We deliberately don't return a value here, as we do not want to transform the source
+ // See more here: https://github.com/facebook/jscodeshift
+}
diff --git a/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.yargs.ts b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.yargs.ts
new file mode 100644
index 000000000000..8bc599d6518a
--- /dev/null
+++ b/packages/codemods/src/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.yargs.ts
@@ -0,0 +1,24 @@
+import path from 'path'
+
+import fg from 'fast-glob'
+import task, { TaskInnerAPI } from 'tasuku'
+
+import runTransform from '../../../lib/runTransform'
+
+export const command = 'convert-js-to-jsx'
+export const description =
+ '(v5.x.x->v6.x.x) Converts web components from .js to .jsx'
+
+export const handler = () => {
+ task('Convert Js To Jsx', async ({ setOutput }: TaskInnerAPI) => {
+ await runTransform({
+ transformPath: path.join(__dirname, 'convertJsToJsx.js'),
+ // All files in web/src that are .js
+ targetPaths: fg.sync('web/src/**/*.js'),
+ })
+
+ setOutput(
+ 'All done! Your file contents have not been changed just the extension.'
+ )
+ })
+}
diff --git a/packages/codemods/src/testUtils/matchFolderTransform.ts b/packages/codemods/src/testUtils/matchFolderTransform.ts
index ba0bdeca2d2d..bc75789dd043 100644
--- a/packages/codemods/src/testUtils/matchFolderTransform.ts
+++ b/packages/codemods/src/testUtils/matchFolderTransform.ts
@@ -3,12 +3,34 @@ import path from 'path'
import fg from 'fast-glob'
import fse from 'fs-extra'
+import runTransform from '../lib/runTransform'
+
import { createProjectMock } from './index'
-export const matchFolderTransform = async (
- transformFunction: () => any,
+type Options = {
+ removeWhitespace?: boolean
+ targetPathsGlob?: string
+ /**
+ * Use this option, when you want to run a codemod that uses jscodeshift
+ * as well as modifies file names. e.g. convertJsToJsx
+ */
+ useJsCodeshift?: boolean
+}
+
+type MatchFolderTransformFunction = (
+ transformFunctionOrName: (() => any) | string,
fixtureName: string,
- { removeWhitespace } = { removeWhitespace: false }
+ options?: Options
+) => Promise
+
+export const matchFolderTransform: MatchFolderTransformFunction = async (
+ transformFunctionOrName,
+ fixtureName,
+ {
+ removeWhitespace = false,
+ targetPathsGlob = '**/*',
+ useJsCodeshift = false,
+ } = {}
) => {
const tempDir = createProjectMock()
@@ -36,17 +58,49 @@ export const matchFolderTransform = async (
overwrite: true,
})
- // Step 2: Run transform against temp dir
- await transformFunction()
-
const GLOB_CONFIG = {
absolute: false,
dot: true,
ignore: ['redwood.toml', '**/*.DS_Store'], // ignore the fake redwood.toml added for getPaths
}
- const transformedPaths = fg.sync('**/*', { ...GLOB_CONFIG, cwd: tempDir })
- const expectedPaths = fg.sync('**/*', {
+ // Step 2: Run transform against temp dir
+ if (useJsCodeshift) {
+ if (typeof transformFunctionOrName !== 'string') {
+ throw new Error(
+ 'When running matchFolderTransform with useJsCodeshift, transformFunction must be a string (file name of jscodeshift transform)'
+ )
+ }
+ const transformName = transformFunctionOrName
+ const transformPath = require.resolve(
+ path.join(testPath, '../../', transformName)
+ )
+
+ const targetPaths = fg.sync(targetPathsGlob, {
+ ...GLOB_CONFIG,
+ cwd: tempDir,
+ })
+
+ await runTransform({
+ transformPath,
+ targetPaths: targetPaths.map((p) => path.join(tempDir, p)),
+ })
+ } else {
+ if (typeof transformFunctionOrName !== 'function') {
+ throw new Error(
+ 'transformFunction must be a function, if useJsCodeshift set to false'
+ )
+ }
+ const transformFunction = transformFunctionOrName
+ await transformFunction()
+ }
+
+ const transformedPaths = fg.sync(targetPathsGlob, {
+ ...GLOB_CONFIG,
+ cwd: tempDir,
+ })
+
+ const expectedPaths = fg.sync(targetPathsGlob, {
...GLOB_CONFIG,
cwd: fixtureOutputDir,
})
diff --git a/packages/codemods/src/testUtils/matchTransformSnapshot.ts b/packages/codemods/src/testUtils/matchTransformSnapshot.ts
index a2fd3c0ede28..5a4665cc9451 100644
--- a/packages/codemods/src/testUtils/matchTransformSnapshot.ts
+++ b/packages/codemods/src/testUtils/matchTransformSnapshot.ts
@@ -7,10 +7,14 @@ import runTransform from '../lib/runTransform'
import { formatCode } from './index'
-export const matchTransformSnapshot = async (
- transformName: string,
- fixtureName: string = transformName,
- parser: 'ts' | 'tsx' | 'babel' = 'tsx'
+export interface MatchTransformSnapshotFunction {
+ (transformName: string, fixtureName?: string, parser?: 'ts' | 'tsx'): void
+}
+
+export const matchTransformSnapshot: MatchTransformSnapshotFunction = async (
+ transformName,
+ fixtureName,
+ parser
) => {
const tempFilePath = tempy.file()
diff --git a/packages/codemods/testUtils.d.ts b/packages/codemods/testUtils.d.ts
index 6e582b604a18..0e8bccfe2d37 100644
--- a/packages/codemods/testUtils.d.ts
+++ b/packages/codemods/testUtils.d.ts
@@ -32,19 +32,39 @@ declare module 'jscodeshift/dist/testUtils' {
): string
}
-import { matchFolderTransform } from './testUtils/matchFolderTransform'
-import { matchInlineTransformSnapshot } from './testUtils/matchInlineTransformSnapshot'
-import { matchTransformSnapshot } from './testUtils/matchTransformSnapshot'
+// @NOTE: Redefining types, because they get lost when importing from the testUtils file
+type MatchTransformSnapshotFunction = (
+ transformName: string,
+ fixtureName?: string,
+ parser?: 'ts' | 'tsx'
+) => Promise
-type MatchFunction = typeof matchTransformSnapshot
-type MatchInlineFunction = typeof matchInlineTransformSnapshot
-type MatchFolder = typeof matchFolderTransform
+type MatchFolderTransformFunction = (
+ transformFunctionOrName: (() => any) | string,
+ fixtureName: string,
+ options?: {
+ removeWhitespace?: boolean
+ targetPathsGlob?: string
+ /**
+ * Use this option, when you want to run a codemod that uses jscodeshift
+ * as well as modifies file names. e.g. convertJsToJsx
+ */
+ useJsCodeshift?: boolean
+ }
+) => Promise
+
+type MatchInlineTransformSnapshotFunction = (
+ transformName: string,
+ fixtureCode: string,
+ expectedCode: string,
+ parser: 'ts' | 'tsx' | 'babel' = 'tsx'
+) => Promise
-// This file gets loaded in jest setup, so becomes available globally in tests
+// These files gets loaded in jest setup, so becomes available globally in tests
declare global {
- const matchTransformSnapshot: MatchFunction
- const matchInlineTransformSnapshot: MatchInlineFunction
- const matchFolderTransform: MatchFolder
+ const matchTransformSnapshot: MatchTransformSnapshotFunction
+ const matchInlineTransformSnapshot: MatchInlineTransformSnapshotFunction
+ const matchFolderTransform: MatchFolderTransformFunction
namespace jest {
interface Matchers {
toMatchFileContents(
@@ -54,3 +74,5 @@ declare global {
}
}
}
+
+export {}
diff --git a/packages/create-redwood-app/templates/js/.env.defaults b/packages/create-redwood-app/templates/js/.env.defaults
index 630016bee2f2..fb88fb33b334 100644
--- a/packages/create-redwood-app/templates/js/.env.defaults
+++ b/packages/create-redwood-app/templates/js/.env.defaults
@@ -12,8 +12,8 @@ DATABASE_URL=file:./dev.db
# disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true
-
# Option to override the current environment's default api-side log level
-# See: https://redwoodjs.com/docs/logger for level options:
-# trace | info | debug | warn | error | silent
-# LOG_LEVEL=debug
\ No newline at end of file
+# See: https://redwoodjs.com/docs/logger for level options, defaults to "trace" otherwise.
+# Most applications want "debug" or "info" during dev, "trace" when you have issues and "warn" in production.
+# Ordered by how verbose they are: trace | debug | info | warn | error | silent
+# LOG_LEVEL=debug
diff --git a/packages/create-redwood-app/templates/js/api/server.config.js b/packages/create-redwood-app/templates/js/api/server.config.js
index b012191dce14..a8d4638a6ff8 100644
--- a/packages/create-redwood-app/templates/js/api/server.config.js
+++ b/packages/create-redwood-app/templates/js/api/server.config.js
@@ -16,7 +16,7 @@
const config = {
requestTimeout: 15_000,
logger: {
- // Note: If running locally using `yarn rw serve` you may want to adust
+ // Note: If running locally using `yarn rw serve` you may want to adjust
// the default non-development level to `info`
level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn',
},
@@ -36,11 +36,11 @@ const config = {
/** @type {import('@redwoodjs/api-server/dist/fastify').FastifySideConfigFn} */
const configureFastify = async (fastify, options) => {
if (options.side === 'api') {
- fastify.log.info({ custom: { options } }, 'Configuring api side')
+ fastify.trace.info({ custom: { options } }, 'Configuring api side')
}
if (options.side === 'web') {
- fastify.log.info({ custom: { options } }, 'Configuring web side')
+ fastify.trace.info({ custom: { options } }, 'Configuring web side')
}
return fastify
diff --git a/packages/create-redwood-app/templates/ts/.env.defaults b/packages/create-redwood-app/templates/ts/.env.defaults
index 630016bee2f2..fb88fb33b334 100644
--- a/packages/create-redwood-app/templates/ts/.env.defaults
+++ b/packages/create-redwood-app/templates/ts/.env.defaults
@@ -12,8 +12,8 @@ DATABASE_URL=file:./dev.db
# disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true
-
# Option to override the current environment's default api-side log level
-# See: https://redwoodjs.com/docs/logger for level options:
-# trace | info | debug | warn | error | silent
-# LOG_LEVEL=debug
\ No newline at end of file
+# See: https://redwoodjs.com/docs/logger for level options, defaults to "trace" otherwise.
+# Most applications want "debug" or "info" during dev, "trace" when you have issues and "warn" in production.
+# Ordered by how verbose they are: trace | debug | info | warn | error | silent
+# LOG_LEVEL=debug
diff --git a/packages/create-redwood-app/templates/ts/api/server.config.js b/packages/create-redwood-app/templates/ts/api/server.config.js
index b012191dce14..e82b04ea3f52 100644
--- a/packages/create-redwood-app/templates/ts/api/server.config.js
+++ b/packages/create-redwood-app/templates/ts/api/server.config.js
@@ -16,7 +16,7 @@
const config = {
requestTimeout: 15_000,
logger: {
- // Note: If running locally using `yarn rw serve` you may want to adust
+ // Note: If running locally using `yarn rw serve` you may want to adjust
// the default non-development level to `info`
level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn',
},
@@ -36,11 +36,11 @@ const config = {
/** @type {import('@redwoodjs/api-server/dist/fastify').FastifySideConfigFn} */
const configureFastify = async (fastify, options) => {
if (options.side === 'api') {
- fastify.log.info({ custom: { options } }, 'Configuring api side')
+ fastify.log.trace({ custom: { options } }, 'Configuring api side')
}
if (options.side === 'web') {
- fastify.log.info({ custom: { options } }, 'Configuring web side')
+ fastify.log.trace({ custom: { options } }, 'Configuring web side')
}
return fastify
diff --git a/packages/fastify/src/config.ts b/packages/fastify/src/config.ts
index 8135c2c0e745..2b336adf171d 100644
--- a/packages/fastify/src/config.ts
+++ b/packages/fastify/src/config.ts
@@ -12,7 +12,10 @@ export const DEFAULT_REDWOOD_FASTIFY_CONFIG: FastifyServerOptions = {
logger: {
// Note: If running locally using `yarn rw serve` you may want to adust
// the default non-development level to `info`
- level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn',
+ level:
+ process.env.LOG_LEVEL ?? process.env.NODE_ENV === 'development'
+ ? 'debug'
+ : 'warn',
},
}
@@ -24,7 +27,7 @@ let serverConfigFile: {
} = {
config: DEFAULT_REDWOOD_FASTIFY_CONFIG,
configureFastify: async (fastify, options) => {
- fastify.log.info(
+ fastify.log.trace(
options,
`In configureFastify hook for side: ${options?.side}`
)
diff --git a/packages/internal/package.json b/packages/internal/package.json
index 8c1653ab4085..35bc627eac0c 100644
--- a/packages/internal/package.json
+++ b/packages/internal/package.json
@@ -43,7 +43,7 @@
"@graphql-codegen/typescript-resolvers": "3.2.1",
"@redwoodjs/graphql-server": "5.0.0",
"@redwoodjs/project-config": "5.0.0",
- "@sdl-codegen/node": "0.0.9",
+ "@sdl-codegen/node": "0.0.10",
"babel-plugin-graphql-tag": "3.3.0",
"babel-plugin-polyfill-corejs3": "0.8.1",
"chalk": "4.1.2",
diff --git a/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap b/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap
index 4f6a8bb33b93..7faa93c8b756 100644
--- a/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap
+++ b/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap
@@ -5,7 +5,7 @@ exports[`Generate gql typedefs api 1`] = `
import { MergePrismaWithSdlTypes, MakeRelationsOptional } from '@redwoodjs/api'
import { PrismaModelOne as PrismaPrismaModelOne, PrismaModelTwo as PrismaPrismaModelTwo, Post as PrismaPost, Todo as PrismaTodo } from '@prisma/client'
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
-import { RedwoodGraphQLContext } from '@redwoodjs/graphql-server/dist/functions/types';
+import { RedwoodGraphQLContext } from '@redwoodjs/graphql-server/dist/types';
export type Maybe = T | null;
export type InputMaybe = Maybe;
export type Exact = { [K in keyof T]: T[K] };
diff --git a/packages/internal/src/generate/graphqlCodeGen.ts b/packages/internal/src/generate/graphqlCodeGen.ts
index 7711edc99d47..068c171a5d30 100644
--- a/packages/internal/src/generate/graphqlCodeGen.ts
+++ b/packages/internal/src/generate/graphqlCodeGen.ts
@@ -252,7 +252,7 @@ function getPluginConfig(side: CodegenSide) {
// Look at type or source https://shrtm.nu/2BA0 for possible config, not well documented
resolvers: true,
},
- contextType: `@redwoodjs/graphql-server/dist/functions/types#RedwoodGraphQLContext`,
+ contextType: `@redwoodjs/graphql-server/dist/types#RedwoodGraphQLContext`,
}
return pluginConfig
diff --git a/yarn.lock b/yarn.lock
index 93deb37002fc..eeaeb4293558 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2655,12 +2655,12 @@ __metadata:
languageName: node
linkType: hard
-"@clerk/types@npm:3.41.0, @clerk/types@npm:^3.41.0":
- version: 3.41.0
- resolution: "@clerk/types@npm:3.41.0"
+"@clerk/types@npm:3.42.0, @clerk/types@npm:^3.41.0":
+ version: 3.42.0
+ resolution: "@clerk/types@npm:3.42.0"
dependencies:
csstype: 3.1.1
- checksum: e9201848b5afbd0338e1b01952dab42f9a5966e041d7e31bb7987440675de08d5b0dab63dbdb43086c5402a275c81c16fd93d2cd7f84bc783fa9e01e9c5e1b6b
+ checksum: fbdec075867d19ccbe13b656bd5bfa4a26b45d766fa7d879472852b63ef5fad46b13eaaafcc314575dc14d091e55496d2dc632e75f2da0d183e349bc13a4c6da
languageName: node
linkType: hard
@@ -7133,7 +7133,7 @@ __metadata:
"@babel/core": 7.22.1
"@babel/runtime-corejs3": 7.22.3
"@clerk/clerk-react": 4.18.0
- "@clerk/types": 3.41.0
+ "@clerk/types": 3.42.0
"@redwoodjs/auth": 5.0.0
"@types/react": 18.2.9
core-js: 3.30.2
@@ -7812,7 +7812,7 @@ __metadata:
"@graphql-codegen/typescript-resolvers": 3.2.1
"@redwoodjs/graphql-server": 5.0.0
"@redwoodjs/project-config": 5.0.0
- "@sdl-codegen/node": 0.0.9
+ "@sdl-codegen/node": 0.0.10
"@types/babel-plugin-tester": 9.0.5
"@types/babel__core": 7.20.1
"@types/fs-extra": 11.0.1
@@ -8223,16 +8223,20 @@ __metadata:
languageName: node
linkType: hard
-"@sdl-codegen/node@npm:0.0.9":
- version: 0.0.9
- resolution: "@sdl-codegen/node@npm:0.0.9"
+"@sdl-codegen/node@npm:0.0.10":
+ version: 0.0.10
+ resolution: "@sdl-codegen/node@npm:0.0.10"
dependencies:
"@mrleebo/prisma-ast": ^0.5.2
ts-morph: ^18.0.0
peerDependencies:
graphql: "*"
+ prettier: ^2
typescript: "*"
- checksum: d297180138e1a2f71301ad71575a9562033d28fe4f6ce2abc727208dd82ccd43104510a3ca2912c12e792e69b111045fe9bb17aba18cb123c3eccc74f15b88bd
+ peerDependenciesMeta:
+ prettier:
+ optional: true
+ checksum: 275247e686cc999d91623d67ce09171f9ed17764616bb7941877439ce44b1cba305ac049e91981660cd8690f18d797cd27cecdf26cf436eb81895093e0223f42
languageName: node
linkType: hard