@spree/docs 0.1.295 → 0.1.297
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/dist/developer/cli/quickstart.md +18 -16
- package/dist/developer/core-concepts/translations.md +28 -7
- package/dist/developer/create-spree-app/quickstart.md +3 -3
- package/dist/developer/customization/checkout.md +1 -1
- package/dist/developer/how-to/custom-api-authentication.md +2 -2
- package/dist/developer/upgrades/5.6-to-6.0.md +15 -2
- package/dist/developer/upgrades/quickstart.md +32 -0
- package/package.json +1 -1
|
@@ -76,14 +76,6 @@ spree restart
|
|
|
76
76
|
|
|
77
77
|
Not appropriate for Gemfile changes (use `spree bundle install`, then Ctrl+C and re-run `spree dev`), Dockerfile / `.ruby-version` changes (use `spree build`), or compose file changes (Ctrl+C and re-run `spree dev`).
|
|
78
78
|
|
|
79
|
-
### `spree update`
|
|
80
|
-
|
|
81
|
-
Pull the latest Spree Docker image and recreate containers. Migrations run automatically on startup.
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
spree update
|
|
85
|
-
```
|
|
86
|
-
|
|
87
79
|
### `spree build`
|
|
88
80
|
|
|
89
81
|
Rebuild the dev image after Dockerfile or `.ruby-version` changes. Only relevant after `spree eject`.
|
|
@@ -100,17 +92,27 @@ spree build --yes # Skip confirmation prompts (for CI)
|
|
|
100
92
|
|
|
101
93
|
### `spree upgrade`
|
|
102
94
|
|
|
103
|
-
|
|
95
|
+
Upgrade your project to the latest Spree release in one go. It works for both kinds of project:
|
|
96
|
+
|
|
97
|
+
1. **Update the server**
|
|
98
|
+
- On a project that runs the prebuilt image, it pulls the latest Spree image and recreates the containers. Database migrations run as the containers start.
|
|
99
|
+
- On an [ejected](#spree-eject) project, it updates the Spree gems with `bundle update`, applies pending migrations, and restarts the app so it loads the new gems.
|
|
100
|
+
2. **Run data backfills** — the version-specific steps from the upgrade manifest that convert existing records.
|
|
101
|
+
3. **Update the `@spree/*` packages** — `@spree/cli` in the project root, and the dashboard packages and Admin SDK in `apps/dashboard` and `apps/seller-dashboard`. Each package moves to the newest release its declared range in `package.json` allows, the same way `bundle update` respects your `Gemfile`. To move to a new major version, change the range in `package.json` first.
|
|
104
102
|
|
|
105
103
|
```bash
|
|
106
|
-
spree upgrade #
|
|
107
|
-
spree upgrade --plan #
|
|
108
|
-
spree upgrade --to
|
|
109
|
-
spree upgrade --step <id> # Re-run a single
|
|
110
|
-
spree upgrade --yes # Skip the
|
|
104
|
+
spree upgrade # Run every step, asking before each one
|
|
105
|
+
spree upgrade --plan # List the data backfills without running anything
|
|
106
|
+
spree upgrade --to 6.1 # Set the target version for the data backfills
|
|
107
|
+
spree upgrade --step <id> # Re-run a single data backfill (runs nothing else)
|
|
108
|
+
spree upgrade --yes # Skip the prompts
|
|
111
109
|
```
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
Your storefront is your own code, so `spree upgrade` does not change it — it tells you which `@spree/sdk` version to move to.
|
|
112
|
+
|
|
113
|
+
Production upgrades only need the data backfills — installing gems and migrating happen in your deploy pipeline. See [Upgrades](../upgrades.md) for the manual production path.
|
|
114
|
+
|
|
115
|
+
> **NOTE:** `spree update` is the old name for this command. It still works, prints a deprecation warning, and will be removed in a future release.
|
|
114
116
|
|
|
115
117
|
### `spree eject`
|
|
116
118
|
|
|
@@ -204,7 +206,7 @@ spree encryption init # Add ACTIVE_RECORD_ENCRYPTION_* keys to the pr
|
|
|
204
206
|
spree encryption init --print # Print a fresh set without writing anything (e.g. for your hosting provider)
|
|
205
207
|
```
|
|
206
208
|
|
|
207
|
-
It never overwrites keys `.env` already sets, and there is no `--force`: changing the keys makes data encrypted with them unreadable. Afterwards, recreate the containers so they load the new `.env` (`spree
|
|
209
|
+
It never overwrites keys `.env` already sets, and there is no `--force`: changing the keys makes data encrypted with them unreadable. Afterwards, recreate the containers so they load the new `.env` (`spree dev` — `spree restart` keeps the old environment), and back the keys up in your secret manager.
|
|
208
210
|
|
|
209
211
|
### `spree api`
|
|
210
212
|
|
|
@@ -116,21 +116,42 @@ Asking the API which resources are translatable means a translation tool doesn't
|
|
|
116
116
|
|
|
117
117
|
## Translating the interface
|
|
118
118
|
|
|
119
|
-
Spree's own
|
|
119
|
+
Spree's own text — transactional emails, API error messages and validation messages — ships translated into 43 languages besides English as part of Spree itself. There is nothing to install. A key that a language does not translate yet is shown in English.
|
|
120
120
|
|
|
121
|
+
The admin dashboard carries its own translations, separate from these. See [Dashboard translations](../dashboard/customization/translations.md).
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
Regional variants such as `de-CH` or `pt-BR` hold only what differs from their base language and fall back to it. Regional English (`en-GB` and the like) falls back to `en`.
|
|
124
|
+
|
|
125
|
+
### Using fewer languages
|
|
126
|
+
|
|
127
|
+
Loading every language costs startup time and memory. An app that serves only some languages can list them, and Spree then loads only those, plus English:
|
|
128
|
+
|
|
129
|
+
```ruby server/config/application.rb
|
|
130
|
+
config.i18n.available_locales = [:en, :de, :fr]
|
|
124
131
|
```
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
### Changing a translation
|
|
134
|
+
|
|
135
|
+
> **TIP:** To change what a customer email says, edit it in the dashboard under **Settings → Emails → Templates** instead. Edits apply per store and per language, and need no deploy. See [Templates merchants edit in the dashboard](../customization/emails.md#templates-merchants-edit-in-the-dashboard) and the [Emails user guide](/user/settings/emails).
|
|
136
|
+
|
|
137
|
+
Locale files are for the text the dashboard does not edit: API error messages, checkout requirements, validation messages and staff emails. To change a word or add a language, add the key to a locale file in your app. Your file wins over the one Spree ships.
|
|
138
|
+
|
|
139
|
+
```yaml server/config/locales/de.yml
|
|
140
|
+
de:
|
|
141
|
+
spree:
|
|
142
|
+
checkout_requirements:
|
|
143
|
+
email_required: Bitte geben Sie Ihre E-Mail-Adresse ein
|
|
128
144
|
```
|
|
129
145
|
|
|
146
|
+
Every key lives under `spree`. To read one from your own Ruby code, use its full key:
|
|
147
|
+
|
|
148
|
+
```ruby server/app/services/my_app/checkout_check.rb
|
|
149
|
+
I18n.t('spree.checkout_requirements.email_required')
|
|
150
|
+
```
|
|
130
151
|
|
|
131
|
-
|
|
152
|
+
> **INFO:** `Spree.t` still works in 6.0 but is deprecated and will be removed in 6.1. Use `I18n.t` with the full `spree.` key instead.
|
|
132
153
|
|
|
133
|
-
|
|
154
|
+
Corrections to the translations Spree ships are welcome as pull requests to the locale files in the [Spree repository](https://github.com/spree/spree/tree/main/spree/core/config/locales).
|
|
134
155
|
|
|
135
156
|
## Related
|
|
136
157
|
|
|
@@ -111,7 +111,7 @@ The project includes [@spree/cli](../cli/quickstart.md) for managing your Spree
|
|
|
111
111
|
|---------|-------------|
|
|
112
112
|
| `spree dev` | Run the app in the foreground — streams logs, Ctrl+C stops it. First run completes setup automatically; co-runs the Admin Dashboard dev server when `apps/dashboard` exists |
|
|
113
113
|
| `spree stop` | Stop backend services |
|
|
114
|
-
| `spree
|
|
114
|
+
| `spree upgrade` | Upgrade Spree — the server, database and `@spree/*` packages |
|
|
115
115
|
| `spree eject` | Switch from prebuilt image to building from `server/` |
|
|
116
116
|
| `spree add dashboard` | Add the Admin Dashboard to an existing project, to customize it |
|
|
117
117
|
| `spree add seller-dashboard` | Add the marketplace seller panel to an existing project |
|
|
@@ -148,10 +148,10 @@ Open [http://localhost:3001](http://localhost:3001) to see your store.
|
|
|
148
148
|
To update to the latest Spree version:
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
|
-
spree
|
|
151
|
+
spree upgrade
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
This
|
|
154
|
+
This updates the server (the Docker image, or the Spree gems on an ejected project), runs database migrations and data backfills, and updates the `@spree/*` packages of the project and its dashboard apps. See [`spree upgrade`](../cli/quickstart.md#spree-upgrade) for details.
|
|
155
155
|
|
|
156
156
|
To pin a specific version, edit `SPREE_VERSION_TAG` in `.env`:
|
|
157
157
|
|
|
@@ -53,7 +53,7 @@ that doesn't apply never appears at all:
|
|
|
53
53
|
applicable: ->(cart) { cart.customer&.company.present? }
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
`message` is stored verbatim — wrap it in `
|
|
56
|
+
`message` is stored verbatim — wrap it in `I18n.t` yourself if it needs translating.
|
|
57
57
|
|
|
58
58
|
## Adding a step
|
|
59
59
|
|
|
@@ -76,7 +76,7 @@ module MyApp
|
|
|
76
76
|
|
|
77
77
|
def authenticate
|
|
78
78
|
token = params[:token] || extract_bearer
|
|
79
|
-
return failure(
|
|
79
|
+
return failure(I18n.t('spree.api.unauthorized')) if token.blank?
|
|
80
80
|
|
|
81
81
|
payload = verify_with_jwks(token)
|
|
82
82
|
|
|
@@ -92,7 +92,7 @@ module MyApp
|
|
|
92
92
|
|
|
93
93
|
success(user)
|
|
94
94
|
rescue JWT::DecodeError, JWT::ExpiredSignature, JWT::InvalidIssuerError, JWT::InvalidAudError, KeyError => e
|
|
95
|
-
failure(
|
|
95
|
+
failure(I18n.t('spree.api.unauthorized'))
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
private
|
|
@@ -226,7 +226,7 @@ bin/rails db:encryption:init # prints a set; put it in env vars or encrypted
|
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
|
|
229
|
-
Recreate the containers so they pick up the new `.env` (`spree
|
|
229
|
+
Recreate the containers so they pick up the new `.env` (`spree dev` — `spree restart` keeps the old environment). Set the keys on your production host **before** deploying, and store them in your secret manager.
|
|
230
230
|
|
|
231
231
|
> **WARNING:** Never change or lose the keys once data is encrypted — the encrypted records become unreadable.
|
|
232
232
|
|
|
@@ -296,7 +296,7 @@ Spree::Checkout::Registry.add_requirement(
|
|
|
296
296
|
|
|
297
297
|
The requirement appears in the Cart API's `requirements` array (so a storefront rendering the feed generically needs zero changes) *and* blocks completion. `register_step` adds whole steps (spliced into `checkout_steps` at `before:`/`after:` anchors); built-in steps are customized through `Registry.base_steps` — an ordered `{ name => applicability }` hash you can mutate directly (`base_steps.delete('confirm')`).
|
|
298
298
|
- **The API `requirements` array now carries a stable `code`** on every entry (`email_required`, `out_of_stock`, `guest_checkout_not_allowed`, ...). Additive change — existing consumers keep working.
|
|
299
|
-
- **The delivery requirement is keyed `delivery_method`, not `shipping_method`.** Its entry is now `{ step: 'delivery', field: 'delivery_method', code: 'delivery_method_required' }`. A storefront that renders the feed generically needs no change; one that keys off the field or code to highlight a specific input must switch both tokens. The `
|
|
299
|
+
- **The delivery requirement is keyed `delivery_method`, not `shipping_method`.** Its entry is now `{ step: 'delivery', field: 'delivery_method', code: 'delivery_method_required' }`. A storefront that renders the feed generically needs no change; one that keys off the field or code to highlight a specific input must switch both tokens. The `spree.checkout_requirements.shipping_method_required` translation key was renamed to `spree.checkout_requirements.delivery_method_required` — override it under the new key.
|
|
300
300
|
- **"Logic between steps" has no backend home by design.** Side effects hang off data writes (workflow hooks such as `Carts::Complete`'s `before_finalize` and `Carts::AddItem`'s `after_item_added`) and events (`cart.updated`, `order.placed`) — not step transitions.
|
|
301
301
|
|
|
302
302
|
## Statuses: derived, then persisted
|
|
@@ -779,6 +779,18 @@ Other changes that come with it:
|
|
|
779
779
|
- **Alba moved into `spree_core`**, with its configuration, so core's staff emails render in installations without `spree_api`.
|
|
780
780
|
- **Your own mailers keep working.** A mailer that inherits `Spree::BaseMailer` and calls `mail` with its own ERB views is wrapped in the new email layout, and the `spree/shared/mailer_hero` and `mailer_button` partials remain for its views. See [Your own mailers](../customization/emails.md#your-own-mailers).
|
|
781
781
|
|
|
782
|
+
## Translations ship with Spree
|
|
783
|
+
|
|
784
|
+
Spree's translations for emails, API messages and validation messages are now part of Spree itself, in 43 languages besides English. Regional English (`en-GB` and the like) now falls back to `en`. A key a language does not translate yet falls back to English, unless your app configured its own `config.i18n.fallbacks`. See [Translations](../core-concepts/translations.md#translating-the-interface).
|
|
785
|
+
|
|
786
|
+
- **Remove `spree_i18n` from your Gemfile.** Its last release is empty and only warns. Older releases load their own, larger files over Spree's.
|
|
787
|
+
- **Use `I18n.t` with the full key.** `Spree.t(:free)` becomes `I18n.t('spree.free')`, and `Spree.t(:x, scope: :api)` becomes `I18n.t('spree.api.x')`. `Spree.t` keeps working until 6.1 with a deprecation warning.
|
|
788
|
+
- **A missing key is plain text.** `Spree.t` used to return a `<span class="translation_missing">` HTML element for a key it could not find. It now returns what `I18n.t` returns.
|
|
789
|
+
- **Untranslated keys fall back to English.** Spree's translations are complete only in English. With `config.i18n.fallbacks = true`, as Rails generates for production, Spree adds English after your default locale. An app that sets its own fallback list or turns fallbacks off keeps its choice.
|
|
790
|
+
- **`spree/testing_support/i18n` does nothing.** Set `config.i18n.raise_on_missing_translations = true` in your test environment to catch missing keys.
|
|
791
|
+
- **Kaminari is no longer loaded.** It came in through `spree_i18n`. Spree paginates with Pagy, and the `Spree::Base.page` bridge for a custom Kaminari `page_method_name` is gone. Add `kaminari` to your Gemfile if your own code uses it.
|
|
792
|
+
- **Translations for removed screens are gone.** Keys used only by the old admin and storefront, and by the v2 API, were removed. If your code reads one, copy it into your app's locale files.
|
|
793
|
+
|
|
782
794
|
## Deprecated in 6.0, removed in 6.1
|
|
783
795
|
|
|
784
796
|
Every rename keeps the legacy name working for one release with a deprecation warning. The notable ones:
|
|
@@ -825,6 +837,7 @@ Before 6.0 a cart was an incomplete order, so extensions written for 5.x (paymen
|
|
|
825
837
|
| `metafields` / `public_metafields` associations | `custom_fields` / `storefront_custom_fields` |
|
|
826
838
|
| `.with_metafield_key`, `.with_metafield_key_value` | `.with_custom_field_key`, `.with_custom_field_key_value` |
|
|
827
839
|
| `Spree.metafields` | `Spree.custom_fields` |
|
|
840
|
+
| `Spree.t`, `Spree.translate` | `I18n.t` with the full key, e.g. `I18n.t('spree.free')` |
|
|
828
841
|
| `CustomFieldDefinition#name`, `#metafield_type`, `#display_on` | `#label`, `#field_type`, `#storefront_visible` (columns renamed) |
|
|
829
842
|
| `Spree::SearchProvider::Meilisearch` | `SpreeMeilisearch::SearchProvider` (moved to the `spree_meilisearch` gem) |
|
|
830
843
|
| `Spree::SearchProvider::ProductPresenter` | `SpreeMeilisearch::ProductPresenter` (moved to the `spree_meilisearch` gem) |
|
|
@@ -9,6 +9,38 @@ The upgrade process is fairly easy and well described. Of course, it all boils d
|
|
|
9
9
|
|
|
10
10
|
We strongly advise upgrading Spree incrementally, rather than in one big go.
|
|
11
11
|
|
|
12
|
+
## How to upgrade
|
|
13
|
+
|
|
14
|
+
An upgrade updates the server, migrates the database, runs the version's data backfills, and updates the `@spree/*` packages of your dashboard apps. Always read the guide for the version you're moving to first — it lists the behavior changes to review.
|
|
15
|
+
|
|
16
|
+
**Spree CLI:**
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
spree upgrade
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
One command for every project: it pulls the new image, or updates the Spree gems on an [ejected](../cli/quickstart.md#spree-eject) project, then runs migrations, data backfills and the package updates. See [`spree upgrade`](../cli/quickstart.md#spree-upgrade) for its options.
|
|
23
|
+
|
|
24
|
+
**Without CLI:**
|
|
25
|
+
|
|
26
|
+
Run from the project root:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cd server
|
|
30
|
+
bundle update $(bundle list --name-only | grep ^spree)
|
|
31
|
+
bin/rails spree:install:migrations db:migrate
|
|
32
|
+
bin/rails spree:upgrade
|
|
33
|
+
cd ..
|
|
34
|
+
|
|
35
|
+
# The project root and each dashboard app have their own package.json
|
|
36
|
+
pnpm update "@spree/*"
|
|
37
|
+
(cd apps/dashboard && pnpm update "@spree/*")
|
|
38
|
+
(cd apps/seller-dashboard && pnpm update "@spree/*")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
On npm or Yarn, run `npm update` or `yarn upgrade` instead, naming each `@spree/*` package from that `package.json` (they do not accept the `"@spree/*"` pattern).
|
|
42
|
+
|
|
43
|
+
|
|
12
44
|
## Support
|
|
13
45
|
|
|
14
46
|
If you're stuck and would want to get some professional help, you can [contact us directly](https://spreecommerce.org/contact/) and request a quote for our consulting services.
|