Skip to content

Commit b5f11d3

Browse files
committed
chore: migrate to pnpm and add lightweight monorepo tooling
1 parent 9e729e0 commit b5f11d3

16 files changed

Lines changed: 1529 additions & 1456 deletions

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
## Verification
3030

31-
<!-- List the commands or checks you ran. For example: cd backend && go test ./..., cd frontend && pnpm check, cd frontend && pnpm build. -->
31+
<!-- List the commands or checks you ran. For example: pnpm check, pnpm test, pnpm build. -->
3232

3333
- [ ] Not run; reason:
3434

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
name: Frontend Quality
1+
name: Workspace Quality
22

33
on:
44
push:
55
branches:
66
- main
77
- dev
88
paths:
9+
- "backend/**"
910
- "frontend/**"
11+
- "package.json"
12+
- "pnpm-lock.yaml"
13+
- "pnpm-workspace.yaml"
14+
- "turbo.json"
1015
- "scripts/sync-version.mjs"
1116
- "VERSION"
1217
- ".github/workflows/frontend-quality.yml"
@@ -15,7 +20,12 @@ on:
1520
- main
1621
- dev
1722
paths:
23+
- "backend/**"
1824
- "frontend/**"
25+
- "package.json"
26+
- "pnpm-lock.yaml"
27+
- "pnpm-workspace.yaml"
28+
- "turbo.json"
1929
- "scripts/sync-version.mjs"
2030
- "VERSION"
2131
- ".github/workflows/frontend-quality.yml"
@@ -26,11 +36,8 @@ permissions:
2636

2737
jobs:
2838
quality:
29-
name: Biome and TypeScript
39+
name: Frontend and backend checks
3040
runs-on: ubuntu-24.04
31-
defaults:
32-
run:
33-
working-directory: frontend
3441

3542
steps:
3643
- name: Checkout
@@ -40,17 +47,24 @@ jobs:
4047
uses: pnpm/action-setup@v4
4148
with:
4249
version: 10.17.0
43-
run_install: false
4450

4551
- name: Set up Node.js
4652
uses: actions/setup-node@v4
4753
with:
4854
node-version: 24
4955
cache: pnpm
50-
cache-dependency-path: frontend/pnpm-lock.yaml
56+
57+
- name: Set up Go
58+
uses: actions/setup-go@v5
59+
with:
60+
go-version-file: backend/go.mod
61+
cache-dependency-path: backend/go.sum
5162

5263
- name: Install dependencies
5364
run: pnpm install --frozen-lockfile
5465

55-
- name: Run frontend checks
66+
- name: Run workspace checks
5667
run: pnpm check
68+
69+
- name: Run workspace tests
70+
run: pnpm test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ web_modules/
9393
.cache
9494
.parcel-cache
9595

96+
# Turborepo cache
97+
.turbo/
98+
9699
# Next.js build output
97100
.next
98101
out

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ Thank you for contributing to DEEIX Chat.
1010

1111
## Development Setup
1212

13-
Backend:
13+
Install all workspace dependencies:
1414

1515
```bash
16-
cd backend
17-
go test ./...
16+
pnpm install
1817
```
1918

20-
Frontend:
19+
Run the shared quality and test pipelines:
2120

2221
```bash
23-
cd frontend
24-
pnpm install
25-
pnpm lint
22+
pnpm check
23+
pnpm test
2624
pnpm build
2725
```
2826

27+
Use `pnpm dev`, `pnpm dev:web`, or `pnpm dev:api` for local development.
28+
2929
Use the example configuration files for local development. Do not commit local secrets or production credentials.
3030

3131
## Pull Request Guidelines
@@ -107,7 +107,7 @@ Core expectations:
107107
- keep API access inside `shared/api` or feature-level API modules
108108
- do not hard-code provider-private model behavior in the frontend
109109
- keep authentication tokens aligned with the existing session model
110-
- run `pnpm lint`, and run `pnpm build` for routing, dependency, or Next.js changes
110+
- run `pnpm --filter @deeix/web lint`, and run `pnpm build` for routing, dependency, or Next.js changes
111111

112112
## Code Style
113113

Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
FROM node:24-bookworm-slim AS frontend-builder
44

5-
WORKDIR /src/frontend
5+
WORKDIR /src
66

77
ENV PNPM_HOME=/pnpm
88
ENV PATH=$PNPM_HOME:$PATH
@@ -12,17 +12,21 @@ ENV NEXT_PUBLIC_API_BASE_URL=${NEXT_PUBLIC_API_BASE_URL}
1212

1313
COPY VERSION /src/VERSION
1414
COPY scripts /src/scripts
15-
COPY frontend/package.json frontend/pnpm-lock.yaml ./
16-
COPY frontend/scripts ./scripts
17-
COPY frontend/public/pwa ./public/pwa
15+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
16+
COPY frontend/package.json ./frontend/package.json
17+
COPY backend/package.json ./backend/package.json
18+
COPY frontend/scripts ./frontend/scripts
19+
COPY frontend/public/pwa ./frontend/public/pwa
1820

19-
RUN corepack enable
21+
RUN npm install --global pnpm@10.17.0
2022

2123
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
2224
pnpm config set store-dir /pnpm/store \
23-
&& pnpm install --frozen-lockfile
25+
&& pnpm install --frozen-lockfile --filter @deeix/web...
26+
27+
COPY frontend ./frontend
2428

25-
COPY frontend ./
29+
WORKDIR /src/frontend
2630

2731
# 如果你的 Next 版本支持,可以在 next.config 里开启 turbopack build filesystem cache
2832
RUN --mount=type=cache,id=next-cache,target=/src/frontend/.next/cache \

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,21 @@ cp config.example.yaml config.yaml
130130

131131
Adjust `database.postgres.dsn`, `database.redis.*`, and public URLs in `config.yaml` for your local environment.
132132

133-
2. Start the backend:
133+
2. Install workspace dependencies and prepare the frontend environment:
134134

135135
```bash
136-
cd backend
137-
make run
136+
pnpm install
137+
cp frontend/.env.example frontend/.env.local
138138
```
139139

140-
3. Start the frontend:
140+
3. Start the frontend and backend together:
141141

142142
```bash
143-
cd frontend
144-
pnpm install
145-
cp .env.example .env.local
146143
pnpm dev
147144
```
148145

146+
Use `pnpm dev:web` or `pnpm dev:api` to start only one workspace.
147+
149148
The frontend uses `NEXT_PUBLIC_API_BASE_URL` for API requests. For local development, confirm that `frontend/.env.local` contains:
150149

151150
```env
@@ -268,9 +267,8 @@ Use this mode when the frontend and backend are served from different public ori
268267
2. Build and publish the frontend.
269268

270269
```bash
271-
cd frontend
272270
pnpm install
273-
NEXT_PUBLIC_API_BASE_URL=https://api.example.com pnpm build
271+
NEXT_PUBLIC_API_BASE_URL=https://api.example.com pnpm --filter @deeix/web build
274272
```
275273

276274
The static output is `frontend/out`. Serve it with Nginx, CDN, object storage, or any static web server. To let the Go backend serve the frontend, place `frontend/out` under `server.frontend_dist_dir`; the Docker image defaults to `/app/frontend/out`.

README.zh-CN.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,21 @@ cp config.example.yaml config.yaml
130130

131131
根据本机环境调整 `config.yaml` 中的 `database.postgres.dsn``database.redis.*` 和公开访问地址。
132132

133-
2. 启动后端
133+
2. 安装工作区依赖并准备前端环境
134134

135135
```bash
136-
cd backend
137-
make run
136+
pnpm install
137+
cp frontend/.env.example frontend/.env.local
138138
```
139139

140-
3. 启动前端
140+
3. 同时启动前端和后端
141141

142142
```bash
143-
cd frontend
144-
pnpm install
145-
cp .env.example .env.local
146143
pnpm dev
147144
```
148145

146+
只启动单个工作区时,使用 `pnpm dev:web``pnpm dev:api`
147+
149148
前端请求后端使用 `NEXT_PUBLIC_API_BASE_URL`。本地开发时确认 `frontend/.env.local` 中包含:
150149

151150
```env
@@ -268,9 +267,8 @@ docker compose -f docker/docling/docker-compose.yml up -d --build
268267
2. 构建并发布前端。
269268

270269
```bash
271-
cd frontend
272270
pnpm install
273-
NEXT_PUBLIC_API_BASE_URL=https://api.example.com pnpm build
271+
NEXT_PUBLIC_API_BASE_URL=https://api.example.com pnpm --filter @deeix/web build
274272
```
275273

276274
静态产物在 `frontend/out`,可由 Nginx、CDN、对象存储或任意静态服务托管。如需由 Go 后端托管前端,把 `frontend/out` 放到 `server.frontend_dist_dir` 指向的目录;Docker 镜像默认是 `/app/frontend/out`

backend/docs/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18601,4 +18601,4 @@
1860118601
"in": "header"
1860218602
}
1860318603
}
18604-
}
18604+
}

backend/docs/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5468,7 +5468,7 @@ info:
54685468
contact: {}
54695469
description: DEEIX Chat 后端 API 文档
54705470
title: DEEIX Chat API
5471-
version: 0.3.2
5471+
version: "0.3.2"
54725472
paths:
54735473
/admin/announcements:
54745474
get:

backend/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@deeix/api",
3+
"version": "0.3.2",
4+
"private": true,
5+
"scripts": {
6+
"build": "make build",
7+
"check": "make check-version && go vet ./...",
8+
"clean": "rm -rf ../.cache/deeix-chat",
9+
"dev": "make run",
10+
"test": "make test"
11+
}
12+
}

0 commit comments

Comments
 (0)