Skip to content

Commit

Permalink
refactor(frontend): upgrade frontend dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Its-Alex committed Jul 5, 2024
1 parent 37a2358 commit 643ee8e
Show file tree
Hide file tree
Showing 28 changed files with 4,854 additions and 13,371 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export SMTP_PORT=1025
# export SMTP2_PORT=1026

# Frontend
export REACT_APP_API_URL=http://127.0.0.1:5000
export VITE_API_URL=http://127.0.0.1:5000
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ jobs:
uses: actions/checkout@v3
- name: Install dependencies and lint javascript
run: |
corepack enable
corepack prepare pnpm@9.4.0 --activate
cd frontend
yarn install --frozen-lockfile
yarn lint
pnpm install --frozen-lockfile
pnpm lint
test-backend:
needs: [lint-backend]
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nodejs 22.3.0
yarn 1.22.22
direnv 2.28.0
pnpm 9.4.0
10 changes: 6 additions & 4 deletions docker-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ RUN mkdir -p /src/
COPY frontend/ /src/frontend/
WORKDIR /src/frontend/

RUN yarn install
RUN yarn run build
RUN corepack enable \
&& corepack prepare pnpm@9.4.0 --activate \
&& pnpm install \
&& pnpm run build

FROM node:22.3.0-alpine3.19

RUN mkdir -p /src/
WORKDIR /src/

COPY --from=0 /src/frontend/build/ /src/frontend/build/
COPY --from=0 /src/frontend/dist/ /src/frontend/dist/
COPY backend/package.json /src/
COPY backend/yarn.lock /src/

Expand All @@ -26,6 +28,6 @@ ENV NODE_OPTIONS=--openssl-legacy-provider
EXPOSE 5000

ENV TEMPLATES_PATH=/templates/
ENV STATIC_PATH=/src/frontend/build/
ENV STATIC_PATH=/src/frontend/dist/

CMD node ./src/cli.js
2 changes: 0 additions & 2 deletions frontend/.dockerignore

This file was deleted.

40 changes: 40 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
settings: {
react: {
version: "detect", // React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// It will default to "latest" and warn if missing, and to "detect" in the future
},
},
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
indent: ["error", 2],
"linebreak-style": ["error", "unix"],
quotes: ["error", "single"],
semi: ["error", "always"],
"react/prop-types": 0,
"space-before-function-paren": [
"error",
{
anonymous: "always",
named: "never",
asyncArrow: "always",
},
],
},
};
58 changes: 0 additions & 58 deletions frontend/.eslintrc.json

This file was deleted.

41 changes: 21 additions & 20 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
38 changes: 23 additions & 15 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
## gibbon-mail frontend
# React + TypeScript + Vite

```
$ yarn install
```
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Before start `frontend` you need to start the [`../backend/`](../backend/) service.
Currently, two official plugins are available:

```
$ direnv allow
$ yarn run start
```
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

Open your browser on http://127.0.0.1:3000
## Expanding the ESLint configuration

```
$ yarn run lint
```
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```
$ yarn run build
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
13 changes: 13 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gibbon mail</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
68 changes: 32 additions & 36 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
{
"name": "gibbon-mail-frontend",
"version": "0.5.0",
"name": "new-frontend",
"private": true,
"devDependencies": {
"eslint": "7.11.0",
"eslint-plugin-react": "7.23.1"
},
"version": "0.0.0",
"type": "module",
"scripts": {
"start": "BROWSER=none NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
"build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
"eject": "NODE_OPTIONS=--openssl-legacy-provider react-scripts eject",
"lint": "NODE_OPTIONS=--openssl-legacy-provider eslint --ignore-path .gitignore .",
"pretest": "NODE_OPTIONS=--openssl-legacy-provider eslint --ignore-path .gitignore ."
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@rjsf/bootstrap-4": "2.5.1",
"@rjsf/core": "2.5.1",
"axios": "0.21.1",
"axios-hooks": "2.6.1",
"bootstrap": "4.6.0",
"@rjsf/bootstrap-4": "5.19.1",
"@rjsf/core": "5.19.1",
"@rjsf/validator-ajv8": "5.19.1",
"axios": "1.7.2",
"axios-hooks": "5.0.2",
"bootstrap": "5.3.3",
"lodash": "4.17.21",
"react": "17.0.2",
"react-bootstrap": "1.5.2",
"react-dom": "17.0.2",
"react-markdown": "5.0.3",
"react-router": "5.2.0",
"react-router-breadcrumbs-hoc": "3.3.1",
"react-router-dom": "5.2.0",
"react-scripts": "4.0.3"
"react": "^18.3.1",
"react-bootstrap": "1.6.8",
"react-dom": "^18.3.1",
"react-markdown": "9.0.1",
"react-router-dom": "6.24.1",
"use-react-router-breadcrumbs": "4.0.1"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^8.57.0",
"eslint-plugin-react": "7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"typescript": "^5.2.2",
"vite": "^5.3.1"
}
}
Loading

0 comments on commit 643ee8e

Please sign in to comment.