Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f15bf83
feat: add queue, schedule and workers tasks and a Taskfile sync comma…
roble Nov 5, 2026
76d55af
feat: create the E2E env file on install (sc-1108)
roble Nov 5, 2026
5b9a1cc
chore: forbid nested ternaries in both stacks' ESLint config
roble Nov 6, 2026
64f463b
feat: throw when two sources declare the same capability in a group (…
roble Nov 6, 2026
3a32e7c
feat: dashboard period filter, Period and TrendStat for widgets, and …
roble Nov 6, 2026
6ed4b00
fix: keep every month in the 12-month period, warn when the E2E env i…
roble Nov 6, 2026
472efcf
Merge branch 'main' of https://github.com/saucebase-dev/core into dev…
roble Nov 6, 2026
8b92522
Merge origin/main into dev
roble Nov 8, 2026
680b537
chore: alias the dev branch as 2.13.x-dev
roble Nov 8, 2026
09239d5
Merge branch 'renanroble-dev-branch-alias' into dev
roble Nov 8, 2026
33c8062
feat: named states replace --demo in modules:seed
roble Nov 10, 2026
2759c3d
Merge branch 'renanroble-named-states' into dev
roble Nov 10, 2026
d4e4765
feat: set up a template after the modules it requires
roble Nov 10, 2026
763a45f
Merge branch 'renanroble-template-type' into dev
roble Nov 10, 2026
fa3ca8d
feat: dashboard widgets fill gaps; drop the Discord links from the ap…
roble Nov 10, 2026
8863ddd
Merge branch 'renanroble-dashboard-dense' into dev
roble Nov 10, 2026
c68c13c
feat: template install and capture, module options
roble Nov 13, 2026
ea39de6
Merge branch 'renanroble-template-install' into dev
roble Nov 13, 2026
a3bac51
feat: install settings, set at install by templates, flags or prompts
roble Nov 13, 2026
c5bd04a
Merge branch 'renanroble-install-settings' into dev
roble Nov 13, 2026
03c80e5
feat: one configure key and --set for templates
roble Nov 13, 2026
c773758
Merge branch 'renanroble-configure' into dev
roble Nov 13, 2026
a3337b8
feat: template workspaces resolve @/ from the app first
roble Nov 13, 2026
b6cb20a
feat: select and table components in the Vue starter UI
roble Nov 13, 2026
a8e8d91
fix: every reka popup opens above an Inertia modal
roble Nov 13, 2026
dbd85d1
Merge branch 'renanroble-app-first-ui' into dev
roble Nov 13, 2026
57f567a
fix: popups opened from a modal keep focus and Escape
roble Nov 14, 2026
9b624ba
feat: combobox in the Vue starter UI
roble Nov 14, 2026
cadec30
fix: the same space above a page's title as below it
roble Nov 14, 2026
bcae913
Merge branch 'renanroble-qa-fixes' into dev
roble Nov 14, 2026
bc2f9ca
feat: a template installs clean; --state seeds its demo
roble Nov 14, 2026
0467bdd
Merge branch 'renanroble-template-demo-opt-in' into dev
roble Nov 14, 2026
8eeaf80
feat: a demo without DEMO_PASSWORD gets a random one, saved in .env
roble Nov 14, 2026
3242bfe
docs: a skill for building Saucebase templates
roble Nov 14, 2026
f03b08d
Merge branch 'renanroble-generated-demo-password' into dev
roble Nov 14, 2026
978f691
Merge branch 'renanroble-template-skill' into dev
roble Nov 14, 2026
44cc972
feat: build a template in any app, by any vendor
roble Nov 14, 2026
1141366
Merge branch 'renanroble-template-from-scratch' into dev
roble Nov 14, 2026
cfee9b1
fix: a recipe's dotfiles reach the module it makes
roble Nov 15, 2026
d9a0f2e
Merge branch 'renanroble-recipe-dotfiles' into dev
roble Nov 15, 2026
1911bb7
fix: a recipe's CI names the module by its folder
roble Nov 15, 2026
05573aa
Merge branch 'renanroble-recipe-ci-name' into dev
roble Nov 15, 2026
1d1439b
docs: what building the notes template taught the template skill
roble Nov 15, 2026
20dd450
Merge branch 'renanroble-template-skill-lessons' into dev
roble Nov 15, 2026
72353f2
fix: put composer files back when a package install fails
roble Nov 15, 2026
d1e25b0
chore: require module-installer 3.3 for templates, alias dev as 3.0.x…
roble Nov 15, 2026
a0d3244
ci: install a template's stubs in the test app, as a customer's app g…
roble Nov 15, 2026
b7b8925
feat!: modules:seed and module-install take --state, not --demo
roble Nov 15, 2026
ee4923f
fix: React popups opened from a modal show above it
roble Nov 15, 2026
6bbd5bb
fix: an override's relative imports find files beside it in the app
roble Nov 15, 2026
b07f886
fix: each post-install command gets only the answers it takes
roble Nov 15, 2026
60a32c4
chore: leave the select, table and combobox shadcn folders out of Sonar
roble Nov 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/actions/fresh-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ runs:
patch -p1 < "modules/$MODULE/$f"
done

# A template also replaces app files (home page, dashboard), as in a customer's app.
if [ "$(jq -r .type "modules/$MODULE/composer.json")" = "saucebase-template" ]; then
php artisan saucebase:template-install "$(jq -r .name "modules/$MODULE/composer.json")" --no-interaction
fi

- name: Configure the environment
shell: bash
working-directory: app
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sonar.test.inclusions=tests/**,**/*.test.ts,**/*.test.tsx
# analysed; a newly added shadcn-vue component needs its folder listed here.
#
# A recipe is a template: its class and file names are placeholders the command fills in.
sonar.exclusions=stubs/recipes/**,stubs/stack/react/js/components/ui/*.tsx,stubs/stack/vue/js/components/ui/alert/**,stubs/stack/vue/js/components/ui/alert-dialog/**,stubs/stack/vue/js/components/ui/avatar/**,stubs/stack/vue/js/components/ui/badge/**,stubs/stack/vue/js/components/ui/breadcrumb/**,stubs/stack/vue/js/components/ui/button/**,stubs/stack/vue/js/components/ui/button-group/**,stubs/stack/vue/js/components/ui/card/**,stubs/stack/vue/js/components/ui/checkbox/**,stubs/stack/vue/js/components/ui/collapsible/**,stubs/stack/vue/js/components/ui/dialog/**,stubs/stack/vue/js/components/ui/dropdown-menu/**,stubs/stack/vue/js/components/ui/field/**,stubs/stack/vue/js/components/ui/input/**,stubs/stack/vue/js/components/ui/input-group/**,stubs/stack/vue/js/components/ui/label/**,stubs/stack/vue/js/components/ui/number-field/**,stubs/stack/vue/js/components/ui/popover/**,stubs/stack/vue/js/components/ui/scroll-area/**,stubs/stack/vue/js/components/ui/separator/**,stubs/stack/vue/js/components/ui/sheet/**,stubs/stack/vue/js/components/ui/sidebar/**,stubs/stack/vue/js/components/ui/skeleton/**,stubs/stack/vue/js/components/ui/slider/**,stubs/stack/vue/js/components/ui/textarea/**,stubs/stack/vue/js/components/ui/tooltip/**
sonar.exclusions=stubs/recipes/**,stubs/stack/react/js/components/ui/*.tsx,stubs/stack/vue/js/components/ui/alert/**,stubs/stack/vue/js/components/ui/alert-dialog/**,stubs/stack/vue/js/components/ui/avatar/**,stubs/stack/vue/js/components/ui/badge/**,stubs/stack/vue/js/components/ui/breadcrumb/**,stubs/stack/vue/js/components/ui/button/**,stubs/stack/vue/js/components/ui/button-group/**,stubs/stack/vue/js/components/ui/card/**,stubs/stack/vue/js/components/ui/checkbox/**,stubs/stack/vue/js/components/ui/collapsible/**,stubs/stack/vue/js/components/ui/combobox/**,stubs/stack/vue/js/components/ui/dialog/**,stubs/stack/vue/js/components/ui/dropdown-menu/**,stubs/stack/vue/js/components/ui/field/**,stubs/stack/vue/js/components/ui/input/**,stubs/stack/vue/js/components/ui/input-group/**,stubs/stack/vue/js/components/ui/label/**,stubs/stack/vue/js/components/ui/number-field/**,stubs/stack/vue/js/components/ui/popover/**,stubs/stack/vue/js/components/ui/scroll-area/**,stubs/stack/vue/js/components/ui/select/**,stubs/stack/vue/js/components/ui/separator/**,stubs/stack/vue/js/components/ui/sheet/**,stubs/stack/vue/js/components/ui/sidebar/**,stubs/stack/vue/js/components/ui/skeleton/**,stubs/stack/vue/js/components/ui/slider/**,stubs/stack/vue/js/components/ui/table/**,stubs/stack/vue/js/components/ui/textarea/**,stubs/stack/vue/js/components/ui/tooltip/**
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"laravel/boost": "^2.10.3",
"laravel/framework": "^13.38",
"saucebase/breadcrumbs": "^1.1",
"saucebase/module-installer": "^3.0.1",
"saucebase/module-installer": "^3.3",
"spatie/laravel-data": "^4.23",
"spatie/laravel-navigation": "^1.3",
"spatie/laravel-permission": "^8.3.2",
Expand Down Expand Up @@ -61,6 +61,9 @@
}
},
"extra": {
"branch-alias": {
"dev-dev": "3.0.x-dev"
},
"laravel": {
"providers": [
"Saucebase\\Core\\CoreServiceProvider"
Expand Down
2 changes: 1 addition & 1 deletion config/saucebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'ignore_files' => ['module.json'],

/*
* The password of every account the demo seeders create. There is no default:
* The password of every account a state's seeders create. There is no default:
* a known password on a reachable admin account is the risk this avoids.
*/
'demo_password' => env('DEMO_PASSWORD'),
Expand Down
4 changes: 2 additions & 2 deletions resources/boost/guidelines/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module plugin.
`canAccess()` and created by the module's `DatabaseSeeder`, and site-wide settings pages are
`manage settings`. The `admin` role passes every check through core's
`Gate::before`. Roles are defined in core's `RolesDatabaseSeeder`; `admin` and `user` (the role
every sign-up gets) are fixed names modules may assign. The one exception is demo data: a module's
`Demo…DatabaseSeeder` may create a staff role for its own area (`blog admin`, `blog@saucebase.dev`).
every sign-up gets) are fixed names modules may assign. The one exception is showcase data: a module's
`Showcase…DatabaseSeeder` may create a staff role for its own area (`blog admin`, `blog@saucebase.dev`).
- Where a signed-in user lands is the app's choice: `Home::using(fn (Request $request, string $reason) => …)`
in a service provider (null means the site root). Modules redirect with `Home::url($request, Home::LOGIN)`
or link to `route('home')`, never `route('dashboard')`, which is only the dashboard page.
Expand Down
8 changes: 5 additions & 3 deletions resources/boost/skills/saucebase-module-development/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ redirects such as OAuth callbacks.
## Seeders

`php artisan modules:seed` runs `Modules\<Name>\Database\Seeders\DatabaseSeeder` for every installed module
that has one; `--module=<name>` limits it to one. `--demo` then also runs `Demo<Name>DatabaseSeeder`, after
every module's required data exists. Each set runs in registry order, except that a seeder marked
that has one; `--module=<name>` limits it to one. `--state=<state>` then also runs `<State><Name>DatabaseSeeder`, after
every module's required data exists; `showcase` is the sample content (`ShowcaseBlogDatabaseSeeder`). A state
no module provides fails. In production it asks first; `--force` (also on `saucebase:module-setup` and
`saucebase:module-install`) skips the question. Each set runs in registry order, except that a seeder marked
`#[SeedAfter('billing')]` (`Saucebase\Core\Attributes\SeedAfter`) runs after the named modules' seeder of the
same kind; modules that aren't installed are ignored. A module with an admin area creates its `manage {module}` permission
there (see `saucebase-filament-development`); demo seeders never hold anything an install needs.
there (see `saucebase-filament-development`); state seeders never hold anything an install needs.

## Patches

Expand Down
85 changes: 85 additions & 0 deletions resources/boost/skills/saucebase-template-development/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
name: saucebase-template-development
description: Create and develop Saucebase templates — a saucebase-template package that installs a whole app (its modules, features, replaced app files and demo state) into a new application. Use when setting up a template workspace, running saucebase:template-capture or saucebase:template-install, writing a template's stubs/ or Default…DatabaseSeeder, or installing an app with --template.
---

# Saucebase Template Development

A template is a module whose Composer type is `saucebase-template`, plus `stubs/`: app files it replaces on install. It installs once, into a new app, and the app owns the copied files. Everything the module skill says about code (`saucebase-module-development`) applies here too.

## Where you work

A template is built inside an app: the app runs it, the template is `modules/<name>`, and `saucebase.json` names it (`"template": "<name>"`). An app builds one template.

| App | Created with | Frontend files |
|---|---|---|
| Normal app (anyone) | `saucebase new <app> --modules=… --make-template=<vendor>/<name>` | App flat (`resources/js/pages`); template keeps `resources/js/{stack}/` |
| Contributor checkout (Saucebase team, also changing core or modules) | Contributor setup, `"template"` in `saucebase.json`, `tsconfig` `@/*` with `./resources/js/{stack}/*` first, then `saucebase:recipe <Name> template` | Both stacks, in their folders |

In an existing app: `php artisan saucebase:recipe <Name> template --vendor=<vendor>`, then `composer update <vendor>/<name>`.

`template-install` refuses a contributor checkout and an app that already has a template.

## The template's composer.json

The recipe writes it: `type: saucebase-template`, `require` = core and every Saucebase module the app has, `extra.saucebase.frameworks` = the stacks it kept.

- A module added later: `saucebase:module-install <module>`, then add it to `require` by hand.
- `extra.saucebase.configure` (optional): module settings for the install, e.g. `{"auth": {"registration_enabled": true}}`.
- `extra.saucebase.demo_account` (optional): the email the demo signs in with; the installer prints it after `--demo`.
- Keep the template's frontend in `resources/js/{stack}/`. The installer flattens it into apps of that stack and refuses a module without the folder.

## Stubs: replacing app files

- Edit the app's file (`resources/js/pages/Index.vue`, `routes/web.php`; in a contributor checkout `resources/js/vue/pages/Index.vue`), then `php artisan saucebase:template-capture <path>`. In a normal app, frontend files are filed under the stack folder for you. With no arguments it refreshes every existing stub; `--check` fails when one is stale.
- `stubs/` mirrors the app root. `resources/js/{vue,react}/…` and `resources/views/{vue,react}/…` lose the stack folder on install; the other stack's stubs are skipped.
- Refused: `composer.json`, `composer.lock`, `.env*`. `stubs/.env.example` is allowed: its missing keys are added to the app's `.env`.
- Import app code in stubs through `@/…`.
- Only replace what the template must. A stub is copied once; later template releases never reach existing apps.
- Most templates replace the starter kit's `routes/navigation.php` (its GitHub and Documentation links, "Welcome" for the dashboard) and `resources/js/{stack}/components/Footer.vue` (its credit), besides the home page and `routes/web.php`.

## Data

| Seeder | Runs |
|---|---|
| `DatabaseSeeder` | Every install: plans, permissions, anything the app needs to work |
| `Default<Name>DatabaseSeeder` | Only with `--demo` / `--state=default`: sample accounts and content |

- `default` is the template's demo. Modules don't ship `Default…` seeders; the template recipe scaffolds an empty one.
- Seeders run twice without duplicating (`firstOrCreate`, `updateOrCreate`). Test that: run the state twice.
- Demo passwords come from `config('saucebase.demo_password')`. Never a literal. `modules:seed` makes a random one when it's unset.
- A clean install has no demo data, so every empty page needs an empty state and a first action.

## Security

- Per-user records: bind them among the signed-in user's own (`Route::bind('note', fn ($id) => Note::where('user_id', Auth::id())->findOrFail($id))`), and child records through their parent (`scopeBindings()`). Someone else's is then a 404. Never guard ownership with a gate or policy alone: core's `Gate::before` lets admins pass every check.
- Validate into arrays and set the owner with `associate()`; never `$request->all()`.
- Escape `LIKE` input with a portable character (`escape '!'`), not a backslash (MySQL).

## Tests

Write each behaviour's failing test first, in `modules/<name>/tests`:

- Feature tests for routes and the state (`modules:seed --module=<name> --state=default`, twice).
- E2E for the replaced pages (`npx playwright test --project="@<Name>*"`; first run needs `php artisan playwright:env`).

## Check it as a user gets it

In `sandboxes/`, never in the app that builds it:

```bash
saucebase new my-app
cd my-app
composer config repositories.<name> '{"type":"path","url":"<path to modules/<name>>","options":{"symlink":false}}'
php artisan saucebase:template-install <vendor>/<name> [--state=default] # no DEMO_PASSWORD? one is made and saved
npm install && npm run build
```

From a registry the installer knows: `saucebase new my-app --template=<vendor>/<name> [--demo]`.

## Gotchas

- `template-install` takes the full package name; a bare name means `saucebase/<name>`.
- A path repository must copy (`"symlink": false`); the module installer refuses a symlink.
- Iterating through a path repository: `composer update` changes nothing while `version` stays the same. Run `composer reinstall <vendor>/<name>`, then `template-install` again.
- An app takes one template, installed into a fresh app. A failed run prints the command to retry.
65 changes: 65 additions & 0 deletions resources/js/lib/modal.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { initializeModals } from './modal';

/** Just enough of a page: a modal open, and a layer (a menu, a dialog) above it. */
class FakeKeyboardEvent extends Event {
key: string;

constructor(type: string, init: KeyboardEventInit = {}) {
super(type, init);
this.key = init.key ?? '';
}
}

const layerAbove = { closest: () => null };

beforeEach(() => {
const document = Object.assign(new EventTarget(), {
querySelector: (selector: string) =>
selector === '.im-modal-wrapper' ? {} : null,
querySelectorAll: () => [layerAbove],
});

Object.assign(globalThis, {
document,
window: new EventTarget(),
KeyboardEvent: FakeKeyboardEvent,
});
initializeModals(() => {});
});

afterEach(() => {
for (const key of ['document', 'window', 'KeyboardEvent']) {
Reflect.deleteProperty(globalThis, key);
}
});

function pressEscape(): Event {
const event = new FakeKeyboardEvent('keydown', {
key: 'Escape',
bubbles: true,
cancelable: true,
});
document.dispatchEvent(event);

return event;
}

describe('Escape over a modal', () => {
it('goes to the layer above, not the modal', () => {
let layerHeardIt = false;
window.addEventListener('keydown', () => (layerHeardIt = true));

pressEscape();

expect(layerHeardIt).toBe(true);
});

/** A layer may refuse Escape (mid-submit, say); the refusal must hold. */
it('keeps a refusal from the layer above', () => {
window.addEventListener('keydown', (event) => event.preventDefault());

expect(pressEscape().defaultPrevented).toBe(true);
});
});
79 changes: 71 additions & 8 deletions resources/js/lib/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,55 @@ export function initializeModals(putConfig: PutConfig): void {
);

releaseCoveredModalFocus();
escapeClosesTheTopLayerFirst();
}

/**
* Escape closes what is on top: a menu, select or dialog opened over a modal, not the
* modal under it.
*
* The modal listens for Escape on `document` and reka-ui's layers on `window`, so the
* modal hears it first and closes, taking the open menu and whatever was typed with
* it. Caught here on the way down instead: while a reka layer outside the modal is
* open, the key goes to `window` alone, where only reka is listening.
*/
function escapeClosesTheTopLayerFirst(): void {
if (typeof document === 'undefined') return;

document.addEventListener(
'keydown',
(event) => {
if (
event.key !== 'Escape' ||
!document.querySelector('.im-modal-wrapper')
) {
return;
}

// A closing layer stays in the page until its exit animation ends.
const layerAbove = [
...document.querySelectorAll(
'[data-dismissable-layer]:not([data-state="closed"])',
),
].some((layer) => !layer.closest('.im-modal-wrapper'));

if (layerAbove) {
event.stopPropagation();
// Cancelable, and its answer carried back: a layer that refuses Escape
// (mid-submit, say) stays open, and the browser's default stays off too.
const forwarded = new KeyboardEvent('keydown', {
key: 'Escape',
bubbles: true,
cancelable: true,
});

if (!window.dispatchEvent(forwarded)) {
event.preventDefault();
}
}
},
true,
);
}

/**
Expand All @@ -35,8 +84,10 @@ export function initializeModals(putConfig: PutConfig): void {
* overflows.
*
* An overlay marks everything it covered with `data-aria-hidden` when it opens,
* so a covered modal has an overlay above it and no business holding focus.
* Swallowing the event in the capture phase keeps it from reaching either trap.
* so a covered modal has an overlay above it and no business holding focus. A
* non-modal layer (popover, combobox) marks nothing, so focus landing inside one
* counts too. Swallowing the event in the capture phase keeps it from reaching
* either trap.
*/
function releaseCoveredModalFocus(): void {
// The server renders the same app but has no document to listen on.
Expand All @@ -45,15 +96,27 @@ function releaseCoveredModalFocus(): void {
document.addEventListener(
'focusin',
(event) => {
const covered = document.querySelector(
'[data-aria-hidden] .im-modal-wrapper',
);
const modal = document.querySelector('.im-modal-wrapper');
const target = event.target;

if (
covered &&
event.target instanceof Node &&
!covered.contains(event.target)
!modal ||
!(target instanceof Element) ||
modal.contains(target)
) {
return;
}

// Covered by a modal layer, or focus moving into a non-modal one (a popover
// or combobox opened from the modal): either way the trap must let go, or
// it pulls focus back and the layer closes as soon as it opens.
const covered = modal.closest('[data-aria-hidden]') !== null;
const intoLayer =
target.closest(
'[data-reka-popper-content-wrapper], [data-dismissable-layer]',
) !== null;

if (covered || intoLayer) {
event.stopPropagation();
}
},
Expand Down
Loading
Loading