@spree/docs 0.1.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 +54 -0
- package/dist/api-reference/platform/authentication.md +38 -0
- package/dist/api-reference/store-api/authentication.md +188 -0
- package/dist/api-reference/store-api/errors.md +277 -0
- package/dist/api-reference/store-api/idempotency.md +129 -0
- package/dist/api-reference/store-api/introduction.md +34 -0
- package/dist/api-reference/store-api/localization.md +279 -0
- package/dist/api-reference/store-api/metadata.md +160 -0
- package/dist/api-reference/store-api/monetary-amounts.md +65 -0
- package/dist/api-reference/store-api/querying.md +399 -0
- package/dist/api-reference/store-api/rate-limitting.md +103 -0
- package/dist/api-reference/store-api/relations.md +185 -0
- package/dist/api-reference/storefront/authentication.md +88 -0
- package/dist/api-reference/tutorials/adyen-integration-guide-for-android.md +165 -0
- package/dist/api-reference/tutorials/adyen-integration-guide-for-ios.md +194 -0
- package/dist/api-reference/tutorials/quick-checkout-with-stripe.md +248 -0
- package/dist/api-reference/v2/fetching-multiple-resources.md +26 -0
- package/dist/api-reference/v2/filtering-and-sorting.md +53 -0
- package/dist/api-reference/v2/introduction.md +22 -0
- package/dist/api-reference/v2/pagination.md +37 -0
- package/dist/api-reference/webhooks-events.md +883 -0
- package/dist/developer/admin/admin.md +205 -0
- package/dist/developer/admin/authentication.md +59 -0
- package/dist/developer/admin/components.md +711 -0
- package/dist/developer/admin/custom-css.md +243 -0
- package/dist/developer/admin/custom-javascript.md +116 -0
- package/dist/developer/admin/extending-ui.md +1964 -0
- package/dist/developer/admin/form-builder.md +444 -0
- package/dist/developer/admin/helper-methods.md +531 -0
- package/dist/developer/admin/navigation.md +805 -0
- package/dist/developer/admin/tables.md +491 -0
- package/dist/developer/advanced/adding_spree_to_rails_app.md +106 -0
- package/dist/developer/cli/quickstart.md +137 -0
- package/dist/developer/contributing/creating-an-extension.md +258 -0
- package/dist/developer/contributing/developing-spree.md +339 -0
- package/dist/developer/contributing/quickstart.md +32 -0
- package/dist/developer/contributing/updating-extensions.md +67 -0
- package/dist/developer/core-concepts/addresses.md +265 -0
- package/dist/developer/core-concepts/adjustments.md +107 -0
- package/dist/developer/core-concepts/architecture.md +177 -0
- package/dist/developer/core-concepts/calculators.md +323 -0
- package/dist/developer/core-concepts/customers.md +230 -0
- package/dist/developer/core-concepts/events.md +624 -0
- package/dist/developer/core-concepts/imports-exports.md +698 -0
- package/dist/developer/core-concepts/inventory.md +191 -0
- package/dist/developer/core-concepts/markets.md +250 -0
- package/dist/developer/core-concepts/media.md +167 -0
- package/dist/developer/core-concepts/metafields.md +187 -0
- package/dist/developer/core-concepts/orders.md +328 -0
- package/dist/developer/core-concepts/payments.md +710 -0
- package/dist/developer/core-concepts/pricing.md +163 -0
- package/dist/developer/core-concepts/products.md +360 -0
- package/dist/developer/core-concepts/promotions.md +322 -0
- package/dist/developer/core-concepts/reports.md +206 -0
- package/dist/developer/core-concepts/search-filtering.md +237 -0
- package/dist/developer/core-concepts/shipments.md +212 -0
- package/dist/developer/core-concepts/slugs.md +111 -0
- package/dist/developer/core-concepts/staff-roles.md +123 -0
- package/dist/developer/core-concepts/store-credits-gift-cards.md +317 -0
- package/dist/developer/core-concepts/stores.md +117 -0
- package/dist/developer/core-concepts/taxes.md +135 -0
- package/dist/developer/core-concepts/translations.md +120 -0
- package/dist/developer/core-concepts/users.md +299 -0
- package/dist/developer/core-concepts/webhooks.md +378 -0
- package/dist/developer/create-spree-app/quickstart.md +158 -0
- package/dist/developer/customization/api.md +93 -0
- package/dist/developer/customization/authentication.md +88 -0
- package/dist/developer/customization/checkout.md +204 -0
- package/dist/developer/customization/configuration.md +55 -0
- package/dist/developer/customization/decorators.md +523 -0
- package/dist/developer/customization/dependencies.md +232 -0
- package/dist/developer/customization/emails.md +21 -0
- package/dist/developer/customization/extensions.md +92 -0
- package/dist/developer/customization/metadata.md +236 -0
- package/dist/developer/customization/model-preferences.md +130 -0
- package/dist/developer/customization/permissions.md +265 -0
- package/dist/developer/customization/quickstart.md +229 -0
- package/dist/developer/customization/routes.md +24 -0
- package/dist/developer/customization/v4/admin-panel.md +78 -0
- package/dist/developer/customization/v4/authentication.md +210 -0
- package/dist/developer/customization/v4/checkout.md +212 -0
- package/dist/developer/customization/v4/deface.md +251 -0
- package/dist/developer/customization/v4/images.md +86 -0
- package/dist/developer/customization/v4/storefront.md +450 -0
- package/dist/developer/deployment/assets.md +87 -0
- package/dist/developer/deployment/aws.md +335 -0
- package/dist/developer/deployment/caching.md +27 -0
- package/dist/developer/deployment/cdn.md +39 -0
- package/dist/developer/deployment/database.md +155 -0
- package/dist/developer/deployment/docker.md +128 -0
- package/dist/developer/deployment/emails.md +77 -0
- package/dist/developer/deployment/environment_variables.md +111 -0
- package/dist/developer/deployment/heroku.md +51 -0
- package/dist/developer/deployment/render.md +95 -0
- package/dist/developer/getting-started/quickstart.md +82 -0
- package/dist/developer/how-to/custom-payment-method.md +374 -0
- package/dist/developer/how-to/custom-promotion.md +373 -0
- package/dist/developer/how-to/custom-report.md +387 -0
- package/dist/developer/how-to/custom-search-provider.md +230 -0
- package/dist/developer/multi-store/quickstart.md +71 -0
- package/dist/developer/multi-store/setup.md +38 -0
- package/dist/developer/multi-tenant/configuration.md +41 -0
- package/dist/developer/multi-tenant/core-concepts.md +75 -0
- package/dist/developer/multi-tenant/installation.md +96 -0
- package/dist/developer/multi-tenant/quickstart.md +20 -0
- package/dist/developer/multi-vendor/installation.md +45 -0
- package/dist/developer/multi-vendor/quickstart.md +17 -0
- package/dist/developer/sdk/admin/quickstart.md +22 -0
- package/dist/developer/sdk/authentication.md +89 -0
- package/dist/developer/sdk/configuration.md +225 -0
- package/dist/developer/sdk/quickstart.md +82 -0
- package/dist/developer/sdk/store/account.md +67 -0
- package/dist/developer/sdk/store/cart-checkout.md +140 -0
- package/dist/developer/sdk/store/markets.md +151 -0
- package/dist/developer/sdk/store/payments.md +96 -0
- package/dist/developer/sdk/store/products.md +149 -0
- package/dist/developer/sdk/store/wishlists.md +52 -0
- package/dist/developer/security/pci_compliance.md +15 -0
- package/dist/developer/security/security_policy.md +68 -0
- package/dist/developer/storefront/blocks.md +285 -0
- package/dist/developer/storefront/custom-css.md +260 -0
- package/dist/developer/storefront/custom-javascript.md +166 -0
- package/dist/developer/storefront/helper-methods.md +1288 -0
- package/dist/developer/storefront/links.md +298 -0
- package/dist/developer/storefront/nextjs/architecture.md +150 -0
- package/dist/developer/storefront/nextjs/customization.md +141 -0
- package/dist/developer/storefront/nextjs/deployment.md +180 -0
- package/dist/developer/storefront/nextjs/quickstart.md +92 -0
- package/dist/developer/storefront/nextjs/spree-next-package.md +314 -0
- package/dist/developer/storefront/pages.md +163 -0
- package/dist/developer/storefront/sections.md +569 -0
- package/dist/developer/storefront/storefront.md +56 -0
- package/dist/developer/storefront/themes.md +161 -0
- package/dist/developer/tutorial/admin.md +134 -0
- package/dist/developer/tutorial/extending-models.md +380 -0
- package/dist/developer/tutorial/file-uploads.md +121 -0
- package/dist/developer/tutorial/introduction.md +33 -0
- package/dist/developer/tutorial/model.md +41 -0
- package/dist/developer/tutorial/page-builder.md +487 -0
- package/dist/developer/tutorial/rich-text.md +73 -0
- package/dist/developer/tutorial/seo.md +332 -0
- package/dist/developer/tutorial/storefront.md +352 -0
- package/dist/developer/tutorial/testing.md +558 -0
- package/dist/developer/upgrades/2.0-to-2.1.md +46 -0
- package/dist/developer/upgrades/2.1-to-2.2.md +59 -0
- package/dist/developer/upgrades/2.2-to-2.3.md +44 -0
- package/dist/developer/upgrades/2.3-to-2.4.md +42 -0
- package/dist/developer/upgrades/3.0-to-3.1.md +47 -0
- package/dist/developer/upgrades/3.1-to-3.2.md +34 -0
- package/dist/developer/upgrades/3.2-to-3.3.md +70 -0
- package/dist/developer/upgrades/3.3-to-3.4.md +36 -0
- package/dist/developer/upgrades/3.4-to-3.5.md +44 -0
- package/dist/developer/upgrades/3.5-to-3.6.md +40 -0
- package/dist/developer/upgrades/3.6-to-3.7.md +62 -0
- package/dist/developer/upgrades/3.7-to-4.0.md +152 -0
- package/dist/developer/upgrades/4.0-to-4.1.md +92 -0
- package/dist/developer/upgrades/4.1-to-4.2.md +109 -0
- package/dist/developer/upgrades/4.10-to-5.0.md +129 -0
- package/dist/developer/upgrades/4.2-to-4.3.md +100 -0
- package/dist/developer/upgrades/4.3-to-4.4.md +125 -0
- package/dist/developer/upgrades/4.4-to-4.5.md +94 -0
- package/dist/developer/upgrades/4.5-to-4.6.md +119 -0
- package/dist/developer/upgrades/4.6-to-4.7.md +39 -0
- package/dist/developer/upgrades/4.8-to-4.9.md +24 -0
- package/dist/developer/upgrades/4.9-to-4.10.md +24 -0
- package/dist/developer/upgrades/4.x-to-4.8.md +52 -0
- package/dist/developer/upgrades/5.0-to-5.1.md +28 -0
- package/dist/developer/upgrades/5.1-to-5.2.md +127 -0
- package/dist/developer/upgrades/5.2-to-5.3.md +338 -0
- package/dist/developer/upgrades/5.3-to-5.4.md +248 -0
- package/dist/developer/upgrades/quickstart.md +36 -0
- package/dist/integrations/analytics/google-analytics.md +64 -0
- package/dist/integrations/analytics/google-tag-manager.md +78 -0
- package/dist/integrations/integrations.md +39 -0
- package/dist/integrations/marketing/klaviyo.md +99 -0
- package/dist/integrations/payments/adyen.md +90 -0
- package/dist/integrations/payments/paypal.md +41 -0
- package/dist/integrations/payments/razorpay.md +45 -0
- package/dist/integrations/payments/stripe.md +109 -0
- package/dist/integrations/search/meilisearch.md +236 -0
- package/dist/integrations/sso-mfa-social-login/admin-dashboard.md +57 -0
- package/dist/integrations/sso-mfa-social-login/storefront.md +56 -0
- package/package.json +27 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Developing Spree
|
|
3
|
+
description: >-
|
|
4
|
+
This guide covers all the necessary steps to contributing to Spree source
|
|
5
|
+
code. We're happy you're here!
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Cloning the repository
|
|
9
|
+
|
|
10
|
+
Spree is a big monorepo. For a faster clone, use a **partial clone** which downloads file contents on demand while keeping full commit history for `git log` and `git blame`:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
git clone --filter=blob:none https://github.com/spree/spree.git
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Spree codebase
|
|
17
|
+
|
|
18
|
+
Spree is a monorepo with three main areas:
|
|
19
|
+
|
|
20
|
+
- **`spree/`** — Ruby gems (core, api, admin, emails) distributed as separate packages via RubyGems
|
|
21
|
+
- **`packages/`** — TypeScript packages (SDK, Next.js helpers)
|
|
22
|
+
- **`server/`** — A Rails application cloned from [spree-starter](https://github.com/spree/spree-starter) that mounts the Spree gems (not checked in — run `pnpm server:setup` to create it)
|
|
23
|
+
|
|
24
|
+
## Backend Development (Ruby)
|
|
25
|
+
|
|
26
|
+
### Engines overview
|
|
27
|
+
|
|
28
|
+
The Spree [Rails engines](https://guides.rubyonrails.org/engines.html) live inside `spree/` and are distributed as separate gems (Ruby packages installed via Bundler):
|
|
29
|
+
|
|
30
|
+
| Engine | Gem | Description |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `core` | `spree_core` | Models, services, business logic |
|
|
33
|
+
| `api` | `spree_api` | REST APIs |
|
|
34
|
+
| `admin` | `spree_admin` | Admin dashboard |
|
|
35
|
+
| `emails` | `spree_emails` | Transactional emails |
|
|
36
|
+
|
|
37
|
+
### Spree namespace
|
|
38
|
+
|
|
39
|
+
All Spree models, controllers and other Ruby classes are namespaced by the `Spree` keyword, eg. `Spree::Product`. This means that those files are also located in `spree` sub-directories eg. [app/models/spree/product.rb](https://github.com/spree/spree/blob/main/spree/core/app/models/spree/product.rb).
|
|
40
|
+
|
|
41
|
+
### Setup
|
|
42
|
+
|
|
43
|
+
The server app is not checked into the monorepo. It's cloned from [spree-starter](https://github.com/spree/spree-starter) on first setup, with `SPREE_PATH=..` automatically configured so it uses your local Spree gems.
|
|
44
|
+
|
|
45
|
+
**Step 1: Start infrastructure**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
docker compose up -d # starts Postgres, Redis, Mailpit
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or install PostgreSQL and Redis locally if you prefer.
|
|
52
|
+
|
|
53
|
+
**Step 2: Clone the server app**
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm server:setup
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This clones [spree-starter](https://github.com/spree/spree-starter) into `server/` and sets `SPREE_PATH=..` in `server/.env` so it uses your local Spree gems.
|
|
60
|
+
|
|
61
|
+
**Step 3: Configure and run**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd server
|
|
65
|
+
# Edit .env if needed (e.g. DATABASE_USERNAME, DATABASE_HOST, DATABASE_PORT)
|
|
66
|
+
bin/setup # installs Ruby (via mise), system packages, gems, prepares database
|
|
67
|
+
bin/dev # starts Rails + Sidekiq + CSS watchers via overmind
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Use `bin/setup --reset` to drop and recreate the database.
|
|
71
|
+
|
|
72
|
+
The app runs at [http://localhost:3000](http://localhost:3000). Admin Panel is at [http://localhost:3000/admin](http://localhost:3000/admin).
|
|
73
|
+
|
|
74
|
+
**Emails in local dev:** When using `docker compose up -d`, Mailpit is included automatically. All outgoing emails are caught and viewable at [http://localhost:8025](http://localhost:8025).
|
|
75
|
+
|
|
76
|
+
### Running engine tests
|
|
77
|
+
|
|
78
|
+
Each engine has its own test suite. First install the shared dependencies at the `spree/` level, then navigate into the specific engine to set up and run its tests:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# 1. Install shared dependencies
|
|
82
|
+
cd spree
|
|
83
|
+
bundle install
|
|
84
|
+
|
|
85
|
+
# 2. Set up and run tests for a specific engine (e.g. core)
|
|
86
|
+
cd core
|
|
87
|
+
bundle install
|
|
88
|
+
bundle exec rake test_app
|
|
89
|
+
bundle exec rspec
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Replace `core` with `api`, `admin`, or `emails` to test other engines.
|
|
93
|
+
|
|
94
|
+
By default engine tests run against SQLite3. To run against PostgreSQL, set the `DB` environment variable:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
DB=postgres DB_USERNAME=postgres DB_PASSWORD=password DB_HOST=localhost bundle exec rake test_app
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Run a single spec file:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cd spree/core
|
|
104
|
+
bundle exec rspec spec/models/spree/state_spec.rb
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Run a specific test by line number:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cd spree/core
|
|
111
|
+
bundle exec rspec spec/models/spree/state_spec.rb:7
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Running tests in parallel
|
|
115
|
+
|
|
116
|
+
For faster test runs on multi-core machines, you can use the `parallel_tests` gem to distribute spec files across multiple CPU cores.
|
|
117
|
+
|
|
118
|
+
After setting up the test app, create databases for parallel workers:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
cd spree/core
|
|
122
|
+
bundle exec rake parallel_setup
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Then run specs in parallel:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
bundle exec parallel_rspec spec
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
You can also specify the number of workers:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bundle exec rake "parallel_setup[4]"
|
|
135
|
+
bundle exec parallel_rspec -n 4 spec
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
After schema changes, re-run `bundle exec rake parallel_setup` to update the worker databases.
|
|
139
|
+
|
|
140
|
+
### Integration tests (Admin Panel)
|
|
141
|
+
|
|
142
|
+
The Admin Panel uses feature specs that run in a real browser via chromedriver. You only need this if you're working on admin UI changes.
|
|
143
|
+
|
|
144
|
+
Install chromedriver on macOS:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
brew install chromedriver
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Performance in development mode
|
|
151
|
+
|
|
152
|
+
You may notice that your Spree store runs slower in development environment. This is caused by disabled caching and automatic reloading of code after each change.
|
|
153
|
+
|
|
154
|
+
Caching is disabled by default. To turn on caching please run:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cd server && bin/rails dev:cache
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
You will need to restart rails server after this change.
|
|
161
|
+
|
|
162
|
+
## TypeScript Development
|
|
163
|
+
|
|
164
|
+
### Setup
|
|
165
|
+
|
|
166
|
+
TypeScript developers don't need Ruby installed. Docker Compose from the repository root starts the backend using a prebuilt image:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
docker compose up -d
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
This boots PostgreSQL, Redis, Mailpit, and the Spree backend automatically (no `pnpm server:setup` needed). The API is available at `http://localhost:3000`. All outgoing emails are caught by Mailpit and viewable at `http://localhost:8025`.
|
|
173
|
+
|
|
174
|
+
Then install dependencies and start all packages in watch mode:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pnpm install
|
|
178
|
+
pnpm dev
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Packages
|
|
182
|
+
|
|
183
|
+
| Package | Path | Description |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| `@spree/sdk` | `packages/sdk` | TypeScript SDK for the Spree Storefront API |
|
|
186
|
+
| `@spree/next` | `packages/next` | Next.js integration (server actions, caching, cookie-based auth) |
|
|
187
|
+
|
|
188
|
+
### Common commands
|
|
189
|
+
|
|
190
|
+
Run from the repository root — [Turborepo](https://turbo.build/) orchestrates tasks across all packages:
|
|
191
|
+
|
|
192
|
+
| Command | Description |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `pnpm dev` | Start Docker backend + watch mode for all packages |
|
|
195
|
+
| `pnpm build` | Build all packages (SDK first, then Next.js) |
|
|
196
|
+
| `pnpm test` | Run tests in all packages |
|
|
197
|
+
| `pnpm lint` | Lint all packages |
|
|
198
|
+
| `pnpm typecheck` | Type-check all packages |
|
|
199
|
+
| `pnpm clean` | Remove build artifacts |
|
|
200
|
+
|
|
201
|
+
### Package-specific commands
|
|
202
|
+
|
|
203
|
+
You can also run commands in a single package:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pnpm --filter @spree/sdk test:watch
|
|
207
|
+
pnpm --filter @spree/sdk console
|
|
208
|
+
pnpm --filter @spree/sdk generate:zod
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Tests use [Vitest](https://vitest.dev/) with [MSW](https://mswjs.io/) for API mocking at the network level.
|
|
212
|
+
|
|
213
|
+
### Type generation
|
|
214
|
+
|
|
215
|
+
TypeScript types in `packages/sdk/src/types/generated/` are auto-generated from the Rails API serializers using [typelizer](https://github.com/skryukov/typelizer). To regenerate after changing serializers:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
cd spree/api
|
|
219
|
+
mise install --yes # to install Ruby if you don't have it already
|
|
220
|
+
bundle install # to install dependencies
|
|
221
|
+
bundle exec rake typelizer:generate
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
After regenerating types, update the Zod schemas:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
pnpm --filter @spree/sdk generate:zod
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Releasing packages
|
|
231
|
+
|
|
232
|
+
Packages use [Changesets](https://github.com/changesets/changesets) for version management:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pnpm changeset
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
This creates a changeset file describing your changes. Commit it with your PR. When merged to `main`, a GitHub Action creates a "Version Packages" PR that bumps the version and publishes to npm.
|
|
239
|
+
|
|
240
|
+
## Code Style
|
|
241
|
+
|
|
242
|
+
Consistent code style is enforced via automated linters. Please make sure your changes pass linting before submitting a PR.
|
|
243
|
+
|
|
244
|
+
**Ruby:** We use [RuboCop](https://rubocop.org/) for Ruby code. Configuration lives in `server/.rubocop.yml`. Run it from the `server/` directory:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
cd server
|
|
248
|
+
bundle exec rubocop
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
To auto-fix correctable offenses:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
bundle exec rubocop -a
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**TypeScript:** We use [Biome](https://biomejs.dev/) for linting and formatting TypeScript code. Run it from the repository root:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
pnpm lint
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Making Changes
|
|
264
|
+
|
|
265
|
+
### Branch naming
|
|
266
|
+
|
|
267
|
+
Create a new branch for your changes. Do not push changes to the main branch. Branch names should be human-readable and informative:
|
|
268
|
+
|
|
269
|
+
- Bug fixes: `fix/order-recalculation-total-bug`
|
|
270
|
+
- Features: `feature/my-new-amazing-feature`
|
|
271
|
+
|
|
272
|
+
### Commit messages
|
|
273
|
+
|
|
274
|
+
Keep your commit history meaningful and clear. Each commit should represent a logical unit of work. [This guide](https://about.gitlab.com/blog/2018/06/07/keeping-git-commit-history-clean/) covers this well.
|
|
275
|
+
|
|
276
|
+
A few tips:
|
|
277
|
+
|
|
278
|
+
- Write commit messages in the imperative mood (e.g. "Add feature" not "Added feature")
|
|
279
|
+
- Keep the first line under 72 characters
|
|
280
|
+
- If your change references a GitHub issue, include `Fixes #<number>` in the commit message or PR description to auto-close it on merge
|
|
281
|
+
|
|
282
|
+
### Using AI tools for development
|
|
283
|
+
|
|
284
|
+
Spree comes with an [AGENTS.md](https://github.com/spree/spree/blob/main/AGENTS.md) file that instructs coding agents like Claude Code or Codex to help you with your development.
|
|
285
|
+
|
|
286
|
+
We also have an MCP server built on top of our Documentation website to help you with your development.
|
|
287
|
+
|
|
288
|
+
Add this URL to your AI tools:
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
https://spreecommerce.org/docs/mcp
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
In Claude Code you need to go to [Connectors](https://claude.ai/settings/connectors) settings and add the URL.
|
|
295
|
+
|
|
296
|
+
## Submitting Changes
|
|
297
|
+
|
|
298
|
+
We use [GitHub Actions](https://github.com/spree/spree/actions) to run CI.
|
|
299
|
+
|
|
300
|
+
1. Push your changes to a topic branch in your fork of the repository.
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
git push origin fix/order-recalculation-total-bug
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
2. [Create a Pull Request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) against the `main` branch.
|
|
307
|
+
|
|
308
|
+
3. Wait for CI to pass.
|
|
309
|
+
|
|
310
|
+
4. Wait for Spree Core team code review. We aim to review and leave feedback as soon as possible.
|
|
311
|
+
|
|
312
|
+
### Pull request guidelines
|
|
313
|
+
|
|
314
|
+
To help us review your PR quickly:
|
|
315
|
+
|
|
316
|
+
- **Keep PRs focused.** One feature or fix per PR. Smaller PRs are easier to review and merge.
|
|
317
|
+
- **Describe your changes.** Explain what you changed and why. Include screenshots for UI changes.
|
|
318
|
+
- **Add tests.** All new features and bug fixes should include appropriate test coverage.
|
|
319
|
+
- **Update documentation.** If your change affects user-facing behavior, update the relevant docs.
|
|
320
|
+
- **Include a changeset** (TypeScript packages only). Run `pnpm changeset` if your change affects `@spree/sdk` or `@spree/next`.
|
|
321
|
+
- **Ensure CI passes.** PRs with failing CI will not be reviewed.
|
|
322
|
+
|
|
323
|
+
## Reporting Bugs
|
|
324
|
+
|
|
325
|
+
We use [GitHub Issues](https://github.com/spree/spree/issues) to track bugs. Before filing a new issue, please search existing issues to avoid duplicates.
|
|
326
|
+
|
|
327
|
+
When reporting a bug, please include:
|
|
328
|
+
|
|
329
|
+
- **Spree version** you're using
|
|
330
|
+
- **Steps to reproduce** the problem
|
|
331
|
+
- **Expected behavior** vs **actual behavior**
|
|
332
|
+
- **Relevant logs or stack traces** (formatted with triple backticks)
|
|
333
|
+
- **Your environment** (Ruby version, database, OS)
|
|
334
|
+
|
|
335
|
+
Issues that are open for 14 days without actionable information or activity will be marked as stale and then closed. They can be re-opened if the requested information is provided.
|
|
336
|
+
|
|
337
|
+
## That's a wrap!
|
|
338
|
+
|
|
339
|
+
Thank you for participating in Open Source and improving Spree - you're awesome!
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Quickstart
|
|
3
|
+
description: How to get started contributing to Spree
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Spree is an open, community-powered project that anyone can contribute to. There are several ways you can help us improve Spree:
|
|
7
|
+
|
|
8
|
+
* fixing a bug or creating a new feature
|
|
9
|
+
* creating a Spree extension
|
|
10
|
+
* upgrading old extensions to recent Spree versions
|
|
11
|
+
* helping others on Spree slack
|
|
12
|
+
* submitting an issue describing a bug or a feature request
|
|
13
|
+
|
|
14
|
+
## Fixing a bug or creating a new feature
|
|
15
|
+
|
|
16
|
+
Before diving into the Spree codebase we recommend you spend some time reviewing the [Core Concepts section](/core-concepts) which will help you understand how Spree works under the hood.
|
|
17
|
+
|
|
18
|
+
After you're done with that please follow to [Developing Spree guide](developing-spree)
|
|
19
|
+
|
|
20
|
+
To find issues you can tackle on we recommend visiting [Spree Contribute page](https://github.com/spree/spree/contribute) which lists issues tagged with [Good First Issue label](https://github.com/spree/spree/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22). Those bugs or features are great starting points into Open Source development.
|
|
21
|
+
|
|
22
|
+
## Creating a Spree extension
|
|
23
|
+
|
|
24
|
+
Extensions provide additional features and integrations for your Spree store. You can create your own and share with the rest of the community. Before doing so please check our [Extension directory](/developer/customization/extensions) if your desired extension does not exist already. If not [follow Extensions tutorial](../contributing/extensions_tutorial) to learn how to create one.
|
|
25
|
+
|
|
26
|
+
## Helping others on Spree slack
|
|
27
|
+
|
|
28
|
+
Last but not least, you're invited to [join our slack](http://slack.spreecommerce.org) to help and receive guidance from fellow Spree developers including Spree Core Team.
|
|
29
|
+
|
|
30
|
+
## Submitting issues
|
|
31
|
+
|
|
32
|
+
You can [submit an issue](https://github.com/spree/spree/issues/new/choose) on our [Github Issues tracker](https://github.com/spree/spree/issues)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Updating Extensions
|
|
3
|
+
description: How to upgrade your Spree extension to work with Spree 4
|
|
4
|
+
version: v4
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Zeitwerk compatibility
|
|
8
|
+
|
|
9
|
+
Zeitwerk is the [new default code autoloader in Rails 6](https://weblog.rubyonrails.org/2019/2/22/zeitwerk-integration-in-rails-6-beta-2/).
|
|
10
|
+
|
|
11
|
+
This doesn't work well with the old approach to decorators files that name ends with decorator.rb, eg. `app/models/spree/order_decorator.rb` using [class_eval](https://www.jimmycuadra.com/posts/metaprogramming-ruby-class-eval-and-instance-eval/).
|
|
12
|
+
|
|
13
|
+
To fix this we need to convert all `class_eval` decorators to modules and use [Module.prepend](https://medium.com/@leo_hetsch/ruby-modules-include-vs-prepend-vs-extend-f09837a5b073). Also we need to name them properly according to [Zeitwerk naming rules](https://github.com/fxn/zeitwerk#file-structure)
|
|
14
|
+
|
|
15
|
+
Example of an old decorator:
|
|
16
|
+
|
|
17
|
+
```ruby app/models/spree/order_decorator.rb
|
|
18
|
+
Spree::Order.class_eval do
|
|
19
|
+
has_many :new_custom_model
|
|
20
|
+
|
|
21
|
+
def some_method
|
|
22
|
+
# ...
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
the same decorator in the new notation:
|
|
28
|
+
|
|
29
|
+
```ruby app/models/your_extension_name/order_decorator.rb
|
|
30
|
+
module YourExtensionName::OrderDecorator
|
|
31
|
+
def self.prepended(base)
|
|
32
|
+
base.has_many :new_custom_model
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def some_method
|
|
36
|
+
# ...
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Spree::Order.prepend(YourExtensionName::OrderDecorator)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Fixing Deface Overrides
|
|
44
|
+
|
|
45
|
+
Please remember to prepare versioned overrides for both Spree 3.x and 4.x, eg. [https://github.com/spree-contrib/spree_static_content/commit/e4b9e4900024235158d0ec1a48a100b4732348ef](https://github.com/spree-contrib/spree_static_content/commit/e4b9e4900024235158d0ec1a48a100b4732348ef)
|
|
46
|
+
|
|
47
|
+
Spree 4 uses Bootstrap 4 and many partials and HTML structure changed compared to Spree 3.x.
|
|
48
|
+
|
|
49
|
+
Also - **remember to add deface gem to gemspec** as deface itself was removed as a dependency of Spree. eg. [https://github.com/spree/spree_auth_devise/commit/d729689ca87d8586e541ffcc865ef1e0a5a79fe4](https://github.com/spree/spree_auth_devise/commit/d729689ca87d8586e541ffcc865ef1e0a5a79fe4)
|
|
50
|
+
|
|
51
|
+
## Migrate to Spree Dev Tools
|
|
52
|
+
|
|
53
|
+
Replace all development dependencies with:
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
s.add_development_dependency 'spree_dev_tools'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Replace `spec_helper.rb` contents with:
|
|
60
|
+
|
|
61
|
+
[https://github.com/spree/spree/blob/777a284b4c70e69d32a05ffa61bbe3905d8f1297/cmd/lib/spree_cmd/templates/extension/spec/spec_helper.rb](https://github.com/spree/spree/blob/777a284b4c70e69d32a05ffa61bbe3905d8f1297/cmd/lib/spree_cmd/templates/extension/spec/spec_helper.rb)
|
|
62
|
+
|
|
63
|
+
Example migrations:
|
|
64
|
+
|
|
65
|
+
* [https://github.com/spree/spree_gateway/pull/357](https://github.com/spree/spree_gateway/pull/357)
|
|
66
|
+
* [https://github.com/spree-contrib/spree-product-assembly/pull/200](https://github.com/spree-contrib/spree-product-assembly/pull/200)
|
|
67
|
+
* [https://github.com/spree/spree_auth_devise/pull/487](https://github.com/spree/spree_auth_devise/pull/487)
|