-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for workspace route library
Adds workspace routes fixture and a failing test
- Loading branch information
Showing
17 changed files
with
344 additions
and
264 deletions.
There are no files selected for viewing
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,45 @@ | ||
import fse from "fs-extra"; | ||
import stripIndent from "strip-indent"; | ||
import path from "node:path"; | ||
import url from "node:url"; | ||
|
||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); | ||
const root = path.resolve(__dirname, "../.."); | ||
const TMP_DIR = path.join(root, ".tmp/integration"); | ||
|
||
export async function writeTestFiles( | ||
files: Record<string, string> | undefined, | ||
dir: string | ||
) { | ||
await Promise.all( | ||
Object.keys(files ?? {}).map(async (filename) => { | ||
let filePath = path.join(dir, filename); | ||
await fse.ensureDir(path.dirname(filePath)); | ||
let file = files![filename]; | ||
|
||
await fse.writeFile(filePath, stripIndent(file)); | ||
}) | ||
); | ||
} | ||
|
||
export async function getAllFilesInDir(dirPath: string): Promise<string[]> { | ||
const entries = await fse.promises.readdir(dirPath, { withFileTypes: true }); | ||
const files = await Promise.all( | ||
entries.map((entry) => { | ||
const resolvedPath = path.resolve(dirPath, entry.name); | ||
if (entry.isDirectory()) { | ||
return getAllFilesInDir(resolvedPath); | ||
} else { | ||
return [resolvedPath]; | ||
} | ||
}) | ||
); | ||
return files.flat(); | ||
} | ||
|
||
export async function createTestDirectory() { | ||
let folderName = `rr-${Math.random().toString(32).slice(2)}`; | ||
let testDir = path.join(TMP_DIR, folderName); | ||
await fse.ensureDir(testDir); | ||
return testDir; | ||
} |
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
6 changes: 6 additions & 0 deletions
6
integration/helpers/workspace-routes-template/apps/test-app/.gitignore
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,6 @@ | ||
node_modules | ||
|
||
/.cache | ||
/build | ||
.env | ||
.react-router |
19 changes: 19 additions & 0 deletions
19
integration/helpers/workspace-routes-template/apps/test-app/app/root.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,19 @@ | ||
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router"; | ||
|
||
export default function App() { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Outlet /> | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} |
4 changes: 4 additions & 0 deletions
4
integration/helpers/workspace-routes-template/apps/test-app/app/routes.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { type RouteConfig } from "@react-router/dev/routes"; | ||
import { flatRoutes } from "@react-router/fs-routes"; | ||
|
||
export default flatRoutes() satisfies RouteConfig; |
16 changes: 16 additions & 0 deletions
16
integration/helpers/workspace-routes-template/apps/test-app/app/routes/_index.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,16 @@ | ||
import type { MetaFunction } from "react-router"; | ||
|
||
export const meta: MetaFunction = () => { | ||
return [ | ||
{ title: "New React Router App" }, | ||
{ name: "description", content: "Welcome to React Router!" }, | ||
]; | ||
}; | ||
|
||
export default function Index() { | ||
return ( | ||
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}> | ||
<h1>Welcome to React Router</h1> | ||
</div> | ||
); | ||
} |
2 changes: 2 additions & 0 deletions
2
integration/helpers/workspace-routes-template/apps/test-app/env.d.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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="@react-router/node" /> | ||
/// <reference types="vite/client" /> |
42 changes: 42 additions & 0 deletions
42
integration/helpers/workspace-routes-template/apps/test-app/package.json
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,42 @@ | ||
{ | ||
"name": "integration-workspace-test-app-template", | ||
"version": "0.0.0", | ||
"private": true, | ||
"sideEffects": false, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "react-router dev", | ||
"build": "react-router build", | ||
"start": "react-router-serve ./build/server/index.js", | ||
"typecheck": "react-router typegen && tsc" | ||
}, | ||
"dependencies": { | ||
"@react-router/express": "workspace:*", | ||
"@react-router/node": "workspace:*", | ||
"@react-router/serve": "workspace:*", | ||
"@vanilla-extract/css": "^1.10.0", | ||
"@vanilla-extract/vite-plugin": "^3.9.2", | ||
"express": "^4.19.2", | ||
"isbot": "^5.1.11", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router": "workspace:*", | ||
"test-route-library": "workspace:*", | ||
"serialize-javascript": "^6.0.1" | ||
}, | ||
"devDependencies": { | ||
"@react-router/dev": "workspace:*", | ||
"@react-router/fs-routes": "workspace:*", | ||
"@react-router/remix-routes-option-adapter": "workspace:*", | ||
"@types/react": "^18.2.20", | ||
"@types/react-dom": "^18.2.7", | ||
"eslint": "^8.38.0", | ||
"typescript": "^5.1.6", | ||
"vite": "^6.0.0", | ||
"vite-env-only": "^3.0.1", | ||
"vite-tsconfig-paths": "^4.2.1" | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
} | ||
} |
Binary file added
BIN
+14.7 KB
integration/helpers/workspace-routes-template/apps/test-app/public/favicon.ico
Binary file not shown.
27 changes: 27 additions & 0 deletions
27
integration/helpers/workspace-routes-template/apps/test-app/tsconfig.json
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,27 @@ | ||
{ | ||
"include": [ | ||
"env.d.ts", | ||
"**/*.ts", | ||
"**/*.tsx", | ||
".react-router/types/**/*.d.ts" | ||
], | ||
"compilerOptions": { | ||
"lib": ["DOM", "DOM.Iterable", "ES2022"], | ||
"verbatimModuleSyntax": true, | ||
"esModuleInterop": true, | ||
"jsx": "react-jsx", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"resolveJsonModule": true, | ||
"target": "ES2022", | ||
"strict": true, | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": ["./app/*"] | ||
}, | ||
"noEmit": true, | ||
"rootDirs": [".", ".react-router/types/"] | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
integration/helpers/workspace-routes-template/apps/test-app/vite.config.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { reactRouter } from "@react-router/dev/vite"; | ||
import { defineConfig } from "vite"; | ||
import tsconfigPaths from "vite-tsconfig-paths"; | ||
|
||
export default defineConfig({ | ||
plugins: [reactRouter(), tsconfigPaths()], | ||
}); |
1 change: 1 addition & 0 deletions
1
integration/helpers/workspace-routes-template/libs/test-route-library/index.d.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export function sum(a: number, b: number): number; |
3 changes: 3 additions & 0 deletions
3
integration/helpers/workspace-routes-template/libs/test-route-library/index.js
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,3 @@ | ||
export function sum(a, b) { | ||
return a + b; | ||
} |
12 changes: 12 additions & 0 deletions
12
integration/helpers/workspace-routes-template/libs/test-route-library/package.json
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,12 @@ | ||
{ | ||
"name": "test-route-library", | ||
"type": "module", | ||
"private": true, | ||
"exports": { | ||
".": "./index.js" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0", | ||
"@react-router/dev": "workspace:*" | ||
} | ||
} |
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
Oops, something went wrong.