-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
81 changed files
with
1,522 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,117 @@ | ||
<?php | ||
|
||
use Mozex\Modules\Enums\AssetType; | ||
|
||
return [ | ||
'migration_patterns' => [ | ||
'Modules/*/Database/Migrations', | ||
[ | ||
'pattern' => 'Modules/*/Database/Migrations/*', | ||
'flags' => GLOB_ONLYDIR, | ||
'modules_directory' => 'Modules', | ||
'modules_namespace' => 'Modules\\', | ||
'assets' => [ | ||
AssetType::Commands->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Console/Commands', | ||
], | ||
], | ||
AssetType::Migrations->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Database/Migrations', | ||
], | ||
], | ||
AssetType::Helpers->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Helpers/*.php', | ||
'*/Helpers.php', | ||
], | ||
], | ||
AssetType::ServiceProviders->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Providers', | ||
], | ||
], | ||
AssetType::Seeders->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Database/Seeders', | ||
], | ||
], | ||
AssetType::Translations->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Resources/lang', | ||
], | ||
], | ||
AssetType::Schedules->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Console', | ||
], | ||
], | ||
AssetType::Configs->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Config/*.php', | ||
], | ||
], | ||
AssetType::Views->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Resources/views', | ||
], | ||
], | ||
AssetType::Routes->value => [ | ||
'active' => true, | ||
'patterns' => [ | ||
'*/Routes/*.php', | ||
], | ||
'groups' => [ | ||
'api' => [ | ||
'prefix' => 'api', | ||
'middlewares' => ['api'], | ||
], | ||
'web' => [ | ||
'middlewares' => ['web'], | ||
], | ||
// 'localized' => [ | ||
// 'middlewares' => [ | ||
// 'web', | ||
// 'localeSessionRedirect', | ||
// 'localizationRedirect', | ||
// ], | ||
// 'prefix' => LaravelLocalization::setLocale() | ||
// ] | ||
], | ||
], | ||
AssetType::Models->value => [ | ||
'namespace' => 'Models\\', | ||
], | ||
AssetType::Factories->value => [ | ||
'active' => true, | ||
'namespace' => 'Database\\Factories\\', | ||
], | ||
AssetType::Policies->value => [ | ||
'active' => true, | ||
'namespace' => 'Policies\\', | ||
], | ||
AssetType::LivewireComponents->value => [ | ||
'active' => false, | ||
'patterns' => [ | ||
'*/Livewire', | ||
], | ||
], | ||
AssetType::NovaResources->value => [ | ||
'active' => false, | ||
'patterns' => [ | ||
'*/Nova', | ||
], | ||
], | ||
], | ||
'seeder_patterns' => [ | ||
'Modules/*/Database/Seeders/*DatabaseSeeder.php', | ||
], | ||
'route_patterns' => [ | ||
'Modules/*/Routes/*.php', | ||
'routes/Modules/*/*.php', | ||
], | ||
'view_patterns' => [ | ||
'Modules/*/Resources/views', | ||
'resources/Modules/*/views', | ||
], | ||
'translation_patterns' => [ | ||
'Modules/*/Resources/lang', | ||
'resources/Modules/*/lang', | ||
'lang/Modules/*/', | ||
], | ||
'config_patterns' => [ | ||
'Modules/*/Config/*.php', | ||
'config/Modules/*/*.php', | ||
], | ||
'command_patterns' => [ | ||
'Modules/*/Console/Commands/*.php', | ||
], | ||
'nova_resource_patterns' => [ | ||
'Modules/*/Nova/*.php', | ||
], | ||
'livewire_component_patterns' => [ | ||
'Modules/*/Livewire/*.php', | ||
], | ||
'helper_patterns' => [ | ||
'Modules/*/Helpers/*.php', | ||
'Modules/*/Helpers.php', | ||
], | ||
'service_provider_patterns' => [ | ||
'Modules/*/Providers/*.php', | ||
], | ||
'kernel_patterns' => [ | ||
'Modules/*/Console/Kernel.php', | ||
], | ||
'api_middleware' => [ | ||
'api', | ||
], | ||
'default_middleware' => [ | ||
'web', | ||
'modules' => [ | ||
// 'Shared' => [ | ||
// 'active' => true, | ||
// 'order' => 1, // Optional | ||
// ], | ||
], | ||
'route_groups' => [], | ||
'modules' => [], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Mozex\Modules\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Mozex\Modules\Contracts\BaseScout; | ||
use Spatie\StructureDiscoverer\Data\DiscoveredClass; | ||
use Spatie\StructureDiscoverer\Discover; | ||
|
||
use function Laravel\Prompts\progress; | ||
|
||
class CacheCommand extends Command | ||
{ | ||
protected $signature = 'modules:cache'; | ||
|
||
protected $description = 'Cache all module assets.'; | ||
|
||
public function handle(): void | ||
{ | ||
progress( | ||
label: 'Caching Modules', | ||
steps: Discover::in(__DIR__.'/../') | ||
->classes() | ||
->extending(BaseScout::class) | ||
->custom(fn (DiscoveredClass $structure) => ! $structure->isAbstract) | ||
->get(), | ||
callback: function (string $scout, $progress) { | ||
/** @var BaseScout $discoverer */ | ||
$discoverer = app($scout); | ||
|
||
if ($discoverer->asset()->isDeactive()) { | ||
return; | ||
} | ||
|
||
$progress->label("Caching {$discoverer->asset()->title()}"); | ||
|
||
$discoverer->cacheDriver()->forget($discoverer->identifier()); | ||
|
||
$discoverer->cache(); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Mozex\Modules\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Mozex\Modules\Contracts\BaseScout; | ||
use Spatie\StructureDiscoverer\Data\DiscoveredClass; | ||
use Spatie\StructureDiscoverer\Discover; | ||
|
||
use function Laravel\Prompts\progress; | ||
|
||
class ClearCommand extends Command | ||
{ | ||
protected $signature = 'modules:clear'; | ||
|
||
protected $description = 'Clear all module assets cache.'; | ||
|
||
public function handle(): void | ||
{ | ||
progress( | ||
label: 'Clearing Modules Cache', | ||
steps: Discover::in(__DIR__.'/../') | ||
->classes() | ||
->extending(BaseScout::class) | ||
->custom(fn (DiscoveredClass $structure) => ! $structure->isAbstract) | ||
->get(), | ||
callback: function (string $scout, $progress) { | ||
/** @var BaseScout $discoverer */ | ||
$discoverer = app($scout); | ||
|
||
if ($discoverer->asset()->isDeactive()) { | ||
return; | ||
} | ||
|
||
$progress->label("Clearing {$discoverer->asset()->title()}"); | ||
|
||
$discoverer->cacheDriver()->forget($discoverer->identifier()); | ||
}, | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.