feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support
Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.
New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering
New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:19:56 +01:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Publishes enabled module web assets into web/modules/.
|
|
|
|
|
*
|
|
|
|
|
* Usage: php bin/module-assets-sync.php
|
|
|
|
|
*
|
|
|
|
|
* APP_MODULE_ASSET_MODE:
|
|
|
|
|
* - symlink (default): create web/modules/<module-id> symlinks to modules/<id>/web
|
|
|
|
|
* - copy: copy module web directories (for environments without symlink support)
|
|
|
|
|
*
|
|
|
|
|
* Exit codes:
|
|
|
|
|
* 0 — sync successful
|
|
|
|
|
* 1 — error during sync
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use MintyPHP\App\Module\ModuleRegistry;
|
|
|
|
|
use MintyPHP\App\Module\ModuleRuntimeAssetPublisher;
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/module-cli-bootstrap.php';
|
|
|
|
|
|
|
|
|
|
function moduleAssetsSyncRun(): int
|
|
|
|
|
{
|
2026-03-19 10:34:35 +01:00
|
|
|
return moduleCliRunStep('module-assets-sync', static function (): int {
|
|
|
|
|
$runtimeModulesDir = __DIR__ . '/../web/modules';
|
|
|
|
|
$lockFile = __DIR__ . '/../storage/runtime/.module-assets-sync.lock';
|
|
|
|
|
$mode = (string) getenv('APP_MODULE_ASSET_MODE');
|
|
|
|
|
if (trim($mode) === '') {
|
|
|
|
|
$mode = 'symlink';
|
feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support
Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.
New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering
New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-19 10:34:35 +01:00
|
|
|
return moduleCliWithFileLock(
|
|
|
|
|
$lockFile,
|
|
|
|
|
'module-assets-sync: another sync is in progress, skipping.',
|
|
|
|
|
static function () use ($runtimeModulesDir, $mode): int {
|
|
|
|
|
$registry = app(ModuleRegistry::class);
|
|
|
|
|
$publisher = new ModuleRuntimeAssetPublisher();
|
|
|
|
|
$result = $publisher->publish($runtimeModulesDir, $registry->getModules(), $mode);
|
|
|
|
|
|
|
|
|
|
fwrite(STDOUT, sprintf(
|
|
|
|
|
"module-assets-sync: mode=%s created=%d updated=%d removed=%d unchanged=%d\n",
|
|
|
|
|
$mode,
|
|
|
|
|
$result['created'],
|
|
|
|
|
$result['updated'],
|
|
|
|
|
$result['removed'],
|
|
|
|
|
$result['unchanged']
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support
Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.
New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering
New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PHP_SAPI === 'cli' && realpath((string) ($_SERVER['SCRIPT_FILENAME'] ?? '')) === __FILE__) {
|
|
|
|
|
exit(moduleAssetsSyncRun());
|
|
|
|
|
}
|