Skip to content
Merged
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
11 changes: 5 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: Setup
description: Install Bun and dependencies
description: Install Node.js, pnpm and dependencies

runs:
using: composite
steps:
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.23
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'

- name: Install dependencies
shell: bash
run: bun install
run: pnpm install --frozen-lockfile
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: ./.github/actions/setup

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

eslint:
name: ESLint
Expand All @@ -47,13 +47,13 @@ jobs:
uses: ./.github/actions/setup

- name: Build MDX
run: bun build:mdx
run: pnpm build:mdx

- name: Generate Next.js route types
run: bun typegen
run: pnpm typegen

- name: Run ESLint
run: bun lint
run: pnpm lint

types:
name: TypeScript
Expand All @@ -66,13 +66,13 @@ jobs:
uses: ./.github/actions/setup

- name: Build MDX
run: bun build:mdx
run: pnpm build:mdx

- name: Generate Next.js route types
run: bun typegen
run: pnpm typegen

- name: Run type check
run: bun type-check
run: pnpm type-check

prettier:
name: Prettier
Expand All @@ -85,7 +85,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run Prettier format check
run: bun format:check
run: pnpm format:check

spelling:
name: Spelling
Expand All @@ -98,7 +98,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run spelling check
run: bun check:spelling
run: pnpm check:spelling

knip:
name: Knip
Expand All @@ -111,10 +111,10 @@ jobs:
uses: ./.github/actions/setup

- name: Build MDX
run: bun build:mdx
run: pnpm build:mdx

- name: Run Knip
run: bun check:knip
run: pnpm check:knip

i18n:
name: i18n
Expand All @@ -127,7 +127,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run i18n check
run: bun check:i18n
run: pnpm check:i18n

e2e:
name: End-to-end tests
Expand All @@ -141,7 +141,7 @@ jobs:
uses: ./.github/actions/setup

- name: Install Playwright with dependencies
run: bun playwright install --with-deps chromium --only-shell
run: pnpm playwright install --with-deps chromium --only-shell

- name: Create test posts and copy dummy images
run: |
Expand Down Expand Up @@ -200,19 +200,19 @@ jobs:
done

- name: Build apps
run: bun build:apps
run: pnpm build:apps

- name: Run services
run: docker compose up -d

- name: Migrate database
run: bun db:migrate
run: pnpm db:migrate

- name: Seed database
run: bun db:seed
run: pnpm db:seed

- name: Run Playwright tests
run: bun test:e2e
run: pnpm test:e2e

- name: Upload Playwright report
if: always()
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
engine-strict=true
save-exact=true
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v24.6.0
v22.20.0
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"configurations": [
{
"command": "bun dev",
"command": "pnpm dev",
"name": "Next.js: debug server-side",
"request": "launch",
"type": "node-terminal"
Expand All @@ -13,7 +13,7 @@
"url": "http://localhost:3000"
},
{
"command": "bun dev",
"command": "pnpm dev",
"name": "Next.js: debug full stack",
"request": "launch",
"serverReadyAction": {
Expand Down
54 changes: 27 additions & 27 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ nelsonlai-dev/
- API: oRPC for type-safe APIs
- Email: React Email for transactional emails
- Testing: Playwright for E2E, Vitest for unit tests
- Package Manager: Bun
- Package Manager: pnpm
- Monorepo: Turborepo

### Content Management
Expand Down Expand Up @@ -130,10 +130,10 @@ export default Component

```bash
# Run E2E tests
bun test:e2e
pnpm test:e2e

# Run unit tests
bun test:unit
pnpm test:unit
```

### Test File Conventions
Expand Down Expand Up @@ -169,8 +169,8 @@ test('page loads correctly', async ({ page }) => {
When modifying database schema:

1. Edit schema files in `packages/db/src/schemas/`
2. Generate migration: `bun db:generate`
3. Apply migration: `bun db:migrate`
2. Generate migration: `pnpm db:generate`
3. Apply migration: `pnpm db:migrate`
4. Update types if needed

## API Development (oRPC)
Expand Down Expand Up @@ -252,8 +252,8 @@ Available scopes:

Before submitting:

1. Run `bun check` (includes lint, type-check, format)
2. Run `bun test:unit && bun test:e2e` for affected packages
1. Run `pnpm check` (includes lint, type-check, format)
2. Run `pnpm test:unit && pnpm test:e2e` for affected packages
3. Add/update tests for new features
4. Ensure no console errors
5. Test on mobile viewport
Expand All @@ -265,36 +265,36 @@ Before submitting:

```bash
# Install dependencies
bun install
pnpm install

# Development
bun dev # Run all apps and packages
bun dev:web # Run web app only
pnpm dev # Run all apps and packages
pnpm dev:web # Run web app only

# Building
bun run build # Build all apps and packages
bun build:apps # Build all apps
bun build:mdx # Build MDX content
pnpm build # Build all apps and packages
pnpm build:apps # Build all apps
pnpm build:mdx # Build MDX content

# Quality Checks
bun lint # Run ESLint
bun lint:fix # Fix ESLint issues
bun format:check # Check Prettier formatting
bun format:fix # Fix formatting
bun type-check # Run TypeScript checks
bun check:knip # Check for unused stuff
bun check:spelling # Check spelling
bun check # Run all checks
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
pnpm format:check # Check Prettier formatting
pnpm format:fix # Fix formatting
pnpm type-check # Run TypeScript checks
pnpm check:knip # Check for unused stuff
pnpm check:spelling # Check spelling
pnpm check # Run all checks

# Database
bun db:generate # Generate migrations
bun db:migrate # Apply migrations
bun db:seed # Seed database
bun db:studio # Open Drizzle Studio
pnpm db:generate # Generate migrations
pnpm db:migrate # Apply migrations
pnpm db:seed # Seed database
pnpm db:studio # Open Drizzle Studio

# Testing
bun test:e2e # Run E2E tests
bun test:unit # Run unit tests
pnpm test:e2e # Run E2E tests
pnpm test:unit # Run unit tests
```

## Common Patterns
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Welcome to the monorepo of my personal blog! This repository houses the code for
### Prerequisites

- Node.js
- Bun
- pnpm
- Docker
- [Visual Studio Code](https://code.visualstudio.com/) with [recommended extensions](.vscode/extensions.json)
- Optionally [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
Expand All @@ -113,10 +113,10 @@ git clone https://github.com/nelsonlaidev/nelsonlai.dev
cd nelsonlai.dev
```

3. Install dependencies using Bun:
3. Install dependencies using pnpm:

```bash
bun install
pnpm install
```

### Environment Setup
Expand All @@ -136,23 +136,23 @@ docker compose up -d
3. Run the database migrations:

```bash
bun db:migrate
pnpm db:migrate
```

4. Seed the database:

```bash
bun db:seed
pnpm db:seed
```

5. Run the app:

```bash
bun dev # Run all services
pnpm dev # Run all services
# or
bun dev:web # Run only the web app
pnpm dev:web # Run only the web app
# or
bun dev:docs # Run only the documentation app
pnpm dev:docs # Run only the documentation app
```

The services will be available at the following URLs:
Expand Down
18 changes: 9 additions & 9 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
"author": "Nelson Lai <[email protected]> (https://github.com/nelsonlaidev/)",
"type": "module",
"scripts": {
"analyze": "cross-env ANALYZE=true bun with-env next build",
"build": "bun with-env next build --turbo",
"analyze": "cross-env ANALYZE=true pnpm with-env next build",
"build": "pnpm with-env next build --turbo",
"build:mdx": "content-collections build",
"clean": "rm -rf .next .turbo .content-collections test-results playwright-report",
"dev": "bun with-env next dev --turbopack -p 3000",
"dev": "pnpm with-env next dev --turbopack -p 3000",
"lint": "eslint . --max-warnings 0",
"lint:fix": "eslint --fix .",
"start": "bun with-env next start -p 3000",
"test:e2e": "bun with-env playwright test",
"test:e2e:inspector": "bun with-env playwright test $1 --debug",
"test:e2e:ui": "bun with-env playwright test --ui",
"start": "pnpm with-env next start -p 3000",
"test:e2e": "pnpm with-env playwright test",
"test:e2e:inspector": "pnpm with-env playwright test $1 --debug",
"test:e2e:ui": "pnpm with-env playwright test --ui",
"type-check": "tsc --noEmit",
"typegen": "bun with-env next typegen",
"typegen": "pnpm with-env next typegen",
"with-env": "dotenvx run -f ../../.env.local --ignore=MISSING_ENV_FILE --"
},
"lint-staged": {
Expand Down Expand Up @@ -95,7 +95,7 @@
"@content-collections/next": "0.2.7",
"@nelsonlaidev/eslint-config": "2.2.0",
"@nelsonlaidev/typescript-config": "0.0.3",
"@next/bundle-analyzer": "15.5.3",
"@next/bundle-analyzer": "15.5.4",
"@repo/kv": "workspace:*",
"@tailwindcss/postcss": "4.1.13",
"@testing-library/jest-dom": "6.8.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineConfig({
{ name: 'teardown', testMatch: '**/*.teardown.ts' }
],
webServer: {
command: CI ? 'bun start' : 'bun dev',
command: CI ? 'pnpm start' : 'pnpm dev',
url: baseURL,
reuseExistingServer: !CI
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/[locale]/(admin)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Layout = async (props: LayoutProps<'/[locale]'>) => {
const { locale } = await params
const session = await getSession()

if (!session || session.user.role !== 'admin') {
if (session?.user.role !== 'admin') {
redirect({ href: '/', locale: locale as Locale })
}

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/orpc/routers/spotify.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const spotifyStats = publicProcedure.output(spotifyStatsOutputSchema).han
const song: SpotifyApi.CurrentlyPlayingResponse = await response.json()

// If the song is not playing or is not a track, return an empty response
if (song.item === null || song.item.type !== 'track') {
if (song.item?.type !== 'track') {
return EMPTY_RESPONSE
}

Expand Down
Loading