Skip to content

Commit d8b1563

Browse files
Complete migration to @spree/next package (#7)
* Complete migration to @spree/next package Migrate all server-side data layer from direct @spree/sdk usage to @spree/next, which provides Server Actions for authentication, cart, checkout, and customer operations with built-in cookie-based auth and token refresh. Changes: - Add @spree/next@0.1.1 as dependency and configure transpilePackages - Delete src/lib/spree.ts (client initialization now internal to @spree/next) - Delete src/lib/data/auth-request.ts (token refresh now internal to @spree/next) - Simplify src/lib/data/cookies.ts to only isAuthenticated() check - Rewrite all data layer files to delegate to @spree/next Server Actions - Fix React 19 hook ordering in CheckoutPage (use() before other hooks) - Fix nested form issue in AddressStep component Result: Reduced data layer from 867 to 252 lines while maintaining all functionality. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * Fix inconsistent error handling in cart and add return type to getCreditCards Wrap addToCart, updateCartItem, removeCartItem in try/catch with structured { success, cart, error } returns for consistency with associateCartWithUser. Update CartContext to handle the new structured return type. Add explicit return type annotation to getCreditCards. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Wrap clearCart in structured error handling for consistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add Vitest test suite and GitHub Actions CI Set up Vitest with React Testing Library and jsdom for unit/integration testing. Add 58 tests across 5 test files covering the data layer (cart, checkout, customer), CartContext, and ProductCard component. Add GitHub Actions CI workflow with parallel lint, typecheck, and test jobs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix Biome lint errors in test files and vitest config Use node: protocol for path import, fix import ordering, and auto-format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent b98856f commit d8b1563

File tree

29 files changed

+4492
-1226
lines changed

29 files changed

+4492
-1226
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
name: Lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: npm
23+
- run: npm ci
24+
- run: npm run check
25+
26+
typecheck:
27+
name: Type Check
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 20
34+
cache: npm
35+
- run: npm ci
36+
- run: npx tsc --noEmit
37+
38+
test:
39+
name: Unit Tests
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: 20
46+
cache: npm
47+
- run: npm ci
48+
- run: npm run test

next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4+
transpilePackages: ["@spree/next", "@spree/sdk"],
45
images: {
56
qualities: [25, 50, 75, 100],
67
dangerouslyAllowLocalIP: true, // Allow localhost images in development

0 commit comments

Comments
 (0)