@spree/cli 2.3.8 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.js +189 -167
- package/dist/templates/dashboard-starter/.env.example +4 -0
- package/dist/templates/dashboard-starter/README.md +36 -0
- package/dist/templates/dashboard-starter/biome.json +60 -0
- package/dist/templates/dashboard-starter/gitignore.template +6 -0
- package/dist/templates/dashboard-starter/index.html +27 -0
- package/dist/templates/dashboard-starter/package.json +33 -0
- package/dist/templates/dashboard-starter/src/main.tsx +30 -0
- package/dist/templates/dashboard-starter/src/plugins.ts +19 -0
- package/dist/templates/dashboard-starter/src/routeTree.gen.ts +1140 -0
- package/dist/templates/dashboard-starter/src/styles.css +8 -0
- package/dist/templates/dashboard-starter/tsconfig.json +20 -0
- package/dist/templates/dashboard-starter/vite.config.ts +33 -0
- package/dist/templates/plugin/LICENSE.tt +3 -0
- package/dist/templates/plugin/README.md.tt +52 -0
- package/dist/templates/plugin/package.json.tt +19 -0
- package/dist/templates/plugin/packages/dashboard/biome.json +24 -0
- package/dist/templates/plugin/packages/dashboard/package.json.tt +49 -0
- package/dist/templates/plugin/packages/dashboard/src/client.ts.tt +29 -0
- package/dist/templates/plugin/packages/dashboard/src/index.tsx.tt +89 -0
- package/dist/templates/plugin/packages/dashboard/src/locales/en.json.tt +25 -0
- package/dist/templates/plugin/packages/dashboard/src/pages/{{name}}-list.tsx.tt +50 -0
- package/dist/templates/plugin/packages/dashboard/src/routes/{{name}}.index.tsx.tt +26 -0
- package/dist/templates/plugin/packages/dashboard/src/slots/product-{{name}}-card.tsx.tt +33 -0
- package/dist/templates/plugin/packages/dashboard/src/types.ts.tt +17 -0
- package/dist/templates/plugin/packages/dashboard/tsconfig.json +26 -0
- package/dist/templates/plugin/pnpm-workspace.yaml +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Spree Dashboard Starter
|
|
2
|
+
|
|
3
|
+
The host app for the [Spree React Dashboard](https://spreecommerce.org/docs/developer/dashboard/overview) — the admin for your Spree store. `@spree/dashboard` is the actual app shell (routes, chrome, resource pages); this project is your customization point: plugins, your own pages, theming, and deployment config.
|
|
4
|
+
|
|
5
|
+
> **Monorepo note.** The canonical source of this template lives at `packages/dashboard-starter` in [spree/spree](https://github.com/spree/spree), where its Spree dependencies resolve via the pnpm workspace and `@spree/dashboard-plugin-example` is installed as a devDependency — booting it here doubles as the end-to-end test for the plugin pipeline. At build time, `@spree/cli` and `create-spree-app` embed a standalone rendering of it (workspace deps rewritten to the published versions — see `scripts/sync-dashboard-starter.mjs`), which is what `spree add dashboard` and the create-spree-app dashboard prompt scaffold from.
|
|
6
|
+
|
|
7
|
+
## Develop
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm install
|
|
11
|
+
cp .env.example .env.local # point VITE_SPREE_API_URL at your Spree API
|
|
12
|
+
pnpm dev # http://localhost:5173
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Sign in with an admin account — authentication is interactive (JWT + refresh cookie). No API keys belong in `.env.local`: every `VITE_`-prefixed value is compiled into the client bundle.
|
|
16
|
+
|
|
17
|
+
## Install a dashboard plugin
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @acme/reviews-plugin
|
|
21
|
+
# restart the dev server
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
That's the whole install. `spreeDashboardPlugin()` (see `vite.config.ts`) discovers any dependency carrying the `spree.dashboard.plugin` marker, activates it through the `virtual:spree-dashboard-plugins` module imported in `src/main.tsx`, and wires its Tailwind classes.
|
|
25
|
+
|
|
26
|
+
## Customize
|
|
27
|
+
|
|
28
|
+
`src/plugins.ts` is yours — register nav entries, routes, slot widgets, and table columns with `defineDashboardPlugin` from `@spree/dashboard-core`. Same API the distributed plugins use; see the [customization quickstart](https://spreecommerce.org/docs/developer/dashboard/customization/quickstart).
|
|
29
|
+
|
|
30
|
+
## Build & deploy
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm build # static assets in dist/
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Deploy `dist/` to any static host. Set `VITE_SPREE_API_URL` to your production API at build time, and configure the API's CORS/cookie settings for the dashboard origin.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"linter": {
|
|
9
|
+
"enabled": true,
|
|
10
|
+
"rules": {
|
|
11
|
+
"recommended": true,
|
|
12
|
+
"correctness": {
|
|
13
|
+
"noUnusedImports": "warn",
|
|
14
|
+
"noUnusedVariables": "warn"
|
|
15
|
+
},
|
|
16
|
+
"suspicious": {
|
|
17
|
+
"noExplicitAny": "off"
|
|
18
|
+
},
|
|
19
|
+
"style": {
|
|
20
|
+
"noNonNullAssertion": "off"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"formatter": {
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"indentStyle": "space",
|
|
27
|
+
"indentWidth": 2,
|
|
28
|
+
"lineWidth": 100
|
|
29
|
+
},
|
|
30
|
+
"javascript": {
|
|
31
|
+
"formatter": {
|
|
32
|
+
"quoteStyle": "single",
|
|
33
|
+
"semicolons": "asNeeded"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"css": {
|
|
37
|
+
"linter": {
|
|
38
|
+
"enabled": false
|
|
39
|
+
},
|
|
40
|
+
"formatter": {
|
|
41
|
+
"enabled": false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"assist": {
|
|
45
|
+
"actions": {
|
|
46
|
+
"source": {
|
|
47
|
+
"organizeImports": "on"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": {
|
|
52
|
+
"includes": [
|
|
53
|
+
"src/**",
|
|
54
|
+
"*.ts",
|
|
55
|
+
"index.html",
|
|
56
|
+
"!src/routeTree.gen.ts",
|
|
57
|
+
"!src/**/*.css"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Spree Admin</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<script>
|
|
10
|
+
(() => {
|
|
11
|
+
try {
|
|
12
|
+
const stored = localStorage.getItem('spree-admin-theme');
|
|
13
|
+
const mode = stored === 'light' || stored === 'dark' ? stored : 'system';
|
|
14
|
+
const dark =
|
|
15
|
+
mode === 'dark' ||
|
|
16
|
+
(mode === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
17
|
+
if (dark) document.documentElement.classList.add('dark');
|
|
18
|
+
document.documentElement.style.colorScheme = dark ? 'dark' : 'light';
|
|
19
|
+
} catch (_) {
|
|
20
|
+
/* localStorage unavailable */
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
23
|
+
</script>
|
|
24
|
+
<div id="root"></div>
|
|
25
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spree/dashboard-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"version": "0.0.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"lint": "biome check .",
|
|
13
|
+
"lint:fix": "biome check --fix ."
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@spree/admin-sdk": "^0.5.0",
|
|
17
|
+
"@spree/dashboard": "^0.10.0",
|
|
18
|
+
"@spree/dashboard-core": "^0.10.0",
|
|
19
|
+
"@spree/dashboard-ui": "^0.10.0",
|
|
20
|
+
"@tanstack/react-query": "^5.100.9",
|
|
21
|
+
"@tanstack/react-router": "^1.169.2",
|
|
22
|
+
"react": "^19.2.6",
|
|
23
|
+
"react-dom": "^19.2.6"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@biomejs/biome": "^2.4.14",
|
|
27
|
+
"@types/react": "^19.2.14",
|
|
28
|
+
"@types/react-dom": "^19.2.3",
|
|
29
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
30
|
+
"typescript": "~6.0.3",
|
|
31
|
+
"vite": "^8.0.16"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The shell module runs the i18n/nav/search bootstrap on import — it must
|
|
2
|
+
// execute before the plugin imports below so plugins can call i18n.t at
|
|
3
|
+
// module load. (Side-effect imports are ordering barriers.)
|
|
4
|
+
import { createDashboardRouter, Dashboard } from '@spree/dashboard'
|
|
5
|
+
import { createRoot } from 'react-dom/client'
|
|
6
|
+
// Activate installed dashboard plugins — synthesized by spreeDashboardPlugin()
|
|
7
|
+
// from your package.json deps. `pnpm add <plugin>` + dev-server restart is the
|
|
8
|
+
// whole install; this line never changes.
|
|
9
|
+
import 'virtual:spree-dashboard-plugins'
|
|
10
|
+
// Your own customizations (nav entries, routes, slot widgets, table columns).
|
|
11
|
+
import './plugins'
|
|
12
|
+
import './styles.css'
|
|
13
|
+
// Generated by @spree/dashboard/vite on every dev start and build: the
|
|
14
|
+
// shell's routes composed with every installed plugin's file routes. Commit
|
|
15
|
+
// it — its diff on upgrades shows exactly which admin pages changed.
|
|
16
|
+
import { routeTree } from './routeTree.gen'
|
|
17
|
+
|
|
18
|
+
// basepath mirrors Vite's `base` so sub-path mounts (/dashboard on the
|
|
19
|
+
// single-node topology) route correctly; '/' in dev and root deploys.
|
|
20
|
+
const router = createDashboardRouter(routeTree, { basepath: import.meta.env.BASE_URL })
|
|
21
|
+
|
|
22
|
+
// Registers the composed router program-wide so <Link> and navigation are
|
|
23
|
+
// type-checked against the real route tree — shell, host, and plugin routes.
|
|
24
|
+
declare module '@tanstack/react-router' {
|
|
25
|
+
interface Register {
|
|
26
|
+
router: typeof router
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
createRoot(document.getElementById('root')!).render(<Dashboard router={router} />)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Dashboard customizations for this store.
|
|
2
|
+
//
|
|
3
|
+
// Register nav entries, routes, slot widgets, and table columns against the
|
|
4
|
+
// shared registries — the same API distributed plugins use. Imported once
|
|
5
|
+
// from main.tsx, before the dashboard renders.
|
|
6
|
+
//
|
|
7
|
+
// Example:
|
|
8
|
+
//
|
|
9
|
+
// import { defineDashboardPlugin } from '@spree/dashboard-core'
|
|
10
|
+
// import { AnalyticsPage } from './pages/analytics'
|
|
11
|
+
//
|
|
12
|
+
// defineDashboardPlugin({
|
|
13
|
+
// nav: [{ key: 'analytics', label: 'Analytics', path: '/analytics', position: 60 }],
|
|
14
|
+
// routes: [{ key: 'analytics', path: '/analytics', component: AnalyticsPage }],
|
|
15
|
+
// })
|
|
16
|
+
//
|
|
17
|
+
// Docs: https://spreecommerce.org/docs/developer/dashboard/customization/quickstart
|
|
18
|
+
|
|
19
|
+
export {}
|