feat(bun): migrate package manager from pnpm to bun

- Replace pnpm-lock.yaml and pnpm-workspace.yaml with bun.lock
- Add bunfig.toml for bun configuration
- Update CI pipeline to use bun commands
- Update lefthook.yaml, tsconfig.json, and turbo.json for bun compatibility
- Update package.json dependencies and scripts
- Update CONTRIBUTING.md documentation
- Add GitHub Actions for bun setup with caching

BREAKING CHANGE: Project now requires bun instead of pnpm for development
This commit is contained in:
taroj1205 2025-06-22 15:16:10 +12:00
parent f9395041e1
commit 17fbba2251
No known key found for this signature in database
GPG key ID: 0FCB6CFFE0981AB7
13 changed files with 2691 additions and 10820 deletions

View file

@ -0,0 +1,46 @@
name: "Setup Bun with Cache"
description: "Setup Bun, restore caches, and install dependencies"
inputs:
cache-suffix:
description: 'Suffix for the cache key (e.g., "build", "playwright")'
required: true
enable-astro-cache:
description: "Whether to enable Astro cache restoration"
required: false
default: "false"
bun-version:
description: "Bun version to install"
required: false
default: "latest"
runs:
using: "composite"
steps:
- name: Restore Turborepo Cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ inputs.cache-suffix }}-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-turbo-${{ inputs.cache-suffix }}-
${{ runner.os }}-turbo-
- name: Restore Astro Cache
if: inputs.enable-astro-cache == 'true'
uses: actions/cache@v4
with:
path: |
.astro
node_modules/.astro
key: ${{ runner.os }}-astro-${{ hashFiles('**/bun.lock') }}
restore-keys: ${{ runner.os }}-astro-
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ inputs.bun-version }}
- name: Install dependencies
shell: bash
run: bun install --frozen-lockfile

View file

@ -16,57 +16,42 @@ jobs:
contents: read
outputs:
exists: ${{ steps.filter.outputs.exists }}
env:
CI_IGNORE: |
*.md
.gitignore
.gitattributes
.vscode/**
steps:
- uses: actions/checkout@v4
- name: Filter changes
uses: yumemi-inc/path-filter@v2
id: filter
with:
patterns: |
**
!**.md
!.gitignore
!.gitattributes
!.vscode/**
!.env.example
fetch-depth: 2
setup:
name: Setup Dependencies
needs: check_changes
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if node_modules cache exists
id: check-node-modules-cache
uses: actions/cache@v4
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
lookup-only: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup pnpm
if: steps.check-node-modules-cache.outputs.cache-hit != 'true'
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install dependencies
if: steps.check-node-modules-cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
- id: filter
shell: bash
run: |
# Determine the commit to diff against (push vs PR)
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi
# List changed files between BASE_SHA and current HEAD
CHANGED=$(git diff --name-only "$BASE_SHA" "$GITHUB_SHA")
# Identify ignored files based on CI_IGNORE patterns
IGNORED=$(echo "$CHANGED" | git check-ignore --stdin --exclude-from=<(printf '%s\n' "$CI_IGNORE") || true)
# Remove ignored files from the changed list
FILTERED=$(comm -23 <(echo "$CHANGED" | sort) <(echo "$IGNORED" | sort))
# Output result for downstream jobs
if [[ -z "$FILTERED" ]]; then
echo "exists=false" >> "$GITHUB_OUTPUT"
else
echo "exists=true" >> "$GITHUB_OUTPUT"
fi
quality_checks:
name: ${{ matrix.name }}
needs: [check_changes, setup]
needs: [check_changes]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
strategy:
@ -85,43 +70,34 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Restore Turborepo Cache
uses: actions/cache@v4
- name: Setup Bun with Cache
uses: ./.github/actions/setup-bun-with-cache
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ matrix.check }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-turbo-${{ matrix.check }}-
- name: Restore node_modules cache
id: cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-node-modules-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
cache-suffix: ${{ matrix.check }}
- name: Run ${{ matrix.name }}
run: pnpm exec turbo run ${{ matrix.check }}
run: bunx turbo run ${{ matrix.check }}
build:
name: Build
needs: [check_changes]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun with Cache
uses: ./.github/actions/setup-bun-with-cache
with:
cache-suffix: build
enable-astro-cache: "true"
- name: Run Build
run: bunx turbo run build
playwright:
name: Playwright Tests
needs: [check_changes, setup]
needs: [check_changes, build]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
steps:
@ -129,49 +105,23 @@ jobs:
with:
fetch-depth: 0
- name: Restore Turborepo Cache
uses: actions/cache@v4
- name: Setup Bun with Cache
uses: ./.github/actions/setup-bun-with-cache
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: ${{ runner.os }}-turbo-
- name: Restore node_modules cache
id: cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-node-modules-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
cache-suffix: playwright
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-playwright-${{ hashFiles('**/bun.lock') }}
restore-keys: ${{ runner.os }}-playwright-
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
run: bunx playwright install --with-deps
- name: Run Playwright Tests
run: pnpm exec turbo run test:playwright
run: bunx turbo run test:playwright
timeout-minutes: 10
verify:

View file

@ -17,7 +17,7 @@ test-results/
# Package files
package-lock.json
yarn.lock
pnpm-lock.yaml
bun.lock
# Config files that should maintain their format
wrangler.toml

View file

@ -28,8 +28,8 @@ git checkout -b <BRANCH_NAME>
5. Start the development environment.
```bash
pnpm install
pnpm dev
bun install
bun dev
```
6. Make your changes.

2562
bun.lock Normal file

File diff suppressed because it is too large Load diff

7
bunfig.toml Normal file
View file

@ -0,0 +1,7 @@
[install.scopes]
# Only built dependencies
"@esbuild" = { "trustedDependencies" = ["esbuild"] }
"@lefthook" = { "trustedDependencies" = ["lefthook"] }
"@sharp" = { "trustedDependencies" = ["sharp"] }
"@unrs-resolver" = { "trustedDependencies" = ["unrs-resolver"] }
"@workerd" = { "trustedDependencies" = ["workerd"] }

View file

@ -11,6 +11,7 @@
"Brhm",
"Briel",
"bryan",
"bunx",
"canoa",
"Canoa",
"cfasync",
@ -87,7 +88,7 @@
"*.bundle.js",
"package-lock.json",
"yarn.lock",
"pnpm-lock.yaml"
"bun.lock"
],
"allowCompoundWords": true,
"dictionaries": ["typescript", "node", "html", "css", "bash", "npm", "es-es"],

View file

@ -5,18 +5,18 @@ pre-commit:
priority: 1
glob: "*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,d.ts,md,mdx,yaml,yml,json,html,css,astro}"
run: |
pnpm prettier {staged_files} --write --list-different
bun prettier {staged_files} --write --list-different
stage_fixed: true
eslint:
priority: 2
run: |
pnpm lefthook run eslint
bun lefthook run eslint
cspell:
priority: 3
run: |
pnpm lefthook run cspell
bun lefthook run cspell
eslint:
commands:
@ -28,7 +28,7 @@ eslint:
- playwright-report/**
- test-results/**
run: |
pnpm eslint {staged_files} --max-warnings=0 --fix --cache
bun eslint {staged_files} --max-warnings=0 --fix --cache
stage_fixed: true
cspell:
@ -36,17 +36,17 @@ cspell:
base:
glob: "*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,d.ts,astro,json,yaml,yml,md,mdx}"
run: |
pnpm cspell {staged_files}
bun cspell {staged_files}
stage_fixed: true
commit-msg:
commands:
commitlint:
run: |
pnpm commitlint --edit {1}
bun commitlint --edit {1}
post-merge:
commands:
pnpm:
glob: "{package.json,pnpm-lock.yaml}"
run: pnpm install
bun:
glob: "{package.json,bun.lock}"
run: bun install

View file

@ -3,9 +3,9 @@
"type": "module",
"version": "0.0.1",
"engines": {
"pnpm": "^10.0.0"
"bun": "^1.0.0"
},
"packageManager": "pnpm@10.12.1",
"packageManager": "bun@1.2.16",
"scripts": {
"dev": "astro dev --port 3000",
"start": "astro preview --port 3000",
@ -22,6 +22,7 @@
"test": "vitest run",
"test:coverage": "vitest --coverage",
"test:playwright": "playwright test --reporter=list",
"test:e2e": "turbo run test:playwright",
"prepare": "lefthook install"
},
"dependencies": {

10690
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +0,0 @@
onlyBuiltDependencies:
- esbuild
- lefthook
- sharp
- unrs-resolver
- workerd

View file

@ -6,8 +6,7 @@
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
},
"types": ["@vitest/browser/providers/playwright"]
}
},
"suppressImplicitAnyIndexErrors": true
}

View file

@ -18,6 +18,7 @@
},
"build": {
"cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro,json,yml,yaml}"],
"outputs": ["dist/**"]
},
"test": {