Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
# Dependabot uses the "npm" ecosystem for npm, pnpm, and Yarn projects.
- package-ecosystem: "npm"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
42 changes: 23 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run check
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm check
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

typecheck:
name: Type Check
Expand All @@ -32,12 +33,13 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npx tsc --noEmit
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm exec tsc --noEmit

test:
name: Unit Tests
Expand All @@ -46,12 +48,13 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run test
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm test

e2e:
name: E2E (Playwright + Spree)
Expand Down Expand Up @@ -80,11 +83,12 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: npm
- run: npm ci
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
# Key the browser cache on the Playwright version, not the whole
# lockfile — unrelated dependency bumps shouldn't force a ~150MB
# Chromium re-download.
Expand All @@ -99,23 +103,23 @@ jobs:
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium
run: pnpm exec playwright install --with-deps chromium
- name: Install Playwright system deps only
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps chromium
run: pnpm exec playwright install-deps chromium
- name: Boot Spree backend (Postgres + Redis + Spree 5.4.3.1)
run: docker compose -f e2e-backend/docker-compose.yml up -d --wait
- name: Seed Spree and issue API key
env:
# Test-mode Stripe key pair from one sandbox account, consumed by
# bootstrap-spree.sh to configure the Spree Stripe gateway. Scoped
# to this step so npm postinstall scripts and third-party actions
# to this step so dependency lifecycle scripts and third-party actions
# in other steps never see the secret.
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_PUBLISHABLE_KEY: ${{ vars.STRIPE_PUBLISHABLE_KEY }}
run: ./scripts/e2e/bootstrap-spree.sh
- name: Run Playwright tests
run: npm run test:e2e
run: pnpm test:e2e
- name: Dump Spree logs on failure
if: failure()
run: docker compose -f e2e-backend/docker-compose.yml logs --no-color web > spree.log || true
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,16 @@ This project uses [Biome](https://biomejs.dev/) for linting and formatting (not

```bash
# Lint the codebase
npm run lint
pnpm lint

# Format all files
npm run format
pnpm format

# Run both lint and format checks
npm run check
pnpm check
```

Always use `npm run check` before committing changes and fix any issues with `npm run format`.
Always use `pnpm check` before committing changes and fix any issues with `pnpm format`.

### Configuration

Expand Down
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,26 @@
ARG NODE_VERSION=22-alpine


# ---- base: pin pnpm from package.json via Corepack ----
FROM node:${NODE_VERSION} AS base
RUN corepack enable


# ---- deps: install production+dev dependencies for the build ----
FROM node:${NODE_VERSION} AS deps
FROM base AS deps
WORKDIR /app

# libc6-compat keeps a few native modules happy on Alpine (musl).
RUN apk add --no-cache libc6-compat

COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --include=dev
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm config set store-dir /pnpm/store && \
CI=true pnpm install --frozen-lockfile


# ---- builder: compile the Next.js app ----
FROM node:${NODE_VERSION} AS builder
FROM base AS builder
WORKDIR /app

ENV NEXT_TELEMETRY_DISABLED=1
Expand Down Expand Up @@ -69,7 +75,7 @@ COPY . .

RUN --mount=type=secret,id=sentry_auth_token,required=false \
SENTRY_AUTH_TOKEN="$(cat /run/secrets/sentry_auth_token 2>/dev/null || true)" \
npm run build
pnpm build


# ---- runner: minimal runtime image ----
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ Browser → Server Action → @spree/sdk → Spree API

### Prerequisites

- Node.js 20+ (required for Next.js 16)
- Node.js 22.13+
- pnpm 11 (Corepack can install the version pinned by this project)
- A running Spree Commerce 5.4+

### Installation

1. Install dependencies:

```bash
npm install
corepack enable
pnpm install --frozen-lockfile
```

2. Copy the environment file and configure:
Expand Down Expand Up @@ -132,7 +134,7 @@ SPREE_PUBLISHABLE_KEY=your_publishable_api_key_here
### Development

```bash
npm run dev
pnpm dev
```

Open [http://localhost:3001](http://localhost:3001) in your browser.
Expand All @@ -150,7 +152,7 @@ brew install cloudflared
2. Start the dev server normally (HTTP on port 3001):

```bash
npm run dev
pnpm dev
```

3. In a second terminal, expose it through a quick tunnel:
Expand All @@ -172,17 +174,17 @@ The output will contain a URL like `https://<random-words>.trycloudflare.com`.
### Production Build

```bash
npm run build
npm start
pnpm build
pnpm start
```

### Testing

Unit and integration tests run through Vitest:

```bash
npm test # one-shot
npm run test:watch # watch mode
pnpm test # one-shot
pnpm test:watch # watch mode
```

End-to-end tests run through Playwright against a real Spree backend booted in Docker. The compose file at `e2e-backend/docker-compose.yml` ships Postgres + Redis + the official `ghcr.io/spree/spree:5.4.3.1` image — no `create-spree-app` setup required. Seeding and API-key creation go through the official [`@spree/cli`](https://spreecommerce.org/docs/developer/cli/quickstart) (`spree seed`, `spree sample-data`, `spree api-key create`), installed as a dev dependency.
Expand All @@ -197,16 +199,16 @@ export STRIPE_SECRET_KEY=sk_test_…

# 2. Boot Spree + Postgres + Redis, seed sample data, register a Stripe
# payment gateway, mint a publishable key, and write .env.e2e.
npm run e2e:up
pnpm e2e:up

# 3. Run the suite. Playwright boots `next dev` against .env.e2e.
npm run test:e2e
pnpm test:e2e

# Optional: interactive UI mode.
npm run test:e2e:ui
pnpm test:e2e:ui

# Tear everything down.
npm run e2e:down
pnpm e2e:down
```

The checkout test pays with card `4242 4242 4242 4242` through Stripe's [test mode](https://docs.stripe.com/keys). PaymentIntents land in whichever Stripe test account owns the keys you exported. In CI, set `STRIPE_SECRET_KEY` as a repository secret and `STRIPE_PUBLISHABLE_KEY` as a repository variable (Settings → Secrets and variables → Actions). The E2E job skips itself on fork PRs, where GitHub never exposes repository secrets.
Expand Down Expand Up @@ -391,7 +393,7 @@ Templates are in `src/lib/emails/` as React components:

### Previewing Templates

Run the storefront in development (`npm run dev`) and visit [http://localhost:3001/dev/emails](http://localhost:3001/dev/emails). Each template is rendered with sample data using `@react-email/render`; the route is gated to non-production environments.
Run the storefront in development (`pnpm dev`) and visit [http://localhost:3001/dev/emails](http://localhost:3001/dev/emails). Each template is rendered with sample data using `@react-email/render`; the route is gated to non-production environments.

### How It Works

Expand Down
4 changes: 2 additions & 2 deletions e2e-backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#
# Usage (driven by ../scripts/e2e/bootstrap-spree.sh):
# docker compose up -d --wait
# npx @spree/cli seed && npx @spree/cli sample-data
# npx @spree/cli api-key create --name E2E --type publishable
# ../node_modules/.bin/spree seed && ../node_modules/.bin/spree sample-data
# ../node_modules/.bin/spree api-key create --name E2E --type publishable
#
# Spree exposes the storefront API on http://localhost:4000/api/v3/store.
# Postgres and Redis are reachable only on the compose network — use
Expand Down
2 changes: 1 addition & 1 deletion e2e/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { expect, type FrameLocator, type Page, test } from "@playwright/test";
* Backend: e2e-backend/docker-compose.yml (Spree 5.4.3.1 with sample data).
* Payments: real Stripe test mode (pk_test_...) — card 4242 4242 4242 4242.
*
* Run with: npm run e2e:up && npm run test:e2e
* Run with: pnpm e2e:up && pnpm test:e2e
*/

const TEST_CARD = "4242424242424242";
Expand Down
3 changes: 1 addition & 2 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ pre-commit:
commands:
biome:
glob: "*.{js,ts,jsx,tsx,json,css}"
exclude: "package-lock.json"
run: npx biome check --write {staged_files} && git add {staged_files}
run: pnpm exec biome check --write {staged_files} && git add {staged_files}
Loading
Loading