Skip to content

Commit

Permalink
feat: migrate to using bun (noodle-run#348)
Browse files Browse the repository at this point in the history
* feat: initial migration to bun

* feat: update bun lockfile and replace pnpm with bun everywhere else

* chore: update lock file

* ci: remove volta

* lint: fix lint error

* feat: forgot to update bug report form

* feat: completes the bun migration

---------

Co-authored-by: Ahmed Elsakaan <[email protected]>
  • Loading branch information
xhayper and ixahmedxi authored Nov 3, 2023
1 parent 6b4f249 commit 7d5d82e
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 9,849 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ If applicable, add screenshots to help explain your problem.

**Information (please complete the following information):**

- Node version [e.g. 18.17.0]
- Pnpm version [e.g. 8.9.2]
- Bun version [e.g. 1.0.8]

**Additional context**
Add any other context about the problem here.
18 changes: 6 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ env:
UPSTASH_REDIS_REST_URL: ${{secrets.UPSTASH_REDIS_REST_URL}}
UPSTASH_REDIS_REST_TOKEN: ${{secrets.UPSTASH_REDIS_REST_TOKEN}}

# Volta
VOLTA_FEATURE_PNPM: 1

jobs:
main:
name: CI
Expand All @@ -38,20 +35,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Volta
uses: volta-cli/action@v4

- name: Install Node & pnpm
run: volta install node && volta install pnpm
- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: pnpm install
run: bun install

- name: Check format
run: pnpm format:check
run: bun run format:check

- name: Check lint
run: pnpm lint
run: bun run lint

- name: Build
run: pnpm build
run: bun run build
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
.next
bun.lockb
pnpm-lock.yaml
migrations
59 changes: 26 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ In this guide, you will get an overview of the project structure and setup, as w
- [The tech stack](#the-tech-stack)
- [Getting stuff running](#getting-stuff-running)
- [Cloning the repo](#cloning-the-repo)
- [Volta](#volta)
- [Bun](#bun)
- [Installing dependencies](#installing-dependencies)
- [Environment Variables](#environment-variables)
- [Configuring your Database](#configuring-your-database)
- [Configuring Clerk](#configuring-clerk)
- [Configuring Upstash](#configuring-upstash)
- [Installing dependencies](#installing-dependencies)
- [Running stuff](#running-stuff)
- [Closing notes](#closing-notes)

Expand Down Expand Up @@ -69,10 +69,9 @@ If you would like to be more involved in the development of Noodle, we would lik

## The tech stack

The Environment:
The Runtime:

- [NodeJS](https://nodejs.org/en)
- [Pnpm](https://pnpm.io/)
- [Bun](https://bun.sh/)

The Tech Stack:

Expand Down Expand Up @@ -112,36 +111,31 @@ To clone the repo, you firstly need to [fork](https://github.com/noodle-run/nood
git clone https://github.com/<your-gh-username>/noodle.git
```

### Volta

To get the project running locally, it is advised that you have [Volta](https://volta.sh/) installed on your system. This allows you to have the exact same versions of [NodeJS](https://nodejs.org/en) and [Pnpm](https://pnpm.io/) as we do, further lowering the chances of you getting errors that we don't get.
### Bun

There are ways to do this using other tools such as NVM, but we take Noodle as an initiative to move people to arguably better tools such as Volta.
Bun is used as the package manager of Noodle, with Bun, you actually don't need to have NodeJS installed at all on your system to be able to run Noodle. The only tool you need to install dependencies & run Noodle is Bun!

Volta's pnpm support is currently experimental, and so you need to do the following to let it manage your Pnpm version:
To install bun, head over to [their website](https://bun.sh/) which will tell you how to get it installed on your system.

In your `.bashrc` or `.zshrc` file, add the following line:
To check that you have Bun installed, simply run the following command:

```bash
export VOLTA_FEATURE_PNPM=1
bun --version
```

With this out of the way, you should have the correct version of Nodejs and Pnpm once you change directory into Noodle's project folder. You can test this out as such:
If this commands outputs a version number, you're all good to go.

```bash
# cd into noodle
cd /path/to/noodle
### Installing dependencies

# output node and pnpm versions
node --version
pnpm --version
```
With bun installed on your machine, the next step would be to install the dependencies that Noodle relies upon to work, to do this, run the following command:

And make sure that the version is the same as the one defined in the root `package.json` file in the `volta` section.
```bash
bun install
```

### Environment Variables

Now that Volta has been installed locally on your system, it's time to configure your environment variables so that the project works as expected:
Now that Bun & dependencies has been installed, it's time to configure your environment variables so that the project works as expected:

1. Duplicate the `.env.example` file as just `.env`

Expand Down Expand Up @@ -188,27 +182,26 @@ And now you got Auth!

And that's all for the redis part!

### Installing dependencies

To install the dependencies needed to run Noodle, you need to run `pnpm install`, this will install all of the packages that we use. After this is done, you are ready to run Noodle locally!

### Running stuff

```bash
# Run the project's dev server
pnpm dev
bun dev

# Build the project
pnpm build
bun run build

# Run the built project in production mode
pnpm start
bun start

# Run the typecheck script
bun typecheck

# Lint
pnpm lint
# Lint using ESLint
bun lint

# Format
pnpm format:write
# Format using Prettier
bun format
```

## Closing notes
Expand Down
Binary file added bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "dotenv/config";
import type { Config } from "drizzle-kit";
import { env } from "./src/env.mjs";

Expand Down
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"author": "NOODLE RUN LTD",
"private": true,
"scripts": {
"dev": "pnpm db:migrate && next dev",
"build": "pnpm db:migrate && next build",
"postinstall": "cd ./node_modules/better-sqlite3 && bun run install && cd ../../",
"dev": "bun run db:migrate && bun run next dev",
"build": "bun run db:migrate && bun run next build",
"start": "next start",
"lint": "next lint --fix",
"format": "prettier --write .",
Expand All @@ -16,7 +17,7 @@
"db:generate": "drizzle-kit generate:sqlite",
"db:push": "drizzle-kit push:sqlite",
"db:studio": "drizzle-kit studio",
"db:migrate": "tsx ./scripts/run-migrations.ts"
"db:migrate": "bun ./scripts/run-migrations.ts"
},
"dependencies": {
"@clerk/nextjs": "^4.25.6",
Expand Down Expand Up @@ -64,6 +65,7 @@
"@upstash/redis": "^1.23.4",
"@vercel/analytics": "^1.1.1",
"autoprefixer": "10.4.16",
"better-sqlite3": "^9.0.0",
"bufferutil": "^4.0.8",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
Expand Down Expand Up @@ -106,14 +108,8 @@
"@types/eslint": "^8.44.6",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.19.13",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.6",
"tsx": "^3.14.0"
},
"volta": {
"node": "20.9.0",
"pnpm": "8.10.0"
"prettier-plugin-tailwindcss": "^0.5.6"
}
}
Loading

0 comments on commit 7d5d82e

Please sign in to comment.