Skip to content

Commit 3221763

Browse files
committed
Merge branch 'main' of github.com:ut-code/CourseMate into fix-edit-prof
2 parents 2119c55 + 00df094 commit 3221763

File tree

117 files changed

+2478
-1582
lines changed

Some content is hidden

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

117 files changed

+2478
-1582
lines changed

.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"reqwest",
2020
"safify",
2121
"supabase",
22-
"swiper"
22+
"swiper",
23+
"lefthook"
2324
],
2425
"dictionaries": [
2526
"softwareTerms",

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
bun-version: latest
6868

6969
- run: make setup-ci
70-
- run: make spell-check
70+
- run: bunx cspell --quiet .
7171

7272
test:
7373
name: Bun Test
@@ -86,7 +86,7 @@ jobs:
8686
- uses: actions/setup-node@v3
8787
- uses: oven-sh/setup-bun@v2
8888
- run: make prepare-deploy-web
89-
- run: test `ls web/out | wc -l` != 0
89+
- run: test `ls web/.next | wc -l` != 0
9090

9191
deploy-test-server:
9292
name: Deploy Test (server)

.github/workflows/rust.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ jobs:
2222
~/.rustup/
2323
scraper/target
2424
key: cargo-cache-${{ github.job }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
25-
- uses: actions-rust-lang/setup-rust-toolchain@v1
25+
- uses: dtolnay/rust-toolchain@v1
2626
with:
27+
toolchain: 1.82.0
2728
components: clippy,rustfmt
2829
- run: cargo build
2930
- run: cargo build --release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ dist-ssr
2525

2626
.env
2727
/.direnv
28+
.husky

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,28 @@ LOCAL_DB := postgres://user:password@localhost:5432/database
55
setup:
66
if [ ! `command -v bun` ]; then echo 'ERR: Bun is required!'; exit 1; fi
77
make sync
8-
bunx husky
98
@echo "auto setup is done. now do:"
109
@echo "- edit server/.env.dev"
1110
@echo "- edit web/.env"
1211
@echo "- run make sync"
1312

14-
setup-ci:
15-
if [ ${DATABASE_URL} == "" ]; then echo 'Please set DATABASE_URL_FOR_SQL_GENERATION!'; exit 1; fi
13+
setup-ci:
14+
if [ "" == ${DATABASE_URL} ]; then echo 'Please set DATABASE_URL_FOR_SQL_GENERATION!'; exit 1; fi
1615
make sync
1716
make generate-sql
1817

19-
sync: sync-server sync-web sync-root copy-common
18+
sync: sync-server sync-web sync-root sync-common
2019
@echo '----------------------------------------------------------------------------------------------------------'
2120
@echo '| Most work is done. now running prisma-generate-sql (which might fail if .env.dev is not set configured)|'
2221
@echo '----------------------------------------------------------------------------------------------------------'
2322
make generate-sql || true
2423

2524
generate-sql:
26-
@cd server; bun run prisma-generate-sql
25+
@cd server; \
26+
if command -v dotenv && command -v prisma; \
27+
then dotenv -e .env.dev -- prisma generate --sql; \
28+
else bunx dotenv -e .env.dev -- bunx prisma generate --sql; \
29+
fi
2730

2831
start: start-all # build -> serve
2932
build: build-server build-web
@@ -42,21 +45,24 @@ test: dev-db
4245
cd ./test; ENV_FILE=../server/.env.dev bun test
4346
docker stop postgres
4447

45-
prepare-deploy-web: copy-common
48+
prepare-deploy-web: sync-common
4649
cd web; bun install; bun run build
47-
prepare-deploy-server: copy-common sync-server generate-sql
50+
deploy-web:
51+
@if [ "${PORT}" == "" ]; then echo 'env PORT not found!'; exit 1; fi
52+
cd web; bun next start --port ${PORT}
53+
prepare-deploy-server: sync-common sync-server generate-sql
4854
deploy-server:
4955
cd server; bun src/main.ts
5056

51-
docker: copy-common
57+
docker:
5258
@# deferring `docker compose down`. https://qiita.com/KEINOS/items/532dc395fe0f89c2b574
5359
trap 'docker compose down' EXIT; docker compose up --build
5460

55-
docker-watch: copy-common
61+
docker-watch:
5662
docker compose up --build --watch
5763

5864
seed:
59-
cd server; bunx prisma db seed
65+
cd server; if command -v prisma; then prisma db seed; else bunx prisma db seed; fi
6066

6167
## server/.envをDATABASE_URL=postgres://user:password@localhost:5432/databaseにしてから行う
6268
dev-db: export DATABASE_URL=$(LOCAL_DB)
@@ -70,26 +76,18 @@ dev-db:
7076
-e POSTGRES_DB=database \
7177
postgres:alpine
7278
@echo "Waiting for PostgreSQL to be ready..."
73-
@sleep 5 # PostgreSQLが起動するまでの待機(必要に応じて調整)
79+
@sleep 2 # PostgreSQLが起動するまでの待機(必要に応じて調整)
7480
@until docker exec postgres pg_isready -U user -d database; do \
7581
echo "Waiting for PostgreSQL to be ready..."; \
7682
sleep 1; \
7783
done
7884
@echo "PostgreSQL is ready. Running seed..."
79-
@cd server; bunx prisma generate; bunx prisma db push; cd ..
80-
@make seed;
85+
@cd server; if command -v prisma; then \
86+
prisma generate; prisma db push; else \
87+
bunx prisma generate; bunx prisma db push; fi
88+
@make seed
8189
@echo "Seeding completed."
8290

83-
84-
precommit: check-branch lint-staged spell-check
85-
86-
lint-staged:
87-
bunx lint-staged
88-
check-branch:
89-
@ if [ "$(git branch --show-current)" == "main" ]; then echo "Cannot make commit on main! aborting..."; exit 1; fi
90-
spell-check:
91-
bunx cspell --quiet .
92-
9391
# Sync (install/update packages, generate prisma, etc)
9492

9593
sync-web:
@@ -98,11 +96,13 @@ sync-web:
9896

9997
sync-server:
10098
cd server; bun install --frozen-lockfile
101-
cd server; bunx prisma generate
99+
cd server; if command -v prisma; then prisma generate; else bunx prisma generate; fi
102100
# copy .env.sample -> .env only if .env is not there
103101

104102
sync-root:
105103
bun install --frozen-lockfile
104+
sync-common:
105+
cd common; bun install --frozen-lockfile
106106

107107

108108
# Static checks
@@ -127,7 +127,7 @@ format-check:
127127
@exit 1
128128

129129
# type checks
130-
type-check: copy-common
130+
type-check:
131131
make type-check-server
132132
make type-check-web
133133

@@ -143,9 +143,9 @@ type-check-web:
143143
start-all: build-web build-server
144144
make serve-all
145145

146-
build-web: copy-common-to-web
146+
build-web:
147147
cd web; bun run build
148-
build-server: copy-common-to-server
148+
build-server:
149149
cd server; bun run build
150150

151151
serve-all:
@@ -155,17 +155,9 @@ serve-web:
155155
serve-server:
156156
cd server; bun run serve
157157

158-
watch-web: copy-common-to-web
158+
watch-web:
159159
cd web; bun run dev
160-
watch-server: copy-common-to-server
160+
watch-server:
161161
cd server; bun run dev
162162

163-
copy-common: copy-common-to-server copy-common-to-web
164-
copy-common-to-server:
165-
@ if [ -d server/src/common ]; then rm -r server/src/common; fi
166-
@ cp -r common server/src/common
167-
copy-common-to-web:
168-
@ if [ -d web/common ]; then rm -r web/common; fi
169-
@ cp -r common web/common
170-
171163
.PHONY: test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ GNU Make が導入されています。以下は、ユーザーが使うこと
1313
- make setup (セットアップします。)
1414
- make start (build -> serve します。)
1515
- make watch (ホットリロードします。)
16-
- make precommit (type-check, format-check, lint を実行します。husky で自動実行されます。)
1716

1817
### 環境構築
1918

@@ -27,6 +26,7 @@ GNU Make が導入されています。以下は、ユーザーが使うこと
2726
- Bun (js)
2827
- GNU Make
2928
- nvm (optional)
29+
- lefthook
3030

3131
- `make setup` を実行します。
3232

bun.lockb

1.14 KB
Binary file not shown.

common/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# common
2+
3+
To install dependencies:
4+
5+
```bash
6+
bun install
7+
```
8+
9+
To run:
10+
11+
```bash
12+
bun run index.ts
13+
```
14+
15+
This project was created using `bun init` in bun v1.1.29. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

common/bun.lockb

3.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)