Skip to content

Commit c52e678

Browse files
authored
Enhancements/pnpm-to-bun-migration (#199)
- Replaced @vitejs/plugin-react-swc with @vitejs/plugin-react for improved compatibility. - Updated package.json to use the latest version of rolldown-vite and added overrides for Vite. - Adjusted build scripts in package.json to utilize bun for consistency across packages. - Ensured Vite configuration files reflect the changes in plugin imports for both admin and client packages.
2 parents dde4c9f + 93eb074 commit c52e678

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1261
-18028
lines changed

.cursor/rules/deployment.mdc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,40 @@ This rule covers Green Goods contract deployment workflows, ensuring safe and co
1414

1515
### When to Deploy (New Addresses)
1616

17-
Use `pnpm deploy:*` when:
17+
Use `bun deploy:*` when:
1818
- Setting up a new network
1919
- First-time deployment
2020
- Testing locally or on fork
2121
- Want completely fresh state
2222

2323
**Commands:**
2424
```bash
25-
pnpm deploy:local # Anvil localhost
26-
pnpm deploy:testnet # Base Sepolia
27-
pnpm deploy:celo # Celo mainnet
28-
pnpm deploy:arbitrum # Arbitrum mainnet
25+
bun deploy:local # Anvil localhost
26+
bun deploy:testnet # Base Sepolia
27+
bun deploy:celo # Celo mainnet
28+
bun deploy:arbitrum # Arbitrum mainnet
2929
```
3030

3131
### When to Upgrade (Same Addresses)
3232

33-
Use `pnpm upgrade:*` when:
33+
Use `bun upgrade:*` when:
3434
- Fixing bugs in production contracts
3535
- Adding features to existing contracts
3636
- Maintaining addresses for existing integrations
3737
- Upgrading UUPS proxies
3838

3939
**Commands:**
4040
```bash
41-
pnpm upgrade:testnet
42-
pnpm upgrade:celo
43-
pnpm upgrade:arbitrum
41+
bun upgrade:testnet
42+
bun upgrade:celo
43+
bun upgrade:arbitrum
4444
```
4545

4646
## MANDATORY: Use deploy.js Wrapper
4747

4848
**✅ ALWAYS:**
4949
```bash
50-
pnpm deploy:testnet
50+
bun deploy:testnet
5151
node script/deploy.js core --network baseSepolia --broadcast
5252
```
5353

@@ -141,7 +141,7 @@ const profiles = {
141141
node script/deploy.js core --network celo --profile production --broadcast
142142

143143
# Default profile (production for mainnet, testing for testnet)
144-
pnpm deploy:celo
144+
bun deploy:celo
145145
```
146146

147147
## Deployment Artifacts
@@ -196,8 +196,8 @@ const workSchemaUID = deployment.schemas.workSchemaUID;
196196

197197
Before running `--broadcast`:
198198

199-
- [ ] Tests passing: `pnpm --filter contracts test`
200-
- [ ] Code formatted: `pnpm --filter contracts format`
199+
- [ ] Tests passing: `bun --filter contracts test`
200+
- [ ] Code formatted: `bun --filter contracts format`
201201
- [ ] Gas analyzed: `forge test --gas-report`
202202
- [ ] Dry run successful: `node script/deploy.js core --network <net>`
203203
- [ ] Deployer funded: `cast balance $ADDRESS --rpc-url $RPC`
@@ -233,8 +233,8 @@ cast call $EAS "getSchema(bytes32)" $SCHEMA_UID --rpc-url $RPC
233233
# Check deployment artifact for verification URLs
234234

235235
# Update dependent packages
236-
cd packages/indexer && pnpm codegen
237-
cd packages/client && pnpm build
236+
cd packages/indexer && bun codegen
237+
cd packages/client && bun build
238238
```
239239

240240
## Deployment Troubleshooting

.cursor/rules/environment.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ To support multiple chains:
337337

338338
```bash
339339
# Example: Deploy client for Celo
340-
VITE_CHAIN_ID=42220 pnpm --filter client build
340+
VITE_CHAIN_ID=42220 bun --filter client build
341341
# Deploy to celo.greengoods.app
342342

343343
# Deploy client for Arbitrum
344-
VITE_CHAIN_ID=42161 pnpm --filter client build
344+
VITE_CHAIN_ID=42161 bun --filter client build
345345
# Deploy to arbitrum.greengoods.app
346346
```
347347

.cursor/rules/monorepo.mdc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ alwaysApply: true
66

77
# Monorepo Structure & Conventions
88

9-
Green Goods is a pnpm monorepo with 4 packages. This rule provides guidance on cross-package patterns and when to share vs duplicate code.
9+
Green Goods is a bun monorepo with 4 packages. This rule provides guidance on cross-package patterns and when to share vs duplicate code.
1010

1111
## Package Architecture
1212

@@ -66,15 +66,15 @@ import { SomeComponent } from '../../admin/src/components/Foo';
6666

6767
```bash
6868
# Run in specific package
69-
pnpm --filter client dev
70-
pnpm --filter contracts test
69+
bun --filter client dev
70+
bun --filter contracts test
7171

7272
# Run in all packages
73-
pnpm -r test
74-
pnpm -r build
73+
bun -r test
74+
bun -r build
7575

7676
# From package directory
77-
cd packages/client && pnpm dev
77+
cd packages/client && bun dev
7878
```
7979

8080
### Package Scripts
@@ -92,13 +92,13 @@ Each package has consistent npm scripts:
9292

9393
```bash
9494
# Add to specific package
95-
pnpm --filter client add viem
95+
bun --filter client add viem
9696

9797
# Add to root (workspace tools)
98-
pnpm add -w -D vitest
98+
bun add -w -D vitest
9999

100100
# Add to all packages
101-
pnpm -r add lodash
101+
bun -r add lodash
102102
```
103103

104104
### Version Alignment
@@ -112,7 +112,7 @@ Keep these dependencies aligned across client/admin:
112112

113113
**Check alignment:**
114114
```bash
115-
pnpm list react --depth=0 -r
115+
bun list react --depth=0 -r
116116
```
117117

118118
## Testing Across Packages
@@ -148,10 +148,10 @@ Packages have build dependencies:
148148

149149
**Build all in order:**
150150
```bash
151-
pnpm build
151+
bun build
152152
```
153153

154-
pnpm handles dependency graph automatically.
154+
bun handles dependency graph automatically.
155155

156156
## Code Ownership
157157

@@ -244,10 +244,10 @@ import { useRole } from '../../admin/src/hooks/useRole';
244244

245245
```bash
246246
# Wrong
247-
cd packages/client && pnpm build # Might fail if contracts not built
247+
cd packages/client && bun build # Might fail if contracts not built
248248

249249
# Correct
250-
pnpm build # From root, handles order
250+
bun build # From root, handles order
251251
```
252252

253253
## MCP Integration for Monorepo
@@ -284,7 +284,7 @@ When moving logic between packages:
284284
- [ ] Update both package tests
285285
- [ ] Update relevant README files
286286
- [ ] Check for duplicate type definitions
287-
- [ ] Validate build still works with `pnpm build`
287+
- [ ] Validate build still works with `bun build`
288288

289289
## Reference Documents
290290

.cursor/rules/quality.mdc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Green Goods maintains high code quality through automated tooling, comprehensive
2121
**Usage:**
2222
```bash
2323
# Format all files
24-
pnpm format
24+
bun format
2525

2626
# Format specific package
27-
pnpm --filter client format
27+
bun --filter client format
2828

2929
# Auto-format on save (VS Code)
3030
# Already configured in .vscode/settings.json
@@ -46,10 +46,10 @@ pnpm --filter client format
4646
**Usage:**
4747
```bash
4848
# Lint client
49-
pnpm --filter client lint
49+
bun --filter client lint
5050

5151
# Lint all packages
52-
pnpm lint
52+
bun lint
5353
```
5454

5555
**What it catches:**
@@ -62,10 +62,10 @@ pnpm lint
6262

6363
```bash
6464
# Pre-commit hook runs automatically
65-
pnpm format && pnpm lint
65+
bun format && bun lint
6666

6767
# Manual quality check
68-
pnpm format && pnpm lint && pnpm test
68+
bun format && bun lint && bun test
6969
```
7070

7171
## Conventional Commits
@@ -315,7 +315,7 @@ modules/job-queue/
315315

316316
```bash
317317
# Run Solhint
318-
pnpm --filter contracts lint
318+
bun --filter contracts lint
319319

320320
# Auto-format Solidity
321321
forge fmt
@@ -428,7 +428,7 @@ Monitor with Lighthouse/PageSpeed:
428428

429429
Automated quality checks on PR:
430430
```yaml
431-
1. Install dependencies (pnpm)
431+
1. Install dependencies (bun)
432432
2. Format check (Biome)
433433
3. Lint (0xlint + Biome)
434434
4. Type check (tsc)
@@ -474,10 +474,10 @@ Use MCP tools for quality workflows:
474474

475475
Before pushing code:
476476

477-
- [ ] `pnpm format` (auto-formatted)
478-
- [ ] `pnpm lint` (no errors)
479-
- [ ] `pnpm test` (relevant tests pass)
480-
- [ ] `pnpm build` (builds successfully)
477+
- [ ] `bun format` (auto-formatted)
478+
- [ ] `bun lint` (no errors)
479+
- [ ] `bun test` (relevant tests pass)
480+
- [ ] `bun build` (builds successfully)
481481
- [ ] Conventional commit message
482482
- [ ] Updated documentation
483483
- [ ] Added tests for new features

.github/workflows/admin-tests.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ jobs:
2222
with:
2323
node-version: '20'
2424

25-
- name: Setup pnpm
26-
uses: pnpm/action-setup@v4
25+
- name: Setup Bun
26+
uses: oven-sh/setup-bun@v2
2727
with:
28-
version: 8
28+
bun-version: latest
2929

3030
- name: Install dependencies
31-
run: pnpm install --frozen-lockfile
31+
run: bun install --frozen-lockfile
3232

3333
- name: Run unit tests
3434
run: |
3535
cd packages/admin
36-
pnpm test:unit
36+
bun run test:unit
3737
env:
3838
CI: true
3939

4040
- name: Generate coverage report
4141
run: |
4242
cd packages/admin
43-
pnpm test:coverage
43+
bun run test:coverage
4444
env:
4545
CI: true
4646

@@ -62,21 +62,21 @@ jobs:
6262
with:
6363
node-version: '20'
6464

65-
- name: Setup pnpm
66-
uses: pnpm/action-setup@v4
65+
- name: Setup Bun
66+
uses: oven-sh/setup-bun@v2
6767
with:
68-
version: 8
68+
bun-version: latest
6969

7070
- name: Install Foundry
7171
uses: foundry-rs/foundry-toolchain@v1
7272

7373
- name: Install dependencies
74-
run: pnpm install --frozen-lockfile
74+
run: bun install --frozen-lockfile
7575

7676
- name: Run integration tests
7777
run: |
7878
cd packages/admin
79-
pnpm test:integration
79+
bun run test:integration
8080
env:
8181
CI: true
8282
VITEST_INTEGRATION: true
@@ -94,20 +94,23 @@ jobs:
9494
with:
9595
node-version: '20'
9696

97-
- name: Setup pnpm
98-
uses: pnpm/action-setup@v4
97+
- name: Setup Bun
98+
uses: oven-sh/setup-bun@v2
9999
with:
100-
version: 8
100+
bun-version: latest
101101

102102
- name: Install dependencies
103-
run: pnpm install --frozen-lockfile
103+
run: bun install --frozen-lockfile
104104

105105
- name: Run linting
106106
run: |
107107
cd packages/admin
108-
pnpm lint
108+
bun run lint
109109
110110
- name: Check formatting
111+
run: bun run format:check
112+
113+
- name: Type check and build
111114
run: |
112115
cd packages/admin
113-
pnpm format --check
116+
bun run build

.husky/pre-commit

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,12 @@ export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
77
# Try to use project Node version (22) silently; ignore errors if nvm is missing
88
nvm use --silent 22 >/dev/null 2>&1 || true
99

10-
# Ensure pnpm is available (via corepack if needed)
11-
if ! command -v pnpm >/dev/null 2>&1; then
12-
if command -v corepack >/dev/null 2>&1; then
13-
corepack enable >/dev/null 2>&1 || true
14-
corepack prepare pnpm@latest --activate >/dev/null 2>&1 || true
15-
fi
16-
fi
17-
18-
# Run lint-staged using pnpm if present, otherwise fall back to npx
19-
if command -v pnpm >/dev/null 2>&1; then
20-
pnpm lint-staged
10+
# Try bun first, fall back to npm
11+
if command -v bun >/dev/null 2>&1; then
12+
bunx lint-staged
13+
elif command -v npm >/dev/null 2>&1; then
14+
npx lint-staged
2115
else
22-
npx --no-install lint-staged
16+
echo "Error: Neither bun nor npm found. Install bun: https://bun.sh"
17+
exit 1
2318
fi
24-

.husky/pre-push

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
echo "🔍 Running format check and linting before push..."
44

5-
# Run format check first
6-
npx pnpm format:check
5+
# Try bun first, fall back to npm
6+
if command -v bun >/dev/null 2>&1; then
7+
bun run format:check
8+
bun run lint
9+
elif command -v npm >/dev/null 2>&1; then
10+
npm run format:check
11+
npm run lint
12+
else
13+
echo "Error: Neither bun nor npm found. Install bun: https://bun.sh"
14+
exit 1
15+
fi
716

8-
# Run linting
9-
npx pnpm lint
10-
11-
echo "✅ Pre-push checks passed!"
17+
echo "✅ Pre-push checks passed!"

0 commit comments

Comments
 (0)