Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Streamline local dev in monorepo and new create-spree-app apps

Damian Legawiec533bae86421e
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 3b08c53d0c..30bd4ae079 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -85,23 +85,39 @@ pnpm server:load_sample_data
After the one-time setup, use these to bring the stack up and down:
```bash
-pnpm server:start # boot the Docker stack (fast — image cached, DB persisted)
-pnpm server:stop # tear down
-pnpm server:logs # follow web container logs
+pnpm server:dev # run the stack in the foreground — streams web + worker logs, Ctrl+C stops them
+pnpm server:stop # full teardown (also stops postgres / redis / meilisearch)
+pnpm server:restart # restart web + worker in place
+pnpm server:logs # follow web container logs (when the stack runs detached)
pnpm server:console # open a Rails console inside the container
+pnpm server:seed # re-run database seeds
+pnpm server:build # rebuild the dev image (only after Dockerfile / .ruby-version changes)
```
+`server:dev` behaves like any TS dev server (`vite dev`, the dashboard's `pnpm dev`): it runs in the foreground and Ctrl+C stops the app containers. Postgres, Redis, and Meilisearch keep running for a fast next boot — `pnpm server:stop` shuts everything down.
+
Run any CLI command against the running backend from `server/`:
```bash
cd server
-pnpm exec spree rails db:migrate
+pnpm exec spree migrate
pnpm exec spree generate model Brand name:string
pnpm exec spree upgrade --plan
```
See the [`@spree/cli` README](../packages/cli/README.md) for the full command surface.
+Which command after which change:
+
+| What changed | What to run |
+|---|---|
+| Ruby code in `spree/*` gems | Nothing — gems are bind-mounted; code reloads on the next request |
+| A new migration in a gem | `cd server && pnpm exec spree migrate` |
+| Gem dependencies (gemspec / Gemfile) | `cd server && pnpm exec spree bundle install` (persists in the `bundle_cache` volume) |
+| Compose files / `server/.env` | `pnpm server:dev` (force-recreates the containers) |
+| `server/Dockerfile` / `.ruby-version` | `pnpm server:build`, then `pnpm server:dev` |
+| Broken beyond repair | `pnpm server:setup` (full reset — wipes the database and volumes) |
+
Re-run `pnpm server:setup` **only** to fully reset — it does `docker compose down -v` + `rm -rf ./server`, wiping all DB data.
### Native Ruby (advanced)
@@ -218,7 +234,7 @@ Spree runs slower in development because caching is disabled and code reloads on
cd server && pnpm exec spree rails dev:cache
```
-Restart the Rails server after running this (`pnpm server:stop && pnpm server:start`).
+Restart the Rails server after running this (Ctrl+C the running `pnpm server:dev` and start it again).
## TypeScript Development
@@ -244,7 +260,7 @@ Run from the repository root — [Turborepo](https://turbo.build/) orchestrates
| Command | Description |
|---|---|
-| `pnpm dev` | Watch mode for all packages (does not boot the backend — use `pnpm server:start` for that) |
+| `pnpm dev` | Watch mode for all packages (does not boot the backend — use `pnpm server:dev` for that) |
| `pnpm build` | Build all packages (Turbo resolves dependency order) |
| `pnpm test` | Run tests in all packages |
| `pnpm lint` | Lint all packages |
@@ -269,7 +285,7 @@ The dashboard runs as a Vite dev server (port 5173) that proxies `/api/*` to the
```bash
# Terminal 1: backend
-pnpm server:start
+pnpm server:dev
# Terminal 2: dashboard
cd packages/dashboard
diff --git a/CLAUDE.md b/CLAUDE.md
index 07b9b7cccc..75b2a00d4a 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -72,6 +72,23 @@ Shipped plans:
| `packages/create-spree-app` | `create-spree-app` — project scaffolding |
| `server/` | Rails app cloned from `spree/spree-starter` (.gitignored, run `pnpm server:setup`) |
+## Development Server (`server/`)
+
+One-time bootstrap (Docker required, no host Ruby): `pnpm install && pnpm server:setup`. It clones spree-starter into `server/`, boots the edge stack (monorepo gems bind-mounted via a compose overlay), and prepares + seeds the DB. Idempotent — but re-running it is a **full reset** that wipes the DB and volumes.
+
+Day-to-day from the repo root: `pnpm server:dev` (foreground — streams web + worker logs, Ctrl+C stops them; postgres/redis stay warm) / `server:stop` (full teardown) / `server:restart` / `server:logs` / `server:console` / `server:seed` / `server:load_sample_data`. CLI commands run from `server/`: `pnpm exec spree <cmd>` (`spree migrate`, `spree console`, `spree generate model …`). `spree dev` and `spree build` refuse to run in `server/` (SPREE_PATH guard) — use the `pnpm server:*` scripts instead.
+
+| What changed | What to run |
+|---|---|
+| Ruby code in `spree/*` gems | Nothing — bind-mounted, reloads on next request |
+| New migration in a gem | `cd server && pnpm exec spree migrate` |
+| Gem dependencies (gemspec / Gemfile) | `cd server && pnpm exec spree bundle install` (persists in the `bundle_cache` volume) |
+| Compose files / `server/.env` | `pnpm server:dev` (force-recreates web + worker) |
+| `server/Dockerfile` / `.ruby-version` | `pnpm server:build`, then `pnpm server:dev` |
+| Broken beyond repair | `pnpm server:setup` (full reset — wipes DB + volumes) |
+
+Backend: http://localhost:3000, admin at `/admin` (`[email protected]` / `spree123`). Native no-Docker path: `pnpm server:create`, then `cd server && bin/setup && bin/dev`.
+
---
## General rules
@@ -453,8 +470,8 @@ The split lets plugin authors register UI via `defineDashboardPlugin` from `@spr
```bash
# 1. Boot a Spree backend (one terminal, from monorepo root)
-pnpm server:setup # one-time: clones spree-starter into ./server
-pnpm server:dev # Rails on http://localhost:3000
+pnpm server:setup # one-time bootstrap (see "Development Server" above)
+pnpm server:dev # foreground; streams logs — Rails on http://localhost:3000
# 2. Boot the admin (separate terminal)
cd packages/dashboard
diff --git a/docs/developer/cli/quickstart.mdx b/docs/developer/cli/quickstart.mdx
index 427a649ce6..773f80ff8f 100644
--- a/docs/developer/cli/quickstart.mdx
+++ b/docs/developer/cli/quickstart.mdx
@@ -40,7 +40,7 @@ spree init --no-open # Skip opening browser
### `spree dev`
-Start services and stream logs.
+Run the app in the foreground — streams web + worker logs; `Ctrl+C` stops them. The databases keep running for a fast next boot (`spree stop` shuts everything down).
```bash
spree dev
@@ -62,7 +62,7 @@ Restart `web` and `worker` in place — same image, same volumes, fresh Rails pr
spree restart
```
-Not appropriate for Gemfile changes (use `spree bundle install` then `spree stop && spree dev`), Dockerfile / `.ruby-version` changes (use `spree build`), or compose file changes (use `spree stop && spree dev`).
+Not appropriate for Gemfile changes (use `spree bundle install`, then Ctrl+C and re-run `spree dev`), Dockerfile / `.ruby-version` changes (use `spree build`), or compose file changes (Ctrl+C and re-run `spree dev`).
### `spree update`
@@ -180,29 +180,29 @@ These mirror the Rails commands you'd run if you were running the app directly o
### `spree generate`
-Run a Rails generator inside the container. Same arguments as `bin/rails generate`.
+Run a generator inside the container. Bare generator names are auto-prefixed with `spree:` — `model` runs `spree:model`, `api_resource` runs `spree:api_resource` — so you get the Spree conventions (`Spree::` namespace, `spree_`-prefixed table, prefixed IDs, `null: false`, no FK constraints) by default. Rails built-ins (`migration`, `scaffold`, `mailer`, `job`, …) and any name containing `:` are forwarded as-is.
```bash
-spree generate model Brand name:string slug:string
-spree generate migration AddPositionToProducts position:integer
-spree generate spree:api_resource Brand name:string slug:string # The Spree v3-conformant generator
+spree generate model Brand name:string slug:string:uniq # runs spree:model
+spree generate api_resource Brand name:string slug:string:uniq # runs spree:api_resource — model + v3 Store/Admin API
+spree generate migration AddPositionToSpreeBrands position:integer # Rails built-in, forwarded as-is
```
-See [Generators](/developer/customization/generators) for the Spree-specific generators (`spree:model`, `spree:api_resource`) that extend Rails' built-in ones with Spree conventions.
+`spree:api_resource` scaffolds the full v3 surface: model, migration, Store + Admin controllers and serializers, factory, controller specs, and routes.
### `spree migrate`
-Install pending Spree migrations from gems, then run `db:migrate`.
+Install pending Spree migrations from gems, then run `db:migrate` — the canonical post-update sequence.
```bash
spree migrate
+spree migrate:status # show the migration log (`db:migrate:status`)
+spree migrate:rollback STEP=2 # roll back (`db:rollback`)
```
-Equivalent to `spree rails spree:install:migrations db:migrate` — a shortcut for the canonical post-update sequence.
-
### `spree db:reset`
-Drop, recreate, and seed the database. **Destructive** — wipes everything. Asks for confirmation.
+Drop, recreate, migrate, and seed the database. **Destructive** — wipes everything. Asks for confirmation.
```bash
spree db:reset
@@ -211,7 +211,7 @@ spree db:reset --yes # Skip confirmation (for CI)
### `spree db:console`
-Open a database console (`bin/rails dbconsole`) connected to the dev Postgres.
+Open a `psql` session against the dev Postgres database (runs inside the `postgres` container).
```bash
spree db:console
diff --git a/docs/developer/contributing/developing-spree.mdx b/docs/developer/contributing/developing-spree.mdx
index a1999ca660..e93b295723 100644
--- a/docs/developer/contributing/developing-spree.mdx
+++ b/docs/developer/contributing/developing-spree.mdx
@@ -5,6 +5,8 @@ description: >-
code. We're happy you're here!
---
+Please read our [Code of Conduct](https://github.com/spree/spree/blob/main/CODE_OF_CONDUCT.md) before contributing.
+
## Cloning the repository
Spree is a big monorepo. For a faster clone, use a **partial clone** which downloads file contents on demand while keeping full commit history for `git log` and `git blame`:
@@ -24,66 +26,98 @@ You need **Node.js 20+** to run the workspace scripts (including `pnpm server:se
Spree is a monorepo with three main areas:
- **`spree/`** — Ruby gems (core, api, admin, emails) distributed as separate packages via RubyGems
-- **`packages/`** — TypeScript packages (SDKs, CLI, project scaffolding, docs)
-- **`server/`** — A Rails application cloned from [spree-starter](https://github.com/spree/spree-starter) that mounts the Spree gems (not checked in — run `pnpm server:setup` to create it)
+- **`packages/`** — TypeScript packages (SDKs, CLI, project scaffolding, docs, React dashboard)
+- **`server/`** — A Rails application cloned from [spree-starter](https://github.com/spree/spree-starter) that mounts the local Spree gems (not checked in — `pnpm server:setup` creates it)
-## Backend Development (Ruby)
+## Setup
-### Engines overview
+A single command bootstraps the whole monorepo for both backend and frontend work. You need **Docker** running locally (Docker Desktop, OrbStack, or any compatible runtime) — no Ruby, Postgres, or Redis on your host.
-The Spree [Rails engines](https://guides.rubyonrails.org/engines.html) live inside `spree/` and are distributed as separate gems (Ruby packages installed via Bundler):
+```bash
+pnpm install # workspace dependencies
+pnpm server:setup # ~5–10 min on first run; idempotent
+```
-| Engine | Gem | Description |
-|---|---|---|
-| `core` | `spree_core` | Models, services, business logic |
-| `api` | `spree_api` | REST APIs |
-| `admin` | `spree_admin` | Admin dashboard |
-| `emails` | `spree_emails` | Transactional emails |
+`pnpm server:setup` clones [spree-starter](https://github.com/spree/spree-starter) into `./server/`, wires it to load Spree gems from the monorepo via a Docker compose overlay, builds the dev image, starts the stack (Postgres + Redis + Meilisearch + Rails `web` + Sidekiq `worker`), and prepares the database. The full sequence lives in `scripts/server-setup.sh`.
-### Spree namespace
+When it's done, the backend is up at [http://localhost:3000](http://localhost:3000) and the admin is at [http://localhost:3000/admin](http://localhost:3000/admin). Sign in with the seed admin: **`[email protected]`** / **`spree123`** (override at seed time with `ADMIN_EMAIL` / `ADMIN_PASSWORD` env vars — see `spree/core/app/services/spree/seeds/admin_user.rb`).
-All Spree models, controllers and other Ruby classes are namespaced by the `Spree` keyword, eg. `Spree::Product`. This means that those files are also located in `spree` sub-directories eg. [app/models/spree/product.rb](https://github.com/spree/spree/blob/main/spree/core/app/models/spree/product.rb).
+Optionally load sample products, taxonomies, and option types:
-### Setup
+```bash
+pnpm server:load_sample_data
+```
-The server app is not checked into the monorepo. It's cloned from [spree-starter](https://github.com/spree/spree-starter) on first setup, with `SPREE_PATH=..` automatically configured so it uses your local Spree gems.
+## Running a backend day-to-day
-**Step 1: Clone the server app**
+After the one-time setup, use these to bring the stack up and down:
```bash
-pnpm server:setup
+pnpm server:dev # run the stack in the foreground — streams web + worker logs, Ctrl+C stops them
+pnpm server:stop # full teardown (also stops postgres / redis / meilisearch)
+pnpm server:restart # restart web + worker in place
+pnpm server:logs # follow web container logs (when the stack runs detached)
+pnpm server:console # open a Rails console inside the container
+pnpm server:seed # re-run database seeds
+pnpm server:build # rebuild the dev image (only after Dockerfile / .ruby-version changes)
```
-This clones [spree-starter](https://github.com/spree/spree-starter) into `server/` and sets `SPREE_PATH=..` in `server/.env` so it uses your local Spree gems.
+`server:dev` behaves like any TS dev server (`vite dev`, the dashboard's `pnpm dev`): it runs in the foreground and Ctrl+C stops the app containers. Postgres, Redis, and Meilisearch keep running for a fast next boot — `pnpm server:stop` shuts everything down.
-**Step 2: Configure and run**
+Run any CLI command against the running backend from `server/`:
```bash
cd server
-# Edit .env if needed (e.g. DATABASE_USERNAME, DATABASE_HOST, DATABASE_PORT)
-bin/setup # installs Ruby (via mise), Postgres/Redis/Meilisearch (via brew), gems, prepares database
-bin/dev # starts Rails + Sidekiq + CSS watchers via overmind
+pnpm exec spree migrate
+pnpm exec spree generate model Brand name:string
+pnpm exec spree upgrade --plan
```
-`bin/setup` installs system services natively (PostgreSQL, Redis, Meilisearch) via `brew bundle` on macOS or `apt-get` on Linux. If you'd rather run those services in Docker, start them from the repo root before running `bin/setup`:
+See the [`@spree/cli` README](https://github.com/spree/spree/blob/main/packages/cli/README.md) for the full command surface.
-```bash
-docker compose up -d postgres redis meilisearch
-```
+Which command after which change:
-Use `bin/setup --reset` to drop and recreate the database.
+| What changed | What to run |
+|---|---|
+| Ruby code in `spree/*` gems | Nothing — gems are bind-mounted; code reloads on the next request |
+| A new migration in a gem | `cd server && pnpm exec spree migrate` |
+| Gem dependencies (gemspec / Gemfile) | `cd server && pnpm exec spree bundle install` (persists in the `bundle_cache` volume) |
+| Compose files / `server/.env` | `pnpm server:dev` (force-recreates the containers) |
+| `server/Dockerfile` / `.ruby-version` | `pnpm server:build`, then `pnpm server:dev` |
+| Broken beyond repair | `pnpm server:setup` (full reset — wipes the database and volumes) |
-The app runs at [http://localhost:3000](http://localhost:3000). Admin Panel is at [http://localhost:3000/admin](http://localhost:3000/admin).
+Re-run `pnpm server:setup` **only** to fully reset — it does `docker compose down -v` + `rm -rf ./server`, wiping all DB data.
-**Step 3 (optional): Load sample data**
+## Native Ruby (advanced)
-To populate your store with sample products, customers, orders, and configuration:
+If you prefer the fastest possible inner loop and don't mind installing Ruby, Postgres, Redis, and Meilisearch on your host directly, you can skip Docker:
```bash
-pnpm server:load_sample_data # from repo root
-# or, from server/: bin/rails spree:load_sample_data
+pnpm server:create # clones spree-starter, writes server/.env with SPREE_PATH=..
+cd server
+bin/setup # installs Ruby (via mise), Postgres/Redis/Meilisearch (via brew bundle on macOS), gems, prepares the database
+bin/dev # starts Rails + Sidekiq + CSS watchers via Foreman
```
+This path is faster per request but means more on your host. It also runs against your installed system services, not a sandboxed Docker stack.
+
+## Backend Development (Ruby)
+
+### Engines overview
+
+The Spree [Rails engines](https://guides.rubyonrails.org/engines.html) live inside `spree/` and are distributed as separate gems (Ruby packages installed via Bundler):
+
+| Engine | Gem | Description |
+|---|---|---|
+| `core` | `spree_core` | Models, services, business logic |
+| `api` | `spree_api` | REST APIs |
+| `admin` | `spree_admin` | Admin dashboard |
+| `emails` | `spree_emails` | Transactional emails |
+
+### Spree namespace
+
+All Spree models, controllers and other Ruby classes are namespaced by the `Spree` keyword, eg. `Spree::Product`. This means that those files are also located in `spree` sub-directories eg. [app/models/spree/product.rb](https://github.com/spree/spree/blob/main/spree/core/app/models/spree/product.rb).
+
### Running engine tests
Each engine has its own test suite. First install the shared dependencies at the `spree/` level, then navigate into the specific engine to set up and run its tests:
@@ -148,9 +182,9 @@ bundle exec parallel_rspec -n 4 spec
After schema changes, re-run `bundle exec rake parallel_setup` to update the worker databases.
-### Integration tests (Admin Panel)
+### Integration tests (legacy Rails admin)
-The Admin Panel uses feature specs that run in a real browser via chromedriver. You only need this if you're working on admin UI changes.
+The legacy Rails admin (`spree/admin`) ships feature specs that run in a real browser via chromedriver. You only need this if you're touching the legacy admin UI.
Install chromedriver on macOS:
@@ -158,47 +192,35 @@ Install chromedriver on macOS:
brew install chromedriver
```
-### Performance in development mode
+The 6.0 React dashboard (`packages/dashboard`) has its own end-to-end test suite running on Playwright against a real Rails backend — see [Dashboard E2E tests](#dashboard-e2e-tests) under TypeScript Development.
-You may notice that your Spree store runs slower in development environment. This is caused by disabled caching and automatic reloading of code after each change.
+### Performance in development mode
-Caching is disabled by default. To turn on caching please run:
+Spree runs slower in development because caching is disabled and code reloads on each request. To turn on caching:
```bash
-cd server && bin/rails dev:cache
+cd server && pnpm exec spree rails dev:cache
```
-You will need to restart rails server after this change.
+Restart the Rails server after running this (Ctrl+C the running `pnpm server:dev` and start it again).
## TypeScript Development
-### Setup
-
-TypeScript developers don't need Ruby installed. Docker Compose from the repository root starts the backend using a prebuilt image:
-
-```bash
-docker compose up -d
-```
-
-This boots PostgreSQL, Redis, Meilisearch, and the Spree backend automatically (no `pnpm server:setup` needed). The API is available at `http://localhost:3000`.
-
-Then install dependencies and start all packages in watch mode:
-
-```bash
-pnpm install
-pnpm dev
-```
+The backend setup is the same as for Ruby work — see [Setup](#setup) above. With `pnpm server:setup` done, the Rails backend is running and you can start the packages you want to work on.
### Packages
-| Package | Path | Description |
-|---|---|---|
-| `@spree/sdk` | `packages/sdk` | TypeScript SDK for the Spree Store API |
-| `@spree/cli` | `packages/cli` | CLI for managing Spree Commerce projects |
-| `create-spree-app` | `packages/create-spree-app` | Project scaffolding (`npm create spree-app`) |
-| `@spree/docs` | `packages/docs` | Developer documentation for AI agents and local reference |
-
-Internal packages (`@spree/admin-sdk`, `@spree/sdk-core`) are also part of the workspace but are not published to npm.
+| Package | Path | Published | Description |
+|---|---|---|---|
+| `@spree/sdk` | `packages/sdk` | yes | TypeScript SDK for the Spree Store API |
+| `@spree/admin-sdk` | `packages/admin-sdk` | yes | TypeScript SDK for the Spree Admin API |
+| `@spree/cli` | `packages/cli` | yes | CLI for managing Spree Commerce projects |
+| `create-spree-app` | `packages/create-spree-app` | yes | Project scaffolding (`npm create spree-app`) |
+| `@spree/docs` | `packages/docs` | yes | Developer documentation for AI agents and local reference |
+| `@spree/dashboard` | `packages/dashboard` | no | React SPA admin dashboard (Spree 6.0, replaces the legacy Rails admin) |
+| `@spree/dashboard-core` | `packages/dashboard-core` | no | Framework: registries, providers, generic infra hooks for the dashboard |
+| `@spree/dashboard-ui` | `packages/dashboard-ui` | no | Design system used by the dashboard |
+| `@spree/sdk-core` | `packages/sdk-core` | no | Shared HTTP/retry/error layer used by both SDKs |
### Common commands
@@ -206,7 +228,7 @@ Run from the repository root — [Turborepo](https://turbo.build/) orchestrates
| Command | Description |
|---|---|
-| `pnpm dev` | Start Docker backend + watch mode for all packages |
+| `pnpm dev` | Watch mode for all packages (does not boot the backend — use `pnpm server:dev` for that) |
| `pnpm build` | Build all packages (Turbo resolves dependency order) |
| `pnpm test` | Run tests in all packages |
| `pnpm lint` | Lint all packages |
@@ -225,21 +247,86 @@ pnpm --filter @spree/sdk generate:zod
Tests use [Vitest](https://vitest.dev/) with [MSW](https://mswjs.io/) for API mocking at the network level.
-### Type generation
+### Working on the React dashboard
+
+The dashboard runs as a Vite dev server (port 5173) that proxies `/api/*` to the Rails backend on port 3000 — required for the auth refresh cookie to work over plain HTTP.
+
+```bash
+# Terminal 1: backend
+pnpm server:dev
+
+# Terminal 2: dashboard
+cd packages/dashboard
+pnpm dev # http://localhost:5173
+```
+
+Sign in with `[email protected]` / `spree123`. To point at a non-default backend, set `VITE_SPREE_API_URL` (also needs to be set at build time for production bundles, not just dev):
+
+```bash
+VITE_SPREE_API_URL=https://my-spree.example.com pnpm dev
+```
+
+**Gotcha:** the dashboard imports `@spree/admin-sdk` from its **built** `dist/`, not source. If you edit `admin-sdk` (or `sdk-core`, or `sdk`) and want the dashboard to see the changes, run `pnpm build` from the monorepo root first (Turbo-cached). Editing dashboard code alone doesn't need this.
+
+See the [dashboard README](https://github.com/spree/spree/blob/main/packages/dashboard/README.md) for the full architecture (auth, permissions, extension points, the three-package split between `dashboard`, `dashboard-core`, and `dashboard-ui`).
+
+### Dashboard E2E tests
+
+The React dashboard ships an end-to-end suite running on [Playwright](https://playwright.dev/) against a real Rails backend — no mocks. The spec files exercise the full UI: login, staff invitation, invitee signup. CI runs the same suite via the `dashboard-e2e` job in `.github/workflows/packages.yml`.
-TypeScript types in `packages/sdk/src/types/generated/` are auto-generated from the Rails API serializers using [typelizer](https://github.com/skryukov/typelizer). To regenerate after changing serializers:
+To run locally you need Ruby (the suite boots a real Rails server) and a one-time browser install:
```bash
+# Make sure the dummy Rails app exists (one-time, after a fresh checkout).
cd spree/api
-mise install --yes # to install Ruby if you don't have it already
-bundle install # to install dependencies
-bundle exec rake typelizer:generate
+bundle install
+bundle exec rake test_app
+
+# Install Playwright's Chromium (one-time per machine).
+cd ../../packages/dashboard
+pnpm test:e2e:install
+
+# Run the suite. Boots Rails on :3010 + Vite on :5174, runs all specs, tears
+# both down. Safe to re-run repeatedly — the SQLite DB resets each run.
+pnpm test:e2e
```
-After regenerating types, update the Zod schemas:
+For interactive debugging (time-travel through actions, inspect the DOM at each step):
```bash
-pnpm --filter @spree/sdk generate:zod
+pnpm test:e2e:ui
+```
+
+Filter to a single spec or test name:
+
+```bash
+pnpm test:e2e e2e/auth.spec.ts
+pnpm test:e2e -g "invites a teammate"
+```
+
+When a test fails, Playwright drops a screenshot, video, and DOM snapshot in `packages/dashboard/test-results/<spec>/` — usually enough to diagnose without re-running.
+
+### Type generation
+
+TypeScript types in `packages/sdk/src/types/generated/` (Store API) and `packages/admin-sdk/src/types/generated/` (Admin API) are auto-generated from the Rails serializers using [typelizer](https://github.com/skryukov/typelizer). Zod schemas in `packages/sdk/src/zod/generated/` are derived from the TS types.
+
+A **Lefthook pre-commit hook** regenerates both whenever you commit a change to `spree/api/app/serializers/**/*.rb` and re-stages the generated output. You don't need to run anything manually for the common case.
+
+To regenerate manually (useful when iterating on serializers before committing):
+
+```bash
+cd server
+pnpm exec spree rake typelizer:generate # regenerate TS types
+cd ../packages/sdk
+pnpm generate:zod # regenerate Zod schemas
+```
+
+If you'd rather avoid the Docker round-trip and have Ruby on your host, the native equivalent works too:
+
+```bash
+cd spree/api
+bundle install
+bundle exec rake typelizer:generate
```
### Releasing packages
@@ -247,29 +334,33 @@ pnpm --filter @spree/sdk generate:zod
Published packages use [Changesets](https://github.com/changesets/changesets) for version management. Each package owns its own `.changeset/` folder, so changesets must be created from inside the package directory:
```bash
-cd packages/sdk # or packages/cli, packages/create-spree-app
+cd packages/sdk # or packages/admin-sdk, packages/cli, packages/create-spree-app
pnpm changeset
```
This creates a changeset file describing your changes. Commit it with your PR. When merged to `main`, a GitHub Action creates a "Version Packages" PR that bumps the version and publishes to npm.
+Private packages (`@spree/dashboard`, `@spree/dashboard-core`, `@spree/dashboard-ui`, `@spree/sdk-core`) don't need changesets.
+
## Code Style
Consistent code style is enforced via automated linters. Please make sure your changes pass linting before submitting a PR.
-**Ruby:** We use [RuboCop](https://rubocop.org/) for Ruby code. The configuration lives in `server/.rubocop.yml` and is shipped with [spree-starter](https://github.com/spree/spree-starter), so it's only available after running `pnpm server:setup`. Run it from the `server/` directory:
+**Ruby:** We use [RuboCop](https://rubocop.org/) for Ruby code. The configuration lives in `server/.rubocop.yml` and is shipped with [spree-starter](https://github.com/spree/spree-starter), so it's only available after running `pnpm server:setup`. Run it inside the container via the CLI:
```bash
cd server
-bundle exec rubocop
+pnpm exec spree exec bundle exec rubocop
```
To auto-fix correctable offenses:
```bash
-bundle exec rubocop -a
+pnpm exec spree exec bundle exec rubocop -a
```
+(On the native path, drop the `pnpm exec spree exec` prefix and run `bundle exec rubocop` directly.)
+
**TypeScript:** We use [Biome](https://biomejs.dev/) for linting and formatting TypeScript code. Run it from the repository root:
```bash
@@ -319,7 +410,7 @@ To help us review your PR quickly:
- **Describe your changes.** Explain what you changed and why. Include screenshots for UI changes.
- **Add tests.** All new features and bug fixes should include appropriate test coverage.
- **Update documentation.** If your change affects user-facing behavior, update the relevant docs.
-- **Include a changeset** if your change affects a published TypeScript package (`@spree/sdk`, `@spree/cli`, or `create-spree-app`). Run `pnpm changeset` from inside that package's directory — each package owns its own `.changeset/` folder.
+- **Include a changeset** if your change affects a published TypeScript package (`@spree/sdk`, `@spree/admin-sdk`, `@spree/cli`, or `create-spree-app`). Run `pnpm changeset` from inside that package's directory — each package owns its own `.changeset/` folder.
- **Ensure CI passes.** PRs with failing CI will not be reviewed.
## Reporting Bugs
diff --git a/docs/developer/create-spree-app/quickstart.mdx b/docs/developer/create-spree-app/quickstart.mdx
index d9bef07b9a..8eb98bdbb2 100644
--- a/docs/developer/create-spree-app/quickstart.mdx
+++ b/docs/developer/create-spree-app/quickstart.mdx
@@ -21,7 +21,7 @@ Once complete, your store is running at [http://localhost:3000](http://localhost
## Prerequisites
- [Node.js](https://nodejs.org/) 20 or later
-- [Docker](https://docs.docker.com/get-docker/) (for running the Spree backend, PostgreSQL, and Redis)
+- [Docker](https://docs.docker.com/get-docker/) (for running the Spree backend, PostgreSQL, Redis, and Meilisearch)
## CLI Flags
@@ -53,9 +53,9 @@ npx create-spree-app@latest my-store --no-storefront --no-sample-data --no-start
```text
my-store/
-├── docker-compose.yml # Spree backend (prebuilt image) + Postgres + Redis
+├── docker-compose.yml # Spree backend (prebuilt image) + Postgres + Redis + Meilisearch
├── docker-compose.dev.yml # Alternative: build from local backend/
-├── .env # SECRET_KEY_BASE, SPREE_PORT
+├── .env # SECRET_KEY_BASE, SPREE_PORT, SPREE_VERSION_TAG
├── .gitignore
├── package.json # Convenience scripts
├── README.md
@@ -73,10 +73,11 @@ my-store/
### What's in docker-compose.yml
-- **Spree** — runs the `ghcr.io/spree/spree:latest` image on the configured port (default `3000`)
+- **Spree** — `web` (Rails) + `worker` (Sidekiq) running the `ghcr.io/spree/spree:latest` image on the configured port (default `3000`)
- **PostgreSQL 18** — database with persistent volume
- **Redis 7** — caching, background jobs, and Action Cable
-- Health checks on all services
+- **Meilisearch** — search engine
+- Health checks on postgres, redis, meilisearch, and web
## Customizing the Backend
@@ -92,7 +93,7 @@ This replaces `docker-compose.yml` with a version that builds from `backend/`, r
- **Override models** with decorators in `backend/app/models/`
- **Add controllers** in `backend/app/controllers/`
- **Configure Spree** in `backend/config/initializers/spree.rb`
-- **Add migrations** with `cd backend && bin/rails generate migration`
+- **Add migrations** with `spree generate migration AddFooToSpreeBars foo:string` (runs inside the container)
See the [Customization Guide](/developer/customization) for more details.
@@ -102,7 +103,7 @@ The project includes [@spree/cli](/developer/cli/quickstart) for managing your S
| Command | Description |
|---------|-------------|
-| `spree dev` | Start backend services and stream logs |
+| `spree dev` | Run the backend in the foreground — streams logs, Ctrl+C stops it |
| `spree stop` | Stop backend services |
| `spree update` | Pull latest Spree image and restart (runs migrations automatically) |
| `spree eject` | Switch from prebuilt image to building from `backend/` |
diff --git a/package.json b/package.json
index 9d3c3882a9..de224570f0 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,8 @@
"clean": "turbo clean",
"server:create": "git clone --depth 1 https://github.com/spree/spree-starter.git server && rm -rf server/.git server/.gitignore && printf 'SPREE_PATH=..\\nSECRET_KEY_BASE=%s\\n' \"$(openssl rand -hex 64)\" > server/.env",
"server:setup": "bash scripts/server-setup.sh",
- "server:start": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml up -d --force-recreate web worker",
+ "server:dev": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml up --force-recreate web worker",
+ "server:build": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml build web worker",
"server:restart": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml restart web worker",
"server:stop": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml down",
"server:console": "cd server && spree console",
diff --git a/packages/cli/.changeset/cli-hot-path-wrappers.md b/packages/cli/.changeset/cli-hot-path-wrappers.md
index 6eb1fb45db..9b751a8153 100644
--- a/packages/cli/.changeset/cli-hot-path-wrappers.md
+++ b/packages/cli/.changeset/cli-hot-path-wrappers.md
@@ -2,6 +2,6 @@
"@spree/cli": minor
---
-Add `spree generate`, `spree migrate` (+ `migrate:rollback`, `migrate:status`), `spree build`, `spree db:reset`, `spree db:console`, and `spree routes`. `spree generate` auto-prefixes `spree:` so `spree generate model Brand name:string` invokes the Spree generator. `spree db:reset` and `spree build --reset-bundle` are destructive and prompt by default; pass `--yes` to skip the prompt in CI. `spree build` targets `docker-compose.dev.yml` explicitly when present so it works before `spree eject`.
+Add `spree generate`, `spree migrate` (+ `migrate:rollback`, `migrate:status`), `spree build`, `spree db:reset`, `spree db:console`, and `spree routes`. `spree generate` auto-prefixes `spree:` so `spree generate model Brand name:string` invokes the Spree generator. `spree db:reset` and `spree build --reset-bundle` are destructive and prompt by default; pass `--yes` to skip the prompt in CI. `spree build` targets the active `docker-compose.yml` (the same file `spree dev` runs) and refuses with a pointer to `spree eject` when it has no `build:` section; in monorepo edge projects it points at `pnpm server:build`.
`spree eject` no longer runs a separate `docker compose build` step (the dev compose builds on first `up -d` automatically). Its description and post-eject hints now point at `spree bundle add` for gems and `spree build` for Dockerfile / `.ruby-version` changes.
diff --git a/packages/cli/README.md b/packages/cli/README.md
index c883448d8a..0586f7ad91 100644
--- a/packages/cli/README.md
+++ b/packages/cli/README.md
@@ -31,13 +31,13 @@ Run these from your Spree project directory.
### `spree dev`
-Start Docker services, print connection info, and stream web server logs.
+Run the app in the foreground — prints connection info, then streams web + worker logs (like `vite dev`).
```bash
spree dev
```
-Press `Ctrl+C` to stop streaming logs (services keep running).
+Press `Ctrl+C` to stop web + worker. The databases (postgres, redis, meilisearch) keep running for a fast next boot — `spree stop` shuts everything down.
### `spree stop`
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index 0ccca035e7..34d6704b6a 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -4,7 +4,7 @@ import * as p from '@clack/prompts'
import type { Command } from 'commander'
import { execa } from 'execa'
import pc from 'picocolors'
-import { detectProject } from '../context.js'
+import { detectProject, hasMonorepoSpreePath } from '../context.js'
import { dockerCompose } from '../docker.js'
export function registerBuildCommand(program: Command): void {
@@ -15,6 +15,18 @@ export function registerBuildCommand(program: Command): void {
.option('--yes', 'skip confirmation prompts (for CI)')
.action(async (flags: { resetBundle?: boolean; yes?: boolean }) => {
const ctx = detectProject()
+
+ if (hasMonorepoSpreePath(ctx.projectDir)) {
+ p.cancel(
+ [
+ 'This project uses SPREE_PATH for monorepo development.',
+ `Use ${pc.bold('pnpm server:build')} from the monorepo root instead of ${pc.bold('spree build')}.`,
+ 'It builds against the edge compose overlay the running stack was started with.',
+ ].join('\n'),
+ )
+ process.exit(1)
+ }
+
// Always build against the active docker-compose.yml — the same file
// `spree dev` runs. After `spree eject` that contains a `build:` section
// pointing at ./backend; before eject, it's a prebuilt-image stack and
diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts
index ec617c1bdb..5ef69dc9dc 100644
--- a/packages/cli/src/commands/dev.ts
+++ b/packages/cli/src/commands/dev.ts
@@ -1,16 +1,14 @@
-import fs from 'node:fs'
-import path from 'node:path'
import * as p from '@clack/prompts'
import type { Command } from 'commander'
import pc from 'picocolors'
import { DEFAULT_ADMIN_EMAIL, DEFAULT_ADMIN_PASSWORD } from '../constants.js'
-import { detectProject } from '../context.js'
-import { dockerCompose, streamLogs } from '../docker.js'
+import { detectProject, hasMonorepoSpreePath } from '../context.js'
+import { dockerCompose } from '../docker.js'
export function registerDevCommand(program: Command): void {
program
.command('dev')
- .description('Start services and stream logs')
+ .description('Run the app in the foreground — streams web + worker logs; Ctrl+C stops them')
.action(async () => {
const ctx = detectProject()
@@ -18,18 +16,13 @@ export function registerDevCommand(program: Command): void {
p.cancel(
[
'This project uses SPREE_PATH for monorepo development.',
- `Use ${pc.bold('pnpm server:start')} from the monorepo root instead of ${pc.bold('spree dev')}.`,
+ `Use ${pc.bold('pnpm server:dev')} from the monorepo root instead of ${pc.bold('spree dev')}.`,
'It loads the edge compose overlay and sets SPREE_PATH so the Spree gems resolve to the monorepo source.',
].join('\n'),
)
process.exit(1)
}
- const s = p.spinner()
- s.start('Starting Docker services...')
- await dockerCompose(['up', '-d'], ctx.projectDir)
- s.stop('Docker services started.')
-
p.note(
[
'',
@@ -45,18 +38,39 @@ export function registerDevCommand(program: Command): void {
'Spree Commerce',
)
- p.log.info('Streaming logs (Ctrl+C to stop)...\n')
- await streamLogs('web', ctx.projectDir)
- })
-}
+ p.log.info(
+ `Starting services — web + worker logs stream below. ${pc.bold('Ctrl+C')} stops them ` +
+ `(databases keep running; ${pc.bold('spree stop')} shuts everything down).\n`,
+ )
+
+ // Foreground `up`, like `vite dev`: Ctrl+C delivers SIGINT to compose,
+ // which gracefully stops web + worker. Dependency services (postgres,
+ // redis, meilisearch) start via depends_on but stay up afterwards.
+ // Ignore SIGINT in the CLI itself so compose owns the shutdown and we
+ // live to print the outro.
+ const ignoreSigint = () => {}
+ process.on('SIGINT', ignoreSigint)
+ let result: { exitCode?: number }
+ try {
+ result = await dockerCompose(['up', 'web', 'worker'], ctx.projectDir, {
+ stdio: 'inherit',
+ reject: false,
+ })
+ } finally {
+ process.off('SIGINT', ignoreSigint)
+ }
+
+ // Ctrl+C lands in compose as SIGINT → graceful stop, exit code 130.
+ // Anything else non-zero is a real failure (daemon down, bad config,
+ // port conflict) — surface it instead of pretending shutdown was clean.
+ const exitCode = result.exitCode ?? 0
+ if (exitCode !== 0 && exitCode !== 130) {
+ p.cancel(`docker compose exited with code ${exitCode} — see the output above.`)
+ process.exit(exitCode)
+ }
-function hasMonorepoSpreePath(projectDir: string): boolean {
- const envPath = path.join(projectDir, '.env')
- if (!fs.existsSync(envPath)) return false
- try {
- const contents = fs.readFileSync(envPath, 'utf-8')
- return /^\s*SPREE_PATH\s*=/m.test(contents)
- } catch {
- return false
- }
+ p.outro(
+ `Web + worker stopped. Databases keep running — ${pc.bold('spree stop')} shuts everything down.`,
+ )
+ })
}
diff --git a/packages/cli/src/context.ts b/packages/cli/src/context.ts
index 87e89077aa..2c2b684576 100644
--- a/packages/cli/src/context.ts
+++ b/packages/cli/src/context.ts
@@ -22,6 +22,23 @@ export function detectProject(cwd: string = process.cwd()): ProjectContext {
}
}
+// Monorepo edge projects (SPREE_PATH in .env) are booted from the monorepo
+// root with the dev + edge compose overlay — the project-local
+// docker-compose.yml the CLI would target is not the running config.
+// Commands that materialize compose config (up, build) must refuse here;
+// label-based commands (exec, stop, restart, logs) resolve the same
+// compose project either way and keep working.
+export function hasMonorepoSpreePath(projectDir: string): boolean {
+ const envPath = path.join(projectDir, '.env')
+ if (!fs.existsSync(envPath)) return false
+ try {
+ const contents = fs.readFileSync(envPath, 'utf-8')
+ return /^\s*SPREE_PATH\s*=/m.test(contents)
+ } catch {
+ return false
+ }
+}
+
export function readPortFromEnv(projectDir: string): number {
const envPath = path.join(projectDir, '.env')
diff --git a/packages/create-spree-app/src/templates/readme.ts b/packages/create-spree-app/src/templates/readme.ts
index 6c1995c734..d59dd75fd7 100644
--- a/packages/create-spree-app/src/templates/readme.ts
+++ b/packages/create-spree-app/src/templates/readme.ts
@@ -65,7 +65,7 @@ This project uses [\`@spree/cli\`](https://www.npmjs.com/package/@spree/cli) to
| Command | Description |
|---------|-------------|
-| \`spree dev\` | Start backend services and stream logs |
+| \`spree dev\` | Run the backend in the foreground — streams logs, Ctrl+C stops it |
| \`spree stop\` | Stop backend services |
| \`spree update\` | Pull latest Spree image and restart (runs migrations automatically) |
| \`spree eject\` | Switch from prebuilt image to building from \`backend/\` |
diff --git a/packages/dashboard/README.md b/packages/dashboard/README.md
index 1b17010f0c..1b08cee060 100644
--- a/packages/dashboard/README.md
+++ b/packages/dashboard/README.md
@@ -67,8 +67,8 @@ The admin needs a running Spree backend exposing the Admin API. The simplest set
```bash
# 1. Boot a Spree server (from the monorepo root)
-pnpm server:setup # one-time: clones spree-starter into ./server
-pnpm server:dev # runs Rails on http://localhost:3000
+pnpm server:setup # one-time bootstrap: clones spree-starter into ./server, boots the stack, prepares the DB
+pnpm server:dev # foreground; streams logs — Rails on http://localhost:3000 (Ctrl+C stops it)
# 2. In a separate terminal, run the admin dev server
cd packages/dashboard
diff --git a/scripts/server-setup.sh b/scripts/server-setup.sh
index 3628d822c9..e50eaf7f4e 100755
--- a/scripts/server-setup.sh
+++ b/scripts/server-setup.sh
@@ -58,7 +58,9 @@ step "Building @spree/cli (so node ../packages/cli/dist/index.js works)"
pnpm --filter @spree/cli build
step "Starting the edge stack"
-pnpm server:start
+# Detached on purpose — `pnpm server:dev` runs the stack in the foreground
+# (streaming logs, Ctrl+C to stop); setup needs to continue past the boot.
+SPREE_PATH="$ROOT" docker compose -f "$DEV_COMPOSE" -f "$EDGE_OVERLAY" up -d --force-recreate web worker
step "Waiting for web container to come up"
WAIT_TIMEOUT=120