Skip to content

Commit

Permalink
Merge pull request #1647 from trillium/vite
Browse files Browse the repository at this point in the history
Merge Vite branch
  • Loading branch information
jbubar committed Aug 20, 2024
2 parents 23228cb + 2a74b01 commit f89f90d
Show file tree
Hide file tree
Showing 91 changed files with 4,135 additions and 12,062 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/aws-frontend-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
- name: Checkout
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
6 changes: 3 additions & 3 deletions backend/Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
FROM node:14.11.0 AS api-development
FROM node:18.12.0 AS api-development
RUN mkdir /srv/backend
WORKDIR /srv/backend
RUN mkdir -p node_modules
COPY package.json yarn.lock ./
RUN yarn install --pure-lockfile
COPY . .

FROM node:14.11.0 AS api-test
FROM node:18.12.0 AS api-test
RUN mkdir /srv/backend
WORKDIR /srv/backend
COPY package.json yarn.lock ./
RUN yarn install --silent
RUN mkdir -p node_modules

FROM node:14.11.0-slim AS api-production
FROM node:18.12.0-slim AS api-production
EXPOSE 4000
USER node
WORKDIR /srv/backend
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.11.0 AS api-development
FROM node:18.12.0 AS api-development
RUN mkdir /srv/backend
WORKDIR /srv/backend
RUN mkdir -p node_modules
Expand Down
4 changes: 2 additions & 2 deletions backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:14.11.0 AS api-builder
FROM node:18.12.0 AS api-builder
RUN mkdir /srv/backend
WORKDIR /srv/backend
RUN mkdir -p node_modules
COPY package.json yarn.lock ./
RUN yarn install --pure-lockfile
COPY . .

FROM node:14.11.0-slim AS api-production
FROM node:18.12.0-slim AS api-production
EXPOSE 4000
USER node
WORKDIR /srv/backend
Expand Down
2 changes: 1 addition & 1 deletion backend/globalConfig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mongoUri":"mongodb://127.0.0.1:63857/jest?","mongoDBName":"jest"}
{"mongoUri":"mongodb://127.0.0.1:53806/jest?","mongoDBName":"jest"}
5 changes: 4 additions & 1 deletion backend/models/project.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { Project } = require('./project.model');

const { setupDB } = require("../setup-test");
setupDB("project-model");

beforeAll(async () => {
await setupDB("user-model");
});

describe("Project Model saves the correct values", () => {
test("Save a model instance and then read from the db", async (done) => {
Expand Down
5 changes: 4 additions & 1 deletion backend/models/user.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { User } = require('./user.model');

const { setupDB } = require("../setup-test");
setupDB("user-model");

beforeAll(async () => {
await setupDB("user-model");
});

// Please add and expand on this simple test.
describe("Question Model saves the correct values", () => {
Expand Down
4 changes: 2 additions & 2 deletions client/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:14.11.0 AS client-development
FROM node:18-alpine AS client-development
RUN mkdir /srv/client && chown node:node /srv/client
WORKDIR /srv/client
USER node
RUN mkdir -p node_modules
COPY --chown=node:node package.json package.json ./
RUN npm install --silent

FROM node:14.11.0-slim AS client-builder
FROM node:18.12.0-slim AS client-builder
USER node
WORKDIR /srv/client
COPY --from=client-development /srv/client/node_modules node_modules
Expand Down
2 changes: 1 addition & 1 deletion client/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.11.0 AS client-development
FROM node:18-alpine AS client-development
RUN mkdir /srv/client && chown node:node /srv/client
WORKDIR /srv/client
USER node
Expand Down
6 changes: 3 additions & 3 deletions client/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:14.11.0 AS node-modules-install
FROM node:20-alpine AS node-modules-install
RUN mkdir /srv/client && chown node:node /srv/client
WORKDIR /srv/client
USER node
RUN mkdir -p node_modules
COPY --chown=node:node package.json package.json ./
RUN npm install --silent
RUN npm install --no-update-notifier

FROM node:14.11.0-slim AS client-builder
FROM node:18-slim AS client-builder
USER node
WORKDIR /srv/client
COPY --from=node-modules-install /srv/client/node_modules node_modules
Expand Down
9 changes: 5 additions & 4 deletions client/public/index.html → client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand All @@ -18,13 +18,13 @@
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
Notice the use of in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
Expand All @@ -33,6 +33,7 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
34 changes: 22 additions & 12 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.14.19",
"@mui/material": "^5.11.12",
"@vitejs/plugin-react": "^4.0.3",
"@vitejs/plugin-react-swc": "^3.3.2",
"classnames": "^2.2.6",
"cross-env": "^7.0.2",
"cross-var": "^1.1.0",
Expand All @@ -21,20 +23,22 @@
"minimist": "^1.2.6",
"moment": "^2.29.2",
"moment-recur": "^1.0.7",
"react": "^16.13.1",
"react-datepicker": "^3.1.3",
"react-dom": "^16.13.1",
"react": "^18.2.0",
"react-datepicker": "^4.16.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.44.3",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.1",
"validator": "^13.7.0"
"validator": "^13.7.0",
"vite": "^4.4.4",
"vite-plugin-svgr": "^3.2.0"
},
"scripts": {
"start": "dotenv -e .env -e ../backend/.env -- cross-var cross-env PORT=%CLIENT_PORT% react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --watchAll=false",
"test:watch": "react-scripts test",
"eject": "react-scripts eject",
"vite": "vite",
"dev": "vite",
"start": "dotenv -e .env -e ../backend/.env -- cross-var cross-env PORT=%CLIENT_PORT% vite",
"build": "vite build",
"test": "vitest run",
"preview": "vite preview",
"heroku-postbuild": "npm run build"
},
"eslintConfig": {
Expand All @@ -55,6 +59,8 @@
"author": "sarL3y",
"license": "ISC",
"devDependencies": {
"@testing-library/dom": "^10.3.2",
"@testing-library/react": "^16.0.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
Expand All @@ -63,8 +69,12 @@
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"jsdom": "^24.1.0",
"prettier": "^2.1.1",
"react-test-renderer": "^16.13.1",
"sass": "^1.49.7"
"sass": "^1.49.7",
"vitest": "^1.6.0"
},
"engines": {
"node": "<=18.0.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Leaderboard = (props) => {

setUsers(resJson);
} catch(error) {
alert(error);
console.log(error);
}
};

Expand Down
8 changes: 0 additions & 8 deletions client/src/components/Leaderboard.test.js

This file was deleted.

9 changes: 9 additions & 0 deletions client/src/components/Leaderboard.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";
import LeaderBoard from "./Leaderboard";
import { render } from "@testing-library/react";
import { test, expect } from 'vitest';

test("renders without crashing", () => {
const { container } = render(<LeaderBoard />);
expect(container).toMatchSnapshot();
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions client/src/components/__snapshots__/Leaderboard.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`renders without crashing 1`] = `
<div>
<div
class="flexcenter-container"
>
<div
class="dashboard-header"
>
<p
class="dashboard-header-text-large"
>
Volunteer Leaderboard
</p>
</div>
<div
class="events-list"
>
<ul />
</div>
</div>
</div>
`;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
const {addDurationToTime} = require('../addDurationToTime')
// const {addDurationToTime} = require('../addDurationToTime')
import {addDurationToTime} from '../addDurationToTime'
import {test, expect} from 'vitest'

describe('addDurationToTime', () => {
it('adds inputted "0.5" duration to inputted time', () => {
test('adds inputted "0.5" duration to inputted time', () => {
const inputDuration = "0.5"
const inputTime = new Date()
const outputTime = new Date(inputTime.getTime() + (.5*3600000))

expect(addDurationToTime(inputTime, inputDuration)).toEqual(outputTime)
})

it('adds inputted ".5" duration to inputted time', () => {
test('adds inputted ".5" duration to inputted time', () => {
const inputDuration = ".5"
const inputTime = new Date()
const outputTime = new Date(inputTime.getTime() + (.5*3600000))

expect(addDurationToTime(inputTime, inputDuration)).toEqual(outputTime)
})

it('adds inputted "3" hour duration to inputted time', () => {
test('adds inputted "3" hour duration to inputted time', () => {
const inputDuration = "3"
const inputTime = new Date()
const outputTime = new Date(inputTime.getTime() + (3*3600000))

expect(addDurationToTime(inputTime, inputDuration)).toEqual(outputTime)
})

it('throws an error when there is no valid input', () => {
test('throws an error when there is no valid input', () => {

expect(addDurationToTime).toThrow(new Error('Error: Cannot calculate endTime.'))
})
})
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions client/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react-swc'
import svgr from "vite-plugin-svgr";

export default defineConfig(({ mode }) => {
// Load env file based on`mode in the current working directory.
const env = loadEnv(mode, process.cwd(), '');
return {
plugins: [
svgr(),
react(),
],
server: {
port: env.CLIENT_PORT,
host: true,
proxy: {
'/api': {
target: env.REACT_APP_PROXY,
changeOrigin: true,
secure: false,
},
},
},
build: {
outDir: 'build',
},
test: {
environment: 'jsdom',
},
};
});
Loading

0 comments on commit f89f90d

Please sign in to comment.