Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Vite branch #1647

Merged
merged 69 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5064dcb
chore: Add vite libraries to package.json
trillium Jul 16, 2023
db10b2c
feat: Create vite.config.js and mimic create-react-app
trillium Jul 16, 2023
57ca417
chore: Add vite to scripts
trillium Jul 16, 2023
46f7aaf
chore: Move index.html to root for vite
trillium Jul 16, 2023
6d36b5f
chore: Remove %PUBLIC_URL% from index.html
trillium Jul 16, 2023
b623c07
chore: Add link to vite in index.html
trillium Jul 16, 2023
8c54c92
chore: Rename all components to .jsx for vite
trillium Jul 16, 2023
efcfd28
Merge pull request #1426 from Spiteless/ts.vite
trillium Jul 16, 2023
fe6e70a
chore: Add "engines" and specifcy node 18+
trillium Jul 16, 2023
9e15afc
Merge pull request #1427 from Spiteless/ts.vite
trillium Jul 16, 2023
3ee8a40
chore: Move Vite out of dev dependencies
trillium Jul 16, 2023
08094f2
Merge pull request #1428 from Spiteless/ts.vite
trillium Jul 16, 2023
a2a9132
asset: Update Dockerfiles in client
trillium Jul 16, 2023
5707139
Merge pull request #1429 from Spiteless/ts.vite-remove-babel
trillium Jul 16, 2023
9e456c3
asset: Update node in backend as well
trillium Jul 16, 2023
ecb8236
Merge pull request #1430 from Spiteless/ts.vite-remove-babel
trillium Jul 16, 2023
289bbfb
fix: Add step to specify more current node
trillium Jul 16, 2023
8abf023
Merge pull request #1431 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
449423a
fix: Direct call to upgrade node in action
trillium Jul 16, 2023
3d9ef88
Merge pull request #1432 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
76fa0c9
fix: Add rest of Dockerfiles, missed two
trillium Jul 16, 2023
86392d4
Merge pull request #1433 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
2fef347
fix: Swap to node:18.alpine, remove 'npm i- g npm'
trillium Jul 16, 2023
cb810b8
Merge pull request #1434 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
03742eb
fix: Change to alpine:3.14 in Dockerfile.prod
trillium Jul 16, 2023
4123952
Merge pull request #1435 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
b3c0c8d
wip: Update containers for testing
trillium Jul 16, 2023
c0d4e36
Merge pull request #1436 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
b9a6707
wip: Update to node:20-alpine in Dockerfile.prod
trillium Jul 16, 2023
a417554
Merge pull request #1437 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
a01cea8
wip: Add --no-update-notifier to yarn install
trillium Jul 16, 2023
6fcb013
Merge pull request #1438 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
229ec35
wip: Remove --silent, get all the infos
trillium Jul 16, 2023
783e929
Merge pull request #1439 from Spiteless/ts.vite-update-ghaction
trillium Jul 16, 2023
e7a22aa
wip: refresh yarn lock using node 18
trillium Jul 17, 2023
7f4ff40
Merge pull request #1441 from Spiteless/ts.vite-update-ghaction
trillium Jul 17, 2023
0cd0794
wip: Upgrade react to 18 in project root
trillium Jul 17, 2023
b7684cd
Merge pull request #1442 from Spiteless/ts.vite-update-ghaction
trillium Jul 17, 2023
f78d56a
wip: Upgrade react-datepicker
trillium Jul 17, 2023
f5a788e
Merge pull request #1443 from Spiteless/ts.vite-update-ghaction
trillium Jul 17, 2023
481aa89
wip: Upgrade react-test-renderer
trillium Jul 17, 2023
8a87d59
Merge pull request #1444 from Spiteless/ts.vite-update-ghaction
trillium Jul 17, 2023
5a63ee7
Merge branch 'dev' into vite, regenerate yarn.lock
trillium May 29, 2024
315f448
chore: snackbarContext.js to .jsx
trillium May 29, 2024
c3772f0
chore: TitledBox.js to .jsx
trillium May 29, 2024
70d156c
chore: ValidatedTextField to .jsx
trillium May 29, 2024
bd563ee
chore: ChangesModal to .jsx
trillium May 29, 2024
a3f6104
chore: addProject to .jsx
trillium May 29, 2024
7912b87
feat: Upgrade .nvmrc to 18
trillium May 29, 2024
b688c34
chore: Add "dev" command in client/scripts
trillium May 29, 2024
3c6a793
Merge remote-tracking branch 'upstream/development' into vite
trillium May 30, 2024
c37c524
feat: Upgrade vitest to ^1.36 in /client
trillium May 30, 2024
a812506
feat: Switch alert to console log, allows test to complete
trillium May 30, 2024
e32a88b
chore: Rename Leaderboard.test.js --> .jsx for vitest
trillium May 30, 2024
9839bda
feat: Change `require` to import to resolve vitest module warning
trillium May 30, 2024
51e9429
feat: Add Leaderboard test snapshot
trillium May 30, 2024
e867b41
feat: Add host to server in config for docker development
trillium May 30, 2024
d9798ed
Merge remote-tracking branch 'upstream/development' into vite
trillium Jun 3, 2024
1234816
feat: Update tests to use beforeAll on setupDB step
trillium Jun 3, 2024
a2ea448
Merge remote-tracking branch 'upstream/development' into vite
trillium Jul 2, 2024
78186c0
Merge remote-tracking branch 'upstream/development' into vite
trillium Jul 15, 2024
6d3ad0f
fix: Update 'vitest' to 'vitest run' to run once in CI/CD
trillium Jul 15, 2024
3f4d077
feat: Add jsom to vite.config.js and /client dependencies
trillium Jul 15, 2024
7516f27
feat: Update from depricated react-test-renderer to @testing-library/…
trillium Jul 15, 2024
bb64b55
feat: Add testing __snapshots__
trillium Jul 15, 2024
321f787
feat: Update yarn.lock to have new dependencies
trillium Jul 15, 2024
48e3f1a
feat: Remove unused dependency "react-test-renderer"
trillium Jul 15, 2024
5a159cb
Merge remote-tracking branch 'upstream/development' into vite
trillium Aug 6, 2024
2a74b01
Merge branch 'development' into vite
jbubar Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
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.
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.
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
Loading