feat: migrate to bun (#443)

This commit is contained in:
nizzy
2025-03-14 14:41:55 -04:00
committed by GitHub
parent f73d8ab47e
commit 8b139d8c84
14 changed files with 2308 additions and 10408 deletions

View File

@@ -44,7 +44,7 @@ RUN . $NVM_DIR/nvm.sh && \
nvm install --lts && \
nvm use --lts && \
nvm alias default 'lts/*' && \
npm install -g yarn pnpm
npm install -g bun
# Register Nvm in bashrc and zshrc
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc

View File

@@ -4,15 +4,20 @@ Thank you for your interest in contributing to 0.email! We're excited to have yo
## Table of Contents
- [Getting Started](#getting-started)
- [Development Workflow](#development-workflow)
- [Database Management](#database-management)
- [Coding Guidelines](#coding-guidelines)
- [Testing](#testing)
- [Documentation](#documentation)
- [Areas of Contribution](#areas-of-contribution)
- [Community](#community)
- [Questions or Need Help?](#questions-or-need-help)
- [Contributing to 0.email](#contributing-to-0email)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Development Workflow](#development-workflow)
- [Database Management](#database-management)
- [Coding Guidelines](#coding-guidelines)
- [General Principles](#general-principles)
- [JavaScript/TypeScript Guidelines](#javascripttypescript-guidelines)
- [React Guidelines](#react-guidelines)
- [Testing](#testing)
- [Documentation](#documentation)
- [Areas of Contribution](#areas-of-contribution)
- [Community](#community)
- [Questions or Need Help?](#questions-or-need-help)
## Getting Started
@@ -21,14 +26,13 @@ Thank you for your interest in contributing to 0.email! We're excited to have yo
- Clone your fork locally: `git clone https://github.com/YOUR-USERNAME/Zero.git`
2. **Set Up Development Environment**
- Install [Node.js](https://nodejs.org/en/download) (v18 or higher)
- Install pnpm: `npm install -g pnpm`
- Install dependencies: `pnpm install`
- Start the database locally: `pnpm docker:up`
- Install [Bun](https://bun.sh)
- Clone the repository and install dependencies: `bun install`
- Start the database locally: `bun docker:up`
- Copy `.env.example` to `.env` in both `apps/mail` and `packages/db` folders
- Set up your Google OAuth credentials (see [README.md](../README.md))
- Install database dependencies: `pnpm db:dependencies`
- Initialize the database: `pnpm db:push`
- Install database dependencies: `bun db:dependencies`
- Initialize the database: `bun db:push`
## Development Workflow
@@ -36,10 +40,10 @@ Thank you for your interest in contributing to 0.email! We're excited to have yo
```bash
# Start database locally
pnpm docker:up
bun docker:up
# Start the development server
pnpm dev
bun dev
```
2. **Create a New Branch**
@@ -63,8 +67,8 @@ Thank you for your interest in contributing to 0.email! We're excited to have yo
- Make sure the app runs without errors
- Test your feature thoroughly
- Run linting: `pnpm lint`
- Format code: `pnpm format`
- Run linting: `bun lint`
- Format code: `bun format`
5. **Commit Your Changes**
@@ -110,19 +114,19 @@ Zero uses PostgreSQL with Drizzle ORM. Here's how to work with it:
```bash
# Install database dependencies
pnpm db:dependencies
bun db:dependencies
# Apply schema changes to development database
pnpm db:push
bun db:push
# Create migration files after schema changes
pnpm db:generate
bun db:generate
# Apply migrations (for production)
pnpm db:migrate
bun db:migrate
# View and edit data with Drizzle Studio
pnpm db:studio
bun db:studio
```
3. **Database Connection**

View File

@@ -22,17 +22,13 @@ jobs:
- name: Checkout Code 🛎
uses: actions/checkout@v4
- name: Setup pnpm 📦
uses: pnpm/action-setup@v3
- name: Setup Node.js 🟩
uses: actions/setup-node@v4
- name: Setup Bun 🌟
uses: oven-sh/setup-bun@v1
with:
cache: "pnpm"
node-version: "22"
bun-version: latest
- name: Install Dependencies 📦
run: pnpm install
run: bun install
- name: Check 🚨
run: pnpm format
run: bun format

2
.gitignore vendored
View File

@@ -31,7 +31,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
bun-debug.log*
# env files (can opt-in for committing if needed)
.env

View File

@@ -1 +1 @@
pnpm lint-staged
bun lint-staged

View File

@@ -1,3 +1,3 @@
pnpm-lock.yaml
bun.lockb
node_modules
.next

View File

@@ -42,7 +42,7 @@ Zero is built with modern and reliable technologies:
**Required Versions:**
- [Node.js](https://nodejs.org/en/download) (v18 or higher)
- [pnpm](https://pnpm.io/installation) (v8 or higher)
- [Bun](https://bun.sh) (v1.0 or higher)
- [Docker](https://docs.docker.com/engine/install/) (v20 or higher)
Before running the application, you'll need to set up services and configure environment variables. For more details on environment variables, see the [Environment Variables](#environment-variables) section.
@@ -64,13 +64,13 @@ You can set up Zero in two ways:
cd Zero
# Install dependencies
pnpm install
bun install
# Install database dependencies
pnpm db:dependencies
bun db:dependencies
# Start database locally
pnpm docker:up
bun docker:up
```
2. **Set Up Environment**
@@ -80,13 +80,13 @@ You can set up Zero in two ways:
cp apps/mail/.env.example apps/mail/.env && cp packages/db/.env.example packages/db/.env
```
- Configure your environment variables (see below)
- Install database dependencies: `pnpm db:dependencies`
- Initialize the database: `pnpm db:push`
- Install database dependencies: `bun db:dependencies`
- Initialize the database: `bun db:push`
3. **Start the App**
```bash
pnpm dev
bun dev
```
4. **Open in Browser**
@@ -118,8 +118,8 @@ This option uses VS Code's Dev Containers feature to provide a fully configured
- For dependency issues inside the container:
```bash
rm -rf node_modules
rm pnpm-lock.yaml
pnpm install
rm bun.lockb
bun install
```
</details>
@@ -210,7 +210,7 @@ REDIS_URL= # Redis URL for caching (http://localhost:8079 for local
REDIS_TOKEN= # Redis token (upstash-local-token for local dev)
```
To be able to run `pnpm db:push` and push the schemas to the database you also have to add a `.env` file to the `packages/db` folder (so `packages/db/.env`) with the following content:
To be able to run `bun db:push` and push the schemas to the database you also have to add a `.env` file to the `packages/db` folder (so `packages/db/.env`) with the following content:
```env
DATABASE_URL= # Required: PostgreSQL connection string for migrations
@@ -228,7 +228,7 @@ Zero uses PostgreSQL for storing data. Here's how to set it up:
Run this command to start a local PostgreSQL instance:
```bash
pnpm docker:up
bun docker:up
```
This creates a database with:
@@ -252,27 +252,27 @@ Zero uses PostgreSQL for storing data. Here's how to set it up:
- **Install database dependencies**:
```bash
pnpm db:dependencies
bun db:dependencies
```
- **Set up database tables**:
```bash
pnpm db:push
bun db:push
```
- **Create migration files** (after schema changes):
```bash
pnpm db:generate
bun db:generate
```
- **Apply migrations**:
```bash
pnpm db:migrate
bun db:migrate
```
- **View database content**:
```bash
pnpm db:studio
bun db:studio
```
## Contribute

View File

@@ -29,7 +29,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
bun-debug.log*
# env files (can opt-in for committing if needed)
.env

2236
bun.lock Normal file

File diff suppressed because it is too large Load Diff

3
bunfig.toml Normal file
View File

@@ -0,0 +1,3 @@
[install]
# Configure workspaces for monorepo
workspaces = ["apps/*", "packages/*"]

View File

@@ -2,24 +2,25 @@
"name": "zero",
"version": "0.1.0",
"private": true,
"packageManager": "bun@1.2.5",
"scripts": {
"dev": "turbo run dev",
"build": "turbo run build",
"start": "turbo run start",
"lint": "next lint",
"lint": "turbo run lint",
"format": "prettier --write .",
"check": "pnpm run check:format && pnpm run lint",
"check": "bun run check:format && bun run lint",
"check:format": "prettier . --check",
"prepare": "husky",
"lint-staged": "prettier --write --ignore-unknown",
"docker:up": "docker-compose up -d",
"docker:down": "docker-compose down",
"docker:clean": "docker-compose down -v",
"db:dependencies": "cd packages/db && pnpm install",
"db:generate": "cd packages/db && pnpm run db:generate",
"db:migrate": "cd packages/db && pnpm run db:migrate",
"db:push": "cd packages/db && pnpm run db:push",
"db:studio": "cd packages/db && pnpm run db:studio"
"db:dependencies": "cd packages/db && bun install",
"db:generate": "cd packages/db && bun run db:generate",
"db:migrate": "cd packages/db && bun run db:migrate",
"db:push": "cd packages/db && bun run db:push",
"db:studio": "cd packages/db && bun run db:studio"
},
"devDependencies": {
"@types/node": "22.13.8",
@@ -31,12 +32,10 @@
"turbo": "2.4.4",
"typescript": "5.8.2"
},
"pnpm": {
"onlyBuiltDependencies": [
"sharp"
]
},
"packageManager": "pnpm@10.2.0",
"workspaces": [
"apps/*",
"packages/*"
],
"dependencies": {
"@tiptap/extension-link": "^2.11.5",
"@tiptap/pm": "2.11.5",

10338
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
packages:
- "apps/*"
- "packages/*"

View File

@@ -27,6 +27,9 @@
},
"start": {
"cache": false
},
"lint": {
"outputs": []
}
}
}