From 5babf9d12f85baa94c2c343fec76db152e4e5125 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 24 Sep 2021 17:09:45 +1000 Subject: [PATCH] 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. --- .github/workflows/ci.yml | 7 +++++-- frontend/dynamicApp.ts | 6 +++--- frontend/index.html | 4 ++-- .../src/{App.test.tsx => MakerApp.test.tsx} | 9 ++------- frontend/src/{Maker.tsx => MakerApp.tsx} | 0 frontend/src/TakerApp.test.tsx | 17 +++++++++++++++++ frontend/src/{Taker.tsx => TakerApp.tsx} | 0 frontend/{ => src}/maker.tsx | 6 +++--- frontend/{ => src}/taker.tsx | 6 +++--- frontend/tsconfig.json | 2 +- 10 files changed, 36 insertions(+), 21 deletions(-) rename frontend/src/{App.test.tsx => MakerApp.test.tsx} (58%) rename frontend/src/{Maker.tsx => MakerApp.tsx} (100%) create mode 100644 frontend/src/TakerApp.test.tsx rename frontend/src/{Taker.tsx => TakerApp.tsx} (100%) rename frontend/{ => src}/maker.tsx (85%) rename frontend/{ => src}/taker.tsx (85%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3951cda..01ee27c 100644 --- a/.github/workflows/ci.yml +++ b/.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: diff --git a/frontend/dynamicApp.ts b/frontend/dynamicApp.ts index 8161555..1cc3313 100644 --- a/frontend/dynamicApp.ts +++ b/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; diff --git a/frontend/index.html b/frontend/index.html index 8546184..f1f149a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,13 +2,13 @@ - + Hermes
- diff --git a/frontend/src/App.test.tsx b/frontend/src/MakerApp.test.tsx similarity index 58% rename from frontend/src/App.test.tsx rename to frontend/src/MakerApp.test.tsx index ee267a2..5949802 100644 --- a/frontend/src/App.test.tsx +++ b/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( - - - } /> - - + , div, diff --git a/frontend/src/Maker.tsx b/frontend/src/MakerApp.tsx similarity index 100% rename from frontend/src/Maker.tsx rename to frontend/src/MakerApp.tsx diff --git a/frontend/src/TakerApp.test.tsx b/frontend/src/TakerApp.test.tsx new file mode 100644 index 0000000..77f8d34 --- /dev/null +++ b/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( + + + + + , + div, + ); +}); diff --git a/frontend/src/Taker.tsx b/frontend/src/TakerApp.tsx similarity index 100% rename from frontend/src/Taker.tsx rename to frontend/src/TakerApp.tsx diff --git a/frontend/maker.tsx b/frontend/src/maker.tsx similarity index 85% rename from frontend/maker.tsx rename to frontend/src/maker.tsx index 5c000ef..1946c0b 100644 --- a/frontend/maker.tsx +++ b/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( diff --git a/frontend/taker.tsx b/frontend/src/taker.tsx similarity index 85% rename from frontend/taker.tsx rename to frontend/src/taker.tsx index 7076c3a..93bcc3b 100644 --- a/frontend/taker.tsx +++ b/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( diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 22a4d8d..03da34a 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -16,5 +16,5 @@ "noEmit": true, "jsx": "react" }, - "include": ["."] + "include": ["src"] }