From 541d1ee69038d076417e85e30fa9d4f977db86a3 Mon Sep 17 00:00:00 2001 From: Matthijs Iriks Date: Fri, 4 Dec 2026 05:42:12 +0100 Subject: [PATCH] Check for names the site already uses, and bring the docs up to 0.5.0 --- AGENTS.md | 2 +- CHANGELOG.md | 1 + README.md | 16 ++++++----- TOKENS.md | 1 + resources/ai/INTEGRATION.md | 8 ++++++ resources/boost/guidelines/core.blade.php | 3 ++- src/Console/DoctorCommand.php | 33 +++++++++++++++++++++++ tests/Feature/DoctorTest.php | 21 +++++++++++++++ 8 files changed, 77 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index dd01a61..bf5dec2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,5 +20,5 @@ between lil-koneko.com, CarsHub, iriks-it.nl and bouwbedrijf.iriks-it.nl, as one ## Open decisions 1. Frontend: decided and built: the screens are in the package (`ui/`, built into `resources/dist`, committed; PR CI checks it is up to date). Still open: a theme editor in the manager, and a `host` mode that publishes the sources for a site to build itself. -2. Moving the rest from bouwbedrijf.iriks-it.nl: real pages and reviews (now skeletons) and revisions. Users, media, posts, audit log and statistics are done, with their screens. Leave out what is site-specific (the IriksIT API disk, the owner's simple screens, client names): this repo is public. +2. Moving the rest from bouwbedrijf.iriks-it.nl: reviews (still a read-only list). Users, media, posts, pages with fields, resources, revisions, audit log and statistics are done, with their screens. Leave out what is site-specific (the IriksIT API disk, client names): this repo is public. Still open: two-factor login, cropping pictures, automated tests of the screens in CI. 3. Decided in 0.5.0: groups stay the default and the host's roles are added next to them (`manager.permissions`: `mode` groups, host or merge; `roles` or a `PermissionResolver`). A host that wants to replace the groups screens entirely is not planned. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4613ea7..534daaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ the section is the text of the release in Gitea. Cloudflare Turnstile is built in (two env keys). No two-factor login in the package itself. - Roles of the host: `manager.permissions` (`mode` groups/host/merge, `roles` map or a `resolver` implementing `PermissionResolver`) lets a site with its own roles say what an account may do; groups stay the default. +- `manager:doctor` has a `names` check: it warns when the site uses a route name or an address of the manager and says to set `route_name` or `path`. ## v0.4.0 - 2026-12-04 diff --git a/README.md b/README.md index 145dc92..ba042d5 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,11 @@ on the JSON routes. A browser that opens a manager address gets the page; anythi | `reviews` | Reviews | off | | `audit` | Audit log and address bans | off | | `statistics` | Visitor statistics | off | +| `resources` | Lists defined in config (`manager.resources`) | on (nothing without definitions) | +| `revisions` | History of posts and pages, with restore | on | Switch a part in `config/manager.php` (`modules`) or with `MANAGER_PAGES`, `MANAGER_POSTS`, -`MANAGER_REVIEWS`, `MANAGER_AUDIT`, `MANAGER_STATISTICS`. A module that is off has **no routes, no tables, no menu item and no permissions**: +`MANAGER_REVIEWS`, `MANAGER_AUDIT`, `MANAGER_STATISTICS`, `MANAGER_REVISIONS`. A module that is off has **no routes, no tables, no menu item and no permissions**: its migrations are not loaded at all. A module that needs another one (`requires()`) fails at boot when that one is off. @@ -228,12 +230,14 @@ scheduled daily), so a code cannot be traced back afterwards. A browser that sen ## State of this version -Done: module registry and switches, permissions per module, users (accounts, groups, command), media (library and public file -route), posts (with categories and tags), the audit log with bans, the statistics, the built-in screens for all of these (with a -login and profile), themes, and the install and doctor commands for AI agents. `composer test` runs the tests. +Done: module registry and switches, permissions per module, users (accounts, groups, command, roles of the host), media (library and +public file route, focus point), posts (with categories and tags), pages with fields, lists defined in config, the history with restore, +the audit log with bans, the statistics (with the counting script), the built-in screens for all of these (with a login, checks on the +login, a profile and the simple view), an editor, themes, translations, a site's own bundle of screens, the import of existing data, and +the install and doctor commands for AI agents. `composer test` runs the tests. -Pages and reviews are still skeletons (a read-only list), and revisions are not ported yet. The answers of every action are JSON -in the shape the screens use, so an app can build its own screens with `MANAGER_UI=none`. +Reviews are still a read-only list. The answers of every action are JSON in the shape the screens use, so an app can build its own screens +with `MANAGER_UI=none`. Not in the package: two-factor login (the login checks are the place for it), cropping or rotating pictures, a theme editor. ## Development cycle diff --git a/TOKENS.md b/TOKENS.md index fda5242..9282b13 100644 --- a/TOKENS.md +++ b/TOKENS.md @@ -43,3 +43,4 @@ Per stuk werk een rij; zie `dev/token-usage.py`. | 2026-12-04 | Het telscript en de Blade-component voor de publieke pagina's van de statistieken | - | claude-sonnet-5-5 | 8 | 9.037 | 16 | 15.948 | 2.254.948 | 0,04 | | 2026-12-04 | Loginhaken: eigen velden en controles, en Turnstile | - | claude-sonnet-5-5 | 4 | 9.009 | 8 | 9.515 | 1.178.544 | 0,02 | | 2026-12-04 | Rollen van de site naast de groepen van het pakket | - | claude-sonnet-5-5 | 3 | 5.308 | 6 | 8.235 | 921.246 | 0,01 | +| 2026-12-04 | Controle op namen die de site al gebruikt, en de documenten van 0.5.0 rechtgezet | - | claude-sonnet-5-5 | 9 | 7.281 | 18 | 12.115 | 2.881.457 | 0,03 | diff --git a/resources/ai/INTEGRATION.md b/resources/ai/INTEGRATION.md index 3c5db6a..8f8e750 100644 --- a/resources/ai/INTEGRATION.md +++ b/resources/ai/INTEGRATION.md @@ -17,6 +17,14 @@ order and never edit files inside `vendor/`. Repeat until `"ok": true`. Facts that matter: +- A site that already has `manager.*` route names, `manager_*` tables or its own posts and pages: `manager:doctor` has a `names` check that says + so. Set `route_name`, `table_prefix` or `tables` in `config/manager.php` before the first `migrate`, then copy what exists with + `php artisan manager:import posts|pages|reviews --table= --map== --dry-run` (the source is only read). +- What the site's own content looks like is configuration, not code: `manager.pages.definitions` (texts with keys, read with `Page::contentFor('slug')`), + `manager.resources` (lists such as services or testimonials, in a model of the site or the package's table) and `manager.menu` (order, sections, + icons, own links). A screen that needs code is a JavaScript module in `manager.extensions`; it registers with `IriksManager.register`. +- Who may do what: the groups of the package, or the roles of the site (`manager.permissions`); more on the login: `manager.login.checks`, Turnstile + with two env keys. The public pages count visits with `` when `statistics` is on. - The screens are part of the package (`MANAGER_UI=package`, the default): open `/manager` in a browser. The app does not need a login of its own: when it has no route named `login`, the manager's own login at `/manager/login` is used. With `MANAGER_UI=none` there are only the JSON routes. diff --git a/resources/boost/guidelines/core.blade.php b/resources/boost/guidelines/core.blade.php index 6b6a276..59914dd 100644 --- a/resources/boost/guidelines/core.blade.php +++ b/resources/boost/guidelines/core.blade.php @@ -1,9 +1,10 @@ ## iriks-it/laravel-manager -A modular backend (users, media, pages, posts, reviews, audit, statistics) installed as a package. +A modular backend (users, media, pages, posts, reviews, audit, statistics, resources, revisions) installed as a package. - To integrate it, follow `vendor/iriks-it/laravel-manager/resources/ai/INTEGRATION.md` step by step. - Set it up with `php artisan manager:install --modules=... --user-model=...`, then `config:clear`, `migrate`, `storage:link`; verify in a new process with `php artisan manager:doctor --json` (non-zero exit on failure, every problem has a `fix`). - The screens come with the package (`MANAGER_UI`), including a login when the app has none; themes: `php artisan manager:make-theme`, `MANAGER_THEME`. - The user model needs the `HasManagerAccess` trait; `is_super_admin` is never mass assignable. The first super admin comes from `php artisan manager:create-user`. +- The site's content is configuration: `manager.pages.definitions`, `manager.resources`, `manager.menu`, `manager.permissions`, `manager.login.checks`; code only as a JavaScript module in `manager.extensions`. Existing data comes in with `php artisan manager:import`. - Switch parts with `MANAGER_=true|false`; never edit `vendor/`. Site-specific parts are your own `Module` class. diff --git a/src/Console/DoctorCommand.php b/src/Console/DoctorCommand.php index f2c0d48..6bdb780 100644 --- a/src/Console/DoctorCommand.php +++ b/src/Console/DoctorCommand.php @@ -31,6 +31,7 @@ class DoctorCommand extends Command $this->checkUserModel($modules); $this->checkTables($modules); $this->checkRoutes(); + $this->checkNames(); $this->checkModules($modules); $failed = collect($this->checks)->contains('status', 'fail'); @@ -127,6 +128,38 @@ class DoctorCommand extends Command } } + /** Route names or addresses of the site that the package would share with its own. */ + private function checkNames(): void + { + $prefix = Names::routePrefix(); + $path = trim((string) config('manager.path'), '/'); + $names = []; + $foreign = []; + + foreach (Route::getRoutes()->getRoutes() as $route) { + $name = (string) $route->getName(); + $mine = $route->isFallback || ($route->getActionName() === 'Closure' && str_starts_with($name, $prefix)) || str_starts_with(ltrim($route->getActionName(), '\\'), 'IriksIT\\Manager\\'); + + if ($prefix !== '' && str_starts_with($name, $prefix) && $name !== $prefix) { + $names[$name] = ($names[$name] ?? 0) + 1; + } + + if (! $mine && ($route->uri() === $path || str_starts_with($route->uri(), $path.'/'))) { + $foreign[] = $route->uri(); + } + } + + $twice = array_keys(array_filter($names, fn (int $count) => $count > 1)); + + if ($twice !== []) { + $this->add('names', 'warn', 'Route names used twice: '.implode(', ', array_slice($twice, 0, 5)).'. The site and the manager share them, and one of the two stops working.', "Set 'route_name' in config/manager.php to something the site does not use, for example 'cms'."); + } elseif ($foreign !== []) { + $this->add('names', 'warn', 'The site has routes under the address of the manager: '.implode(', ', array_slice($foreign, 0, 5)).'.', "Move them, or set 'path' in config/manager.php (MANAGER_PATH) to another address."); + } else { + $this->add('names', 'ok', 'No route name or address is shared with the site.'); + } + } + private function checkModules(ModuleRegistry $modules): void { $active = array_keys($modules->active()); diff --git a/tests/Feature/DoctorTest.php b/tests/Feature/DoctorTest.php index 2c266ec..ba4fe6c 100644 --- a/tests/Feature/DoctorTest.php +++ b/tests/Feature/DoctorTest.php @@ -73,3 +73,24 @@ it('leaves the check to a new process after it changed the switches', function ( expect(Artisan::output())->toContain('manager:doctor')->not->toContain('[OK]'); }); + +it('finds no shared names in a clean setup', function () { + $check = collect(doctorReport()['checks'])->firstWhere('check', 'names'); + expect($check['message'])->toBe('No route name or address is shared with the site.'); +}); + +it('warns when the site uses a route name of the manager, and says what to set', function () { + Route::get('/home', fn () => 'x')->name('manager.dashboard'); + + $check = collect(doctorReport()['checks'])->firstWhere('check', 'names'); + + expect($check['status'])->toBe('warn')->and($check['message'])->toContain('manager.dashboard')->and($check['fix'])->toContain('route_name'); +}); + +it('warns when the site has routes under the address of the manager', function () { + Route::get('/manager/reports', fn () => 'x'); + + $check = collect(doctorReport()['checks'])->firstWhere('check', 'names'); + + expect($check['status'])->toBe('warn')->and($check['message'])->toContain('manager/reports'); +});