Skip to content

Commit 3ec741e

Browse files
authored
Merge pull request #3868 from Northeastern-Electric-Racing/esm-switch
Esm switch
2 parents e0bea8c + 40d9a71 commit 3ec741e

239 files changed

Lines changed: 3031 additions & 3107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/run-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@ jobs:
3737
run: docker exec finishline psql -U postgres -c "CREATE DATABASE nerpm;"
3838
- name: Install modules
3939
run: yarn install && yarn prisma:generate && yarn prisma:migrate:prod
40+
- name: Build shared package
41+
run: yarn build:shared
4042
- name: Run tests
4143
run: yarn test:backend; yarn test:frontend

.github/workflows/tsc-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ jobs:
2828
- name: Install dependencies
2929
run: yarn install && yarn prisma:generate
3030

31+
- name: Build shared package
32+
run: yarn build:shared
33+
3134
- name: Run tsc check
3235
run: npm run tsc-check # You need to define this script in your package.json

devContainerization/docker-compose.dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: finishline-development
22
services:
33
database:
44
container_name: database-dev
5-
image: postgres
5+
image: postgres:16
66
environment:
77
POSTGRES_USER: postgres
88
POSTGRES_PASSWORD: docker
99
POSTGRES_DB: finishline_database
10+
PGDATA: /var/lib/postgresql/data
1011
ports:
1112
- '5432:5432'
1213
volumes:

devContainerization/start-containers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { exec, spawn } = require('child_process');
2-
const { promisify } = require('util');
1+
import { exec, spawn } from 'child_process';
2+
import { promisify } from 'util';
33

44
const execAsync = promisify(exec);
55
const COMPOSE_FILE = 'docker-compose.dev.yml';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"prisma:manual": "yarn workspace backend prisma:manual",
2828
"prisma:studio": "cd src/backend; npx prisma studio",
2929
"docker:prisma:studio": "cd devContainerization && docker compose -f docker-compose.dev.yml exec -T backend sh -c \"cd /src/backend && npx prisma studio\"",
30-
"containerize": "cd containerization; docker compose down && docker compose build && docker compose up -d && sleep 5 && cd ../ && yarn containerize:psql:init && yarn prisma:migrate",
30+
"containerize": "cd containerization; docker compose down && docker compose build && docker compose up -d && sleep 5 && cd ../ && yarn containerize:psql:init && docker exec backend sh -c 'cd /base/src/backend && npx prisma migrate deploy'",
3131
"containerize:psql:init": "docker exec database psql -U postgres -c \"CREATE DATABASE nerpm;\" && yarn database:setup:script",
3232
"containerize:test:e2e": "yarn containerize && yarn prisma:reset:force && yarn test:e2e",
3333
"lint": "npx eslint .",

scripts/database-setup.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
const fs = require('fs');
1+
import fs from 'fs';
22

33
const filePath = './src/backend/.env';
44
const lineToAdd = 'DATABASE_URL="postgresql://postgres:docker@localhost:5432/nerpm?schema=public"';
55

66
if (!fs.existsSync(filePath)) {
7-
fs.writeFileSync(filePath, lineToAdd, 'utf8');
8-
return;
7+
fs.writeFileSync(filePath, lineToAdd, 'utf8');
8+
return;
99
}
1010

1111
fs.readFile(filePath, 'utf8', (err, data) => {
12-
if (err) {
13-
console.error('Error reading file:', err);
14-
return;
15-
}
12+
if (err) {
13+
console.error('Error reading file:', err);
14+
return;
15+
}
1616

17-
// Split file contents into lines
18-
const lines = data.trim().split('\n');
17+
// Split file contents into lines
18+
const lines = data.trim().split('\n');
1919

20-
for (const line of lines) {
21-
//db url already exists, no need to add it
22-
if (line.startsWith("DATABASE_URL=")) return;
23-
}
20+
for (const line of lines) {
21+
//db url already exists, no need to add it
22+
if (line.startsWith('DATABASE_URL=')) return;
23+
}
2424

25-
fs.appendFile(filePath, `\n${lineToAdd}`, 'utf8', (err) => {
26-
if (err) {
27-
console.error('Error appending line to file:', err);
28-
return;
29-
}
30-
});
25+
fs.appendFile(filePath, `\n${lineToAdd}`, 'utf8', (err) => {
26+
if (err) {
27+
console.error('Error appending line to file:', err);
28+
return;
29+
}
30+
});
3131
});

scripts/db-pull.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { execSync } = require('child_process');
2-
const readline = require('readline');
1+
import { execSync } from 'child_process';
2+
import readline from 'readline';
33

44
function promptUser(question) {
55
const rl = readline.createInterface({
@@ -19,7 +19,7 @@ async function main() {
1919
console.log('🚀 Database Migration Script\n');
2020

2121
try {
22-
const targetUrl = "postgresql://postgres:docker@localhost:5432/nerpm"
22+
const targetUrl = 'postgresql://postgres:docker@localhost:5432/nerpm';
2323

2424
console.log(`📍 Target database: ${targetUrl.replace(/\/\/[^@]*@/, '//***:***@')}`);
2525

@@ -41,7 +41,7 @@ async function main() {
4141

4242
// First, clear the target database completely
4343
const clearCommand = `psql "${targetUrl}" -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"`;
44-
console.log(targetUrl)
44+
console.log(targetUrl);
4545

4646
try {
4747
execSync(clearCommand, { stdio: 'inherit' });
@@ -57,11 +57,10 @@ async function main() {
5757
execSync(dumpCommand, { stdio: 'inherit' });
5858

5959
console.log('✅ Migration complete!');
60-
6160
} catch (error) {
6261
console.error('❌ Error:', error.message);
6362
process.exit(1);
6463
}
6564
}
6665

67-
main();
66+
main();

scripts/test-setup.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const fs = require('fs');
1+
import fs from 'fs';
22

33
const filePath = './src/backend/.env';
44
const lineToAdd = 'DATABASE_URL="postgresql://postgres:docker@localhost:5433/nerpm?schema=public"';
55

66
fs.readFile(filePath, 'utf8', (err, data) => {
7-
if (err) {
8-
console.error('Error reading file:', err);
9-
return;
10-
}
7+
if (err) {
8+
console.error('Error reading file:', err);
9+
return;
10+
}
1111

12-
// Split file contents into lines
13-
const lines = data.trim().split('\n');
12+
// Split file contents into lines
13+
const lines = data.trim().split('\n');
1414

15-
// Check if the last line matches the lineToAdd
16-
if (lines[lines.length - 1] !== lineToAdd) {
17-
// Append the line if it's not already the last line
18-
fs.appendFile(filePath, `\n${lineToAdd}`, 'utf8', (err) => {
19-
if (err) {
20-
console.error('Error appending line to file:', err);
21-
return;
22-
}
23-
});
24-
}
25-
});
15+
// Check if the last line matches the lineToAdd
16+
if (lines[lines.length - 1] !== lineToAdd) {
17+
// Append the line if it's not already the last line
18+
fs.appendFile(filePath, `\n${lineToAdd}`, 'utf8', (err) => {
19+
if (err) {
20+
console.error('Error appending line to file:', err);
21+
return;
22+
}
23+
});
24+
}
25+
});

scripts/test-teardown.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
const fs = require('fs');
1+
import fs from 'fs';
22

33
const filePath = './src/backend/.env';
44
const lineToMatch = 'DATABASE_URL="postgresql://postgres:docker@localhost:5433/nerpm?schema=public"';
55

66
fs.readFile(filePath, 'utf8', (err, data) => {
7-
if (err) {
8-
console.error('Error reading file:', err);
9-
return;
10-
}
7+
if (err) {
8+
console.error('Error reading file:', err);
9+
return;
10+
}
1111

12-
// Split file contents into lines
13-
const lines = data.trim().split('\n');
12+
// Split file contents into lines
13+
const lines = data.trim().split('\n');
1414

15-
// Check if the last line matches the lineToMatch
16-
if (lines[lines.length - 1] === lineToMatch) {
17-
// Remove the last line
18-
lines.pop();
15+
// Check if the last line matches the lineToMatch
16+
if (lines[lines.length - 1] === lineToMatch) {
17+
// Remove the last line
18+
lines.pop();
1919

20-
// Write modified contents back to the file
21-
fs.writeFile(filePath, lines.join('\n'), 'utf8', (err) => {
22-
if (err) {
23-
console.error('Error writing file:', err);
24-
return;
25-
}
26-
});
27-
}
28-
});
20+
// Write modified contents back to the file
21+
fs.writeFile(filePath, lines.join('\n'), 'utf8', (err) => {
22+
if (err) {
23+
console.error('Error writing file:', err);
24+
return;
25+
}
26+
});
27+
}
28+
});

src/backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN yarn install --prod;
1414
RUN echo DATABASE_URL=\"postgresql://postgres:docker@database:5432/nerpm?schema=public\" > ./src/backend/.env
1515
RUN echo NODE_ENV=development >> ./src/backend/.env
1616

17-
RUN yarn prisma:generate && yarn build:backend && yarn build:shared
17+
RUN yarn prisma:generate && yarn build:shared && yarn build:backend
1818

1919
EXPOSE 3001
2020
CMD [ "yarn", "backend" ]

0 commit comments

Comments
 (0)