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.

Release the dashboard packages as a 0.x Developer Preview

Damian Legawiec899c4c9fea5d
diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml
index ec5aec5b42..cd4be088c1 100644
--- a/.github/workflows/packages.yml
+++ b/.github/workflows/packages.yml
@@ -362,6 +362,119 @@ jobs:
if: steps.check.outputs.published == 'false'
run: pnpm publish --provenance --access public --tag ${{ steps.tag.outputs.tag }} --no-git-checks
+ # The dashboard packages are source-only (they ship src/, no build step) and
+ # depend on each other via workspace:^, which `pnpm publish` rewrites to the
+ # concrete ^x.y.z while packing — so they publish in dependency order from a
+ # single job. Pre-1.0 Developer Preview versions ship under the `next` tag,
+ # matching @spree/admin-sdk.
+ release-dashboard:
+ name: "Dashboard packages - Release"
+ needs: check
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: write
+ id-token: write
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: pnpm/action-setup@v6
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: pnpm
+ registry-url: https://registry.npmjs.org
+
+ - run: pnpm install --frozen-lockfile
+
+ # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
+ # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
+ # npm's own files in place and the in-flight install can't find
+ # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
+ # to a separate prefix and prepend to PATH instead.
+ - name: Upgrade npm for Trusted Publishing support
+ run: |
+ npm install -g npm@latest --prefix="$HOME/.npm-global"
+ echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
+
+ - name: Publish unpublished versions (dependency order)
+ run: |
+ set -euo pipefail
+ for pkg in dashboard-ui dashboard-core dashboard; do
+ cd "packages/$pkg"
+ NAME=$(node -p "require('./package.json').name")
+ VERSION=$(node -p "require('./package.json').version")
+ if npm view "$NAME@$VERSION" version 2>/dev/null; then
+ echo "$NAME@$VERSION already published — skipping."
+ else
+ if echo "$VERSION" | grep -qE '^0\.'; then TAG=next
+ elif echo "$VERSION" | grep -qE '[-]'; then TAG=beta
+ else TAG=latest
+ fi
+ echo "Publishing $NAME@$VERSION with tag $TAG..."
+ pnpm publish --provenance --access public --tag "$TAG" --no-git-checks
+ fi
+ cd ../..
+ done
+
+ # Push the monorepo-canonical packages/dashboard-starter out to the
+ # spree/dashboard-starter template repo (what `spree add dashboard` and
+ # create-spree-app clone). Runs after release-dashboard so the rewritten
+ # `^x.y.z` pins always reference versions that exist on npm. Requires the
+ # DASHBOARD_STARTER_SYNC_TOKEN secret: a fine-grained PAT with contents
+ # write on spree/dashboard-starter.
+ sync-dashboard-starter:
+ name: "dashboard-starter - Sync template repo"
+ needs: release-dashboard
+ if: github.repository == 'spree/spree' && github.ref == 'refs/heads/main' && github.event_name == 'push'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+
+ - name: Check sync token
+ id: token
+ env:
+ SYNC_TOKEN: ${{ secrets.DASHBOARD_STARTER_SYNC_TOKEN }}
+ run: |
+ if [ -z "$SYNC_TOKEN" ]; then
+ echo "DASHBOARD_STARTER_SYNC_TOKEN is not configured — skipping sync."
+ echo "present=false" >> $GITHUB_OUTPUT
+ else
+ echo "present=true" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Clone template repo
+ if: steps.token.outputs.present == 'true'
+ env:
+ SYNC_TOKEN: ${{ secrets.DASHBOARD_STARTER_SYNC_TOKEN }}
+ run: git clone "https://x-access-token:${SYNC_TOKEN}@github.com/spree/dashboard-starter.git" /tmp/dashboard-starter
+
+ - name: Sync starter into the template working tree
+ if: steps.token.outputs.present == 'true'
+ run: node scripts/sync-dashboard-starter.mjs /tmp/dashboard-starter
+
+ - name: Commit and push
+ if: steps.token.outputs.present == 'true'
+ working-directory: /tmp/dashboard-starter
+ run: |
+ git config user.name "spree-releases"
+ git config user.email "[email protected]"
+ git add -A
+ if git diff --cached --quiet; then
+ echo "Template repo already up to date."
+ exit 0
+ fi
+ git commit -m "Sync from spree/spree@${{ github.sha }}"
+ git push origin HEAD:main
+
release-create-spree-app:
name: "create-spree-app - Release"
needs: check
diff --git a/.gitignore b/.gitignore
index 0423e579bf..038d485b18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,7 @@ server/
package-lock.json
packages/*/package-lock.json
.turbo
+.tanstack
packages/*/dist
.claude/worktrees
*.tsbuildinfo
diff --git a/CLAUDE.md b/CLAUDE.md
index 9d02e2d889..3bfdb97c87 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -39,7 +39,7 @@ Multi-version plans (some phases shipped, some pending):
- `6.0-order-routing.md` — Two-tier extension: pluggable `Spree::OrderRouting::Strategy::Base` + STI subclasses of `Spree::OrderRoutingRule`. Phase 1 (5.5) shipped: `Channel`, `OrderRoutingRule`, strategy base + Rules + Reducer + Legacy, `preferred_stock_location_id` + `channel_id` on Order. Phase 2+ (6.0) layers Catalog/Company on top via `6.0-channels-catalogs-b2b.md`.
- `6.0-channels-catalogs-b2b.md` — Channel + ProductPublication (replaces StoreProduct) + single-owner Product (`belongs_to :store`) + Publishing card (legacy admin + SPA) + `Channel#default` boolean shipped in 5.5. Channel-level gated storefront access (`storefront_access` enum + channel-owned `guest_checkout`, both with store fallback, enforced in the v3 Store API) targeted for 5.6. Catalog, Company/CompanyLocation/CompanyContact for B2B pending in 6.0. Multi-store catalogs (historic `Product has_many :stores`) move to the `spree_multi_store` extension.
- `5.6-6.0-single-store-promotions-payment-methods.md` — Migrate `Spree::Promotion` + `Spree::PaymentMethod` from multi-store (`has_many :stores` via `spree_promotions_stores` / `spree_payment_methods_stores` join tables) to single-owner `belongs_to :store`, mirroring the 5.5 single-owner Product migration. 5.6 (implemented): `store_id` FK + required-store presence via `Spree::SingleStoreResource`, backfill rake task (loud per-record deprecation on shared records), shared `LegacyMultiStoreSupport` deprecation bridge, deletes the `ResourceController` `store_ids=` seam, deprecates `StoreScopedResource`; multi-store sharing moves to the `spree_multi_store` extension (join tables left intact). 6.0 cleanup: enforce `null: false`, drop join tables + bridges. Paired with `6.0-channels-catalogs-b2b.md`.
-- `5.6-project-layout-and-dashboard.md` — React Dashboard Developer Preview packaging + `backend/` → `api/` project layout. Implemented: `<Dashboard />` shell export from `@spree/dashboard` (source-only, relative imports only), monorepo-canonical `packages/dashboard-starter` thin host (synced to the `spree/dashboard-starter` template repo on release), `spree add dashboard` + create-spree-app dashboard phase (env carries only `VITE_SPREE_API_URL` — never secret keys). Pending: layout rename + `detectApiDir` dual-layout CLI, `spree upgrade layout`, template sync job.
+- `5.6-project-layout-and-dashboard.md` — React Dashboard Developer Preview packaging + `backend/` → `api/` project layout. Implemented: `<Dashboard />` shell export from `@spree/dashboard` (source-only, relative imports only), monorepo-canonical `packages/dashboard-starter` thin host (synced to the `spree/dashboard-starter` template repo on release), `spree add dashboard` + create-spree-app dashboard phase (env carries only `VITE_SPREE_API_URL` — never secret keys), npm release job for `@spree/dashboard{,-ui,-core}` (0.x → `next` tag) + template sync job. Pending: layout rename + `detectApiDir` dual-layout CLI, `spree upgrade layout`.
- `5.6-dashboard-typed-plugin-routes.md` — Plugin file routes compiled into the host's TanStack route tree: `spree.dashboard.routes` marker + virtual-route-config composition in `@spree/dashboard/vite`, `createDashboardRouter` + `<Dashboard router>` ownership inversion, typed cast-free links, cross-package collision pre-flight with package-named errors. Runtime route registry stays for dynamic/in-app cases (catch-all is lowest priority). Implemented; published-tarball spike passed.
Pending design work (drafts, no implementation yet):
diff --git a/docs/plans/5.6-project-layout-and-dashboard.md b/docs/plans/5.6-project-layout-and-dashboard.md
index 7d050a5268..c9bb308b43 100644
--- a/docs/plans/5.6-project-layout-and-dashboard.md
+++ b/docs/plans/5.6-project-layout-and-dashboard.md
@@ -470,12 +470,12 @@ All phases ship in **5.6**. The dashboard ships as Developer Preview alongside `
3. Add an `exports` map to `package.json` (`.` → shell export, `./styles.css`).
4. Teach `spreeDashboardPlugin()` to scan `@spree/dashboard` for Tailwind classes when installed (optional resolution — silent for custom dashboards without the shell).
-### Phase 3: Create `packages/dashboard-starter` *(implemented)* + sync job
+### Phase 3: Create `packages/dashboard-starter` *(implemented, incl. sync job)*
1. Scaffold the thin host in the monorepo per the shape above, with `workspace:^` deps. It compiles `<Dashboard />` from source and (dev-only) activates `@spree/dashboard-plugin-example` through auto-discovery — the standing consumer test for the plugin pipeline.
2. Write minimal Vite config that proxies to `localhost:3000` in dev. The proxy path is irrelevant to the Rails directory name — it's an HTTP URL.
3. Write README covering: dev workflow, installing plugins, `plugins.ts` customizations, deploying.
-4. Add the release sync job: copy to `spree/dashboard-starter`, rewrite `workspace:^` → published versions, strip monorepo-only devDeps, push. Mark the target as a GitHub template repository.
+4. Add the release sync job *(implemented — `sync-dashboard-starter` in `packages.yml` + `scripts/sync-dashboard-starter.mjs`; runs after the npm release job so version pins always resolve; also inlines the workspace `biome.json`)*. Manual one-time setup: create the `spree/dashboard-starter` repo, mark it as a GitHub template, and add the `DASHBOARD_STARTER_SYNC_TOKEN` secret (fine-grained PAT, contents write). Note: the first npm publish of `@spree/dashboard{,-ui,-core}` must be manual (Trusted Publishing can only be configured once a package exists).
5. Add CI on the template repo: typecheck, build, e2e smoke test against a Dockerized Spree backend.
### Phase 4: Rename `backend/` → `api/` in create-spree-app (new projects only)
diff --git a/packages/dashboard-core/.changeset/config.json b/packages/dashboard-core/.changeset/config.json
new file mode 100644
index 0000000000..0fbbd8c795
--- /dev/null
+++ b/packages/dashboard-core/.changeset/config.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
+ "changelog": ["@changesets/changelog-github", { "repo": "spree/spree" }],
+ "commit": false,
+ "fixed": [],
+ "linked": [],
+ "access": "public",
+ "baseBranch": "main",
+ "updateInternalDependencies": "patch",
+ "ignore": []
+}
diff --git a/packages/dashboard-core/LICENSE b/packages/dashboard-core/LICENSE
new file mode 100644
index 0000000000..fbaaca776c
--- /dev/null
+++ b/packages/dashboard-core/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 Vendo Connect Inc., Vendo Sp. z o.o.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/packages/dashboard-core/package.json b/packages/dashboard-core/package.json
index e79b715935..db4aaf3b54 100644
--- a/packages/dashboard-core/package.json
+++ b/packages/dashboard-core/package.json
@@ -1,9 +1,24 @@
{
"name": "@spree/dashboard-core",
- "private": true,
"license": "MIT",
- "version": "0.0.0",
- "description": "Spree Dashboard framework — registries (table, nav, slot, settings-nav), providers (auth, permission, store), admin SDK client, generic infra hooks, and the defineDashboardPlugin extension API.",
+ "version": "0.1.0",
+ "description": "Spree Dashboard framework — registries (table, nav, slot, settings-nav), providers (auth, permission, store), admin SDK client, generic infra hooks, and the defineDashboardPlugin extension API. Developer Preview.",
+ "author": "Vendo Connect Inc.",
+ "homepage": "https://spreecommerce.org",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/spree/spree.git",
+ "directory": "packages/dashboard-core"
+ },
+ "keywords": [
+ "spree",
+ "commerce",
+ "ecommerce",
+ "admin",
+ "dashboard",
+ "react",
+ "plugin"
+ ],
"type": "module",
"main": "./src/index.ts",
"module": "./src/index.ts",
@@ -21,7 +36,8 @@
},
"files": [
"src",
- "README.md"
+ "README.md",
+ "LICENSE"
],
"scripts": {
"lint": "biome check src",
diff --git a/packages/dashboard-starter/.gitignore b/packages/dashboard-starter/.gitignore
index c2458765e8..c2dad0cbfa 100644
--- a/packages/dashboard-starter/.gitignore
+++ b/packages/dashboard-starter/.gitignore
@@ -1,5 +1,6 @@
node_modules/
dist/
+.tanstack/
.env.local
.env.*.local
*.log
diff --git a/packages/dashboard-starter/src/plugins.ts b/packages/dashboard-starter/src/plugins.ts
index ff7e0e3c49..97f293ca7f 100644
--- a/packages/dashboard-starter/src/plugins.ts
+++ b/packages/dashboard-starter/src/plugins.ts
@@ -14,6 +14,6 @@
// routes: [{ key: 'analytics', path: '/analytics', component: AnalyticsPage }],
// })
//
-// Docs: https://docs.spreecommerce.org/developer/dashboard/customization/quickstart
+// Docs: https://spreecommerce.org/docs/developer/dashboard/customization/quickstart
export {}
diff --git a/packages/dashboard-starter/vite.config.ts b/packages/dashboard-starter/vite.config.ts
index 0806465d42..5a9380fbe2 100644
--- a/packages/dashboard-starter/vite.config.ts
+++ b/packages/dashboard-starter/vite.config.ts
@@ -6,9 +6,10 @@ export default defineConfig({
// spreeDashboardPlugin bundles Tailwind, injects @source directives for
// every Spree dashboard package, auto-discovers installed dashboard
// plugins (package.json deps carrying the `spree.dashboard.plugin`
- // marker), and serves the `virtual:spree-dashboard-plugins` module that
- // src/main.tsx imports to activate them. No TanStack Router plugin needed:
- // the route tree ships pre-generated inside @spree/dashboard.
+ // marker), serves the `virtual:spree-dashboard-plugins` module that
+ // src/main.tsx imports to activate them, and composes the shell's and
+ // every plugin's file routes into src/routeTree.gen.ts on each dev
+ // start/build — commit that file; its diff shows what an upgrade added.
plugins: [spreeDashboardPlugin(), react()],
// Proxy /api to the Rails server so the SPA is same-origin with the API in
// dev — keeps the refresh-token cookie working under SameSite=Lax without
diff --git a/packages/dashboard-ui/.changeset/config.json b/packages/dashboard-ui/.changeset/config.json
new file mode 100644
index 0000000000..0fbbd8c795
--- /dev/null
+++ b/packages/dashboard-ui/.changeset/config.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
+ "changelog": ["@changesets/changelog-github", { "repo": "spree/spree" }],
+ "commit": false,
+ "fixed": [],
+ "linked": [],
+ "access": "public",
+ "baseBranch": "main",
+ "updateInternalDependencies": "patch",
+ "ignore": []
+}
diff --git a/packages/dashboard-ui/LICENSE b/packages/dashboard-ui/LICENSE
new file mode 100644
index 0000000000..fbaaca776c
--- /dev/null
+++ b/packages/dashboard-ui/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 Vendo Connect Inc., Vendo Sp. z o.o.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/packages/dashboard-ui/package.json b/packages/dashboard-ui/package.json
index d3179999d1..81c675543e 100644
--- a/packages/dashboard-ui/package.json
+++ b/packages/dashboard-ui/package.json
@@ -1,9 +1,23 @@
{
"name": "@spree/dashboard-ui",
- "private": true,
"license": "MIT",
- "version": "0.0.0",
- "description": "Spree Dashboard design system — shadcn primitives, headless composed components, and design tokens. Source-only package; consumers compile via their own Vite/Tailwind setup.",
+ "version": "0.1.0",
+ "description": "Spree Dashboard design system — shadcn primitives, headless composed components, and design tokens. Source-only package; consumers compile via their own Vite/Tailwind setup. Developer Preview.",
+ "author": "Vendo Connect Inc.",
+ "homepage": "https://spreecommerce.org",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/spree/spree.git",
+ "directory": "packages/dashboard-ui"
+ },
+ "keywords": [
+ "spree",
+ "commerce",
+ "ecommerce",
+ "admin",
+ "dashboard",
+ "react"
+ ],
"type": "module",
"main": "./src/index.ts",
"module": "./src/index.ts",
@@ -18,7 +32,8 @@
},
"files": [
"src",
- "README.md"
+ "README.md",
+ "LICENSE"
],
"scripts": {
"lint": "biome check src",
diff --git a/packages/dashboard/.changeset/config.json b/packages/dashboard/.changeset/config.json
new file mode 100644
index 0000000000..0fbbd8c795
--- /dev/null
+++ b/packages/dashboard/.changeset/config.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
+ "changelog": ["@changesets/changelog-github", { "repo": "spree/spree" }],
+ "commit": false,
+ "fixed": [],
+ "linked": [],
+ "access": "public",
+ "baseBranch": "main",
+ "updateInternalDependencies": "patch",
+ "ignore": []
+}
diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json
index 33e70b5415..0d2d9b8d7a 100644
--- a/packages/dashboard/package.json
+++ b/packages/dashboard/package.json
@@ -1,8 +1,23 @@
{
"name": "@spree/dashboard",
- "private": true,
"license": "MIT",
- "version": "0.0.0",
+ "version": "0.1.0",
+ "description": "Spree Dashboard app shell — the next-gen React admin for Spree Commerce. Routes, resource hooks, schemas, locales, and the <Dashboard /> component. Source-only package; hosts compile it via @spree/dashboard/vite. Developer Preview.",
+ "author": "Vendo Connect Inc.",
+ "homepage": "https://spreecommerce.org",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/spree/spree.git",
+ "directory": "packages/dashboard"
+ },
+ "keywords": [
+ "spree",
+ "commerce",
+ "ecommerce",
+ "admin",
+ "dashboard",
+ "react"
+ ],
"type": "module",
"exports": {
".": "./src/index.ts",
@@ -13,7 +28,8 @@
},
"files": [
"src",
- "README.md"
+ "README.md",
+ "LICENSE"
],
"scripts": {
"dev": "vite",
diff --git a/scripts/sync-dashboard-starter.mjs b/scripts/sync-dashboard-starter.mjs
new file mode 100644
index 0000000000..17e575695d
--- /dev/null
+++ b/scripts/sync-dashboard-starter.mjs
@@ -0,0 +1,96 @@
+#!/usr/bin/env node
+// Sync packages/dashboard-starter (the monorepo-canonical source) into a
+// working clone of the spree/dashboard-starter template repo, rewriting the
+// bits that only make sense inside the monorepo:
+//
+// - `workspace:^` dependency ranges → `^<version>` of the published packages
+// - monorepo-only devDependencies dropped (the example plugin isn't on npm)
+// - biome.json extends the workspace root config → replaced with a
+// self-contained equivalent
+//
+// Everything else copies verbatim, including src/routeTree.gen.ts (committed
+// by design — its diff on upgrade shows which admin pages changed).
+//
+// Usage: node scripts/sync-dashboard-starter.mjs <target-dir>
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
+const starterDir = path.join(repoRoot, 'packages', 'dashboard-starter')
+
+const target = process.argv[2]
+if (!target) {
+ console.error('Usage: node scripts/sync-dashboard-starter.mjs <target-dir>')
+ process.exit(2)
+}
+const targetDir = path.resolve(target)
+if (!fs.existsSync(targetDir)) {
+ console.error(`Target directory does not exist: ${targetDir}`)
+ process.exit(2)
+}
+
+const EXCLUDE = new Set(['node_modules', 'dist', '.turbo', '.tanstack'])
+const MONOREPO_ONLY_DEV_DEPS = new Set(['@spree/dashboard-plugin-example'])
+
+// Clear the target working tree (keep .git) so deletions in the monorepo
+// propagate instead of accumulating stale files.
+for (const entry of fs.readdirSync(targetDir)) {
+ if (entry === '.git') continue
+ fs.rmSync(path.join(targetDir, entry), { recursive: true, force: true })
+}
+
+fs.cpSync(starterDir, targetDir, {
+ recursive: true,
+ filter: (src) => !EXCLUDE.has(path.basename(src)),
+})
+
+// --- package.json: pin published versions -----------------------------------
+
+function publishedRange(name) {
+ const dir = name.replace('@spree/', '')
+ const manifestPath = path.join(repoRoot, 'packages', dir, 'package.json')
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
+ if (manifest.private) {
+ throw new Error(`${name} is private — it can't be a dependency of the synced template`)
+ }
+ return `^${manifest.version}`
+}
+
+const pkgPath = path.join(targetDir, 'package.json')
+const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
+for (const section of ['dependencies', 'devDependencies']) {
+ const deps = pkg[section]
+ if (!deps) continue
+ for (const [name, range] of Object.entries(deps)) {
+ if (MONOREPO_ONLY_DEV_DEPS.has(name)) {
+ delete deps[name]
+ } else if (typeof range === 'string' && range.startsWith('workspace:')) {
+ deps[name] = publishedRange(name)
+ }
+ }
+}
+fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
+
+// --- biome.json: inline the workspace root config ----------------------------
+
+const rootBiome = JSON.parse(fs.readFileSync(path.join(repoRoot, 'biome.json'), 'utf8'))
+const starterBiome = JSON.parse(fs.readFileSync(path.join(starterDir, 'biome.json'), 'utf8'))
+const standaloneBiome = {
+ $schema: rootBiome.$schema,
+ vcs: rootBiome.vcs,
+ linter: rootBiome.linter,
+ formatter: rootBiome.formatter,
+ javascript: rootBiome.javascript,
+ css: rootBiome.css,
+ assist: rootBiome.assist,
+ // The starter's own file list (routeTree.gen.ts stays excluded); the
+ // monorepo root's list is irrelevant outside the workspace.
+ files: starterBiome.files,
+}
+fs.writeFileSync(
+ path.join(targetDir, 'biome.json'),
+ `${JSON.stringify(standaloneBiome, null, 2)}\n`,
+)
+
+console.log(`Synced ${starterDir} → ${targetDir}`)