Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): migrate from bun to pnpm #453

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ runs:
using: 'composite'
steps:
- name: Setup node env 🏗
uses: oven-sh/setup-bun@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: 'Cache Dependencies 🕓'
uses: 'actions/cache@v4'
id: cache-node-modules
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: 'node_modules'
key: deps-node-modules-${{ hashFiles('**/bun.lockb') }}
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install Dependencies 👨🏻‍💻
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: bun install
run: pnpm install --no-frozen-lockfile
shell: bash
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: ./.github/actions/setup

- name: Build Application 🧱
run: bun run build
run: pnpm run build

lint:
name: 'Lint 🐱'
Expand All @@ -38,7 +38,7 @@ jobs:
uses: ./.github/actions/setup

- name: Lint 🐱
run: bun run lint
run: pnpm run lint

test:
name: 'Test 🧪'
Expand All @@ -53,7 +53,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run unit tests 🧪
run: bun run test:coverage
run: pnpm run test:coverage

- name: Collect coverage
uses: codecov/codecov-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bun run commitlint --edit $1
pnpm commitlint --edit $1
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bun run lint-staged
pnpm lint-staged
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"tsconfig.json": "tsconfig.*.json",
"Dockerfile": "docker-compose.yml, .dockerignore",
".env": "*.env",
"package.json": "yarn.lock, .nvmrc, .yarnrc.yml, bun.lockb",
"package.json": "yarn.lock, .nvmrc, .yarnrc.yml, pnpm-lock.yaml",
".eslintrc.*": ".eslintignore, .eslintcache",
".prettierrc": ".prettierignore",
".gitignore": ".gitattributes"
Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM imbios/bun-node:latest-20.12.2-debian as development
FROM node:20.12.2-debian as development

WORKDIR /usr/src/app

COPY package.json ./
COPY bun.lockb ./
COPY pnpm-lock.yaml ./

RUN bun install
RUN pnpm install

COPY . .

RUN bun run build
RUN pnpm run build

FROM imbios/bun-node:latest-20.12.2-debian as production
FROM node:20.12.2-debian as production

ARG NODE_ENV=production
ARG EnvironmentVariable
Expand All @@ -20,9 +20,9 @@ ENV NODE_ENV=${NODE_ENV}
WORKDIR /usr/src/app

COPY package.json ./
COPY bun.lockb ./
COPY pnpm-lock.yaml ./

RUN bun install --production --ignore-scripts
RUN pnpm install --production --ignore-scripts
RUN npm install pm2 -g

COPY . .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ when you have registered on **rigtch.fm**.

![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
![NodeJS](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)
![Bun](https://img.shields.io/badge/Bun-%23000000.svg?style=for-the-badge&logo=bun&logoColor=white)
![Pnpm](https://img.shields.io/badge/pnpm-F69220?style=for-the-badge&logo=pnpm&logoColor=white)
![NestJS](https://img.shields.io/badge/nestjs-%23E0234E.svg?style=for-the-badge&logo=nestjs&logoColor=white)
![Postgres](https://img.shields.io/badge/postgres-%23316192.svg?style=for-the-badge&logo=postgresql&logoColor=white)
![Redis](https://img.shields.io/badge/redis-%23DD0031.svg?style=for-the-badge&logo=redis&logoColor=white)
Expand Down
Binary file removed bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: Dockerfile
target: development
command: bun run start:dev
command: pnpm run start:dev
ports:
- ${PORT}:${PORT}
env_file:
Expand Down
8 changes: 4 additions & 4 deletions docs/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ Make sure that you have the right version of Node.js installed in nvm.
nvm use
```

Make sure you have bun installed globally.
Make sure you have pnpm installed globally.

```bash
#Linux & macOS
curl -fsSL https://bun.sh/install | bash
curl -fsSL https://get.pnpm.io/install.sh | sh -

#Windows
powershell -c "irm bun.sh/install.ps1 | iex"
npm install -g pnpm
```

I'm suggesting to install
[@antfu/ni](https://www.npmjs.com/package/@antfu/ni/v/0.13.1) globally:

```bash
bun add -g @antfu/ni
pnpm add -g @antfu/ni
```

Don't forget to install the dependencies:
Expand Down
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"license": "Apache License 2.0",
"engines": {
"node": ">=20.0.0",
"npm": "please-use-bun",
"yarn": "please-use-bun",
"bun": ">=1.1.0"
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"bun": "please-use-pnpm",
"pnpm": ">=9"
},
"packageManager": "pnpm@9.14.2",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
Expand All @@ -28,11 +30,11 @@
"test:ui": "vitest --ui",
"test:coverage": "vitest run --coverage",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli",
"schema:sync": "bun run typeorm schema:sync -d ./dist/config/database/typeorm.config.js",
"migration:run": "bun run typeorm migration:run -d ./dist/config/database/typeorm.config.js",
"migration:generate": "bun run typeorm migration:generate -d ./dist/config/database/typeorm.config.js ./src/migrations/$NAME",
"migration:create": "bun run typeorm migration:create ./src/migrations/$NAME",
"migration:revert": "bun run typeorm migration:revert -d ./src/config/database/typeorm.config.ts",
"schema:sync": "pnpm run typeorm schema:sync -d ./dist/config/database/typeorm.config.js",
"migration:run": "pnpm run typeorm migration:run -d ./dist/config/database/typeorm.config.js",
"migration:generate": "pnpm run typeorm migration:generate -d ./dist/config/database/typeorm.config.js ./src/migrations/$NAME",
"migration:create": "pnpm run typeorm migration:create ./src/migrations/$NAME",
"migration:revert": "pnpm run typeorm migration:revert -d ./src/config/database/typeorm.config.ts",
"prepare": "husky",
"commit": "cz"
},
Expand Down Expand Up @@ -111,6 +113,7 @@
"husky": "^9.0.11",
"lint-staged": "^15.2.0",
"prettier": "^3.2.4",
"rimraf": "^6.0.1",
"source-map-support": "^0.5.21",
"tsconfig-paths": "4.2.0",
"typescript": "^5.3.3",
Expand Down
Loading
Loading