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.

Fix CLI and CLAUDE.md

Damian Legawiec687117692c68
diff --git a/.changeset/cli-drop-admin-stylesheets.md b/.changeset/cli-drop-admin-stylesheets.md
index 54da45a14e..a8e432f2ed 100644
--- a/.changeset/cli-drop-admin-stylesheets.md
+++ b/.changeset/cli-drop-admin-stylesheets.md
@@ -2,8 +2,11 @@
'@spree/cli': major
---
-Dropped the admin stylesheet steps from `spree dev` and `spree eject`.
+Dropped the legacy Rails admin from the CLI.
-The legacy Rails admin (`spree_admin`) is removed in Spree 6.0, and with it the `spree:admin:tailwindcss:build` and `spree:admin:tailwindcss:watch` rake tasks these steps invoked. On an ejected project, `spree dev` no longer compiles `spree/admin/application.css` before boot or starts the Tailwind watcher, and `spree eject` no longer compiles it during setup.
+`spree_admin` is removed in Spree 6.0, so the CLI no longer references it:
-Admin UI now ships as the React dashboard, which builds through Vite — run it with `spree dev` (co-runs the dashboard dev server) or `spree add dashboard`. Projects ejected before this release can delete the orphaned `backend/app/assets/builds/spree/admin/` directory.
+- `spree dev` and `spree eject` no longer compile the admin Tailwind stylesheet or start its watcher — the `spree:admin:tailwindcss:build` and `spree:admin:tailwindcss:watch` rake tasks went with the gem.
+- `spree dev`, `spree init` and `spree open` no longer point at `http://localhost:<port>/admin`, which now 404s. With a dashboard app present they open its Vite dev server; without one they open the store, and the summary card says to run `spree add dashboard`.
+
+Admin UI now ships as the React dashboard. Run it with `spree dev` (co-runs the dashboard dev server) or add it with `spree add dashboard`. Projects ejected before this release can delete the orphaned `backend/app/assets/builds/spree/admin/` directory.
diff --git a/CLAUDE.md b/CLAUDE.md
index b3f38f408d..e673abde17 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -512,11 +512,10 @@ The starter is the canonical host — the same app `spree add dashboard` scaffol
**When implementing a new admin feature:**
1. **The Admin API is the only data source.** Never reach into Rails models or import server-rendered HTML. If a needed endpoint or attribute is missing, add it to `spree/api` first (see backend conventions above), regenerate types via the [Type Generation Pipeline](#type-generation-pipeline), then consume it from the SPA.
-2. **Look at the legacy Rails admin in `spree/admin/`** for what the feature does today (data shape, business rules, edge cases) — but don't port the UX 1:1. The SPA can do better than Turbo-era full-page reloads where it meaningfully improves the experience.
-3. **Follow `docs/plans/6.0-admin-spa.md`** for the three extension points (table registry, navigation registry, component injection) and the shadcn copy-paste ownership model.
-4. **Wrap SDK calls in custom hooks** under `src/hooks/` (e.g. `useOrders`, `useProduct`) — never call `adminClient` directly from components.
+2. **Follow `docs/plans/6.0-admin-spa.md`** for the three extension points (table registry, navigation registry, component injection) and the shadcn copy-paste ownership model.
+3. **Wrap SDK calls in custom hooks** under `src/hooks/` (e.g. `useOrders`, `useProduct`) — never call `adminClient` directly from components.
-**Translations.** Every user-visible string in `@spree/dashboard` goes through i18next — page titles, headings, table column labels, button labels, empty states, toast messages, confirm dialog copy, select option labels, badges, status text, tooltips, helper text. Never hardcode English (or any language) into JSX, into table column definitions, or into dropdown option arrays. Keys live in `packages/dashboard/src/locales/en.json` (app-specific copy) or `packages/dashboard-core/src/locales/en.json` (cross-cutting: `admin.common.*`, `admin.fields.<attribute>.<facet>`). Reach for `i18n.t(...)` at module load (table definitions) and `useTranslation().t(...)` inside components. **Schemas in `src/schemas/` hold canonical values only — never label strings.** Build `{ value, label }` pairs at render time inside the component by mapping the canonical value list against translation keys. Same goes for the legacy Rails admin: every label/hint goes through `Spree.t` / `I18n.t` against `spree/admin/config/locales/en.yml`; run `bundle exec i18n-tasks normalize` after adding keys. When adding a new translation key, ALWAYS add it to the all languages files in `packages/dashboard/src/locales/` and `packages/dashboard-core/src/locales/`.
+**Translations.** Every user-visible string in `@spree/dashboard` goes through i18next — page titles, headings, table column labels, button labels, empty states, toast messages, confirm dialog copy, select option labels, badges, status text, tooltips, helper text. Never hardcode English (or any language) into JSX, into table column definitions, or into dropdown option arrays. Keys live in `packages/dashboard/src/locales/en.json` (app-specific copy) or `packages/dashboard-core/src/locales/en.json` (cross-cutting: `admin.common.*`, `admin.fields.<attribute>.<facet>`). Reach for `i18n.t(...)` at module load (table definitions) and `useTranslation().t(...)` inside components. **Schemas in `src/schemas/` hold canonical values only — never label strings.** Build `{ value, label }` pairs at render time inside the component by mapping the canonical value list against translation keys. When adding a new translation key, ALWAYS add it to the all languages files in `packages/dashboard/src/locales/` and `packages/dashboard-core/src/locales/`.
**Forms.** Raw React Hook Form with `<Field>` / `<Input>` / `<FieldError>` blocks. Drive each input explicitly with `form.register(...)` or a `<Controller>` for custom widgets so the form reads top-to-bottom. Wrap RHF's `handleSubmit` with a try/catch that calls `mapSpreeErrorsToForm` (`@/lib/form-errors`) to route 422 responses onto `form.formState.errors`: flat attribute keys become field errors with `aria-invalid` + `<FieldError>`; `:base` and nested keys land on `errors.root.message` so render a destructive banner at the top of the form.
diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts
index 31493abc4d..1ef593ddc8 100644
--- a/packages/cli/src/commands/dev.ts
+++ b/packages/cli/src/commands/dev.ts
@@ -99,11 +99,11 @@ export function registerDevCommand(program: Command): void {
` ${pc.cyan(`http://localhost:${DASHBOARD_PORT}`)}`,
` Email: ${DEFAULT_ADMIN_EMAIL}`,
` Password: ${DEFAULT_ADMIN_PASSWORD}`,
- ` ${pc.dim(`Live-reloading from apps/dashboard/ — classic admin: http://localhost:${ctx.port}/admin`)}`,
+ ` ${pc.dim('Live-reloading from apps/dashboard/')}`,
]
: [
pc.bold('Admin Dashboard'),
- ` ${pc.cyan(`http://localhost:${ctx.port}/admin`)}`,
+ ` ${pc.dim(`Not installed — add it with ${pc.bold('spree add dashboard')}`)}`,
` Email: ${DEFAULT_ADMIN_EMAIL}`,
` Password: ${DEFAULT_ADMIN_PASSWORD}`,
]),
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index ee4e9d4f0a..bd38b04b62 100644
--- a/packages/cli/src/commands/init.ts
+++ b/packages/cli/src/commands/init.ts
@@ -103,12 +103,12 @@ export async function runFirstRunSetup(flags: {
// With the React Dashboard chosen, its dev server IS the admin — started
// below alongside the stack, so what the user customizes is what they use.
- // One admin block; the classic admin gets a one-line pointer. (The
- // production image serves the built dashboard at /dashboard — a deployment
+ // One admin block: the dev server is the only admin URL worth naming. (The
+ // production image serves a built dashboard at /dashboard — a deployment
// detail, not a dev-flow concept.) The summary, --open, and the spawn all
// key off the same runnable check so they can't disagree — if the dev
- // server can't start (deps install failed above), the card leads with the
- // classic admin instead of advertising a dead URL.
+ // server can't start (deps install failed above), the card says how to
+ // install it instead of advertising a dead URL.
const dashboardRunnable = dashboardDevRunnable(ctx.projectDir)
if (hasDashboardApp(ctx.projectDir) && !dashboardRunnable) {
warnDashboardNotRunnable(ctx.projectDir)
@@ -119,11 +119,11 @@ export async function runFirstRunSetup(flags: {
` ${pc.cyan(`http://localhost:${DASHBOARD_PORT}`)}`,
` Email: ${DEFAULT_ADMIN_EMAIL}`,
` Password: ${DEFAULT_ADMIN_PASSWORD}`,
- ` ${pc.dim(`Live-reloading from apps/dashboard/ — classic admin: http://localhost:${ctx.port}/admin`)}`,
+ ` ${pc.dim('Live-reloading from apps/dashboard/')}`,
]
: [
pc.bold('Admin Dashboard'),
- ` ${pc.cyan(`http://localhost:${ctx.port}/admin`)}`,
+ ` ${pc.dim(`Not installed — add it with ${pc.bold('spree add dashboard')}`)}`,
` Email: ${DEFAULT_ADMIN_EMAIL}`,
` Password: ${DEFAULT_ADMIN_PASSWORD}`,
]
@@ -176,8 +176,10 @@ export async function runFirstRunSetup(flags: {
try {
if (flags.open) {
// With the dashboard, wait for Vite to report ready (it auto-bumps the
- // port when 5173 is taken) so the browser opens the real URL.
- await openBrowser(dashboard ? await dashboard.url : `http://localhost:${ctx.port}/admin`)
+ // port when 5173 is taken) so the browser opens the real URL. Without
+ // one there's no admin to open in development, so fall back to the
+ // store itself.
+ await openBrowser(dashboard ? await dashboard.url : `http://localhost:${ctx.port}`)
}
p.log.info('Streaming logs (Ctrl+C to stop)...\n')
diff --git a/packages/cli/src/commands/open.ts b/packages/cli/src/commands/open.ts
index 908879b7c1..71a5aae817 100644
--- a/packages/cli/src/commands/open.ts
+++ b/packages/cli/src/commands/open.ts
@@ -1,7 +1,9 @@
import { platform } from 'node:os'
import type { Command } from 'commander'
import { execaCommand } from 'execa'
+import { DASHBOARD_PORT } from '../constants.js'
import { detectProject } from '../context.js'
+import { hasDashboardApp } from '../dashboard-server.js'
export function registerOpenCommand(program: Command): void {
program
@@ -9,7 +11,12 @@ export function registerOpenCommand(program: Command): void {
.description('Open the admin dashboard in the browser')
.action(async () => {
const ctx = detectProject()
- const url = `http://localhost:${ctx.port}/admin`
+ // The React dashboard runs on its own Vite server (`spree dev`). Without
+ // one, open the store: /dashboard serves a production build and isn't a
+ // development target.
+ const url = hasDashboardApp(ctx.projectDir)
+ ? `http://localhost:${DASHBOARD_PORT}`
+ : `http://localhost:${ctx.port}`
const os = platform()
const cmd = os === 'darwin' ? 'open' : os === 'win32' ? 'start' : 'xdg-open'
await execaCommand(`${cmd} ${url}`)