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.

Make the seller panel runnable in a worktree

Damian Legawiecbf18c0ac27a5
diff --git a/CLAUDE.md b/CLAUDE.md
index c341bfeff9..4803ac357d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -114,6 +114,7 @@ Development happens in **git worktrees** — every worktree is a self-contained
wt switch -c feature-x # create worktree + provisioned environment (~20 s)
pnpm wt:dev # Rails → https://feature-x.spree.localhost (/up, /api/v3, /jobs; jobs run inside Puma via Solid Queue)
pnpm wt:dashboard # admin UI → https://admin.feature-x.spree.localhost
+pnpm wt:seller # seller panel → https://sellers.feature-x.spree.localhost
pnpm wt:e2e [spec...] # Playwright on this worktree's own port block
pnpm wt:template # rebuild the template DB after schema-changing pulls
wt merge main # ship + clean up (worktree, branch and databases all removed)
@@ -563,6 +564,11 @@ pnpm wt:dev # foreground; streams logs — https://<branch>.spree.lo
# 2. Boot the admin (separate terminal)
pnpm wt:dashboard # https://admin.<branch>.spree.localhost (proxies /api/* to this worktree's Rails)
+
+# 3. Boot the marketplace seller panel (third terminal, optional)
+pnpm wt:seller # https://sellers.<branch>.spree.localhost
+# Seed a seller to sign in as:
+# cd server && bin/rails spree:sellers:sample_data → [email protected] / spree123
```
The starter is the canonical host — the same app `spree add dashboard` scaffolds — so local dev exercises the real consumer path (shell + plugin pipeline) while still hot-reloading `@spree/dashboard`/`-core`/`-ui` source through the workspace. Building the workspace deps first matters on a fresh worktree: the starter's `vite.config.ts` resolves the compiled Node-side Vite entries (`@spree/dashboard/vite`, `@spree/dashboard-core/vite`) from `dist/` — `pnpm wt:dashboard` handles this (turbo builds the dependency graph, then starts Vite on the portless-assigned port).
diff --git a/package.json b/package.json
index 0d72fd1461..e77011bb6c 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"wt:template": "scripts/worktree/make-template.sh",
"wt:dev": "scripts/worktree/dev.sh",
"wt:dashboard": "scripts/worktree/dev-dashboard.sh",
+ "wt:seller": "scripts/worktree/dev-seller.sh",
"wt:e2e": "scripts/worktree/e2e.sh",
"changeset": "changeset",
"version:preview": "changeset version --ignore @spree/sdk"
diff --git a/scripts/worktree/dev-seller.sh b/scripts/worktree/dev-seller.sh
new file mode 100755
index 0000000000..b2d93429ed
--- /dev/null
+++ b/scripts/worktree/dev-seller.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# Start this worktree's seller panel (Vite) behind portless, proxying API
+# calls to this worktree's Rails URL. URL: https://sellers.<branch>.spree.localhost
+#
+# The seller panel is its own app, not a route inside the operator's
+# dashboard, so it runs as a second process on its own host — sign in as a
+# seller here, as marketplace staff on the admin host.
+#
+# Vite ignores the PORT env var, so we build the panel's workspace deps with
+# turbo first, then run vite directly with the portless-assigned port.
+set -euo pipefail
+source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh"
+require_portless
+cd "$(worktree_root)"
+
+export VITE_API_PROXY_TARGET
+VITE_API_PROXY_TARGET="$(rails_url)"
+
+pnpm turbo build --filter='@spree/seller-dashboard-starter^...'
+
+cd packages/seller-dashboard-starter
+echo "▸ $(seller_url) (proxying /api → $VITE_API_PROXY_TARGET)"
+exec portless "$(seller_name)" sh -c 'exec pnpm vite --port "$PORT" --strictPort'
diff --git a/scripts/worktree/lib.sh b/scripts/worktree/lib.sh
index 795b5c7be9..9202ca5445 100755
--- a/scripts/worktree/lib.sh
+++ b/scripts/worktree/lib.sh
@@ -74,6 +74,10 @@ rails_name() { echo "$(branch_slug).spree"; }
dashboard_name() { echo "admin.$(branch_slug).spree"; }
rails_url() { echo "https://$(rails_name).localhost$(url_suffix)"; }
dashboard_url() { echo "https://$(dashboard_name).localhost$(url_suffix)"; }
+# The marketplace seller panel — a separate app from the operator's dashboard,
+# so it gets its own host rather than a route inside it.
+seller_name() { echo "sellers.$(branch_slug).spree"; }
+seller_url() { echo "https://$(seller_name).localhost$(url_suffix)"; }
# RAILS_HOST wants a bare host with an optional port, no scheme.
rails_host() { echo "$(rails_name).localhost$(url_suffix)"; }
diff --git a/spree/core/lib/tasks/seller_sample_data.rake b/spree/core/lib/tasks/seller_sample_data.rake
new file mode 100644
index 0000000000..f364492e58
--- /dev/null
+++ b/spree/core/lib/tasks/seller_sample_data.rake
@@ -0,0 +1,34 @@
+namespace :spree do
+ namespace :sellers do
+ desc 'Create a sample seller with a signed-in owner and a pending invitation, for trying the seller panel'
+ task sample_data: :environment do
+ store = Spree::Store.default || Spree::Store.first
+ abort 'No store found — run db:seed first.' if store.nil?
+
+ email = ENV.fetch('SELLER_EMAIL', '[email protected]')
+ password = ENV.fetch('SELLER_PASSWORD', 'spree123')
+
+ seller = Spree::Seller.find_or_initialize_by(name: ENV.fetch('SELLER_NAME', 'Bright Sparks'), store: store)
+ seller.save! if seller.new_record?
+ seller.update!(status: 'approved') unless seller.approved?
+
+ owner = Spree.admin_user_class.find_or_initialize_by(email: email)
+ owner.password = password
+ owner.first_name ||= 'Ada'
+ owner.last_name ||= 'Lovelace'
+ owner.save!
+ seller.add_user(owner)
+
+ # One outstanding offer, so the panel's pending-invitations card has
+ # something to show without having to send an email first.
+ invitee = ENV.fetch('SELLER_INVITEE', '[email protected]')
+ unless seller.invitations.pending.exists?(email: invitee)
+ seller.invitations.create!(email: invitee, role: seller.default_user_role, inviter: owner)
+ end
+
+ puts "Seller: #{seller.name} (#{seller.prefixed_id}, #{seller.status})"
+ puts "Sign in: #{email} / #{password}"
+ puts "Pending: #{seller.invitations.pending.pluck(:email).join(', ')}"
+ end
+ end
+end