Skip to content

Commit d5b0102

Browse files
committed
chore: switch to bun package manager
1 parent 38206e7 commit d5b0102

17 files changed

+129
-149
lines changed

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
# Node.js
77
node_modules
8+
bun.lockb
89
npm-debug.log
910
yarn-debug.log
1011
yarn-error.log
11-
pnpm-debug.log
1212

1313
# Build outputs
1414
dist
@@ -62,4 +62,3 @@ logs
6262
# Cache
6363
.cache
6464
.npm
65-
.pnpm-store

.github/workflows/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ This workflow runs on all branches and pull requests. It:
2424
- On push to any branch (except changes to README.md and docs)
2525
- On pull requests to any branch (except changes to README.md and docs)
2626

27-
**Key features:**
28-
- Uses pnpm for faster dependency installation
27+
- Uses Bun for dependency installation
2928
- Caches dependencies to speed up builds
3029
- Uploads build artifacts for 7 days
3130

.github/workflows/astro-build-test.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,20 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24-
- name: Install pnpm
25-
uses: pnpm/action-setup@v3
24+
- name: Setup Bun
25+
uses: oven-sh/setup-bun@v1
2626
with:
27-
version: 10
28-
run_install: false
29-
30-
- name: Setup Node.js
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version: 'lts/*'
34-
cache: 'pnpm'
27+
bun-version: '1.2.9'
28+
cache: true
3529

3630
- name: Install dependencies
37-
run: pnpm install
31+
run: bun install
3832

3933
- name: Run tests
40-
run: pnpm test
34+
run: bunx vitest run
4135

4236
- name: Build Astro project
43-
run: pnpm build
37+
run: bunx astro build
4438

4539
- name: Upload build artifacts
4640
uses: actions/upload-artifact@v4

.github/workflows/docker-scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ on:
77
- 'Dockerfile'
88
- '.dockerignore'
99
- 'package.json'
10-
- 'pnpm-lock.yaml'
10+
- 'bun.lockb'
1111
pull_request:
1212
branches: [ main ]
1313
paths:
1414
- 'Dockerfile'
1515
- '.dockerignore'
1616
- 'package.json'
17-
- 'pnpm-lock.yaml'
17+
- 'bun.lockb'
1818
schedule:
1919
- cron: '0 0 * * 0' # Run weekly on Sunday at midnight
2020

README.md

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
```bash
1919
docker compose --profile production up -d
2020
# or
21-
pnpm setup && pnpm dev
21+
bun run setup && bun run dev
2222
```
2323

2424
<p align="center">
@@ -63,9 +63,9 @@ Easily configure your GitHub and Gitea connections, set up automatic mirroring s
6363

6464
See the [Quick Start Guide](docs/quickstart.md) for detailed instructions on getting up and running quickly.
6565

66-
### Prerequisites
66+
-### Prerequisites
6767

68-
- Node.js 22 or later
68+
- Bun 1.2.9 or later
6969
- A GitHub account with a personal access token
7070
- A Gitea instance with an access token
7171

@@ -92,7 +92,7 @@ Before running the application in production mode for the first time, you need t
9292

9393
```bash
9494
# Initialize the database for production mode
95-
pnpm setup
95+
bun run setup
9696
```
9797

9898
This will create the necessary tables. On first launch, you'll be guided through creating your admin account with a secure password.
@@ -110,7 +110,7 @@ Gitea Mirror provides multi-architecture Docker images that work on both ARM64 (
110110
docker compose --profile production up -d
111111

112112
# For development mode (requires configuration)
113-
# Ensure you have run pnpm setup first
113+
# Ensure you have run bun run setup first
114114
docker compose -f docker-compose.dev.yml up -d
115115
```
116116

@@ -206,40 +206,40 @@ git clone https://github.com/arunavo4/gitea-mirror.git
206206
cd gitea-mirror
207207

208208
# Quick setup (installs dependencies and initializes the database)
209-
pnpm setup
209+
bun run setup
210210

211211
# Development Mode Options
212212

213213
# Run in development mode
214-
pnpm dev
214+
bun run dev
215215

216216
# Run in development mode with clean database (removes existing DB first)
217-
pnpm dev:clean
217+
bun run dev:clean
218218

219219
# Production Mode Options
220220

221221
# Build the application
222-
pnpm build
222+
bun run build
223223

224224
# Preview the production build
225-
pnpm preview
225+
bun run preview
226226

227227
# Start the production server (default)
228-
pnpm start
228+
bun run start
229229

230230
# Start the production server with a clean setup
231-
pnpm start:fresh
231+
bun run start:fresh
232232

233233
# Database Management
234234

235235
# Initialize the database
236-
pnpm init-db
236+
bun run init-db
237237

238238
# Reset users for testing first-time signup
239-
pnpm reset-users
239+
bun run reset-users
240240

241241
# Check database status
242-
pnpm check-db
242+
bun run check-db
243243
```
244244

245245
### Configuration
@@ -262,10 +262,10 @@ Key configuration options include:
262262

263263
```bash
264264
# Install dependencies
265-
pnpm setup
265+
bun run setup
266266

267267
# Start the development server
268-
pnpm dev
268+
bun run dev
269269
```
270270

271271

@@ -359,7 +359,7 @@ docker compose -f docker-compose.dev.yml up -d
359359
## Technologies Used
360360
361361
- **Frontend**: Astro, React, Shadcn UI, Tailwind CSS v4
362-
- **Backend**: Node.js
362+
- **Backend**: Bun
363363
- **Database**: SQLite (default) or PostgreSQL
364364
- **Caching/Queue**: Redis
365365
- **API Integration**: GitHub API (Octokit), Gitea API
@@ -467,33 +467,19 @@ Try the following steps:
467467
> For better Redis connection handling, you can modify the `src/lib/redis.ts` file to include retry logic and better error handling:
468468
469469
```typescript
470-
import Redis from "ioredis";
470+
import { RedisClient } from "bun";
471471
472472
// Connect to Redis using REDIS_URL environment variable or default to redis://redis:6379
473-
const redisUrl = process.env.REDIS_URL ?? 'redis://redis:6379';
473+
const redisUrl = process.env.REDIS_URL ?? "redis://redis:6379";
474474
475475
console.log(`Connecting to Redis at: ${redisUrl}`);
476476
477-
// Configure Redis client with connection options
478-
const redisOptions = {
479-
retryStrategy: (times) => {
480-
// Retry with exponential backoff up to 30 seconds
481-
const delay = Math.min(times * 100, 3000);
482-
console.log(`Redis connection attempt ${times} failed. Retrying in ${delay}ms...`);
483-
return delay;
484-
},
485-
maxRetriesPerRequest: 5,
486-
enableReadyCheck: true,
487-
connectTimeout: 10000,
488-
};
489-
490-
export const redis = new Redis(redisUrl, redisOptions);
491-
export const redisPublisher = new Redis(redisUrl, redisOptions);
492-
export const redisSubscriber = new Redis(redisUrl, redisOptions);
477+
const redis = new RedisClient(redisUrl, { autoReconnect: true });
493478
494-
// Log connection events
495-
redis.on('connect', () => console.log('Redis client connected'));
496-
redis.on('error', (err) => console.error('Redis client error:', err));
479+
redis.onconnect = () => console.log("Redis client connected");
480+
redis.onclose = err => {
481+
if (err) console.error("Redis client error:", err);
482+
};
497483
```
498484
499485

docker-entrypoint.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ set -e
55
# Ensure data directory exists
66
mkdir -p /app/data
77

8-
# If pnpm is available, run setup (for dev images), else run node init directly
9-
if command -v pnpm >/dev/null 2>&1; then
10-
echo "Running pnpm setup (if needed)..."
11-
pnpm setup || true
8+
# If bun is available, run setup (for dev images)
9+
if command -v bun >/dev/null 2>&1; then
10+
echo "Running bun setup (if needed)..."
11+
bun run setup || true
1212
fi
1313

1414
# Initialize the database if it doesn't exist
1515
if [ ! -f "/app/data/gitea-mirror.db" ]; then
1616
echo "Initializing database..."
1717
if [ -f "dist/scripts/init-db.js" ]; then
18-
node dist/scripts/init-db.js
18+
bun dist/scripts/init-db.js
1919
elif [ -f "dist/scripts/manage-db.js" ]; then
20-
node dist/scripts/manage-db.js init
20+
bun dist/scripts/manage-db.js init
2121
else
2222
echo "Warning: Could not find database initialization scripts in dist/scripts."
2323
echo "Creating and initializing database manually..."
@@ -119,9 +119,9 @@ EOF
119119
else
120120
echo "Database already exists, checking for issues..."
121121
if [ -f "dist/scripts/fix-db-issues.js" ]; then
122-
node dist/scripts/fix-db-issues.js
122+
bun dist/scripts/fix-db-issues.js
123123
elif [ -f "dist/scripts/manage-db.js" ]; then
124-
node dist/scripts/manage-db.js fix
124+
bun dist/scripts/manage-db.js fix
125125
fi
126126

127127
# Since the application is not used by anyone yet, we've removed the schema updates and migrations
@@ -130,4 +130,4 @@ fi
130130

131131
# Start the application
132132
echo "Starting Gitea Mirror..."
133-
exec node ./dist/server/entry.mjs
133+
exec bun ./dist/server/entry.mjs

package.json

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,30 @@
33
"type": "module",
44
"version": "1.0.0",
55
"engines": {
6-
"node": ">=22.0.0"
6+
"bun": ">=1.2.9"
77
},
88
"scripts": {
9-
"setup": "pnpm install && pnpm manage-db init",
10-
"dev": "astro dev",
11-
"dev:clean": "pnpm cleanup-db && pnpm manage-db init && astro dev",
12-
"build": "astro build",
9+
"setup": "bun install && bun run manage-db init",
10+
"dev": "bunx astro dev",
11+
"dev:clean": "bun run cleanup-db && bun run manage-db init && bunx astro dev",
12+
"build": "bunx astro build",
1313
"cleanup-db": "rm -f gitea-mirror.db data/gitea-mirror.db",
14-
"manage-db": "tsx scripts/manage-db.ts",
15-
"init-db": "tsx scripts/manage-db.ts init",
16-
"check-db": "tsx scripts/manage-db.ts check",
17-
"fix-db": "tsx scripts/manage-db.ts fix",
18-
"reset-users": "tsx scripts/manage-db.ts reset-users",
19-
"preview": "astro preview",
20-
"start": "node dist/server/entry.mjs",
21-
"start:fresh": "pnpm cleanup-db && pnpm manage-db init && node dist/server/entry.mjs",
22-
"test": "vitest run",
23-
"test:watch": "vitest",
24-
"astro": "astro"
14+
"manage-db": "bun scripts/manage-db.ts",
15+
"init-db": "bun scripts/manage-db.ts init",
16+
"check-db": "bun scripts/manage-db.ts check",
17+
"fix-db": "bun scripts/manage-db.ts fix",
18+
"reset-users": "bun scripts/manage-db.ts reset-users",
19+
"preview": "bunx astro preview",
20+
"start": "bun dist/server/entry.mjs",
21+
"start:fresh": "bun run cleanup-db && bun run manage-db init && bun dist/server/entry.mjs",
22+
"test": "bunx vitest run",
23+
"test:watch": "bunx vitest",
24+
"astro": "bunx astro"
2525
},
2626
"dependencies": {
2727
"@astrojs/mdx": "^4.2.6",
2828
"@astrojs/node": "^9.2.1",
2929
"@astrojs/react": "^4.2.7",
30-
"@libsql/client": "^0.15.4",
3130
"@octokit/rest": "^21.1.1",
3231
"@radix-ui/react-avatar": "^1.1.4",
3332
"@radix-ui/react-checkbox": "^1.1.5",
@@ -54,7 +53,6 @@
5453
"cmdk": "^1.1.1",
5554
"drizzle-orm": "^0.41.0",
5655
"fuse.js": "^7.1.0",
57-
"ioredis": "^5.6.1",
5856
"jsonwebtoken": "^9.0.2",
5957
"lucide-react": "^0.488.0",
6058
"next-themes": "^0.4.6",
@@ -73,15 +71,13 @@
7371
"@testing-library/jest-dom": "^6.6.3",
7472
"@testing-library/react": "^16.3.0",
7573
"@types/bcryptjs": "^3.0.0",
76-
"@types/better-sqlite3": "^7.6.13",
7774
"@types/jsonwebtoken": "^9.0.9",
7875
"@types/superagent": "^8.1.9",
7976
"@types/uuid": "^10.0.0",
8077
"@vitejs/plugin-react": "^4.4.0",
81-
"better-sqlite3": "^9.6.0",
8278
"jsdom": "^26.1.0",
8379
"tsx": "^4.19.3",
8480
"vitest": "^3.1.1"
8581
},
86-
"packageManager": "pnpm@10.10.0"
82+
"packageManager": "bun@1.2.9"
8783
}

scripts/README-docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The script uses environment variables from the `.env` file in the project root:
4343
3. Using with docker-compose:
4444
```bash
4545
# Ensure dependencies are installed and database is initialized
46-
pnpm setup
46+
bun run setup
4747

4848
# First build the image
4949
./scripts/build-docker.sh --load

0 commit comments

Comments
 (0)