Skip to content

Commit 10e58d8

Browse files
kennkentcdodds
andauthored
Migrate from remix-flat-routes to react-router-auto-routes (#1051)
Co-authored-by: Kent C. Dodds <[email protected]>
1 parent 833a057 commit 10e58d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+301
-232
lines changed

app/root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
ThemeSwitch,
2727
useOptionalTheme,
2828
useTheme,
29-
} from './routes/resources+/theme-switch.tsx'
29+
} from './routes/resources/theme-switch.tsx'
3030
import tailwindStyleSheetUrl from './styles/tailwind.css?url'
3131
import { getUserId, logout } from './utils/auth.server.ts'
3232
import { ClientHintCheck, getHints } from './utils/client-hints.tsx'
@@ -190,7 +190,7 @@ function App() {
190190
const user = useOptionalUser()
191191
const theme = useTheme()
192192
const matches = useMatches()
193-
const isOnSearchPage = matches.find((m) => m.id === 'routes/users+/index')
193+
const isOnSearchPage = matches.find((m) => m.id === 'routes/users/index')
194194
const searchBar = isOnSearchPage ? null : <SearchBar status="idle" />
195195
useToast(data.toast)
196196

app/routes.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import { type RouteConfig } from '@react-router/dev/routes'
2-
import { remixRoutesOptionAdapter } from '@react-router/remix-routes-option-adapter'
3-
import { flatRoutes } from 'remix-flat-routes'
2+
import { autoRoutes } from 'react-router-auto-routes'
43

5-
export default remixRoutesOptionAdapter((defineRoutes) => {
6-
return flatRoutes('routes', defineRoutes, {
7-
ignoredRouteFiles: [
8-
'.*',
9-
'**/*.css',
10-
'**/*.test.{js,jsx,ts,tsx}',
11-
'**/__*.*',
12-
// This is for server-side utilities you want to colocate
13-
// next to your routes without making an additional
14-
// directory. If you need a route that includes "server" or
15-
// "client" in the filename, use the escape brackets like:
16-
// my-route.[server].tsx
17-
'**/*.server.*',
18-
'**/*.client.*',
19-
],
20-
})
4+
export default autoRoutes({
5+
ignoredRouteFiles: [
6+
'.*',
7+
'**/*.css',
8+
'**/*.test.{js,jsx,ts,tsx}',
9+
'**/__*.*',
10+
// This is for server-side utilities you want to colocate
11+
// next to your routes without making an additional
12+
// directory. If you need a route that includes "server" or
13+
// "client" in the filename, use the escape brackets like:
14+
// my-route.[server].tsx
15+
'**/*.server.*',
16+
'**/*.client.*',
17+
],
2118
}) satisfies RouteConfig

app/routes/_auth+/auth.$provider.callback.test.ts renamed to app/routes/_auth/auth.$provider.callback.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker'
33
import { SetCookie } from '@mjackson/headers'
44
import { http } from 'msw'
55
import { afterEach, expect, test } from 'vitest'
6-
import { twoFAVerificationType } from '#app/routes/settings+/profile.two-factor.tsx'
6+
import { twoFAVerificationType } from '#app/routes/settings/profile/two-factor/_layout.tsx'
77
import { getSessionExpirationDate, sessionKey } from '#app/utils/auth.server.ts'
88
import { GITHUB_PROVIDER_NAME } from '#app/utils/connections.tsx'
99
import { prisma } from '#app/utils/db.server.ts'
File renamed without changes.
File renamed without changes.

app/routes/_auth+/login.server.ts renamed to app/routes/_auth/login.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { invariant } from '@epic-web/invariant'
22
import { redirect } from 'react-router'
33
import { safeRedirect } from 'remix-utils/safe-redirect'
4-
import { twoFAVerificationType } from '#app/routes/settings+/profile.two-factor.tsx'
4+
import { twoFAVerificationType } from '#app/routes/settings/profile/two-factor/_layout.tsx'
55
import { getUserId, sessionKey } from '#app/utils/auth.server.ts'
66
import { prisma } from '#app/utils/db.server.ts'
77
import { combineResponseInits } from '#app/utils/misc.tsx'
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)