Docs: fix stale localization, module and contributing docs

- localization.md: the label seeders are StorefrontTranslationsSeeder
  (and the checkout/validation ones), not a StorefrontLabels class or
  lunar:install; when each runs (storefront isn't seeded on boot);
  translations:pull; examples use the same slug in every locale.
- modules.md: core's JS/CSS is a real npm package (@boboko/core) with a
  Vite plugin, not files read from vendor/; bin/core-mode does the swap;
  open 0.x ranges instead of ^1.0; a real shop as the example app.
- CONTRIBUTE.md, README.md: seeding on boot corrected; 0.* range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lexxandClaude Opus 5.5 committed 2026-11-06 18:50:42 +02:00
1 parent bfc1f92b2e
commit 79e7e9b4fd
4 files changed
+60 -75

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ export default defineConfig({
## Translations added in the UI ## Translations added in the UI
Default translation lines ship in core's seeders (`StorefrontTranslationsSeeder`, `CheckoutTranslationsSeeder`, `ValidationTranslationsSeeder`), which every app runs on boot and which only ever add missing keys. Lines added while building a storefront usually start in the Filament Language Lines UI instead. To move them into core: Default translation lines ship in core's seeders (`StorefrontTranslationsSeeder`, `CheckoutTranslationsSeeder`, `ValidationTranslationsSeeder`), which only ever add missing keys. A shop's entrypoint runs the checkout and validation seeders on every boot; `StorefrontTranslationsSeeder` currently has to be run explicitly (see `docs/localization.md`, "Seeding"). Lines added while building a storefront usually start in the Filament Language Lines UI instead. To move them into core:
```bash ```bash
bin/dc-core.sh exec app php artisan boboko:translations:pull # local mode: writes into ../boboko-core bin/dc-core.sh exec app php artisan boboko:translations:pull # local mode: writes into ../boboko-core
+1 -1
View File
@@ -179,7 +179,7 @@ Add the repository to your project's `composer.json`:
} }
], ],
"require": { "require": {
"boboko/core": "^1.0" "boboko/core": "0.*"
} }
} }
``` ```
+33 -18
View File
@@ -1,6 +1,6 @@
# Localization # Localization
Storefront routes can be locale-prefixed (`/el/proionta`, `/en/products`) using a middleware Storefront routes can be locale-prefixed (`/el/products`, `/en/products`) using a middleware
that reads directly from Lunar's `languages` table — the same table the Filament **Languages** that reads directly from Lunar's `languages` table — the same table the Filament **Languages**
resource manages, so there's no separate locale config to keep in sync. resource manages, so there's no separate locale config to keep in sync.
@@ -8,7 +8,7 @@ resource manages, so there's no separate locale config to keep in sync.
## Why prefix every locale, including the default ## Why prefix every locale, including the default
Leaving the default locale bare at the root (`/proionta` for Greek, `/en/products` for English) Leaving the default locale bare at the root (`/products` for Greek, `/en/products` for English)
creates ambiguity: is `/` the language-neutral homepage or specifically the Greek version? It creates ambiguity: is `/` the language-neutral homepage or specifically the Greek version? It
also complicates `hreflang` (needs a self-referencing tag on the root plus a possibly-duplicate also complicates `hreflang` (needs a self-referencing tag on the root plus a possibly-duplicate
`x-default`) and risks duplicate content if a bot or campaign link reaches the root without a `x-default`) and risks duplicate content if a bot or campaign link reaches the root without a
@@ -17,6 +17,11 @@ language signal.
Prefixing every locale avoids this: every URL unambiguously declares its language, `hreflang` Prefixing every locale avoids this: every URL unambiguously declares its language, `hreflang`
tags are symmetrical, and adding a locale later requires no URL restructuring. tags are symmetrical, and adding a locale later requires no URL restructuring.
**Slugs are the same in every locale** (`/el/products/…` and `/en/products/…`, never
`/el/proionta/…`). Only the visible content is translated. Boboko shops don't use per-locale
slugs.
--- ---
## Opt-in, not global ## Opt-in, not global
@@ -30,8 +35,8 @@ use Illuminate\Support\Facades\Route;
Route::middleware('locale')->group(function () { Route::middleware('locale')->group(function () {
Route::get('/{locale}', HomeController::class); Route::get('/{locale}', HomeController::class);
Route::get('/{locale}/proionta', ProductIndexController::class); Route::get('/{locale}/products', ProductIndexController::class);
Route::get('/{locale}/proionta/{slug}', ProductShowController::class); Route::get('/{locale}/products/{slug}', ProductShowController::class);
}); });
``` ```
@@ -198,21 +203,31 @@ registered.
### Seeding ### Seeding
A starter set of common e-shop labels (`nav.*`, `cart.*`, `product.*`, `auth.*`, `search.*`, The default labels for every shop (`nav.*`, `footer.*`, `cart.*`, `product.*`, `shop.*`,
`review.*`, `shop.*`, `pagination.*`, English + Greek) lives in `search.*`, `auth.*`, `account.*`, `orders.*`, `contact.*`, `review.*`, `wishlist.*`,
`Modules\Core\Localization\Services\StorefrontLabels::all()` — kept as its own class, separate `pagination.*`, English + Greek) live in
from the seeding logic, so the label list can be scanned/diffed without wading through the `Modules\Core\Localization\Database\Seeders\StorefrontTranslationsSeeder::lines()`. Checkout and
seeding mechanics. validation messages have their own seeders (`Modules\Core\Checkout\Database\Seeders\CheckoutTranslationsSeeder`,
`Modules\Core\Localization\Database\Seeders\ValidationTranslationsSeeder`).
`Modules\Core\Command\InstallLunarCommand` (overrides Lunar's own `lunar:install`) seeds them via The seeders are **additive per key**: a key already in the database, including one an admin has
a **per-key upsert**, not an all-or-nothing "only seed if the group is empty" guard: a key already since edited in the Filament **Language Lines** resource, is left untouched; only missing keys
present in the database — including one an admin has since edited via the Filament **Language are created. That makes it safe to add keys to a seeder later and re-run it on an installed store,
Lines** resource — is left untouched; only keys missing entirely are created. This is what makes without skipping the new keys or reverting an admin's edits. New lines go through
it safe to add new keys to `StorefrontLabels::all()` later and re-run `lunar:install` on an `TranslationService::create()`, so the usual cache-invalidation and activity-log events fire.
already-installed store, without either silently skipping the new keys (the old guard's behavior)
or reverting an admin's edits back to the hardcoded default (what a naive `updateOrCreate` would **When they run:** a shop's `docker/entrypoint.sh` runs the checkout and validation seeders on
do). New writes go through `TranslationService::create()`, so the usual cache-invalidation and every boot. `StorefrontTranslationsSeeder` isn't run automatically (not by `lunar:install`, not on
activity-log events fire for them too. boot), so run it explicitly after a core update that adds keys, or add it to the shop's
entrypoint:
```bash
php artisan db:seed --class="Modules\Core\Localization\Database\Seeders\StorefrontTranslationsSeeder"
```
**Lines added in the admin** while building a storefront are copied back into the seeders with
`php artisan boboko:translations:pull` (local mode; see `CONTRIBUTE.md`, "Translations added in
the UI"). A key that exists only in one shop's database shows as a raw key everywhere else.
### Admin UI ### Admin UI
+25 -55
View File
@@ -42,10 +42,10 @@ boboko-core/ (this repo)
Stoic/ Stoic/
``` ```
The e-shop app (`boboko-test`) consumes it as `vendor/boboko/core`: A shop app (e.g. `3dealer`) consumes it as `vendor/boboko/core`:
``` ```
boboko-test/ my-shop/
app/ app/
Models/ Models/
Customer.php ← app-level model, extends Modules\Core\Customer\Models\Customer Customer.php ← app-level model, extends Modules\Core\Customer\Models\Customer
@@ -75,7 +75,7 @@ Within a module, organise by concern rather than by type (`Auth/`, `Customer/`,
```json ```json
"require": { "require": {
"boboko/core": "^1.0" "boboko/core": "0.*"
}, },
"repositories": [ "repositories": [
{ {
@@ -99,7 +99,12 @@ This is the **default** — a fresh `composer install` never depends on a local
] ]
``` ```
This is a **manual, deliberate swap** of `composer.json` — not automated, since Composer has no clean built-in mechanism to merge an additional repository on top of the main list per-environment (`composer.local.json` is not auto-merged in Composer 2.x; `COMPOSER_REPOSITORIES` does not merge either — both were tested and ruled out). Swap it back to `vcs` before committing, so CI/prod builds never require `../boboko-core` to exist. Don't swap it by hand: each shop's `bin/core-mode local` / `bin/core-mode repo` does it (and the
`package.json` side), restarts the stack, and turns on a pre-commit guard; see `CONTRIBUTE.md`.
It's a swap rather than an overlay because Composer has no clean built-in mechanism to merge an additional repository on top of the main list per-environment (`composer.local.json` is not auto-merged in Composer 2.x; `COMPOSER_REPOSITORIES` does not merge either — both were tested and ruled out). The committed state is always the `vcs` form, so CI/prod builds never require `../boboko-core` to exist.
Below 1.0, shops require core with an open range (`0.*` in Composer, `#semver:0.x` in npm), never
a caret: `^0.31.0` means `<0.32.0` and would silently refuse the next minor.
### Docker Compose: the local-core mount ### Docker Compose: the local-core mount
@@ -124,58 +129,23 @@ Docker Compose merges `volumes:` lists additively across `-f` files, so the over
## Frontend Assets (JS/CSS) ## Frontend Assets (JS/CSS)
A module's JS (Stimulus controllers) and CSS ship as plain source files under `resources/js/` and `resources/css/` — **there is no separate npm package per module.** A module is never `npm install`ed; its frontend assets are read directly by the consuming app's own Vite build, straight out of `vendor/boboko/<module>`. A module's Stimulus controllers and CSS ship as a **real npm package** (`@boboko/core`),
installed into the consumer's `node_modules`: a symlink to `../boboko-core` in local mode
(`file:../boboko-core`), a real copy of the tagged release in repo mode
(`git+https://…#semver:0.x`). It's a package rather than files read out of `vendor/` so npm
installs core's own JS dependencies (`leaflet`, `@hotwired/stimulus`) transitively, the same way
Composer does for PHP.
This mirrors the PHP story above exactly: Composer already gives every environment one single, unconditional path — `vendor/boboko/<module>` — whether that resolves to a symlink into a sibling checkout (local path repo) or a real installed copy (tagged VCS release). A consumer's `vite.config.js` and JS entry point read from that same path, so there is nothing to toggle on the JS side — whatever Composer resolved is exactly what Vite sees, in both dev and prod, automatically. - **One stable entry point:** consumers import only from the `@boboko/core` barrel
(`resources/js/index.js`, e.g. `import { registerCheckout, registerWishlist } from "@boboko/core"`),
never from a module's internal files, so the internal layout can change freely.
- **CSS:** `node_modules/@boboko/core/resources/css/…` in the consumer's Vite inputs and `@vite()`
(core's structural checkout CSS loads before the app's own, so the app's theming wins).
- **Vite:** the consumer adds the `boboko()` plugin from `@boboko/core/vite-plugin`. It owns the
settings the local-mode symlink needs (no stale pre-bundle, symlink-safe resolution, HMR on core
edits), so consumers don't copy them.
**Each module exposes one stable JS entry point** — `resources/js/index.js` — that re-exports whatever a consumer needs, e.g. `boboko-core`'s: Full details and the export map: `CONTRIBUTE.md`, "JS/CSS: a real npm package".
```js
// boboko-core/resources/js/index.js
export { registerCheckout } from './checkout/index.js'
```
A consuming app imports from that one file only, never from a path reaching into a module's internal folder structure directly:
```js
// consumer app's resources/js/app.js
import { registerCheckout } from "../../vendor/boboko/core/resources/js/index.js";
registerCheckout(application);
```
```php
{{-- consumer app's layout --}}
@vite(['vendor/boboko/core/resources/css/checkout.css', 'resources/css/app.css', 'resources/js/app.js'])
```
This keeps a module's internal file layout free to change without breaking every consumer's entry point — the same reasoning as PSR-4 namespaces for PHP, just for JS imports.
**A consuming app's `vite.config.js` needs one addition**, because `vendor/boboko/<module>` is a symlink in local path-repo dev (not a real directory Vite would otherwise watch through):
```js
export default defineConfig({
server: {
watch: {
// vendor/boboko/<module> is a symlink into ../boboko-<module> in
// local path-repo dev. Vite/chokidar don't follow symlinks for
// watched files by default, so edits to a module's source
// wouldn't otherwise trigger HMR. No-op against a real installed
// copy (tagged VCS release) in production.
followSymlinks: true,
},
},
});
```
Bare imports inside a module's own JS (e.g. `leaflet`, `@hotwired/stimulus`) resolve against the **consumer's** `node_modules` via Node's normal upward resolution walk from `vendor/boboko/<module>/resources/js/...` — no extra config needed, as long as `vendor/boboko/<module>` sits inside the consumer's own directory tree (true for both the symlink and real-copy case). The consumer's Vite Docker service (if any) needs the same bind mount the PHP containers already get, landing at the equivalent path relative to its own working directory:
```yaml
# consumer app's docker-compose.core-dev.yml
services:
vite:
volumes:
- ../boboko-core:/app/vendor/boboko/core # match /app to the vite service's actual workdir
```
--- ---
@@ -190,7 +160,7 @@ services:
"type": "library", "type": "library",
"version": "1.0.0", "version": "1.0.0",
"require": { "require": {
"boboko/core": "^1.0" "boboko/core": "0.*"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {