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

View file

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

View file

@ -28,8 +28,8 @@ git checkout -b <BRANCH_NAME>
5. Start the development environment. 5. Start the development environment.
```bash ```bash
pnpm install bun install
pnpm dev bun dev
``` ```
6. Make your changes. 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", "Brhm",
"Briel", "Briel",
"bryan", "bryan",
"bunx",
"canoa", "canoa",
"Canoa", "Canoa",
"cfasync", "cfasync",
@ -87,7 +88,7 @@
"*.bundle.js", "*.bundle.js",
"package-lock.json", "package-lock.json",
"yarn.lock", "yarn.lock",
"pnpm-lock.yaml" "bun.lock"
], ],
"allowCompoundWords": true, "allowCompoundWords": true,
"dictionaries": ["typescript", "node", "html", "css", "bash", "npm", "es-es"], "dictionaries": ["typescript", "node", "html", "css", "bash", "npm", "es-es"],

View file

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

View file

@ -3,9 +3,9 @@
"type": "module", "type": "module",
"version": "0.0.1", "version": "0.0.1",
"engines": { "engines": {
"pnpm": "^10.0.0" "bun": "^1.0.0"
}, },
"packageManager": "pnpm@10.12.1", "packageManager": "bun@1.2.16",
"scripts": { "scripts": {
"dev": "astro dev --port 3000", "dev": "astro dev --port 3000",
"start": "astro preview --port 3000", "start": "astro preview --port 3000",
@ -22,6 +22,7 @@
"test": "vitest run", "test": "vitest run",
"test:coverage": "vitest --coverage", "test:coverage": "vitest --coverage",
"test:playwright": "playwright test --reporter=list", "test:playwright": "playwright test --reporter=list",
"test:e2e": "turbo run test:playwright",
"prepare": "lefthook install" "prepare": "lefthook install"
}, },
"dependencies": { "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": ".", "baseUrl": ".",
"paths": { "paths": {
"~/*": ["./src/*"] "~/*": ["./src/*"]
}, }
"types": ["@vitest/browser/providers/playwright"]
}, },
"suppressImplicitAnyIndexErrors": true "suppressImplicitAnyIndexErrors": true
} }

View file

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