Browse Source

Put sources under src/

The only thing that has to stay in the root is the `index.html` file,
otherwise the dev server doesn't pick it up.
Also make sure our frontend tests actually run and pass in CI.
fix-bad-api-calls
Thomas Eizinger 3 years ago
parent
commit
5babf9d12f
No known key found for this signature in database GPG Key ID: 651AC83A6C6C8B96
  1. 7
      .github/workflows/ci.yml
  2. 6
      frontend/dynamicApp.ts
  3. 4
      frontend/index.html
  4. 9
      frontend/src/MakerApp.test.tsx
  5. 0
      frontend/src/MakerApp.tsx
  6. 17
      frontend/src/TakerApp.test.tsx
  7. 0
      frontend/src/TakerApp.tsx
  8. 6
      frontend/src/maker.tsx
  9. 6
      frontend/src/taker.tsx
  10. 2
      frontend/tsconfig.json

7
.github/workflows/ci.yml

@ -29,6 +29,9 @@ jobs:
- run: cargo clippy --workspace --all-targets -- -D warnings
build_frontend:
strategy:
matrix:
app: [ maker, taker ]
defaults:
run:
working-directory: frontend
@ -41,8 +44,8 @@ jobs:
cache-dependency-path: frontend/yarn.lock
- run: yarn install
- run: yarn run eslint
- run: APP=maker yarn build
- run: APP=taker yarn build
- run: APP=${{ matrix.app }} yarn test
- run: APP=${{ matrix.app }} yarn build
test_daemons:
strategy:

6
frontend/dynamicApp.ts

@ -5,11 +5,11 @@ export default function dynamicApp(app: string): Plugin {
name: "dynamicApp", // required, will show up in warnings and errors
resolveId: (id) => {
// For some reason these are different?
const productionBuildId = "./__app__.tsx";
const devBuildId = "/__app__.tsx";
const productionBuildId = "src/__app__.tsx";
const devBuildId = "/src/__app__.tsx";
if (id === productionBuildId || id === devBuildId) {
return `${__dirname}/${app}.tsx`;
return `${__dirname}/src/${app}.tsx`;
}
return null;

4
frontend/index.html

@ -2,13 +2,13 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hermes</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./__app__.tsx"> // `__app__` is dynamically resolved by the `dynamicApp` vite plugin
<script type="module" src="src/__app__.tsx"> // `__app__` is dynamically resolved by the `dynamicApp` vite plugin
</script>
</body>
</html>

9
frontend/src/App.test.tsx → frontend/src/MakerApp.test.tsx

@ -1,8 +1,7 @@
import { ChakraProvider } from "@chakra-ui/react";
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Maker from "./Maker";
import Maker from "./MakerApp";
import theme from "./theme";
it("renders without crashing", () => {
@ -10,11 +9,7 @@ it("renders without crashing", () => {
ReactDOM.render(
<React.StrictMode>
<ChakraProvider theme={theme}>
<BrowserRouter>
<Routes>
<Route path="/maker/*" element={<Maker />} />
</Routes>
</BrowserRouter>
<Maker />
</ChakraProvider>
</React.StrictMode>,
div,

0
frontend/src/Maker.tsx → frontend/src/MakerApp.tsx

17
frontend/src/TakerApp.test.tsx

@ -0,0 +1,17 @@
import { ChakraProvider } from "@chakra-ui/react";
import React from "react";
import ReactDOM from "react-dom";
import Taker from "./TakerApp";
import theme from "./theme";
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(
<React.StrictMode>
<ChakraProvider theme={theme}>
<Taker />
</ChakraProvider>
</React.StrictMode>,
div,
);
});

0
frontend/src/Taker.tsx → frontend/src/TakerApp.tsx

6
frontend/maker.tsx → frontend/src/maker.tsx

@ -3,9 +3,9 @@ import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import { EventSourceProvider } from "react-sse-hooks";
import "./src/index.css";
import App from "./src/Maker";
import theme from "./src/theme";
import "./index.css";
import App from "./MakerApp";
import theme from "./theme";
ReactDOM.render(
<React.StrictMode>

6
frontend/taker.tsx → frontend/src/taker.tsx

@ -3,9 +3,9 @@ import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import { EventSourceProvider } from "react-sse-hooks";
import "./src/index.css";
import App from "./src/Taker";
import theme from "./src/theme";
import "./index.css";
import App from "./TakerApp";
import theme from "./theme";
ReactDOM.render(
<React.StrictMode>

2
frontend/tsconfig.json

@ -16,5 +16,5 @@
"noEmit": true,
"jsx": "react"
},
"include": ["."]
"include": ["src"]
}

Loading…
Cancel
Save