@spree/cli 2.4.4 → 2.4.5

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 CHANGED
@@ -1,24 +1,8 @@
1
1
  # @spree/cli
2
2
 
3
- CLI for managing [Spree Commerce](https://spreecommerce.org) projects.
3
+ CLI for managing [Spree Commerce](https://spreecommerce.org) projects — Docker-based dev stack, generators, API keys, and a gh-style Admin API client.
4
4
 
5
- Automatically included in projects created with [`create-spree-app`](https://www.npmjs.com/package/create-spree-app). Can also be installed standalone.
6
-
7
- ## Installation
8
-
9
- Already included when you scaffold a project with `create-spree-app`. To install separately:
10
-
11
- ```bash
12
- npm install @spree/cli
13
- ```
14
-
15
- Or run directly with npx:
16
-
17
- ```bash
18
- npx @spree/cli <command>
19
- ```
20
-
21
- Or install globally:
5
+ Automatically included in projects created with [`create-spree-app`](https://spreecommerce.org/docs/developer/create-spree-app/quickstart). Can also be installed standalone:
22
6
 
23
7
  ```bash
24
8
  npm install -g @spree/cli
@@ -27,220 +11,31 @@ spree <command>
27
11
 
28
12
  ## Commands
29
13
 
30
- Run these from your Spree project directory.
31
-
32
- ### `spree dev`
33
-
34
- Run the app in the foreground — prints connection info, then streams web + worker logs (like `vite dev`).
35
-
36
- ```bash
37
- spree dev
38
- ```
39
-
40
- Press `Ctrl+C` to stop web + worker. The databases (postgres, redis, meilisearch) keep running for a fast next boot — `spree stop` shuts everything down.
41
-
42
- ### `spree stop`
43
-
44
- Stop all running services.
45
-
46
- ```bash
47
- spree stop
48
- ```
49
-
50
- ### `spree update`
51
-
52
- Pull the latest Spree Docker image and recreate containers. Database migrations run automatically on startup via `db:prepare`.
53
-
54
- ```bash
55
- spree update
56
- ```
57
-
58
- To pin a specific version, edit `SPREE_VERSION_TAG` in your `.env` file:
59
-
60
- ```
61
- SPREE_VERSION_TAG=5.4
62
- ```
63
-
64
- ### `spree eject`
65
-
66
- Switch from the prebuilt Docker image to building from your local `backend/` directory. This lets you customize the Rails app — add gems, override models, add migrations, etc.
67
-
68
- ```bash
69
- spree eject
70
- ```
71
-
72
- After ejecting, edit files in `backend/` and run `spree dev` to rebuild and restart.
73
-
74
- ### `spree logs [service]`
75
-
76
- Stream logs from a service. Defaults to `web`.
77
-
78
- ```bash
79
- spree logs # web server logs
80
- spree logs worker # background job logs
81
- ```
82
-
83
- ### `spree console`
84
-
85
- Open an interactive Rails console inside the running container.
86
-
87
- ```bash
88
- spree console
89
- ```
90
-
91
- ### `spree shell`
92
-
93
- Open an interactive bash shell inside the web container. If the container is down, a one-off container is started against the same volumes instead.
94
-
95
- ```bash
96
- spree shell
97
- spree bash # alias
98
- ```
99
-
100
- ### `spree rspec`
101
-
102
- Run the RSpec test suite inside the web container with `RAILS_ENV=test`. Everything after `rspec` is passed through to RSpec.
103
-
104
- ```bash
105
- spree rspec # full suite
106
- spree rspec spec/models/product_spec.rb # one file
107
- spree rspec spec/models/product_spec.rb:15 # one example
108
- spree rspec --format documentation
109
- ```
110
-
111
- Before the first run, create the test database with `spree rails db:test:prepare`.
112
-
113
- ### `spree user create`
114
-
115
- Create an admin user. Prompts interactively for email and password, or accepts flags for scripting.
116
-
117
- ```bash
118
- # Interactive
119
- spree user create
120
-
121
- # Non-interactive
122
- spree user create --email admin@example.com --password secret123
123
- ```
124
-
125
- The user is automatically assigned the `admin` role on the default store.
126
-
127
- ### `spree api-key create`
128
-
129
- Create a Store API (publishable) or Admin API (secret) key. Prompts interactively for name and type, or accepts flags.
130
-
131
- ```bash
132
- # Interactive
133
- spree api-key create
134
-
135
- # Non-interactive
136
- spree api-key create --name "My Storefront" --type publishable
137
- spree api-key create --name "Admin Integration" --type secret --scopes read_orders,write_products
138
- ```
139
-
140
- Secret keys require at least one scope (`read_all` for a read-only key, `write_all` for full access, or granular `read_*`/`write_*` pairs).
141
-
142
- **Important:** Secret key tokens are displayed only once at creation time and cannot be retrieved later. Save them immediately.
143
-
144
- ### `spree api-key list`
145
-
146
- List all API keys for the default store with their name, type, token/prefix, creation date, and status.
147
-
148
- ```bash
149
- spree api-key list
150
- ```
151
-
152
- ### `spree api-key revoke`
153
-
154
- Revoke an API key by its token (publishable) or token prefix (secret).
155
-
156
- ```bash
157
- spree api-key revoke pk_abc123def456...
158
- ```
159
-
160
- ### `spree api`
161
-
162
- Call the Admin API directly with generic `get`/`post`/`patch`/`delete` commands. Works against any Spree 5.5+ instance — inside a project it self-provisions a **read-only** key via the dev stack on first use (saved to `.spree/credentials.json`, gitignored). For other servers set `SPREE_API_KEY` (the host defaults to `http://localhost:3000`; add `SPREE_BASE_URL` for a remote store) or save a profile with `spree auth login`.
163
-
164
- ```bash
165
- spree api get /products -q status_eq=active --sort -created_at --limit 10
166
- spree api get /orders/ord_x8k2J9aQ --expand items,payments
167
- spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
168
- spree api patch /orders/ord_x8k2J9aQ/cancel
169
- spree api delete /products/prod_86Rf07xd
170
-
171
- spree api endpoints --resource orders # endpoints + required scopes (offline)
172
- spree api schema "POST /orders" # request/response schema (offline)
173
- spree api status # resolved credentials + server check
174
- ```
175
-
176
- Output is JSON on stdout — indented and colored in a terminal, compact and uncolored when piped (so it feeds cleanly into `jq`). `--format table` renders collections for humans. `--fields name,price` trims the response (the `id` is always included). API errors exit `1` with the error envelope on stderr — scope denials include the exact `--scopes` remediation.
177
-
178
- ### `spree completion`
179
-
180
- Output a shell completion script (`bash`, `zsh`, or `fish`). Tab-completion suggests resource paths, Ransack predicate stems, and scope names — offline from the bundled spec.
181
-
182
- ```bash
183
- eval "$(spree completion zsh)" # add to ~/.zshrc (bash/fish also supported)
184
- ```
185
-
186
- ### `spree auth`
187
-
188
- Manage saved Admin API credentials for remote stores (profiles in `~/.config/spree/config.json`).
189
-
190
- ```bash
191
- spree auth login --profile prod --base-url https://store.example.com # key read from a prompt
192
- spree api get /orders --profile prod
193
- spree auth status
194
- spree auth list
195
- spree auth logout --profile prod
196
- ```
197
-
198
- ### `spree seed`
199
-
200
- Run database seeds.
201
-
202
- ```bash
203
- spree seed
204
- ```
205
-
206
- ### `spree sample-data`
207
-
208
- Load sample products, categories, customers, and images.
209
-
210
- ```bash
211
- spree sample-data
212
- ```
213
-
214
- ## How It Works
215
-
216
- The CLI detects your project by looking for `docker-compose.yml` in the current directory. All commands execute via `docker compose` against the running Spree containers.
217
-
218
- - **Port** is read from `SPREE_PORT` in your `.env` file (default: `3000`)
219
- - **User and API key commands** run Ruby scripts via `docker compose exec web bin/rails runner`
220
- - **Service commands** (`dev`, `stop`, `update`) are thin wrappers around `docker compose`
221
-
222
- ## Using with npm scripts
223
-
224
- Projects created with `create-spree-app` include convenience scripts in `package.json`:
225
-
226
- ```bash
227
- npm run dev # spree dev
228
- npm run stop # spree stop
229
- npm run update # spree update
230
- npm run eject # spree eject
231
- npm run logs # spree logs
232
- npm run logs:worker # spree logs worker
233
- npm run console # spree console
234
- npm run seed # spree seed
235
- npm run load-sample-data # spree sample-data
236
- ```
237
-
238
- ## Learn More
239
-
240
- - [Spree Documentation](https://spreecommerce.org/docs)
241
- - [Store API Reference](https://spreecommerce.org/docs/api-reference/introduction)
242
- - [create-spree-app](https://www.npmjs.com/package/create-spree-app)
243
- - [Spree GitHub](https://github.com/spree/spree)
14
+ Run from your Spree project directory:
15
+
16
+ | Command | Description |
17
+ |---------|-------------|
18
+ | `spree dev` | Run the app in the foreground — streams logs, Ctrl+C stops it. First run completes setup automatically; co-runs the React Dashboard dev server when `apps/dashboard` exists |
19
+ | `spree stop` | Stop backend services |
20
+ | `spree update` | Pull the latest Spree image and restart (runs migrations automatically) |
21
+ | `spree eject` | Switch from the prebuilt image to building from `backend/` |
22
+ | `spree add dashboard` | Add the React Dashboard (Developer Preview) to an existing project |
23
+ | `spree build --production` | Build the production image — the Spree API plus your dashboard, in one |
24
+ | `spree console` / `spree shell` / `spree logs` | Rails console, container shell, log tailing |
25
+ | `spree migrate` / `spree seed` / `spree sample-data` | Database tasks |
26
+ | `spree generate …` | Spree generators (models, API resources, subscribers, migrations) |
27
+ | `spree user create` / `spree api-key …` | Admin users and scoped API keys |
28
+ | `spree api get/post/patch/delete <path>` | Call the Admin API directly (`spree api endpoints` lists routes + scopes) |
29
+ | `spree rspec` | Run the backend test suite inside the container |
30
+
31
+ ## Documentation
32
+
33
+ The full command reference lives on the docs site — this README intentionally stays short:
34
+
35
+ - [CLI quickstart](https://spreecommerce.org/docs/developer/cli/quickstart)
36
+ - [Admin API from the CLI](https://spreecommerce.org/docs/developer/cli/admin-api) — credentials, scopes, profiles
37
+ - [create-spree-app](https://spreecommerce.org/docs/developer/create-spree-app/quickstart)
38
+ - [Deployment](https://spreecommerce.org/docs/developer/deployment/docker)
244
39
 
245
40
  ## License
246
41