Skip to content

Commit fb2a023

Browse files
authored
🔧 Migrate from npm to Bun (#2097)
1 parent ab7c28c commit fb2a023

File tree

13 files changed

+989
-6815
lines changed

13 files changed

+989
-6815
lines changed

.github/workflows/generate-client.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ jobs:
2020
with:
2121
ref: ${{ github.head_ref }}
2222
token: ${{ secrets.FULL_STACK_FASTAPI_TEMPLATE_REPO_TOKEN }}
23-
- uses: actions/setup-node@v6
24-
with:
25-
node-version: lts/*
23+
- uses: oven-sh/setup-bun@v2
2624
- uses: actions/setup-python@v6
2725
with:
2826
python-version: "3.10"
@@ -32,7 +30,7 @@ jobs:
3230
version: "0.4.15"
3331
enable-cache: true
3432
- name: Install dependencies
35-
run: npm ci
33+
run: bun ci
3634
- run: uv sync
3735
working-directory: backend
3836
- run: uv run bash scripts/generate-client.sh

.github/workflows/playwright.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ jobs:
4848
fail-fast: false
4949
steps:
5050
- uses: actions/checkout@v6
51-
- uses: actions/setup-node@v6
52-
with:
53-
node-version: lts/*
51+
- uses: oven-sh/setup-bun@v2
5452
- uses: actions/setup-python@v6
5553
with:
5654
python-version: '3.10'
@@ -66,15 +64,15 @@ jobs:
6664
enable-cache: true
6765
- run: uv sync
6866
working-directory: backend
69-
- run: npm ci
67+
- run: bun ci
7068
working-directory: frontend
7169
- run: uv run bash scripts/generate-client.sh
7270
env:
7371
VIRTUAL_ENV: backend/.venv
7472
- run: docker compose build
7573
- run: docker compose down -v --remove-orphans
7674
- name: Run Playwright tests
77-
run: docker compose run --rm playwright npx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
75+
run: docker compose run --rm playwright bunx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
7876
- run: docker compose down -v --remove-orphans
7977
- name: Upload blob report to GitHub Actions Artifacts
8078
if: ${{ !cancelled() }}
@@ -94,19 +92,17 @@ jobs:
9492
runs-on: ubuntu-latest
9593
steps:
9694
- uses: actions/checkout@v6
97-
- uses: actions/setup-node@v6
98-
with:
99-
node-version: 20
95+
- uses: oven-sh/setup-bun@v2
10096
- name: Install dependencies
101-
run: npm ci
97+
run: bun ci
10298
- name: Download blob reports from GitHub Actions Artifacts
10399
uses: actions/download-artifact@v7
104100
with:
105101
path: frontend/all-blob-reports
106102
pattern: blob-report-*
107103
merge-multiple: true
108104
- name: Merge into HTML Report
109-
run: npx playwright merge-reports --reporter html ./all-blob-reports
105+
run: bunx playwright merge-reports --reporter html ./all-blob-reports
110106
working-directory: frontend
111107
- name: Upload HTML report
112108
uses: actions/upload-artifact@v6

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ jobs:
3737
# To be able to commit it needs the head branch of the PR, the remote one
3838
ref: ${{ github.event.pull_request.head.sha }}
3939
fetch-depth: 0
40-
- uses: actions/setup-node@v6
41-
with:
42-
node-version: lts/*
40+
- uses: oven-sh/setup-bun@v2
4341
- name: Set up Python
4442
uses: actions/setup-python@v6
4543
with:
@@ -54,7 +52,7 @@ jobs:
5452
- name: Install backend dependencies
5553
run: uv sync --all-packages
5654
- name: Install frontend dependencies
57-
run: npm ci
55+
run: bun ci
5856
- name: Run prek - pre-commit
5957
id: precommit
6058
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure

.nvmrc

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

bun.lock

Lines changed: 933 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ docker compose stop frontend
6363
And then start the local frontend development server:
6464

6565
```bash
66-
npm run dev
66+
bun run dev
6767
```
6868

6969
Or you could stop the `backend` Docker Compose service:

docker-compose.override.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ services:
9898
ports:
9999
- "5173:80"
100100
build:
101-
context: ./frontend
101+
context: .
102+
dockerfile: frontend/Dockerfile
102103
args:
103104
- VITE_API_URL=http://localhost:8000
104105
- NODE_ENV=development
105106

106107
playwright:
107108
build:
108-
context: ./frontend
109-
dockerfile: Dockerfile.playwright
109+
context: .
110+
dockerfile: frontend/Dockerfile.playwright
110111
args:
111112
- VITE_API_URL=http://backend:8000
112113
- NODE_ENV=production
@@ -123,8 +124,8 @@ services:
123124
- PLAYWRIGHT_HTML_HOST=0.0.0.0
124125
- CI=${CI}
125126
volumes:
126-
- ./frontend/blob-report:/app/blob-report
127-
- ./frontend/test-results:/app/test-results
127+
- ./frontend/blob-report:/app/frontend/blob-report
128+
- ./frontend/test-results:/app/frontend/test-results
128129
ports:
129130
- 9323:9323
130131

frontend/Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
2-
FROM node:24 AS build-stage
1+
# Stage 0, "build-stage", based on Bun, to build and compile the frontend
2+
FROM oven/bun:1 AS build-stage
33

44
WORKDIR /app
55

6-
COPY package*.json /app/
6+
COPY package.json bun.lock /app/
77

8-
RUN npm install
8+
COPY frontend/package.json /app/frontend/
99

10-
COPY ./ /app/
10+
WORKDIR /app/frontend
1111

12-
ARG VITE_API_URL=${VITE_API_URL}
12+
RUN bun install
1313

14-
RUN npm run build
14+
COPY ./frontend /app/frontend
15+
ARG VITE_API_URL
16+
17+
RUN bun run build
1518

1619

1720
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
1821
FROM nginx:1
1922

20-
COPY --from=build-stage /app/dist/ /usr/share/nginx/html
23+
COPY --from=build-stage /app/frontend/dist/ /usr/share/nginx/html
2124

22-
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
23-
COPY ./nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf
25+
COPY ./frontend/nginx.conf /etc/nginx/conf.d/default.conf
26+
COPY ./frontend/nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf

frontend/Dockerfile.playwright

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ FROM mcr.microsoft.com/playwright:v1.57.0-noble
22

33
WORKDIR /app
44

5-
COPY package*.json /app/
5+
RUN apt-get update && apt-get install -y unzip \
6+
&& rm -rf /var/lib/apt/lists/*
67

7-
RUN npm install
8+
RUN curl -fsSL https://bun.sh/install | bash
9+
ENV PATH="/root/.bun/bin:$PATH"
810

9-
COPY ./ /app/
11+
COPY package.json bun.lock /app/
1012

11-
ARG VITE_API_URL=${VITE_API_URL}
13+
COPY frontend/package.json /app/frontend/
14+
15+
WORKDIR /app/frontend
16+
17+
RUN bun install
18+
19+
COPY ./frontend /app/frontend
20+
21+
ARG VITE_API_URL

frontend/README.md

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,15 @@
22

33
The frontend is built with [Vite](https://vitejs.dev/), [React](https://reactjs.org/), [TypeScript](https://www.typescriptlang.org/), [TanStack Query](https://tanstack.com/query), [TanStack Router](https://tanstack.com/router) and [Tailwind CSS](https://tailwindcss.com/).
44

5-
## Frontend development
5+
## Requirements
66

7-
Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed on your system.
7+
- [Bun](https://bun.sh/) (recommended) or [Node.js](https://nodejs.org/)
88

9-
* To install fnm follow the [official fnm guide](https://github.com/Schniz/fnm#installation). If you prefer nvm, you can install it using the [official nvm guide](https://github.com/nvm-sh/nvm#installing-and-updating).
10-
11-
* After installing either nvm or fnm, proceed to the `frontend` directory:
12-
13-
```bash
14-
# If using fnm
15-
fnm install
16-
17-
# If using nvm
18-
nvm install
19-
```
20-
21-
* Once the installation is complete, switch to the installed version:
22-
23-
```bash
24-
# If using fnm
25-
fnm use
26-
27-
# If using nvm
28-
nvm use
29-
```
30-
31-
* Within the `frontend` directory, install the necessary NPM packages:
32-
33-
```bash
34-
npm install
35-
```
36-
37-
* And start the live server with the following `npm` script:
9+
## Quick Start
3810

3911
```bash
40-
npm run dev
12+
bun install
13+
bun run dev
4114
```
4215

4316
* Then open your browser at http://localhost:5173/.
@@ -89,7 +62,7 @@ But it would be only to clean them up, leaving them won't really have any effect
8962
* To generate the frontend client, run:
9063

9164
```bash
92-
npm run generate-client
65+
bun run generate-client
9366
```
9467

9568
* Commit the changes.
@@ -128,13 +101,13 @@ docker compose up -d --wait backend
128101
Then, you can run the tests with the following command:
129102

130103
```bash
131-
npx playwright test
104+
bunx playwright test
132105
```
133106

134107
You can also run your tests in UI mode to see the browser and interact with it running:
135108

136109
```bash
137-
npx playwright test --ui
110+
bunx playwright test --ui
138111
```
139112

140113
To stop and remove the Docker Compose stack and clean the data created in tests, use the following command:

0 commit comments

Comments
 (0)