From bf2092721395df0d2a9b4e2770b243b36befc23c Mon Sep 17 00:00:00 2001 From: Hossain Mohammad Shahidullah Jaber Date: Thu, 27 Apr 2023 11:54:26 +0600 Subject: [PATCH 001/422] [feat] Indicate a sub-path for modules specific migration file Co-Authored-By: Abdul Majid Irfan <78084618+Irfan-Majid@users.noreply.github.com> --- src/Commands/MigrateRollbackCommand.php | 3 ++- src/Migrations/Migrator.php | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Commands/MigrateRollbackCommand.php b/src/Commands/MigrateRollbackCommand.php index 920c93b21..3afc81147 100644 --- a/src/Commands/MigrateRollbackCommand.php +++ b/src/Commands/MigrateRollbackCommand.php @@ -66,7 +66,7 @@ public function rollback($module) $module = $this->module->findOrFail($module); } - $migrator = new Migrator($module, $this->getLaravel()); + $migrator = new Migrator($module, $this->getLaravel(), $this->option('subpath')); $database = $this->option('database'); @@ -111,6 +111,7 @@ protected function getOptions() ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file'] ]; } } diff --git a/src/Migrations/Migrator.php b/src/Migrations/Migrator.php index 75901a19d..d2bd00d43 100644 --- a/src/Migrations/Migrator.php +++ b/src/Migrations/Migrator.php @@ -23,6 +23,14 @@ class Migrator */ protected $laravel; + /** + * Optional subpath for specific migration file. + * + * @var string|null + * @example subpath 2000_01_01_000000_create_example_table.php + */ + protected $subpath = null; + /** * The database connection to be used * @@ -34,11 +42,13 @@ class Migrator * Create new instance. * @param Module $module * @param Application $application + * @param string|null $subpath */ - public function __construct(Module $module, Application $application) + public function __construct(Module $module, Application $application, $subpath = null) { $this->module = $module; $this->laravel = $application; + $this->subpath = $subpath; } /** @@ -88,7 +98,11 @@ public function getPath() */ public function getMigrations($reverse = false) { - $files = $this->laravel['files']->glob($this->getPath() . '/*_*.php'); + if ($this->subpath) { + $files = $this->laravel['files']->glob($this->getPath() . '/' . $this->subpath); + } else { + $files = $this->laravel['files']->glob($this->getPath() . '/*_*.php'); + } // Once we have the array of files in the directory we will just remove the // extension and take the basename of the file which is all we need when From 0e0730fbbd8a13b8280b623c0c1b6db5c5cdfcd3 Mon Sep 17 00:00:00 2001 From: Hossain Mohammad Shahidullah Jaber Date: Thu, 27 Apr 2023 13:02:52 +0600 Subject: [PATCH 002/422] [feat] Indicate a sub-path for modules specific migration file Co-Authored-By: Abdul Majid Irfan <78084618+Irfan-Majid@users.noreply.github.com> Co-Authored-By: Delowar Hossain --- src/Migrations/Migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Migrations/Migrator.php b/src/Migrations/Migrator.php index d2bd00d43..c3a1afd61 100644 --- a/src/Migrations/Migrator.php +++ b/src/Migrations/Migrator.php @@ -29,7 +29,7 @@ class Migrator * @var string|null * @example subpath 2000_01_01_000000_create_example_table.php */ - protected $subpath = null; + protected $subpath = ''; /** * The database connection to be used @@ -98,7 +98,7 @@ public function getPath() */ public function getMigrations($reverse = false) { - if ($this->subpath) { + if (!empty($this->subpath)) { $files = $this->laravel['files']->glob($this->getPath() . '/' . $this->subpath); } else { $files = $this->laravel['files']->glob($this->getPath() . '/*_*.php'); From 82187602a8a11dbd36bae1716d1ca0a70a7039f6 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 11 Jul 2023 01:03:28 +0330 Subject: [PATCH 003/422] [feat] Add phpdoc to Module facade class for IDE auto completion --- src/Facades/Module.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Facades/Module.php b/src/Facades/Module.php index e4b930dee..1e0d32b65 100644 --- a/src/Facades/Module.php +++ b/src/Facades/Module.php @@ -4,14 +4,33 @@ use Illuminate\Support\Facades\Facade; +/** + * @method array all() + * @method array getCached() + * @method array scan() + * @method \Nwidart\Modules\Collection toCollection() + * @method array getScanPaths() + * @method array allEnabled() + * @method array allDisabled() + * @method int count() + * @method array getOrdered($direction = 'asc') + * @method array getByStatus($status) + * @method \Nwidart\Modules\Module find(string $name) + * @method \Nwidart\Modules\Module findOrFail(string $name) + * @method string getModulePath($moduleName) + * @method \Illuminate\Filesystem\Filesystem getFiles() + * @method mixed config(string $key, $default = NULL) + * @method string getPath() + * @method void boot() + * @method void register(): void + * @method string assetPath(string $module) + * @method bool delete(string $module) + * @method bool isEnabled(string $name) + * @method bool isDisabled(string $name) + */ class Module extends Facade { - /** - * Get the registered name of the component. - * - * @return string - */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'modules'; } From c38ea0f5d6308d793c5103382ab3c228bd9146eb Mon Sep 17 00:00:00 2001 From: aryaa <56627259+aryala7@users.noreply.github.com> Date: Wed, 12 Jul 2023 10:14:55 +0330 Subject: [PATCH 004/422] [feat] update DisableCommand to get list of modules --- src/Commands/DisableCommand.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Commands/DisableCommand.php b/src/Commands/DisableCommand.php index 69fef2b21..e4eba6b26 100644 --- a/src/Commands/DisableCommand.php +++ b/src/Commands/DisableCommand.php @@ -15,12 +15,19 @@ class DisableCommand extends Command */ protected $name = 'module:disable'; + /** + * The console command signature. + * + * @var string + */ + protected $signature = 'module:disable {module?*}'; + /** * The console command description. * * @var string */ - protected $description = 'Disable the specified module.'; + protected $description = 'Disable an array of modules.'; /** * Execute the console command. @@ -29,11 +36,10 @@ public function handle(): int { $this->components->info('Disabling module ...'); - if ($name = $this->argument('module') ) { + foreach($this->argument('module') as $name) { $this->disable($name); - - return 0; } + return 0; $this->disableAll(); From 1ef6323c7655ddde1086697cb46339a226d8c5c5 Mon Sep 17 00:00:00 2001 From: aryaa <56627259+aryala7@users.noreply.github.com> Date: Sat, 15 Jul 2023 14:12:30 +0330 Subject: [PATCH 005/422] [fix] check arguments count --- src/Commands/DisableCommand.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Commands/DisableCommand.php b/src/Commands/DisableCommand.php index e4eba6b26..70c37ec97 100644 --- a/src/Commands/DisableCommand.php +++ b/src/Commands/DisableCommand.php @@ -35,11 +35,13 @@ class DisableCommand extends Command public function handle(): int { $this->components->info('Disabling module ...'); - - foreach($this->argument('module') as $name) { - $this->disable($name); + + if (count($this->argument('module'))) { + foreach($this->argument('module') as $name) { + $this->disable($name); + } + return 0; } - return 0; $this->disableAll(); From d8e9070abe5eb11d86ec2da62e83e0a0c371bd8a Mon Sep 17 00:00:00 2001 From: Moeen Basra Date: Sun, 16 Jul 2023 02:30:43 +0200 Subject: [PATCH 006/422] fix provider stub --- src/Commands/stubs/scaffold/provider.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index c299d2126..8599fce44 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -3,7 +3,7 @@ namespace $NAMESPACE$; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factories\Factory; + class $CLASS$ extends ServiceProvider { @@ -104,7 +104,7 @@ class $CLASS$ extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } From 17826c1b5501a551522f6adc46b8a2ad236c8012 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 22 Jul 2023 14:48:49 +0100 Subject: [PATCH 007/422] removed unused test --- tests/Commands/MigrateCommandTest.php | 37 --------------------------- 1 file changed, 37 deletions(-) delete mode 100644 tests/Commands/MigrateCommandTest.php diff --git a/tests/Commands/MigrateCommandTest.php b/tests/Commands/MigrateCommandTest.php deleted file mode 100644 index 00ef3a9bf..000000000 --- a/tests/Commands/MigrateCommandTest.php +++ /dev/null @@ -1,37 +0,0 @@ -repository = new LaravelFileRepository($this->app); - $this->finder = $this->app['files']; - } - - /** @test */ - public function it_migrates_a_module() - { - $this->repository->addLocation(__DIR__ . '/../stubs/Recipe'); - - $this->artisan('module:migrate', ['module' => 'Recipe']); - - dd(Schema::hasTable('recipe__recipes'), $this->app['db']->table('recipe__recipes')->get()); - } -} From bf2fcadec31c075dc1b499f66afb1478cba67110 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 22 Jul 2023 14:49:09 +0100 Subject: [PATCH 008/422] updated snapshots --- phpunit.xml.dist | 45 +++++++++---------- ...it_can_change_the_default_namespace__1.txt | 28 ++++++++++++ ...generated_correct_file_with_content__1.txt | 28 ++++++++++++ ...generates_api_module_with_resources__1.txt | 4 +- ..._module_namespace_using_studly_case__1.txt | 4 +- ...Test__it_generates_module_resources__1.txt | 4 +- ...generates_web_module_with_resources__1.txt | 4 +- ...es_when_adding_more_than_one_option__1.txt | 4 +- ...it_can_change_the_default_namespace__1.txt | 4 +- ...ange_the_default_namespace_specific__1.txt | 4 +- ..._migration_resources_location_paths__1.txt | 4 +- ...vice_provider_with_resource_loading__1.txt | 4 +- 12 files changed, 95 insertions(+), 42 deletions(-) create mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_generated_correct_file_with_content__1.txt diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4712d716f..0526c79bc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,26 +1,23 @@ - - - - tests - - - - - src/ - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + src/ + + diff --git a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..bc32a72c3 --- /dev/null +++ b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -0,0 +1,28 @@ +moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index 30379cbc0..a3a8161a5 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -3,7 +3,7 @@ namespace Modules\ModuleName\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class ModuleNameServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class ModuleNameServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index a395df1e7..e268f9e16 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index a395df1e7..e268f9e16 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index a395df1e7..e268f9e16 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 9bd8d748f..2ac74b875 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\SuperProviders; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 9bd8d748f..2ac74b875 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\SuperProviders; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index a5e94c436..162c75a99 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index a395df1e7..e268f9e16 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -3,7 +3,7 @@ namespace Modules\Blog\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Database\Eloquent\Factory; + class BlogServiceProvider extends ServiceProvider { @@ -104,7 +104,7 @@ class BlogServiceProvider extends ServiceProvider private function getPublishableViewPaths(): array { $paths = []; - foreach (\Config::get('view.paths') as $path) { + foreach (config('view.paths') as $path) { if (is_dir($path . '/modules/' . $this->moduleNameLower)) { $paths[] = $path . '/modules/' . $this->moduleNameLower; } From d18bc39d319ddcbcba92d3252545310ddaefc5d9 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 22 Jul 2023 14:49:43 +0100 Subject: [PATCH 009/422] updated CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e3fb380a..863ab038c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Added + +- [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. + +## Changed + +- [@moeen-basra](https://github.com/moeen-basra) Remove the unused Factory import +- [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function +- [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable + ## 10.0 - 2023-02-14 ### Changed From 8e71544412a183ed4531266bcb5807c38b79ccf0 Mon Sep 17 00:00:00 2001 From: aryaa <56627259+aryala7@users.noreply.github.com> Date: Sat, 22 Jul 2023 22:57:26 +0330 Subject: [PATCH 010/422] [feat] implement make broadcast command --- config/config.php | 1 + src/Commands/ChannelMakeCommand.php | 87 +++++++++++++++++++++++++++++ src/Commands/stubs/channel.stub | 24 ++++++++ 3 files changed, 112 insertions(+) create mode 100644 src/Commands/ChannelMakeCommand.php create mode 100644 src/Commands/stubs/channel.stub diff --git a/config/config.php b/config/config.php index 0936d185d..8fe4f58c1 100644 --- a/config/config.php +++ b/config/config.php @@ -103,6 +103,7 @@ 'generator' => [ 'config' => ['path' => 'Config', 'generate' => true], 'command' => ['path' => 'Console', 'generate' => true], + 'channels' => ['path' => 'Broadcasting','generate' => true], 'migration' => ['path' => 'Database/Migrations', 'generate' => true], 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], 'factory' => ['path' => 'Database/factories', 'generate' => true], diff --git a/src/Commands/ChannelMakeCommand.php b/src/Commands/ChannelMakeCommand.php new file mode 100644 index 000000000..a4c5e6485 --- /dev/null +++ b/src/Commands/ChannelMakeCommand.php @@ -0,0 +1,87 @@ +laravel['modules']; + + return $module->config('paths.generator.channels.namespace') ?: $module->config('paths.generator.channels.path', 'Broadcasting'); + } + + /** + * Get template contents. + * + * @return string + */ + protected function getTemplateContents() + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub('/channel.stub', [ + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + ]))->render(); + } + + /** + * Get the destination file path. + * + * @return string + */ + protected function getDestinationFilePath() + { + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + + $channelPath = GenerateConfigReader::read('channels'); + + return $path . $channelPath->getPath() . '/' . $this->getFileName() . '.php'; + } + + /** + * @return string + */ + private function getFileName() + { + return Str::studly($this->argument('name')); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the channel class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } +} diff --git a/src/Commands/stubs/channel.stub b/src/Commands/stubs/channel.stub new file mode 100644 index 000000000..f68b0b0c8 --- /dev/null +++ b/src/Commands/stubs/channel.stub @@ -0,0 +1,24 @@ + Date: Sat, 22 Jul 2023 23:14:48 +0330 Subject: [PATCH 011/422] [feat] add test for channel make command --- tests/Commands/ChannelMakeCommandTest.php | 80 +++++++++++++++++++ .../Commands/NotificationMakeCommandTest.php | 22 ++--- 2 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 tests/Commands/ChannelMakeCommandTest.php diff --git a/tests/Commands/ChannelMakeCommandTest.php b/tests/Commands/ChannelMakeCommandTest.php new file mode 100644 index 000000000..a34e877ee --- /dev/null +++ b/tests/Commands/ChannelMakeCommandTest.php @@ -0,0 +1,80 @@ +modulePath = base_path('modules/Blog'); + $this->finder = $this->app['files']; + $this->artisan('module:make', ['name' => ['Blog']]); + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + /** @test */ + public function it_generates_the_mail_class() + { + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Notifications/WelcomeNotification.php')); + $this->assertSame(0, $code); + } + + /** @test */ + public function it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + /** @test */ + public function it_can_change_the_default_namespace() + { + $this->app['config']->set('modules.paths.generator.notifications.path', 'SuperNotifications'); + + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/SuperNotifications/WelcomeNotification.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + /** @test */ + public function it_can_change_the_default_namespace_specific() + { + $this->app['config']->set('modules.paths.generator.notifications.namespace', 'SuperNotifications'); + + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/NotificationMakeCommandTest.php b/tests/Commands/NotificationMakeCommandTest.php index a34e877ee..0077a18c7 100644 --- a/tests/Commands/NotificationMakeCommandTest.php +++ b/tests/Commands/NotificationMakeCommandTest.php @@ -6,7 +6,7 @@ use Nwidart\Modules\Tests\BaseTestCase; use Spatie\Snapshots\MatchesSnapshots; -class NotificationMakeCommandTest extends BaseTestCase +class ChannelMakeCommandTest extends BaseTestCase { use MatchesSnapshots; /** @@ -35,18 +35,18 @@ public function tearDown(): void /** @test */ public function it_generates_the_mail_class() { - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Notifications/WelcomeNotification.php')); + $this->assertTrue(is_file($this->modulePath . '/Broadcasting/WelcomeChannel.php')); $this->assertSame(0, $code); } /** @test */ public function it_generated_correct_file_with_content() { - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -55,11 +55,11 @@ public function it_generated_correct_file_with_content() /** @test */ public function it_can_change_the_default_namespace() { - $this->app['config']->set('modules.paths.generator.notifications.path', 'SuperNotifications'); + $this->app['config']->set('modules.paths.generator.channels.path', 'SuperChannel'); - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperNotifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath . '/SuperChannel/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,11 +68,11 @@ public function it_can_change_the_default_namespace() /** @test */ public function it_can_change_the_default_namespace_specific() { - $this->app['config']->set('modules.paths.generator.notifications.namespace', 'SuperNotifications'); + $this->app['config']->set('modules.paths.generator.channels.namespace', 'SuperChannel'); - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); From eb9c87e386d588407a54b5ff3270bb4bb0f56357 Mon Sep 17 00:00:00 2001 From: arya Date: Sat, 22 Jul 2023 23:57:32 +0330 Subject: [PATCH 012/422] [feat] implement test and define channelMake in base test case --- config/config.php | 1 + src/Providers/ConsoleServiceProvider.php | 1 + tests/BaseTestCase.php | 2 ++ tests/Commands/ChannelMakeCommandTest.php | 22 +++++++++---------- .../Commands/NotificationMakeCommandTest.php | 22 +++++++++---------- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/config/config.php b/config/config.php index 8fe4f58c1..19df47d00 100644 --- a/config/config.php +++ b/config/config.php @@ -143,6 +143,7 @@ | */ 'commands' => [ + Commands\ChannelMakeCommand::class, Commands\CommandMakeCommand::class, Commands\ComponentClassMakeCommand::class, Commands\ComponentViewMakeCommand::class, diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 76ead208e..ed80c6823 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -12,6 +12,7 @@ class ConsoleServiceProvider extends ServiceProvider * @var array */ protected $commands = [ + Commands\ChannelMakeCommand::class, Commands\CommandMakeCommand::class, Commands\ControllerMakeCommand::class, Commands\DisableCommand::class, diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 8c4ca94fc..465bd846c 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -55,6 +55,7 @@ protected function getEnvironmentSetUp($app) 'assets' => ['path' => 'Assets', 'generate' => true], 'config' => ['path' => 'Config', 'generate' => true], 'command' => ['path' => 'Console', 'generate' => true], + 'channels' => ['path' => 'Broadcasting', 'generate' => true], 'event' => ['path' => 'Events', 'generate' => true], 'listener' => ['path' => 'Listeners', 'generate' => true], 'migration' => ['path' => 'Database/Migrations', 'generate' => true], @@ -84,6 +85,7 @@ protected function getEnvironmentSetUp($app) $app['config']->set('modules.composer-output', true); $app['config']->set('modules.commands', [ + Commands\ChannelMakeCommand::class, Commands\CommandMakeCommand::class, Commands\ControllerMakeCommand::class, Commands\DisableCommand::class, diff --git a/tests/Commands/ChannelMakeCommandTest.php b/tests/Commands/ChannelMakeCommandTest.php index a34e877ee..0077a18c7 100644 --- a/tests/Commands/ChannelMakeCommandTest.php +++ b/tests/Commands/ChannelMakeCommandTest.php @@ -6,7 +6,7 @@ use Nwidart\Modules\Tests\BaseTestCase; use Spatie\Snapshots\MatchesSnapshots; -class NotificationMakeCommandTest extends BaseTestCase +class ChannelMakeCommandTest extends BaseTestCase { use MatchesSnapshots; /** @@ -35,18 +35,18 @@ public function tearDown(): void /** @test */ public function it_generates_the_mail_class() { - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Notifications/WelcomeNotification.php')); + $this->assertTrue(is_file($this->modulePath . '/Broadcasting/WelcomeChannel.php')); $this->assertSame(0, $code); } /** @test */ public function it_generated_correct_file_with_content() { - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -55,11 +55,11 @@ public function it_generated_correct_file_with_content() /** @test */ public function it_can_change_the_default_namespace() { - $this->app['config']->set('modules.paths.generator.notifications.path', 'SuperNotifications'); + $this->app['config']->set('modules.paths.generator.channels.path', 'SuperChannel'); - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperNotifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath . '/SuperChannel/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,11 +68,11 @@ public function it_can_change_the_default_namespace() /** @test */ public function it_can_change_the_default_namespace_specific() { - $this->app['config']->set('modules.paths.generator.notifications.namespace', 'SuperNotifications'); + $this->app['config']->set('modules.paths.generator.channels.namespace', 'SuperChannel'); - $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); + $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/NotificationMakeCommandTest.php b/tests/Commands/NotificationMakeCommandTest.php index 0077a18c7..a34e877ee 100644 --- a/tests/Commands/NotificationMakeCommandTest.php +++ b/tests/Commands/NotificationMakeCommandTest.php @@ -6,7 +6,7 @@ use Nwidart\Modules\Tests\BaseTestCase; use Spatie\Snapshots\MatchesSnapshots; -class ChannelMakeCommandTest extends BaseTestCase +class NotificationMakeCommandTest extends BaseTestCase { use MatchesSnapshots; /** @@ -35,18 +35,18 @@ public function tearDown(): void /** @test */ public function it_generates_the_mail_class() { - $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Broadcasting/WelcomeChannel.php')); + $this->assertTrue(is_file($this->modulePath . '/Notifications/WelcomeNotification.php')); $this->assertSame(0, $code); } /** @test */ public function it_generated_correct_file_with_content() { - $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); + $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -55,11 +55,11 @@ public function it_generated_correct_file_with_content() /** @test */ public function it_can_change_the_default_namespace() { - $this->app['config']->set('modules.paths.generator.channels.path', 'SuperChannel'); + $this->app['config']->set('modules.paths.generator.notifications.path', 'SuperNotifications'); - $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperChannel/WelcomeChannel.php'); + $file = $this->finder->get($this->modulePath . '/SuperNotifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,11 +68,11 @@ public function it_can_change_the_default_namespace() /** @test */ public function it_can_change_the_default_namespace_specific() { - $this->app['config']->set('modules.paths.generator.channels.namespace', 'SuperChannel'); + $this->app['config']->set('modules.paths.generator.notifications.namespace', 'SuperNotifications'); - $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); + $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); + $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); From f07f954e65787aee87f13ff651f83c84e2afccf8 Mon Sep 17 00:00:00 2001 From: arya Date: Sun, 23 Jul 2023 00:08:25 +0330 Subject: [PATCH 013/422] [fix] fix test name in channel --- tests/Commands/ChannelMakeCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Commands/ChannelMakeCommandTest.php b/tests/Commands/ChannelMakeCommandTest.php index 0077a18c7..49be68dda 100644 --- a/tests/Commands/ChannelMakeCommandTest.php +++ b/tests/Commands/ChannelMakeCommandTest.php @@ -33,7 +33,7 @@ public function tearDown(): void } /** @test */ - public function it_generates_the_mail_class() + public function it_generates_the_channel_class() { $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); From cfda40a92aa3761baad682f9c78d99aea51a644c Mon Sep 17 00:00:00 2001 From: arya Date: Sun, 23 Jul 2023 00:08:45 +0330 Subject: [PATCH 014/422] [fix] fix notification test name --- tests/Commands/NotificationMakeCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Commands/NotificationMakeCommandTest.php b/tests/Commands/NotificationMakeCommandTest.php index a34e877ee..61d19cedb 100644 --- a/tests/Commands/NotificationMakeCommandTest.php +++ b/tests/Commands/NotificationMakeCommandTest.php @@ -33,7 +33,7 @@ public function tearDown(): void } /** @test */ - public function it_generates_the_mail_class() + public function it_generates_the_notification_class() { $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); From 354d91d46907f9ecc8d7197c69186a2b84020ada Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 23 Jul 2023 16:29:05 +0100 Subject: [PATCH 015/422] updated CHANGELOG.md --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 863ab038c..beafca2d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,14 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Added -- [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. +- [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. [#1589](https://github.com/nWidart/laravel-modules/pull/1589) +- [@aryala7](https://github.com/aryala7) Add command to create broadcasting channel [#1599](https://github.com/nWidart/laravel-modules/pull/1599) ## Changed -- [@moeen-basra](https://github.com/moeen-basra) Remove the unused Factory import -- [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function -- [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable +- [@moeen-basra](https://github.com/moeen-basra) Remove the unused Factory import [#1596](https://github.com/nWidart/laravel-modules/pull/1596) +- [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function [#1596](https://github.com/nWidart/laravel-modules/pull/1596) +- [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable [#1591](https://github.com/nWidart/laravel-modules/pull/1591) ## 10.0 - 2023-02-14 From f27d030b4fbe5aeee0580d8e693d63600855c3f8 Mon Sep 17 00:00:00 2001 From: arya Date: Mon, 31 Jul 2023 14:30:24 +0330 Subject: [PATCH 016/422] [feat] implement test for disabling commands --- tests/Commands/DisableCommandTest.php | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Commands/DisableCommandTest.php diff --git a/tests/Commands/DisableCommandTest.php b/tests/Commands/DisableCommandTest.php new file mode 100644 index 000000000..50f6b0865 --- /dev/null +++ b/tests/Commands/DisableCommandTest.php @@ -0,0 +1,71 @@ +artisan('module:make', ['name' => ['Blog']]); + $this->artisan('module:make', ['name' => ['Taxonomy']]); + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + $this->app[RepositoryInterface::class]->delete('Taxonomy'); + parent::tearDown(); + } + + /** @test */ + public function it_disables_a_module() + { + /** @var Module $blogModule */ + $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule->disable(); + + $code = $this->artisan('module:disable', ['module' => ['Blog']]); + + $this->assertTrue($blogModule->isDisabled()); + $this->assertSame(0, $code); + } + + /** @test */ + public function it_disables_array_of_modules() + { + /** @var Module $blogModule */ + $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule->enable(); + + /** @var Module $taxonomyModule */ + $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); + $taxonomyModule->enable(); + + $code = $this->artisan('module:disable',['module' => ['Blog','Taxonomy']]); + + $this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled()); + $this->assertSame(0, $code); + } + + /** @test */ + public function it_disables_all_modules() + { + /** @var Module $blogModule */ + $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule->enable(); + + /** @var Module $taxonomyModule */ + $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); + $taxonomyModule->enable(); + + $code = $this->artisan('module:disable'); + + $this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled()); + $this->assertSame(0, $code); + } +} From ecba8cdd47a714fa8cb9416e515be6001a846a22 Mon Sep 17 00:00:00 2001 From: Hanie Asemi Date: Mon, 2 Oct 2023 15:07:35 +0330 Subject: [PATCH 017/422] [feat] Add observer make command --- config/config.php | 1 + src/Commands/ObserverMakeCommand.php | 91 ++++++++++++++++++++++++ src/Commands/stubs/observer.stub | 8 +++ src/Providers/ConsoleServiceProvider.php | 1 + 4 files changed, 101 insertions(+) create mode 100644 src/Commands/ObserverMakeCommand.php create mode 100644 src/Commands/stubs/observer.stub diff --git a/config/config.php b/config/config.php index 19df47d00..716afccfe 100644 --- a/config/config.php +++ b/config/config.php @@ -108,6 +108,7 @@ 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], 'factory' => ['path' => 'Database/factories', 'generate' => true], 'model' => ['path' => 'Entities', 'generate' => true], + 'observer' => ['path' => 'Observers', 'generate' => true], 'routes' => ['path' => 'Routes', 'generate' => true], 'controller' => ['path' => 'Http/Controllers', 'generate' => true], 'filter' => ['path' => 'Http/Middleware', 'generate' => true], diff --git a/src/Commands/ObserverMakeCommand.php b/src/Commands/ObserverMakeCommand.php new file mode 100644 index 000000000..c9289a9a4 --- /dev/null +++ b/src/Commands/ObserverMakeCommand.php @@ -0,0 +1,91 @@ +laravel['modules']->findOrFail($this->getModuleName()); + return (new Stub('/observer.stub', [ + 'NAMESPACE' => $this->getClassNamespace($module).'\Observers', + 'CLASS' => $this->getClass(), +// 'NAMESPACEMODEL' => $this->getClass() + ]))->render(); + } + /** + * @return mixed + */ + protected function getDestinationFilePath() + { + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $observerPath = GenerateConfigReader::read('observer'); + return $path . $observerPath->getPath() . '/' . $this->getFileName() . '.php'; + } + + /** + * @return string + */ + private function getFileName() + { + return Str::studly($this->argument('name')); + } + + + public function handle(): int + { + $this->components->info('Creating observer...'); + + parent::handle(); + + return 0; + } + +} diff --git a/src/Commands/stubs/observer.stub b/src/Commands/stubs/observer.stub new file mode 100644 index 000000000..c0aa0b931 --- /dev/null +++ b/src/Commands/stubs/observer.stub @@ -0,0 +1,8 @@ + Date: Tue, 3 Oct 2023 20:37:58 +0330 Subject: [PATCH 018/422] [feat] Add observer command --- src/Commands/ObserverMakeCommand.php | 48 +++++++++++++++--- src/Commands/stubs/observer.stub | 42 +++++++++++++++- tests/BaseTestCase.php | 1 + tests/Commands/ObserverMakeCommandTest.php | 47 +++++++++++++++++ ...rMakeCommandTest__it_makes_observer__1.php | 50 +++++++++++++++++++ ...rMakeCommandTest__it_makes_observer__1.txt | 48 ++++++++++++++++++ 6 files changed, 227 insertions(+), 9 deletions(-) create mode 100644 tests/Commands/ObserverMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php create mode 100644 tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.txt diff --git a/src/Commands/ObserverMakeCommand.php b/src/Commands/ObserverMakeCommand.php index c9289a9a4..68f8196a0 100644 --- a/src/Commands/ObserverMakeCommand.php +++ b/src/Commands/ObserverMakeCommand.php @@ -7,7 +7,6 @@ use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; class ObserverMakeCommand extends GeneratorCommand { @@ -55,19 +54,53 @@ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/observer.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module).'\Observers', - 'CLASS' => $this->getClass(), -// 'NAMESPACEMODEL' => $this->getClass() - ]))->render(); + 'NAMESPACE' => $this->getClassNamespace($module) . '\Observers', + 'NAME' => $this->getModelName(), + 'MODEL_NAMESPACE' => $this->getModelNamespace(), + 'NAME_VARIABLE' => $this->getModelVariable(), + ]))->render(); } + + /** + * Get model namespace. + * + * @return string + */ + public function getModelNamespace(): string + { + $path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities'); + + $path = str_replace('/', '\\', $path); + + return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path; + } + + /** + * @return mixed|string + */ + private function getModelName() + { + return Str::studly($this->argument('name')); + } + + /** + * @return mixed|string + */ + private function getModelVariable() : string + { + return '$'.Str::lower($this->argument('name')); + } + /** * @return mixed */ protected function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $observerPath = GenerateConfigReader::read('observer'); - return $path . $observerPath->getPath() . '/' . $this->getFileName() . '.php'; + + return $path . $observerPath->getPath() . '/' . $this->getFileName(); } /** @@ -75,7 +108,7 @@ protected function getDestinationFilePath() */ private function getFileName() { - return Str::studly($this->argument('name')); + return Str::studly($this->argument('name')) . 'Observer.php'; } @@ -87,5 +120,4 @@ public function handle(): int return 0; } - } diff --git a/src/Commands/stubs/observer.stub b/src/Commands/stubs/observer.stub index c0aa0b931..ca498635f 100644 --- a/src/Commands/stubs/observer.stub +++ b/src/Commands/stubs/observer.stub @@ -2,7 +2,47 @@ namespace $NAMESPACE$; -class $CLASS$ +use $MODEL_NAMESPACE$\$NAME$; + +class $NAME$Observer { + /** + * Handle the $NAME$ "created" event. + */ + public function created($NAME$ $NAME_VARIABLE$): void + { + // + } + + /** + * Handle the $NAME$ "updated" event. + */ + public function updated($NAME$ $NAME_VARIABLE$): void + { + // + } + + /** + * Handle the $NAME$ "deleted" event. + */ + public function deleted($NAME$ $NAME_VARIABLE$): void + { + // + } + + /** + * Handle the $NAME$ "restored" event. + */ + public function restored($NAME$ $NAME_VARIABLE$): void + { + // + } + /** + * Handle the $NAME$ "force deleted" event. + */ + public function forceDeleted($NAME$ $NAME_VARIABLE$): void + { + // + } } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 465bd846c..58f075e9f 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -61,6 +61,7 @@ protected function getEnvironmentSetUp($app) 'migration' => ['path' => 'Database/Migrations', 'generate' => true], 'factory' => ['path' => 'Database/factories', 'generate' => true], 'model' => ['path' => 'Entities', 'generate' => true], + 'observer' => ['path' => 'Observers', 'generate' => true], 'repository' => ['path' => 'Repositories', 'generate' => true], 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], 'controller' => ['path' => 'Http/Controllers', 'generate' => true], diff --git a/tests/Commands/ObserverMakeCommandTest.php b/tests/Commands/ObserverMakeCommandTest.php new file mode 100644 index 000000000..ab0a78f67 --- /dev/null +++ b/tests/Commands/ObserverMakeCommandTest.php @@ -0,0 +1,47 @@ +modulePath = base_path('modules/Blog'); + $this->finder = $this->app['files']; + $this->artisan('module:make', ['name' => ['Blog']]); + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + /** @test */ + public function it_makes_observer() + { + $code = $this->artisan('module:make-observer', ['name' => 'Post', 'module' => 'Blog']); + + $observerFile = $this->modulePath . '/Observers/PostObserver.php'; + // dd($observerFile); + + $this->assertTrue(is_file($observerFile), 'Observer file was not created.'); + $this->assertMatchesSnapshot($this->finder->get($observerFile)); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php b/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php new file mode 100644 index 000000000..8d0d30ea3 --- /dev/null +++ b/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php @@ -0,0 +1,50 @@ + Date: Thu, 5 Oct 2023 16:57:37 +0300 Subject: [PATCH 019/422] Test against php 8.2 and 8.3 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d4a140f06..14cb45832 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -10,7 +10,7 @@ jobs: strategy: max-parallel: 2 matrix: - php-versions: ['8.1'] + php-versions: ['8.1', '8.2', '8.3'] name: PHP ${{ matrix.php-versions }} From c23b194013a6f0394bb3bee6c143d40e400c03cd Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 14 Oct 2023 19:36:01 +0200 Subject: [PATCH 020/422] Command $name property works but it doesn't support options and maybe even arguments I lost more than an hour to realize that the signature was actually the name, and for this reason I couldn't pass options to the command. This was the only command I had generated from this stub and I was punished :-P --- src/Commands/stubs/command.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/command.stub b/src/Commands/stubs/command.stub index 87469deec..95145d84b 100644 --- a/src/Commands/stubs/command.stub +++ b/src/Commands/stubs/command.stub @@ -13,7 +13,7 @@ class $CLASS$ extends Command * * @var string */ - protected $name = '$COMMAND_NAME$'; + protected $signature = '$COMMAND_NAME$'; /** * The console command description. From c9e9a031d96fbd2c974e1366fbf7b9b818c98d90 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 18 Oct 2023 16:23:50 +0100 Subject: [PATCH 021/422] updated CHANGELOG.md --- CHANGELOG.md | 5 ++++ ...it_can_change_the_default_namespace__1.txt | 24 +++++++++++++++++++ ...ange_the_default_namespace_specific__1.txt | 24 +++++++++++++++++++ ...generated_correct_file_with_content__1.txt | 24 +++++++++++++++++++ ...it_can_change_the_default_namespace__1.txt | 2 +- ...ange_the_default_namespace_specific__1.txt | 2 +- ...generated_correct_file_with_content__1.txt | 2 +- ...__it_uses_set_command_name_in_class__1.txt | 2 +- 8 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__it_generated_correct_file_with_content__1.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index beafca2d9..252e568d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,18 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 10.1 - 2023-02-14 + ## Added +- [@sergiy-petrov](https://github.com/sergiy-petrov) Added support for testing GitHub actions against PHP versions 8.2 and 8.3. [#1624](https://github.com/nWidart/laravel-modules/pull/1624) +- [@hanieas](https://github.com/hanieas) Added make Observer command. [#1623](https://github.com/nWidart/laravel-modules/pull/1623) - [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. [#1589](https://github.com/nWidart/laravel-modules/pull/1589) - [@aryala7](https://github.com/aryala7) Add command to create broadcasting channel [#1599](https://github.com/nWidart/laravel-modules/pull/1599) ## Changed +- [@Rattone](https://github.com/Rattone) Updated stubs for command from `name` to `signature` [#1625](https://github.com/nWidart/laravel-modules/pull/1625) - [@moeen-basra](https://github.com/moeen-basra) Remove the unused Factory import [#1596](https://github.com/nWidart/laravel-modules/pull/1596) - [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function [#1596](https://github.com/nWidart/laravel-modules/pull/1596) - [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable [#1591](https://github.com/nWidart/laravel-modules/pull/1591) diff --git a/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..55d364bf9 --- /dev/null +++ b/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -0,0 +1,24 @@ + Date: Wed, 18 Oct 2023 16:38:12 +0100 Subject: [PATCH 022/422] updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 252e568d5..ed98ac958 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Added +- [@JaberWiki](https://github.com/JaberWiki) Added Include an optional flag `subpath` for rolling back a module's specific migration file [#1626](https://github.com/nWidart/laravel-modules/pull/1626) - [@sergiy-petrov](https://github.com/sergiy-petrov) Added support for testing GitHub actions against PHP versions 8.2 and 8.3. [#1624](https://github.com/nWidart/laravel-modules/pull/1624) - [@hanieas](https://github.com/hanieas) Added make Observer command. [#1623](https://github.com/nWidart/laravel-modules/pull/1623) - [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. [#1589](https://github.com/nWidart/laravel-modules/pull/1589) From 51d93c86e0fbcfb945fdb915e7734c43685d9f5a Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 18 Oct 2023 17:22:52 +0100 Subject: [PATCH 023/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed98ac958..eb4d107f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next -## 10.1 - 2023-02-14 +## 10.0.1 - 2023-09-18 ## Added @@ -21,7 +21,7 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function [#1596](https://github.com/nWidart/laravel-modules/pull/1596) - [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable [#1591](https://github.com/nWidart/laravel-modules/pull/1591) -## 10.0 - 2023-02-14 +## 10.0.0 - 2023-02-14 ### Changed From 840f1e83f08f69c31fb840d18d52c94bf23bd64d Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 18 Oct 2023 20:13:26 +0100 Subject: [PATCH 024/422] reorder config commands and added missing observer command --- config/config.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/config/config.php b/config/config.php index 716afccfe..30b304a93 100644 --- a/config/config.php +++ b/config/config.php @@ -103,7 +103,7 @@ 'generator' => [ 'config' => ['path' => 'Config', 'generate' => true], 'command' => ['path' => 'Console', 'generate' => true], - 'channels' => ['path' => 'Broadcasting','generate' => true], + 'channels' => ['path' => 'Broadcasting', 'generate' => true], 'migration' => ['path' => 'Database/Migrations', 'generate' => true], 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], 'factory' => ['path' => 'Database/factories', 'generate' => true], @@ -144,30 +144,29 @@ | */ 'commands' => [ - Commands\ChannelMakeCommand::class, Commands\CommandMakeCommand::class, Commands\ComponentClassMakeCommand::class, Commands\ComponentViewMakeCommand::class, Commands\ControllerMakeCommand::class, + Commands\ChannelMakeCommand::class, Commands\DisableCommand::class, Commands\DumpCommand::class, Commands\EnableCommand::class, Commands\EventMakeCommand::class, + Commands\FactoryMakeCommand::class, Commands\JobMakeCommand::class, Commands\ListenerMakeCommand::class, Commands\MailMakeCommand::class, Commands\MiddlewareMakeCommand::class, Commands\NotificationMakeCommand::class, + Commands\ObserverMakeCommand::class, + Commands\PolicyMakeCommand::class, Commands\ProviderMakeCommand::class, - Commands\RouteProviderMakeCommand::class, Commands\InstallCommand::class, + Commands\LaravelModulesV6Migrator::class, Commands\ListCommand::class, Commands\ModuleDeleteCommand::class, Commands\ModuleMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\RequestMakeCommand::class, - Commands\RuleMakeCommand::class, Commands\MigrateCommand::class, Commands\MigrateFreshCommand::class, Commands\MigrateRefreshCommand::class, @@ -176,6 +175,10 @@ Commands\MigrateStatusCommand::class, Commands\MigrationMakeCommand::class, Commands\ModelMakeCommand::class, + Commands\ResourceMakeCommand::class, + Commands\RequestMakeCommand::class, + Commands\RuleMakeCommand::class, + Commands\RouteProviderMakeCommand::class, Commands\PublishCommand::class, Commands\PublishConfigurationCommand::class, Commands\PublishMigrationCommand::class, @@ -183,12 +186,10 @@ Commands\SeedCommand::class, Commands\SeedMakeCommand::class, Commands\SetupCommand::class, + Commands\TestMakeCommand::class, Commands\UnUseCommand::class, Commands\UpdateCommand::class, Commands\UseCommand::class, - Commands\ResourceMakeCommand::class, - Commands\TestMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, ], /* From ef67a7367223ab96539136116d69405d1c21c321 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 18 Oct 2023 20:14:29 +0100 Subject: [PATCH 025/422] updated CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb4d107f4..7c2f622a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 10.0.2 - 2023-09-18 + +## Changed + +- reordered config commands and added missing observer command + ## 10.0.1 - 2023-09-18 ## Added From 15c53cdce09f8b4cf212eec2600e75eb85bb3534 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:02:01 -0700 Subject: [PATCH 026/422] Update config.php Format the file structure to the current Laravel standard. --- config/config.php | 94 +++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/config/config.php b/config/config.php index 30b304a93..9a1f52f25 100644 --- a/config/config.php +++ b/config/config.php @@ -29,14 +29,14 @@ 'enabled' => false, 'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'), 'files' => [ - 'routes/web' => 'Routes/web.php', - 'routes/api' => 'Routes/api.php', - 'views/index' => 'Resources/views/index.blade.php', - 'views/master' => 'Resources/views/layouts/master.blade.php', - 'scaffold/config' => 'Config/config.php', + 'routes/web' => 'routes/web.php', + 'routes/api' => 'routes/api.php', + 'views/index' => 'resources/views/index.blade.php', + 'views/master' => 'resources/views/layouts/master.blade.php', + 'scaffold/config' => 'config/config.php', 'composer' => 'composer.json', - 'assets/js/app' => 'Resources/assets/js/app.js', - 'assets/sass/app' => 'Resources/assets/sass/app.scss', + 'assets/js/app' => 'resources/assets/js/app.js', + 'assets/sass/app' => 'resources/assets/sass/app.scss', 'vite' => 'vite.config.js', 'package' => 'package.json', ], @@ -66,8 +66,8 @@ | Modules path |-------------------------------------------------------------------------- | - | This path used for save the generated module. This path also will be added - | automatically to list of scanned folders. + | This path is used to save the generated module. + | This path will also be added automatically to the list of scanned folders. | */ @@ -77,17 +77,17 @@ | Modules assets path |-------------------------------------------------------------------------- | - | Here you may update the modules assets path. + | Here you may update the modules' assets path. | */ 'assets' => public_path('modules'), /* |-------------------------------------------------------------------------- - | The migrations path + | The migrations' path |-------------------------------------------------------------------------- | - | Where you run 'module:publish-migration' command, where do you publish the + | Where you run the 'module:publish-migration' command, where do you publish the | the migration files? | */ @@ -98,38 +98,38 @@ | Generator path |-------------------------------------------------------------------------- | Customise the paths where the folders will be generated. - | Set the generate key to false to not generate that folder + | Set the generate's key to false to not generate that folder */ 'generator' => [ - 'config' => ['path' => 'Config', 'generate' => true], - 'command' => ['path' => 'Console', 'generate' => true], - 'channels' => ['path' => 'Broadcasting', 'generate' => true], - 'migration' => ['path' => 'Database/Migrations', 'generate' => true], - 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], - 'factory' => ['path' => 'Database/factories', 'generate' => true], - 'model' => ['path' => 'Entities', 'generate' => true], - 'observer' => ['path' => 'Observers', 'generate' => true], - 'routes' => ['path' => 'Routes', 'generate' => true], - 'controller' => ['path' => 'Http/Controllers', 'generate' => true], - 'filter' => ['path' => 'Http/Middleware', 'generate' => true], - 'request' => ['path' => 'Http/Requests', 'generate' => true], - 'provider' => ['path' => 'Providers', 'generate' => true], - 'assets' => ['path' => 'Resources/assets', 'generate' => true], - 'lang' => ['path' => 'Resources/lang', 'generate' => true], - 'views' => ['path' => 'Resources/views', 'generate' => true], - 'test' => ['path' => 'Tests/Unit', 'generate' => true], - 'test-feature' => ['path' => 'Tests/Feature', 'generate' => true], - 'repository' => ['path' => 'Repositories', 'generate' => false], - 'event' => ['path' => 'Events', 'generate' => false], - 'listener' => ['path' => 'Listeners', 'generate' => false], - 'policies' => ['path' => 'Policies', 'generate' => false], - 'rules' => ['path' => 'Rules', 'generate' => false], - 'jobs' => ['path' => 'Jobs', 'generate' => false], - 'emails' => ['path' => 'Emails', 'generate' => false], - 'notifications' => ['path' => 'Notifications', 'generate' => false], - 'resource' => ['path' => 'Transformers', 'generate' => false], - 'component-view' => ['path' => 'Resources/views/components', 'generate' => false], - 'component-class' => ['path' => 'View/Components', 'generate' => false], + 'config' => ['path' => 'config', 'generate' => true], + 'command' => ['path' => 'app/Console', 'generate' => false], + 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], + 'migration' => ['path' => 'database/migrations', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'generate' => true], + 'model' => ['path' => 'app/Models', 'generate' => true], + 'observer' => ['path' => 'app/Observers', 'generate' => false], + 'routes' => ['path' => 'routes', 'generate' => true], + 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], + 'filter' => ['path' => 'app/Http/Middleware', 'generate' => true], + 'request' => ['path' => 'app/Http/Requests', 'generate' => true], + 'provider' => ['path' => 'app/Providers', 'generate' => true], + 'assets' => ['path' => 'resources/assets', 'generate' => true], + 'lang' => ['path' => 'lang', 'generate' => true], + 'views' => ['path' => 'resources/views', 'generate' => true], + 'test' => ['path' => 'tests/Unit', 'generate' => true], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], + 'repository' => ['path' => 'app/Repositories', 'generate' => false], + 'event' => ['path' => 'app/Events', 'generate' => false], + 'listener' => ['path' => 'app/Listeners', 'generate' => false], + 'policies' => ['path' => 'app/Policies', 'generate' => false], + 'rules' => ['path' => 'app/Rules', 'generate' => false], + 'jobs' => ['path' => 'app/Jobs', 'generate' => false], + 'emails' => ['path' => 'app/Emails', 'generate' => false], + 'notifications' => ['path' => 'app/Notifications', 'generate' => false], + 'resource' => ['path' => 'app/Resources', 'generate' => false], + 'component-view' => ['path' => 'resources/views/components', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], ], ], @@ -139,7 +139,7 @@ |-------------------------------------------------------------------------- | | Here you can define which commands will be visible and used in your - | application. If for example you don't use some of the commands provided + | application. If for example, you don't use some of the commands provided | you can simply comment them out. | */ @@ -213,7 +213,7 @@ | Composer File Template |-------------------------------------------------------------------------- | - | Here is the config for composer.json file, generated by this package + | Here is the config for the composer.json file, generated by this package | */ @@ -231,7 +231,7 @@ | Caching |-------------------------------------------------------------------------- | - | Here is the config for setting up caching feature. + | Here is the config for setting up the caching feature. | */ 'cache' => [ @@ -264,14 +264,14 @@ | Activators |-------------------------------------------------------------------------- | - | You can define new types of activators here, file, database etc. The only + | You can define new types of activators here, file, database, etc. The only | required parameter is 'class'. | The file activator will store the activation status in storage/installed_modules */ 'activators' => [ 'file' => [ 'class' => FileActivator::class, - 'statuses-file' => base_path('modules_statuses.json'), + 'statuses-file' => base_path('modules.json'), 'cache-key' => 'activator.installed', 'cache-lifetime' => 604800, ], From cd4a0f6da1193625ccabdb3292f55f0eb7467be1 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:18:26 -0700 Subject: [PATCH 027/422] Update seeder.stub --- src/Commands/stubs/seeder.stub | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Commands/stubs/seeder.stub b/src/Commands/stubs/seeder.stub index f35057de3..3882d1cf9 100644 --- a/src/Commands/stubs/seeder.stub +++ b/src/Commands/stubs/seeder.stub @@ -3,19 +3,14 @@ namespace $NAMESPACE$; use Illuminate\Database\Seeder; -use Illuminate\Database\Eloquent\Model; class $NAME$ extends Seeder { /** * Run the database seeds. - * - * @return void */ - public function run() + public function run(): void { - Model::unguard(); - - // $this->call("OthersTableSeeder"); + // $this->call([]); } } From 990ca1ce853cd756c41fd32b00e818bf3006fe17 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:32:58 -0700 Subject: [PATCH 028/422] Update rule.stub Format to the current Laravel standard. --- src/Commands/stubs/rule.stub | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Commands/stubs/rule.stub b/src/Commands/stubs/rule.stub index 9b716321e..0da463619 100644 --- a/src/Commands/stubs/rule.stub +++ b/src/Commands/stubs/rule.stub @@ -8,32 +8,24 @@ class $CLASS$ implements Rule { /** * Create a new rule instance. - * - * @return void */ - public function __construct() + public function __construct(): void { // } /** * Determine if the validation rule passes. - * - * @param string $attribute - * @param mixed $value - * @return bool */ - public function passes($attribute, $value) + public function passes(string $attribute, $value): bool { // } /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'The validation error message.'; } From b1e1beaba4c2da8b9e92ad149c0622d9989ec326 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:42:10 -0700 Subject: [PATCH 029/422] Update route-provider.stub Format to the current Laravel standard. --- src/Commands/stubs/route-provider.stub | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Commands/stubs/route-provider.stub b/src/Commands/stubs/route-provider.stub index 67f3a6d24..f622e406b 100644 --- a/src/Commands/stubs/route-provider.stub +++ b/src/Commands/stubs/route-provider.stub @@ -9,8 +9,6 @@ class $CLASS$ extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$'; @@ -18,20 +16,16 @@ class $CLASS$ extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class $CLASS$ extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class $CLASS$ extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') From 4646f9f4f5eca2273774ba79663e97322ebebcd7 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:47:24 -0700 Subject: [PATCH 030/422] Update resource.stub Format to the current Laravel standard. --- src/Commands/stubs/resource.stub | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Commands/stubs/resource.stub b/src/Commands/stubs/resource.stub index 6a1f18390..3ba4b154d 100644 --- a/src/Commands/stubs/resource.stub +++ b/src/Commands/stubs/resource.stub @@ -8,11 +8,8 @@ class $CLASS$ extends JsonResource { /** * Transform the resource into an array. - * - * @param \Illuminate\Http\Request - * @return array */ - public function toArray($request) + public function toArray($request): array { return parent::toArray($request); } From 05bc1e6f36e2ede2786096f3dc5970a98060c340 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:50:53 -0700 Subject: [PATCH 031/422] Update resource-collection.stub Format to the current Laravel standard. --- src/Commands/stubs/resource-collection.stub | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Commands/stubs/resource-collection.stub b/src/Commands/stubs/resource-collection.stub index c88f43b85..0bb408aee 100644 --- a/src/Commands/stubs/resource-collection.stub +++ b/src/Commands/stubs/resource-collection.stub @@ -8,11 +8,8 @@ class $CLASS$ extends ResourceCollection { /** * Transform the resource collection into an array. - * - * @param \Illuminate\Http\Request - * @return array */ - public function toArray($request) + public function toArray($request): array { return parent::toArray($request); } From 1f4c32d49a9249dc780f563c77e7993b2b6c8e86 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:53:57 -0700 Subject: [PATCH 032/422] Update request.stub Format to the current Laravel standard. --- src/Commands/stubs/request.stub | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Commands/stubs/request.stub b/src/Commands/stubs/request.stub index 96e06163c..202d2e0dd 100644 --- a/src/Commands/stubs/request.stub +++ b/src/Commands/stubs/request.stub @@ -8,10 +8,8 @@ class $CLASS$ extends FormRequest { /** * Get the validation rules that apply to the request. - * - * @return array */ - public function rules() + public function rules(): array { return [ // @@ -20,10 +18,8 @@ class $CLASS$ extends FormRequest /** * Determine if the user is authorized to make this request. - * - * @return bool */ - public function authorize() + public function authorize(): bool { return true; } From c2b48e0680839be26c89e6a9f92b2c96ac611267 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:56:34 -0700 Subject: [PATCH 033/422] Update provider.stub Format to the current Laravel standard. --- src/Commands/stubs/provider.stub | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Commands/stubs/provider.stub b/src/Commands/stubs/provider.stub index 4e370777c..535c8b6ef 100644 --- a/src/Commands/stubs/provider.stub +++ b/src/Commands/stubs/provider.stub @@ -8,20 +8,16 @@ class $CLASS$ extends ServiceProvider { /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { // } /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } From 1a9eabe02d254ede07e7847173a2f0a4f81edceb Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 16:58:52 -0700 Subject: [PATCH 034/422] Update policy.plain.stub Format to the current Laravel standard. --- src/Commands/stubs/policy.plain.stub | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Commands/stubs/policy.plain.stub b/src/Commands/stubs/policy.plain.stub index 02e16df36..da9210910 100644 --- a/src/Commands/stubs/policy.plain.stub +++ b/src/Commands/stubs/policy.plain.stub @@ -10,10 +10,8 @@ class $CLASS$ /** * Create a new policy instance. - * - * @return void */ - public function __construct() + public function __construct(): void { // } From 6a3e246ca176c8e919ad08fbe1319c5c89ae60ef Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:11:57 -0700 Subject: [PATCH 035/422] Update policy.plain.stub --- src/Commands/stubs/policy.plain.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/policy.plain.stub b/src/Commands/stubs/policy.plain.stub index da9210910..17d0c99a1 100644 --- a/src/Commands/stubs/policy.plain.stub +++ b/src/Commands/stubs/policy.plain.stub @@ -11,7 +11,7 @@ class $CLASS$ /** * Create a new policy instance. */ - public function __construct(): void + public function __construct() { // } From 890a7654d3595877d86433265870f1d44d2e165e Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:14:24 -0700 Subject: [PATCH 036/422] Update rule.stub --- src/Commands/stubs/rule.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/rule.stub b/src/Commands/stubs/rule.stub index 0da463619..4bd15dd4b 100644 --- a/src/Commands/stubs/rule.stub +++ b/src/Commands/stubs/rule.stub @@ -9,7 +9,7 @@ class $CLASS$ implements Rule /** * Create a new rule instance. */ - public function __construct(): void + public function __construct() { // } From 3b6af2945adfc57626aab86ff8c277fe8a6d3708 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:23:38 -0700 Subject: [PATCH 037/422] Update notification.stub --- src/Commands/stubs/notification.stub | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/Commands/stubs/notification.stub b/src/Commands/stubs/notification.stub index 21aeb8772..691a91aea 100644 --- a/src/Commands/stubs/notification.stub +++ b/src/Commands/stubs/notification.stub @@ -13,8 +13,6 @@ class $CLASS$ extends Notification /** * Create a new notification instance. - * - * @return void */ public function __construct() { @@ -23,39 +21,28 @@ class $CLASS$ extends Notification /** * Get the notification's delivery channels. - * - * @param mixed $notifiable - * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail($notifiable): MailMessage { return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); + ->line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); } /** * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array */ - public function toArray($notifiable) + public function toArray($notifiable): array { - return [ - // - ]; + return []; } } From 4a9c1baca6db5fbe6f2a36b389668bf77527fbca Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:31:00 -0700 Subject: [PATCH 038/422] Update middleware.stub Formatted. --- src/Commands/stubs/middleware.stub | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Commands/stubs/middleware.stub b/src/Commands/stubs/middleware.stub index 954583ed4..bdd192dfc 100644 --- a/src/Commands/stubs/middleware.stub +++ b/src/Commands/stubs/middleware.stub @@ -9,10 +9,6 @@ class $CLASS$ { /** * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed */ public function handle(Request $request, Closure $next) { From 63b9400e705a2e9433ae6c97ae80c4f43d43bede Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:46:31 -0700 Subject: [PATCH 039/422] Update mail.stub Formatted. --- src/Commands/stubs/mail.stub | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Commands/stubs/mail.stub b/src/Commands/stubs/mail.stub index 7e9a47b84..67159f898 100644 --- a/src/Commands/stubs/mail.stub +++ b/src/Commands/stubs/mail.stub @@ -13,8 +13,6 @@ class $CLASS$ extends Mailable /** * Create a new message instance. - * - * @return void */ public function __construct() { @@ -23,10 +21,8 @@ class $CLASS$ extends Mailable /** * Build the message. - * - * @return $this */ - public function build() + public function build(): self { return $this->view('view.name'); } From 37046d91477599a8a6aa931d6197f712c3f23934 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:49:50 -0700 Subject: [PATCH 040/422] Update listener.stub Formatted. --- src/Commands/stubs/listener.stub | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Commands/stubs/listener.stub b/src/Commands/stubs/listener.stub index d52751663..44361865d 100644 --- a/src/Commands/stubs/listener.stub +++ b/src/Commands/stubs/listener.stub @@ -10,8 +10,6 @@ class $CLASS$ { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -20,11 +18,8 @@ class $CLASS$ /** * Handle the event. - * - * @param $SHORTEVENTNAME$ $event - * @return void */ - public function handle($SHORTEVENTNAME$ $event) + public function handle($SHORTEVENTNAME$ $event): void { // } From 95a000c27fc1d1e301bdffc445cbecdf1c0738f1 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 17:58:19 -0700 Subject: [PATCH 041/422] Update listener-queued.stub Formatted. --- src/Commands/stubs/listener-queued.stub | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Commands/stubs/listener-queued.stub b/src/Commands/stubs/listener-queued.stub index f60ddf7a3..68e67b9ac 100644 --- a/src/Commands/stubs/listener-queued.stub +++ b/src/Commands/stubs/listener-queued.stub @@ -12,8 +12,6 @@ class $CLASS$ implements ShouldQueue /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -22,11 +20,8 @@ class $CLASS$ implements ShouldQueue /** * Handle the event. - * - * @param $SHORTEVENTNAME$ $event - * @return void */ - public function handle($SHORTEVENTNAME$ $event) + public function handle($SHORTEVENTNAME$ $event): void { // } From 91a5db6056e7806dacc40e788d3a9c76b2d3a910 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:00:02 -0700 Subject: [PATCH 042/422] Update listener-queued-duck.stub Formatted. --- src/Commands/stubs/listener-queued-duck.stub | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Commands/stubs/listener-queued-duck.stub b/src/Commands/stubs/listener-queued-duck.stub index d61c99226..f80d5d6f2 100644 --- a/src/Commands/stubs/listener-queued-duck.stub +++ b/src/Commands/stubs/listener-queued-duck.stub @@ -10,9 +10,7 @@ class $CLASS$ implements ShouldQueue use InteractsWithQueue; /** - * Create the event listener. - * - * @return void + * Create the event listener */ public function __construct() { @@ -21,11 +19,8 @@ class $CLASS$ implements ShouldQueue /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle($event): void { // } From 778d9fcb97b271c4a658fcb2f152731a7426aba5 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:01:18 -0700 Subject: [PATCH 043/422] Update listener-duck.stub Formatted. --- src/Commands/stubs/listener-duck.stub | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Commands/stubs/listener-duck.stub b/src/Commands/stubs/listener-duck.stub index 5d700db5b..d78019275 100644 --- a/src/Commands/stubs/listener-duck.stub +++ b/src/Commands/stubs/listener-duck.stub @@ -9,8 +9,6 @@ class $CLASS$ { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -19,11 +17,8 @@ class $CLASS$ /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle($event): void { // } From 1b639d7c49c7b4662ec1861b5ef382422d52de92 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:03:16 -0700 Subject: [PATCH 044/422] Update job.stub Formatted. --- src/Commands/stubs/job.stub | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Commands/stubs/job.stub b/src/Commands/stubs/job.stub index 3a8836999..84d0bb992 100644 --- a/src/Commands/stubs/job.stub +++ b/src/Commands/stubs/job.stub @@ -11,8 +11,6 @@ class $CLASS$ implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -21,10 +19,8 @@ class $CLASS$ implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } From 2380b4bc9c3ca410f41c0e63fd6fd0121a462918 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:06:01 -0700 Subject: [PATCH 045/422] Update job-queued.stub Formatted. --- src/Commands/stubs/job-queued.stub | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Commands/stubs/job-queued.stub b/src/Commands/stubs/job-queued.stub index 5bcccf1a2..26dd3f0de 100644 --- a/src/Commands/stubs/job-queued.stub +++ b/src/Commands/stubs/job-queued.stub @@ -14,8 +14,6 @@ class $CLASS$ implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -24,10 +22,8 @@ class $CLASS$ implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } From e76a39611086894a63fdac2b9a13d8afb8d839ce Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:08:15 -0700 Subject: [PATCH 046/422] Update feature-test.stub Formatted. --- src/Commands/stubs/feature-test.stub | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Commands/stubs/feature-test.stub b/src/Commands/stubs/feature-test.stub index f344b5d01..316953493 100644 --- a/src/Commands/stubs/feature-test.stub +++ b/src/Commands/stubs/feature-test.stub @@ -10,10 +10,8 @@ class $CLASS$ extends TestCase { /** * A basic feature test example. - * - * @return void */ - public function testExample() + public function testExample(): void { $response = $this->get('/'); From 55837efcaa1717a0e9a6d17fcd933c5c6da76aba Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:10:37 -0700 Subject: [PATCH 047/422] Update factory.stub Formatted. --- src/Commands/stubs/factory.stub | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Commands/stubs/factory.stub b/src/Commands/stubs/factory.stub index a2c39a839..ece09967d 100644 --- a/src/Commands/stubs/factory.stub +++ b/src/Commands/stubs/factory.stub @@ -8,21 +8,15 @@ class $NAME$Factory extends Factory { /** * The name of the factory's corresponding model. - * - * @var string */ protected $model = \$MODEL_NAMESPACE$\$NAME$::class; /** * Define the model's default state. - * - * @return array */ - public function definition() + public function definition(): array { - return [ - // - ]; + return []; } } From a5d026a94ea62af5c79be00d91fb5e6785ab9b8d Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:12:10 -0700 Subject: [PATCH 048/422] Update event.stub Formatted. --- src/Commands/stubs/event.stub | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Commands/stubs/event.stub b/src/Commands/stubs/event.stub index ad1cb6966..ff4ff0733 100644 --- a/src/Commands/stubs/event.stub +++ b/src/Commands/stubs/event.stub @@ -10,8 +10,6 @@ class $CLASS$ /** * Create a new event instance. - * - * @return void */ public function __construct() { @@ -20,10 +18,8 @@ class $CLASS$ /** * Get the channels the event should be broadcast on. - * - * @return array */ - public function broadcastOn() + public function broadcastOn(): array { return []; } From eb99eb2e618dd0cb6badd101f9d4ff4b3adda406 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:22:07 -0700 Subject: [PATCH 049/422] Update controller.stub Formatted. --- src/Commands/stubs/controller.stub | 32 ++++++++++-------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/Commands/stubs/controller.stub b/src/Commands/stubs/controller.stub index 30fcff098..e8b7164b9 100644 --- a/src/Commands/stubs/controller.stub +++ b/src/Commands/stubs/controller.stub @@ -2,77 +2,65 @@ namespace $CLASS_NAMESPACE$; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class $CLASS$ extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('$LOWER_NAME$::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('$LOWER_NAME$::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('$LOWER_NAME$::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('$LOWER_NAME$::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } From bb53abf919a88babf0f6c160767b7f98df99e8dc Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:38:27 -0700 Subject: [PATCH 050/422] Update controller-api.stub Formatted. --- src/Commands/stubs/controller-api.stub | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Commands/stubs/controller-api.stub b/src/Commands/stubs/controller-api.stub index 8cdac7c82..54062c3c3 100644 --- a/src/Commands/stubs/controller-api.stub +++ b/src/Commands/stubs/controller-api.stub @@ -2,59 +2,61 @@ namespace $CLASS_NAMESPACE$; +use App\Http\Controllers\Controller; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Routing\Controller; class $CLASS$ extends Controller { + public array $data = []; + /** * Display a listing of the resource. - * @return Response */ - public function index() + public function index(): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Response */ - public function store(Request $request) + public function store(Request $request): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Show the specified resource. - * @param int $id - * @return Response */ - public function show($id) + public function show($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Response */ - public function update(Request $request, $id) + public function update(Request $request, $id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Remove the specified resource from storage. - * @param int $id - * @return Response */ - public function destroy($id) + public function destroy($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } } From 3c72fbd0c55a202ff1483ef657cc573416384882 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:44:12 -0700 Subject: [PATCH 051/422] Update component-class.stub Formatted. --- src/Commands/stubs/component-class.stub | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Commands/stubs/component-class.stub b/src/Commands/stubs/component-class.stub index 8926bec8c..b481950c5 100644 --- a/src/Commands/stubs/component-class.stub +++ b/src/Commands/stubs/component-class.stub @@ -3,13 +3,12 @@ namespace $NAMESPACE$; use Illuminate\View\Component; +use Illuminate\View\View; class $CLASS$ extends Component { /** * Create a new component instance. - * - * @return void */ public function __construct() { @@ -17,11 +16,9 @@ class $CLASS$ extends Component } /** - * Get the view / contents that represent the component. - * - * @return \Illuminate\View\View|string + * Get the view/contents that represent the component. */ - public function render() + public function render(): View|string { return view('$LOWER_NAME$::$COMPONENT_NAME$'); } From 92bdc994c0a2dc5df296891f0f7f6f51d593e91e Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:50:07 -0700 Subject: [PATCH 052/422] Update command.stub Formatted. --- src/Commands/stubs/command.stub | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Commands/stubs/command.stub b/src/Commands/stubs/command.stub index 95145d84b..b4338f664 100644 --- a/src/Commands/stubs/command.stub +++ b/src/Commands/stubs/command.stub @@ -10,22 +10,16 @@ class $CLASS$ extends Command { /** * The name and signature of the console command. - * - * @var string */ protected $signature = '$COMMAND_NAME$'; /** * The console command description. - * - * @var string */ protected $description = 'Command description.'; /** * Create a new command instance. - * - * @return void */ public function __construct() { @@ -34,8 +28,6 @@ class $CLASS$ extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { @@ -44,10 +36,8 @@ class $CLASS$ extends Command /** * Get the console command arguments. - * - * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], @@ -56,10 +46,8 @@ class $CLASS$ extends Command /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], From bed73e9f184b3d23667b83ec1a3309405ca3b05a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:53:42 -0700 Subject: [PATCH 053/422] Update config.stub Formatted. --- src/Commands/stubs/scaffold/config.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/scaffold/config.stub b/src/Commands/stubs/scaffold/config.stub index 74c3001c9..5ceca0e80 100644 --- a/src/Commands/stubs/scaffold/config.stub +++ b/src/Commands/stubs/scaffold/config.stub @@ -1,5 +1,5 @@ '$STUDLY_NAME$' + 'name' => '$STUDLY_NAME$', ]; From f7b4c3b24d23fa6b191b3fb0d239cfbc237de9d0 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 18:59:01 -0700 Subject: [PATCH 054/422] Update provider.stub Formatted. --- src/Commands/stubs/scaffold/provider.stub | 45 +++++++---------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 8599fce44..394256696 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class $CLASS$ extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = '$MODULE$'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = '$LOWER_NAME$'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class $CLASS$ extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, '$PATH_CONFIG$/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class $CLASS$ extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, '$PATH_VIEWS$'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class $CLASS$ extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class $CLASS$ extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } From 95e956cd9377518615da8d75aee461bb05135445 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 20 Oct 2023 19:03:36 -0700 Subject: [PATCH 055/422] Update api.stub Formatted. --- src/Commands/stubs/routes/api.stub | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Commands/stubs/routes/api.stub b/src/Commands/stubs/routes/api.stub index 78681d7ab..17d43af9d 100755 --- a/src/Commands/stubs/routes/api.stub +++ b/src/Commands/stubs/routes/api.stub @@ -1,18 +1,19 @@ get('/$LOWER_NAME$', function (Request $request) { - return $request->user(); -}); \ No newline at end of file +Route::middleware(['auth:api'])->prefix('v1')->group(function () { + Route::get('/$LOWER_NAME$', fn (Request $request) => $request->user()); +}); From 48e2458a98d948c028b98651eb00e83d8d3167d2 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 22 Oct 2023 09:56:43 +0100 Subject: [PATCH 056/422] updated snapshots --- ...it_can_change_the_default_namespace__1.txt | 16 ++--------- ...ange_the_default_namespace_specific__1.txt | 16 ++--------- ...generated_correct_file_with_content__1.txt | 16 ++--------- ...__it_uses_set_command_name_in_class__1.txt | 16 ++--------- ...it_can_change_the_default_namespace__1.txt | 9 +++---- ...generated_correct_file_with_content__1.txt | 9 +++---- ...it_can_change_the_default_namespace__1.txt | 6 +---- ...ange_the_default_namespace_specific__1.txt | 6 +---- ...generated_correct_file_with_content__1.txt | 6 +---- ...ryMakeCommandTest__it_makes_factory__1.txt | 10 ++----- ...it_can_change_the_default_namespace__1.txt | 6 +---- ...ange_the_default_namespace_specific__1.txt | 6 +---- ...generated_correct_file_with_content__1.txt | 6 +---- ..._correct_sync_job_file_with_content__1.txt | 6 +---- ...it_can_change_the_default_namespace__1.txt | 7 +---- ...ange_the_default_namespace_specific__1.txt | 7 +---- ...rect_queued_duck_event_with_content__1.txt | 9 ++----- ...vent_in_a_subdirectory_with_content__1.txt | 7 +---- ...d_correct_queued_event_with_content__1.txt | 7 +---- ...orrect_sync_duck_event_with_content__1.txt | 7 +---- ...vent_in_a_subdirectory_with_content__1.txt | 7 +---- ...ted_correct_sync_event_with_content__1.txt | 7 +---- ...it_can_change_the_default_namespace__1.txt | 6 +---- ...ange_the_default_namespace_specific__1.txt | 6 +---- ...generated_correct_file_with_content__1.txt | 6 +---- ...it_can_change_the_default_namespace__1.txt | 4 --- ...ange_the_default_namespace_specific__1.txt | 4 --- ...generated_correct_file_with_content__1.txt | 4 --- ...generates_api_module_with_resources__4.txt | 18 +++---------- ...Test__it_generates_module_resources__4.txt | 18 +++---------- ...generates_web_module_with_resources__4.txt | 18 +++---------- ...es_when_adding_more_than_one_option__4.txt | 18 +++---------- ...it_can_change_the_default_namespace__1.txt | 27 +++++-------------- ...ange_the_default_namespace_specific__1.txt | 27 +++++-------------- ...generated_correct_file_with_content__1.txt | 27 +++++-------------- ...it_can_change_the_default_namespace__1.txt | 2 -- ...ange_the_default_namespace_specific__1.txt | 2 -- ...icyMakeCommandTest__it_makes_policy__1.txt | 2 -- ...generated_correct_file_with_content__1.txt | 8 ++---- ...it_can_change_the_default_namespace__1.txt | 8 ++---- ...ange_the_default_namespace_specific__1.txt | 8 ++---- ...generated_correct_file_with_content__1.txt | 8 ++---- ...it_can_change_the_default_namespace__1.txt | 5 +--- ...ange_the_default_namespace_specific__1.txt | 5 +--- ...enerate_a_collection_resource_class__1.txt | 5 +--- ...generated_correct_file_with_content__1.txt | 5 +--- ...nge_the_custom_controller_namespace__1.txt | 18 +++---------- ...it_can_change_the_default_namespace__1.txt | 18 +++---------- ...ange_the_default_namespace_specific__1.txt | 18 +++---------- ...eCommandTest__it_can_overwrite_file__1.txt | 18 +++---------- ...__it_can_overwrite_route_file_names__1.txt | 18 +++---------- ...generated_correct_file_with_content__1.txt | 18 +++---------- ...it_can_change_the_default_namespace__1.txt | 12 ++------- ...ange_the_default_namespace_specific__1.txt | 12 ++------- .../RuleMakeCommandTest__it_makes_rule__1.txt | 12 ++------- ...hange_the_default_feature_namespace__1.txt | 4 +-- ..._default_feature_namespace_specific__1.txt | 4 +-- ...d_correct_feature_file_with_content__1.txt | 4 +-- 58 files changed, 117 insertions(+), 472 deletions(-) diff --git a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt index db6a20cd1..454a9fbc5 100644 --- a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -10,22 +10,16 @@ class AwesomeCommand extends Command { /** * The name and signature of the console command. - * - * @var string */ protected $signature = 'command:name'; /** * The console command description. - * - * @var string */ protected $description = 'Command description.'; /** * Create a new command instance. - * - * @return void */ public function __construct() { @@ -34,8 +28,6 @@ class AwesomeCommand extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { @@ -44,10 +36,8 @@ class AwesomeCommand extends Command /** * Get the console command arguments. - * - * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], @@ -56,10 +46,8 @@ class AwesomeCommand extends Command /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], diff --git a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index db6a20cd1..454a9fbc5 100644 --- a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -10,22 +10,16 @@ class AwesomeCommand extends Command { /** * The name and signature of the console command. - * - * @var string */ protected $signature = 'command:name'; /** * The console command description. - * - * @var string */ protected $description = 'Command description.'; /** * Create a new command instance. - * - * @return void */ public function __construct() { @@ -34,8 +28,6 @@ class AwesomeCommand extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { @@ -44,10 +36,8 @@ class AwesomeCommand extends Command /** * Get the console command arguments. - * - * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], @@ -56,10 +46,8 @@ class AwesomeCommand extends Command /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], diff --git a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_generated_correct_file_with_content__1.txt index a60cea132..1056c9200 100644 --- a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -10,22 +10,16 @@ class MyAwesomeCommand extends Command { /** * The name and signature of the console command. - * - * @var string */ protected $signature = 'command:name'; /** * The console command description. - * - * @var string */ protected $description = 'Command description.'; /** * Create a new command instance. - * - * @return void */ public function __construct() { @@ -34,8 +28,6 @@ class MyAwesomeCommand extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { @@ -44,10 +36,8 @@ class MyAwesomeCommand extends Command /** * Get the console command arguments. - * - * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], @@ -56,10 +46,8 @@ class MyAwesomeCommand extends Command /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], diff --git a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_uses_set_command_name_in_class__1.txt b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_uses_set_command_name_in_class__1.txt index 42e7212a2..7b9e87c70 100644 --- a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_uses_set_command_name_in_class__1.txt +++ b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_uses_set_command_name_in_class__1.txt @@ -10,22 +10,16 @@ class MyAwesomeCommand extends Command { /** * The name and signature of the console command. - * - * @var string */ protected $signature = 'my:awesome'; /** * The console command description. - * - * @var string */ protected $description = 'Command description.'; /** * Create a new command instance. - * - * @return void */ public function __construct() { @@ -34,8 +28,6 @@ class MyAwesomeCommand extends Command /** * Execute the console command. - * - * @return mixed */ public function handle() { @@ -44,10 +36,8 @@ class MyAwesomeCommand extends Command /** * Get the console command arguments. - * - * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], @@ -56,10 +46,8 @@ class MyAwesomeCommand extends Command /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], diff --git a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt index bc32a72c3..bffbed14b 100644 --- a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -3,13 +3,12 @@ namespace Modules\Blog\View\Component\newDirectory; use Illuminate\View\Component; +use Illuminate\View\View; class Blog extends Component { /** * Create a new component instance. - * - * @return void */ public function __construct() { @@ -17,11 +16,9 @@ class Blog extends Component } /** - * Get the view / contents that represent the component. - * - * @return \Illuminate\View\View|string + * Get the view/contents that represent the component. */ - public function render() + public function render(): View|string { return view('blog::components.blog'); } diff --git a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_generated_correct_file_with_content__1.txt index 8f64b407b..c5bb74b6f 100644 --- a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -3,13 +3,12 @@ namespace Modules\Blog\View\Component; use Illuminate\View\Component; +use Illuminate\View\View; class Blog extends Component { /** * Create a new component instance. - * - * @return void */ public function __construct() { @@ -17,11 +16,9 @@ class Blog extends Component } /** - * Get the view / contents that represent the component. - * - * @return \Illuminate\View\View|string + * Get the view/contents that represent the component. */ - public function render() + public function render(): View|string { return view('blog::components.blog'); } diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt index 59b88f481..483cb1c60 100644 --- a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -10,8 +10,6 @@ class PostWasCreated /** * Create a new event instance. - * - * @return void */ public function __construct() { @@ -20,10 +18,8 @@ class PostWasCreated /** * Get the channels the event should be broadcast on. - * - * @return array */ - public function broadcastOn() + public function broadcastOn(): array { return []; } diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 59b88f481..483cb1c60 100644 --- a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -10,8 +10,6 @@ class PostWasCreated /** * Create a new event instance. - * - * @return void */ public function __construct() { @@ -20,10 +18,8 @@ class PostWasCreated /** * Get the channels the event should be broadcast on. - * - * @return array */ - public function broadcastOn() + public function broadcastOn(): array { return []; } diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt index 55812b3b8..5fbc3d908 100644 --- a/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -10,8 +10,6 @@ class PostWasCreated /** * Create a new event instance. - * - * @return void */ public function __construct() { @@ -20,10 +18,8 @@ class PostWasCreated /** * Get the channels the event should be broadcast on. - * - * @return array */ - public function broadcastOn() + public function broadcastOn(): array { return []; } diff --git a/tests/Commands/__snapshots__/FactoryMakeCommandTest__it_makes_factory__1.txt b/tests/Commands/__snapshots__/FactoryMakeCommandTest__it_makes_factory__1.txt index 6911006e5..402644e86 100644 --- a/tests/Commands/__snapshots__/FactoryMakeCommandTest__it_makes_factory__1.txt +++ b/tests/Commands/__snapshots__/FactoryMakeCommandTest__it_makes_factory__1.txt @@ -8,21 +8,15 @@ class PostFactory extends Factory { /** * The name of the factory's corresponding model. - * - * @var string */ protected $model = \Modules\Blog\Entities\Post::class; /** * Define the model's default state. - * - * @return array */ - public function definition() + public function definition(): array { - return [ - // - ]; + return []; } } diff --git a/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace__1.txt index 2449de58e..6ae619387 100644 --- a/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -14,8 +14,6 @@ class SomeJob implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -24,10 +22,8 @@ class SomeJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } diff --git a/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 2449de58e..6ae619387 100644 --- a/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -14,8 +14,6 @@ class SomeJob implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -24,10 +22,8 @@ class SomeJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } diff --git a/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_file_with_content__1.txt index 65684cd4f..12195d292 100644 --- a/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -14,8 +14,6 @@ class SomeJob implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -24,10 +22,8 @@ class SomeJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } diff --git a/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_sync_job_file_with_content__1.txt b/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_sync_job_file_with_content__1.txt index 518b31c8b..971c66f80 100644 --- a/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_sync_job_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_sync_job_file_with_content__1.txt @@ -11,8 +11,6 @@ class SomeJob implements ShouldQueue /** * Create a new job instance. - * - * @return void */ public function __construct() { @@ -21,10 +19,8 @@ class SomeJob implements ShouldQueue /** * Execute the job. - * - * @return void */ - public function handle() + public function handle(): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace__1.txt index 12d3333f6..b5c7d0ad5 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -9,8 +9,6 @@ class NotifyUsersOfANewPost { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -19,11 +17,8 @@ class NotifyUsersOfANewPost /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle($event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 12d3333f6..b5c7d0ad5 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -9,8 +9,6 @@ class NotifyUsersOfANewPost { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -19,11 +17,8 @@ class NotifyUsersOfANewPost /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle($event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_duck_event_with_content__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_duck_event_with_content__1.txt index 1f7773017..1ee48076b 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_duck_event_with_content__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_duck_event_with_content__1.txt @@ -10,9 +10,7 @@ class NotifyUsersOfANewPost implements ShouldQueue use InteractsWithQueue; /** - * Create the event listener. - * - * @return void + * Create the event listener */ public function __construct() { @@ -21,11 +19,8 @@ class NotifyUsersOfANewPost implements ShouldQueue /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle($event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt index fd367eea3..2ad1c9117 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt @@ -12,8 +12,6 @@ class NotifyUsersOfANewPost implements ShouldQueue /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -22,11 +20,8 @@ class NotifyUsersOfANewPost implements ShouldQueue /** * Handle the event. - * - * @param WasCreated $event - * @return void */ - public function handle(WasCreated $event) + public function handle(WasCreated $event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_with_content__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_with_content__1.txt index 0bd29b1f6..fdb0f5843 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_with_content__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_with_content__1.txt @@ -12,8 +12,6 @@ class NotifyUsersOfANewPost implements ShouldQueue /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -22,11 +20,8 @@ class NotifyUsersOfANewPost implements ShouldQueue /** * Handle the event. - * - * @param UserWasCreated $event - * @return void */ - public function handle(UserWasCreated $event) + public function handle(UserWasCreated $event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_duck_event_with_content__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_duck_event_with_content__1.txt index 6ed48ffcc..437cffd78 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_duck_event_with_content__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_duck_event_with_content__1.txt @@ -9,8 +9,6 @@ class NotifyUsersOfANewPost { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -19,11 +17,8 @@ class NotifyUsersOfANewPost /** * Handle the event. - * - * @param object $event - * @return void */ - public function handle($event) + public function handle($event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt index 4e69c20f7..aaca0c78b 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt @@ -10,8 +10,6 @@ class NotifyUsersOfANewPost { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -20,11 +18,8 @@ class NotifyUsersOfANewPost /** * Handle the event. - * - * @param WasCreated $event - * @return void */ - public function handle(WasCreated $event) + public function handle(WasCreated $event): void { // } diff --git a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_with_content__1.txt b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_with_content__1.txt index 42bc0ad0d..fc55e36a1 100644 --- a/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_with_content__1.txt +++ b/tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_with_content__1.txt @@ -10,8 +10,6 @@ class NotifyUsersOfANewPost { /** * Create the event listener. - * - * @return void */ public function __construct() { @@ -20,11 +18,8 @@ class NotifyUsersOfANewPost /** * Handle the event. - * - * @param UserWasCreated $event - * @return void */ - public function handle(UserWasCreated $event) + public function handle(UserWasCreated $event): void { // } diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt index 1247d2e77..45f802ffe 100644 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -13,8 +13,6 @@ class SomeMail extends Mailable /** * Create a new message instance. - * - * @return void */ public function __construct() { @@ -23,10 +21,8 @@ class SomeMail extends Mailable /** * Build the message. - * - * @return $this */ - public function build() + public function build(): self { return $this->view('view.name'); } diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 1247d2e77..45f802ffe 100644 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -13,8 +13,6 @@ class SomeMail extends Mailable /** * Create a new message instance. - * - * @return void */ public function __construct() { @@ -23,10 +21,8 @@ class SomeMail extends Mailable /** * Build the message. - * - * @return $this */ - public function build() + public function build(): self { return $this->view('view.name'); } diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt index 9fe735a64..5bee369ee 100644 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -13,8 +13,6 @@ class SomeMail extends Mailable /** * Create a new message instance. - * - * @return void */ public function __construct() { @@ -23,10 +21,8 @@ class SomeMail extends Mailable /** * Build the message. - * - * @return $this */ - public function build() + public function build(): self { return $this->view('view.name'); } diff --git a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.txt index 324fdf356..e8b586751 100644 --- a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -9,10 +9,6 @@ class SomeMiddleware { /** * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed */ public function handle(Request $request, Closure $next) { diff --git a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 324fdf356..e8b586751 100644 --- a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -9,10 +9,6 @@ class SomeMiddleware { /** * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed */ public function handle(Request $request, Closure $next) { diff --git a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_generated_correct_file_with_content__1.txt index dde546720..d0763ead2 100644 --- a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -9,10 +9,6 @@ class SomeMiddleware { /** * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed */ public function handle(Request $request, Closure $next) { diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt index 288050277..982a5534a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt index 288050277..982a5534a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt index 288050277..982a5534a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt index 288050277..982a5534a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt index 8b9169efd..4fb9ff311 100644 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -13,8 +13,6 @@ class WelcomeNotification extends Notification /** * Create a new notification instance. - * - * @return void */ public function __construct() { @@ -23,39 +21,28 @@ class WelcomeNotification extends Notification /** * Get the notification's delivery channels. - * - * @param mixed $notifiable - * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail($notifiable): MailMessage { return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); + ->line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); } /** * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array */ - public function toArray($notifiable) + public function toArray($notifiable): array { - return [ - // - ]; + return []; } } diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 8b9169efd..4fb9ff311 100644 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -13,8 +13,6 @@ class WelcomeNotification extends Notification /** * Create a new notification instance. - * - * @return void */ public function __construct() { @@ -23,39 +21,28 @@ class WelcomeNotification extends Notification /** * Get the notification's delivery channels. - * - * @param mixed $notifiable - * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail($notifiable): MailMessage { return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); + ->line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); } /** * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array */ - public function toArray($notifiable) + public function toArray($notifiable): array { - return [ - // - ]; + return []; } } diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt index 961b05228..53e7ab765 100644 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -13,8 +13,6 @@ class WelcomeNotification extends Notification /** * Create a new notification instance. - * - * @return void */ public function __construct() { @@ -23,39 +21,28 @@ class WelcomeNotification extends Notification /** * Get the notification's delivery channels. - * - * @param mixed $notifiable - * @return array */ - public function via($notifiable) + public function via($notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail($notifiable): MailMessage { return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); + ->line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); } /** * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array */ - public function toArray($notifiable) + public function toArray($notifiable): array { - return [ - // - ]; + return []; } } diff --git a/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace__1.txt index 1697bce2c..2b95d0318 100644 --- a/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -10,8 +10,6 @@ class PostPolicy /** * Create a new policy instance. - * - * @return void */ public function __construct() { diff --git a/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 1697bce2c..2b95d0318 100644 --- a/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -10,8 +10,6 @@ class PostPolicy /** * Create a new policy instance. - * - * @return void */ public function __construct() { diff --git a/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_makes_policy__1.txt b/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_makes_policy__1.txt index 84da3d022..ae70c6af2 100644 --- a/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_makes_policy__1.txt +++ b/tests/Commands/__snapshots__/PolicyMakeCommandTest__it_makes_policy__1.txt @@ -10,8 +10,6 @@ class PostPolicy /** * Create a new policy instance. - * - * @return void */ public function __construct() { diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt index 3019d551b..922456f3d 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -8,20 +8,16 @@ class MyBlogServiceProvider extends ServiceProvider { /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { // } /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt index 454c125e9..f217f1ecf 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -8,10 +8,8 @@ class CreateBlogPostRequest extends FormRequest { /** * Get the validation rules that apply to the request. - * - * @return array */ - public function rules() + public function rules(): array { return [ // @@ -20,10 +18,8 @@ class CreateBlogPostRequest extends FormRequest /** * Determine if the user is authorized to make this request. - * - * @return bool */ - public function authorize() + public function authorize(): bool { return true; } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 454c125e9..f217f1ecf 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -8,10 +8,8 @@ class CreateBlogPostRequest extends FormRequest { /** * Get the validation rules that apply to the request. - * - * @return array */ - public function rules() + public function rules(): array { return [ // @@ -20,10 +18,8 @@ class CreateBlogPostRequest extends FormRequest /** * Determine if the user is authorized to make this request. - * - * @return bool */ - public function authorize() + public function authorize(): bool { return true; } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt index df3218305..e4829d542 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -8,10 +8,8 @@ class CreateBlogPostRequest extends FormRequest { /** * Get the validation rules that apply to the request. - * - * @return array */ - public function rules() + public function rules(): array { return [ // @@ -20,10 +18,8 @@ class CreateBlogPostRequest extends FormRequest /** * Determine if the user is authorized to make this request. - * - * @return bool */ - public function authorize() + public function authorize(): bool { return true; } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt index 412554f23..33d6bd67b 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -8,11 +8,8 @@ class PostsTransformer extends ResourceCollection { /** * Transform the resource collection into an array. - * - * @param \Illuminate\Http\Request - * @return array */ - public function toArray($request) + public function toArray($request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 412554f23..33d6bd67b 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -8,11 +8,8 @@ class PostsTransformer extends ResourceCollection { /** * Transform the resource collection into an array. - * - * @param \Illuminate\Http\Request - * @return array */ - public function toArray($request) + public function toArray($request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt index 18871e8f3..32e3cef3c 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt @@ -8,11 +8,8 @@ class PostsTransformer extends ResourceCollection { /** * Transform the resource collection into an array. - * - * @param \Illuminate\Http\Request - * @return array */ - public function toArray($request) + public function toArray($request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt index f39326876..a61859f33 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -8,11 +8,8 @@ class PostsTransformer extends JsonResource { /** * Transform the resource into an array. - * - * @param \Illuminate\Http\Request - * @return array */ - public function toArray($request) + public function toArray($request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt index 7bf24ab21..6393fb97e 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Base\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index ebc5786a4..f5dc95c12 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index ebc5786a4..f5dc95c12 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt index 99fb6b8d6..1e54f7bdf 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt index 4caf69906..2273f1db7 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt index 288050277..982a5534a 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -9,8 +9,6 @@ class RouteServiceProvider extends ServiceProvider { /** * The module namespace to assume when generating URLs to actions. - * - * @var string */ protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; @@ -18,20 +16,16 @@ class RouteServiceProvider extends ServiceProvider * Called before routes are registered. * * Register any model bindings or pattern based filters. - * - * @return void */ - public function boot() + public function boot(): void { parent::boot(); } /** * Define the routes for the application. - * - * @return void */ - public function map() + public function map(): void { $this->mapApiRoutes(); @@ -42,10 +36,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. - * - * @return void */ - protected function mapWebRoutes() + protected function mapWebRoutes(): void { Route::middleware('web') ->namespace($this->moduleNamespace) @@ -56,10 +48,8 @@ class RouteServiceProvider extends ServiceProvider * Define the "api" routes for the application. * * These routes are typically stateless. - * - * @return void */ - protected function mapApiRoutes() + protected function mapApiRoutes(): void { Route::prefix('api') ->middleware('api') diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt index df545f507..95972e4bc 100644 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -8,8 +8,6 @@ class UniqueRule implements Rule { /** * Create a new rule instance. - * - * @return void */ public function __construct() { @@ -18,22 +16,16 @@ class UniqueRule implements Rule /** * Determine if the validation rule passes. - * - * @param string $attribute - * @param mixed $value - * @return bool */ - public function passes($attribute, $value) + public function passes(string $attribute, $value): bool { // } /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'The validation error message.'; } diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index df545f507..95972e4bc 100644 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -8,8 +8,6 @@ class UniqueRule implements Rule { /** * Create a new rule instance. - * - * @return void */ public function __construct() { @@ -18,22 +16,16 @@ class UniqueRule implements Rule /** * Determine if the validation rule passes. - * - * @param string $attribute - * @param mixed $value - * @return bool */ - public function passes($attribute, $value) + public function passes(string $attribute, $value): bool { // } /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'The validation error message.'; } diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt index b2c397d48..675e3d09a 100644 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt @@ -8,8 +8,6 @@ class UniqueRule implements Rule { /** * Create a new rule instance. - * - * @return void */ public function __construct() { @@ -18,22 +16,16 @@ class UniqueRule implements Rule /** * Determine if the validation rule passes. - * - * @param string $attribute - * @param mixed $value - * @return bool */ - public function passes($attribute, $value) + public function passes(string $attribute, $value): bool { // } /** * Get the validation error message. - * - * @return string */ - public function message() + public function message(): string { return 'The validation error message.'; } diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt index 4ccecd857..dba6e35a1 100644 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt @@ -10,10 +10,8 @@ class EloquentPostRepositoryTest extends TestCase { /** * A basic feature test example. - * - * @return void */ - public function testExample() + public function testExample(): void { $response = $this->get('/'); diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt index 4ccecd857..dba6e35a1 100644 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt @@ -10,10 +10,8 @@ class EloquentPostRepositoryTest extends TestCase { /** * A basic feature test example. - * - * @return void */ - public function testExample() + public function testExample(): void { $response = $this->get('/'); diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt index 04d4c6b90..6378738a3 100644 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt @@ -10,10 +10,8 @@ class EloquentPostRepositoryTest extends TestCase { /** * A basic feature test example. - * - * @return void */ - public function testExample() + public function testExample(): void { $response = $this->get('/'); From d99c0ce15198fa2a296518dd0f6c96c9455d6c1a Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 22 Oct 2023 14:35:54 +0100 Subject: [PATCH 057/422] Update FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 66c5b8be3..1540daa65 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,4 @@ # These are supported funding model platforms github: nwidart +github: dcblogdev From 6a56cb5c5b10c10ca0a16de1f219cc8558151f2c Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 22 Oct 2023 16:29:24 +0100 Subject: [PATCH 058/422] updated snapshots --- CHANGELOG.md | 7 ++- ...roller_to_class_name_if_not_present__1.txt | 32 +++++-------- ...it_can_change_the_default_namespace__1.txt | 32 +++++-------- ...ange_the_default_namespace_specific__1.txt | 32 +++++-------- ...mespace_with_correct_generated_file__1.txt | 32 +++++-------- ...generated_correct_file_with_content__1.txt | 32 +++++-------- ...est__it_generates_an_api_controller__1.txt | 36 ++++++++------- ...gration_when_both_flags_are_present__1.txt | 32 +++++-------- ...enerates_controller_file_with_model__1.txt | 32 +++++-------- ...le_with_model_using_shortcut_option__1.txt | 32 +++++-------- ...generates_api_module_with_resources__1.txt | 45 ++++++------------- ...generates_api_module_with_resources__2.txt | 36 ++++++++------- ..._module_namespace_using_studly_case__1.txt | 45 ++++++------------- ...Test__it_generates_module_resources__1.txt | 45 ++++++------------- ...Test__it_generates_module_resources__2.txt | 32 +++++-------- ...generates_web_module_with_resources__1.txt | 45 ++++++------------- ...generates_web_module_with_resources__2.txt | 32 +++++-------- ...es_when_adding_more_than_one_option__1.txt | 45 ++++++------------- ...es_when_adding_more_than_one_option__2.txt | 32 +++++-------- ...it_can_change_the_default_namespace__1.txt | 45 ++++++------------- ...ange_the_default_namespace_specific__1.txt | 45 ++++++------------- ..._migration_resources_location_paths__1.txt | 45 ++++++------------- ...vice_provider_with_resource_loading__1.txt | 45 ++++++------------- 23 files changed, 280 insertions(+), 556 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c2f622a8..2b937d69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Changed + +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs to use return types + + ## 10.0.2 - 2023-09-18 ## Changed @@ -13,7 +18,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## 10.0.1 - 2023-09-18 ## Added - + - [@JaberWiki](https://github.com/JaberWiki) Added Include an optional flag `subpath` for rolling back a module's specific migration file [#1626](https://github.com/nWidart/laravel-modules/pull/1626) - [@sergiy-petrov](https://github.com/sergiy-petrov) Added support for testing GitHub actions against PHP versions 8.2 and 8.3. [#1624](https://github.com/nWidart/laravel-modules/pull/1624) - [@hanieas](https://github.com/hanieas) Added make Observer command. [#1623](https://github.com/nWidart/laravel-modules/pull/1623) diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt index 7d3e83261..166c7c5cf 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt index 836193ff0..608c92496 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 836193ff0..608c92496 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt index 8068f08af..b8a2e2bd6 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers\Api; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt index 7d3e83261..166c7c5cf 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class MyController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt index d13a9ac18..201ff4148 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt @@ -2,59 +2,61 @@ namespace Modules\Blog\Http\Controllers; +use App\Http\Controllers\Controller; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Routing\Controller; class MyController extends Controller { + public array $data = []; + /** * Display a listing of the resource. - * @return Response */ - public function index() + public function index(): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Response */ - public function store(Request $request) + public function store(Request $request): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Show the specified resource. - * @param int $id - * @return Response */ - public function show($id) + public function show($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Response */ - public function update(Request $request, $id) + public function update(Request $request, $id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Remove the specified resource from storage. - * @param int $id - * @return Response */ - public function destroy($id) + public function destroy($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt index 0bbb67f04..8d5aef5e5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class PostController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt index 0bbb67f04..8d5aef5e5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class PostController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt index 0bbb67f04..8d5aef5e5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class PostController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt index 7a087461e..821f40f57 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt @@ -2,59 +2,61 @@ namespace Modules\Blog\Http\Controllers; +use App\Http\Controllers\Controller; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Routing\Controller; class BlogController extends Controller { + public array $data = []; + /** * Display a listing of the resource. - * @return Response */ - public function index() + public function index(): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Response */ - public function store(Request $request) + public function store(Request $request): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Show the specified resource. - * @param int $id - * @return Response */ - public function show($id) + public function show($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Response */ - public function update(Request $request, $id) + public function update(Request $request, $id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } /** * Remove the specified resource from storage. - * @param int $id - * @return Response */ - public function destroy($id) + public function destroy($id): JsonResponse { // + + return response()->json($this->data)->setStatusCode(200); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index a3a8161a5..1a47cf6ec 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class ModuleNameServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'ModuleName'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'modulename'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class ModuleNameServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt index fa3f878dd..01959660b 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class BlogController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt index fa3f878dd..01959660b 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class BlogController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt index fa3f878dd..01959660b 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -2,77 +2,65 @@ namespace Modules\Blog\Http\Controllers; -use Illuminate\Contracts\Support\Renderable; +use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Routing\Controller; +use Illuminate\Http\Response; class BlogController extends Controller { /** * Display a listing of the resource. - * @return Renderable */ - public function index() + public function index(): Response { return view('blog::index'); } /** * Show the form for creating a new resource. - * @return Renderable */ - public function create() + public function create(): Response { return view('blog::create'); } /** * Store a newly created resource in storage. - * @param Request $request - * @return Renderable */ - public function store(Request $request) + public function store(Request $request): RedirectResponse { // } /** * Show the specified resource. - * @param int $id - * @return Renderable */ - public function show($id) + public function show($id): Response { return view('blog::show'); } /** * Show the form for editing the specified resource. - * @param int $id - * @return Renderable */ - public function edit($id) + public function edit($id): Response { return view('blog::edit'); } /** * Update the specified resource in storage. - * @param Request $request - * @param int $id - * @return Renderable */ - public function update(Request $request, $id) + public function update(Request $request, $id): RedirectResponse { // } /** * Remove the specified resource from storage. - * @param int $id - * @return Renderable */ - public function destroy($id) + public function destroy($id): RedirectResponse { // } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 2ac74b875..85f47ec7a 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 2ac74b875..85f47ec7a 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index 162c75a99..be6dd9df1 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index e268f9e16..e20768cf9 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -7,22 +7,14 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - /** - * @var string $moduleName - */ protected $moduleName = 'Blog'; - /** - * @var string $moduleNameLower - */ protected $moduleNameLower = 'blog'; /** * Boot the application events. - * - * @return void */ - public function boot() + public function boot(): void { $this->registerTranslations(); $this->registerConfig(); @@ -32,23 +24,19 @@ class BlogServiceProvider extends ServiceProvider /** * Register the service provider. - * - * @return void */ - public function register() + public function register(): void { $this->app->register(RouteServiceProvider::class); } /** * Register config. - * - * @return void */ - protected function registerConfig() + protected function registerConfig(): void { $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), + module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), ], 'config'); $this->mergeConfigFrom( module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower @@ -57,30 +45,26 @@ class BlogServiceProvider extends ServiceProvider /** * Register views. - * - * @return void */ - public function registerViews() + public function registerViews(): void { - $viewPath = resource_path('views/modules/' . $this->moduleNameLower); + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath - ], ['views', $this->moduleNameLower . '-module-views']); + $sourcePath => $viewPath, + ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); } /** * Register translations. - * - * @return void */ - public function registerTranslations() + public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . $this->moduleNameLower); + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -93,10 +77,8 @@ class BlogServiceProvider extends ServiceProvider /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return []; } @@ -105,10 +87,11 @@ class BlogServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path . '/modules/' . $this->moduleNameLower)) { - $paths[] = $path . '/modules/' . $this->moduleNameLower; + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; } } + return $paths; } } From 22355d3d21b0c13b584cfa30aef000f72332eda2 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 22 Oct 2023 16:39:58 +0100 Subject: [PATCH 059/422] updated snapshots --- ...ndTest__it_generates_api_route_file__1.txt | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt index dec192862..42c8b7d3d 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt @@ -1,18 +1,19 @@ get('/blog', function (Request $request) { - return $request->user(); -}); \ No newline at end of file +Route::middleware(['auth:api'])->prefix('v1')->group(function () { + Route::get('/blog', fn (Request $request) => $request->user()); +}); From 7dd39ed455114f47d29cd5d260b910f4d838efe9 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 22 Oct 2023 18:17:49 +0100 Subject: [PATCH 060/422] Update config.php Reverse activator filename to `modules_statuses.json` --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 9a1f52f25..5c336fe81 100644 --- a/config/config.php +++ b/config/config.php @@ -271,7 +271,7 @@ 'activators' => [ 'file' => [ 'class' => FileActivator::class, - 'statuses-file' => base_path('modules.json'), + 'statuses-file' => base_path('modules_statuses.json'), 'cache-key' => 'activator.installed', 'cache-lifetime' => 604800, ], From f1f7fb68452a81e1fe47df36554bdb62383468ee Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 22 Oct 2023 16:12:16 -0700 Subject: [PATCH 061/422] Update controller-api.stub Remove default status code from response. --- src/Commands/stubs/controller-api.stub | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Commands/stubs/controller-api.stub b/src/Commands/stubs/controller-api.stub index 54062c3c3..66e70a6eb 100644 --- a/src/Commands/stubs/controller-api.stub +++ b/src/Commands/stubs/controller-api.stub @@ -17,7 +17,7 @@ class $CLASS$ extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -27,7 +27,7 @@ class $CLASS$ extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -37,7 +37,7 @@ class $CLASS$ extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -47,7 +47,7 @@ class $CLASS$ extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -57,6 +57,6 @@ class $CLASS$ extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } } From d28ec5c8a526da0cb24498958b7c37101e82d118 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 23 Oct 2023 11:59:40 +0100 Subject: [PATCH 062/422] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index abee5b7ae..33d5498d0 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ By default, the module classes are not loaded automatically. You can autoload yo You'll find installation instructions and full documentation on [https://docs.laravelmodules.com/](https://docs.laravelmodules.com/). +## Community + +We also have a Discord community. [https://discord.gg/hkF7BRvRZK](https://discord.gg/hkF7BRvRZK) For quick help, ask questions in the appropriate channel. + ## Credits - [Nicolas Widart](https://github.com/nwidart) @@ -78,7 +82,6 @@ You'll find installation instructions and full documentation on [https://docs.la Nicolas Widart is a freelance web developer specialising on the Laravel framework. View all my packages [on my website](https://nwidart.com/), or visit [my website](https://nicolaswidart.com). - ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. From 87fc2b7f11a4bc2b8dda699a19f0878a35f7d39b Mon Sep 17 00:00:00 2001 From: Hossain Mohammad Shahidullah Jaber <55241455+JaberWiki@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:47:21 +0600 Subject: [PATCH 063/422] [Update] Replaced AsGardCms site with GitHub URL due to site downtime. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33d5498d0..faad99b17 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ `nwidart/laravel-modules` is a Laravel package which created to manage your large Laravel app using modules. Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 10. -This package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. This package is used in [AsgardCMS](https://asgardcms.com/). +This package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. This package is used in [AsgardCMS](https://github.com/AsgardCms). With one big added bonus that the original package didn't have: **tests**. From 5e12aee7dc1cc0e542131771264c47e6a32b5666 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Tue, 24 Oct 2023 16:04:48 +0700 Subject: [PATCH 064/422] feat: update new rule stub --- src/Commands/stubs/rule.stub | 25 ++++--------------- ...est__it_generates_an_api_controller__1.txt | 10 ++++---- ...generates_api_module_with_resources__2.txt | 10 ++++---- ...it_can_change_the_default_namespace__1.txt | 25 ++++--------------- ...ange_the_default_namespace_specific__1.txt | 25 ++++--------------- .../RuleMakeCommandTest__it_makes_rule__1.txt | 25 ++++--------------- 6 files changed, 30 insertions(+), 90 deletions(-) diff --git a/src/Commands/stubs/rule.stub b/src/Commands/stubs/rule.stub index 4bd15dd4b..73556f152 100644 --- a/src/Commands/stubs/rule.stub +++ b/src/Commands/stubs/rule.stub @@ -2,31 +2,16 @@ namespace $NAMESPACE$; -use Illuminate\Contracts\Validation\Rule; +use Closure; +use Illuminate\Contracts\Validation\ValidationRule; -class $CLASS$ implements Rule +class $CLASS$ implements ValidationRule { /** - * Create a new rule instance. + * Run the validation rule. */ - public function __construct() + public function validate(string $attribute, mixed $value, Closure $fail): void { // } - - /** - * Determine if the validation rule passes. - */ - public function passes(string $attribute, $value): bool - { - // - } - - /** - * Get the validation error message. - */ - public function message(): string - { - return 'The validation error message.'; - } } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt index 201ff4148..dc7c1310a 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt @@ -17,7 +17,7 @@ class MyController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -27,7 +27,7 @@ class MyController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -37,7 +37,7 @@ class MyController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -47,7 +47,7 @@ class MyController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -57,6 +57,6 @@ class MyController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt index 821f40f57..48d9b883f 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt @@ -17,7 +17,7 @@ class BlogController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -27,7 +27,7 @@ class BlogController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -37,7 +37,7 @@ class BlogController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -47,7 +47,7 @@ class BlogController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } /** @@ -57,6 +57,6 @@ class BlogController extends Controller { // - return response()->json($this->data)->setStatusCode(200); + return response()->json($this->data); } } diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt index 95972e4bc..23757e05f 100644 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -2,31 +2,16 @@ namespace Modules\Blog\SuperRules; -use Illuminate\Contracts\Validation\Rule; +use Closure; +use Illuminate\Contracts\Validation\ValidationRule; -class UniqueRule implements Rule +class UniqueRule implements ValidationRule { /** - * Create a new rule instance. + * Run the validation rule. */ - public function __construct() + public function validate(string $attribute, mixed $value, Closure $fail): void { // } - - /** - * Determine if the validation rule passes. - */ - public function passes(string $attribute, $value): bool - { - // - } - - /** - * Get the validation error message. - */ - public function message(): string - { - return 'The validation error message.'; - } } diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 95972e4bc..23757e05f 100644 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -2,31 +2,16 @@ namespace Modules\Blog\SuperRules; -use Illuminate\Contracts\Validation\Rule; +use Closure; +use Illuminate\Contracts\Validation\ValidationRule; -class UniqueRule implements Rule +class UniqueRule implements ValidationRule { /** - * Create a new rule instance. + * Run the validation rule. */ - public function __construct() + public function validate(string $attribute, mixed $value, Closure $fail): void { // } - - /** - * Determine if the validation rule passes. - */ - public function passes(string $attribute, $value): bool - { - // - } - - /** - * Get the validation error message. - */ - public function message(): string - { - return 'The validation error message.'; - } } diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt index 675e3d09a..f4b07d26f 100644 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt @@ -2,31 +2,16 @@ namespace Modules\Blog\Rules; -use Illuminate\Contracts\Validation\Rule; +use Closure; +use Illuminate\Contracts\Validation\ValidationRule; -class UniqueRule implements Rule +class UniqueRule implements ValidationRule { /** - * Create a new rule instance. + * Run the validation rule. */ - public function __construct() + public function validate(string $attribute, mixed $value, Closure $fail): void { // } - - /** - * Determine if the validation rule passes. - */ - public function passes(string $attribute, $value): bool - { - // - } - - /** - * Get the validation error message. - */ - public function message(): string - { - return 'The validation error message.'; - } } From 5bba01e6d6bd91dc1f98ef8793aa8ac79b21d6ae Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Tue, 24 Oct 2023 17:44:01 +0100 Subject: [PATCH 065/422] Update provider.stub (Fix: Module components class issue) Fix: Module Components Class not working issue. --- src/Commands/stubs/scaffold/provider.stub | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 394256696..3a2dd6b6b 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -2,9 +2,9 @@ namespace $NAMESPACE$; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class $CLASS$ extends ServiceProvider { protected $moduleName = '$MODULE$'; @@ -57,6 +57,9 @@ class $CLASS$ extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** From 91bd1823cf746669f4b611531263c82b704688e8 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 25 Oct 2023 13:34:52 +0100 Subject: [PATCH 066/422] updated snapshots --- CHANGELOG.md | 1 + ...ommandTest__it_generates_api_module_with_resources__1.txt | 5 ++++- ...t__it_generates_module_namespace_using_studly_case__1.txt | 5 ++++- ...duleMakeCommandTest__it_generates_module_resources__1.txt | 5 ++++- ...ommandTest__it_generates_web_module_with_resources__1.txt | 5 ++++- ...le_with_resources_when_adding_more_than_one_option__1.txt | 5 ++++- ...keCommandTest__it_can_change_the_default_namespace__1.txt | 5 ++++- ...Test__it_can_change_the_default_namespace_specific__1.txt | 5 ++++- ...can_have_custom_migration_resources_location_paths__1.txt | 5 ++++- ...es_a_master_service_provider_with_resource_loading__1.txt | 5 ++++- 10 files changed, 37 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b937d69d..d1dc8a5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed - [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs to use return types +- [@hungthai1401](https://github.com/hungthai1401) updated rule stub ## 10.0.2 - 2023-09-18 diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index e20768cf9..c18b50f35 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index 1a47cf6ec..2953befed 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -2,9 +2,9 @@ namespace Modules\ModuleName\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class ModuleNameServiceProvider extends ServiceProvider { protected $moduleName = 'ModuleName'; @@ -57,6 +57,9 @@ class ModuleNameServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index e20768cf9..c18b50f35 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index e20768cf9..c18b50f35 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index e20768cf9..c18b50f35 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 85f47ec7a..878576762 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\SuperProviders; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 85f47ec7a..878576762 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\SuperProviders; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index be6dd9df1..16f3964bf 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index e20768cf9..c18b50f35 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -2,9 +2,9 @@ namespace Modules\Blog\Providers; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; - class BlogServiceProvider extends ServiceProvider { protected $moduleName = 'Blog'; @@ -57,6 +57,9 @@ class BlogServiceProvider extends ServiceProvider ], ['views', $this->moduleNameLower.'-module-views',]); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** From 1a7265e56609f7deb40a7f9895f9f7ae7d775fa6 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 25 Oct 2023 22:18:51 +0100 Subject: [PATCH 067/422] updated snapshots --- src/Commands/stubs/controller.stub | 10 +++++----- ...ends_controller_to_class_name_if_not_present__1.txt | 10 +++++----- ...andTest__it_can_change_the_default_namespace__1.txt | 10 +++++----- ...it_can_change_the_default_namespace_specific__1.txt | 10 +++++----- ...in_sub_namespace_with_correct_generated_file__1.txt | 10 +++++----- ...Test__it_generated_correct_file_with_content__1.txt | 10 +++++----- ...er_and_migration_when_both_flags_are_present__1.txt | 10 +++++----- ...est__it_generates_controller_file_with_model__1.txt | 10 +++++----- ...roller_file_with_model_using_shortcut_option__1.txt | 10 +++++----- ...keCommandTest__it_generates_module_resources__2.txt | 10 +++++----- ...Test__it_generates_web_module_with_resources__2.txt | 10 +++++----- ...h_resources_when_adding_more_than_one_option__2.txt | 10 +++++----- 12 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Commands/stubs/controller.stub b/src/Commands/stubs/controller.stub index e8b7164b9..04aaefd2b 100644 --- a/src/Commands/stubs/controller.stub +++ b/src/Commands/stubs/controller.stub @@ -12,7 +12,7 @@ class $CLASS$ extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('$LOWER_NAME$::index'); } @@ -20,7 +20,7 @@ class $CLASS$ extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('$LOWER_NAME$::create'); } @@ -36,7 +36,7 @@ class $CLASS$ extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('$LOWER_NAME$::show'); } @@ -44,7 +44,7 @@ class $CLASS$ extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('$LOWER_NAME$::edit'); } @@ -60,7 +60,7 @@ class $CLASS$ extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt index 166c7c5cf..863f2f9d1 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt @@ -12,7 +12,7 @@ class MyController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class MyController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class MyController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class MyController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class MyController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt index 608c92496..8d94acf97 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -12,7 +12,7 @@ class MyController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class MyController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class MyController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class MyController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class MyController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 608c92496..8d94acf97 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -12,7 +12,7 @@ class MyController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class MyController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class MyController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class MyController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class MyController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt index b8a2e2bd6..5001fb01e 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt @@ -12,7 +12,7 @@ class MyController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class MyController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class MyController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class MyController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class MyController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt index 166c7c5cf..863f2f9d1 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -12,7 +12,7 @@ class MyController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class MyController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class MyController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class MyController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class MyController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt index 8d5aef5e5..0006937ff 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt @@ -12,7 +12,7 @@ class PostController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class PostController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class PostController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class PostController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class PostController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt index 8d5aef5e5..0006937ff 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt @@ -12,7 +12,7 @@ class PostController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class PostController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class PostController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class PostController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class PostController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt index 8d5aef5e5..0006937ff 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt @@ -12,7 +12,7 @@ class PostController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class PostController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class PostController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class PostController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class PostController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt index 01959660b..6a89e8c29 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt @@ -12,7 +12,7 @@ class BlogController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class BlogController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class BlogController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class BlogController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class BlogController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt index 01959660b..6a89e8c29 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt @@ -12,7 +12,7 @@ class BlogController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class BlogController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class BlogController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class BlogController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class BlogController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt index 01959660b..6a89e8c29 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -12,7 +12,7 @@ class BlogController extends Controller /** * Display a listing of the resource. */ - public function index(): Response + public function index() { return view('blog::index'); } @@ -20,7 +20,7 @@ class BlogController extends Controller /** * Show the form for creating a new resource. */ - public function create(): Response + public function create() { return view('blog::create'); } @@ -36,7 +36,7 @@ class BlogController extends Controller /** * Show the specified resource. */ - public function show($id): Response + public function show($id) { return view('blog::show'); } @@ -44,7 +44,7 @@ class BlogController extends Controller /** * Show the form for editing the specified resource. */ - public function edit($id): Response + public function edit($id) { return view('blog::edit'); } @@ -60,7 +60,7 @@ class BlogController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id): RedirectResponse + public function destroy($id) { // } From 40b80fbe208b29d4d3d6759b642a65b74cbed3fa Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Thu, 26 Oct 2023 10:02:00 +0700 Subject: [PATCH 068/422] feat: implicit rule --- src/Commands/RuleMakeCommand.php | 19 +++++++++++++++- src/Commands/stubs/rule.implicit.stub | 22 +++++++++++++++++++ tests/Commands/RuleMakeCommandTest.php | 12 ++++++++++ ...CommandTest__it_makes_implicit_rule__1.txt | 22 +++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/Commands/stubs/rule.implicit.stub create mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_implicit_rule__1.txt diff --git a/src/Commands/RuleMakeCommand.php b/src/Commands/RuleMakeCommand.php index 64b2123af..d59289e82 100644 --- a/src/Commands/RuleMakeCommand.php +++ b/src/Commands/RuleMakeCommand.php @@ -7,6 +7,7 @@ use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; class RuleMakeCommand extends GeneratorCommand { @@ -53,6 +54,18 @@ protected function getArguments() ]; } + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['implicit', 'i', InputOption::VALUE_NONE, 'Generate an implicit rule'], + ]; + } + /** * @return mixed */ @@ -60,7 +73,11 @@ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); - return (new Stub('/rule.stub', [ + $stub = $this->option('implicit') + ? '/rule.implicit.stub' + : '/rule.stub'; + + return (new Stub($stub, [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getFileName(), ]))->render(); diff --git a/src/Commands/stubs/rule.implicit.stub b/src/Commands/stubs/rule.implicit.stub new file mode 100644 index 000000000..edc029c29 --- /dev/null +++ b/src/Commands/stubs/rule.implicit.stub @@ -0,0 +1,22 @@ +assertSame(0, $code); } + /** @test */ + public function it_makes_implicit_rule() + { + $code = $this->artisan('module:make-rule', ['name' => 'ImplicitUniqueRule', 'module' => 'Blog', '--implicit' => true]); + + $ruleFile = $this->modulePath . '/Rules/ImplicitUniqueRule.php'; + + $this->assertTrue(is_file($ruleFile), 'Rule file was not created.'); + $this->assertMatchesSnapshot($this->finder->get($ruleFile)); + $this->assertSame(0, $code); + } + /** @test */ public function it_can_change_the_default_namespace() { diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_implicit_rule__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_implicit_rule__1.txt new file mode 100644 index 000000000..ef46fa0a2 --- /dev/null +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_implicit_rule__1.txt @@ -0,0 +1,22 @@ + Date: Thu, 26 Oct 2023 05:29:16 +0100 Subject: [PATCH 069/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1dc8a5d9..2ea0f814e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs to use return types - [@hungthai1401](https://github.com/hungthai1401) updated rule stub +## Added + +- [@hungthai1401](https://github.com/hungthai1401 ) added implicit rule + ## 10.0.2 - 2023-09-18 From d51a832ad43e07f979f51e55a2f20d1b92273551 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Wed, 25 Oct 2023 22:31:57 -0700 Subject: [PATCH 070/422] Update SeedMakeCommand.php Fix: Multiple "Seeder" keywords in the seeder file name. `BlogSeederTableSeeder.php` -> `BlogSeeder.php` --- src/Commands/SeedMakeCommand.php | 42 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/Commands/SeedMakeCommand.php b/src/Commands/SeedMakeCommand.php index 659c9ad97..43c0acf23 100644 --- a/src/Commands/SeedMakeCommand.php +++ b/src/Commands/SeedMakeCommand.php @@ -12,31 +12,25 @@ class SeedMakeCommand extends GeneratorCommand { - use ModuleCommandTrait; use CanClearModulesCache; + use ModuleCommandTrait; protected $argumentName = 'name'; /** * The console command name. - * - * @var string */ protected $name = 'module:make-seed'; /** * The console command description. - * - * @var string */ protected $description = 'Generate new seeder for the specified module.'; /** * Get the console command arguments. - * - * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['name', InputArgument::REQUIRED, 'The name of seeder will be created.'], @@ -46,10 +40,8 @@ protected function getArguments() /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ [ @@ -61,10 +53,7 @@ protected function getOptions() ]; } - /** - * @return mixed - */ - protected function getTemplateContents() + protected function getTemplateContents(): mixed { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); @@ -76,10 +65,7 @@ protected function getTemplateContents() ]))->render(); } - /** - * @return mixed - */ - protected function getDestinationFilePath() + protected function getDestinationFilePath(): mixed { $this->clearCache(); @@ -91,21 +77,23 @@ protected function getDestinationFilePath() } /** - * Get seeder name. - * - * @return string + * Get the seeder name. */ - private function getSeederName() + private function getSeederName(): string { - $end = $this->option('master') ? 'DatabaseSeeder' : 'TableSeeder'; + $string = $this->argument('name'); + $string .= $this->option('master') ? 'Database' : ''; + $suffix = 'Seeder'; + + if (strpos($string, $suffix) === false) { + $string .= $suffix; + } - return Str::studly($this->argument('name')) . $end; + return Str::studly($string); } /** * Get default namespace. - * - * @return string */ public function getDefaultNamespace(): string { From 1bb0d92b37efe2af2a41d4799307a24577d173d9 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Wed, 25 Oct 2023 22:49:25 -0700 Subject: [PATCH 071/422] Update config.php --- config/config.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 5c336fe81..eb64e55b7 100644 --- a/config/config.php +++ b/config/config.php @@ -105,7 +105,11 @@ 'command' => ['path' => 'app/Console', 'generate' => false], 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'migration' => ['path' => 'database/migrations', 'generate' => true], - 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'seeder' => [ + 'path' => 'database/seeders', + 'namespace' => 'Database/Seeders', + 'generate' => true, + ], 'factory' => ['path' => 'database/factories', 'generate' => true], 'model' => ['path' => 'app/Models', 'generate' => true], 'observer' => ['path' => 'app/Observers', 'generate' => false], From 8e9ba70f2f655145d75723a36d0fca12f579bb00 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Wed, 25 Oct 2023 23:02:41 -0700 Subject: [PATCH 072/422] Update composer.stub Add keys to transform the App, Database, and Test namespace. --- src/Commands/stubs/composer.stub | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Commands/stubs/composer.stub b/src/Commands/stubs/composer.stub index 8615cda46..7d75c4215 100644 --- a/src/Commands/stubs/composer.stub +++ b/src/Commands/stubs/composer.stub @@ -17,7 +17,15 @@ }, "autoload": { "psr-4": { - "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "" + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\App\\": "app/", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Factories\\": "database/factories/", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Tests\\": "tests/" } } } From bc7866433f0ffac137bcbeb4b0d56b6f69d751a7 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 26 Oct 2023 16:50:49 +0100 Subject: [PATCH 073/422] Update vite.stub Correct the path format. --- src/Commands/stubs/vite.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/vite.stub b/src/Commands/stubs/vite.stub index 4bc21f85c..11843e2b7 100644 --- a/src/Commands/stubs/vite.stub +++ b/src/Commands/stubs/vite.stub @@ -15,8 +15,8 @@ export default defineConfig({ publicDirectory: '../../public', buildDirectory: 'build-$LOWER_NAME$', input: [ - __dirname + '/Resources/assets/sass/app.scss', - __dirname + '/Resources/assets/js/app.js' + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' ], refresh: true, }), From 462bbf4b4b17c29447959397c2c5d4a37d23e0e0 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 26 Oct 2023 17:06:49 +0100 Subject: [PATCH 074/422] updated snapshots --- ...Test__it_generates_api_module_with_resources__3.txt | 9 ++------- ...Test__it_generates_api_module_with_resources__4.txt | 4 ++-- ...Test__it_generates_correct_composerjson_file__1.txt | 10 +++++++++- ...keCommandTest__it_generates_module_resources__3.txt | 9 ++------- ...keCommandTest__it_generates_module_resources__4.txt | 4 ++-- ...oduleMakeCommandTest__it_generates_vite_file__1.txt | 4 ++-- ...Test__it_generates_web_module_with_resources__3.txt | 9 ++------- ...Test__it_generates_web_module_with_resources__4.txt | 4 ++-- ...h_resources_when_adding_more_than_one_option__3.txt | 9 ++------- ...h_resources_when_adding_more_than_one_option__4.txt | 4 ++-- ...it_generes_module_with_new_provider_location__2.txt | 10 +++++++++- ...t_can_change_the_custom_controller_namespace__1.txt | 4 ++-- ...andTest__it_can_change_the_default_namespace__1.txt | 4 ++-- ...it_can_change_the_default_namespace_specific__1.txt | 4 ++-- ...oviderMakeCommandTest__it_can_overwrite_file__1.txt | 2 +- ...Test__it_generated_correct_file_with_content__1.txt | 4 ++-- 16 files changed, 45 insertions(+), 49 deletions(-) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt index decbc5805..97e7e2a48 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt @@ -3,19 +3,14 @@ namespace Modules\Blog\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Database\Eloquent\Model; class BlogDatabaseSeeder extends Seeder { /** * Run the database seeds. - * - * @return void */ - public function run() + public function run(): void { - Model::unguard(); - - // $this->call("OthersTableSeeder"); + // $this->call([]); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt index 982a5534a..970d8b01f 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt index acaf6a48b..c54049e1a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt @@ -17,7 +17,15 @@ }, "autoload": { "psr-4": { - "Modules\\Blog\\": "" + "Modules\\Blog\\": "", + "Modules\\Blog\\App\\": "app/", + "Modules\\Blog\\Database\\Factories\\": "database/factories/", + "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Blog\\Tests\\": "tests/" } } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt index decbc5805..97e7e2a48 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt @@ -3,19 +3,14 @@ namespace Modules\Blog\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Database\Eloquent\Model; class BlogDatabaseSeeder extends Seeder { /** * Run the database seeds. - * - * @return void */ - public function run() + public function run(): void { - Model::unguard(); - - // $this->call("OthersTableSeeder"); + // $this->call([]); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt index 982a5534a..970d8b01f 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt index 94f65d3fa..166dab311 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt @@ -15,8 +15,8 @@ export default defineConfig({ publicDirectory: '../../public', buildDirectory: 'build-blog', input: [ - __dirname + '/Resources/assets/sass/app.scss', - __dirname + '/Resources/assets/js/app.js' + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' ], refresh: true, }), diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt index decbc5805..97e7e2a48 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt @@ -3,19 +3,14 @@ namespace Modules\Blog\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Database\Eloquent\Model; class BlogDatabaseSeeder extends Seeder { /** * Run the database seeds. - * - * @return void */ - public function run() + public function run(): void { - Model::unguard(); - - // $this->call("OthersTableSeeder"); + // $this->call([]); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt index 982a5534a..970d8b01f 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt index decbc5805..97e7e2a48 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt @@ -3,19 +3,14 @@ namespace Modules\Blog\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Database\Eloquent\Model; class BlogDatabaseSeeder extends Seeder { /** * Run the database seeds. - * - * @return void */ - public function run() + public function run(): void { - Model::unguard(); - - // $this->call("OthersTableSeeder"); + // $this->call([]); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt index 982a5534a..970d8b01f 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt index acaf6a48b..c54049e1a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt @@ -17,7 +17,15 @@ }, "autoload": { "psr-4": { - "Modules\\Blog\\": "" + "Modules\\Blog\\": "", + "Modules\\Blog\\App\\": "app/", + "Modules\\Blog\\Database\\Factories\\": "database/factories/", + "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Blog\\Tests\\": "tests/" } } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt index 6393fb97e..2e1db2aae 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index f5dc95c12..9aefabdaf 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index f5dc95c12..9aefabdaf 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt index 1e54f7bdf..81eb22c7f 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt index 982a5534a..970d8b01f 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -41,7 +41,7 @@ class RouteServiceProvider extends ServiceProvider { Route::middleware('web') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/web.php')); + ->group(module_path('Blog', '/routes/web.php')); } /** @@ -54,6 +54,6 @@ class RouteServiceProvider extends ServiceProvider Route::prefix('api') ->middleware('api') ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/Routes/api.php')); + ->group(module_path('Blog', '/routes/api.php')); } } From fbd22475dec43a5bdd0db2047af093668102fe5f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 26 Oct 2023 18:36:53 +0100 Subject: [PATCH 075/422] Update config.php Fix: *** does not comply with the psr-4 autoloading standard. The namespace `Database/Seeders` has not been fully implemented yet. Until another pull request is submitted to address this issue, it is advised to continue using the default namespace 'database/seeders' --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index eb64e55b7..7ecadcf06 100644 --- a/config/config.php +++ b/config/config.php @@ -107,7 +107,7 @@ 'migration' => ['path' => 'database/migrations', 'generate' => true], 'seeder' => [ 'path' => 'database/seeders', - 'namespace' => 'Database/Seeders', + 'namespace' => 'database/seeders', 'generate' => true, ], 'factory' => ['path' => 'database/factories', 'generate' => true], From 4c5d87c1c97b7840a550dbb8103f290f38b65892 Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:11:39 +0100 Subject: [PATCH 076/422] use sanctum as placeholder for api auth --- src/Commands/stubs/routes/api.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/routes/api.stub b/src/Commands/stubs/routes/api.stub index 17d43af9d..5a87faa67 100755 --- a/src/Commands/stubs/routes/api.stub +++ b/src/Commands/stubs/routes/api.stub @@ -14,6 +14,6 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware(['auth:api'])->prefix('v1')->group(function () { - Route::get('/$LOWER_NAME$', fn (Request $request) => $request->user()); +Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { + Route::get('$LOWER_NAME$', fn (Request $request) => $request->user()); }); From 39d895dccfda79bff805bff285ba3def8547e281 Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:11:52 +0100 Subject: [PATCH 077/422] added placeholders for replacements --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 7ecadcf06..272f14ef4 100644 --- a/config/config.php +++ b/config/config.php @@ -41,7 +41,7 @@ 'package' => 'package.json', ], 'replacements' => [ - 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME'], + 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], 'routes/api' => ['LOWER_NAME'], 'vite' => ['LOWER_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], From d8ecf705e994bfb239f61d37095520e944a476fa Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:12:50 +0100 Subject: [PATCH 078/422] added getControllerNamespaceReplacement method for CONTROLLER_NAMESPACE placeholders --- src/Generators/ModuleGenerator.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index bff04d542..0c3f31c45 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -445,6 +445,8 @@ protected function getStubContents($stub) )->render(); } + + /** * get the list for the replacements. */ @@ -563,6 +565,16 @@ protected function getModuleNamespaceReplacement() return str_replace('\\', '\\\\', $this->module->config('namespace')); } + /** + * Get replacement for $CONTROLLER_NAMESPACE$. + * + * @return string + */ + private function getControllerNamespaceReplacement(): string + { + return str_replace('/', '\\', $this->module->config('paths.generator.controller.namespace') ?: $this->module->config('paths.generator.controller.path', 'Controller')); + } + /** * Get replacement for $AUTHOR_NAME$. * From 829a9f2f6b12ab10f86b3bf77ae477002d0b1190 Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:13:24 +0100 Subject: [PATCH 079/422] changed default route format --- src/Commands/stubs/routes/web.stub | 4 +++- .../ModuleMakeCommandTest__it_generates_api_route_file__1.txt | 4 ++-- .../ModuleMakeCommandTest__it_generates_web_route_file__1.txt | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Commands/stubs/routes/web.stub b/src/Commands/stubs/routes/web.stub index ab7e7f7c3..6de80a40a 100755 --- a/src/Commands/stubs/routes/web.stub +++ b/src/Commands/stubs/routes/web.stub @@ -10,7 +10,9 @@ | contains the "web" middleware group. Now create something great! | */ +use Illuminate\Support\Facades\Route; +use $MODULE_NAMESPACE$\$STUDLY_NAME$\$CONTROLLER_NAMESPACE$\$STUDLY_NAME$Controller; Route::prefix('$LOWER_NAME$')->group(function() { - Route::get('/', '$STUDLY_NAME$Controller@index'); + Route::get('/', [$STUDLY_NAME$Controller::class, 'index'])->name('$LOWER_NAME$.index'); }); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt index 42c8b7d3d..8b4beed77 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt @@ -14,6 +14,6 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware(['auth:api'])->prefix('v1')->group(function () { - Route::get('/blog', fn (Request $request) => $request->user()); +Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { + Route::get('blog', fn (Request $request) => $request->user()); }); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt index d4d641ff5..ce46e6439 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt @@ -10,7 +10,9 @@ | contains the "web" middleware group. Now create something great! | */ +use Illuminate\Support\Facades\Route; +use Modules\Blog\Http\Controllers\BlogController; Route::prefix('blog')->group(function() { - Route::get('/', 'BlogController@index'); + Route::get('/', [BlogController::class, 'index'])->name('blog.index'); }); From 40b935d406937da8693f21cb35bf91b7fe602f65 Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:13:38 +0100 Subject: [PATCH 080/422] updated CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea0f814e..27922dcbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed -- [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs to use return types +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs +- [@dcblogdev](https://github.com/dcblogdev) updated enababled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs - [@hungthai1401](https://github.com/hungthai1401) updated rule stub ## Added From d94cf8805493d903b0f96a08b32abbf978545e2f Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:13:55 +0100 Subject: [PATCH 081/422] updated CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27922dcbd..a826b5ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed - [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs -- [@dcblogdev](https://github.com/dcblogdev) updated enababled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs +- [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs - [@hungthai1401](https://github.com/hungthai1401) updated rule stub ## Added From 5b51c588eef35df17f1779d87189bf2afd001ca1 Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 13:34:57 +0100 Subject: [PATCH 082/422] added placeholders for console commands and their schedules inside module service provider --- CHANGELOG.md | 3 +- src/Commands/stubs/scaffold/provider.stub | 57 ++++++++++++++----- ...generates_api_module_with_resources__1.txt | 57 ++++++++++++++----- ..._module_namespace_using_studly_case__1.txt | 57 ++++++++++++++----- ...Test__it_generates_module_resources__1.txt | 57 ++++++++++++++----- ...generates_web_module_with_resources__1.txt | 57 ++++++++++++++----- ...es_when_adding_more_than_one_option__1.txt | 57 ++++++++++++++----- ...it_can_change_the_default_namespace__1.txt | 57 ++++++++++++++----- ...ange_the_default_namespace_specific__1.txt | 57 ++++++++++++++----- ..._migration_resources_location_paths__1.txt | 57 ++++++++++++++----- ...vice_provider_with_resource_loading__1.txt | 57 ++++++++++++++----- 11 files changed, 432 insertions(+), 141 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a826b5ceb..665dbef14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,9 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed -- [@solomon-ochepa](https://github.com/solomon-ochepa) updated stubs +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated multiple & config stubs for to follow modern laravel standards - [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs +- [@dcblogdev](https://github.com/dcblogdev) added placeholders for console commands and their schedules inside module service provider - [@hungthai1401](https://github.com/hungthai1401) updated rule stub ## Added diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 3a2dd6b6b..3b129816a 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -16,6 +16,8 @@ class $CLASS$ extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class $CLASS$ extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class $CLASS$ extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index c18b50f35..6a2d7910c 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index 2953befed..cb530f181 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -16,6 +16,8 @@ class ModuleNameServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class ModuleNameServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class ModuleNameServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index c18b50f35..6a2d7910c 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index c18b50f35..6a2d7910c 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index c18b50f35..6a2d7910c 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 878576762..43f654be1 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 878576762..43f654be1 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index 16f3964bf..0263a281d 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index c18b50f35..6a2d7910c 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -16,6 +16,8 @@ class BlogServiceProvider extends ServiceProvider */ public function boot(): void { + $this->registerCommands(); + $this->registerCommandSchedules(); $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); @@ -30,6 +32,47 @@ class BlogServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); } + /** + * Register commands in the format of Command::class + * + * @return void + */ + protected function registerCommands() + { + /*$this->commands([ + + ]);*/ + } + + /** + * Register command Schedules. + * + * @return void + */ + protected function registerCommandSchedules() + { + /*$this->app->booted(function () { + $schedule = $this->app->make(Schedule::class); + $schedule->command('inspire')->hourly(); + });*/ + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + } + } + /** * Register config. */ @@ -62,21 +105,7 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); - } - } /** * Get the services provided by the provider. From 8e6186cdc6c4fc5bb9bf7c6a28de81117646f7f1 Mon Sep 17 00:00:00 2001 From: David Carr Date: Fri, 27 Oct 2023 14:10:13 +0100 Subject: [PATCH 083/422] added placeholders for console commands and their schedules inside module service provider --- CHANGELOG.md | 3 ++- src/Commands/ModelMakeCommand.php | 19 ++++++++++++++++++- src/Commands/stubs/model.stub | 5 +++-- ...it_can_change_the_default_namespace__1.txt | 5 +++-- ...ange_the_default_namespace_specific__1.txt | 5 +++-- ...generated_correct_file_with_content__1.txt | 5 +++-- ...t_generates_correct_fillable_fields__1.txt | 5 +++-- 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 665dbef14..c56bded14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,12 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@solomon-ochepa](https://github.com/solomon-ochepa) updated multiple & config stubs for to follow modern laravel standards - [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs -- [@dcblogdev](https://github.com/dcblogdev) added placeholders for console commands and their schedules inside module service provider +- [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs - [@hungthai1401](https://github.com/hungthai1401) updated rule stub ## Added +- [@dcblogdev](https://github.com/dcblogdev) added option to generate a factory by using the flag -f when generating a model - [@hungthai1401](https://github.com/hungthai1401 ) added implicit rule diff --git a/src/Commands/ModelMakeCommand.php b/src/Commands/ModelMakeCommand.php index 87134871d..d6da06327 100644 --- a/src/Commands/ModelMakeCommand.php +++ b/src/Commands/ModelMakeCommand.php @@ -43,6 +43,7 @@ public function handle(): int $this->handleOptionalMigrationOption(); $this->handleOptionalControllerOption(); $this->handleOptionalSeedOption(); + $this->handleOptionalFactoryOption(); $this->handleOptionalRequestOption(); return 0; @@ -95,7 +96,8 @@ protected function getOptions() ['migration', 'm', InputOption::VALUE_NONE, 'Flag to create associated migrations', null], ['controller', 'c', InputOption::VALUE_NONE, 'Flag to create associated controllers', null], ['seed', 's', InputOption::VALUE_NONE, 'Create a new seeder for the model', null], - ['request', 'r', InputOption::VALUE_NONE, 'Create a new request for the model', null] + ['factory', 'f', InputOption::VALUE_NONE, 'Create a new factory for the model', null], + ['request', 'r', InputOption::VALUE_NONE, 'Create a new request for the model', null], ]; } @@ -142,6 +144,21 @@ protected function handleOptionalSeedOption() } } + /** + * Create a seeder file for the model. + * + * @return void + */ + protected function handleOptionalFactoryOption() + { + if ($this->option('factory') === true) { + $this->call('module:make-factory', array_filter([ + 'name' => $this->getModelName(), + 'module' => $this->argument('module') + ])); + } + } + /** * Create a request file for the model. * diff --git a/src/Commands/stubs/model.stub b/src/Commands/stubs/model.stub index b691e5ee0..db2f9b9ce 100644 --- a/src/Commands/stubs/model.stub +++ b/src/Commands/stubs/model.stub @@ -4,6 +4,7 @@ namespace $NAMESPACE$; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use $MODULE_NAMESPACE$\$MODULE$\Database\factories\$NAME$Factory; class $CLASS$ extends Model { @@ -11,8 +12,8 @@ class $CLASS$ extends Model protected $fillable = $FILLABLE$; - protected static function newFactory() + protected static function newFactory(): $NAME$Factory { - return \$MODULE_NAMESPACE$\$MODULE$\Database\factories\$NAME$Factory::new(); + //return $NAME$Factory::new(); } } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt index 7b64dbf18..17ff74ed1 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -4,6 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Modules\Blog\Database\factories\PostFactory; class Post extends Model { @@ -11,8 +12,8 @@ class Post extends Model protected $fillable = []; - protected static function newFactory() + protected static function newFactory(): PostFactory { - return \Modules\Blog\Database\factories\PostFactory::new(); + //return PostFactory::new(); } } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 7b64dbf18..17ff74ed1 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -4,6 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Modules\Blog\Database\factories\PostFactory; class Post extends Model { @@ -11,8 +12,8 @@ class Post extends Model protected $fillable = []; - protected static function newFactory() + protected static function newFactory(): PostFactory { - return \Modules\Blog\Database\factories\PostFactory::new(); + //return PostFactory::new(); } } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt index 3e541f806..299cac90b 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -4,6 +4,7 @@ namespace Modules\Blog\Entities; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Modules\Blog\Database\factories\PostFactory; class Post extends Model { @@ -11,8 +12,8 @@ class Post extends Model protected $fillable = []; - protected static function newFactory() + protected static function newFactory(): PostFactory { - return \Modules\Blog\Database\factories\PostFactory::new(); + //return PostFactory::new(); } } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt index 9a3f9c800..07681c1eb 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt @@ -4,6 +4,7 @@ namespace Modules\Blog\Entities; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Modules\Blog\Database\factories\PostFactory; class Post extends Model { @@ -11,8 +12,8 @@ class Post extends Model protected $fillable = ["title","slug"]; - protected static function newFactory() + protected static function newFactory(): PostFactory { - return \Modules\Blog\Database\factories\PostFactory::new(); + //return PostFactory::new(); } } From 4e9b2f6bc291837e73371beea4c6a80e57f514be Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 29 Oct 2023 18:32:21 +0100 Subject: [PATCH 084/422] Update master.stub Mocking the latest Laravel Layout format `Guest.blade.php` --- src/Commands/stubs/views/master.stub | 40 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/Commands/stubs/views/master.stub b/src/Commands/stubs/views/master.stub index 89d8b7653..6821e0d97 100644 --- a/src/Commands/stubs/views/master.stub +++ b/src/Commands/stubs/views/master.stub @@ -1,19 +1,29 @@ - - - - - - Module $STUDLY_NAME$ + - {{-- Laravel Vite - CSS File --}} - {{-- {{ module_vite('build-$LOWER_NAME$', 'Resources/assets/sass/app.scss') }} --}} + + + + + - - - @yield('content') + $STUDLY_NAME$ Module - {{ config('app.name', 'Laravel') }} - {{-- Laravel Vite - JS File --}} - {{-- {{ module_vite('build-$LOWER_NAME$', 'Resources/assets/js/app.js') }} --}} - - + + + + + + + + + {{-- Vite CSS --}} + {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/sass/app.scss') }} --}} + + + + {{ $slot }} + + {{-- Vite JS --}} + {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/js/app.js') }} --}} + From 7dff34a6646b1d61aad556a79c61de7c2ab8fead Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 12:40:46 +0100 Subject: [PATCH 085/422] Update add.stub Update the return type and general reformatting. --- src/Commands/stubs/migration/add.stub | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Commands/stubs/migration/add.stub b/src/Commands/stubs/migration/add.stub index 4d1e064ad..788cdee2a 100644 --- a/src/Commands/stubs/migration/add.stub +++ b/src/Commands/stubs/migration/add.stub @@ -1,32 +1,28 @@ Date: Mon, 30 Oct 2023 12:47:55 +0100 Subject: [PATCH 086/422] Update create.stub Update the return type and general reformatting. --- src/Commands/stubs/migration/create.stub | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Commands/stubs/migration/create.stub b/src/Commands/stubs/migration/create.stub index c03d510cd..a8f8ab156 100644 --- a/src/Commands/stubs/migration/create.stub +++ b/src/Commands/stubs/migration/create.stub @@ -1,31 +1,27 @@ id(); -$FIELDS$ + $FIELDS$ $table->timestamps(); }); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('$TABLE$'); } From f86522cdbe8886f50b0163a086e983272aff445f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 12:51:56 +0100 Subject: [PATCH 087/422] Update delete.stub Update the return types and general reformatting. --- src/Commands/stubs/migration/delete.stub | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Commands/stubs/migration/delete.stub b/src/Commands/stubs/migration/delete.stub index 4d1e064ad..788cdee2a 100644 --- a/src/Commands/stubs/migration/delete.stub +++ b/src/Commands/stubs/migration/delete.stub @@ -1,32 +1,28 @@ Date: Mon, 30 Oct 2023 12:57:32 +0100 Subject: [PATCH 088/422] Update drop.stub Update the return types and general reformatting. --- src/Commands/stubs/migration/drop.stub | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Commands/stubs/migration/drop.stub b/src/Commands/stubs/migration/drop.stub index 94023ac16..df6b91970 100644 --- a/src/Commands/stubs/migration/drop.stub +++ b/src/Commands/stubs/migration/drop.stub @@ -1,31 +1,27 @@ bigIncrements('id'); -$FIELDS$ + $table->id(); + $FIELDS$ $table->timestamps(); }); } From a92307954edb01eebc52605be47060d5b1780998 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 12:59:44 +0100 Subject: [PATCH 089/422] Update plain.stub Update the return types and general reformatting. --- src/Commands/stubs/migration/plain.stub | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Commands/stubs/migration/plain.stub b/src/Commands/stubs/migration/plain.stub index e46b052fc..88fa2f36b 100644 --- a/src/Commands/stubs/migration/plain.stub +++ b/src/Commands/stubs/migration/plain.stub @@ -1,27 +1,23 @@ Date: Mon, 30 Oct 2023 13:14:30 +0100 Subject: [PATCH 090/422] Update web.stub Create routes from resources and move namespaces importation (`use`) to the top. --- src/Commands/stubs/routes/web.stub | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Commands/stubs/routes/web.stub b/src/Commands/stubs/routes/web.stub index 6de80a40a..c00f766d9 100755 --- a/src/Commands/stubs/routes/web.stub +++ b/src/Commands/stubs/routes/web.stub @@ -1,5 +1,8 @@ group(function() { - Route::get('/', [$STUDLY_NAME$Controller::class, 'index'])->name('$LOWER_NAME$.index'); +Route::group([], function () { + Route::resource('$LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$'); }); From 2539346da70b1f25495c79433558363a19123c5a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 13:25:53 +0100 Subject: [PATCH 091/422] Update index.stub Update to extend the default layout. --- src/Commands/stubs/views/index.stub | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Commands/stubs/views/index.stub b/src/Commands/stubs/views/index.stub index 04b928889..1d4aaa6bd 100644 --- a/src/Commands/stubs/views/index.stub +++ b/src/Commands/stubs/views/index.stub @@ -1,9 +1,5 @@ -@extends('$LOWER_NAME$::layouts.master') - -@section('content') +

Hello World

-

- This view is loaded from module: {!! config('$LOWER_NAME$.name') !!} -

-@endsection +

Module: {!! config('$LOWER_NAME$.name') !!}

+
From d953be9523c3b3a1ff6d445c5d127a4207500135 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 13:31:14 +0100 Subject: [PATCH 092/422] Update master.stub --- src/Commands/stubs/views/master.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/views/master.stub b/src/Commands/stubs/views/master.stub index 6821e0d97..2607e5d0d 100644 --- a/src/Commands/stubs/views/master.stub +++ b/src/Commands/stubs/views/master.stub @@ -21,7 +21,7 @@ {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/sass/app.scss') }} --}} - + {{ $slot }} {{-- Vite JS --}} From 61c62ac6a17fd3b9898b5fa605fe1ce600cb896a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 14:12:28 +0100 Subject: [PATCH 093/422] Update provider.stub Update the returns type and general reformatting. --- src/Commands/stubs/scaffold/provider.stub | 35 +++++++---------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 3b129816a..55b6f5242 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -34,27 +34,21 @@ class $CLASS$ extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class $CLASS$ extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, '$PATH_CONFIG$/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, '$PATH_CONFIG$/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class $CLASS$ extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, '$PATH_VIEWS$'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class $CLASS$ extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ From e76eaefb7b63fa3db5362f96204701a759180a84 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 30 Oct 2023 13:24:50 +0000 Subject: [PATCH 094/422] updated snapshots --- ..._correct_add_migration_file_content__1.txt | 16 ++++----- ...rrect_create_migration_file_content__1.txt | 14 +++----- ...rect_default_migration_file_content__1.txt | 12 +++---- ...rrect_delete_migration_file_content__1.txt | 16 ++++----- ...correct_drop_migration_file_content__1.txt | 16 ++++----- ...t_generates_foreign_key_constraints__1.txt | 14 +++----- ...gration_when_both_flags_are_present__2.txt | 14 +++----- ...file_name_with_multiple_words_model__1.txt | 14 +++----- ...generates_migration_file_with_model__1.txt | 14 +++----- ...le_with_model_using_shortcut_option__1.txt | 14 +++----- ...generates_api_module_with_resources__1.txt | 35 ++++++------------- ..._module_namespace_using_studly_case__1.txt | 35 ++++++------------- ...Test__it_generates_module_resources__1.txt | 35 ++++++------------- ...generates_web_module_with_resources__1.txt | 35 ++++++------------- ...es_when_adding_more_than_one_option__1.txt | 35 ++++++------------- ...ndTest__it_generates_web_route_file__1.txt | 9 ++--- ...it_can_change_the_default_namespace__1.txt | 35 ++++++------------- ...ange_the_default_namespace_specific__1.txt | 35 ++++++------------- ..._migration_resources_location_paths__1.txt | 35 ++++++------------- ...vice_provider_with_resource_loading__1.txt | 35 ++++++------------- 20 files changed, 147 insertions(+), 321 deletions(-) diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_add_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_add_migration_file_content__1.txt index 7f55aeaea..ec659d5fe 100644 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_add_migration_file_content__1.txt +++ b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_add_migration_file_content__1.txt @@ -1,32 +1,28 @@ id(); - + $table->timestamps(); }); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('posts'); } diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.txt index e46b052fc..88fa2f36b 100644 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.txt +++ b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.txt @@ -1,27 +1,23 @@ bigIncrements('id'); - + $table->id(); + $table->timestamps(); }); } diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt index 06a41628c..6546dae4d 100644 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt +++ b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt @@ -1,21 +1,19 @@ id(); - $table->integer('user_id')->unsigned(); + $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users'); $table->timestamps(); @@ -24,10 +22,8 @@ return new class extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('posts'); } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt index e61d263de..36dc20e86 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt @@ -1,31 +1,27 @@ id(); - + $table->timestamps(); }); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('posts'); } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt index ab0772347..1e0f11a0a 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt @@ -1,31 +1,27 @@ id(); - + $table->timestamps(); }); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('product_details'); } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt index e61d263de..36dc20e86 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt @@ -1,31 +1,27 @@ id(); - + $table->timestamps(); }); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('posts'); } diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt index e61d263de..36dc20e86 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt @@ -1,31 +1,27 @@ id(); - + $table->timestamps(); }); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('posts'); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index 6a2d7910c..04b5ac2ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index cb530f181..4643559ad 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -34,27 +34,21 @@ class ModuleNameServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class ModuleNameServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class ModuleNameServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class ModuleNameServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index 6a2d7910c..04b5ac2ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index 6a2d7910c..04b5ac2ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 6a2d7910c..04b5ac2ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt index ce46e6439..082efd6d4 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt @@ -1,5 +1,8 @@ group(function() { - Route::get('/', [BlogController::class, 'index'])->name('blog.index'); +Route::group([], function () { + Route::resource('blog', BlogController::class)->names('blog'); }); diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 43f654be1..c17228e41 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 43f654be1..c17228e41 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index 0263a281d..8b2f3eae8 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index 6a2d7910c..04b5ac2ab 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -34,27 +34,21 @@ class BlogServiceProvider extends ServiceProvider /** * Register commands in the format of Command::class - * - * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - /*$this->commands([ - - ]);*/ + // $this->commands([]); } /** * Register command Schedules. - * - * @return void */ - protected function registerCommandSchedules() + protected function registerCommandSchedules(): void { - /*$this->app->booted(function () { - $schedule = $this->app->make(Schedule::class); - $schedule->command('inspire')->hourly(); - });*/ + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); } /** @@ -78,12 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'config'); - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); + $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); } /** @@ -92,12 +82,9 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); - $this->publishes([ - $sourcePath => $viewPath, - ], ['views', $this->moduleNameLower.'-module-views',]); + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); @@ -105,8 +92,6 @@ class BlogServiceProvider extends ServiceProvider Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } - - /** * Get the services provided by the provider. */ From 750a9acd979d71b088dfa8a45bba83141821ca3c Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 16:48:12 +0100 Subject: [PATCH 095/422] Update model.stub Add missing comment documentation to `$fillable` --- src/Commands/stubs/model.stub | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Commands/stubs/model.stub b/src/Commands/stubs/model.stub index db2f9b9ce..ac848e872 100644 --- a/src/Commands/stubs/model.stub +++ b/src/Commands/stubs/model.stub @@ -10,6 +10,9 @@ class $CLASS$ extends Model { use HasFactory; + /** + * The attributes that are mass assignable. + */ protected $fillable = $FILLABLE$; protected static function newFactory(): $NAME$Factory From 51f04275deee2f82d9dce7726385b0f635f9efad Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 16:52:44 +0100 Subject: [PATCH 096/422] Update request.stub Add permission-based return value to the `authorize()` method. --- src/Commands/stubs/request.stub | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/stubs/request.stub b/src/Commands/stubs/request.stub index 202d2e0dd..0dc2cbced 100644 --- a/src/Commands/stubs/request.stub +++ b/src/Commands/stubs/request.stub @@ -22,5 +22,6 @@ class $CLASS$ extends FormRequest public function authorize(): bool { return true; + // return auth()->user()->can('users.create'); } } From 558dcd1824a4dfc2edf773ceea0a4dc0d081814a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 30 Oct 2023 17:35:27 +0100 Subject: [PATCH 097/422] Update api.stub Add a group `name` to distinguish between `api` and ordinary `web` routes. Also, add the route name. --- src/Commands/stubs/routes/api.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/routes/api.stub b/src/Commands/stubs/routes/api.stub index 5a87faa67..4941c53b5 100755 --- a/src/Commands/stubs/routes/api.stub +++ b/src/Commands/stubs/routes/api.stub @@ -14,6 +14,6 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { - Route::get('$LOWER_NAME$', fn (Request $request) => $request->user()); +Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () { + Route::get('$LOWER_NAME$', fn (Request $request) => $request->user())->name('$LOWER_NAME$); }); From 18846333173d55ccb592e7c4242ace72f4bd2970 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 06:47:03 +0000 Subject: [PATCH 098/422] updated snapshots --- ...akeCommandTest__it_can_change_the_default_namespace__1.txt | 3 +++ ...dTest__it_can_change_the_default_namespace_specific__1.txt | 3 +++ ...CommandTest__it_generated_correct_file_with_content__1.txt | 3 +++ ...keCommandTest__it_generates_correct_fillable_fields__1.txt | 3 +++ .../ModuleMakeCommandTest__it_generates_api_route_file__1.txt | 4 ++-- ...akeCommandTest__it_can_change_the_default_namespace__1.txt | 1 + ...dTest__it_can_change_the_default_namespace_specific__1.txt | 1 + ...CommandTest__it_generated_correct_file_with_content__1.txt | 1 + 8 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt index 17ff74ed1..5c74c8eca 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -10,6 +10,9 @@ class Post extends Model { use HasFactory; + /** + * The attributes that are mass assignable. + */ protected $fillable = []; protected static function newFactory(): PostFactory diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 17ff74ed1..5c74c8eca 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -10,6 +10,9 @@ class Post extends Model { use HasFactory; + /** + * The attributes that are mass assignable. + */ protected $fillable = []; protected static function newFactory(): PostFactory diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt index 299cac90b..963d9acbe 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -10,6 +10,9 @@ class Post extends Model { use HasFactory; + /** + * The attributes that are mass assignable. + */ protected $fillable = []; protected static function newFactory(): PostFactory diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt index 07681c1eb..5088dd99c 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt @@ -10,6 +10,9 @@ class Post extends Model { use HasFactory; + /** + * The attributes that are mass assignable. + */ protected $fillable = ["title","slug"]; protected static function newFactory(): PostFactory diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt index 8b4beed77..172572266 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt @@ -14,6 +14,6 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { - Route::get('blog', fn (Request $request) => $request->user()); +Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () { + Route::get('blog', fn (Request $request) => $request->user())->name('blog); }); diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt index f217f1ecf..e36a083c6 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -22,5 +22,6 @@ class CreateBlogPostRequest extends FormRequest public function authorize(): bool { return true; + // return auth()->user()->can('users.create'); } } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index f217f1ecf..e36a083c6 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -22,5 +22,6 @@ class CreateBlogPostRequest extends FormRequest public function authorize(): bool { return true; + // return auth()->user()->can('users.create'); } } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt index e4829d542..95ee48bde 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -22,5 +22,6 @@ class CreateBlogPostRequest extends FormRequest public function authorize(): bool { return true; + // return auth()->user()->can('users.create'); } } From 11d3f931ffdf9c3b4ffc1e29a35c2287af2fa0e0 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 08:20:05 +0000 Subject: [PATCH 099/422] updated snapshots --- src/Commands/stubs/routes/api.stub | 2 +- .../ModuleMakeCommandTest__it_generates_api_route_file__1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/routes/api.stub b/src/Commands/stubs/routes/api.stub index 4941c53b5..10ae87e72 100755 --- a/src/Commands/stubs/routes/api.stub +++ b/src/Commands/stubs/routes/api.stub @@ -15,5 +15,5 @@ use Illuminate\Support\Facades\Route; */ Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () { - Route::get('$LOWER_NAME$', fn (Request $request) => $request->user())->name('$LOWER_NAME$); + Route::get('$LOWER_NAME$', fn (Request $request) => $request->user())->name('$LOWER_NAME$'); }); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt index 172572266..b7fd90bac 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt @@ -15,5 +15,5 @@ use Illuminate\Support\Facades\Route; */ Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () { - Route::get('blog', fn (Request $request) => $request->user())->name('blog); + Route::get('blog', fn (Request $request) => $request->user())->name('blog'); }); From 954da31c87078e09ed245e993a1554a9c864a15f Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 11:50:54 +0000 Subject: [PATCH 100/422] set package to have type module set --- src/Commands/stubs/package.stub | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/stubs/package.stub b/src/Commands/stubs/package.stub index 30c1a8089..26c090d3f 100644 --- a/src/Commands/stubs/package.stub +++ b/src/Commands/stubs/package.stub @@ -1,5 +1,6 @@ { "private": true, + "type": "module", "scripts": { "dev": "vite", "build": "vite build" From 06c1a73839851843c754fd5adcd13a860f114cdd Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 11:51:27 +0000 Subject: [PATCH 101/422] added new method getAssets to load contents of manifest when exists --- src/Module.php | 20 ++++++++++++ tests/LaravelModuleTest.php | 62 +++++++++++++++++++++++++++++++------ 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/src/Module.php b/src/Module.php index a3148141c..c9a5770be 100644 --- a/src/Module.php +++ b/src/Module.php @@ -74,6 +74,26 @@ public function __construct(Container $app, string $name, $path) $this->app = $app; } + /** + * Returns an array of assets + * + * @return array + */ + public static function getAssets(): array + { + $paths = []; + + if (file_exists('build/manifest.json')) { + $files = json_decode(file_get_contents('build/manifest.json'), true); + + foreach ($files as $file) { + $paths[] = $file['src']; + } + } + + return $paths; + } + /** * Get name. * diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index c91452221..34e974c1b 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -23,7 +23,7 @@ class LaravelModuleTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid/Recipe'); + $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid/Recipe'); $this->activator = $this->app[ActivatorInterface::class]; } @@ -36,13 +36,13 @@ public function tearDown(): void public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - symlink(__DIR__ . '/stubs/valid', __DIR__ . '/stubs/valid_symlink'); + symlink(__DIR__.'/stubs/valid', __DIR__.'/stubs/valid_symlink'); } public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); - unlink(__DIR__ . '/stubs/valid_symlink'); + unlink(__DIR__.'/stubs/valid_symlink'); } /** @test */ @@ -78,7 +78,7 @@ public function it_gets_module_description() /** @test */ public function it_gets_module_path() { - $this->assertEquals(__DIR__ . '/stubs/valid/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__.'/stubs/valid/Recipe', $this->module->getPath()); } /** @test */ @@ -86,9 +86,9 @@ public function it_gets_module_path_with_symlink() { // symlink created in setUpBeforeClass - $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid_symlink/Recipe'); + $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid_symlink/Recipe'); - $this->assertEquals(__DIR__ . '/stubs/valid_symlink/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__.'/stubs/valid_symlink/Recipe', $this->module->getPath()); // symlink deleted in tearDownAfterClass } @@ -96,7 +96,7 @@ public function it_gets_module_path_with_symlink() /** @test */ public function it_loads_module_translations() { - (new TestingModule($this->app, 'Recipe', __DIR__ . '/stubs/valid/Recipe'))->boot(); + (new TestingModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'))->boot(); $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); } @@ -205,9 +205,9 @@ public function it_makes_a_manifest_file_when_providers_are_loaded() RecipeServiceProvider::class, DeferredServiceProvider::class, ], - 'eager' => [RecipeServiceProvider::class], - 'deferred' => ['deferred' => DeferredServiceProvider::class], - 'when' => + 'eager' => [RecipeServiceProvider::class], + 'deferred' => ['deferred' => DeferredServiceProvider::class], + 'when' => [DeferredServiceProvider::class => []], ], $manifest); } @@ -230,6 +230,48 @@ public function it_can_load_a_deferred_provider() $this->assertEquals('bar', app('foo')); } + + /** @test */ + public function it_can_load_assets_is_empty_when_no_manifest_exists() + { + $result = $this->module->getAssets(); + + $this->assertEquals([], $result); + } + + /** @test */ + public function it_can_load_assets_when_manifest_exists() + { + mkdir('build'); + file_put_contents('build/manifest.json', '{ + "Modules/Books/resources/assets/sass/app.scss": { + "file": "assets/app-4ed993c7.js", + "isEntry": true, + "src": "Modules/Books/resources/assets/sass/app.scss" + }, + "Modules/Pages/resources/css/app.css": { + "file": "assets/app-5a5d3a39.css", + "isEntry": true, + "src": "Modules/Pages/resources/css/app.css" + }, + "resources/css/app.css": { + "file": "assets/app-3ebdfa1f.css", + "isEntry": true, + "src": "resources/css/app.css" + } + }'); + + $result = $this->module->getAssets(); + + $this->assertEquals([ + 'Modules/Books/resources/assets/sass/app.scss', + 'Modules/Pages/resources/css/app.css', + 'resources/css/app.css' + ], $result); + + unlink('build/manifest.json'); + rmdir('build'); + } } class TestingModule extends \Nwidart\Modules\Laravel\Module From 2df05ccc5fc63503a904cdde14777cb2ad332529 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 11:52:02 +0000 Subject: [PATCH 102/422] added option to publish vite-module-loader.js --- scripts/vite-module-loader.js | 45 ++++++++++++++++++++++++++++++++++ src/ModulesServiceProvider.php | 4 +++ 2 files changed, 49 insertions(+) create mode 100644 scripts/vite-module-loader.js diff --git a/scripts/vite-module-loader.js b/scripts/vite-module-loader.js new file mode 100644 index 000000000..ab41f226d --- /dev/null +++ b/scripts/vite-module-loader.js @@ -0,0 +1,45 @@ +import fs from 'fs/promises'; +import path from 'path'; + +async function collectModuleAssetsPaths(paths, modulesPath) { + modulesPath = path.join(__dirname, modulesPath); + + const moduleStatusesPath = path.join(__dirname, 'modules_statuses.json'); + + try { + // Read module_statuses.json + const moduleStatusesContent = await fs.readFile(moduleStatusesPath, 'utf-8'); + const moduleStatuses = JSON.parse(moduleStatusesContent); + + // Read module directories + const moduleDirectories = await fs.readdir(modulesPath); + + for (const moduleDir of moduleDirectories) { + if (moduleDir === '.DS_Store') { + // Skip .DS_Store directory + continue; + } + + // Check if the module is enabled (status is true) + if (moduleStatuses[moduleDir] === true) { + const viteConfigPath = path.join(modulesPath, moduleDir, 'vite.config.js'); + const stat = await fs.stat(viteConfigPath); + + if (stat.isFile()) { + // Import the module-specific Vite configuration + const moduleConfig = await import(viteConfigPath); + + if (moduleConfig.paths && Array.isArray(moduleConfig.paths)) { + paths.push(...moduleConfig.paths); + } + } + } + } + } catch (error) { + console.error(`Error reading module statuses or module configurations: ${error}`); + } + + return paths; +} + +export default collectModuleAssetsPaths; diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index eb3fbf122..d7c10c14a 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -46,6 +46,10 @@ protected function registerNamespaces() $this->publishes([ $stubsPath => base_path('stubs/nwidart-stubs'), ], 'stubs'); + + $this->publishes([ + __DIR__.'/../scripts/vite-module-loader.js' => base_path('vite-module-loader.js'), + ], 'vite'); } /** From ecad31853164e6ec8f7442a1090d5ac39a153a31 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 12:47:53 +0000 Subject: [PATCH 103/422] added option to publish vite-module-loader.js --- src/Module.php | 9 +++++++-- tests/LaravelModuleTest.php | 38 +------------------------------------ 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/src/Module.php b/src/Module.php index c9a5770be..eb42f0364 100644 --- a/src/Module.php +++ b/src/Module.php @@ -6,6 +6,7 @@ use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Illuminate\Translation\Translator; @@ -86,8 +87,12 @@ public static function getAssets(): array if (file_exists('build/manifest.json')) { $files = json_decode(file_get_contents('build/manifest.json'), true); - foreach ($files as $file) { - $paths[] = $file['src']; + if (is_array($files)) { + foreach ($files as $file) { + if (isset($file['src'])) { + $paths[] = $file['src']; + } + } } } diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index 34e974c1b..e3933bd55 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -234,43 +234,7 @@ public function it_can_load_a_deferred_provider() /** @test */ public function it_can_load_assets_is_empty_when_no_manifest_exists() { - $result = $this->module->getAssets(); - - $this->assertEquals([], $result); - } - - /** @test */ - public function it_can_load_assets_when_manifest_exists() - { - mkdir('build'); - file_put_contents('build/manifest.json', '{ - "Modules/Books/resources/assets/sass/app.scss": { - "file": "assets/app-4ed993c7.js", - "isEntry": true, - "src": "Modules/Books/resources/assets/sass/app.scss" - }, - "Modules/Pages/resources/css/app.css": { - "file": "assets/app-5a5d3a39.css", - "isEntry": true, - "src": "Modules/Pages/resources/css/app.css" - }, - "resources/css/app.css": { - "file": "assets/app-3ebdfa1f.css", - "isEntry": true, - "src": "resources/css/app.css" - } - }'); - - $result = $this->module->getAssets(); - - $this->assertEquals([ - 'Modules/Books/resources/assets/sass/app.scss', - 'Modules/Pages/resources/css/app.css', - 'resources/css/app.css' - ], $result); - - unlink('build/manifest.json'); - rmdir('build'); + $this->assertEquals([], $this->module->getAssets()); } } From c2c508f6216b76c441912ac90b06463f143b81dd Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 13:32:07 +0000 Subject: [PATCH 104/422] removed unused import --- src/Commands/stubs/vite.stub | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Commands/stubs/vite.stub b/src/Commands/stubs/vite.stub index 11843e2b7..db0130029 100644 --- a/src/Commands/stubs/vite.stub +++ b/src/Commands/stubs/vite.stub @@ -1,6 +1,3 @@ -const dotenvExpand = require('dotenv-expand'); -dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/})); - import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; From 95aae990bfd9327968c354c01fd24b24912f2c8d Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 13:37:13 +0000 Subject: [PATCH 105/422] reverted layout so use extends, not all installs have layout components --- src/Commands/stubs/views/index.stub | 6 ++++-- src/Commands/stubs/views/master.stub | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Commands/stubs/views/index.stub b/src/Commands/stubs/views/index.stub index 1d4aaa6bd..1a535d44b 100644 --- a/src/Commands/stubs/views/index.stub +++ b/src/Commands/stubs/views/index.stub @@ -1,5 +1,7 @@ - +@extends('$LOWER_NAME$::layouts.master') + +@section('content')

Hello World

Module: {!! config('$LOWER_NAME$.name') !!}

-
+@endsection diff --git a/src/Commands/stubs/views/master.stub b/src/Commands/stubs/views/master.stub index 2607e5d0d..8fa6ac498 100644 --- a/src/Commands/stubs/views/master.stub +++ b/src/Commands/stubs/views/master.stub @@ -18,12 +18,12 @@ {{-- Vite CSS --}} - {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/sass/app.scss') }} --}} + {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/assets/sass/app.scss') }} --}} - {{ $slot }} + @yield('content') {{-- Vite JS --}} - {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/js/app.js') }} --}} + {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/assets/js/app.js') }} --}} From 7fb319b997d3ba3e39d3112fe8dc9b759de9a0e7 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 13:38:04 +0000 Subject: [PATCH 106/422] reverted layout so use extends, not all installs have layout components --- .../ModuleMakeCommandTest__it_generates_vite_file__1.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt index 166dab311..511b83f93 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt @@ -1,6 +1,3 @@ -const dotenvExpand = require('dotenv-expand'); -dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/})); - import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; From 3fe5c30c542e36ee740e150624e4af837903b36d Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 14:03:58 +0000 Subject: [PATCH 107/422] added return types --- CHANGELOG.md | 4 ++-- src/Commands/stubs/route-provider.stub | 2 +- src/Commands/stubs/scaffold/provider.stub | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c56bded14..dc9e1f48f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,13 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@solomon-ochepa](https://github.com/solomon-ochepa) updated multiple & config stubs for to follow modern laravel standards - [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs -- [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs - [@hungthai1401](https://github.com/hungthai1401) updated rule stub ## Added +- [@dcblogdev](https://github.com/dcblogdev) added support for using modules inside the main vite.config.js file https://github.com/nWidart/laravel-modules/pull/1682 - [@dcblogdev](https://github.com/dcblogdev) added option to generate a factory by using the flag -f when generating a model -- [@hungthai1401](https://github.com/hungthai1401 ) added implicit rule +- [@hungthai1401](https://github.com/hungthai1401 ) added implicit rule https://github.com/nWidart/laravel-modules/pull/1664 ## 10.0.2 - 2023-09-18 diff --git a/src/Commands/stubs/route-provider.stub b/src/Commands/stubs/route-provider.stub index f622e406b..e5aa0b5f3 100644 --- a/src/Commands/stubs/route-provider.stub +++ b/src/Commands/stubs/route-provider.stub @@ -10,7 +10,7 @@ class $CLASS$ extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$'; + protected string $moduleNamespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$'; /** * Called before routes are registered. diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 55b6f5242..526c5bd28 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class $CLASS$ extends ServiceProvider { - protected $moduleName = '$MODULE$'; + protected string $moduleName = '$MODULE$'; - protected $moduleNameLower = '$LOWER_NAME$'; + protected string $moduleNameLower = '$LOWER_NAME$'; /** * Boot the application events. From 53dc34d3ec4bca86b1cf92cdfe342daaff995302 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 14:04:29 +0000 Subject: [PATCH 108/422] added return types --- ...CommandTest__it_generates_api_module_with_resources__1.txt | 4 ++-- ...CommandTest__it_generates_api_module_with_resources__4.txt | 2 +- ...st__it_generates_module_namespace_using_studly_case__1.txt | 4 ++-- ...oduleMakeCommandTest__it_generates_module_resources__1.txt | 4 ++-- ...oduleMakeCommandTest__it_generates_module_resources__4.txt | 2 +- ...CommandTest__it_generates_web_module_with_resources__1.txt | 4 ++-- ...CommandTest__it_generates_web_module_with_resources__4.txt | 2 +- ...ule_with_resources_when_adding_more_than_one_option__1.txt | 4 ++-- ...ule_with_resources_when_adding_more_than_one_option__4.txt | 2 +- ...akeCommandTest__it_can_change_the_default_namespace__1.txt | 4 ++-- ...dTest__it_can_change_the_default_namespace_specific__1.txt | 4 ++-- ..._can_have_custom_migration_resources_location_paths__1.txt | 4 ++-- ...tes_a_master_service_provider_with_resource_loading__1.txt | 4 ++-- ...Test__it_can_change_the_custom_controller_namespace__1.txt | 2 +- ...akeCommandTest__it_can_change_the_default_namespace__1.txt | 2 +- ...dTest__it_can_change_the_default_namespace_specific__1.txt | 2 +- ...RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt | 2 +- ...rMakeCommandTest__it_can_overwrite_route_file_names__1.txt | 2 +- ...CommandTest__it_generated_correct_file_with_content__1.txt | 2 +- 19 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index 04b5ac2ab..7e1237a88 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt index 970d8b01f..f1dfe5127 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index 4643559ad..6e6f69083 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class ModuleNameServiceProvider extends ServiceProvider { - protected $moduleName = 'ModuleName'; + protected string $moduleName = 'ModuleName'; - protected $moduleNameLower = 'modulename'; + protected string $moduleNameLower = 'modulename'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index 04b5ac2ab..7e1237a88 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt index 970d8b01f..f1dfe5127 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index 04b5ac2ab..7e1237a88 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt index 970d8b01f..f1dfe5127 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 04b5ac2ab..7e1237a88 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt index 970d8b01f..f1dfe5127 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index c17228e41..290b4e978 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index c17228e41..290b4e978 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index 8b2f3eae8..cd1eb65f1 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index 04b5ac2ab..7e1237a88 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -7,9 +7,9 @@ use Illuminate\Support\ServiceProvider; class BlogServiceProvider extends ServiceProvider { - protected $moduleName = 'Blog'; + protected string $moduleName = 'Blog'; - protected $moduleNameLower = 'blog'; + protected string $moduleNameLower = 'blog'; /** * Boot the application events. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt index 2e1db2aae..4415d0ded 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Base\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Base\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 9aefabdaf..b93942cfe 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 9aefabdaf..b93942cfe 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt index 81eb22c7f..40a5982cb 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt index 2273f1db7..2abee95ad 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt index 970d8b01f..f1dfe5127 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; /** * Called before routes are registered. From 3bfc63e13e0e3920a5290b080a42dcc7363ec930 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 15:28:09 +0000 Subject: [PATCH 109/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc9e1f48f..c4db1a34c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Added -- [@dcblogdev](https://github.com/dcblogdev) added support for using modules inside the main vite.config.js file https://github.com/nWidart/laravel-modules/pull/1682 -- [@dcblogdev](https://github.com/dcblogdev) added option to generate a factory by using the flag -f when generating a model +- [@dcblogdev](https://github.com/dcblogdev) added support for using modules inside the main `vite.config.js` file https://github.com/nWidart/laravel-modules/pull/1682 +- [@dcblogdev](https://github.com/dcblogdev) added option to generate a factory by using the flag `-f` when generating a model - [@hungthai1401](https://github.com/hungthai1401 ) added implicit rule https://github.com/nWidart/laravel-modules/pull/1664 From 00501d62239b153970eac3470f46562cff48637b Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 17:42:37 +0000 Subject: [PATCH 110/422] added vite commented option --- config/config.php | 2 +- src/Commands/stubs/package.stub | 10 ++++------ src/Commands/stubs/vite.stub | 5 +++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index 272f14ef4..d9b24cb76 100644 --- a/config/config.php +++ b/config/config.php @@ -42,7 +42,7 @@ ], 'replacements' => [ 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], - 'routes/api' => ['LOWER_NAME'], + 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME'], 'vite' => ['LOWER_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], 'views/index' => ['LOWER_NAME'], diff --git a/src/Commands/stubs/package.stub b/src/Commands/stubs/package.stub index 26c090d3f..d6fbfc837 100644 --- a/src/Commands/stubs/package.stub +++ b/src/Commands/stubs/package.stub @@ -6,12 +6,10 @@ "build": "vite build" }, "devDependencies": { - "axios": "^0.21.4", - "dotenv": "^10.0.0", - "dotenv-expand": "^5.1.0", - "laravel-vite-plugin": "^0.6.0", - "lodash": "^4.17.21", + "axios": "^1.1.2", + "laravel-vite-plugin": "^0.7.5", + "sass": "^1.69.5", "postcss": "^8.3.7", - "vite": "^3.0.9" + "vite": "^4.0.0" } } diff --git a/src/Commands/stubs/vite.stub b/src/Commands/stubs/vite.stub index db0130029..314ef8101 100644 --- a/src/Commands/stubs/vite.stub +++ b/src/Commands/stubs/vite.stub @@ -19,3 +19,8 @@ export default defineConfig({ }), ], }); + +//export const paths = [ +// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', +// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', +//]; \ No newline at end of file From 2c9b3757d644971d2c555379dbc857ad0a4e0c59 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 17:44:01 +0000 Subject: [PATCH 111/422] updated snapshots --- .../ModuleMakeCommandTest__it_generates_vite_file__1.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt index 511b83f93..ef986a50e 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt @@ -19,3 +19,8 @@ export default defineConfig({ }), ], }); + +//export const paths = [ +// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', +// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', +//]; \ No newline at end of file From 786da1e6dfa2df6caa8718acb9c37a8fe94595b3 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 2 Nov 2023 17:47:33 +0000 Subject: [PATCH 112/422] updated CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4db1a34c..4e9fdffe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,11 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 10.0.3 - 2023-10-02 + ## Changed -- [@solomon-ochepa](https://github.com/solomon-ochepa) updated multiple & config stubs for to follow modern laravel standards +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated multiple & config stubs to follow modern laravel standards - [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs - [@hungthai1401](https://github.com/hungthai1401) updated rule stub From 9e1f3e1e87304ca88f1499b4d01aa32cd3a50f1f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 5 Nov 2023 18:31:35 +0100 Subject: [PATCH 113/422] Update request.stub Removed the commented code sample. `// return auth()->user()->can('users.create');` --- src/Commands/stubs/request.stub | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands/stubs/request.stub b/src/Commands/stubs/request.stub index 0dc2cbced..202d2e0dd 100644 --- a/src/Commands/stubs/request.stub +++ b/src/Commands/stubs/request.stub @@ -22,6 +22,5 @@ class $CLASS$ extends FormRequest public function authorize(): bool { return true; - // return auth()->user()->can('users.create'); } } From c33b0b7e194475c10cfe3486f7b535e6766b0f9c Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 13 Nov 2023 22:23:25 +0000 Subject: [PATCH 114/422] updated config provider path to be dynamic based on the module's config paths.generator.provider.path path --- src/Commands/PublishConfigurationCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Commands/PublishConfigurationCommand.php b/src/Commands/PublishConfigurationCommand.php index 6a681569b..7dcf99dc4 100644 --- a/src/Commands/PublishConfigurationCommand.php +++ b/src/Commands/PublishConfigurationCommand.php @@ -51,8 +51,10 @@ private function getServiceProviderForModule($module) { $namespace = $this->laravel['config']->get('modules.namespace'); $studlyName = Str::studly($module); + $provider = $this->laravel['config']->get('modules.paths.generator.provider.path'); + $provider = str_replace('/', '\\', $provider); - return "$namespace\\$studlyName\\Providers\\{$studlyName}ServiceProvider"; + return "$namespace\\$studlyName\\$provider\\{$studlyName}ServiceProvider"; } /** From cc969e527cb93967a27832d7ccb993dfd1f192e2 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 13 Nov 2023 22:26:14 +0000 Subject: [PATCH 115/422] updated snapshots --- ...stMakeCommandTest__it_can_change_the_default_namespace__1.txt | 1 - ...mandTest__it_can_change_the_default_namespace_specific__1.txt | 1 - ...akeCommandTest__it_generated_correct_file_with_content__1.txt | 1 - 3 files changed, 3 deletions(-) diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt index e36a083c6..f217f1ecf 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -22,6 +22,5 @@ class CreateBlogPostRequest extends FormRequest public function authorize(): bool { return true; - // return auth()->user()->can('users.create'); } } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index e36a083c6..f217f1ecf 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -22,6 +22,5 @@ class CreateBlogPostRequest extends FormRequest public function authorize(): bool { return true; - // return auth()->user()->can('users.create'); } } diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt index 95ee48bde..e4829d542 100644 --- a/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -22,6 +22,5 @@ class CreateBlogPostRequest extends FormRequest public function authorize(): bool { return true; - // return auth()->user()->can('users.create'); } } From 5a75f90d7d0d2689f1fb08c766f23fd3ee76769e Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 13 Nov 2023 22:35:16 +0000 Subject: [PATCH 116/422] updated snapshots --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e9fdffe7..105be1826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 10.0.4 - 2023-11-13 + +## Changed +- [@dcblogdev](https://github.com/dcblogdev) updated module:publish-config to a dynamic path to the service provider + ## 10.0.3 - 2023-10-02 ## Changed From 3232601c0e119be9824106fc996d8554a31b7d57 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 18 Nov 2023 01:53:19 -0800 Subject: [PATCH 117/422] Update README.md Moved the autoload property below the defaults for easy sighting and clarification. This doesn't alter its meaning or effects! --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index faad99b17..e79a496ae 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ By default, the module classes are not loaded automatically. You can autoload yo "autoload": { "psr-4": { "App\\": "app/", - "Modules\\": "Modules/", "Database\\Factories\\": "database/factories/", - "Database\\Seeders\\": "database/seeders/" + "Database\\Seeders\\": "database/seeders/", + "Modules\\": "Modules/" } } From 10679c305988dfe6755cacffecb79324a865959d Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 18 Nov 2023 02:26:33 -0800 Subject: [PATCH 118/422] Update README.md Move the command to the end for easy sighting and clarification. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e79a496ae..bcafa246b 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Find out why you should use this package in the article: [Writing modular applic ## Install -To install through Composer, by run the following command: +To install via Composer, run: ``` bash composer require nwidart/laravel-modules @@ -45,9 +45,7 @@ php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProv ``` ### Autoloading - -By default, the module classes are not loaded automatically. You can autoload your modules using `psr-4`. For example: - +By default, module classes aren't loaded automatically. To autoload them using psr-4, add the following line to the end of the root composer.json file under the autoload section: ``` json { "autoload": { From 57a1a66726f2d2bff90123c646f24dc65f7bb654 Mon Sep 17 00:00:00 2001 From: MojtabaKordpour Date: Tue, 5 Dec 2023 01:12:34 +0330 Subject: [PATCH 119/422] Add `static` to all methods in Module facade --- src/Facades/Module.php | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Facades/Module.php b/src/Facades/Module.php index 1e0d32b65..905a9b3fa 100644 --- a/src/Facades/Module.php +++ b/src/Facades/Module.php @@ -5,28 +5,28 @@ use Illuminate\Support\Facades\Facade; /** - * @method array all() - * @method array getCached() - * @method array scan() - * @method \Nwidart\Modules\Collection toCollection() - * @method array getScanPaths() - * @method array allEnabled() - * @method array allDisabled() - * @method int count() - * @method array getOrdered($direction = 'asc') - * @method array getByStatus($status) - * @method \Nwidart\Modules\Module find(string $name) - * @method \Nwidart\Modules\Module findOrFail(string $name) - * @method string getModulePath($moduleName) - * @method \Illuminate\Filesystem\Filesystem getFiles() - * @method mixed config(string $key, $default = NULL) - * @method string getPath() - * @method void boot() - * @method void register(): void - * @method string assetPath(string $module) - * @method bool delete(string $module) - * @method bool isEnabled(string $name) - * @method bool isDisabled(string $name) + * @method static array all() + * @method static array getCached() + * @method static array scan() + * @method static \Nwidart\Modules\Collection toCollection() + * @method static array getScanPaths() + * @method static array allEnabled() + * @method static array allDisabled() + * @method static int count() + * @method static array getOrdered($direction = 'asc') + * @method static array getByStatus($status) + * @method static \Nwidart\Modules\Module find(string $name) + * @method static \Nwidart\Modules\Module findOrFail(string $name) + * @method static string getModulePath($moduleName) + * @method static \Illuminate\Filesystem\Filesystem getFiles() + * @method static mixed config(string $key, $default = NULL) + * @method static string getPath() + * @method static void boot() + * @method static void register(): void + * @method static string assetPath(string $module) + * @method static bool delete(string $module) + * @method static bool isEnabled(string $name) + * @method static bool isDisabled(string $name) */ class Module extends Facade { From 30b443b7556062f76b557b729b8c7d78c0499ae2 Mon Sep 17 00:00:00 2001 From: Benjamin Niess Date: Thu, 7 Dec 2023 10:06:56 +0100 Subject: [PATCH 120/422] :bug: Fix ModelShowCommand extends property --- src/Commands/ModelShowCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/ModelShowCommand.php b/src/Commands/ModelShowCommand.php index 75eddf411..6aeaea549 100644 --- a/src/Commands/ModelShowCommand.php +++ b/src/Commands/ModelShowCommand.php @@ -2,11 +2,12 @@ namespace Nwidart\Modules\Commands; +use Illuminate\Console\Command; use Illuminate\Database\Console\ShowModelCommand; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('module:model-show', 'Show information about an Eloquent model in modules')] -class ModelShowCommand extends ShowModelCommand +class ModelShowCommand extends Command { From 8a2a66e3efb3ce0cad3631b6e1aac72afd7f6037 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Fri, 8 Dec 2023 23:58:08 +0330 Subject: [PATCH 121/422] [fix] revert extend class to ShowModelCommand --- src/Commands/ModelShowCommand.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Commands/ModelShowCommand.php b/src/Commands/ModelShowCommand.php index 6aeaea549..0fe9a526c 100644 --- a/src/Commands/ModelShowCommand.php +++ b/src/Commands/ModelShowCommand.php @@ -2,15 +2,12 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Illuminate\Database\Console\ShowModelCommand; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('module:model-show', 'Show information about an Eloquent model in modules')] -class ModelShowCommand extends Command +class ModelShowCommand extends ShowModelCommand { - - /** * The console command name. * From ae6111b6a73390a1fb2d0aa10e54b4900d934783 Mon Sep 17 00:00:00 2001 From: fpermana Date: Wed, 27 Dec 2023 10:56:36 +0700 Subject: [PATCH 122/422] Update ObserverMakeCommand.php Update Observer namespace class --- src/Commands/ObserverMakeCommand.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Commands/ObserverMakeCommand.php b/src/Commands/ObserverMakeCommand.php index 68f8196a0..5b756c2ff 100644 --- a/src/Commands/ObserverMakeCommand.php +++ b/src/Commands/ObserverMakeCommand.php @@ -54,7 +54,7 @@ protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/observer.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module) . '\Observers', + 'NAMESPACE' => $this->getClassNamespace($module), 'NAME' => $this->getModelName(), 'MODEL_NAMESPACE' => $this->getModelNamespace(), 'NAME_VARIABLE' => $this->getModelVariable(), @@ -120,4 +120,16 @@ public function handle(): int return 0; } + + /** + * Get default namespace. + * + * @return string + */ + public function getDefaultNamespace(): string + { + $module = $this->laravel['modules']; + + return $module->config('paths.generator.observer.namespace') ?: $module->config('paths.generator.observer.path', 'Observers'); + } } From f6dc7ffb7f020732ccd10f388bc50a9f30ec71b6 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 18 Jan 2024 22:51:01 +0000 Subject: [PATCH 123/422] updated CHANGELOG.md --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 105be1826..b1a033660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Added + +- [@azim-kordpour](https://github.com/azim-kordpour) Add PHPDoc static to all methods in Module facade + +## Changed + +- [@fpermana](https://github.com/fpermana) Update ObserverMakeCommand.php + +## Fixed + +- [@benjaminniess](https://github.com/benjaminniess) Fix ModelShowCommand extends property +- [@alissn](https://github.com/alissn) revert extend class to ShowModelCommand + + ## 10.0.4 - 2023-11-13 ## Changed From 3dc12c3e3ccb7bd742c5e5075005c2c458d4cfec Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Sat, 20 Jan 2024 01:59:28 +0330 Subject: [PATCH 124/422] [sync] sync command list from provider and config file --- config/config.php | 30 ++++++++++--------- src/Providers/ConsoleServiceProvider.php | 38 ++++++++++++------------ 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/config/config.php b/config/config.php index d9b24cb76..57e78b400 100644 --- a/config/config.php +++ b/config/config.php @@ -148,29 +148,24 @@ | */ 'commands' => [ + Commands\ChannelMakeCommand::class, + Commands\CheckLangCommand::class, Commands\CommandMakeCommand::class, Commands\ComponentClassMakeCommand::class, Commands\ComponentViewMakeCommand::class, Commands\ControllerMakeCommand::class, - Commands\ChannelMakeCommand::class, Commands\DisableCommand::class, Commands\DumpCommand::class, Commands\EnableCommand::class, Commands\EventMakeCommand::class, Commands\FactoryMakeCommand::class, + Commands\InstallCommand::class, Commands\JobMakeCommand::class, + Commands\LaravelModulesV6Migrator::class, + Commands\ListCommand::class, Commands\ListenerMakeCommand::class, Commands\MailMakeCommand::class, Commands\MiddlewareMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ObserverMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\InstallCommand::class, - Commands\LaravelModulesV6Migrator::class, - Commands\ListCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, Commands\MigrateCommand::class, Commands\MigrateFreshCommand::class, Commands\MigrateRefreshCommand::class, @@ -179,14 +174,21 @@ Commands\MigrateStatusCommand::class, Commands\MigrationMakeCommand::class, Commands\ModelMakeCommand::class, - Commands\ResourceMakeCommand::class, - Commands\RequestMakeCommand::class, - Commands\RuleMakeCommand::class, - Commands\RouteProviderMakeCommand::class, + Commands\ModelShowCommand::class, + Commands\ModuleDeleteCommand::class, + Commands\ModuleMakeCommand::class, + Commands\NotificationMakeCommand::class, + Commands\ObserverMakeCommand::class, + Commands\PolicyMakeCommand::class, + Commands\ProviderMakeCommand::class, Commands\PublishCommand::class, Commands\PublishConfigurationCommand::class, Commands\PublishMigrationCommand::class, Commands\PublishTranslationCommand::class, + Commands\RequestMakeCommand::class, + Commands\ResourceMakeCommand::class, + Commands\RouteProviderMakeCommand::class, + Commands\RuleMakeCommand::class, Commands\SeedCommand::class, Commands\SeedMakeCommand::class, Commands\SetupCommand::class, diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index ba99eec19..881a74af3 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -13,53 +13,53 @@ class ConsoleServiceProvider extends ServiceProvider */ protected $commands = [ Commands\ChannelMakeCommand::class, + Commands\CheckLangCommand::class, Commands\CommandMakeCommand::class, + Commands\ComponentClassMakeCommand::class, + Commands\ComponentViewMakeCommand::class, Commands\ControllerMakeCommand::class, Commands\DisableCommand::class, Commands\DumpCommand::class, Commands\EnableCommand::class, Commands\EventMakeCommand::class, + Commands\FactoryMakeCommand::class, + Commands\InstallCommand::class, Commands\JobMakeCommand::class, + Commands\LaravelModulesV6Migrator::class, + Commands\ListCommand::class, Commands\ListenerMakeCommand::class, Commands\MailMakeCommand::class, Commands\MiddlewareMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\RouteProviderMakeCommand::class, - Commands\InstallCommand::class, - Commands\ListCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\RequestMakeCommand::class, - Commands\RuleMakeCommand::class, Commands\MigrateCommand::class, + Commands\MigrateFreshCommand::class, Commands\MigrateRefreshCommand::class, Commands\MigrateResetCommand::class, - Commands\MigrateFreshCommand::class, Commands\MigrateRollbackCommand::class, Commands\MigrateStatusCommand::class, Commands\MigrationMakeCommand::class, Commands\ModelMakeCommand::class, - Commands\ObserverMakeCommand::class, Commands\ModelShowCommand::class, + Commands\ModuleDeleteCommand::class, + Commands\ModuleMakeCommand::class, + Commands\NotificationMakeCommand::class, + Commands\ObserverMakeCommand::class, + Commands\PolicyMakeCommand::class, + Commands\ProviderMakeCommand::class, Commands\PublishCommand::class, Commands\PublishConfigurationCommand::class, Commands\PublishMigrationCommand::class, Commands\PublishTranslationCommand::class, + Commands\RequestMakeCommand::class, + Commands\ResourceMakeCommand::class, + Commands\RouteProviderMakeCommand::class, + Commands\RuleMakeCommand::class, Commands\SeedCommand::class, Commands\SeedMakeCommand::class, Commands\SetupCommand::class, + Commands\TestMakeCommand::class, Commands\UnUseCommand::class, Commands\UpdateCommand::class, Commands\UseCommand::class, - Commands\ResourceMakeCommand::class, - Commands\TestMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, - Commands\ComponentClassMakeCommand::class, - Commands\ComponentViewMakeCommand::class, - Commands\CheckLangCommand::class, ]; public function register(): void From 73f4d67ad9c48676d42ee9da463adc2c6314a99a Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Sat, 20 Jan 2024 02:20:32 +0330 Subject: [PATCH 125/422] [feat] merge command from provider and config --- config/config.php | 61 ++---------- src/Providers/ConsoleServiceProvider.php | 118 ++++++++++++----------- 2 files changed, 70 insertions(+), 109 deletions(-) diff --git a/config/config.php b/config/config.php index 57e78b400..c675de663 100644 --- a/config/config.php +++ b/config/config.php @@ -1,7 +1,7 @@ [ - Commands\ChannelMakeCommand::class, - Commands\CheckLangCommand::class, - Commands\CommandMakeCommand::class, - Commands\ComponentClassMakeCommand::class, - Commands\ComponentViewMakeCommand::class, - Commands\ControllerMakeCommand::class, - Commands\DisableCommand::class, - Commands\DumpCommand::class, - Commands\EnableCommand::class, - Commands\EventMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\InstallCommand::class, - Commands\JobMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, - Commands\ListCommand::class, - Commands\ListenerMakeCommand::class, - Commands\MailMakeCommand::class, - Commands\MiddlewareMakeCommand::class, - Commands\MigrateCommand::class, - Commands\MigrateFreshCommand::class, - Commands\MigrateRefreshCommand::class, - Commands\MigrateResetCommand::class, - Commands\MigrateRollbackCommand::class, - Commands\MigrateStatusCommand::class, - Commands\MigrationMakeCommand::class, - Commands\ModelMakeCommand::class, - Commands\ModelShowCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ObserverMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\PublishCommand::class, - Commands\PublishConfigurationCommand::class, - Commands\PublishMigrationCommand::class, - Commands\PublishTranslationCommand::class, - Commands\RequestMakeCommand::class, - Commands\ResourceMakeCommand::class, - Commands\RouteProviderMakeCommand::class, - Commands\RuleMakeCommand::class, - Commands\SeedCommand::class, - Commands\SeedMakeCommand::class, - Commands\SetupCommand::class, - Commands\TestMakeCommand::class, - Commands\UnUseCommand::class, - Commands\UpdateCommand::class, - Commands\UseCommand::class, - ], + 'commands' => ConsoleServiceProvider::defaultCommands() + ->merge([ + // + ]) + ->except([ + // + ])->toArray(), /* |-------------------------------------------------------------------------- diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 881a74af3..2e70b8d61 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -7,68 +7,72 @@ class ConsoleServiceProvider extends ServiceProvider { - /** - * The available commands - * @var array - */ - protected $commands = [ - Commands\ChannelMakeCommand::class, - Commands\CheckLangCommand::class, - Commands\CommandMakeCommand::class, - Commands\ComponentClassMakeCommand::class, - Commands\ComponentViewMakeCommand::class, - Commands\ControllerMakeCommand::class, - Commands\DisableCommand::class, - Commands\DumpCommand::class, - Commands\EnableCommand::class, - Commands\EventMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\InstallCommand::class, - Commands\JobMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, - Commands\ListCommand::class, - Commands\ListenerMakeCommand::class, - Commands\MailMakeCommand::class, - Commands\MiddlewareMakeCommand::class, - Commands\MigrateCommand::class, - Commands\MigrateFreshCommand::class, - Commands\MigrateRefreshCommand::class, - Commands\MigrateResetCommand::class, - Commands\MigrateRollbackCommand::class, - Commands\MigrateStatusCommand::class, - Commands\MigrationMakeCommand::class, - Commands\ModelMakeCommand::class, - Commands\ModelShowCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ObserverMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\PublishCommand::class, - Commands\PublishConfigurationCommand::class, - Commands\PublishMigrationCommand::class, - Commands\PublishTranslationCommand::class, - Commands\RequestMakeCommand::class, - Commands\ResourceMakeCommand::class, - Commands\RouteProviderMakeCommand::class, - Commands\RuleMakeCommand::class, - Commands\SeedCommand::class, - Commands\SeedMakeCommand::class, - Commands\SetupCommand::class, - Commands\TestMakeCommand::class, - Commands\UnUseCommand::class, - Commands\UpdateCommand::class, - Commands\UseCommand::class, - ]; - public function register(): void { - $this->commands(config('modules.commands', $this->commands)); + $this->commands(config('modules.commands', self::defaultCommands()->toArray())); } public function provides(): array { - return $this->commands; + return self::defaultCommands()->toArray(); + } + + /** + * Get the package default commands. + * + * @return \Illuminate\Support\Collection + */ + public static function defaultCommands(): \Illuminate\Support\Collection + { + return collect([ + Commands\ChannelMakeCommand::class, + Commands\CommandMakeCommand::class, + Commands\ControllerMakeCommand::class, + Commands\DisableCommand::class, + Commands\DumpCommand::class, + Commands\EnableCommand::class, + Commands\EventMakeCommand::class, + Commands\JobMakeCommand::class, + Commands\ListenerMakeCommand::class, + Commands\MailMakeCommand::class, + Commands\MiddlewareMakeCommand::class, + Commands\NotificationMakeCommand::class, + Commands\ProviderMakeCommand::class, + Commands\RouteProviderMakeCommand::class, + Commands\InstallCommand::class, + Commands\ListCommand::class, + Commands\ModuleDeleteCommand::class, + Commands\ModuleMakeCommand::class, + Commands\FactoryMakeCommand::class, + Commands\PolicyMakeCommand::class, + Commands\RequestMakeCommand::class, + Commands\RuleMakeCommand::class, + Commands\MigrateCommand::class, + Commands\MigrateRefreshCommand::class, + Commands\MigrateResetCommand::class, + Commands\MigrateFreshCommand::class, + Commands\MigrateRollbackCommand::class, + Commands\MigrateStatusCommand::class, + Commands\MigrationMakeCommand::class, + Commands\ModelMakeCommand::class, + Commands\ObserverMakeCommand::class, + Commands\ModelShowCommand::class, + Commands\PublishCommand::class, + Commands\PublishConfigurationCommand::class, + Commands\PublishMigrationCommand::class, + Commands\PublishTranslationCommand::class, + Commands\SeedCommand::class, + Commands\SeedMakeCommand::class, + Commands\SetupCommand::class, + Commands\UnUseCommand::class, + Commands\UpdateCommand::class, + Commands\UseCommand::class, + Commands\ResourceMakeCommand::class, + Commands\TestMakeCommand::class, + Commands\LaravelModulesV6Migrator::class, + Commands\ComponentClassMakeCommand::class, + Commands\ComponentViewMakeCommand::class, + Commands\CheckLangCommand::class, + ]); } } From 69cebb1ccfdb32ef25c44b09e024bb4174b89bd6 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Sat, 20 Jan 2024 02:24:21 +0330 Subject: [PATCH 126/422] [style] sort command list --- src/Providers/ConsoleServiceProvider.php | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 2e70b8d61..5e268b477 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -26,53 +26,53 @@ public static function defaultCommands(): \Illuminate\Support\Collection { return collect([ Commands\ChannelMakeCommand::class, + Commands\CheckLangCommand::class, Commands\CommandMakeCommand::class, + Commands\ComponentClassMakeCommand::class, + Commands\ComponentViewMakeCommand::class, Commands\ControllerMakeCommand::class, Commands\DisableCommand::class, Commands\DumpCommand::class, Commands\EnableCommand::class, Commands\EventMakeCommand::class, + Commands\FactoryMakeCommand::class, + Commands\InstallCommand::class, Commands\JobMakeCommand::class, + Commands\LaravelModulesV6Migrator::class, + Commands\ListCommand::class, Commands\ListenerMakeCommand::class, Commands\MailMakeCommand::class, Commands\MiddlewareMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\RouteProviderMakeCommand::class, - Commands\InstallCommand::class, - Commands\ListCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\RequestMakeCommand::class, - Commands\RuleMakeCommand::class, Commands\MigrateCommand::class, + Commands\MigrateFreshCommand::class, Commands\MigrateRefreshCommand::class, Commands\MigrateResetCommand::class, - Commands\MigrateFreshCommand::class, Commands\MigrateRollbackCommand::class, Commands\MigrateStatusCommand::class, Commands\MigrationMakeCommand::class, Commands\ModelMakeCommand::class, - Commands\ObserverMakeCommand::class, Commands\ModelShowCommand::class, + Commands\ModuleDeleteCommand::class, + Commands\ModuleMakeCommand::class, + Commands\NotificationMakeCommand::class, + Commands\ObserverMakeCommand::class, + Commands\PolicyMakeCommand::class, + Commands\ProviderMakeCommand::class, Commands\PublishCommand::class, Commands\PublishConfigurationCommand::class, Commands\PublishMigrationCommand::class, Commands\PublishTranslationCommand::class, + Commands\RequestMakeCommand::class, + Commands\ResourceMakeCommand::class, + Commands\RouteProviderMakeCommand::class, + Commands\RuleMakeCommand::class, Commands\SeedCommand::class, Commands\SeedMakeCommand::class, Commands\SetupCommand::class, + Commands\TestMakeCommand::class, Commands\UnUseCommand::class, Commands\UpdateCommand::class, Commands\UseCommand::class, - Commands\ResourceMakeCommand::class, - Commands\TestMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, - Commands\ComponentClassMakeCommand::class, - Commands\ComponentViewMakeCommand::class, - Commands\CheckLangCommand::class, ]); } } From 3507b8eb21452bfae11ffed7a868588ce839a408 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 21 Jan 2024 20:45:08 +0000 Subject: [PATCH 127/422] updated CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1a033660..ea02bad2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,13 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed +- [@alissn](https://github.com/alissn) Command Synchronization and Alphabetical Sorting in ConsoleServiceProvider - [@fpermana](https://github.com/fpermana) Update ObserverMakeCommand.php ## Fixed -- [@benjaminniess](https://github.com/benjaminniess) Fix ModelShowCommand extends property - [@alissn](https://github.com/alissn) revert extend class to ShowModelCommand +- [@benjaminniess](https://github.com/benjaminniess) Fix ModelShowCommand extends property ## 10.0.4 - 2023-11-13 From 95cad096288780db7273b0e2888bd81462d34cde Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Mon, 22 Jan 2024 00:19:39 +0330 Subject: [PATCH 128/422] [feat] delete except section --- config/config.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index c675de663..19e92bab8 100644 --- a/config/config.php +++ b/config/config.php @@ -149,10 +149,7 @@ */ 'commands' => ConsoleServiceProvider::defaultCommands() ->merge([ - // - ]) - ->except([ - // + // New commands go here ])->toArray(), /* From e9bffe1181562871c24cb5297cbf0771e0a0d6e5 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 21 Jan 2024 21:26:07 +0000 Subject: [PATCH 129/422] renamed comment --- config/config.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index 19e92bab8..ec5b3fb9f 100644 --- a/config/config.php +++ b/config/config.php @@ -143,8 +143,7 @@ |-------------------------------------------------------------------------- | | Here you can define which commands will be visible and used in your - | application. If for example, you don't use some of the commands provided - | you can add them to except section. and can add own command to merge section. + | application. You can add your own commands to merge section. | */ 'commands' => ConsoleServiceProvider::defaultCommands() From e92b96e7caf71b4b79e980c7b101ebe52870f07f Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 22 Jan 2024 01:17:13 +0000 Subject: [PATCH 130/422] Reverted to use App and Database namespaces --- config/config.php | 60 ++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/config/config.php b/config/config.php index ec5b3fb9f..a74d5aeff 100644 --- a/config/config.php +++ b/config/config.php @@ -98,42 +98,38 @@ | Generator path |-------------------------------------------------------------------------- | Customise the paths where the folders will be generated. - | Set the generate's key to false to not generate that folder + | Setting the generate key to false will not generate that folder */ 'generator' => [ 'config' => ['path' => 'config', 'generate' => true], - 'command' => ['path' => 'app/Console', 'generate' => false], - 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], - 'migration' => ['path' => 'database/migrations', 'generate' => true], - 'seeder' => [ - 'path' => 'database/seeders', - 'namespace' => 'database/seeders', - 'generate' => true, - ], - 'factory' => ['path' => 'database/factories', 'generate' => true], - 'model' => ['path' => 'app/Models', 'generate' => true], - 'observer' => ['path' => 'app/Observers', 'generate' => false], + 'command' => ['path' => 'App/Console', 'generate' => false], + 'channels' => ['path' => 'App/Broadcasting', 'generate' => false], + 'migration' => ['path' => 'Database/migrations', 'generate' => false], + 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], + 'factory' => ['path' => 'Database/Factories', 'generate' => false], + 'model' => ['path' => 'App/Models', 'generate' => false], + 'observer' => ['path' => 'App/Observers', 'generate' => false], 'routes' => ['path' => 'routes', 'generate' => true], - 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], - 'filter' => ['path' => 'app/Http/Middleware', 'generate' => true], - 'request' => ['path' => 'app/Http/Requests', 'generate' => true], - 'provider' => ['path' => 'app/Providers', 'generate' => true], - 'assets' => ['path' => 'resources/assets', 'generate' => true], - 'lang' => ['path' => 'lang', 'generate' => true], + 'controller' => ['path' => 'App/Http/Controllers', 'generate' => true], + 'filter' => ['path' => 'App/Http/Middleware', 'generate' => false], + 'request' => ['path' => 'App/Http/Requests', 'generate' => false], + 'provider' => ['path' => 'App/Providers', 'generate' => true], + 'assets' => ['path' => 'resources/assets', 'generate' => false], + 'lang' => ['path' => 'lang', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], - 'test' => ['path' => 'tests/Unit', 'generate' => true], - 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], - 'repository' => ['path' => 'app/Repositories', 'generate' => false], - 'event' => ['path' => 'app/Events', 'generate' => false], - 'listener' => ['path' => 'app/Listeners', 'generate' => false], - 'policies' => ['path' => 'app/Policies', 'generate' => false], - 'rules' => ['path' => 'app/Rules', 'generate' => false], - 'jobs' => ['path' => 'app/Jobs', 'generate' => false], - 'emails' => ['path' => 'app/Emails', 'generate' => false], - 'notifications' => ['path' => 'app/Notifications', 'generate' => false], - 'resource' => ['path' => 'app/Resources', 'generate' => false], + 'test' => ['path' => 'tests/Unit', 'generate' => false], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], + 'repository' => ['path' => 'App/Repositories', 'generate' => false], + 'event' => ['path' => 'App/Events', 'generate' => false], + 'listener' => ['path' => 'App/Listeners', 'generate' => false], + 'policies' => ['path' => 'App/Policies', 'generate' => false], + 'rules' => ['path' => 'App/Rules', 'generate' => false], + 'jobs' => ['path' => 'App/Jobs', 'generate' => false], + 'emails' => ['path' => 'App/Emails', 'generate' => false], + 'notifications' => ['path' => 'App/Notifications', 'generate' => false], + 'resource' => ['path' => 'App/resources', 'generate' => false], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], + 'component-class' => ['path' => 'App/View/Components', 'generate' => false], ], ], @@ -210,10 +206,6 @@ 'translations' => true, /** * load files on boot or register method - * - * Note: boot not compatible with asgardcms - * - * @example boot|register */ 'files' => 'register', ], From 3cf83d604c5ec346335c5fd1241c96822001abe9 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 22 Jan 2024 01:20:01 +0000 Subject: [PATCH 131/422] updated CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea02bad2b..ea74343e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,15 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 10.0.5 - 2024-01-22 + ## Added - [@azim-kordpour](https://github.com/azim-kordpour) Add PHPDoc static to all methods in Module facade ## Changed +- [@dcblogdev](https://github.com/dcblogdev) Reverted config to use `App` and `Database` namespace / folders by default - [@alissn](https://github.com/alissn) Command Synchronization and Alphabetical Sorting in ConsoleServiceProvider - [@fpermana](https://github.com/fpermana) Update ObserverMakeCommand.php From 99f22b2fcb8f3816ef5c9f1bfaac4fff31e6d9ab Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 23 Jan 2024 01:46:57 +0330 Subject: [PATCH 132/422] [feat] add command --- src/Commands/ModelPruneCommand.php | 119 +++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/Commands/ModelPruneCommand.php diff --git a/src/Commands/ModelPruneCommand.php b/src/Commands/ModelPruneCommand.php new file mode 100644 index 000000000..1e278acfa --- /dev/null +++ b/src/Commands/ModelPruneCommand.php @@ -0,0 +1,119 @@ +option('all')) { + $input->setArgument('module', [self::ALL]); + return; + } + + $selected_item = multiselect( + label : 'What Module want to check?', + options : [ + self::ALL, + ...array_keys(Module::all()), + ], + required: 'You must select at least one module', + ); + + $input->setArgument('module', + value: in_array(self::ALL, $selected_item) + ? [self::ALL] + : $selected_item + ); + } + + + /** + * Determine the models that should be pruned. + * + * @return Collection + */ + protected function models(): Collection + { + if (! empty($models = $this->option('model'))) { + return collect($models)->filter(function ($model) { + return class_exists($model); + })->values(); + } + + $except = $this->option('except'); + + if (! empty($models) && ! empty($except)) { + throw new InvalidArgumentException('The --models and --except options cannot be combined.'); + } + + if ($this->argument('module') == [self::ALL]) { + $path = sprintf('%s/*/%s', + config('modules.paths.modules'), + config('modules.paths.generator.model.path') + ); + } + else { + $path = sprintf('%s/{%s}/%s', + config('modules.paths.modules'), + collect($this->argument('module'))->implode(','), + config('modules.paths.generator.model.path')); + } + + return collect(Finder::create()->in($path)->files()->name('*.php')) + ->map(function ($model) { + + $namespace = config('modules.namespace'); + return $namespace . str_replace( + ['/', '.php'], + ['\\', ''], + Str::after($model->getRealPath(), realpath(config('modules.paths.modules'))) + ); + })->values() + ->when(! empty($except), function ($models) use ($except) { + return $models->reject(function ($model) use ($except) { + return in_array($model, $except); + }); + })->filter(function ($model) { + return class_exists($model); + })->filter(function ($model) { + return $this->isPrunable($model); + })->values(); + } + +} From 23c17516ebbbedd35cdab3df74923be059f0e55f Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 23 Jan 2024 01:47:32 +0330 Subject: [PATCH 133/422] [feat] add ModelPruneCommand to command list --- src/Providers/ConsoleServiceProvider.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 5e268b477..b3bb05ddb 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -2,6 +2,7 @@ namespace Nwidart\Modules\Providers; +use Illuminate\Support\Collection; use Illuminate\Support\ServiceProvider; use Nwidart\Modules\Commands; @@ -20,9 +21,9 @@ public function provides(): array /** * Get the package default commands. * - * @return \Illuminate\Support\Collection + * @return Collection */ - public static function defaultCommands(): \Illuminate\Support\Collection + public static function defaultCommands(): Collection { return collect([ Commands\ChannelMakeCommand::class, @@ -51,6 +52,7 @@ public static function defaultCommands(): \Illuminate\Support\Collection Commands\MigrateStatusCommand::class, Commands\MigrationMakeCommand::class, Commands\ModelMakeCommand::class, + Commands\ModelPruneCommand::class, Commands\ModelShowCommand::class, Commands\ModuleDeleteCommand::class, Commands\ModuleMakeCommand::class, From 99cbe59b009775282efc43fc55817f8bc3bf9fd3 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 23 Jan 2024 01:49:35 +0330 Subject: [PATCH 134/422] [feat] update laravel.framework version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 91c4c62a7..bf933e8b4 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "mockery/mockery": "^1.5", "orchestra/testbench": "^8.0", "friendsofphp/php-cs-fixer": "^3.6", - "laravel/framework": "^10.0", + "laravel/framework": "^10.41", "spatie/phpunit-snapshot-assertions": "^5.0", "phpstan/phpstan": "^1.4" }, From a6f2c8b53ae7945ef41d296735e963cee885ebde Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 28 Jan 2024 10:04:15 +0000 Subject: [PATCH 135/422] updated CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea74343e9..4ccfd2caf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 10.0.6 - 2024-01-28 + +## Added + +- [@alissn](https://github.com/alissn) Add command module prune + ## 10.0.5 - 2024-01-22 ## Added From fe7ec9bc3d72f3f06a23379574027a78274d2340 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Jan 2024 12:16:12 +0000 Subject: [PATCH 136/422] Update php.yml Upgraded checkout to use v4 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 14cb45832..9d6479e14 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -15,7 +15,7 @@ jobs: name: PHP ${{ matrix.php-versions }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@master From 6d27a5ecc18f74b5e71ecc8e3f15e6fb55d52174 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Jan 2024 23:50:40 +0000 Subject: [PATCH 137/422] updated event stub to include Dispatchable and InteractsWithSockets --- src/Commands/stubs/event.stub | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/event.stub b/src/Commands/stubs/event.stub index ff4ff0733..9a4f2bd5b 100644 --- a/src/Commands/stubs/event.stub +++ b/src/Commands/stubs/event.stub @@ -2,11 +2,17 @@ namespace $NAMESPACE$; +use Illuminate\Broadcasting\Channel; +use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; +use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; class $CLASS$ { - use SerializesModels; + use Dispatchable, InteractsWithSockets, SerializesModels; /** * Create a new event instance. @@ -21,6 +27,8 @@ class $CLASS$ */ public function broadcastOn(): array { - return []; + return [ + new PrivateChannel('channel-name'), + ]; } } From 8cb3d9f7c29ed4679eae4ef274a26d9282568358 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Jan 2024 23:52:18 +0000 Subject: [PATCH 138/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ccfd2caf..4b9e1293a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Updated + +- [@dcblogdev](https://github.com/dcblogdev) updated event stub to include Dispatchable and InteractsWithSockets traits + ## 10.0.6 - 2024-01-28 ## Added From b468eeb37649fc0f1f2a543bf64946e567635004 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Jan 2024 23:55:43 +0000 Subject: [PATCH 139/422] updated snapshots --- ...dTest__it_can_change_the_default_namespace__1.txt | 12 ++++++++++-- ..._can_change_the_default_namespace_specific__1.txt | 12 ++++++++++-- ...st__it_generated_correct_file_with_content__1.txt | 12 ++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt index 483cb1c60..7d9e697fe 100644 --- a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -2,11 +2,17 @@ namespace Modules\Blog\SuperEvents; +use Illuminate\Broadcasting\Channel; +use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; +use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; class PostWasCreated { - use SerializesModels; + use Dispatchable, InteractsWithSockets, SerializesModels; /** * Create a new event instance. @@ -21,6 +27,8 @@ class PostWasCreated */ public function broadcastOn(): array { - return []; + return [ + new PrivateChannel('channel-name'), + ]; } } diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 483cb1c60..7d9e697fe 100644 --- a/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -2,11 +2,17 @@ namespace Modules\Blog\SuperEvents; +use Illuminate\Broadcasting\Channel; +use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; +use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; class PostWasCreated { - use SerializesModels; + use Dispatchable, InteractsWithSockets, SerializesModels; /** * Create a new event instance. @@ -21,6 +27,8 @@ class PostWasCreated */ public function broadcastOn(): array { - return []; + return [ + new PrivateChannel('channel-name'), + ]; } } diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt index 5fbc3d908..d99431e28 100644 --- a/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -2,11 +2,17 @@ namespace Modules\Blog\Events; +use Illuminate\Broadcasting\Channel; +use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; +use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; class PostWasCreated { - use SerializesModels; + use Dispatchable, InteractsWithSockets, SerializesModels; /** * Create a new event instance. @@ -21,6 +27,8 @@ class PostWasCreated */ public function broadcastOn(): array { - return []; + return [ + new PrivateChannel('channel-name'), + ]; } } From 20800352dcddf2c050319e25d707a67735724db3 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 31 Jan 2024 00:05:38 +0000 Subject: [PATCH 140/422] renamed generated tests from to be Tests --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index a74d5aeff..91d7db647 100644 --- a/config/config.php +++ b/config/config.php @@ -117,8 +117,8 @@ 'assets' => ['path' => 'resources/assets', 'generate' => false], 'lang' => ['path' => 'lang', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], - 'test' => ['path' => 'tests/Unit', 'generate' => false], - 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], + 'test' => ['path' => 'Tests/Unit', 'generate' => false], + 'test-feature' => ['path' => 'Tests/Feature', 'generate' => false], 'repository' => ['path' => 'App/Repositories', 'generate' => false], 'event' => ['path' => 'App/Events', 'generate' => false], 'listener' => ['path' => 'App/Listeners', 'generate' => false], From 6c9f078494ba3ff099cecec0423241af5e484c22 Mon Sep 17 00:00:00 2001 From: DESMG-ShenLin <773933146@qq.com> Date: Thu, 1 Feb 2024 11:48:53 +0800 Subject: [PATCH 141/422] Fix for Symfony/Console vendor/symfony/console/Input/InputOption.php:85 --- src/Commands/TestMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/TestMakeCommand.php b/src/Commands/TestMakeCommand.php index 1093fb9d4..5d6d353fd 100644 --- a/src/Commands/TestMakeCommand.php +++ b/src/Commands/TestMakeCommand.php @@ -49,7 +49,7 @@ protected function getArguments() protected function getOptions() { return [ - ['feature', false, InputOption::VALUE_NONE, 'Create a feature test.'], + ['feature', null, InputOption::VALUE_NONE, 'Create a feature test.'], ]; } From d52b5023d2443d73430b9ee7a356054688c480cd Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Mon, 5 Feb 2024 23:24:31 +0330 Subject: [PATCH 142/422] [feat] implement BaseCommand class --- src/Commands/BaseCommand.php | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/Commands/BaseCommand.php diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php new file mode 100644 index 000000000..080937d3c --- /dev/null +++ b/src/Commands/BaseCommand.php @@ -0,0 +1,99 @@ +getDefinition()->addOption(new InputOption( + 'all', + 'a', + InputOption::VALUE_NONE, + 'Check all Modules', + )); + + $this->getDefinition()->addArgument(new InputArgument( + 'module', + InputArgument::IS_ARRAY, + 'The name of module will be used.', + )); + } + + abstract function executeAction($name); + + public function getInfo(): string|null + { + return NULL; + } + + /** + * Execute the console command. + */ + public function handle() + { + if (! is_null($info = $this->getInfo())) { + $this->components->info($info); + } + + $modules = (array) $this->argument('module'); + + foreach ($modules as $module) { + $this->executeAction($module); + } + } + + protected function promptForMissingArguments(InputInterface $input, OutputInterface $output): void + { + $modules = array_keys(Module::all()); + + if ($input->getOption('all')) { + $input->setArgument('module', $modules); + return; + } + + if (! empty($input->getArgument('module'))) { + return; + } + + $selected_item = multiselect( + label : 'What Module want to check?', + options : [ + self::ALL, + ...$modules, + ], + required: 'You must select at least one module', + ); + + $input->setArgument('module', + value: in_array(self::ALL, $selected_item) + ? $modules + : $selected_item + ); + } + + protected function getModuleModel($name) + { + return $name instanceof \Nwidart\Modules\Module + ? $name + : $this->laravel['modules']->findOrFail($name); + } + +} From b0336ce3f687b01fed14a9bbeda38f873967647c Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Mon, 5 Feb 2024 23:26:33 +0330 Subject: [PATCH 143/422] [refactor] refactor use command --- src/Commands/UseCommand.php | 38 ++++++++----------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/src/Commands/UseCommand.php b/src/Commands/UseCommand.php index 930129464..7df7faeb6 100644 --- a/src/Commands/UseCommand.php +++ b/src/Commands/UseCommand.php @@ -2,11 +2,7 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Illuminate\Support\Str; -use Symfony\Component\Console\Input\InputArgument; - -class UseCommand extends Command +class UseCommand extends BaseCommand { /** * The console command name. @@ -22,35 +18,17 @@ class UseCommand extends Command */ protected $description = 'Use the specified module.'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { - $module = Str::studly($this->argument('module')); - - if (!$this->laravel['modules']->has($module)) { - $this->error("Module [{$module}] does not exists."); - - return E_ERROR; - } + $module = $this->getModuleModel($name); - $this->laravel['modules']->setUsed($module); - - $this->info("Module [{$module}] used successfully."); - - return 0; + $this->components->task("Using {$module->getName()} module", function () use ($module) { + $this->laravel['modules']->setUsed($module); + }); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::REQUIRED, 'The name of module will be used.'], - ]; + return 'Using Module ...'; } } From 4359923077bbe5486e80fa05b157810fbb5ab4d5 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Mon, 5 Feb 2024 23:27:03 +0330 Subject: [PATCH 144/422] [refactor] refactor unuse command --- src/Commands/UnUseCommand.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Commands/UnUseCommand.php b/src/Commands/UnUseCommand.php index 185fe755e..c12012584 100644 --- a/src/Commands/UnUseCommand.php +++ b/src/Commands/UnUseCommand.php @@ -4,7 +4,7 @@ use Illuminate\Console\Command; -class UnUseCommand extends Command +class UnUseCommand extends BaseCommand { /** * The console command name. @@ -20,15 +20,17 @@ class UnUseCommand extends Command */ protected $description = 'Forget the used module with module:use'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { - $this->laravel['modules']->forgetUsed(); + $module = $this->getModuleModel($name); - $this->components->info('Previous module used successfully forgotten.'); + $this->components->task("Forget Using {$module->getName()} module", function () use ($module) { + $this->laravel['modules']->forgetUsed($module); + }); + } - return 0; + function getInfo(): string|null + { + return 'Forget Using Module ...'; } } From c42c567d7502dfe594696679648385fea5353551 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:09:34 +0330 Subject: [PATCH 145/422] [fix] use const --- src/Commands/BaseCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 080937d3c..f9ae06763 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -24,7 +24,7 @@ public function __construct() { parent::__construct(); $this->getDefinition()->addOption(new InputOption( - 'all', + strtolower(self::ALL), 'a', InputOption::VALUE_NONE, 'Check all Modules', @@ -64,7 +64,7 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf { $modules = array_keys(Module::all()); - if ($input->getOption('all')) { + if ($input->getOption(strtolower(self::ALL))) { $input->setArgument('module', $modules); return; } From cf6d1162fa900c45406f2a154701b796cf585932 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:19:36 +0330 Subject: [PATCH 146/422] [refactor] refactor update command --- src/Commands/UpdateCommand.php | 61 +++------------------------------- 1 file changed, 5 insertions(+), 56 deletions(-) diff --git a/src/Commands/UpdateCommand.php b/src/Commands/UpdateCommand.php index 7ecc312af..626691c52 100644 --- a/src/Commands/UpdateCommand.php +++ b/src/Commands/UpdateCommand.php @@ -2,15 +2,8 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; -use Nwidart\Modules\Traits\ModuleCommandTrait; -use Symfony\Component\Console\Input\InputArgument; - -class UpdateCommand extends Command +class UpdateCommand extends BaseCommand { - use ModuleCommandTrait; - /** * The console command name. * @@ -25,61 +18,17 @@ class UpdateCommand extends Command */ protected $description = 'Update dependencies for the specified module or for all modules.'; - /** - * Execute the console command. - */ - public function handle(): int - { - $this->components->info('Updating module ...'); - - if ($name = $this->argument('module')) { - $this->updateModule($name); - - return 0; - } - - $this->updateAllModule(); - - return 0; - } - - - protected function updateAllModule() - { - /** @var \Nwidart\Modules\Module $module */ - $modules = $this->laravel['modules']->getOrdered(); - - foreach ($modules as $module) { - $this->updateModule($module); - } - - } - - protected function updateModule($name) + public function executeAction($name): void { - - if ($name instanceof Module) { - $module = $name; - }else { - $module = $this->laravel['modules']->findOrFail($name); - } + $module = $this->getModuleModel($name); $this->components->task("Updating {$module->getName()} module", function () use ($module) { $this->laravel['modules']->update($module); }); - $this->laravel['modules']->update($name); - } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be updated.'], - ]; + return 'Updating Module ...'; } } From 59b61db1e59ab70d9db9e41555281890519adcf5 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:25:35 +0330 Subject: [PATCH 147/422] [feat] update color od module name --- src/Commands/UnUseCommand.php | 2 +- src/Commands/UpdateCommand.php | 2 +- src/Commands/UseCommand.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/UnUseCommand.php b/src/Commands/UnUseCommand.php index c12012584..874bec496 100644 --- a/src/Commands/UnUseCommand.php +++ b/src/Commands/UnUseCommand.php @@ -24,7 +24,7 @@ public function executeAction($name): void { $module = $this->getModuleModel($name); - $this->components->task("Forget Using {$module->getName()} module", function () use ($module) { + $this->components->task("Forget Using {$module->getName()} Module", function () use ($module) { $this->laravel['modules']->forgetUsed($module); }); } diff --git a/src/Commands/UpdateCommand.php b/src/Commands/UpdateCommand.php index 626691c52..fed527043 100644 --- a/src/Commands/UpdateCommand.php +++ b/src/Commands/UpdateCommand.php @@ -22,7 +22,7 @@ public function executeAction($name): void { $module = $this->getModuleModel($name); - $this->components->task("Updating {$module->getName()} module", function () use ($module) { + $this->components->task("Updating {$module->getName()} Module", function () use ($module) { $this->laravel['modules']->update($module); }); } diff --git a/src/Commands/UseCommand.php b/src/Commands/UseCommand.php index 7df7faeb6..0a3d66324 100644 --- a/src/Commands/UseCommand.php +++ b/src/Commands/UseCommand.php @@ -22,7 +22,7 @@ public function executeAction($name): void { $module = $this->getModuleModel($name); - $this->components->task("Using {$module->getName()} module", function () use ($module) { + $this->components->task("Using {$module->getName()} Module", function () use ($module) { $this->laravel['modules']->setUsed($module); }); } From afb250135bbaacead0d1ddc2887c273c88ff375c Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:28:38 +0330 Subject: [PATCH 148/422] [feat] update publish commands --- src/Commands/PublishCommand.php | 68 ++++--------------- src/Commands/PublishConfigurationCommand.php | 64 +++++------------- src/Commands/PublishMigrationCommand.php | 55 ++++----------- src/Commands/PublishTranslationCommand.php | 71 ++++---------------- 4 files changed, 52 insertions(+), 206 deletions(-) diff --git a/src/Commands/PublishCommand.php b/src/Commands/PublishCommand.php index c4944c8a2..505298a9b 100644 --- a/src/Commands/PublishCommand.php +++ b/src/Commands/PublishCommand.php @@ -2,12 +2,9 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; use Nwidart\Modules\Publishing\AssetPublisher; -use Symfony\Component\Console\Input\InputArgument; -class PublishCommand extends Command +class PublishCommand extends BaseCommand { /** * The console command name. @@ -23,64 +20,23 @@ class PublishCommand extends Command */ protected $description = 'Publish a module\'s assets to the application'; - /** - * Execute the console command. - */ - public function handle(): int - { - $this->components->info('Publishing module assets...'); - - if ($name = $this->argument('module')) { - $this->publish($name); - - return 0; - } - - $this->publishAll(); - - return 0; - } - - /** - * Publish assets from all modules. - */ - public function publishAll() - { - foreach ($this->laravel['modules']->allEnabled() as $module) { - $this->publish($module); - } - } - /** - * Publish assets from the specified module. - * - * @param string $name - */ - public function publish($name) + public function executeAction($name): void { - if ($name instanceof Module) { - $module = $name; - } else { - $module = $this->laravel['modules']->findOrFail($name); - } + $module = $this->getModuleModel($name); - with(new AssetPublisher($module)) - ->setRepository($this->laravel['modules']) - ->setConsole($this) - ->publish(); + $this->components->task("Publishing Assets {$module->getName()} Module", function () use ($module) { + with(new AssetPublisher($module)) + ->setRepository($this->laravel['modules']) + ->setConsole($this) + ->publish(); + }); - $this->components->task($module->getStudlyName(), fn()=>true); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; + return 'Publishing module asset files ...'; } + } diff --git a/src/Commands/PublishConfigurationCommand.php b/src/Commands/PublishConfigurationCommand.php index 7dcf99dc4..cc6476684 100644 --- a/src/Commands/PublishConfigurationCommand.php +++ b/src/Commands/PublishConfigurationCommand.php @@ -2,12 +2,10 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Illuminate\Support\Str; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class PublishConfigurationCommand extends Command +class PublishConfigurationCommand extends BaseCommand { /** * The console command name. @@ -23,68 +21,38 @@ class PublishConfigurationCommand extends Command */ protected $description = 'Publish a module\'s config files to the application'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { - $this->components->info('publishing module config files...'); - - if ($module = $this->argument('module')) { - $this->publishConfiguration($module); - - return 0; - } - - foreach ($this->laravel['modules']->allEnabled() as $module) { - $this->publishConfiguration($module->getName()); - } + $this->call('vendor:publish', [ + '--provider' => $this->getServiceProviderForModule($name), + '--force' => $this->option('force'), + '--tag' => ['config'], + ]); + } - return 0; + function getInfo(): string|null + { + return 'Publishing module config files ...'; } /** * @param string $module * @return string */ - private function getServiceProviderForModule($module) + private function getServiceProviderForModule($module): string { - $namespace = $this->laravel['config']->get('modules.namespace'); + $namespace = $this->laravel['config']->get('modules.namespace'); $studlyName = Str::studly($module); - $provider = $this->laravel['config']->get('modules.paths.generator.provider.path'); - $provider = str_replace('/', '\\', $provider); + $provider = $this->laravel['config']->get('modules.paths.generator.provider.path'); + $provider = str_replace('/', '\\', $provider); return "$namespace\\$studlyName\\$provider\\{$studlyName}ServiceProvider"; } - /** - * @param string $module - */ - private function publishConfiguration($module) - { - $this->call('vendor:publish', [ - '--provider' => $this->getServiceProviderForModule($module), - '--force' => $this->option('force'), - '--tag' => ['config'], - ]); - } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module being used.'], - ]; - } - /** * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['--force', '-f', InputOption::VALUE_NONE, 'Force the publishing of config files'], diff --git a/src/Commands/PublishMigrationCommand.php b/src/Commands/PublishMigrationCommand.php index 3b8472c36..3d657c3ae 100644 --- a/src/Commands/PublishMigrationCommand.php +++ b/src/Commands/PublishMigrationCommand.php @@ -5,9 +5,8 @@ use Illuminate\Console\Command; use Nwidart\Modules\Migrations\Migrator; use Nwidart\Modules\Publishing\MigrationPublisher; -use Symfony\Component\Console\Input\InputArgument; -class PublishMigrationCommand extends Command +class PublishMigrationCommand extends BaseCommand { /** * The console command name. @@ -23,50 +22,20 @@ class PublishMigrationCommand extends Command */ protected $description = "Publish a module's migrations to the application"; - /** - * Execute the console command. - */ - public function handle(): int - { - $this->components->info('publishing module migrations...'); - - if ($name = $this->argument('module')) { - $module = $this->laravel['modules']->findOrFail($name); - - $this->publish($module); - - return 0; - } - - foreach ($this->laravel['modules']->allEnabled() as $module) { - $this->publish($module); - } - - return 0; - } - - /** - * Publish migration for the specified module. - * - * @param \Nwidart\Modules\Module $module - */ - public function publish($module) + public function executeAction($name): void { - with(new MigrationPublisher(new Migrator($module, $this->getLaravel()))) - ->setRepository($this->laravel['modules']) - ->setConsole($this) - ->publish(); + $module = $this->getModuleModel($name); + + $this->components->task("Publishing Migration {$module->getName()} Module", function () use ($module) { + with(new MigrationPublisher(new Migrator($module, $this->getLaravel()))) + ->setRepository($this->laravel['modules']) + ->setConsole($this) + ->publish(); + }); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module being used.'], - ]; + return 'Publishing module migrations ...'; } } diff --git a/src/Commands/PublishTranslationCommand.php b/src/Commands/PublishTranslationCommand.php index 616fc92f0..a11b80062 100644 --- a/src/Commands/PublishTranslationCommand.php +++ b/src/Commands/PublishTranslationCommand.php @@ -2,12 +2,9 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; use Nwidart\Modules\Publishing\LangPublisher; -use Symfony\Component\Console\Input\InputArgument; -class PublishTranslationCommand extends Command +class PublishTranslationCommand extends BaseCommand { /** * The console command name. @@ -23,64 +20,20 @@ class PublishTranslationCommand extends Command */ protected $description = 'Publish a module\'s translations to the application'; - /** - * Execute the console command. - */ - public function handle(): int - { - $this->components->info('Publishing module translations...'); - - if ($name = $this->argument('module')) { - $this->publish($name); - - return 0; - } - - $this->publishAll(); - - return 0; - } - - /** - * Publish assets from all modules. - */ - public function publishAll() + public function executeAction($name): void { - foreach ($this->laravel['modules']->allEnabled() as $module) { - $this->publish($module); - } + $module = $this->getModuleModel($name); + + $this->components->task("Publishing Translations {$module->getName()} Module", function () use ($module) { + with(new LangPublisher($module)) + ->setRepository($this->laravel['modules']) + ->setConsole($this) + ->publish(); + }); } - /** - * Publish assets from the specified module. - * - * @param string $name - */ - public function publish($name) - { - if ($name instanceof Module) { - $module = $name; - } else { - $module = $this->laravel['modules']->findOrFail($name); - } - - with(new LangPublisher($module)) - ->setRepository($this->laravel['modules']) - ->setConsole($this) - ->publish(); - - $this->line("Published: {$module->getStudlyName()}"); - } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; + return 'Publishing module translations ...'; } } From 15b31bc6369abba72b1d5b3acba96d92390aac85 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:29:17 +0330 Subject: [PATCH 149/422] [refactor] refactor delete command --- src/Commands/ModuleDeleteCommand.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Commands/ModuleDeleteCommand.php b/src/Commands/ModuleDeleteCommand.php index 10864dcde..02ad0584d 100644 --- a/src/Commands/ModuleDeleteCommand.php +++ b/src/Commands/ModuleDeleteCommand.php @@ -2,27 +2,22 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Symfony\Component\Console\Input\InputArgument; - -class ModuleDeleteCommand extends Command +class ModuleDeleteCommand extends BaseCommand { - protected $name = 'module:delete'; + protected $name = 'module:delete'; protected $description = 'Delete a module from the application'; - public function handle(): int + public function executeAction($name): void { - $this->laravel['modules']->delete($this->argument('module')); - - $this->components->info("Module {$this->argument('module')} has been deleted."); - - return 0; + $module = $this->getModuleModel($name); + $this->components->task("Deleting {$module->getName()} Module", function () use ($module) { + $module->delete(); + }); } - protected function getArguments() + public function getInfo(): string|null { - return [ - ['module', InputArgument::REQUIRED, 'The name of module to delete.'], - ]; + return 'deleting module ...'; } + } From 40b560c5b36a35812c3eeed4cfdb655aeac30703 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:36:52 +0330 Subject: [PATCH 150/422] [refactor] refactor migration status command --- src/Commands/MigrateStatusCommand.php | 54 ++++----------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/src/Commands/MigrateStatusCommand.php b/src/Commands/MigrateStatusCommand.php index 43c61c558..b10a498f4 100644 --- a/src/Commands/MigrateStatusCommand.php +++ b/src/Commands/MigrateStatusCommand.php @@ -2,13 +2,10 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Nwidart\Modules\Migrations\Migrator; -use Nwidart\Modules\Module; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class MigrateStatusCommand extends Command +class MigrateStatusCommand extends BaseCommand { /** * The console command name. @@ -29,58 +26,21 @@ class MigrateStatusCommand extends Command */ protected $module; - /** - * Execute the console command. - * - * @return mixed - */ - public function handle(): int + public function executeAction($name): void { - $this->module = $this->laravel['modules']; - - $name = $this->argument('module'); - - if ($name) { - $module = $this->module->findOrFail($name); - - $this->migrateStatus($module); - - return 0; - } - - foreach ($this->module->getOrdered($this->option('direction')) as $module) { - $this->line('Running for module: ' . $module->getName() . ''); - $this->migrateStatus($module); - } - - return 0; - } + $module = $this->getModuleModel($name); - /** - * Run the migration from the specified module. - * - * @param Module $module - */ - protected function migrateStatus(Module $module) - { $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); $this->call('migrate:status', [ - '--path' => $path, + '--path' => $path, '--database' => $this->option('database'), ]); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + public function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; + return NULL; } /** @@ -92,7 +52,7 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], - ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ]; } } From 21b4bbe818e19e996dad1e6014148afa5e2aae20 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:37:49 +0330 Subject: [PATCH 151/422] [refactor] refactor migration rollback command --- src/Commands/MigrateRollbackCommand.php | 69 +++++-------------------- 1 file changed, 13 insertions(+), 56 deletions(-) diff --git a/src/Commands/MigrateRollbackCommand.php b/src/Commands/MigrateRollbackCommand.php index 3afc81147..6a9c863f3 100644 --- a/src/Commands/MigrateRollbackCommand.php +++ b/src/Commands/MigrateRollbackCommand.php @@ -5,10 +5,9 @@ use Illuminate\Console\Command; use Nwidart\Modules\Migrations\Migrator; use Nwidart\Modules\Traits\MigrationLoaderTrait; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class MigrateRollbackCommand extends Command +class MigrateRollbackCommand extends BaseCommand { use MigrationLoaderTrait; @@ -26,51 +25,15 @@ class MigrateRollbackCommand extends Command */ protected $description = 'Rollback the modules migrations.'; - /** - * @var \Nwidart\Modules\Contracts\RepositoryInterface - */ - protected $module; - - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { - $this->module = $this->laravel['modules']; - - $name = $this->argument('module'); - - if (!empty($name)) { - $this->rollback($name); - - return 0; - } - - foreach ($this->module->getOrdered($this->option('direction')) as $module) { - $this->line('Running for module: ' . $module->getName() . ''); - - $this->rollback($module); - } - - return 0; - } - - /** - * Rollback migration from the specified module. - * - * @param $module - */ - public function rollback($module) - { - if (is_string($module)) { - $module = $this->module->findOrFail($module); - } + $module = $this->getModuleModel($name); $migrator = new Migrator($module, $this->getLaravel(), $this->option('subpath')); $database = $this->option('database'); - if (!empty($database)) { + if (! empty($database)) { $migrator->setDatabase($database); } @@ -78,25 +41,19 @@ public function rollback($module) if (count($migrated)) { foreach ($migrated as $migration) { - $this->line("Rollback: {$migration}"); + $this->components->task("Rollback: {$migration}", ); } return; } - $this->comment('Nothing to rollback.'); + $this->components->warn("Nothing to rollback on module {$module->getName()}"); + } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + public function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; + return NULL; } /** @@ -108,10 +65,10 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'], - ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], - ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], - ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], - ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file'] + ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['pretend', NULL, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['subpath', NULL, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file'], ]; } } From 3ba79144b81a739adc8e83220d8f817b333ed005 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:38:15 +0330 Subject: [PATCH 152/422] [refactor] refactor migration reset command --- src/Commands/MigrateResetCommand.php | 65 ++++--------------------- src/Commands/MigrateRollbackCommand.php | 3 +- 2 files changed, 11 insertions(+), 57 deletions(-) diff --git a/src/Commands/MigrateResetCommand.php b/src/Commands/MigrateResetCommand.php index e468f1f0c..5a7210841 100644 --- a/src/Commands/MigrateResetCommand.php +++ b/src/Commands/MigrateResetCommand.php @@ -2,13 +2,11 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Nwidart\Modules\Migrations\Migrator; use Nwidart\Modules\Traits\MigrationLoaderTrait; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class MigrateResetCommand extends Command +class MigrateResetCommand extends BaseCommand { use MigrationLoaderTrait; @@ -26,51 +24,15 @@ class MigrateResetCommand extends Command */ protected $description = 'Reset the modules migrations.'; - /** - * @var \Nwidart\Modules\Contracts\RepositoryInterface - */ - protected $module; - - /** - * Execute the console command. - */ - public function handle(): int - { - $this->module = $this->laravel['modules']; - - $name = $this->argument('module'); - - if (!empty($name)) { - $this->reset($name); - - return 0; - } - - foreach ($this->module->getOrdered($this->option('direction')) as $module) { - $this->line('Running for module: ' . $module->getName() . ''); - - $this->reset($module); - } - - return 0; - } - - /** - * Rollback migration from the specified module. - * - * @param $module - */ - public function reset($module) + public function executeAction($name): void { - if (is_string($module)) { - $module = $this->module->findOrFail($module); - } + $module = $this->getModuleModel($name); $migrator = new Migrator($module, $this->getLaravel()); $database = $this->option('database'); - if (!empty($database)) { + if (! empty($database)) { $migrator->setDatabase($database); } @@ -84,19 +46,12 @@ public function reset($module) return; } - $this->comment('Nothing to rollback.'); + $this->components->warn("Nothing to rollback on module {$module->getName()}"); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + public function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; + return NULL; } /** @@ -108,9 +63,9 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'], - ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], - ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], - ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['pretend', NULL, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], ]; } } diff --git a/src/Commands/MigrateRollbackCommand.php b/src/Commands/MigrateRollbackCommand.php index 6a9c863f3..3456e76c9 100644 --- a/src/Commands/MigrateRollbackCommand.php +++ b/src/Commands/MigrateRollbackCommand.php @@ -2,7 +2,6 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Nwidart\Modules\Migrations\Migrator; use Nwidart\Modules\Traits\MigrationLoaderTrait; use Symfony\Component\Console\Input\InputOption; @@ -41,7 +40,7 @@ public function executeAction($name): void if (count($migrated)) { foreach ($migrated as $migration) { - $this->components->task("Rollback: {$migration}", ); + $this->components->task("Rollback: {$migration}",); } return; From a55e7035dede11b41d799f8a36174818693591a7 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:42:34 +0330 Subject: [PATCH 153/422] [style] update module name --- src/Commands/MigrateResetCommand.php | 2 +- src/Commands/MigrateRollbackCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/MigrateResetCommand.php b/src/Commands/MigrateResetCommand.php index 5a7210841..d87813cc1 100644 --- a/src/Commands/MigrateResetCommand.php +++ b/src/Commands/MigrateResetCommand.php @@ -46,7 +46,7 @@ public function executeAction($name): void return; } - $this->components->warn("Nothing to rollback on module {$module->getName()}"); + $this->components->warn("Nothing to rollback on module {$module->getName()}"); } public function getInfo(): string|null diff --git a/src/Commands/MigrateRollbackCommand.php b/src/Commands/MigrateRollbackCommand.php index 3456e76c9..978fa934c 100644 --- a/src/Commands/MigrateRollbackCommand.php +++ b/src/Commands/MigrateRollbackCommand.php @@ -46,7 +46,7 @@ public function executeAction($name): void return; } - $this->components->warn("Nothing to rollback on module {$module->getName()}"); + $this->components->warn("Nothing to rollback on module {$module->getName()}"); } From 69b5655a2cd98f8ce37d0f4bb37d2a3ae7103ecb Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 00:43:18 +0330 Subject: [PATCH 154/422] [refactor] refactor migrate command --- src/Commands/MigrateCommand.php | 93 ++++++++------------------------- 1 file changed, 23 insertions(+), 70 deletions(-) diff --git a/src/Commands/MigrateCommand.php b/src/Commands/MigrateCommand.php index d93b850db..7550c15e1 100644 --- a/src/Commands/MigrateCommand.php +++ b/src/Commands/MigrateCommand.php @@ -2,13 +2,10 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Nwidart\Modules\Migrations\Migrator; -use Nwidart\Modules\Module; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class MigrateCommand extends Command +class MigrateCommand extends BaseCommand { /** * The console command name. @@ -24,74 +21,30 @@ class MigrateCommand extends Command */ protected $description = 'Migrate the migrations from the specified module or from all modules.'; - /** - * @var \Nwidart\Modules\Contracts\RepositoryInterface - */ - protected $module; - /** - * Execute the console command. - * - * @return mixed - */ - public function handle(): int + public function executeAction($name): void { - $this->module = $this->laravel['modules']; - - $name = $this->argument('module'); - - if ($name) { - $module = $this->module->findOrFail($name); + $module = $this->getModuleModel($name); - $this->migrate($module); + $this->components->task("Running Migration {$module->getName()} Module", function () use ($module) { + $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); - return 0; - } + if ($this->option('subpath')) { + $path = $path . "/" . $this->option("subpath"); + } - foreach ($this->module->getOrdered($this->option('direction')) as $module) { - $this->line('Running for module: ' . $module->getName() . ''); + $this->call('migrate', [ + '--path' => $path, + '--database' => $this->option('database'), + '--pretend' => $this->option('pretend'), + '--force' => $this->option('force'), + ]); - $this->migrate($module); - } + if ($this->option('seed')) { + $this->call('module:seed', ['module' => $module->getName(), '--force' => $this->option('force')]); + } + }); - return 0; - } - - /** - * Run the migration from the specified module. - * - * @param Module $module - */ - protected function migrate(Module $module) - { - $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); - - if ($this->option('subpath')) { - $path = $path . "/" . $this->option("subpath"); - } - - $this->call('migrate', [ - '--path' => $path, - '--database' => $this->option('database'), - '--pretend' => $this->option('pretend'), - '--force' => $this->option('force'), - ]); - - if ($this->option('seed')) { - $this->call('module:seed', ['module' => $module->getName(), '--force' => $this->option('force')]); - } - } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; } /** @@ -103,11 +56,11 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], - ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], - ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], - ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], - ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], - ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath to run your migrations from'], + ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['pretend', NULL, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['seed', NULL, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], + ['subpath', NULL, InputOption::VALUE_OPTIONAL, 'Indicate a subpath to run your migrations from'], ]; } } From ee23471993065ea6149e203f976011227e50bee2 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 01:27:12 +0330 Subject: [PATCH 155/422] [refactor] refactor enable/disable command --- src/Commands/DisableCommand.php | 76 +++++---------------------------- src/Commands/EnableCommand.php | 76 +++++---------------------------- 2 files changed, 20 insertions(+), 132 deletions(-) diff --git a/src/Commands/DisableCommand.php b/src/Commands/DisableCommand.php index 70c37ec97..eb4cfe067 100644 --- a/src/Commands/DisableCommand.php +++ b/src/Commands/DisableCommand.php @@ -2,11 +2,7 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; -use Symfony\Component\Console\Input\InputArgument; - -class DisableCommand extends Command +class DisableCommand extends BaseCommand { /** * The console command name. @@ -29,73 +25,21 @@ class DisableCommand extends Command */ protected $description = 'Disable an array of modules.'; - /** - * Execute the console command. - */ - public function handle(): int - { - $this->components->info('Disabling module ...'); - - if (count($this->argument('module'))) { - foreach($this->argument('module') as $name) { - $this->disable($name); - } - return 0; - } - - $this->disableAll(); - - return 0; - } - - /** - * disableAll - * - * @return void - */ - public function disableAll() + public function executeAction($name): void { - /** @var Modules $modules */ - $modules = $this->laravel['modules']->all(); + $module = $this->getModuleModel($name); - foreach ($modules as $module) { - $this->disable($module); - } - } - - /** - * disable - * - * @param string $name - * @return void - */ - public function disable($name) - { - if ($name instanceof Module) { - $module = $name; - }else { - $module = $this->laravel['modules']->findOrFail($name); - } + $status = $module->isDisabled() + ? 'Disabled' + : 'Enabled'; - if ($module->isEnabled()) { + $this->components->task("Disabling {$module->getName()} Module, old status: $status", function () use ($module) { $module->disable(); - - $this->components->info("Module [{$module}] disabled successful."); - } else { - $this->components->warn("Module [{$module}] has already disabled."); - } - + }); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'Module name.'], - ]; + return 'Disabling module ...'; } } diff --git a/src/Commands/EnableCommand.php b/src/Commands/EnableCommand.php index 19a8a2d25..23d9570eb 100644 --- a/src/Commands/EnableCommand.php +++ b/src/Commands/EnableCommand.php @@ -2,11 +2,7 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; -use Symfony\Component\Console\Input\InputArgument; - -class EnableCommand extends Command +class EnableCommand extends BaseCommand { /** * The console command name. @@ -22,73 +18,21 @@ class EnableCommand extends Command */ protected $description = 'Enable the specified module.'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { + $module = $this->getModuleModel($name); - $this->components->info('Enabling module ...'); - - if ($name = $this->argument('module') ) { - $this->enable($name); - - return 0; - } - - $this->enableAll(); - - return 0; - } - - /** - * enableAll - * - * @return void - */ - public function enableAll() - { - /** @var Modules $modules */ - $modules = $this->laravel['modules']->all(); + $status = $module->isDisabled() + ? 'Disabled' + : 'Enabled'; - foreach ($modules as $module) { - $this->enable($module); - } - } - - /** - * enable - * - * @param string $name - * @return void - */ - public function enable($name) - { - if ($name instanceof Module) { - $module = $name; - }else { - $module = $this->laravel['modules']->findOrFail($name); - } - - if ($module->isDisabled()) { + $this->components->task("Enabling {$module->getName()} Module, old status: $status", function () use ($module) { $module->enable(); - - $this->components->info("Module [{$module}] enabled successful."); - }else { - $this->components->warn("Module [{$module}] has already enabled."); - } - + }); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'Module name.'], - ]; + return 'Enabling module ...'; } } From c6424e2a96d6baf841d5ad699ff00135ae8e1495 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 01:27:47 +0330 Subject: [PATCH 156/422] [fix] fix some changes --- src/Commands/BaseCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index f9ae06763..2a5f6ac6d 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -62,7 +62,7 @@ public function handle() protected function promptForMissingArguments(InputInterface $input, OutputInterface $output): void { - $modules = array_keys(Module::all()); + $modules = array_keys($this->laravel['modules']->all()); if ($input->getOption(strtolower(self::ALL))) { $input->setArgument('module', $modules); From f89abe4cc5c01d1c1ac1b22f0024976cf0de4fa6 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 01:33:14 +0330 Subject: [PATCH 157/422] [fix] fix bug module:disable,module:enabke --- src/Commands/DisableCommand.php | 2 +- src/Commands/EnableCommand.php | 76 ++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/src/Commands/DisableCommand.php b/src/Commands/DisableCommand.php index eb4cfe067..38dd1d6b5 100644 --- a/src/Commands/DisableCommand.php +++ b/src/Commands/DisableCommand.php @@ -16,7 +16,7 @@ class DisableCommand extends BaseCommand * * @var string */ - protected $signature = 'module:disable {module?*}'; + protected $signature = 'module:disable'; /** * The console command description. diff --git a/src/Commands/EnableCommand.php b/src/Commands/EnableCommand.php index 23d9570eb..19a8a2d25 100644 --- a/src/Commands/EnableCommand.php +++ b/src/Commands/EnableCommand.php @@ -2,7 +2,11 @@ namespace Nwidart\Modules\Commands; -class EnableCommand extends BaseCommand +use Illuminate\Console\Command; +use Nwidart\Modules\Module; +use Symfony\Component\Console\Input\InputArgument; + +class EnableCommand extends Command { /** * The console command name. @@ -18,21 +22,73 @@ class EnableCommand extends BaseCommand */ protected $description = 'Enable the specified module.'; - public function executeAction($name): void + /** + * Execute the console command. + */ + public function handle(): int { - $module = $this->getModuleModel($name); - $status = $module->isDisabled() - ? 'Disabled' - : 'Enabled'; + $this->components->info('Enabling module ...'); + + if ($name = $this->argument('module') ) { + $this->enable($name); + + return 0; + } + + $this->enableAll(); + + return 0; + } + + /** + * enableAll + * + * @return void + */ + public function enableAll() + { + /** @var Modules $modules */ + $modules = $this->laravel['modules']->all(); - $this->components->task("Enabling {$module->getName()} Module, old status: $status", function () use ($module) { + foreach ($modules as $module) { + $this->enable($module); + } + } + + /** + * enable + * + * @param string $name + * @return void + */ + public function enable($name) + { + if ($name instanceof Module) { + $module = $name; + }else { + $module = $this->laravel['modules']->findOrFail($name); + } + + if ($module->isDisabled()) { $module->enable(); - }); + + $this->components->info("Module [{$module}] enabled successful."); + }else { + $this->components->warn("Module [{$module}] has already enabled."); + } + } - function getInfo(): string|null + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() { - return 'Enabling module ...'; + return [ + ['module', InputArgument::OPTIONAL, 'Module name.'], + ]; } } From f1f3cd19aabd3b826010641abcffb4fda99fdea5 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 01:38:23 +0330 Subject: [PATCH 158/422] [fix] fix test --- tests/Commands/DisableCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Commands/DisableCommandTest.php b/tests/Commands/DisableCommandTest.php index 50f6b0865..840055c8b 100644 --- a/tests/Commands/DisableCommandTest.php +++ b/tests/Commands/DisableCommandTest.php @@ -63,7 +63,7 @@ public function it_disables_all_modules() $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); $taxonomyModule->enable(); - $code = $this->artisan('module:disable'); + $code = $this->artisan('module:disable',['--all' => true]); $this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled()); $this->assertSame(0, $code); From eb033c77df14057a92492be89ce7b9b50c58f4aa Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 22:24:42 +0330 Subject: [PATCH 159/422] [refactor] refactor Dump composer command --- src/Commands/DumpCommand.php | 61 ++++-------------------------------- 1 file changed, 6 insertions(+), 55 deletions(-) diff --git a/src/Commands/DumpCommand.php b/src/Commands/DumpCommand.php index b9665ee57..0f31aa2a8 100644 --- a/src/Commands/DumpCommand.php +++ b/src/Commands/DumpCommand.php @@ -2,11 +2,7 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; -use Symfony\Component\Console\Input\InputArgument; - -class DumpCommand extends Command +class DumpCommand extends BaseCommand { /** * The console command name. @@ -22,64 +18,19 @@ class DumpCommand extends Command */ protected $description = 'Dump-autoload the specified module or for all module.'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { - $this->components->info('Generating optimized autoload modules.'); - - if ($name = $this->argument('module') ) { - $this->dump($name); - - return 0; - } - - $this->dumpAll(); + $module = $this->getModuleModel($name); - return 0; - } - - /** - * dumpAll - * - * @return void - */ - public function dumpAll() - { - /** @var Modules $modules */ - $modules = $this->laravel['modules']->all(); - - foreach ($modules as $module) { - $this->dump($module); - } - } - - public function dump($name) - { - if ($name instanceof Module) { - $module = $name; - } else { - $module = $this->laravel['modules']->findOrFail($name); - } - - $this->components->task("$module", function () use ($module) { + $this->components->task("Generating for {$module->getName()} Module", function () use ($module) { chdir($module->getPath()); passthru('composer dump -o -n -q'); }); - } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'Module name.'], - ]; + return 'Generating optimized autoload modules'; } } From 24c02ac0e00779de0f0bae5a52ecae5eb8c6c1ac Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 22:24:58 +0330 Subject: [PATCH 160/422] [refactor] refactor enable command --- src/Commands/EnableCommand.php | 76 +++++----------------------------- 1 file changed, 10 insertions(+), 66 deletions(-) diff --git a/src/Commands/EnableCommand.php b/src/Commands/EnableCommand.php index 19a8a2d25..9beac5569 100644 --- a/src/Commands/EnableCommand.php +++ b/src/Commands/EnableCommand.php @@ -2,11 +2,7 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Module; -use Symfony\Component\Console\Input\InputArgument; - -class EnableCommand extends Command +class EnableCommand extends BaseCommand { /** * The console command name. @@ -22,73 +18,21 @@ class EnableCommand extends Command */ protected $description = 'Enable the specified module.'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { + $module = $this->getModuleModel($name); - $this->components->info('Enabling module ...'); - - if ($name = $this->argument('module') ) { - $this->enable($name); - - return 0; - } - - $this->enableAll(); - - return 0; - } - - /** - * enableAll - * - * @return void - */ - public function enableAll() - { - /** @var Modules $modules */ - $modules = $this->laravel['modules']->all(); + $status = $module->isDisabled() + ? 'Disabled' + : 'Enabled'; - foreach ($modules as $module) { - $this->enable($module); - } - } - - /** - * enable - * - * @param string $name - * @return void - */ - public function enable($name) - { - if ($name instanceof Module) { - $module = $name; - }else { - $module = $this->laravel['modules']->findOrFail($name); - } - - if ($module->isDisabled()) { + $this->components->task("Enabling {$module->getName()} Module, old status: $status", function () use ($module) { $module->enable(); - - $this->components->info("Module [{$module}] enabled successful."); - }else { - $this->components->warn("Module [{$module}] has already enabled."); - } - + }); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'Module name.'], - ]; + return 'Disabling module ...'; } } From 8c901a5c0ebbef501627f5bff187934de4fcebb2 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 22:32:45 +0330 Subject: [PATCH 161/422] [refactor] refactor check lang command --- src/Commands/CheckLangCommand.php | 78 ++++++------------------------- 1 file changed, 14 insertions(+), 64 deletions(-) diff --git a/src/Commands/CheckLangCommand.php b/src/Commands/CheckLangCommand.php index 83e355555..6cd606bb8 100644 --- a/src/Commands/CheckLangCommand.php +++ b/src/Commands/CheckLangCommand.php @@ -2,11 +2,9 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; use Illuminate\Support\Collection; -use Symfony\Component\Console\Input\InputArgument; -class CheckLangCommand extends Command +class CheckLangCommand extends baseCommand { private $langPath; @@ -25,58 +23,16 @@ class CheckLangCommand extends Command */ protected $description = 'Check missing language keys in the specified module.'; - - /** - * Execute the console command. - */ - public function handle(): int + public function __construct() { + parent::__construct(); $this->langPath = DIRECTORY_SEPARATOR . config('modules.paths.generator.lang.path', 'Resources/lang'); - - $this->components->alert('Checking languages ...'); - - $this->newLine(); - - if ($name = $this->argument('module')) { - $this->check($name); - - return 0; - } - - $this->checkAll(); - - return 0; - } - /** - * enableAll - * - * @return void - */ - public function checkAll() + public function executeAction($name): void { - $modules = $this->laravel['modules']->all(); - - foreach ($modules as $module) { - $this->check($module); - } - } - - /** - * enable - * - * @param string $name - * @return void - */ - public function check($name) - { - if ($name instanceof Module) { - $module = $name; - } else { - $module = $this->laravel['modules']->findOrFail($name); - } + $module = $this->getModuleModel($name); $directories = $this->getDirectories($module); @@ -90,16 +46,9 @@ public function check($name) } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() + function getInfo(): string|null { - return [ - ['module', InputArgument::OPTIONAL, 'Module name.'], - ]; + return 'Checking languages ...'; } private function getLangFiles($module) @@ -133,12 +82,12 @@ private function getDirectories($module) if (count($directories) == 0) { $this->components->info("No language files found in module $moduleName"); - return false; + return FALSE; } if (count($directories) == 1) { $this->components->warn("Only one language file found in module $moduleName"); - return false; + return FALSE; } return collect($directories); @@ -194,7 +143,7 @@ private function checkMissingKeys(Collection $directories) $uniqeLangFiles->each(function ($file) use ($directory, $langDirectories, &$missingKeysMessage) { $langKeys = $this->getLangKeys($directory['path'] . DIRECTORY_SEPARATOR . $file); - if ($langKeys == false) { + if ($langKeys == FALSE) { return; } @@ -206,7 +155,7 @@ private function checkMissingKeys(Collection $directories) $otherLangKeys = $this->getLangKeys($basePath . DIRECTORY_SEPARATOR . $file); - if ($otherLangKeys == false) { + if ($otherLangKeys == FALSE) { return; } @@ -244,8 +193,9 @@ private function getLangKeys($file) if (\File::exists($file)) { $lang = \File::getRequire($file); return collect(\Arr::dot($lang))->keys(); - } else { - return false; + } + else { + return FALSE; } } } From 3cb4e2ffdb02e41ed5c8b57f6baa797af67b2621 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 22:58:47 +0330 Subject: [PATCH 162/422] [refactor] refactor seed command --- src/Commands/SeedCommand.php | 66 ++++++++++++++---------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/src/Commands/SeedCommand.php b/src/Commands/SeedCommand.php index 960c2a9ff..b2eca44b3 100644 --- a/src/Commands/SeedCommand.php +++ b/src/Commands/SeedCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands; use ErrorException; -use Illuminate\Console\Command; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Support\Str; use Nwidart\Modules\Contracts\RepositoryInterface; @@ -14,7 +13,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class SeedCommand extends Command +class SeedCommand extends BaseCommand { use ModuleCommandTrait; @@ -32,34 +31,33 @@ class SeedCommand extends Command */ protected $description = 'Run database seeder from the specified module or from all modules.'; - /** - * Execute the console command. - */ - public function handle(): int + public function executeAction($name): void { - try { - if ($name = $this->argument('module')) { - $name = Str::studly($name); - $this->moduleSeed($this->getModuleByName($name)); - } else { - $modules = $this->getModuleRepository()->getOrdered(); - array_walk($modules, [$this, 'moduleSeed']); - $this->info('All modules seeded.'); + $module = $this->getModuleModel($name); + + $this->components->task("Seeding {$module->getName()} Module", function () use ($module) { + try { + $this->moduleSeed($module); } - } catch (\Error $e) { - $e = new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e); - $this->reportException($e); - $this->renderException($this->getOutput(), $e); + catch (\Error $e) { + $e = new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e); + $this->reportException($e); + $this->renderException($this->getOutput(), $e); - return E_ERROR; - } catch (\Exception $e) { - $this->reportException($e); - $this->renderException($this->getOutput(), $e); + return FALSE; + } + catch (\Exception $e) { + $this->reportException($e); + $this->renderException($this->getOutput(), $e); - return E_ERROR; - } + return FALSE; + } + }); + } - return 0; + function getInfo(): string|null + { + return 'Seeding module ...'; } /** @@ -218,18 +216,6 @@ protected function reportException(\Exception $e) $this->laravel[ExceptionHandler::class]->report($e); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; - } - /** * Get the console command options. * @@ -238,9 +224,9 @@ protected function getArguments() protected function getOptions() { return [ - ['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], - ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'], - ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['class', NULL, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], + ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'], + ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ]; } } From 019fbd9d27d31258a6d10311274195f651db454e Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 23:00:10 +0330 Subject: [PATCH 163/422] [refactor] refactor module:migrate-refresh command --- src/Commands/MigrateRefreshCommand.php | 77 +++++++------------------- 1 file changed, 20 insertions(+), 57 deletions(-) diff --git a/src/Commands/MigrateRefreshCommand.php b/src/Commands/MigrateRefreshCommand.php index c52365f9f..f1f4f3ed0 100644 --- a/src/Commands/MigrateRefreshCommand.php +++ b/src/Commands/MigrateRefreshCommand.php @@ -2,15 +2,10 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Console\Command; -use Nwidart\Modules\Traits\ModuleCommandTrait; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -class MigrateRefreshCommand extends Command +class MigrateRefreshCommand extends BaseCommand { - use ModuleCommandTrait; - /** * The console command name. * @@ -25,50 +20,31 @@ class MigrateRefreshCommand extends Command */ protected $description = 'Rollback & re-migrate the modules migrations.'; - /** - * Execute the console command. - */ - public function handle(): int - { - $module = $this->argument('module'); - - if ($module && !$this->getModuleName()) { - $this->error("Module [$module] does not exists."); - - return E_ERROR; - } - $this->call('module:migrate-reset', [ - 'module' => $this->getModuleName(), - '--database' => $this->option('database'), - '--force' => $this->option('force'), - ]); + public function executeAction($name): void + { + $module = $this->getModuleModel($name); - $this->call('module:migrate', [ - 'module' => $this->getModuleName(), - '--database' => $this->option('database'), - '--force' => $this->option('force'), - ]); + $this->components->task("Refreshing Migration {$module->getName()} module", function () use ($module) { + $this->call('module:migrate-reset', [ + 'module' => $module->getStudlyName(), + '--database' => $this->option('database'), + '--force' => $this->option('force'), + ]); - if ($this->option('seed')) { - $this->call('module:seed', [ - 'module' => $this->getModuleName(), + $this->call('module:migrate', [ + 'module' => $module->getStudlyName(), + '--database' => $this->option('database'), + '--force' => $this->option('force'), ]); - } - return 0; - } + if ($this->option('seed')) { + $this->call('module:seed', [ + 'module' => $module->getStudlyName(), + ]); + } + }); - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; } /** @@ -84,17 +60,4 @@ protected function getOptions() ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], ]; } - - public function getModuleName() - { - $module = $this->argument('module'); - - if (!$module) { - return null; - } - - $module = app('modules')->find($module); - - return $module ? $module->getStudlyName() : null; - } } From f470dd5a0cff2af30269ef9be913b1c06c2a896e Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 23:06:25 +0330 Subject: [PATCH 164/422] [fix] fix extend class --- src/Commands/CheckLangCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/CheckLangCommand.php b/src/Commands/CheckLangCommand.php index 6cd606bb8..6766a0283 100644 --- a/src/Commands/CheckLangCommand.php +++ b/src/Commands/CheckLangCommand.php @@ -4,7 +4,7 @@ use Illuminate\Support\Collection; -class CheckLangCommand extends baseCommand +class CheckLangCommand extends BaseCommand { private $langPath; From c71a6b04654904e33ed1e22d84dd9f5e4c1a6f12 Mon Sep 17 00:00:00 2001 From: Ali-SSN Date: Tue, 6 Feb 2024 23:09:54 +0330 Subject: [PATCH 165/422] [fix] fix enable test --- tests/Commands/EnableCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Commands/EnableCommandTest.php b/tests/Commands/EnableCommandTest.php index 7d6e39354..516b0371f 100644 --- a/tests/Commands/EnableCommandTest.php +++ b/tests/Commands/EnableCommandTest.php @@ -46,7 +46,7 @@ public function it_enables_all_modules() $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); $taxonomyModule->disable(); - $code = $this->artisan('module:enable'); + $code = $this->artisan('module:enable', ['--all' => true]); $this->assertTrue($blogModule->isEnabled() && $taxonomyModule->isEnabled()); $this->assertSame(0, $code); From 8718595715a098a5a165f6670d8db0a003f34bf3 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Wed, 7 Feb 2024 20:30:56 -0800 Subject: [PATCH 166/422] Update resource.stub Bind incoming requests with Illuminate\Http\Request --- src/Commands/stubs/resource.stub | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/stubs/resource.stub b/src/Commands/stubs/resource.stub index 3ba4b154d..82040e5e6 100644 --- a/src/Commands/stubs/resource.stub +++ b/src/Commands/stubs/resource.stub @@ -2,6 +2,7 @@ namespace $NAMESPACE$; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class $CLASS$ extends JsonResource @@ -9,7 +10,7 @@ class $CLASS$ extends JsonResource /** * Transform the resource into an array. */ - public function toArray($request): array + public function toArray(Request $request): array { return parent::toArray($request); } From 924bdddd5796b7f10ed3405dffa1c096c9ad9258 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Wed, 7 Feb 2024 20:58:50 -0800 Subject: [PATCH 167/422] Update resource-collection.stub --- src/Commands/stubs/resource-collection.stub | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/stubs/resource-collection.stub b/src/Commands/stubs/resource-collection.stub index 0bb408aee..26a405976 100644 --- a/src/Commands/stubs/resource-collection.stub +++ b/src/Commands/stubs/resource-collection.stub @@ -2,6 +2,7 @@ namespace $NAMESPACE$; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\ResourceCollection; class $CLASS$ extends ResourceCollection @@ -9,7 +10,7 @@ class $CLASS$ extends ResourceCollection /** * Transform the resource collection into an array. */ - public function toArray($request): array + public function toArray(Request $request): array { return parent::toArray($request); } From 418450ba6a76f4c9a5335ce75a7295993e78617b Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 12 Feb 2024 01:03:01 +0000 Subject: [PATCH 168/422] updated snapshots --- ...MakeCommandTest__it_can_change_the_default_namespace__1.txt | 3 ++- ...ndTest__it_can_change_the_default_namespace_specific__1.txt | 3 ++- ...andTest__it_can_generate_a_collection_resource_class__1.txt | 3 ++- ...eCommandTest__it_generated_correct_file_with_content__1.txt | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt index 33d6bd67b..874504dd5 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -2,6 +2,7 @@ namespace Modules\Blog\Http\Resources; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\ResourceCollection; class PostsTransformer extends ResourceCollection @@ -9,7 +10,7 @@ class PostsTransformer extends ResourceCollection /** * Transform the resource collection into an array. */ - public function toArray($request): array + public function toArray(Request $request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 33d6bd67b..874504dd5 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -2,6 +2,7 @@ namespace Modules\Blog\Http\Resources; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\ResourceCollection; class PostsTransformer extends ResourceCollection @@ -9,7 +10,7 @@ class PostsTransformer extends ResourceCollection /** * Transform the resource collection into an array. */ - public function toArray($request): array + public function toArray(Request $request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt index 32e3cef3c..27112f9f1 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt @@ -2,6 +2,7 @@ namespace Modules\Blog\Transformers; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\ResourceCollection; class PostsTransformer extends ResourceCollection @@ -9,7 +10,7 @@ class PostsTransformer extends ResourceCollection /** * Transform the resource collection into an array. */ - public function toArray($request): array + public function toArray(Request $request): array { return parent::toArray($request); } diff --git a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt index a61859f33..84f81f252 100644 --- a/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -2,6 +2,7 @@ namespace Modules\Blog\Transformers; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class PostsTransformer extends JsonResource @@ -9,7 +10,7 @@ class PostsTransformer extends JsonResource /** * Transform the resource into an array. */ - public function toArray($request): array + public function toArray(Request $request): array { return parent::toArray($request); } From f1952f3c0f4872fa5034fce64673ec5562489a5e Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 13 Feb 2024 22:53:23 +0000 Subject: [PATCH 169/422] updated snapshots --- CHANGELOG.md | 2 ++ src/Commands/stubs/vite.stub | 4 ++-- .../ModuleMakeCommandTest__it_generates_vite_file__1.txt | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b9e1293a..de9f4080f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Updated +- [@dcblogdev](https://github.com/dcblogdev) updated vite to rename placeholder with module name +- [@alissn](https://github.com/alissn) Updated commands to use Laravel Prompt - [@dcblogdev](https://github.com/dcblogdev) updated event stub to include Dispatchable and InteractsWithSockets traits ## 10.0.6 - 2024-01-28 diff --git a/src/Commands/stubs/vite.stub b/src/Commands/stubs/vite.stub index 314ef8101..bcc5e20e0 100644 --- a/src/Commands/stubs/vite.stub +++ b/src/Commands/stubs/vite.stub @@ -21,6 +21,6 @@ export default defineConfig({ }); //export const paths = [ -// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', -// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', +// 'Modules/$LOWER_NAME$/resources/assets/sass/app.scss', +// 'Modules/$LOWER_NAME$/resources/assets/js/app.js', //]; \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt index ef986a50e..dc2b5ef50 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt @@ -21,6 +21,6 @@ export default defineConfig({ }); //export const paths = [ -// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', -// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', +// 'Modules/blog/resources/assets/sass/app.scss', +// 'Modules/blog/resources/assets/js/app.js', //]; \ No newline at end of file From 0f6fa6c6d3ea0531631d7386dada9574b788214d Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 14 Feb 2024 01:38:26 +0000 Subject: [PATCH 170/422] updated snapshots and vite placeholder --- config/config.php | 2 +- src/Commands/stubs/vite.stub | 4 ++-- .../ModuleMakeCommandTest__it_generates_vite_file__1.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/config.php b/config/config.php index 91d7db647..8d01e4ffb 100644 --- a/config/config.php +++ b/config/config.php @@ -43,7 +43,7 @@ 'replacements' => [ 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME'], - 'vite' => ['LOWER_NAME'], + 'vite' => ['LOWER_NAME', 'STUDLY_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], 'views/index' => ['LOWER_NAME'], 'views/master' => ['LOWER_NAME', 'STUDLY_NAME'], diff --git a/src/Commands/stubs/vite.stub b/src/Commands/stubs/vite.stub index bcc5e20e0..314ef8101 100644 --- a/src/Commands/stubs/vite.stub +++ b/src/Commands/stubs/vite.stub @@ -21,6 +21,6 @@ export default defineConfig({ }); //export const paths = [ -// 'Modules/$LOWER_NAME$/resources/assets/sass/app.scss', -// 'Modules/$LOWER_NAME$/resources/assets/js/app.js', +// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', +// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', //]; \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt index dc2b5ef50..72d694d39 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt @@ -21,6 +21,6 @@ export default defineConfig({ }); //export const paths = [ -// 'Modules/blog/resources/assets/sass/app.scss', -// 'Modules/blog/resources/assets/js/app.js', +// 'Modules/Blog/resources/assets/sass/app.scss', +// 'Modules/Blog/resources/assets/js/app.js', //]; \ No newline at end of file From 91cbebae29763d07a8e0256285edfe72a92ee2c4 Mon Sep 17 00:00:00 2001 From: Dominic Hock Date: Thu, 29 Feb 2024 22:43:16 +0100 Subject: [PATCH 171/422] fix: #1752 Additionally fixes the hardcoded path to "Resources/lang" --- src/Commands/CheckLangCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/CheckLangCommand.php b/src/Commands/CheckLangCommand.php index 6766a0283..01afbc39c 100644 --- a/src/Commands/CheckLangCommand.php +++ b/src/Commands/CheckLangCommand.php @@ -65,7 +65,8 @@ private function getLangFiles($module) private function getDirectories($module) { $moduleName = $module->getStudlyName(); - $path = $module->getPath() . '/Resources/lang'; + $path = $module->getPath() . $this->langPath; + $directories = []; if (is_dir($path)) { $directories = $this->laravel['files']->directories($path); $directories = array_map(function ($directory) use ($moduleName) { From 8f145fa1b85a7e4102f3fc113c80c63437c65304 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 7 Mar 2024 12:28:32 +0330 Subject: [PATCH 172/422] [fix] fix factory and seeder folder name --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index 8d01e4ffb..21ddc3acc 100644 --- a/config/config.php +++ b/config/config.php @@ -105,8 +105,8 @@ 'command' => ['path' => 'App/Console', 'generate' => false], 'channels' => ['path' => 'App/Broadcasting', 'generate' => false], 'migration' => ['path' => 'Database/migrations', 'generate' => false], - 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], - 'factory' => ['path' => 'Database/Factories', 'generate' => false], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'generate' => false], 'model' => ['path' => 'App/Models', 'generate' => false], 'observer' => ['path' => 'App/Observers', 'generate' => false], 'routes' => ['path' => 'routes', 'generate' => true], From e5b671c6cb77cd2b00cf5836b6434f8f4633e4fe Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 7 Mar 2024 12:45:07 +0330 Subject: [PATCH 173/422] [fix] enable create folder of migration on make new module --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 8d01e4ffb..2d4e52617 100644 --- a/config/config.php +++ b/config/config.php @@ -104,7 +104,7 @@ 'config' => ['path' => 'config', 'generate' => true], 'command' => ['path' => 'App/Console', 'generate' => false], 'channels' => ['path' => 'App/Broadcasting', 'generate' => false], - 'migration' => ['path' => 'Database/migrations', 'generate' => false], + 'migration' => ['path' => 'Database/migrations', 'generate' => true], 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], 'factory' => ['path' => 'Database/Factories', 'generate' => false], 'model' => ['path' => 'App/Models', 'generate' => false], From cba0ebb676dc6150bc211f4c079b7ffb09ae7940 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 7 Mar 2024 12:28:32 +0330 Subject: [PATCH 174/422] [fix] fix factory and seeder folder name --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index 8d01e4ffb..21ddc3acc 100644 --- a/config/config.php +++ b/config/config.php @@ -105,8 +105,8 @@ 'command' => ['path' => 'App/Console', 'generate' => false], 'channels' => ['path' => 'App/Broadcasting', 'generate' => false], 'migration' => ['path' => 'Database/migrations', 'generate' => false], - 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], - 'factory' => ['path' => 'Database/Factories', 'generate' => false], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'generate' => false], 'model' => ['path' => 'App/Models', 'generate' => false], 'observer' => ['path' => 'App/Observers', 'generate' => false], 'routes' => ['path' => 'routes', 'generate' => true], From 6df3feaa2dac1f4ca12cac4c908856842d4564d9 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 02:54:45 +0330 Subject: [PATCH 175/422] [style] sort generator config --- config/config.php | 60 +++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/config/config.php b/config/config.php index 21ddc3acc..28d774e5a 100644 --- a/config/config.php +++ b/config/config.php @@ -101,35 +101,49 @@ | Setting the generate key to false will not generate that folder */ 'generator' => [ + // app folder + 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], + 'command' => ['path' => 'app/Console', 'generate' => false], + 'emails' => ['path' => 'app/Emails', 'generate' => false], + 'event' => ['path' => 'app/Events', 'generate' => false], + 'jobs' => ['path' => 'app/Jobs', 'generate' => false], + 'listener' => ['path' => 'app/Listeners', 'generate' => false], + 'model' => ['path' => 'app/Models', 'generate' => false], + 'notifications' => ['path' => 'app/Notifications', 'generate' => false], + 'observer' => ['path' => 'app/Observers', 'generate' => false], + 'policies' => ['path' => 'app/Policies', 'generate' => false], + 'provider' => ['path' => 'app/Providers', 'generate' => true], + 'repository' => ['path' => 'app/Repositories', 'generate' => false], + 'resource' => ['path' => 'app/resources', 'generate' => false], + 'rules' => ['path' => 'app/Rules', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], + // app/HTTP folder + 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], + 'filter' => ['path' => 'app/Http/Middleware', 'generate' => false], + 'request' => ['path' => 'app/Http/Requests', 'generate' => false], + + // config Folder 'config' => ['path' => 'config', 'generate' => true], - 'command' => ['path' => 'App/Console', 'generate' => false], - 'channels' => ['path' => 'App/Broadcasting', 'generate' => false], - 'migration' => ['path' => 'Database/migrations', 'generate' => false], + + // Database + 'migration' => ['path' => 'database/migrations', 'generate' => false], 'seeder' => ['path' => 'database/seeders', 'generate' => true], 'factory' => ['path' => 'database/factories', 'generate' => false], - 'model' => ['path' => 'App/Models', 'generate' => false], - 'observer' => ['path' => 'App/Observers', 'generate' => false], - 'routes' => ['path' => 'routes', 'generate' => true], - 'controller' => ['path' => 'App/Http/Controllers', 'generate' => true], - 'filter' => ['path' => 'App/Http/Middleware', 'generate' => false], - 'request' => ['path' => 'App/Http/Requests', 'generate' => false], - 'provider' => ['path' => 'App/Providers', 'generate' => true], - 'assets' => ['path' => 'resources/assets', 'generate' => false], + + // lang Folder 'lang' => ['path' => 'lang', 'generate' => false], + + // Resource Folder + 'assets' => ['path' => 'resources/assets', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], - 'test' => ['path' => 'Tests/Unit', 'generate' => false], - 'test-feature' => ['path' => 'Tests/Feature', 'generate' => false], - 'repository' => ['path' => 'App/Repositories', 'generate' => false], - 'event' => ['path' => 'App/Events', 'generate' => false], - 'listener' => ['path' => 'App/Listeners', 'generate' => false], - 'policies' => ['path' => 'App/Policies', 'generate' => false], - 'rules' => ['path' => 'App/Rules', 'generate' => false], - 'jobs' => ['path' => 'App/Jobs', 'generate' => false], - 'emails' => ['path' => 'App/Emails', 'generate' => false], - 'notifications' => ['path' => 'App/Notifications', 'generate' => false], - 'resource' => ['path' => 'App/resources', 'generate' => false], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], - 'component-class' => ['path' => 'App/View/Components', 'generate' => false], + + // Route Folder + 'routes' => ['path' => 'routes', 'generate' => true], + + // Test Folder + 'test-unit' => ['path' => 'Tests/Unit', 'generate' => false], + 'test-feature' => ['path' => 'Tests/Feature', 'generate' => false], ], ], From 951cd4a7dd0d02607e22d46a9d4d4da2afd151a3 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 02:58:57 +0330 Subject: [PATCH 176/422] [fix] fix migration folder name --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 21ddc3acc..7d10a44f5 100644 --- a/config/config.php +++ b/config/config.php @@ -104,7 +104,7 @@ 'config' => ['path' => 'config', 'generate' => true], 'command' => ['path' => 'App/Console', 'generate' => false], 'channels' => ['path' => 'App/Broadcasting', 'generate' => false], - 'migration' => ['path' => 'Database/migrations', 'generate' => false], + 'migration' => ['path' => 'database/migrations', 'generate' => false], 'seeder' => ['path' => 'database/seeders', 'generate' => true], 'factory' => ['path' => 'database/factories', 'generate' => false], 'model' => ['path' => 'App/Models', 'generate' => false], From 5f2512fa0bad0c4f58ba0e766e81fd16572f6783 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 03:01:37 +0330 Subject: [PATCH 177/422] [fix] fix autoload of app folder in composer stub --- src/Commands/stubs/composer.stub | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Commands/stubs/composer.stub b/src/Commands/stubs/composer.stub index 7d75c4215..d1500a22e 100644 --- a/src/Commands/stubs/composer.stub +++ b/src/Commands/stubs/composer.stub @@ -17,8 +17,7 @@ }, "autoload": { "psr-4": { - "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "", - "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\App\\": "app/", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "app/", "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Factories\\": "database/factories/", "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Seeders\\": "database/seeders/" } From f4976dbf57f0e5ba783ef56925d61c0f57909c9a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 03:07:32 +0330 Subject: [PATCH 178/422] [fix] fix folder name of test to lower case --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index 28d774e5a..cace62895 100644 --- a/config/config.php +++ b/config/config.php @@ -142,8 +142,8 @@ 'routes' => ['path' => 'routes', 'generate' => true], // Test Folder - 'test-unit' => ['path' => 'Tests/Unit', 'generate' => false], - 'test-feature' => ['path' => 'Tests/Feature', 'generate' => false], + 'test-unit' => ['path' => 'tests/Unit', 'generate' => false], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], ], ], From 79d08e140248379a16b63e53a1859ada0da50d22 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 03:09:07 +0330 Subject: [PATCH 179/422] [fix] fix test directory name on generator config --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index 8d01e4ffb..42e120145 100644 --- a/config/config.php +++ b/config/config.php @@ -117,8 +117,8 @@ 'assets' => ['path' => 'resources/assets', 'generate' => false], 'lang' => ['path' => 'lang', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], - 'test' => ['path' => 'Tests/Unit', 'generate' => false], - 'test-feature' => ['path' => 'Tests/Feature', 'generate' => false], + 'test' => ['path' => 'tests/Unit', 'generate' => false], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], 'repository' => ['path' => 'App/Repositories', 'generate' => false], 'event' => ['path' => 'App/Events', 'generate' => false], 'listener' => ['path' => 'App/Listeners', 'generate' => false], From 3e24984f1b06ff8a476e7becd2f1d408e7e09383 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 03:18:04 +0330 Subject: [PATCH 180/422] [feat] add package wikimedia/composer-merge-plugin --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf933e8b4..c2012548d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ ], "require": { "php": ">=8.1", - "ext-json": "*" + "ext-json": "*", + "wikimedia/composer-merge-plugin": "^2.1" }, "require-dev": { "phpunit/phpunit": "^10.0", @@ -57,6 +58,11 @@ "dev-master": "10.0-dev" } }, + "config": { + "allow-plugins": { + "wikimedia/composer-merge-plugin": true + } + }, "scripts": { "update-snapshots": "./vendor/bin/phpunit --no-coverage -d --update-snapshots", "test": "vendor/bin/phpunit", From 6ca7d120f29343cfd12594403b33ed13ce29bf1c Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 03:22:15 +0330 Subject: [PATCH 181/422] [fix] fix namespace of view components --- src/Commands/stubs/scaffold/provider.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 526c5bd28..484368f84 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -88,7 +88,7 @@ class $CLASS$ extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'),'app/')); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From 77e90340f8f1046669df218ef29670765c028fab Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 23:23:54 +0330 Subject: [PATCH 182/422] [feat] add app_folder config key --- config/config.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config/config.php b/config/config.php index cace62895..4d95c76ed 100644 --- a/config/config.php +++ b/config/config.php @@ -93,6 +93,17 @@ */ 'migration' => base_path('database/migrations'), + + /* + |-------------------------------------------------------------------------- + | The app path + |-------------------------------------------------------------------------- + | + | app folder name + | for example can change it to 'src' or 'App' + */ + 'app_folder' => 'app/', + /* |-------------------------------------------------------------------------- | Generator path From ac72ab24bae612c76f6ab71602f7f51fcc2f99d3 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 23:25:59 +0330 Subject: [PATCH 183/422] [feat] update namespace generation without app folder --- src/Commands/ControllerMakeCommand.php | 5 ++-- src/Commands/ProviderMakeCommand.php | 29 +++++++++++------------ src/Commands/RouteProviderMakeCommand.php | 5 ++-- src/Commands/stubs/scaffold/provider.stub | 2 +- src/Generators/ModuleGenerator.php | 2 +- src/Support/Config/GeneratorPath.php | 10 ++++---- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/Commands/ControllerMakeCommand.php b/src/Commands/ControllerMakeCommand.php index 4c1126bb8..48c2acf63 100644 --- a/src/Commands/ControllerMakeCommand.php +++ b/src/Commands/ControllerMakeCommand.php @@ -117,9 +117,8 @@ private function getControllerNameWithoutNamespace() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.controller.namespace') ?: $module->config('paths.generator.controller.path', 'Http/Controllers'); + return config('modules.paths.generator.controller.namespace' ) + ?? ltrim(config('modules.paths.generator.controller.path','Http/Controllers'),config('modules.paths.app_folder')); } /** diff --git a/src/Commands/ProviderMakeCommand.php b/src/Commands/ProviderMakeCommand.php index ee2dc117e..31ff47cf3 100644 --- a/src/Commands/ProviderMakeCommand.php +++ b/src/Commands/ProviderMakeCommand.php @@ -37,9 +37,8 @@ class ProviderMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.provider.namespace') ?: $module->config('paths.generator.provider.path', 'Providers'); + return config('modules.paths.generator.provider.namespace') + ?? ltrim(config('modules.paths.generator.provider.path', 'Providers'), config('modules.paths.app_folder', '')); } /** @@ -78,18 +77,18 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/' . $stub . '.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), - 'LOWER_NAME' => $module->getLowerName(), - 'MODULE' => $this->getModuleName(), - 'NAME' => $this->getFileName(), - 'STUDLY_NAME' => $module->getStudlyName(), - 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), - 'PATH_VIEWS' => GenerateConfigReader::read('views')->getPath(), - 'PATH_LANG' => GenerateConfigReader::read('lang')->getPath(), - 'PATH_CONFIG' => GenerateConfigReader::read('config')->getPath(), - 'MIGRATIONS_PATH' => GenerateConfigReader::read('migration')->getPath(), - 'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + 'LOWER_NAME' => $module->getLowerName(), + 'MODULE' => $this->getModuleName(), + 'NAME' => $this->getFileName(), + 'STUDLY_NAME' => $module->getStudlyName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), + 'PATH_VIEWS' => GenerateConfigReader::read('views')->getPath(), + 'PATH_LANG' => GenerateConfigReader::read('lang')->getPath(), + 'PATH_CONFIG' => GenerateConfigReader::read('config')->getPath(), + 'MIGRATIONS_PATH' => GenerateConfigReader::read('migration')->getPath(), + 'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(), ]))->render(); } diff --git a/src/Commands/RouteProviderMakeCommand.php b/src/Commands/RouteProviderMakeCommand.php index eef489320..fa03d51c1 100644 --- a/src/Commands/RouteProviderMakeCommand.php +++ b/src/Commands/RouteProviderMakeCommand.php @@ -108,9 +108,8 @@ protected function getApiRoutesPath() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.provider.namespace') ?: $module->config('paths.generator.provider.path', 'Providers'); + return config('modules.paths.generator.provider.namespace' ) + ?? ltrim(config('modules.paths.generator.provider.path','Providers'),config('modules.paths.app_folder','')); } /** diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 484368f84..790f93982 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -88,7 +88,7 @@ class $CLASS$ extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'),'app/')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 0c3f31c45..e15a08ccc 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -572,7 +572,7 @@ protected function getModuleNamespaceReplacement() */ private function getControllerNamespaceReplacement(): string { - return str_replace('/', '\\', $this->module->config('paths.generator.controller.namespace') ?: $this->module->config('paths.generator.controller.path', 'Controller')); + return str_replace('/', '\\', $this->module->config('paths.generator.controller.namespace') ?: ltrim($this->module->config('paths.generator.controller.path', 'Controller'),config('modules.paths.app_folder'))); } /** diff --git a/src/Support/Config/GeneratorPath.php b/src/Support/Config/GeneratorPath.php index ad78970db..385bf2c01 100644 --- a/src/Support/Config/GeneratorPath.php +++ b/src/Support/Config/GeneratorPath.php @@ -11,14 +11,14 @@ class GeneratorPath public function __construct($config) { if (is_array($config)) { - $this->path = $config['path']; - $this->generate = $config['generate']; + $this->path = $config['path']; + $this->generate = $config['generate']; $this->namespace = $config['namespace'] ?? $this->convertPathToNamespace($config['path']); return; } - $this->path = $config; - $this->generate = (bool) $config; + $this->path = $config; + $this->generate = (bool) $config; $this->namespace = $config; } @@ -39,6 +39,6 @@ public function getNamespace() private function convertPathToNamespace($path) { - return str_replace('/', '\\', $path); + return str_replace('/', '\\', ltrim($path, config('modules.paths.app_folder', ''))); } } From f3fc552c7e3af5383c1345dda7855905335ab8a0 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 23:26:27 +0330 Subject: [PATCH 184/422] [feat] run dump-autoload command after create new module --- src/Commands/ModuleMakeCommand.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Commands/ModuleMakeCommand.php b/src/Commands/ModuleMakeCommand.php index 3ead04ae6..b87bbb1b8 100644 --- a/src/Commands/ModuleMakeCommand.php +++ b/src/Commands/ModuleMakeCommand.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules\Commands; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Process; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Generators\ModuleGenerator; use Symfony\Component\Console\Input\InputArgument; @@ -50,6 +51,11 @@ public function handle(): int } } + // to discover new service providers + Process::path(base_path()) + ->command('composer dump-autoload') + ->run(); + return $success ? 0 : E_ERROR; } From 5029cb462c9f91b893a72c670eb127ef53199223 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 8 Mar 2024 23:36:00 +0330 Subject: [PATCH 185/422] [test] update snapshots --- ...eCommandTest__it_generates_api_module_with_resources__1.txt | 2 +- ...eCommandTest__it_generates_correct_composerjson_file__1.txt | 3 +-- ...est__it_generates_module_namespace_using_studly_case__1.txt | 2 +- ...ModuleMakeCommandTest__it_generates_module_resources__1.txt | 2 +- ...eCommandTest__it_generates_web_module_with_resources__1.txt | 2 +- ...dule_with_resources_when_adding_more_than_one_option__1.txt | 2 +- ...ndTest__it_generes_module_with_new_provider_location__2.txt | 3 +-- ...MakeCommandTest__it_can_change_the_default_namespace__1.txt | 2 +- ...ndTest__it_can_change_the_default_namespace_specific__1.txt | 2 +- ...t_can_have_custom_migration_resources_location_paths__1.txt | 2 +- ...ates_a_master_service_provider_with_resource_loading__1.txt | 2 +- 11 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index 7e1237a88..10814f6ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt index c54049e1a..746cae739 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt @@ -17,8 +17,7 @@ }, "autoload": { "psr-4": { - "Modules\\Blog\\": "", - "Modules\\Blog\\App\\": "app/", + "Modules\\Blog\\": "app/", "Modules\\Blog\\Database\\Factories\\": "database/factories/", "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index 6e6f69083..d901e5384 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -88,7 +88,7 @@ class ModuleNameServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index 7e1237a88..10814f6ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index 7e1237a88..10814f6ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 7e1237a88..10814f6ab 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt index c54049e1a..746cae739 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt @@ -17,8 +17,7 @@ }, "autoload": { "psr-4": { - "Modules\\Blog\\": "", - "Modules\\Blog\\App\\": "app/", + "Modules\\Blog\\": "app/", "Modules\\Blog\\Database\\Factories\\": "database/factories/", "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 290b4e978..1933ca368 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 290b4e978..1933ca368 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index cd1eb65f1..6e083d923 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index 7e1237a88..10814f6ab 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From 1b752290d3bb6594880bba343ccbd65985d5948a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 9 Mar 2024 22:54:32 +0330 Subject: [PATCH 186/422] [fix] fix method 'getDefaultNamespace' on make commands --- src/Commands/ChannelMakeCommand.php | 5 ++--- src/Commands/CommandMakeCommand.php | 5 ++--- src/Commands/ComponentClassMakeCommand.php | 5 ++--- src/Commands/EventMakeCommand.php | 5 ++--- src/Commands/FactoryMakeCommand.php | 11 +++++------ src/Commands/JobMakeCommand.php | 5 ++--- src/Commands/ListenerMakeCommand.php | 5 ++--- src/Commands/MailMakeCommand.php | 5 ++--- src/Commands/MiddlewareMakeCommand.php | 5 ++--- src/Commands/ModelMakeCommand.php | 5 ++--- src/Commands/NotificationMakeCommand.php | 5 ++--- src/Commands/ObserverMakeCommand.php | 7 +++---- src/Commands/PolicyMakeCommand.php | 5 ++--- src/Commands/RequestMakeCommand.php | 5 ++--- src/Commands/ResourceMakeCommand.php | 5 ++--- src/Commands/RuleMakeCommand.php | 5 ++--- src/Commands/SeedMakeCommand.php | 5 ++--- src/Commands/TestMakeCommand.php | 5 +++++ 18 files changed, 43 insertions(+), 55 deletions(-) diff --git a/src/Commands/ChannelMakeCommand.php b/src/Commands/ChannelMakeCommand.php index a4c5e6485..0514e6eec 100644 --- a/src/Commands/ChannelMakeCommand.php +++ b/src/Commands/ChannelMakeCommand.php @@ -30,9 +30,8 @@ final class ChannelMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.channels.namespace') ?: $module->config('paths.generator.channels.path', 'Broadcasting'); + return config('modules.paths.generator.channels.namespace') + ?? ltrim(config('modules.paths.generator.channels.path', 'Broadcasting'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/CommandMakeCommand.php b/src/Commands/CommandMakeCommand.php index 8470c9a84..5ccdbbc80 100644 --- a/src/Commands/CommandMakeCommand.php +++ b/src/Commands/CommandMakeCommand.php @@ -36,9 +36,8 @@ class CommandMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.command.namespace') ?: $module->config('paths.generator.command.path', 'Console'); + return config('modules.paths.generator.command.namespace') + ?? ltrim(config('modules.paths.generator.command.path', 'Console'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ComponentClassMakeCommand.php b/src/Commands/ComponentClassMakeCommand.php index 1cac7e6b1..ab949cf8f 100644 --- a/src/Commands/ComponentClassMakeCommand.php +++ b/src/Commands/ComponentClassMakeCommand.php @@ -54,9 +54,8 @@ protected function writeComponentViewTemplate() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.component-class.namespace') ?: $module->config('paths.generator.component-class.path', 'View/Component'); + return config('modules.paths.generator.component-class.namespace') + ?? ltrim(config('modules.paths.generator.component-class.path', 'View/Component'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/EventMakeCommand.php b/src/Commands/EventMakeCommand.php index d16fe6168..cfad73758 100644 --- a/src/Commands/EventMakeCommand.php +++ b/src/Commands/EventMakeCommand.php @@ -57,9 +57,8 @@ protected function getFileName() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.event.namespace') ?: $module->config('paths.generator.event.path', 'Events'); + return config('modules.paths.generator.event.namespace') + ?? ltrim(config('modules.paths.generator.event.path', 'Events'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/FactoryMakeCommand.php b/src/Commands/FactoryMakeCommand.php index 20809f678..555e81a59 100644 --- a/src/Commands/FactoryMakeCommand.php +++ b/src/Commands/FactoryMakeCommand.php @@ -54,8 +54,8 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/factory.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'NAME' => $this->getModelName(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'NAME' => $this->getModelName(), 'MODEL_NAMESPACE' => $this->getModelNamespace(), ]))->render(); } @@ -95,9 +95,8 @@ private function getModelName() */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.factory.namespace') ?: $module->config('paths.generator.factory.path'); + return config('modules.paths.generator.factory.namespace') + ?? ltrim(config('modules.paths.generator.factory.path', 'Database/Factories'), config('modules.paths.app_folder', '')); } /** @@ -107,7 +106,7 @@ public function getDefaultNamespace(): string */ public function getModelNamespace(): string { - $path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities'); + $path = ltrim(config('modules.paths.generator.model.path', 'Entities'), config('modules.paths.app_folder', '')); $path = str_replace('/', '\\', $path); diff --git a/src/Commands/JobMakeCommand.php b/src/Commands/JobMakeCommand.php index 434eb72e3..993c07d0a 100644 --- a/src/Commands/JobMakeCommand.php +++ b/src/Commands/JobMakeCommand.php @@ -31,9 +31,8 @@ class JobMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.jobs.namespace') ?: $module->config('paths.generator.jobs.path', 'Jobs'); + return config('modules.paths.generator.jobs.namespace') + ?? ltrim(config('modules.paths.generator.jobs.path', 'Jobs'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ListenerMakeCommand.php b/src/Commands/ListenerMakeCommand.php index 4002f4db3..972053c30 100644 --- a/src/Commands/ListenerMakeCommand.php +++ b/src/Commands/ListenerMakeCommand.php @@ -70,9 +70,8 @@ protected function getTemplateContents() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.listener.namespace') ?: $module->config('paths.generator.listener.path', 'Listeners'); + return config('modules.paths.generator.listener.namespace') + ?? ltrim(config('modules.paths.generator.listener.path', 'Listeners'), config('modules.paths.app_folder', '')); } protected function getEventName(Module $module) diff --git a/src/Commands/MailMakeCommand.php b/src/Commands/MailMakeCommand.php index d10b1c033..8c08c0598 100644 --- a/src/Commands/MailMakeCommand.php +++ b/src/Commands/MailMakeCommand.php @@ -30,9 +30,8 @@ class MailMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.emails.namespace') ?: $module->config('paths.generator.emails.path', 'Emails'); + return config('modules.paths.generator.emails.namespace') + ?? ltrim(config('modules.paths.generator.emails.path', 'Emails'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/MiddlewareMakeCommand.php b/src/Commands/MiddlewareMakeCommand.php index 7298fcc92..d9283b2ef 100644 --- a/src/Commands/MiddlewareMakeCommand.php +++ b/src/Commands/MiddlewareMakeCommand.php @@ -35,9 +35,8 @@ class MiddlewareMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.filter.namespace') ?: $module->config('paths.generator.filter.path', 'Http/Middleware'); + return config('modules.paths.generator.filter.namespace') + ?? ltrim(config('modules.paths.generator.filter.path', 'Http/Middleware'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ModelMakeCommand.php b/src/Commands/ModelMakeCommand.php index d6da06327..c063ea67b 100644 --- a/src/Commands/ModelMakeCommand.php +++ b/src/Commands/ModelMakeCommand.php @@ -238,8 +238,7 @@ private function getFillable() */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.model.namespace') ?: $module->config('paths.generator.model.path', 'Entities'); + return config('modules.paths.generator.model.namespace') + ?? ltrim(config('modules.paths.generator.model.path', 'Models'), config('modules.paths.app_folder', '')); } } diff --git a/src/Commands/NotificationMakeCommand.php b/src/Commands/NotificationMakeCommand.php index 72cec53d1..9069fcd79 100644 --- a/src/Commands/NotificationMakeCommand.php +++ b/src/Commands/NotificationMakeCommand.php @@ -30,9 +30,8 @@ final class NotificationMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.notifications.namespace') ?: $module->config('paths.generator.notifications.path', 'Notifications'); + return config('modules.paths.generator.notifications.namespace') + ?? ltrim(config('modules.paths.generator.notifications.path', 'Notifications'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ObserverMakeCommand.php b/src/Commands/ObserverMakeCommand.php index 5b756c2ff..aec1382b5 100644 --- a/src/Commands/ObserverMakeCommand.php +++ b/src/Commands/ObserverMakeCommand.php @@ -120,7 +120,7 @@ public function handle(): int return 0; } - + /** * Get default namespace. * @@ -128,8 +128,7 @@ public function handle(): int */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.observer.namespace') ?: $module->config('paths.generator.observer.path', 'Observers'); + return config('modules.paths.generator.observer.namespace') + ?? ltrim(config('modules.paths.generator.observer.path', 'Observers'), config('modules.paths.app_folder', '')); } } diff --git a/src/Commands/PolicyMakeCommand.php b/src/Commands/PolicyMakeCommand.php index 1ed55cb42..4932d9024 100644 --- a/src/Commands/PolicyMakeCommand.php +++ b/src/Commands/PolicyMakeCommand.php @@ -35,9 +35,8 @@ class PolicyMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.policies.namespace') ?: $module->config('paths.generator.policies.path', 'Policies'); + return config('modules.paths.generator.policies.namespace') + ?? ltrim(config('modules.paths.generator.policies.path', 'Policies'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/RequestMakeCommand.php b/src/Commands/RequestMakeCommand.php index c20882650..2dd0c6e5e 100644 --- a/src/Commands/RequestMakeCommand.php +++ b/src/Commands/RequestMakeCommand.php @@ -35,9 +35,8 @@ class RequestMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.request.namespace') ?: $module->config('paths.generator.request.path', 'Http/Requests'); + return config('modules.paths.generator.request.namespace') + ?? ltrim(config('modules.paths.generator.request.path', 'Http/Requests'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ResourceMakeCommand.php b/src/Commands/ResourceMakeCommand.php index daea669d9..8ead3dce5 100644 --- a/src/Commands/ResourceMakeCommand.php +++ b/src/Commands/ResourceMakeCommand.php @@ -19,9 +19,8 @@ class ResourceMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.resource.namespace') ?: $module->config('paths.generator.resource.path', 'Transformers'); + return config('modules.paths.generator.resource.namespace') + ?? ltrim(config('modules.paths.generator.resource.path', 'Transformers'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/RuleMakeCommand.php b/src/Commands/RuleMakeCommand.php index d59289e82..29ffdff53 100644 --- a/src/Commands/RuleMakeCommand.php +++ b/src/Commands/RuleMakeCommand.php @@ -36,9 +36,8 @@ class RuleMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.rules.namespace') ?: $module->config('paths.generator.rules.path', 'Rules'); + return config('modules.paths.generator.rules.namespace') + ?? ltrim(config('modules.paths.generator.rules.path', 'Rules'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/SeedMakeCommand.php b/src/Commands/SeedMakeCommand.php index 43c0acf23..455f4352a 100644 --- a/src/Commands/SeedMakeCommand.php +++ b/src/Commands/SeedMakeCommand.php @@ -97,8 +97,7 @@ private function getSeederName(): string */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.seeder.namespace') ?: $module->config('paths.generator.seeder.path', 'Database/Seeders'); + return config('modules.paths.generator.seeder.namespace') + ?? ltrim(config('modules.paths.generator.seeder.path', 'Database/Seeders'), config('modules.paths.app_folder', '')); } } diff --git a/src/Commands/TestMakeCommand.php b/src/Commands/TestMakeCommand.php index 5d6d353fd..ed292372d 100644 --- a/src/Commands/TestMakeCommand.php +++ b/src/Commands/TestMakeCommand.php @@ -22,6 +22,11 @@ public function getDefaultNamespace(): string $module = $this->laravel['modules']; if ($this->option('feature')) { + + return config('modules.paths.generator.test-feature.namespace') + ?? config('modules.paths.generator.test-feature.path', 'Tests/Feature'); + + return $module->config('paths.generator.test-feature.namespace') ?: $module->config('paths.generator.test-feature.path', 'Tests/Feature'); } From e249300d2a66e7fba8e114d36048326e47118861 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 9 Mar 2024 22:54:32 +0330 Subject: [PATCH 187/422] [fix] fix method 'getDefaultNamespace' on make commands --- src/Commands/ChannelMakeCommand.php | 5 ++--- src/Commands/CommandMakeCommand.php | 5 ++--- src/Commands/ComponentClassMakeCommand.php | 5 ++--- src/Commands/EventMakeCommand.php | 5 ++--- src/Commands/FactoryMakeCommand.php | 11 +++++------ src/Commands/JobMakeCommand.php | 5 ++--- src/Commands/ListenerMakeCommand.php | 5 ++--- src/Commands/MailMakeCommand.php | 5 ++--- src/Commands/MiddlewareMakeCommand.php | 5 ++--- src/Commands/ModelMakeCommand.php | 5 ++--- src/Commands/NotificationMakeCommand.php | 5 ++--- src/Commands/ObserverMakeCommand.php | 7 +++---- src/Commands/PolicyMakeCommand.php | 5 ++--- src/Commands/RequestMakeCommand.php | 5 ++--- src/Commands/ResourceMakeCommand.php | 5 ++--- src/Commands/RuleMakeCommand.php | 5 ++--- src/Commands/SeedMakeCommand.php | 5 ++--- src/Commands/TestMakeCommand.php | 5 +++++ src/Commands/stubs/scaffold/provider.stub | 2 +- ...est__it_generates_api_module_with_resources__1.txt | 2 +- ...enerates_module_namespace_using_studly_case__1.txt | 2 +- ...eCommandTest__it_generates_module_resources__1.txt | 2 +- ...est__it_generates_web_module_with_resources__1.txt | 2 +- ..._resources_when_adding_more_than_one_option__1.txt | 2 +- ...ndTest__it_can_change_the_default_namespace__1.txt | 2 +- ...t_can_change_the_default_namespace_specific__1.txt | 2 +- ...e_custom_migration_resources_location_paths__1.txt | 2 +- ...ster_service_provider_with_resource_loading__1.txt | 2 +- 28 files changed, 53 insertions(+), 65 deletions(-) diff --git a/src/Commands/ChannelMakeCommand.php b/src/Commands/ChannelMakeCommand.php index a4c5e6485..0514e6eec 100644 --- a/src/Commands/ChannelMakeCommand.php +++ b/src/Commands/ChannelMakeCommand.php @@ -30,9 +30,8 @@ final class ChannelMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.channels.namespace') ?: $module->config('paths.generator.channels.path', 'Broadcasting'); + return config('modules.paths.generator.channels.namespace') + ?? ltrim(config('modules.paths.generator.channels.path', 'Broadcasting'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/CommandMakeCommand.php b/src/Commands/CommandMakeCommand.php index 8470c9a84..5ccdbbc80 100644 --- a/src/Commands/CommandMakeCommand.php +++ b/src/Commands/CommandMakeCommand.php @@ -36,9 +36,8 @@ class CommandMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.command.namespace') ?: $module->config('paths.generator.command.path', 'Console'); + return config('modules.paths.generator.command.namespace') + ?? ltrim(config('modules.paths.generator.command.path', 'Console'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ComponentClassMakeCommand.php b/src/Commands/ComponentClassMakeCommand.php index 1cac7e6b1..ab949cf8f 100644 --- a/src/Commands/ComponentClassMakeCommand.php +++ b/src/Commands/ComponentClassMakeCommand.php @@ -54,9 +54,8 @@ protected function writeComponentViewTemplate() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.component-class.namespace') ?: $module->config('paths.generator.component-class.path', 'View/Component'); + return config('modules.paths.generator.component-class.namespace') + ?? ltrim(config('modules.paths.generator.component-class.path', 'View/Component'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/EventMakeCommand.php b/src/Commands/EventMakeCommand.php index d16fe6168..cfad73758 100644 --- a/src/Commands/EventMakeCommand.php +++ b/src/Commands/EventMakeCommand.php @@ -57,9 +57,8 @@ protected function getFileName() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.event.namespace') ?: $module->config('paths.generator.event.path', 'Events'); + return config('modules.paths.generator.event.namespace') + ?? ltrim(config('modules.paths.generator.event.path', 'Events'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/FactoryMakeCommand.php b/src/Commands/FactoryMakeCommand.php index 20809f678..555e81a59 100644 --- a/src/Commands/FactoryMakeCommand.php +++ b/src/Commands/FactoryMakeCommand.php @@ -54,8 +54,8 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/factory.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'NAME' => $this->getModelName(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'NAME' => $this->getModelName(), 'MODEL_NAMESPACE' => $this->getModelNamespace(), ]))->render(); } @@ -95,9 +95,8 @@ private function getModelName() */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.factory.namespace') ?: $module->config('paths.generator.factory.path'); + return config('modules.paths.generator.factory.namespace') + ?? ltrim(config('modules.paths.generator.factory.path', 'Database/Factories'), config('modules.paths.app_folder', '')); } /** @@ -107,7 +106,7 @@ public function getDefaultNamespace(): string */ public function getModelNamespace(): string { - $path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities'); + $path = ltrim(config('modules.paths.generator.model.path', 'Entities'), config('modules.paths.app_folder', '')); $path = str_replace('/', '\\', $path); diff --git a/src/Commands/JobMakeCommand.php b/src/Commands/JobMakeCommand.php index 434eb72e3..993c07d0a 100644 --- a/src/Commands/JobMakeCommand.php +++ b/src/Commands/JobMakeCommand.php @@ -31,9 +31,8 @@ class JobMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.jobs.namespace') ?: $module->config('paths.generator.jobs.path', 'Jobs'); + return config('modules.paths.generator.jobs.namespace') + ?? ltrim(config('modules.paths.generator.jobs.path', 'Jobs'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ListenerMakeCommand.php b/src/Commands/ListenerMakeCommand.php index 4002f4db3..972053c30 100644 --- a/src/Commands/ListenerMakeCommand.php +++ b/src/Commands/ListenerMakeCommand.php @@ -70,9 +70,8 @@ protected function getTemplateContents() public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.listener.namespace') ?: $module->config('paths.generator.listener.path', 'Listeners'); + return config('modules.paths.generator.listener.namespace') + ?? ltrim(config('modules.paths.generator.listener.path', 'Listeners'), config('modules.paths.app_folder', '')); } protected function getEventName(Module $module) diff --git a/src/Commands/MailMakeCommand.php b/src/Commands/MailMakeCommand.php index d10b1c033..8c08c0598 100644 --- a/src/Commands/MailMakeCommand.php +++ b/src/Commands/MailMakeCommand.php @@ -30,9 +30,8 @@ class MailMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.emails.namespace') ?: $module->config('paths.generator.emails.path', 'Emails'); + return config('modules.paths.generator.emails.namespace') + ?? ltrim(config('modules.paths.generator.emails.path', 'Emails'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/MiddlewareMakeCommand.php b/src/Commands/MiddlewareMakeCommand.php index 7298fcc92..d9283b2ef 100644 --- a/src/Commands/MiddlewareMakeCommand.php +++ b/src/Commands/MiddlewareMakeCommand.php @@ -35,9 +35,8 @@ class MiddlewareMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.filter.namespace') ?: $module->config('paths.generator.filter.path', 'Http/Middleware'); + return config('modules.paths.generator.filter.namespace') + ?? ltrim(config('modules.paths.generator.filter.path', 'Http/Middleware'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ModelMakeCommand.php b/src/Commands/ModelMakeCommand.php index d6da06327..c063ea67b 100644 --- a/src/Commands/ModelMakeCommand.php +++ b/src/Commands/ModelMakeCommand.php @@ -238,8 +238,7 @@ private function getFillable() */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.model.namespace') ?: $module->config('paths.generator.model.path', 'Entities'); + return config('modules.paths.generator.model.namespace') + ?? ltrim(config('modules.paths.generator.model.path', 'Models'), config('modules.paths.app_folder', '')); } } diff --git a/src/Commands/NotificationMakeCommand.php b/src/Commands/NotificationMakeCommand.php index 72cec53d1..9069fcd79 100644 --- a/src/Commands/NotificationMakeCommand.php +++ b/src/Commands/NotificationMakeCommand.php @@ -30,9 +30,8 @@ final class NotificationMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.notifications.namespace') ?: $module->config('paths.generator.notifications.path', 'Notifications'); + return config('modules.paths.generator.notifications.namespace') + ?? ltrim(config('modules.paths.generator.notifications.path', 'Notifications'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ObserverMakeCommand.php b/src/Commands/ObserverMakeCommand.php index 5b756c2ff..aec1382b5 100644 --- a/src/Commands/ObserverMakeCommand.php +++ b/src/Commands/ObserverMakeCommand.php @@ -120,7 +120,7 @@ public function handle(): int return 0; } - + /** * Get default namespace. * @@ -128,8 +128,7 @@ public function handle(): int */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.observer.namespace') ?: $module->config('paths.generator.observer.path', 'Observers'); + return config('modules.paths.generator.observer.namespace') + ?? ltrim(config('modules.paths.generator.observer.path', 'Observers'), config('modules.paths.app_folder', '')); } } diff --git a/src/Commands/PolicyMakeCommand.php b/src/Commands/PolicyMakeCommand.php index 1ed55cb42..4932d9024 100644 --- a/src/Commands/PolicyMakeCommand.php +++ b/src/Commands/PolicyMakeCommand.php @@ -35,9 +35,8 @@ class PolicyMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.policies.namespace') ?: $module->config('paths.generator.policies.path', 'Policies'); + return config('modules.paths.generator.policies.namespace') + ?? ltrim(config('modules.paths.generator.policies.path', 'Policies'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/RequestMakeCommand.php b/src/Commands/RequestMakeCommand.php index c20882650..2dd0c6e5e 100644 --- a/src/Commands/RequestMakeCommand.php +++ b/src/Commands/RequestMakeCommand.php @@ -35,9 +35,8 @@ class RequestMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.request.namespace') ?: $module->config('paths.generator.request.path', 'Http/Requests'); + return config('modules.paths.generator.request.namespace') + ?? ltrim(config('modules.paths.generator.request.path', 'Http/Requests'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/ResourceMakeCommand.php b/src/Commands/ResourceMakeCommand.php index daea669d9..8ead3dce5 100644 --- a/src/Commands/ResourceMakeCommand.php +++ b/src/Commands/ResourceMakeCommand.php @@ -19,9 +19,8 @@ class ResourceMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.resource.namespace') ?: $module->config('paths.generator.resource.path', 'Transformers'); + return config('modules.paths.generator.resource.namespace') + ?? ltrim(config('modules.paths.generator.resource.path', 'Transformers'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/RuleMakeCommand.php b/src/Commands/RuleMakeCommand.php index d59289e82..29ffdff53 100644 --- a/src/Commands/RuleMakeCommand.php +++ b/src/Commands/RuleMakeCommand.php @@ -36,9 +36,8 @@ class RuleMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.rules.namespace') ?: $module->config('paths.generator.rules.path', 'Rules'); + return config('modules.paths.generator.rules.namespace') + ?? ltrim(config('modules.paths.generator.rules.path', 'Rules'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/SeedMakeCommand.php b/src/Commands/SeedMakeCommand.php index 43c0acf23..455f4352a 100644 --- a/src/Commands/SeedMakeCommand.php +++ b/src/Commands/SeedMakeCommand.php @@ -97,8 +97,7 @@ private function getSeederName(): string */ public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - - return $module->config('paths.generator.seeder.namespace') ?: $module->config('paths.generator.seeder.path', 'Database/Seeders'); + return config('modules.paths.generator.seeder.namespace') + ?? ltrim(config('modules.paths.generator.seeder.path', 'Database/Seeders'), config('modules.paths.app_folder', '')); } } diff --git a/src/Commands/TestMakeCommand.php b/src/Commands/TestMakeCommand.php index 5d6d353fd..ed292372d 100644 --- a/src/Commands/TestMakeCommand.php +++ b/src/Commands/TestMakeCommand.php @@ -22,6 +22,11 @@ public function getDefaultNamespace(): string $module = $this->laravel['modules']; if ($this->option('feature')) { + + return config('modules.paths.generator.test-feature.namespace') + ?? config('modules.paths.generator.test-feature.path', 'Tests/Feature'); + + return $module->config('paths.generator.test-feature.namespace') ?: $module->config('paths.generator.test-feature.path', 'Tests/Feature'); } diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 790f93982..b6aa804c4 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -88,7 +88,7 @@ class $CLASS$ extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt index 10814f6ab..39c7fa448 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt index d901e5384..6be5bae91 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt @@ -88,7 +88,7 @@ class ModuleNameServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index 10814f6ab..39c7fa448 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt index 10814f6ab..39c7fa448 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 10814f6ab..39c7fa448 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index 1933ca368..c310c307c 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 1933ca368..c310c307c 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index 6e083d923..e75371fbd 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index 10814f6ab..39c7fa448 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -88,7 +88,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder'))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From f8440fd47d98ec863223006fe57caf7aaa568929 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 11 Mar 2024 13:52:51 +0330 Subject: [PATCH 188/422] [fix] fix create test command --- src/Commands/TestMakeCommand.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Commands/TestMakeCommand.php b/src/Commands/TestMakeCommand.php index ed292372d..fff05d6e1 100644 --- a/src/Commands/TestMakeCommand.php +++ b/src/Commands/TestMakeCommand.php @@ -19,18 +19,13 @@ class TestMakeCommand extends GeneratorCommand public function getDefaultNamespace(): string { - $module = $this->laravel['modules']; - if ($this->option('feature')) { - return config('modules.paths.generator.test-feature.namespace') ?? config('modules.paths.generator.test-feature.path', 'Tests/Feature'); - - - return $module->config('paths.generator.test-feature.namespace') ?: $module->config('paths.generator.test-feature.path', 'Tests/Feature'); } - return $module->config('paths.generator.test.namespace') ?: $module->config('paths.generator.test.path', 'Tests/Unit'); + return config('modules.paths.generator.test-unit.namespace') + ?? config('modules.paths.generator.test-unit.path', 'Tests/Unit'); } /** From dd8579653d51e010ba4a556f79e96d8d340b297e Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 11 Mar 2024 14:51:11 +0330 Subject: [PATCH 189/422] [test] update snapshots --- ...CommandTest__it_can_change_the_default_unit_namespace__1.txt | 2 +- ...st__it_can_change_the_default_unit_namespace_specific__1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt index 273dc9657..fcbfc0da3 100644 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt @@ -1,6 +1,6 @@ Date: Tue, 12 Mar 2024 12:45:06 +0000 Subject: [PATCH 190/422] fix: Failed to load module script for static assets such as images --- src/Module.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Module.php b/src/Module.php index eb42f0364..7d6ae8830 100644 --- a/src/Module.php +++ b/src/Module.php @@ -89,6 +89,11 @@ public static function getAssets(): array if (is_array($files)) { foreach ($files as $file) { + // Ignore files which aren't entrypoints. + if (empty($file['isEntry'])) { + continue; + } + if (isset($file['src'])) { $paths[] = $file['src']; } From ff38caa2c7c659a9175e45ece352353ed137b933 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 12 Mar 2024 15:20:51 +0000 Subject: [PATCH 191/422] updated CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de9f4080f..3cef59a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Fixed + +- [@Subtixx](https://github.com/subtixx) Fix Issue #1752 - Hardcoded string + undefined variable +- [@jaymeh](https://github.com/jaymeh) fix: Failed to load module script for static assets such as images + +## Changed + +- [@alissn](https://github.com/alissn) delete command module:migrate-fresh +- [@alissn](https://github.com/alissn) Fixing Case of tests/Unit and tests/Feature + ## Updated - [@dcblogdev](https://github.com/dcblogdev) updated vite to rename placeholder with module name From 9e4676f4383c82687b125419bf381ce09882679d Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 13 Mar 2024 00:49:10 +0000 Subject: [PATCH 192/422] removed broken links / outdated content --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bcafa246b..d76e3d964 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,10 @@ `nwidart/laravel-modules` is a Laravel package which created to manage your large Laravel app using modules. Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 10. -This package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. This package is used in [AsgardCMS](https://github.com/AsgardCms). +This package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. With one big added bonus that the original package didn't have: **tests**. -Find out why you should use this package in the article: [Writing modular applications with laravel-modules](https://nicolaswidart.com/blog/writing-modular-applications-with-laravel-modules). - ## Install To install via Composer, run: @@ -55,7 +53,6 @@ By default, module classes aren't loaded automatically. To autoload them using p "Database\\Seeders\\": "database/seeders/", "Modules\\": "Modules/" } - } ``` @@ -63,7 +60,7 @@ By default, module classes aren't loaded automatically. To autoload them using p ## Documentation -You'll find installation instructions and full documentation on [https://docs.laravelmodules.com/](https://docs.laravelmodules.com/). +You'll find installation instructions and full documentation on [https://laravelmodules.com/](https://laravelmodules.com/docs). ## Community @@ -76,10 +73,6 @@ We also have a Discord community. [https://discord.gg/hkF7BRvRZK](https://discor - [gravitano](https://github.com/gravitano) - [All Contributors](../../contributors) -## About Nicolas Widart - -Nicolas Widart is a freelance web developer specialising on the Laravel framework. View all my packages [on my website](https://nwidart.com/), or visit [my website](https://nicolaswidart.com). - ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. From 40129bd8464a20601aa504c1d586e8d06596e81d Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 13 Mar 2024 21:41:01 +0330 Subject: [PATCH 193/422] [feat] add command module:composer-update --- src/Commands/ComposerUpdateCommand.php | 60 ++++++++++++++++++++++++ src/Providers/ConsoleServiceProvider.php | 1 + 2 files changed, 61 insertions(+) create mode 100644 src/Commands/ComposerUpdateCommand.php diff --git a/src/Commands/ComposerUpdateCommand.php b/src/Commands/ComposerUpdateCommand.php new file mode 100644 index 000000000..4a2614655 --- /dev/null +++ b/src/Commands/ComposerUpdateCommand.php @@ -0,0 +1,60 @@ +getModuleModel($name); + + $this->components->task("Updating Composer.json {$module->getName()} Module", function () use ($module) { + + $composer_path = $module->getPath() . DIRECTORY_SEPARATOR . 'composer.json'; + + $composer = json_decode(File::get($composer_path), TRUE); + + $autoload = data_get($composer, 'autoload.psr-4'); + + if (! $autoload) { + return; + } + + $key_name_with_app = sprintf('Modules\\%s\\App\\', $module->getStudlyName()); + + if (! array_key_exists($key_name_with_app, $autoload) ) { + return; + } + + unset($autoload[$key_name_with_app]); + $key_name_with_out_app = sprintf('Modules\\%s\\', $module->getStudlyName()); + $autoload[$key_name_with_out_app] = 'app/'; + + data_set($composer, 'autoload.psr-4', $autoload); + + file_put_contents($composer_path, json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + + }); + } + + function getInfo(): string|null + { + return 'Updating Composer.json of modules...'; + } +} diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index b3bb05ddb..730a82f6c 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -31,6 +31,7 @@ public static function defaultCommands(): Collection Commands\CommandMakeCommand::class, Commands\ComponentClassMakeCommand::class, Commands\ComponentViewMakeCommand::class, + Commands\ComposerUpdateCommand::class, Commands\ControllerMakeCommand::class, Commands\DisableCommand::class, Commands\DumpCommand::class, From bd3c6cd960a305ab14825be1972e43517bfda98c Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 15 Mar 2024 16:50:04 +0330 Subject: [PATCH 194/422] [fix] move command to sub directory --- src/Commands/{ => Database}/MigrateCommand.php | 3 ++- src/Commands/{ => Database}/MigrateRefreshCommand.php | 3 ++- src/Commands/{ => Database}/MigrateResetCommand.php | 3 ++- src/Commands/{ => Database}/MigrateRollbackCommand.php | 3 ++- src/Commands/{ => Database}/MigrateStatusCommand.php | 3 ++- src/Commands/{ => Database}/SeedCommand.php | 4 ++-- 6 files changed, 12 insertions(+), 7 deletions(-) rename src/Commands/{ => Database}/MigrateCommand.php (96%) rename src/Commands/{ => Database}/MigrateRefreshCommand.php (95%) rename src/Commands/{ => Database}/MigrateResetCommand.php (95%) rename src/Commands/{ => Database}/MigrateRollbackCommand.php (95%) rename src/Commands/{ => Database}/MigrateStatusCommand.php (93%) rename src/Commands/{ => Database}/SeedCommand.php (98%) diff --git a/src/Commands/MigrateCommand.php b/src/Commands/Database/MigrateCommand.php similarity index 96% rename from src/Commands/MigrateCommand.php rename to src/Commands/Database/MigrateCommand.php index 7550c15e1..ab970e8fe 100644 --- a/src/Commands/MigrateCommand.php +++ b/src/Commands/Database/MigrateCommand.php @@ -1,7 +1,8 @@ Date: Fri, 15 Mar 2024 16:56:22 +0330 Subject: [PATCH 195/422] [fix] move make command to sub directory --- src/Commands/{ => Make}/ChannelMakeCommand.php | 3 ++- src/Commands/{ => Make}/CommandMakeCommand.php | 3 ++- src/Commands/{ => Make}/ComponentClassMakeCommand.php | 3 ++- src/Commands/{ => Make}/ComponentViewMakeCommand.php | 3 ++- src/Commands/{ => Make}/ControllerMakeCommand.php | 3 ++- src/Commands/{ => Make}/EventMakeCommand.php | 3 ++- src/Commands/{ => Make}/FactoryMakeCommand.php | 3 ++- src/Commands/{ => Make}/JobMakeCommand.php | 3 ++- src/Commands/{ => Make}/ListenerMakeCommand.php | 3 ++- src/Commands/{ => Make}/MailMakeCommand.php | 3 ++- src/Commands/{ => Make}/MiddlewareMakeCommand.php | 3 ++- src/Commands/{ => Make}/MigrationMakeCommand.php | 3 ++- src/Commands/{ => Make}/ModelMakeCommand.php | 3 ++- src/Commands/{ => Make}/ModuleMakeCommand.php | 2 +- src/Commands/{ => Make}/NotificationMakeCommand.php | 3 ++- src/Commands/{ => Make}/ObserverMakeCommand.php | 3 ++- src/Commands/{ => Make}/PolicyMakeCommand.php | 3 ++- src/Commands/{ => Make}/ProviderMakeCommand.php | 3 ++- src/Commands/{ => Make}/RequestMakeCommand.php | 3 ++- src/Commands/{ => Make}/ResourceMakeCommand.php | 3 ++- src/Commands/{ => Make}/RouteProviderMakeCommand.php | 3 ++- src/Commands/{ => Make}/RuleMakeCommand.php | 3 ++- src/Commands/{ => Make}/SeedMakeCommand.php | 3 ++- src/Commands/{ => Make}/TestMakeCommand.php | 3 ++- 24 files changed, 47 insertions(+), 24 deletions(-) rename src/Commands/{ => Make}/ChannelMakeCommand.php (96%) rename src/Commands/{ => Make}/CommandMakeCommand.php (96%) rename src/Commands/{ => Make}/ComponentClassMakeCommand.php (96%) rename src/Commands/{ => Make}/ComponentViewMakeCommand.php (95%) rename src/Commands/{ => Make}/ControllerMakeCommand.php (97%) rename src/Commands/{ => Make}/EventMakeCommand.php (95%) rename src/Commands/{ => Make}/FactoryMakeCommand.php (97%) rename src/Commands/{ => Make}/JobMakeCommand.php (96%) rename src/Commands/{ => Make}/ListenerMakeCommand.php (97%) rename src/Commands/{ => Make}/MailMakeCommand.php (95%) rename src/Commands/{ => Make}/MiddlewareMakeCommand.php (96%) rename src/Commands/{ => Make}/MigrationMakeCommand.php (98%) rename src/Commands/{ => Make}/ModelMakeCommand.php (98%) rename src/Commands/{ => Make}/ModuleMakeCommand.php (98%) rename src/Commands/{ => Make}/NotificationMakeCommand.php (96%) rename src/Commands/{ => Make}/ObserverMakeCommand.php (97%) rename src/Commands/{ => Make}/PolicyMakeCommand.php (96%) rename src/Commands/{ => Make}/ProviderMakeCommand.php (97%) rename src/Commands/{ => Make}/RequestMakeCommand.php (96%) rename src/Commands/{ => Make}/ResourceMakeCommand.php (96%) rename src/Commands/{ => Make}/RouteProviderMakeCommand.php (97%) rename src/Commands/{ => Make}/RuleMakeCommand.php (96%) rename src/Commands/{ => Make}/SeedMakeCommand.php (96%) rename src/Commands/{ => Make}/TestMakeCommand.php (96%) diff --git a/src/Commands/ChannelMakeCommand.php b/src/Commands/Make/ChannelMakeCommand.php similarity index 96% rename from src/Commands/ChannelMakeCommand.php rename to src/Commands/Make/ChannelMakeCommand.php index 0514e6eec..77a0d1784 100644 --- a/src/Commands/ChannelMakeCommand.php +++ b/src/Commands/Make/ChannelMakeCommand.php @@ -1,8 +1,9 @@ Date: Fri, 15 Mar 2024 17:05:22 +0330 Subject: [PATCH 196/422] [fix] move generator class to make folder --- src/Commands/Make/ChannelMakeCommand.php | 1 - src/Commands/Make/CommandMakeCommand.php | 1 - src/Commands/Make/ComponentClassMakeCommand.php | 1 - src/Commands/Make/ComponentViewMakeCommand.php | 1 - src/Commands/Make/ControllerMakeCommand.php | 1 - src/Commands/Make/EventMakeCommand.php | 1 - src/Commands/Make/FactoryMakeCommand.php | 1 - src/Commands/{ => Make}/GeneratorCommand.php | 2 +- src/Commands/Make/JobMakeCommand.php | 1 - src/Commands/Make/ListenerMakeCommand.php | 1 - src/Commands/Make/MailMakeCommand.php | 1 - src/Commands/Make/MiddlewareMakeCommand.php | 1 - src/Commands/Make/MigrationMakeCommand.php | 1 - src/Commands/Make/ModelMakeCommand.php | 1 - src/Commands/Make/NotificationMakeCommand.php | 1 - src/Commands/Make/ObserverMakeCommand.php | 1 - src/Commands/Make/PolicyMakeCommand.php | 1 - src/Commands/Make/ProviderMakeCommand.php | 1 - src/Commands/Make/RequestMakeCommand.php | 1 - src/Commands/Make/ResourceMakeCommand.php | 1 - src/Commands/Make/RouteProviderMakeCommand.php | 1 - src/Commands/Make/RuleMakeCommand.php | 1 - src/Commands/Make/SeedMakeCommand.php | 1 - src/Commands/Make/TestMakeCommand.php | 1 - 24 files changed, 1 insertion(+), 24 deletions(-) rename src/Commands/{ => Make}/GeneratorCommand.php (98%) diff --git a/src/Commands/Make/ChannelMakeCommand.php b/src/Commands/Make/ChannelMakeCommand.php index 77a0d1784..b65836fac 100644 --- a/src/Commands/Make/ChannelMakeCommand.php +++ b/src/Commands/Make/ChannelMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/Make/CommandMakeCommand.php b/src/Commands/Make/CommandMakeCommand.php index c166250f3..d4aa9aafb 100644 --- a/src/Commands/Make/CommandMakeCommand.php +++ b/src/Commands/Make/CommandMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/Make/ComponentClassMakeCommand.php b/src/Commands/Make/ComponentClassMakeCommand.php index 376c6487c..04637fbd7 100644 --- a/src/Commands/Make/ComponentClassMakeCommand.php +++ b/src/Commands/Make/ComponentClassMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/Make/ComponentViewMakeCommand.php b/src/Commands/Make/ComponentViewMakeCommand.php index 017be1413..86812e3be 100644 --- a/src/Commands/Make/ComponentViewMakeCommand.php +++ b/src/Commands/Make/ComponentViewMakeCommand.php @@ -4,7 +4,6 @@ use Illuminate\Foundation\Inspiring; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/Make/ControllerMakeCommand.php b/src/Commands/Make/ControllerMakeCommand.php index 413236404..04c91ae47 100644 --- a/src/Commands/Make/ControllerMakeCommand.php +++ b/src/Commands/Make/ControllerMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/Make/EventMakeCommand.php b/src/Commands/Make/EventMakeCommand.php index 93abf4162..0275b5f8c 100644 --- a/src/Commands/Make/EventMakeCommand.php +++ b/src/Commands/Make/EventMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/Make/FactoryMakeCommand.php b/src/Commands/Make/FactoryMakeCommand.php index 3f842db56..39ca32ff5 100644 --- a/src/Commands/Make/FactoryMakeCommand.php +++ b/src/Commands/Make/FactoryMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Nwidart\Modules\Commands\GeneratorCommand; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; diff --git a/src/Commands/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php similarity index 98% rename from src/Commands/GeneratorCommand.php rename to src/Commands/Make/GeneratorCommand.php index 96c3a1e88..ee2d897e4 100644 --- a/src/Commands/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -1,6 +1,6 @@ Date: Fri, 15 Mar 2024 17:06:36 +0330 Subject: [PATCH 197/422] [fix] move publish command to publish folder --- src/Commands/{ => Publish}/PublishCommand.php | 3 ++- src/Commands/{ => Publish}/PublishConfigurationCommand.php | 3 ++- src/Commands/{ => Publish}/PublishMigrationCommand.php | 4 ++-- src/Commands/{ => Publish}/PublishTranslationCommand.php | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) rename src/Commands/{ => Publish}/PublishCommand.php (91%) rename src/Commands/{ => Publish}/PublishConfigurationCommand.php (94%) rename src/Commands/{ => Publish}/PublishMigrationCommand.php (92%) rename src/Commands/{ => Publish}/PublishTranslationCommand.php (91%) diff --git a/src/Commands/PublishCommand.php b/src/Commands/Publish/PublishCommand.php similarity index 91% rename from src/Commands/PublishCommand.php rename to src/Commands/Publish/PublishCommand.php index 505298a9b..291a4555c 100644 --- a/src/Commands/PublishCommand.php +++ b/src/Commands/Publish/PublishCommand.php @@ -1,7 +1,8 @@ Date: Fri, 15 Mar 2024 17:17:47 +0330 Subject: [PATCH 198/422] [fix] move action command to Action folder --- src/Commands/{ => Actions}/CheckLangCommand.php | 3 ++- src/Commands/{ => Actions}/DisableCommand.php | 4 +++- src/Commands/{ => Actions}/DumpCommand.php | 4 +++- src/Commands/{ => Actions}/EnableCommand.php | 4 +++- src/Commands/{ => Actions}/InstallCommand.php | 2 +- src/Commands/{ => Actions}/ListCommand.php | 2 +- src/Commands/{ => Actions}/ModelPruneCommand.php | 2 +- src/Commands/{ => Actions}/ModelShowCommand.php | 2 +- src/Commands/{ => Actions}/ModuleDeleteCommand.php | 4 +++- src/Commands/{ => Actions}/UnUseCommand.php | 4 ++-- src/Commands/{ => Actions}/UpdateCommand.php | 4 +++- src/Commands/{ => Actions}/UseCommand.php | 4 +++- 12 files changed, 26 insertions(+), 13 deletions(-) rename src/Commands/{ => Actions}/CheckLangCommand.php (98%) rename src/Commands/{ => Actions}/DisableCommand.php (91%) rename src/Commands/{ => Actions}/DumpCommand.php (89%) rename src/Commands/{ => Actions}/EnableCommand.php (90%) rename src/Commands/{ => Actions}/InstallCommand.php (98%) rename src/Commands/{ => Actions}/ListCommand.php (98%) rename src/Commands/{ => Actions}/ModelPruneCommand.php (98%) rename src/Commands/{ => Actions}/ModelShowCommand.php (97%) rename src/Commands/{ => Actions}/ModuleDeleteCommand.php (86%) rename src/Commands/{ => Actions}/UnUseCommand.php (89%) rename src/Commands/{ => Actions}/UpdateCommand.php (89%) rename src/Commands/{ => Actions}/UseCommand.php (88%) diff --git a/src/Commands/CheckLangCommand.php b/src/Commands/Actions/CheckLangCommand.php similarity index 98% rename from src/Commands/CheckLangCommand.php rename to src/Commands/Actions/CheckLangCommand.php index 01afbc39c..d15b0c516 100644 --- a/src/Commands/CheckLangCommand.php +++ b/src/Commands/Actions/CheckLangCommand.php @@ -1,8 +1,9 @@ Date: Fri, 15 Mar 2024 17:19:13 +0330 Subject: [PATCH 199/422] [feat] update namespace of commands --- src/Providers/ConsoleServiceProvider.php | 92 ++++++++++++------------ tests/BaseTestCase.php | 84 +++++++++++----------- 2 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 730a82f6c..96b83ec14 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -26,56 +26,56 @@ public function provides(): array public static function defaultCommands(): Collection { return collect([ - Commands\ChannelMakeCommand::class, - Commands\CheckLangCommand::class, - Commands\CommandMakeCommand::class, - Commands\ComponentClassMakeCommand::class, - Commands\ComponentViewMakeCommand::class, + Commands\Make\ChannelMakeCommand::class, + Commands\Actions\CheckLangCommand::class, + Commands\Make\CommandMakeCommand::class, + Commands\Make\ComponentClassMakeCommand::class, + Commands\Make\ComponentViewMakeCommand::class, Commands\ComposerUpdateCommand::class, - Commands\ControllerMakeCommand::class, - Commands\DisableCommand::class, - Commands\DumpCommand::class, - Commands\EnableCommand::class, - Commands\EventMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\InstallCommand::class, - Commands\JobMakeCommand::class, + Commands\Make\ControllerMakeCommand::class, + Commands\Actions\DisableCommand::class, + Commands\Actions\DumpCommand::class, + Commands\Actions\EnableCommand::class, + Commands\Make\EventMakeCommand::class, + Commands\Make\FactoryMakeCommand::class, + Commands\Actions\InstallCommand::class, + Commands\Make\JobMakeCommand::class, Commands\LaravelModulesV6Migrator::class, - Commands\ListCommand::class, - Commands\ListenerMakeCommand::class, - Commands\MailMakeCommand::class, - Commands\MiddlewareMakeCommand::class, - Commands\MigrateCommand::class, + Commands\Actions\ListCommand::class, + Commands\Make\ListenerMakeCommand::class, + Commands\Make\MailMakeCommand::class, + Commands\Make\MiddlewareMakeCommand::class, + Commands\Database\MigrateCommand::class, Commands\MigrateFreshCommand::class, - Commands\MigrateRefreshCommand::class, - Commands\MigrateResetCommand::class, - Commands\MigrateRollbackCommand::class, - Commands\MigrateStatusCommand::class, - Commands\MigrationMakeCommand::class, - Commands\ModelMakeCommand::class, - Commands\ModelPruneCommand::class, - Commands\ModelShowCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ObserverMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\PublishCommand::class, - Commands\PublishConfigurationCommand::class, - Commands\PublishMigrationCommand::class, - Commands\PublishTranslationCommand::class, - Commands\RequestMakeCommand::class, - Commands\ResourceMakeCommand::class, - Commands\RouteProviderMakeCommand::class, - Commands\RuleMakeCommand::class, - Commands\SeedCommand::class, - Commands\SeedMakeCommand::class, + Commands\Database\MigrateRefreshCommand::class, + Commands\Database\MigrateResetCommand::class, + Commands\Database\MigrateRollbackCommand::class, + Commands\Database\MigrateStatusCommand::class, + Commands\Make\MigrationMakeCommand::class, + Commands\Make\ModelMakeCommand::class, + Commands\Actions\ModelPruneCommand::class, + Commands\Actions\ModelShowCommand::class, + Commands\Actions\ModuleDeleteCommand::class, + Commands\Make\ModuleMakeCommand::class, + Commands\Make\NotificationMakeCommand::class, + Commands\Make\ObserverMakeCommand::class, + Commands\Make\PolicyMakeCommand::class, + Commands\Make\ProviderMakeCommand::class, + Commands\Publish\PublishCommand::class, + Commands\Publish\PublishConfigurationCommand::class, + Commands\Publish\PublishMigrationCommand::class, + Commands\Publish\PublishTranslationCommand::class, + Commands\Make\RequestMakeCommand::class, + Commands\Make\ResourceMakeCommand::class, + Commands\Make\RouteProviderMakeCommand::class, + Commands\Make\RuleMakeCommand::class, + Commands\Database\SeedCommand::class, + Commands\Make\SeedMakeCommand::class, Commands\SetupCommand::class, - Commands\TestMakeCommand::class, - Commands\UnUseCommand::class, - Commands\UpdateCommand::class, - Commands\UseCommand::class, + Commands\Make\TestMakeCommand::class, + Commands\Actions\UnUseCommand::class, + Commands\Actions\UpdateCommand::class, + Commands\Actions\UseCommand::class, ]); } } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 58f075e9f..a8a56b9fb 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -86,50 +86,50 @@ protected function getEnvironmentSetUp($app) $app['config']->set('modules.composer-output', true); $app['config']->set('modules.commands', [ - Commands\ChannelMakeCommand::class, - Commands\CommandMakeCommand::class, - Commands\ControllerMakeCommand::class, - Commands\DisableCommand::class, - Commands\DumpCommand::class, - Commands\EnableCommand::class, - Commands\EventMakeCommand::class, - Commands\JobMakeCommand::class, - Commands\ListenerMakeCommand::class, - Commands\MailMakeCommand::class, - Commands\MiddlewareMakeCommand::class, - Commands\NotificationMakeCommand::class, - Commands\ProviderMakeCommand::class, - Commands\RouteProviderMakeCommand::class, - Commands\InstallCommand::class, - Commands\ListCommand::class, - Commands\ModuleDeleteCommand::class, - Commands\ModuleMakeCommand::class, - Commands\FactoryMakeCommand::class, - Commands\PolicyMakeCommand::class, - Commands\RequestMakeCommand::class, - Commands\RuleMakeCommand::class, - Commands\MigrateCommand::class, - Commands\MigrateRefreshCommand::class, - Commands\MigrateResetCommand::class, - Commands\MigrateRollbackCommand::class, - Commands\MigrateStatusCommand::class, - Commands\MigrationMakeCommand::class, - Commands\ModelMakeCommand::class, - Commands\PublishCommand::class, - Commands\PublishConfigurationCommand::class, - Commands\PublishMigrationCommand::class, - Commands\PublishTranslationCommand::class, - Commands\SeedCommand::class, - Commands\SeedMakeCommand::class, + Commands\Make\ChannelMakeCommand::class, + Commands\Make\CommandMakeCommand::class, + Commands\Make\ControllerMakeCommand::class, + Commands\Actions\DisableCommand::class, + Commands\Actions\DumpCommand::class, + Commands\Actions\EnableCommand::class, + Commands\Make\EventMakeCommand::class, + Commands\Make\JobMakeCommand::class, + Commands\Make\ListenerMakeCommand::class, + Commands\Make\MailMakeCommand::class, + Commands\Make\MiddlewareMakeCommand::class, + Commands\Make\NotificationMakeCommand::class, + Commands\Make\ProviderMakeCommand::class, + Commands\Make\RouteProviderMakeCommand::class, + Commands\Actions\InstallCommand::class, + Commands\Actions\ListCommand::class, + Commands\Actions\ModuleDeleteCommand::class, + Commands\Make\ModuleMakeCommand::class, + Commands\Make\FactoryMakeCommand::class, + Commands\Make\PolicyMakeCommand::class, + Commands\Make\RequestMakeCommand::class, + Commands\Make\RuleMakeCommand::class, + Commands\Database\MigrateCommand::class, + Commands\Database\MigrateRefreshCommand::class, + Commands\Database\MigrateResetCommand::class, + Commands\Database\MigrateRollbackCommand::class, + Commands\Database\MigrateStatusCommand::class, + Commands\Make\MigrationMakeCommand::class, + Commands\Make\ModelMakeCommand::class, + Commands\Publish\PublishCommand::class, + Commands\Publish\PublishConfigurationCommand::class, + Commands\Publish\PublishMigrationCommand::class, + Commands\Publish\PublishTranslationCommand::class, + Commands\Database\SeedCommand::class, + Commands\Make\SeedMakeCommand::class, Commands\SetupCommand::class, - Commands\UnUseCommand::class, - Commands\UpdateCommand::class, - Commands\UseCommand::class, - Commands\ResourceMakeCommand::class, - Commands\TestMakeCommand::class, + Commands\Actions\UnUseCommand::class, + Commands\Actions\UpdateCommand::class, + Commands\Actions\UseCommand::class, + Commands\Make\ResourceMakeCommand::class, + Commands\Make\TestMakeCommand::class, Commands\LaravelModulesV6Migrator::class, - Commands\ComponentClassMakeCommand::class, - Commands\ComponentViewMakeCommand::class, + Commands\Make\ComponentClassMakeCommand::class, + Commands\Make\ComponentViewMakeCommand::class, ]); } From 9a72334e2cfb622e4d0ac02bd0609ad6f7b915a1 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 15 Mar 2024 17:21:51 +0330 Subject: [PATCH 200/422] [feat] read command list from provider class on BaseTestCase --- tests/BaseTestCase.php | 49 ++---------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index a8a56b9fb..ee2e29614 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -2,8 +2,8 @@ namespace Nwidart\Modules\Tests; -use Nwidart\Modules\Commands; use Nwidart\Modules\LaravelModulesServiceProvider; +use Nwidart\Modules\Providers\ConsoleServiceProvider; use Orchestra\Testbench\TestCase as OrchestraTestCase; abstract class BaseTestCase extends OrchestraTestCase @@ -85,52 +85,7 @@ protected function getEnvironmentSetUp($app) $app['config']->set('modules.composer-output', true); - $app['config']->set('modules.commands', [ - Commands\Make\ChannelMakeCommand::class, - Commands\Make\CommandMakeCommand::class, - Commands\Make\ControllerMakeCommand::class, - Commands\Actions\DisableCommand::class, - Commands\Actions\DumpCommand::class, - Commands\Actions\EnableCommand::class, - Commands\Make\EventMakeCommand::class, - Commands\Make\JobMakeCommand::class, - Commands\Make\ListenerMakeCommand::class, - Commands\Make\MailMakeCommand::class, - Commands\Make\MiddlewareMakeCommand::class, - Commands\Make\NotificationMakeCommand::class, - Commands\Make\ProviderMakeCommand::class, - Commands\Make\RouteProviderMakeCommand::class, - Commands\Actions\InstallCommand::class, - Commands\Actions\ListCommand::class, - Commands\Actions\ModuleDeleteCommand::class, - Commands\Make\ModuleMakeCommand::class, - Commands\Make\FactoryMakeCommand::class, - Commands\Make\PolicyMakeCommand::class, - Commands\Make\RequestMakeCommand::class, - Commands\Make\RuleMakeCommand::class, - Commands\Database\MigrateCommand::class, - Commands\Database\MigrateRefreshCommand::class, - Commands\Database\MigrateResetCommand::class, - Commands\Database\MigrateRollbackCommand::class, - Commands\Database\MigrateStatusCommand::class, - Commands\Make\MigrationMakeCommand::class, - Commands\Make\ModelMakeCommand::class, - Commands\Publish\PublishCommand::class, - Commands\Publish\PublishConfigurationCommand::class, - Commands\Publish\PublishMigrationCommand::class, - Commands\Publish\PublishTranslationCommand::class, - Commands\Database\SeedCommand::class, - Commands\Make\SeedMakeCommand::class, - Commands\SetupCommand::class, - Commands\Actions\UnUseCommand::class, - Commands\Actions\UpdateCommand::class, - Commands\Actions\UseCommand::class, - Commands\Make\ResourceMakeCommand::class, - Commands\Make\TestMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, - Commands\Make\ComponentClassMakeCommand::class, - Commands\Make\ComponentViewMakeCommand::class, - ]); + $app['config']->set('modules.commands', ConsoleServiceProvider::defaultCommands()->toArray()); } protected function setUpDatabase() From 84df2c689321acdafc5a7fcd1ee0f4a6d55a7983 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 15 Mar 2024 17:27:10 +0330 Subject: [PATCH 201/422] [feat] sort command in ConsoleServiceProvider --- src/Providers/ConsoleServiceProvider.php | 62 ++++++++++++++---------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 96b83ec14..ee90bd4a8 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -26,56 +26,66 @@ public function provides(): array public static function defaultCommands(): Collection { return collect([ - Commands\Make\ChannelMakeCommand::class, + // Actions Commands Commands\Actions\CheckLangCommand::class, - Commands\Make\CommandMakeCommand::class, - Commands\Make\ComponentClassMakeCommand::class, - Commands\Make\ComponentViewMakeCommand::class, - Commands\ComposerUpdateCommand::class, - Commands\Make\ControllerMakeCommand::class, Commands\Actions\DisableCommand::class, Commands\Actions\DumpCommand::class, Commands\Actions\EnableCommand::class, - Commands\Make\EventMakeCommand::class, - Commands\Make\FactoryMakeCommand::class, Commands\Actions\InstallCommand::class, - Commands\Make\JobMakeCommand::class, - Commands\LaravelModulesV6Migrator::class, Commands\Actions\ListCommand::class, - Commands\Make\ListenerMakeCommand::class, - Commands\Make\MailMakeCommand::class, - Commands\Make\MiddlewareMakeCommand::class, + Commands\Actions\ModelPruneCommand::class, + Commands\Actions\ModelShowCommand::class, + Commands\Actions\ModuleDeleteCommand::class, + Commands\Actions\UnUseCommand::class, + Commands\Actions\UpdateCommand::class, + Commands\Actions\UseCommand::class, + + // Database Commands Commands\Database\MigrateCommand::class, - Commands\MigrateFreshCommand::class, Commands\Database\MigrateRefreshCommand::class, Commands\Database\MigrateResetCommand::class, Commands\Database\MigrateRollbackCommand::class, Commands\Database\MigrateStatusCommand::class, + Commands\Database\SeedCommand::class, + + // Make Commands + Commands\Make\ChannelMakeCommand::class, + Commands\Make\CommandMakeCommand::class, + Commands\Make\ComponentClassMakeCommand::class, + Commands\Make\ComponentViewMakeCommand::class, + Commands\Make\ControllerMakeCommand::class, + Commands\Make\EventMakeCommand::class, + Commands\Make\FactoryMakeCommand::class, + Commands\Make\JobMakeCommand::class, + Commands\Make\ListenerMakeCommand::class, + Commands\Make\MailMakeCommand::class, + Commands\Make\MiddlewareMakeCommand::class, Commands\Make\MigrationMakeCommand::class, Commands\Make\ModelMakeCommand::class, - Commands\Actions\ModelPruneCommand::class, - Commands\Actions\ModelShowCommand::class, - Commands\Actions\ModuleDeleteCommand::class, Commands\Make\ModuleMakeCommand::class, Commands\Make\NotificationMakeCommand::class, Commands\Make\ObserverMakeCommand::class, Commands\Make\PolicyMakeCommand::class, Commands\Make\ProviderMakeCommand::class, - Commands\Publish\PublishCommand::class, - Commands\Publish\PublishConfigurationCommand::class, - Commands\Publish\PublishMigrationCommand::class, - Commands\Publish\PublishTranslationCommand::class, Commands\Make\RequestMakeCommand::class, Commands\Make\ResourceMakeCommand::class, Commands\Make\RouteProviderMakeCommand::class, Commands\Make\RuleMakeCommand::class, - Commands\Database\SeedCommand::class, Commands\Make\SeedMakeCommand::class, - Commands\SetupCommand::class, Commands\Make\TestMakeCommand::class, - Commands\Actions\UnUseCommand::class, - Commands\Actions\UpdateCommand::class, - Commands\Actions\UseCommand::class, + + //Publish Commands + Commands\Publish\PublishCommand::class, + Commands\Publish\PublishConfigurationCommand::class, + Commands\Publish\PublishMigrationCommand::class, + Commands\Publish\PublishTranslationCommand::class, + + // Other Commands + Commands\ComposerUpdateCommand::class, + Commands\LaravelModulesV6Migrator::class, + Commands\SetupCommand::class, + + Commands\MigrateFreshCommand::class, ]); } } From b23f08363e38f8a1da49d044f9e7ea9af67d82e9 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 15 Mar 2024 22:48:14 +0330 Subject: [PATCH 202/422] [fix] fix BaseTestCase, read generator path from config --- tests/BaseTestCase.php | 70 +++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index ee2e29614..4b72fff71 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -35,55 +35,34 @@ protected function getPackageProviders($app) /** * Set up the environment. * - * @param \Illuminate\Foundation\Application $app + * @param \Illuminate\Foundation\Application $app */ protected function getEnvironmentSetUp($app) { - $app['config']->set('app.asset_url', null); + $module_config = require __DIR__ . '/../config/config.php'; + + // enable all generators + array_walk($module_config['paths']['generator'], function (&$item) { + $item['generate'] = TRUE; + }); + + $app['config']->set('app.asset_url', NULL); $app['config']->set('database.default', 'sqlite'); $app['config']->set('database.connections.sqlite', [ - 'driver' => 'sqlite', + 'driver' => 'sqlite', 'database' => ':memory:', - 'prefix' => '', + 'prefix' => '', ]); $app['config']->set('modules.paths.modules', base_path('modules')); $app['config']->set('modules.paths', [ - 'modules' => base_path('modules'), - 'assets' => public_path('modules'), - 'migration' => base_path('database/migrations'), - 'generator' => [ - 'assets' => ['path' => 'Assets', 'generate' => true], - 'config' => ['path' => 'Config', 'generate' => true], - 'command' => ['path' => 'Console', 'generate' => true], - 'channels' => ['path' => 'Broadcasting', 'generate' => true], - 'event' => ['path' => 'Events', 'generate' => true], - 'listener' => ['path' => 'Listeners', 'generate' => true], - 'migration' => ['path' => 'Database/Migrations', 'generate' => true], - 'factory' => ['path' => 'Database/factories', 'generate' => true], - 'model' => ['path' => 'Entities', 'generate' => true], - 'observer' => ['path' => 'Observers', 'generate' => true], - 'repository' => ['path' => 'Repositories', 'generate' => true], - 'seeder' => ['path' => 'Database/Seeders', 'generate' => true], - 'controller' => ['path' => 'Http/Controllers', 'generate' => true], - 'filter' => ['path' => 'Http/Middleware', 'generate' => true], - 'request' => ['path' => 'Http/Requests', 'generate' => true], - 'provider' => ['path' => 'Providers', 'generate' => true], - 'lang' => ['path' => 'Resources/lang', 'generate' => true], - 'views' => ['path' => 'Resources/views', 'generate' => true], - 'policies' => ['path' => 'Policies', 'generate' => true], - 'rules' => ['path' => 'Rules', 'generate' => true], - 'test-feature' => ['path' => 'Tests/Feature', 'generate' => true], - 'test' => ['path' => 'Tests/Unit', 'generate' => true], - 'jobs' => ['path' => 'Jobs', 'generate' => true], - 'emails' => ['path' => 'Emails', 'generate' => true], - 'notifications' => ['path' => 'Notifications', 'generate' => true], - 'resource' => ['path' => 'Transformers', 'generate' => true], - 'component-view' => ['path' => 'Resources/views/components', 'generate' => true], - 'component-class' => ['path' => 'View/Component', 'generate' => true], - ], + 'modules' => base_path('modules'), + 'assets' => public_path('modules'), + 'migration' => base_path('database/migrations'), + 'app_folder' => $module_config['paths']['app_folder'], + 'generator' => $module_config['paths']['generator'], ]); - $app['config']->set('modules.composer-output', true); + $app['config']->set('modules.composer-output', TRUE); $app['config']->set('modules.commands', ConsoleServiceProvider::defaultCommands()->toArray()); } @@ -92,4 +71,19 @@ protected function setUpDatabase() { $this->resetDatabase(); } + + protected function createModule(string $moduleName = 'Blog'): void + { + $this->artisan('module:make', ['name' => [$moduleName]]); + } + + protected function getModuleAppPath(string $moduleName = 'Blog'): string + { + return base_path("modules/$moduleName/") . rtrim(config('modules.paths.app_folder'), '/'); + } + + protected function getModuleBasePath(string $moduleName = 'Blog'): string + { + return base_path("modules/$moduleName"); + } } From cb166d34c90f4e46036cceab80e525bd2e57e405 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 15 Mar 2024 22:51:30 +0330 Subject: [PATCH 203/422] [test] update test to pass with new config --- tests/Commands/ChannelMakeCommandTest.php | 7 ++-- tests/Commands/CommandMakeCommandTest.php | 9 ++--- .../ComponentClassMakeCommandTest.php | 17 ++++++---- .../Commands/ComponentViewMakeCommandTest.php | 12 ++++--- tests/Commands/ControllerMakeCommandTest.php | 16 +++++---- tests/Commands/DisableCommandTest.php | 25 ++++++++------ tests/Commands/EnableCommandTest.php | 34 +++++++++++++++---- 7 files changed, 76 insertions(+), 44 deletions(-) diff --git a/tests/Commands/ChannelMakeCommandTest.php b/tests/Commands/ChannelMakeCommandTest.php index 49be68dda..3da047db7 100644 --- a/tests/Commands/ChannelMakeCommandTest.php +++ b/tests/Commands/ChannelMakeCommandTest.php @@ -9,6 +9,7 @@ class ChannelMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -21,9 +22,9 @@ class ChannelMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -59,7 +60,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperChannel/WelcomeChannel.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperChannel/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/CommandMakeCommandTest.php b/tests/Commands/CommandMakeCommandTest.php index 6a4031b6b..98f7948ac 100644 --- a/tests/Commands/CommandMakeCommandTest.php +++ b/tests/Commands/CommandMakeCommandTest.php @@ -9,6 +9,7 @@ class CommandMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -21,9 +22,9 @@ class CommandMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -69,11 +70,11 @@ public function it_uses_set_command_name_in_class() /** @test */ public function it_can_change_the_default_namespace() { - $this->app['config']->set('modules.paths.generator.command.path', 'Commands'); + $this->app['config']->set('modules.paths.generator.command.path', 'app/CustomCommands'); $code = $this->artisan('module:make-command', ['name' => 'AwesomeCommand', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Commands/AwesomeCommand.php'); + $file = $this->finder->get($this->modulePath . '/CustomCommands/AwesomeCommand.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ComponentClassMakeCommandTest.php b/tests/Commands/ComponentClassMakeCommandTest.php index 779675060..914d415da 100644 --- a/tests/Commands/ComponentClassMakeCommandTest.php +++ b/tests/Commands/ComponentClassMakeCommandTest.php @@ -9,6 +9,7 @@ class ComponentClassMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -21,9 +22,9 @@ class ComponentClassMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -36,22 +37,24 @@ public function tearDown(): void public function it_generates_the_component_class() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/View/Component/Blog.php')); + $this->assertTrue(is_file($this->modulePath . '/View/Components/Blog.php')); $this->assertSame(0, $code); } + /** @test */ public function it_generates_the_component_view_from_component_class_command() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Resources/views/components/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/components/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); } + /** @test */ public function it_generated_correct_file_with_content() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/View/Component/Blog.php'); + $file = $this->finder->get($this->modulePath . '/View/Components/Blog.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); } @@ -59,11 +62,11 @@ public function it_generated_correct_file_with_content() /** @test */ public function it_can_change_the_default_namespace() { - $this->app['config']->set('modules.paths.generator.component-class.path', 'View/Component/newDirectory'); + $this->app['config']->set('modules.paths.generator.component-class.path', 'View/Components/newDirectory'); $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/View/Component/newDirectory/Blog.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/View/Components/newDirectory/Blog.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ComponentViewMakeCommandTest.php b/tests/Commands/ComponentViewMakeCommandTest.php index 9000343f9..18e4bdf85 100644 --- a/tests/Commands/ComponentViewMakeCommandTest.php +++ b/tests/Commands/ComponentViewMakeCommandTest.php @@ -9,6 +9,7 @@ class ComponentViewMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -21,9 +22,9 @@ class ComponentViewMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -36,14 +37,15 @@ public function tearDown(): void public function it_generates_the_component_view() { $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Resources/views/components/blog.blade.php')); + $this->assertTrue(is_file($this->getModuleBasePath() . '/resources/views/components/blog.blade.php')); $this->assertSame(0, $code); } + /** @test */ public function it_generated_correct_file_with_content() { $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Resources/views/components/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/components/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); } @@ -55,7 +57,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Resources/views/components/newDirectory/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/Resources/views/components/newDirectory/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); diff --git a/tests/Commands/ControllerMakeCommandTest.php b/tests/Commands/ControllerMakeCommandTest.php index 13d8b973c..b9cd957bb 100644 --- a/tests/Commands/ControllerMakeCommandTest.php +++ b/tests/Commands/ControllerMakeCommandTest.php @@ -9,6 +9,7 @@ class ControllerMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -21,9 +22,10 @@ class ControllerMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + } public function tearDown(): void @@ -77,8 +79,8 @@ public function it_generates_a_plain_controller() { $code = $this->artisan('module:make-controller', [ 'controller' => 'MyController', - 'module' => 'Blog', - '--plain' => true, + 'module' => 'Blog', + '--plain' => true, ]); $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); @@ -92,8 +94,8 @@ public function it_generates_an_api_controller() { $code = $this->artisan('module:make-controller', [ 'controller' => 'MyController', - 'module' => 'Blog', - '--api' => true, + 'module' => 'Blog', + '--api' => true, ]); $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); @@ -109,7 +111,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Controllers/MyController.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/DisableCommandTest.php b/tests/Commands/DisableCommandTest.php index 840055c8b..b5ddb4aff 100644 --- a/tests/Commands/DisableCommandTest.php +++ b/tests/Commands/DisableCommandTest.php @@ -8,17 +8,20 @@ class DisableCommandTest extends BaseTestCase { + private RepositoryInterface $repository; + public function setUp(): void { parent::setUp(); - $this->artisan('module:make', ['name' => ['Blog']]); - $this->artisan('module:make', ['name' => ['Taxonomy']]); + $this->createModule('Blog'); + $this->createModule('Taxonomy'); + $this->repository = $this->app[RepositoryInterface::class]; } public function tearDown(): void { - $this->app[RepositoryInterface::class]->delete('Blog'); - $this->app[RepositoryInterface::class]->delete('Taxonomy'); + $this->repository->delete('Blog'); + $this->repository->delete('Taxonomy'); parent::tearDown(); } @@ -26,7 +29,7 @@ public function tearDown(): void public function it_disables_a_module() { /** @var Module $blogModule */ - $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule = $this->repository->find('Blog'); $blogModule->disable(); $code = $this->artisan('module:disable', ['module' => ['Blog']]); @@ -39,14 +42,14 @@ public function it_disables_a_module() public function it_disables_array_of_modules() { /** @var Module $blogModule */ - $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule = $this->repository->find('Blog'); $blogModule->enable(); /** @var Module $taxonomyModule */ - $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); + $taxonomyModule = $this->repository->find('Taxonomy'); $taxonomyModule->enable(); - $code = $this->artisan('module:disable',['module' => ['Blog','Taxonomy']]); + $code = $this->artisan('module:disable', ['module' => ['Blog', 'Taxonomy']]); $this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled()); $this->assertSame(0, $code); @@ -56,14 +59,14 @@ public function it_disables_array_of_modules() public function it_disables_all_modules() { /** @var Module $blogModule */ - $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule = $this->repository->find('Blog'); $blogModule->enable(); /** @var Module $taxonomyModule */ - $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); + $taxonomyModule = $this->repository->find('Taxonomy'); $taxonomyModule->enable(); - $code = $this->artisan('module:disable',['--all' => true]); + $code = $this->artisan('module:disable', ['--all' => true]); $this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled()); $this->assertSame(0, $code); diff --git a/tests/Commands/EnableCommandTest.php b/tests/Commands/EnableCommandTest.php index 516b0371f..688d4ec22 100644 --- a/tests/Commands/EnableCommandTest.php +++ b/tests/Commands/EnableCommandTest.php @@ -8,17 +8,20 @@ class EnableCommandTest extends BaseTestCase { + private RepositoryInterface $repository; + public function setUp(): void { parent::setUp(); - $this->artisan('module:make', ['name' => ['Blog']]); - $this->artisan('module:make', ['name' => ['Taxonomy']]); + $this->createModule('Blog'); + $this->createModule('Taxonomy'); + $this->repository = $this->app[RepositoryInterface::class]; } public function tearDown(): void { - $this->app[RepositoryInterface::class]->delete('Blog'); - $this->app[RepositoryInterface::class]->delete('Taxonomy'); + $this->repository->delete('Blog'); + $this->repository->delete('Taxonomy'); parent::tearDown(); } @@ -26,7 +29,7 @@ public function tearDown(): void public function it_enables_a_module() { /** @var Module $blogModule */ - $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule = $this->repository->find('Blog'); $blogModule->disable(); $code = $this->artisan('module:enable', ['module' => 'Blog']); @@ -35,15 +38,32 @@ public function it_enables_a_module() $this->assertSame(0, $code); } + /** @test */ + public function it_enables_array_of_modules() + { + /** @var Module $blogModule */ + $blogModule = $this->repository->find('Blog'); + $blogModule->disable(); + + /** @var Module $taxonomyModule */ + $taxonomyModule = $this->repository->find('Taxonomy'); + $taxonomyModule->disable(); + + $code = $this->artisan('module:enable', ['module' => ['Blog', 'Taxonomy']]); + + $this->assertTrue($blogModule->isEnabled() && $taxonomyModule->isEnabled()); + $this->assertSame(0, $code); + } + /** @test */ public function it_enables_all_modules() { /** @var Module $blogModule */ - $blogModule = $this->app[RepositoryInterface::class]->find('Blog'); + $blogModule = $this->repository->find('Blog'); $blogModule->disable(); /** @var Module $taxonomyModule */ - $taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy'); + $taxonomyModule = $this->repository->find('Taxonomy'); $taxonomyModule->disable(); $code = $this->artisan('module:enable', ['--all' => true]); From c24a8c959e6d159ca226020627c4370fe0f65984 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 15 Mar 2024 23:16:18 +0330 Subject: [PATCH 204/422] [test] fix test of commands --- tests/Commands/EventMakeCommandTest.php | 6 +-- tests/Commands/FactoryMakeCommandTest.php | 6 +-- tests/Commands/JobMakeCommandTest.php | 6 +-- tests/Commands/ListCommandTest.php | 10 +---- tests/Commands/ListenerMakeCommandTest.php | 6 +-- tests/Commands/MailMakeCommandTest.php | 6 +-- tests/Commands/MiddlewareMakeCommandTest.php | 6 +-- tests/Commands/MigrationMakeCommandTest.php | 30 ++++++------- tests/Commands/ModelMakeCommandTest.php | 30 ++++++------- tests/Commands/ModuleDeleteCommandTest.php | 47 +++++++++++++++++++- 10 files changed, 96 insertions(+), 57 deletions(-) diff --git a/tests/Commands/EventMakeCommandTest.php b/tests/Commands/EventMakeCommandTest.php index 906c27313..6c67c2146 100644 --- a/tests/Commands/EventMakeCommandTest.php +++ b/tests/Commands/EventMakeCommandTest.php @@ -22,9 +22,9 @@ class EventMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -60,7 +60,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperEvents/PostWasCreated.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperEvents/PostWasCreated.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/FactoryMakeCommandTest.php b/tests/Commands/FactoryMakeCommandTest.php index caf39f153..5db22855d 100644 --- a/tests/Commands/FactoryMakeCommandTest.php +++ b/tests/Commands/FactoryMakeCommandTest.php @@ -21,9 +21,9 @@ class FactoryMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -37,7 +37,7 @@ public function it_makes_factory() { $code = $this->artisan('module:make-factory', ['name' => 'Post', 'module' => 'Blog']); - $factoryFile = $this->modulePath . '/Database/factories/PostFactory.php'; + $factoryFile = $this->getModuleBasePath() . '/database/factories/PostFactory.php'; $this->assertTrue(is_file($factoryFile), 'Factory file was not created.'); $this->assertMatchesSnapshot($this->finder->get($factoryFile)); diff --git a/tests/Commands/JobMakeCommandTest.php b/tests/Commands/JobMakeCommandTest.php index 30a044582..88588dfa0 100644 --- a/tests/Commands/JobMakeCommandTest.php +++ b/tests/Commands/JobMakeCommandTest.php @@ -21,9 +21,9 @@ class JobMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -70,7 +70,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperJobs/SomeJob.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperJobs/SomeJob.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ListCommandTest.php b/tests/Commands/ListCommandTest.php index 90d058708..5bc5904e8 100644 --- a/tests/Commands/ListCommandTest.php +++ b/tests/Commands/ListCommandTest.php @@ -2,16 +2,11 @@ namespace Nwidart\Modules\Commands; -use Illuminate\Filesystem\Filesystem; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; class ListCommandTest extends BaseTestCase { - /** - * @var Filesystem - */ - private $finder; /** * @var string */ @@ -20,9 +15,8 @@ class ListCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); - $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void diff --git a/tests/Commands/ListenerMakeCommandTest.php b/tests/Commands/ListenerMakeCommandTest.php index 6815a5067..3bc70ef22 100644 --- a/tests/Commands/ListenerMakeCommandTest.php +++ b/tests/Commands/ListenerMakeCommandTest.php @@ -22,9 +22,9 @@ class ListenerMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -139,7 +139,7 @@ public function it_can_change_the_default_namespace() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog'] ); - $file = $this->finder->get($this->modulePath . '/Events/Handlers/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/Events/Handlers/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/MailMakeCommandTest.php b/tests/Commands/MailMakeCommandTest.php index e88697adb..b26748214 100644 --- a/tests/Commands/MailMakeCommandTest.php +++ b/tests/Commands/MailMakeCommandTest.php @@ -21,9 +21,9 @@ class MailMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -59,7 +59,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperEmails/SomeMail.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperEmails/SomeMail.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/MiddlewareMakeCommandTest.php b/tests/Commands/MiddlewareMakeCommandTest.php index 157d6e5ae..197c17855 100644 --- a/tests/Commands/MiddlewareMakeCommandTest.php +++ b/tests/Commands/MiddlewareMakeCommandTest.php @@ -21,9 +21,9 @@ class MiddlewareMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -59,7 +59,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Middleware/SomeMiddleware.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/Middleware/SomeMiddleware.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/MigrationMakeCommandTest.php b/tests/Commands/MigrationMakeCommandTest.php index 483240436..88416613d 100644 --- a/tests/Commands/MigrationMakeCommandTest.php +++ b/tests/Commands/MigrationMakeCommandTest.php @@ -21,9 +21,9 @@ class MigrationMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleBasePath(); } public function tearDown(): void @@ -37,7 +37,7 @@ public function it_generates_a_new_migration_class() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); - $files = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $files = $this->finder->allFiles($this->modulePath . '/database/migrations'); $this->assertCount(1, $files); $this->assertSame(0, $code); @@ -48,9 +48,9 @@ public function it_generates_correct_create_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName); + $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -61,9 +61,9 @@ public function it_generates_correct_add_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'add_something_to_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName); + $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -74,9 +74,9 @@ public function it_generates_correct_delete_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'delete_something_from_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName); + $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -87,9 +87,9 @@ public function it_generates_correct_drop_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'drop_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName); + $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -100,9 +100,9 @@ public function it_generates_correct_default_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'something_random_name', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName); + $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -113,9 +113,9 @@ public function it_generates_foreign_key_constraints() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog', '--fields' => 'belongsTo:user:id:users']); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/Database/Migrations/' . $fileName); + $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ModelMakeCommandTest.php b/tests/Commands/ModelMakeCommandTest.php index b4dd59ff7..e3b7819a5 100644 --- a/tests/Commands/ModelMakeCommandTest.php +++ b/tests/Commands/ModelMakeCommandTest.php @@ -22,9 +22,9 @@ class ModelMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -38,7 +38,7 @@ public function it_generates_a_new_model_class() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Entities/Post.php')); + $this->assertTrue(is_file($this->modulePath . '/Models/Post.php')); $this->assertSame(0, $code); } @@ -47,7 +47,7 @@ public function it_generated_correct_file_with_content() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Entities/Post.php'); + $file = $this->finder->get($this->modulePath . '/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -58,7 +58,7 @@ public function it_generates_correct_fillable_fields() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--fillable' => 'title,slug']); - $file = $this->finder->get($this->modulePath . '/Entities/Post.php'); + $file = $this->finder->get($this->modulePath . '/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -69,9 +69,9 @@ public function it_generates_migration_file_with_model() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--migration' => true]); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->modulePath . '/Database/Migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); $this->assertCount(1, $migrations); $this->assertMatchesSnapshot($migrationContent); $this->assertSame(0, $code); @@ -82,9 +82,9 @@ public function it_generates_migration_file_with_model_using_shortcut_option() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-m' => true]); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->modulePath . '/Database/Migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); $this->assertCount(1, $migrations); $this->assertMatchesSnapshot($migrationContent); $this->assertSame(0, $code); @@ -126,9 +126,9 @@ public function it_generates_controller_and_migration_when_both_flags_are_presen $this->assertCount(2, $controllers); $this->assertMatchesSnapshot($controllerContent); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->modulePath . '/Database/Migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); $this->assertCount(1, $migrations); $this->assertMatchesSnapshot($migrationContent); @@ -140,9 +140,9 @@ public function it_generates_correct_migration_file_name_with_multiple_words_mod { $code = $this->artisan('module:make-model', ['model' => 'ProductDetail', 'module' => 'Blog', '-m' => true]); - $migrations = $this->finder->allFiles($this->modulePath . '/Database/Migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->modulePath . '/Database/Migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); $this->assertStringContainsString('create_product_details_table', $migrationFile->getFilename()); $this->assertMatchesSnapshot($migrationContent); @@ -166,7 +166,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Models/Post.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -179,7 +179,7 @@ public function it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Entities/Post.php'); + $file = $this->finder->get($this->modulePath . '/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ModuleDeleteCommandTest.php b/tests/Commands/ModuleDeleteCommandTest.php index 939ec52d9..083dec1c7 100644 --- a/tests/Commands/ModuleDeleteCommandTest.php +++ b/tests/Commands/ModuleDeleteCommandTest.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules\Commands; use Nwidart\Modules\Activators\FileActivator; +use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; use Spatie\Snapshots\MatchesSnapshots; @@ -22,7 +23,7 @@ class ModuleDeleteCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->finder = $this->app['files']; + $this->finder = $this->app['files']; $this->activator = new FileActivator($this->app); } @@ -37,6 +38,50 @@ public function it_can_delete_a_module_from_disk(): void $this->assertSame(0, $code); } + /** @test */ + public function it_can_delete_array_module_from_disk(): void + { + $modules = [ + 'Foo', + 'Bar', + 'Zoo', + ]; + + foreach ($modules as $module) { + $this->createModule($module); + $this->assertDirectoryExists($this->getModuleBasePath($module)); + } + + $code = $this->artisan('module:delete', ['module' => ['Foo', 'Bar']]); + $this->assertSame(0, $code); + $this->assertFileDoesNotExist($this->getModuleBasePath('Foo')); + $this->assertFileDoesNotExist($this->getModuleBasePath('Bar')); + $this->assertDirectoryExists($this->getModuleBasePath('Zoo')); + + $this->app[RepositoryInterface::class]->delete('Zoo'); + } + + /** @test */ + public function it_can_delete_all_module_from_disk(): void + { + $modules = [ + 'Foo', + 'Bar', + 'Zoo', + ]; + + foreach ($modules as $module) { + $this->createModule($module); + $this->assertDirectoryExists($this->getModuleBasePath($module)); + } + + $code = $this->artisan('module:delete', ['--all' => true]); + $this->assertSame(0, $code); + $this->assertFileDoesNotExist($this->getModuleBasePath('Foo')); + $this->assertFileDoesNotExist($this->getModuleBasePath('Bar')); + $this->assertFileDoesNotExist($this->getModuleBasePath('Zoo')); + } + /** @test */ public function it_deletes_modules_from_status_file(): void { From a7dad27dc219ae7203d2736bf3afd5ba5c828407 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 16 Mar 2024 00:07:24 +0330 Subject: [PATCH 205/422] [test] fix test other commands --- tests/BaseTestCase.php | 10 +- tests/Commands/ModuleMakeCommandTest.php | 97 ++++++++++--------- .../Commands/NotificationMakeCommandTest.php | 6 +- tests/Commands/ObserverMakeCommandTest.php | 5 +- tests/Commands/PolicyMakeCommandTest.php | 6 +- tests/Commands/ProviderMakeCommandTest.php | 4 +- tests/Commands/PublishCommandTest.php | 6 +- .../Commands/PublishMigrationCommandTest.php | 4 +- .../PublishTranslationCommandTest.php | 4 +- tests/Commands/RequestMakeCommandTest.php | 6 +- tests/Commands/ResourceMakeCommandTest.php | 6 +- .../Commands/RouteProviderMakeCommandTest.php | 8 +- tests/Commands/RuleMakeCommandTest.php | 6 +- tests/Commands/TestMakeCommandTest.php | 31 +++--- tests/GenerateConfigReaderTest.php | 2 +- tests/HelpersTest.php | 7 +- 16 files changed, 109 insertions(+), 99 deletions(-) diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 4b72fff71..e43f49236 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -43,10 +43,10 @@ protected function getEnvironmentSetUp($app) // enable all generators array_walk($module_config['paths']['generator'], function (&$item) { - $item['generate'] = TRUE; + $item['generate'] = true; }); - $app['config']->set('app.asset_url', NULL); + $app['config']->set('app.asset_url', null); $app['config']->set('database.default', 'sqlite'); $app['config']->set('database.connections.sqlite', [ 'driver' => 'sqlite', @@ -62,7 +62,7 @@ protected function getEnvironmentSetUp($app) 'generator' => $module_config['paths']['generator'], ]); - $app['config']->set('modules.composer-output', TRUE); + $app['config']->set('modules.composer-output', true); $app['config']->set('modules.commands', ConsoleServiceProvider::defaultCommands()->toArray()); } @@ -72,9 +72,9 @@ protected function setUpDatabase() $this->resetDatabase(); } - protected function createModule(string $moduleName = 'Blog'): void + protected function createModule(string $moduleName = 'Blog'): int { - $this->artisan('module:make', ['name' => [$moduleName]]); + return $this->artisan('module:make', ['name' => [$moduleName]]); } protected function getModuleAppPath(string $moduleName = 'Blog'): string diff --git a/tests/Commands/ModuleMakeCommandTest.php b/tests/Commands/ModuleMakeCommandTest.php index 0fcbc0966..aaf786d7e 100644 --- a/tests/Commands/ModuleMakeCommandTest.php +++ b/tests/Commands/ModuleMakeCommandTest.php @@ -12,6 +12,7 @@ class ModuleMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -33,10 +34,10 @@ class ModuleMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); - $this->finder = $this->app['files']; + $this->modulePath = $this->getModuleBasePath(); + $this->finder = $this->app['files']; $this->repository = $this->app[RepositoryInterface::class]; - $this->activator = $this->app[ActivatorInterface::class]; + $this->activator = $this->app[ActivatorInterface::class]; } public function tearDown(): void @@ -88,7 +89,7 @@ public function it_generates_module_files() public function it_generates_web_route_file() { $files = $this->app['modules']->config('stubs.files'); - $code = $this->artisan('module:make', ['name' => ['Blog']]); + $code = $this->artisan('module:make', ['name' => ['Blog']]); $path = $this->modulePath . '/' . $files['routes/web']; @@ -100,7 +101,7 @@ public function it_generates_web_route_file() public function it_generates_api_route_file() { $files = $this->app['modules']->config('stubs.files'); - $code = $this->artisan('module:make', ['name' => ['Blog']]); + $code = $this->artisan('module:make', ['name' => ['Blog']]); $path = $this->modulePath . '/' . $files['routes/api']; @@ -124,19 +125,19 @@ public function it_generates_module_resources() { $code = $this->artisan('module:make', ['name' => ['Blog']]); - $path = base_path('modules/Blog') . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Database/Seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); @@ -168,7 +169,7 @@ public function it_generates_module_namespace_using_studly_case() { $code = $this->artisan('module:make', ['name' => ['ModuleName']]); - $file = $this->finder->get(base_path('modules/ModuleName') . '/Providers/ModuleNameServiceProvider.php'); + $file = $this->finder->get($this->getModuleAppPath('ModuleName') . '/Providers/ModuleNameServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -210,7 +211,7 @@ public function it_generates_plain_module_with_no_service_provider_in_modulejson { $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); - $path = base_path('modules/ModuleName') . '/module.json'; + $path = base_path('modules/ModuleName') . '/module.json'; $content = json_decode($this->finder->get($path)); $this->assertCount(0, $content->providers); @@ -223,7 +224,7 @@ public function it_outputs_error_when_module_exists() $this->artisan('module:make', ['name' => ['Blog']]); $code = $this->artisan('module:make', ['name' => ['Blog']]); - $output = Artisan::output(); + $output = Artisan::output(); $expected = 'ERROR Module [Blog] already exists!'; $this->assertTrue(Str::contains($output, $expected)); @@ -250,29 +251,29 @@ public function it_still_generates_module_if_it_exists_using_force_flag() public function it_can_generate_module_with_old_config_format() { $this->app['config']->set('modules.paths.generator', [ - 'assets' => 'Assets', - 'config' => 'Config', - 'command' => 'Console', - 'event' => 'Events', - 'listener' => 'Listeners', - 'migration' => 'Database/Migrations', - 'factory' => 'Database/factories', - 'model' => 'Entities', - 'repository' => 'Repositories', - 'seeder' => 'Database/Seeders', - 'controller' => 'Http/Controllers', - 'filter' => 'Http/Middleware', - 'request' => 'Http/Requests', - 'provider' => 'Providers', - 'lang' => 'Resources/lang', - 'views' => 'Resources/views', - 'policies' => false, - 'rules' => false, - 'test' => 'Tests', - 'jobs' => 'Jobs', - 'emails' => 'Emails', + 'assets' => 'Assets', + 'config' => 'Config', + 'command' => 'Console', + 'event' => 'Events', + 'listener' => 'Listeners', + 'migration' => 'Database/Migrations', + 'factory' => 'Database/factories', + 'model' => 'Entities', + 'repository' => 'Repositories', + 'seeder' => 'Database/Seeders', + 'controller' => 'Http/Controllers', + 'filter' => 'Http/Middleware', + 'request' => 'Http/Requests', + 'provider' => 'Providers', + 'lang' => 'Resources/lang', + 'views' => 'Resources/views', + 'policies' => false, + 'rules' => false, + 'test' => 'Tests', + 'jobs' => 'Jobs', + 'emails' => 'Emails', 'notifications' => 'Notifications', - 'resource' => false, + 'resource' => false, ]); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -363,65 +364,67 @@ public function it_generates_web_module_with_resources() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--web' => true]); - $path = base_path('modules/Blog') . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Database/Seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); $this->assertSame(0, $code); } + /** @test */ public function it_generates_api_module_with_resources() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true]); - $path = base_path('modules/Blog') . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Database/Seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); $this->assertSame(0, $code); } + /** @test */ public function it_generates_web_module_with_resources_when_adding_more_than_one_option() { - $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true,'--plain'=>true]); + $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true, '--plain' => true]); - $path = base_path('modules/Blog') . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Database/Seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = base_path('modules/Blog') . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); diff --git a/tests/Commands/NotificationMakeCommandTest.php b/tests/Commands/NotificationMakeCommandTest.php index 61d19cedb..3831495d2 100644 --- a/tests/Commands/NotificationMakeCommandTest.php +++ b/tests/Commands/NotificationMakeCommandTest.php @@ -21,9 +21,9 @@ class NotificationMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -59,7 +59,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperNotifications/WelcomeNotification.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperNotifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ObserverMakeCommandTest.php b/tests/Commands/ObserverMakeCommandTest.php index ab0a78f67..2afaca853 100644 --- a/tests/Commands/ObserverMakeCommandTest.php +++ b/tests/Commands/ObserverMakeCommandTest.php @@ -21,9 +21,9 @@ class ObserverMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -38,7 +38,6 @@ public function it_makes_observer() $code = $this->artisan('module:make-observer', ['name' => 'Post', 'module' => 'Blog']); $observerFile = $this->modulePath . '/Observers/PostObserver.php'; - // dd($observerFile); $this->assertTrue(is_file($observerFile), 'Observer file was not created.'); $this->assertMatchesSnapshot($this->finder->get($observerFile)); diff --git a/tests/Commands/PolicyMakeCommandTest.php b/tests/Commands/PolicyMakeCommandTest.php index 493582cc8..a75f3aa09 100644 --- a/tests/Commands/PolicyMakeCommandTest.php +++ b/tests/Commands/PolicyMakeCommandTest.php @@ -21,9 +21,9 @@ class PolicyMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -51,7 +51,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-policy', ['name' => 'PostPolicy', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperPolicies/PostPolicy.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperPolicies/PostPolicy.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ProviderMakeCommandTest.php b/tests/Commands/ProviderMakeCommandTest.php index d9a7ef2ac..f93f1b383 100644 --- a/tests/Commands/ProviderMakeCommandTest.php +++ b/tests/Commands/ProviderMakeCommandTest.php @@ -21,8 +21,8 @@ class ProviderMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; + $this->modulePath = $this->getModuleAppPath(); $this->artisan('module:make', ['name' => ['Blog'], '--plain' => true, ]); } @@ -81,7 +81,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); - $file = $this->finder->get($this->modulePath . '/SuperProviders/BlogServiceProvider.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperProviders/BlogServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/PublishCommandTest.php b/tests/Commands/PublishCommandTest.php index d9c0b03cf..cb55385af 100644 --- a/tests/Commands/PublishCommandTest.php +++ b/tests/Commands/PublishCommandTest.php @@ -19,10 +19,10 @@ class PublishCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); + $this->createModule(); + $this->modulePath = $this->getModuleBasePath(); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); - $this->finder->put($this->modulePath . '/Assets/script.js', 'assetfile'); + $this->finder->put($this->modulePath . '/resources/assets/script.js', 'assetfile'); } public function tearDown(): void diff --git a/tests/Commands/PublishMigrationCommandTest.php b/tests/Commands/PublishMigrationCommandTest.php index bca073d65..fa5ba1897 100644 --- a/tests/Commands/PublishMigrationCommandTest.php +++ b/tests/Commands/PublishMigrationCommandTest.php @@ -19,9 +19,9 @@ class PublishMigrationCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); } diff --git a/tests/Commands/PublishTranslationCommandTest.php b/tests/Commands/PublishTranslationCommandTest.php index b1136831b..6f0b73fe3 100644 --- a/tests/Commands/PublishTranslationCommandTest.php +++ b/tests/Commands/PublishTranslationCommandTest.php @@ -19,9 +19,9 @@ class PublishTranslationCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void diff --git a/tests/Commands/RequestMakeCommandTest.php b/tests/Commands/RequestMakeCommandTest.php index 87f7a743a..bb5a81249 100644 --- a/tests/Commands/RequestMakeCommandTest.php +++ b/tests/Commands/RequestMakeCommandTest.php @@ -21,9 +21,9 @@ class RequestMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -59,7 +59,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperRequests/CreateBlogPostRequest.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperRequests/CreateBlogPostRequest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/ResourceMakeCommandTest.php b/tests/Commands/ResourceMakeCommandTest.php index b3b01323b..1ac05bf67 100644 --- a/tests/Commands/ResourceMakeCommandTest.php +++ b/tests/Commands/ResourceMakeCommandTest.php @@ -21,9 +21,9 @@ class ResourceMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -66,7 +66,7 @@ public function it_can_generate_a_collection_resource_class() /** @test */ public function it_can_change_the_default_namespace() { - $this->app['config']->set('modules.paths.generator.resource.path', 'Http/Resources'); + $this->app['config']->set('modules.paths.generator.resource.path', 'app/Http/Resources'); $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog', '--collection' => true]); diff --git a/tests/Commands/RouteProviderMakeCommandTest.php b/tests/Commands/RouteProviderMakeCommandTest.php index abd59d775..f69a05f12 100644 --- a/tests/Commands/RouteProviderMakeCommandTest.php +++ b/tests/Commands/RouteProviderMakeCommandTest.php @@ -21,9 +21,9 @@ class RouteProviderMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -63,7 +63,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:route-provider', ['module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperProviders/RouteServiceProvider.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperProviders/RouteServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -118,7 +118,7 @@ public function it_can_change_the_custom_controller_namespace(): void $this->app['config']->set('modules.paths.generator.provider.path', 'Base/Providers'); $code = $this->artisan('module:route-provider', ['module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Base/Providers/RouteServiceProvider.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/Base/Providers/RouteServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/RuleMakeCommandTest.php b/tests/Commands/RuleMakeCommandTest.php index a3b58641e..b961f115b 100644 --- a/tests/Commands/RuleMakeCommandTest.php +++ b/tests/Commands/RuleMakeCommandTest.php @@ -21,9 +21,9 @@ class RuleMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void @@ -63,7 +63,7 @@ public function it_can_change_the_default_namespace() $code = $this->artisan('module:make-rule', ['name' => 'UniqueRule', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperRules/UniqueRule.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperRules/UniqueRule.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/TestMakeCommandTest.php b/tests/Commands/TestMakeCommandTest.php index bde53c84a..ff87c4689 100644 --- a/tests/Commands/TestMakeCommandTest.php +++ b/tests/Commands/TestMakeCommandTest.php @@ -27,9 +27,9 @@ class TestMakeCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleBasePath(); $this->activator = $this->app[ActivatorInterface::class]; } @@ -41,13 +41,20 @@ public function tearDown(): void } /** @test */ - public function it_generates_a_new_test_class() + public function it_generates_a_new_unit_test_class() + { + $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/tests/Unit/EloquentPostRepositoryTest.php')); + $this->assertSame(0, $code); + } + + /** @test */ + public function it_generates_a_new_feature_test_class() { - $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $this->assertTrue(is_file($this->modulePath . '/Tests/Unit/EloquentPostRepositoryTest.php')); - $this->assertTrue(is_file($this->modulePath . '/Tests/Feature/EloquentPostRepositoryTest.php')); + $this->assertTrue(is_file($this->modulePath . '/tests/Feature/EloquentPostRepositoryTest.php')); $this->assertSame(0, $code); } @@ -56,7 +63,7 @@ public function it_generated_correct_unit_file_with_content() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Tests/Unit/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath . '/tests/Unit/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -67,7 +74,7 @@ public function it_generated_correct_feature_file_with_content() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $file = $this->finder->get($this->modulePath . '/Tests/Feature/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath . '/tests/Feature/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -76,11 +83,11 @@ public function it_generated_correct_feature_file_with_content() /** @test */ public function it_can_change_the_default_unit_namespace() { - $this->app['config']->set('modules.paths.generator.test.path', 'SuperTests/Unit'); + $this->app['config']->set('modules.paths.generator.test-unit.path', 'SuperTests/Unit'); $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/SuperTests/Unit/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/SuperTests/Unit/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -93,7 +100,7 @@ public function it_can_change_the_default_unit_namespace_specific() $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Tests/Unit/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath . '/tests/Unit/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -119,7 +126,7 @@ public function it_can_change_the_default_feature_namespace_specific() $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $file = $this->finder->get($this->modulePath . '/Tests/Feature/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->getModuleBasePath() . '/tests/Feature/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/GenerateConfigReaderTest.php b/tests/GenerateConfigReaderTest.php index 427108701..6b0e3a050 100644 --- a/tests/GenerateConfigReaderTest.php +++ b/tests/GenerateConfigReaderTest.php @@ -13,7 +13,7 @@ public function it_can_read_a_configuration_value_with_new_format() $seedConfig = GenerateConfigReader::read('seeder'); $this->assertInstanceOf(GeneratorPath::class, $seedConfig); - $this->assertEquals('Database/Seeders', $seedConfig->getPath()); + $this->assertEquals('database/seeders', $seedConfig->getPath()); $this->assertTrue($seedConfig->generate()); } diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php index eaf7e790e..4c7f0751e 100644 --- a/tests/HelpersTest.php +++ b/tests/HelpersTest.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules\Tests; use Illuminate\Support\Str; +use Nwidart\Modules\Contracts\RepositoryInterface; class HelpersTest extends BaseTestCase { @@ -18,14 +19,14 @@ class HelpersTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->modulePath = base_path('modules/Blog'); $this->finder = $this->app['files']; - $this->artisan('module:make', ['name' => ['Blog']]); + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); } public function tearDown(): void { - $this->finder->deleteDirectory($this->modulePath); + $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); } From 84b896470cafde5ca602198dff5e15717fc558db Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 16 Mar 2024 00:07:56 +0330 Subject: [PATCH 206/422] [fix] fix command create unit test and path --- src/Commands/Make/TestMakeCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/TestMakeCommand.php b/src/Commands/Make/TestMakeCommand.php index e05a2f50f..6994769b7 100644 --- a/src/Commands/Make/TestMakeCommand.php +++ b/src/Commands/Make/TestMakeCommand.php @@ -21,11 +21,11 @@ public function getDefaultNamespace(): string { if ($this->option('feature')) { return config('modules.paths.generator.test-feature.namespace') - ?? config('modules.paths.generator.test-feature.path', 'Tests/Feature'); + ?? config('modules.paths.generator.test-feature.path', 'tests/Feature'); } return config('modules.paths.generator.test-unit.namespace') - ?? config('modules.paths.generator.test-unit.path', 'Tests/Unit'); + ?? config('modules.paths.generator.test-unit.path', 'tests/Unit'); } /** @@ -81,7 +81,7 @@ protected function getDestinationFilePath() if ($this->option('feature')) { $testPath = GenerateConfigReader::read('test-feature'); } else { - $testPath = GenerateConfigReader::read('test'); + $testPath = GenerateConfigReader::read('test-unit'); } return $path . $testPath->getPath() . '/' . $this->getFileName() . '.php'; From 7348a5fd934553eb35c2b4d742480db4733ffeb7 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 16 Mar 2024 00:08:38 +0330 Subject: [PATCH 207/422] [fix] fix transformer path on config file --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 4d95c76ed..ef0d5e00f 100644 --- a/config/config.php +++ b/config/config.php @@ -125,7 +125,7 @@ 'policies' => ['path' => 'app/Policies', 'generate' => false], 'provider' => ['path' => 'app/Providers', 'generate' => true], 'repository' => ['path' => 'app/Repositories', 'generate' => false], - 'resource' => ['path' => 'app/resources', 'generate' => false], + 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], // app/HTTP folder From 66421ea1fedf2af9f9f7583af9bd241edfa156b8 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 16 Mar 2024 00:08:54 +0330 Subject: [PATCH 208/422] [test] update tests snapshots --- ...dTest__it_can_change_the_default_namespace__1.txt | 2 +- ...dTest__it_can_change_the_default_namespace__1.txt | 2 +- ...st__it_generated_correct_file_with_content__1.txt | 2 +- .../FactoryMakeCommandTest__it_makes_factory__1.txt | 4 ++-- ...ueued_event_in_a_subdirectory_with_content__1.txt | 2 +- ...enerated_correct_queued_event_with_content__1.txt | 2 +- ..._sync_event_in_a_subdirectory_with_content__1.txt | 2 +- ..._generated_correct_sync_event_with_content__1.txt | 2 +- ...st__it_generated_correct_file_with_content__1.txt | 2 +- ...Test__it_generates_correct_fillable_fields__1.txt | 2 +- ...st__it_generates_api_module_with_resources__1.txt | 12 ++++++------ ...st__it_generates_api_module_with_resources__3.txt | 2 +- ...st__it_generates_api_module_with_resources__4.txt | 2 +- ...nerates_module_namespace_using_studly_case__1.txt | 12 ++++++------ ...CommandTest__it_generates_module_resources__1.txt | 12 ++++++------ ...CommandTest__it_generates_module_resources__3.txt | 2 +- ...CommandTest__it_generates_module_resources__4.txt | 2 +- ...st__it_generates_web_module_with_resources__1.txt | 12 ++++++------ ...st__it_generates_web_module_with_resources__3.txt | 2 +- ...st__it_generates_web_module_with_resources__4.txt | 2 +- ...resources_when_adding_more_than_one_option__1.txt | 12 ++++++------ ...resources_when_adding_more_than_one_option__3.txt | 2 +- ...resources_when_adding_more_than_one_option__4.txt | 2 +- ...ObserverMakeCommandTest__it_makes_observer__1.txt | 2 +- ...dTest__it_can_change_the_default_namespace__1.txt | 12 ++++++------ ..._can_change_the_default_namespace_specific__1.txt | 12 ++++++------ ..._custom_migration_resources_location_paths__1.txt | 10 +++++----- ...ter_service_provider_with_resource_loading__1.txt | 12 ++++++------ ...dTest__it_can_change_the_default_namespace__1.txt | 2 +- ..._can_change_the_default_namespace_specific__1.txt | 2 +- ...iderMakeCommandTest__it_can_overwrite_file__1.txt | 2 +- ...andTest__it_can_overwrite_route_file_names__1.txt | 2 +- ...st__it_generated_correct_file_with_content__1.txt | 2 +- ...__it_can_change_the_default_unit_namespace__1.txt | 2 +- ...change_the_default_unit_namespace_specific__1.txt | 2 +- ...enerated_correct_feature_file_with_content__1.txt | 2 +- ...t_generated_correct_unit_file_with_content__1.txt | 2 +- 37 files changed, 82 insertions(+), 82 deletions(-) diff --git a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt index 454a9fbc5..4a142f902 100644 --- a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -1,6 +1,6 @@ registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt index 97e7e2a48..6abbddde9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt @@ -1,6 +1,6 @@ registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class ModuleNameServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class ModuleNameServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class ModuleNameServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt index 39c7fa448..ad1ad48fd 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt @@ -21,7 +21,7 @@ class BlogServiceProvider extends ServiceProvider $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt index 97e7e2a48..6abbddde9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt @@ -1,6 +1,6 @@ registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt index 97e7e2a48..6abbddde9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt @@ -1,6 +1,6 @@ registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt index 97e7e2a48..6abbddde9 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt @@ -1,6 +1,6 @@ registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index c310c307c..b4c6f48d6 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -21,7 +21,7 @@ class BlogServiceProvider extends ServiceProvider $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt index e75371fbd..4f132a028 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt index 39c7fa448..ad1ad48fd 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -21,7 +21,7 @@ class BlogServiceProvider extends ServiceProvider $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); } /** @@ -62,8 +62,8 @@ class BlogServiceProvider extends ServiceProvider $this->loadTranslationsFrom($langPath, $this->moduleNameLower); $this->loadJsonTranslationsFrom($langPath); } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang')); + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); } } @@ -72,8 +72,8 @@ class BlogServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower); + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); } /** @@ -82,7 +82,7 @@ class BlogServiceProvider extends ServiceProvider public function registerViews(): void { $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'Resources/views'); + $sourcePath = module_path($this->moduleName, 'resources/views'); $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt index b93942cfe..4d24c8e15 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index b93942cfe..4d24c8e15 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt index 40a5982cb..68d0fd9d6 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt index 2abee95ad..10aaad55e 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt index f1dfe5127..bab850316 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\Http\Controllers'; + protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt index fcbfc0da3..273dc9657 100644 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt @@ -1,6 +1,6 @@ Date: Sat, 16 Mar 2024 23:40:18 +0000 Subject: [PATCH 209/422] removed stale github action --- .github/stale.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 3b6ae488c..000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 15 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security -# Label to use when marking an issue as stale -staleLabel: stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false From cac79320be923f58dc39cf99d24309696f861b6a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 16 Mar 2024 20:46:43 -0700 Subject: [PATCH 210/422] Update config.php Ensure comment normalization and consistency. --- config/config.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/config.php b/config/config.php index ef0d5e00f..fb1581182 100644 --- a/config/config.php +++ b/config/config.php @@ -112,7 +112,7 @@ | Setting the generate key to false will not generate that folder */ 'generator' => [ - // app folder + // app/ 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], @@ -128,31 +128,31 @@ 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], - // app/HTTP folder + // app/HTTP/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], 'filter' => ['path' => 'app/Http/Middleware', 'generate' => false], 'request' => ['path' => 'app/Http/Requests', 'generate' => false], - // config Folder + // config/ 'config' => ['path' => 'config', 'generate' => true], - // Database + // database/ 'migration' => ['path' => 'database/migrations', 'generate' => false], - 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'generate' => false], 'factory' => ['path' => 'database/factories', 'generate' => false], - // lang Folder + // lang/ 'lang' => ['path' => 'lang', 'generate' => false], - // Resource Folder + // resource/ 'assets' => ['path' => 'resources/assets', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], - // Route Folder + // routes/ 'routes' => ['path' => 'routes', 'generate' => true], - // Test Folder + // tests/ 'test-unit' => ['path' => 'tests/Unit', 'generate' => false], 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], ], From fde749285b7e59d0e3b54d9ab3aa8f02362f8b5a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 18 Mar 2024 14:47:22 +0330 Subject: [PATCH 211/422] [feat] add method 'getAppPath' --- src/Module.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Module.php b/src/Module.php index 7d6ae8830..8008d2573 100644 --- a/src/Module.php +++ b/src/Module.php @@ -6,7 +6,6 @@ use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Arr; -use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Illuminate\Translation\Translator; @@ -174,6 +173,17 @@ public function getPath(): string return $this->path; } + /** + * Get app path. + * + * @return string + */ + public function getAppPath(): string + { + $app_path = rtrim($this->getExtraPath(config('modules.paths.app_folder', '')), '/'); + return is_dir($app_path) ? $app_path : $this->getPath(); + } + /** * Set path. * @@ -289,6 +299,7 @@ protected function fireEvent($event): void { $this->app['events']->dispatch(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]); } + /** * Register the aliases from this module. */ From 82fc28ed24df1d36d1e62c46249bc0b1b6112c2e Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 18 Mar 2024 22:36:37 -0700 Subject: [PATCH 212/422] Update controller-api.stub Remove custom code to comply with standard syntax. --- src/Commands/stubs/controller-api.stub | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Commands/stubs/controller-api.stub b/src/Commands/stubs/controller-api.stub index 66e70a6eb..025095da3 100644 --- a/src/Commands/stubs/controller-api.stub +++ b/src/Commands/stubs/controller-api.stub @@ -3,60 +3,57 @@ namespace $CLASS_NAMESPACE$; use App\Http\Controllers\Controller; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class $CLASS$ extends Controller { - public array $data = []; - /** * Display a listing of the resource. */ - public function index(): JsonResponse + public function index() { // - return response()->json($this->data); + return response()->json([]); } /** * Store a newly created resource in storage. */ - public function store(Request $request): JsonResponse + public function store(Request $request) { // - return response()->json($this->data); + return response()->json([]); } /** * Show the specified resource. */ - public function show($id): JsonResponse + public function show($id) { // - return response()->json($this->data); + return response()->json([]); } /** * Update the specified resource in storage. */ - public function update(Request $request, $id): JsonResponse + public function update(Request $request, $id) { // - return response()->json($this->data); + return response()->json([]); } /** * Remove the specified resource from storage. */ - public function destroy($id): JsonResponse + public function destroy($id) { // - return response()->json($this->data); + return response()->json([]); } } From 806404819957cadb8e22805f0e2fb91710b83fe4 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 18 Mar 2024 22:50:59 -0700 Subject: [PATCH 213/422] Update api.stub Bind the module's resource Controller. --- src/Commands/stubs/routes/api.stub | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Commands/stubs/routes/api.stub b/src/Commands/stubs/routes/api.stub index 10ae87e72..c99a9bbbb 100755 --- a/src/Commands/stubs/routes/api.stub +++ b/src/Commands/stubs/routes/api.stub @@ -1,19 +1,19 @@ prefix('v1')->name('api.')->group(function () { - Route::get('$LOWER_NAME$', fn (Request $request) => $request->user())->name('$LOWER_NAME$'); +Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { + Route::apiResource('$LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$'); }); From 00560460d61c5f3466ea5a374d825ed0165518fb Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 17:36:37 +0000 Subject: [PATCH 214/422] updated CHANGELOG.md and snapshots --- CHANGELOG.md | 5 ++++ config/config.php | 2 +- ...est__it_generates_an_api_controller__1.txt | 23 ++++++++----------- ...generates_api_module_with_resources__2.txt | 23 ++++++++----------- ...ndTest__it_generates_api_route_file__1.txt | 22 +++++++++--------- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cef59a17..6a95a20d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,14 +8,19 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@Subtixx](https://github.com/subtixx) Fix Issue #1752 - Hardcoded string + undefined variable - [@jaymeh](https://github.com/jaymeh) fix: Failed to load module script for static assets such as images +- [@alissn](https://github.com/alissn) Fixing failing tests ## Changed +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated API route stub to use controller +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated config comments +- [@alissn](https://github.com/alissn) rearrange Command Classes into Folders and Update Namespace Structure - [@alissn](https://github.com/alissn) delete command module:migrate-fresh - [@alissn](https://github.com/alissn) Fixing Case of tests/Unit and tests/Feature ## Updated +- [@dcblogdev](https://github.com/dcblogdev) added replacement placeholders in config for API stubs - [@dcblogdev](https://github.com/dcblogdev) updated vite to rename placeholder with module name - [@alissn](https://github.com/alissn) Updated commands to use Laravel Prompt - [@dcblogdev](https://github.com/dcblogdev) updated event stub to include Dispatchable and InteractsWithSockets traits diff --git a/config/config.php b/config/config.php index fb1581182..4674f121f 100644 --- a/config/config.php +++ b/config/config.php @@ -42,7 +42,7 @@ ], 'replacements' => [ 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], - 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME'], + 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'STUDLY_NAME', 'CONTROLLER_NAMESPACE'], 'vite' => ['LOWER_NAME', 'STUDLY_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], 'views/index' => ['LOWER_NAME'], diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt index dc7c1310a..b674ddc5f 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt @@ -3,60 +3,57 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class MyController extends Controller { - public array $data = []; - /** * Display a listing of the resource. */ - public function index(): JsonResponse + public function index() { // - return response()->json($this->data); + return response()->json([]); } /** * Store a newly created resource in storage. */ - public function store(Request $request): JsonResponse + public function store(Request $request) { // - return response()->json($this->data); + return response()->json([]); } /** * Show the specified resource. */ - public function show($id): JsonResponse + public function show($id) { // - return response()->json($this->data); + return response()->json([]); } /** * Update the specified resource in storage. */ - public function update(Request $request, $id): JsonResponse + public function update(Request $request, $id) { // - return response()->json($this->data); + return response()->json([]); } /** * Remove the specified resource from storage. */ - public function destroy($id): JsonResponse + public function destroy($id) { // - return response()->json($this->data); + return response()->json([]); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt index 48d9b883f..bc3afb929 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt @@ -3,60 +3,57 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class BlogController extends Controller { - public array $data = []; - /** * Display a listing of the resource. */ - public function index(): JsonResponse + public function index() { // - return response()->json($this->data); + return response()->json([]); } /** * Store a newly created resource in storage. */ - public function store(Request $request): JsonResponse + public function store(Request $request) { // - return response()->json($this->data); + return response()->json([]); } /** * Show the specified resource. */ - public function show($id): JsonResponse + public function show($id) { // - return response()->json($this->data); + return response()->json([]); } /** * Update the specified resource in storage. */ - public function update(Request $request, $id): JsonResponse + public function update(Request $request, $id) { // - return response()->json($this->data); + return response()->json([]); } /** * Remove the specified resource from storage. */ - public function destroy($id): JsonResponse + public function destroy($id) { // - return response()->json($this->data); + return response()->json([]); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt index b7fd90bac..cbdf7602e 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt @@ -1,19 +1,19 @@ prefix('v1')->name('api.')->group(function () { - Route::get('blog', fn (Request $request) => $request->user())->name('blog'); +Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () { + Route::apiResource('blog', BlogController::class)->names('blog'); }); From b289b358d9249f34c2ddb072efec84d89949347f Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 19:25:43 +0000 Subject: [PATCH 215/422] add support for Laravel 11 --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index c2012548d..1fbd48599 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,16 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.2", "ext-json": "*", "wikimedia/composer-merge-plugin": "^2.1" }, "require-dev": { - "phpunit/phpunit": "^10.0", - "mockery/mockery": "^1.5", - "orchestra/testbench": "^8.0", - "friendsofphp/php-cs-fixer": "^3.6", - "laravel/framework": "^10.41", + "phpunit/phpunit": "^11.0", + "mockery/mockery": "^1.6", + "orchestra/testbench": "^v9.0", + "friendsofphp/php-cs-fixer": "^v3.52", + "laravel/framework": "^v11.0", "spatie/phpunit-snapshot-assertions": "^5.0", "phpstan/phpstan": "^1.4" }, @@ -55,7 +55,7 @@ } }, "branch-alias": { - "dev-master": "10.0-dev" + "dev-master": "11.0-dev" } }, "config": { From 80d0148ff8bd0edb98e018b39f93fd656b98be15 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 19:26:15 +0000 Subject: [PATCH 216/422] updated tests for compatability with PhpUnit 12 --- tests/Activators/FileActivatorTest.php | 15 +-- ...tes_valid_json_file_after_disabling__1.txt | 3 + ...tes_valid_json_file_after_disabling__2.txt | 3 + ...ates_valid_json_file_after_enabling__1.txt | 3 + ...ates_valid_json_file_after_enabling__2.txt | 3 + tests/CollectionTest.php | 6 +- tests/Commands/ChannelMakeCommandTest.php | 12 +- tests/Commands/CommandMakeCommandTest.php | 15 +-- .../ComponentClassMakeCommandTest.php | 12 +- .../Commands/ComponentViewMakeCommandTest.php | 9 +- tests/Commands/ControllerMakeCommandTest.php | 30 ++--- tests/Commands/DisableCommandTest.php | 9 +- tests/Commands/EnableCommandTest.php | 9 +- tests/Commands/EventMakeCommandTest.php | 12 +- tests/Commands/FactoryMakeCommandTest.php | 3 +- tests/Commands/JobMakeCommandTest.php | 15 +-- tests/Commands/ListCommandTest.php | 3 +- tests/Commands/ListenerMakeCommandTest.php | 27 ++--- tests/Commands/MailMakeCommandTest.php | 12 +- tests/Commands/MiddlewareMakeCommandTest.php | 12 +- tests/Commands/MigrationMakeCommandTest.php | 21 ++-- tests/Commands/ModelMakeCommandTest.php | 36 ++---- tests/Commands/ModuleDeleteCommandTest.php | 12 +- tests/Commands/ModuleMakeCommandTest.php | 75 ++++-------- .../Commands/NotificationMakeCommandTest.php | 12 +- tests/Commands/ObserverMakeCommandTest.php | 3 +- tests/Commands/PolicyMakeCommandTest.php | 9 +- tests/Commands/ProviderMakeCommandTest.php | 18 +-- tests/Commands/PublishCommandTest.php | 3 +- .../Commands/PublishMigrationCommandTest.php | 3 +- .../PublishTranslationCommandTest.php | 3 +- tests/Commands/RequestMakeCommandTest.php | 12 +- tests/Commands/ResourceMakeCommandTest.php | 15 +-- .../Commands/RouteProviderMakeCommandTest.php | 21 ++-- tests/Commands/RuleMakeCommandTest.php | 12 +- tests/Commands/TestMakeCommandTest.php | 24 ++-- ...it_can_change_the_default_namespace__1.txt | 24 ++++ ...ange_the_default_namespace_specific__1.txt | 24 ++++ ...generated_correct_file_with_content__1.txt | 24 ++++ ...it_can_change_the_default_namespace__1.txt | 56 +++++++++ ...ange_the_default_namespace_specific__1.txt | 56 +++++++++ ...generated_correct_file_with_content__1.txt | 56 +++++++++ ...t_it_uses_set_command_name_in_class__1.txt | 56 +++++++++ ...it_can_change_the_default_namespace__1.txt | 25 ++++ ...generated_correct_file_with_content__1.txt | 25 ++++ ...roller_to_class_name_if_not_present__1.txt | 67 ++++++++++ ...it_can_change_the_default_namespace__1.txt | 67 ++++++++++ ...ange_the_default_namespace_specific__1.txt | 67 ++++++++++ ...mespace_with_correct_generated_file__1.txt | 67 ++++++++++ ...generated_correct_file_with_content__1.txt | 67 ++++++++++ ...est_it_generates_a_plain_controller__1.txt | 9 ++ ...test_it_generates_an_api_controller__1.txt | 59 +++++++++ ...it_can_change_the_default_namespace__1.txt | 34 ++++++ ...ange_the_default_namespace_specific__1.txt | 34 ++++++ ...generated_correct_file_with_content__1.txt | 34 ++++++ ...eCommandTest__test_it_makes_factory__1.txt | 22 ++++ ...it_can_change_the_default_namespace__1.txt | 30 +++++ ...ange_the_default_namespace_specific__1.txt | 30 +++++ ...generated_correct_file_with_content__1.txt | 30 +++++ ..._correct_sync_job_file_with_content__1.txt | 27 +++++ ...it_can_change_the_default_namespace__1.txt | 25 ++++ ...ange_the_default_namespace_specific__1.txt | 25 ++++ ...rect_queued_duck_event_with_content__1.txt | 27 +++++ ...vent_in_a_subdirectory_with_content__1.txt | 28 +++++ ...d_correct_queued_event_with_content__1.txt | 28 +++++ ...orrect_sync_duck_event_with_content__1.txt | 25 ++++ ...vent_in_a_subdirectory_with_content__1.txt | 26 ++++ ...ted_correct_sync_event_with_content__1.txt | 26 ++++ ...it_can_change_the_default_namespace__1.txt | 29 +++++ ...ange_the_default_namespace_specific__1.txt | 29 +++++ ...generated_correct_file_with_content__1.txt | 29 +++++ ...it_can_change_the_default_namespace__1.txt | 17 +++ ...ange_the_default_namespace_specific__1.txt | 17 +++ ...generated_correct_file_with_content__1.txt | 17 +++ ..._correct_add_migration_file_content__1.txt | 28 +++++ ...rrect_create_migration_file_content__1.txt | 28 +++++ ...rect_default_migration_file_content__1.txt | 24 ++++ ...rrect_delete_migration_file_content__1.txt | 28 +++++ ...correct_drop_migration_file_content__1.txt | 28 +++++ ...t_generates_foreign_key_constraints__1.txt | 30 +++++ ...it_can_change_the_default_namespace__1.txt | 22 ++++ ...ange_the_default_namespace_specific__1.txt | 22 ++++ ...generated_correct_file_with_content__1.txt | 22 ++++ ...gration_when_both_flags_are_present__1.txt | 67 ++++++++++ ...gration_when_both_flags_are_present__2.txt | 28 +++++ ...enerates_controller_file_with_model__1.txt | 67 ++++++++++ ...le_with_model_using_shortcut_option__1.txt | 67 ++++++++++ ...t_generates_correct_fillable_fields__1.txt | 22 ++++ ...file_name_with_multiple_words_model__1.txt | 28 +++++ ...generates_migration_file_with_model__1.txt | 28 +++++ ...le_with_model_using_shortcut_option__1.txt | 28 +++++ ...it_deletes_modules_from_status_file__1.txt | 3 + ...it_deletes_modules_from_status_file__2.txt | 1 + ...generates_api_module_with_resources__1.txt | 114 ++++++++++++++++++ ...generates_api_module_with_resources__2.txt | 59 +++++++++ ...generates_api_module_with_resources__3.txt | 16 +++ ...generates_api_module_with_resources__4.txt | 59 +++++++++ ...t__test_it_generates_api_route_file__1.txt | 19 +++ ...generates_correct_composerjson_file__1.txt | 30 +++++ ...est__test_it_generates_module_files__1.txt | 11 ++ ..._module_namespace_using_studly_case__1.txt | 114 ++++++++++++++++++ ..._test_it_generates_module_resources__1.txt | 114 ++++++++++++++++++ ..._test_it_generates_module_resources__2.txt | 67 ++++++++++ ..._test_it_generates_module_resources__3.txt | 16 +++ ..._test_it_generates_module_resources__4.txt | 59 +++++++++ ...ndTest__test_it_generates_vite_file__1.txt | 26 ++++ ...generates_web_module_with_resources__1.txt | 114 ++++++++++++++++++ ...generates_web_module_with_resources__2.txt | 67 ++++++++++ ...generates_web_module_with_resources__3.txt | 16 +++ ...generates_web_module_with_resources__4.txt | 59 +++++++++ ...es_when_adding_more_than_one_option__1.txt | 114 ++++++++++++++++++ ...es_when_adding_more_than_one_option__2.txt | 67 ++++++++++ ...es_when_adding_more_than_one_option__3.txt | 16 +++ ...es_when_adding_more_than_one_option__4.txt | 59 +++++++++ ...t__test_it_generates_web_route_file__1.txt | 19 +++ ...s_module_with_new_provider_location__1.txt | 11 ++ ...s_module_with_new_provider_location__2.txt | 30 +++++ ...it_can_change_the_default_namespace__1.txt | 48 ++++++++ ...ange_the_default_namespace_specific__1.txt | 48 ++++++++ ...generated_correct_file_with_content__1.txt | 48 ++++++++ ...CommandTest__test_it_makes_observer__1.txt | 48 ++++++++ ...it_can_change_the_default_namespace__1.txt | 18 +++ ...ange_the_default_namespace_specific__1.txt | 18 +++ ...keCommandTest__test_it_makes_policy__1.txt | 18 +++ ...it_can_change_the_default_namespace__1.txt | 114 ++++++++++++++++++ ...ange_the_default_namespace_specific__1.txt | 114 ++++++++++++++++++ ..._migration_resources_location_paths__1.txt | 114 ++++++++++++++++++ ...generated_correct_file_with_content__1.txt | 24 ++++ ...vice_provider_with_resource_loading__1.txt | 114 ++++++++++++++++++ ...it_can_change_the_default_namespace__1.txt | 26 ++++ ...ange_the_default_namespace_specific__1.txt | 26 ++++ ...generated_correct_file_with_content__1.txt | 26 ++++ ...it_can_change_the_default_namespace__1.txt | 17 +++ ...ange_the_default_namespace_specific__1.txt | 17 +++ ...enerate_a_collection_resource_class__1.txt | 17 +++ ...generated_correct_file_with_content__1.txt | 17 +++ ...nge_the_custom_controller_namespace__1.txt | 59 +++++++++ ...it_can_change_the_default_namespace__1.txt | 59 +++++++++ ...ange_the_default_namespace_specific__1.txt | 59 +++++++++ ...andTest__test_it_can_overwrite_file__1.txt | 59 +++++++++ ...t_it_can_overwrite_route_file_names__1.txt | 59 +++++++++ ...generated_correct_file_with_content__1.txt | 59 +++++++++ ...it_can_change_the_default_namespace__1.txt | 17 +++ ...ange_the_default_namespace_specific__1.txt | 17 +++ ...ndTest__test_it_makes_implicit_rule__1.txt | 22 ++++ ...MakeCommandTest__test_it_makes_rule__1.txt | 17 +++ ...hange_the_default_feature_namespace__1.txt | 20 +++ ..._default_feature_namespace_specific__1.txt | 20 +++ ...n_change_the_default_unit_namespace__1.txt | 20 +++ ...the_default_unit_namespace_specific__1.txt | 20 +++ ...d_correct_feature_file_with_content__1.txt | 20 +++ ...ated_correct_unit_file_with_content__1.txt | 20 +++ tests/ContractsServiceProviderTest.php | 3 +- tests/GenerateConfigReaderTest.php | 15 +-- tests/HelpersTest.php | 6 +- tests/JsonTest.php | 27 ++--- tests/LaravelFileRepositoryTest.php | 75 ++++-------- tests/LaravelModuleTest.php | 63 ++++------ tests/LaravelModulesServiceProviderTest.php | 9 +- tests/LumenModuleTest.php | 48 +++----- tests/ModuleFacadeTest.php | 9 +- tests/NameParserTest.php | 36 ++---- tests/SchemaParserTest.php | 9 +- tests/StubTest.php | 18 +-- 164 files changed, 4882 insertions(+), 532 deletions(-) create mode 100644 tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__1.txt create mode 100644 tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__2.txt create mode 100644 tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__1.txt create mode 100644 tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__2.txt create mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_uses_set_command_name_in_class__1.txt create mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_a_plain_controller__1.txt create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_api_controller__1.txt create mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt create mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_generated_correct_sync_job_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_duck_event_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_event_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_duck_event_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_event_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt create mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_create_migration_file_content__1.txt create mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt create mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_delete_migration_file_content__1.txt create mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_drop_migration_file_content__1.txt create mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__2.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_migration_file_name_with_multiple_words_model__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt create mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__2.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__3.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt create mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt create mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__test_it_makes_policy__1.txt create mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt create mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt create mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_can_generate_a_collection_resource_class__1.txt create mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt create mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt create mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_makes_implicit_rule__1.txt create mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_makes_rule__1.txt create mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt create mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt diff --git a/tests/Activators/FileActivatorTest.php b/tests/Activators/FileActivatorTest.php index a7a1affb5..139de5f6a 100644 --- a/tests/Activators/FileActivatorTest.php +++ b/tests/Activators/FileActivatorTest.php @@ -39,8 +39,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_creates_valid_json_file_after_enabling() + public function test_it_creates_valid_json_file_after_enabling() { $this->activator->enable($this->module); $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); @@ -49,8 +48,7 @@ public function it_creates_valid_json_file_after_enabling() $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); } - /** @test */ - public function it_creates_valid_json_file_after_disabling() + public function test_it_creates_valid_json_file_after_disabling() { $this->activator->disable($this->module); $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); @@ -59,8 +57,7 @@ public function it_creates_valid_json_file_after_disabling() $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); } - /** @test */ - public function it_can_check_module_enabled_status() + public function test_it_can_check_module_enabled_status() { $this->activator->enable($this->module); $this->assertTrue($this->activator->hasStatus($this->module, true)); @@ -69,8 +66,7 @@ public function it_can_check_module_enabled_status() $this->assertTrue($this->activator->hasStatus($this->module, true)); } - /** @test */ - public function it_can_check_module_disabled_status() + public function test_it_can_check_module_disabled_status() { $this->activator->disable($this->module); $this->assertTrue($this->activator->hasStatus($this->module, false)); @@ -79,8 +75,7 @@ public function it_can_check_module_disabled_status() $this->assertTrue($this->activator->hasStatus($this->module, false)); } - /** @test */ - public function it_can_check_status_of_module_that_hasnt_been_enabled_or_disabled() + public function test_it_can_check_status_of_module_that_hasnt_been_enabled_or_disabled() { $this->assertTrue($this->activator->hasStatus($this->module, false)); } diff --git a/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__1.txt b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__1.txt new file mode 100644 index 000000000..df07c139d --- /dev/null +++ b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__1.txt @@ -0,0 +1,3 @@ +{ + "Recipe": false +} \ No newline at end of file diff --git a/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__2.txt b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__2.txt new file mode 100644 index 000000000..df07c139d --- /dev/null +++ b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_disabling__2.txt @@ -0,0 +1,3 @@ +{ + "Recipe": false +} \ No newline at end of file diff --git a/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__1.txt b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__1.txt new file mode 100644 index 000000000..57b480388 --- /dev/null +++ b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__1.txt @@ -0,0 +1,3 @@ +{ + "Recipe": true +} \ No newline at end of file diff --git a/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__2.txt b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__2.txt new file mode 100644 index 000000000..57b480388 --- /dev/null +++ b/tests/Activators/__snapshots__/FileActivatorTest__test_it_creates_valid_json_file_after_enabling__2.txt @@ -0,0 +1,3 @@ +{ + "Recipe": true +} \ No newline at end of file diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 1e2889210..5c3571275 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -7,8 +7,7 @@ class CollectionTest extends BaseTestCase { - /** @test */ - public function toArraySetsPathAttribute() + public function test_toArraySetsPathAttribute() { $moduleOnePath = __DIR__ . '/stubs/valid/Recipe'; $moduleTwoPath = __DIR__ . '/stubs/valid/Requirement'; @@ -25,8 +24,7 @@ public function toArraySetsPathAttribute() $this->assertEquals($moduleTwoPath, $collectionArray[1]['path']); } - /** @test */ - public function getItemsReturnsTheCollectionItems() + public function test_getItemsReturnsTheCollectionItems() { $modules = [ new Module($this->app, 'module-one', __DIR__ . '/stubs/valid/Recipe'), diff --git a/tests/Commands/ChannelMakeCommandTest.php b/tests/Commands/ChannelMakeCommandTest.php index 3da047db7..e5ca9141d 100644 --- a/tests/Commands/ChannelMakeCommandTest.php +++ b/tests/Commands/ChannelMakeCommandTest.php @@ -33,8 +33,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_the_channel_class() + public function test_it_generates_the_channel_class() { $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); @@ -42,8 +41,7 @@ public function it_generates_the_channel_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); @@ -53,8 +51,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.channels.path', 'SuperChannel'); @@ -66,8 +63,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.channels.namespace', 'SuperChannel'); diff --git a/tests/Commands/CommandMakeCommandTest.php b/tests/Commands/CommandMakeCommandTest.php index 98f7948ac..123500466 100644 --- a/tests/Commands/CommandMakeCommandTest.php +++ b/tests/Commands/CommandMakeCommandTest.php @@ -33,8 +33,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_console_command_class() + public function test_it_generates_a_new_console_command_class() { $code = $this->artisan('module:make-command', ['name' => 'MyAwesomeCommand', 'module' => 'Blog']); @@ -42,8 +41,7 @@ public function it_generates_a_new_console_command_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-command', ['name' => 'MyAwesomeCommand', 'module' => 'Blog']); @@ -53,8 +51,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_uses_set_command_name_in_class() + public function test_it_uses_set_command_name_in_class() { $code = $this->artisan( 'module:make-command', @@ -67,8 +64,7 @@ public function it_uses_set_command_name_in_class() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.command.path', 'app/CustomCommands'); @@ -80,8 +76,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.command.namespace', 'Commands'); diff --git a/tests/Commands/ComponentClassMakeCommandTest.php b/tests/Commands/ComponentClassMakeCommandTest.php index 914d415da..605c5e897 100644 --- a/tests/Commands/ComponentClassMakeCommandTest.php +++ b/tests/Commands/ComponentClassMakeCommandTest.php @@ -33,16 +33,14 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_the_component_class() + public function test_it_generates_the_component_class() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); $this->assertTrue(is_file($this->modulePath . '/View/Components/Blog.php')); $this->assertSame(0, $code); } - /** @test */ - public function it_generates_the_component_view_from_component_class_command() + public function test_it_generates_the_component_view_from_component_class_command() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/components/blog.blade.php'); @@ -50,8 +48,7 @@ public function it_generates_the_component_view_from_component_class_command() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); $file = $this->finder->get($this->modulePath . '/View/Components/Blog.php'); @@ -59,8 +56,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.component-class.path', 'View/Components/newDirectory'); diff --git a/tests/Commands/ComponentViewMakeCommandTest.php b/tests/Commands/ComponentViewMakeCommandTest.php index 18e4bdf85..6732a5997 100644 --- a/tests/Commands/ComponentViewMakeCommandTest.php +++ b/tests/Commands/ComponentViewMakeCommandTest.php @@ -33,16 +33,14 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_the_component_view() + public function test_it_generates_the_component_view() { $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); $this->assertTrue(is_file($this->getModuleBasePath() . '/resources/views/components/blog.blade.php')); $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/components/blog.blade.php'); @@ -50,8 +48,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.component-view.path', 'Resources/views/components/newDirectory'); diff --git a/tests/Commands/ControllerMakeCommandTest.php b/tests/Commands/ControllerMakeCommandTest.php index b9cd957bb..2bbe1ae7c 100644 --- a/tests/Commands/ControllerMakeCommandTest.php +++ b/tests/Commands/ControllerMakeCommandTest.php @@ -34,8 +34,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_controller_class() + public function test_it_generates_a_new_controller_class() { $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); @@ -43,8 +42,7 @@ public function it_generates_a_new_controller_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); @@ -54,8 +52,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_appends_controller_to_name_if_not_present() + public function test_it_appends_controller_to_name_if_not_present() { $code = $this->artisan('module:make-controller', ['controller' => 'My', 'module' => 'Blog']); @@ -63,8 +60,7 @@ public function it_appends_controller_to_name_if_not_present() $this->assertSame(0, $code); } - /** @test */ - public function it_appends_controller_to_class_name_if_not_present() + public function test_it_appends_controller_to_class_name_if_not_present() { $code = $this->artisan('module:make-controller', ['controller' => 'My', 'module' => 'Blog']); @@ -74,8 +70,7 @@ public function it_appends_controller_to_class_name_if_not_present() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_a_plain_controller() + public function test_it_generates_a_plain_controller() { $code = $this->artisan('module:make-controller', [ 'controller' => 'MyController', @@ -89,8 +84,7 @@ public function it_generates_a_plain_controller() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_an_api_controller() + public function test_it_generates_an_api_controller() { $code = $this->artisan('module:make-controller', [ 'controller' => 'MyController', @@ -104,8 +98,7 @@ public function it_generates_an_api_controller() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.controller.path', 'Controllers'); @@ -117,8 +110,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.controller.namespace', 'Controllers'); @@ -130,8 +122,7 @@ public function it_can_change_the_default_namespace_specific() $this->assertSame(0, $code); } - /** @test */ - public function it_can_generate_a_controller_in_sub_namespace_in_correct_folder() + public function test_it_can_generate_a_controller_in_sub_namespace_in_correct_folder() { $code = $this->artisan('module:make-controller', ['controller' => 'Api\\MyController', 'module' => 'Blog']); @@ -139,8 +130,7 @@ public function it_can_generate_a_controller_in_sub_namespace_in_correct_folder( $this->assertSame(0, $code); } - /** @test */ - public function it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file() + public function test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file() { $code = $this->artisan('module:make-controller', ['controller' => 'Api\\MyController', 'module' => 'Blog']); diff --git a/tests/Commands/DisableCommandTest.php b/tests/Commands/DisableCommandTest.php index b5ddb4aff..64ba5a27e 100644 --- a/tests/Commands/DisableCommandTest.php +++ b/tests/Commands/DisableCommandTest.php @@ -25,8 +25,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_disables_a_module() + public function test_it_disables_a_module() { /** @var Module $blogModule */ $blogModule = $this->repository->find('Blog'); @@ -38,8 +37,7 @@ public function it_disables_a_module() $this->assertSame(0, $code); } - /** @test */ - public function it_disables_array_of_modules() + public function test_it_disables_array_of_modules() { /** @var Module $blogModule */ $blogModule = $this->repository->find('Blog'); @@ -55,8 +53,7 @@ public function it_disables_array_of_modules() $this->assertSame(0, $code); } - /** @test */ - public function it_disables_all_modules() + public function test_it_disables_all_modules() { /** @var Module $blogModule */ $blogModule = $this->repository->find('Blog'); diff --git a/tests/Commands/EnableCommandTest.php b/tests/Commands/EnableCommandTest.php index 688d4ec22..efb1ceae5 100644 --- a/tests/Commands/EnableCommandTest.php +++ b/tests/Commands/EnableCommandTest.php @@ -25,8 +25,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_enables_a_module() + public function test_it_enables_a_module() { /** @var Module $blogModule */ $blogModule = $this->repository->find('Blog'); @@ -38,8 +37,7 @@ public function it_enables_a_module() $this->assertSame(0, $code); } - /** @test */ - public function it_enables_array_of_modules() + public function test_it_enables_array_of_modules() { /** @var Module $blogModule */ $blogModule = $this->repository->find('Blog'); @@ -55,8 +53,7 @@ public function it_enables_array_of_modules() $this->assertSame(0, $code); } - /** @test */ - public function it_enables_all_modules() + public function test_it_enables_all_modules() { /** @var Module $blogModule */ $blogModule = $this->repository->find('Blog'); diff --git a/tests/Commands/EventMakeCommandTest.php b/tests/Commands/EventMakeCommandTest.php index 6c67c2146..5e82f1700 100644 --- a/tests/Commands/EventMakeCommandTest.php +++ b/tests/Commands/EventMakeCommandTest.php @@ -33,8 +33,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_event_class() + public function test_it_generates_a_new_event_class() { $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); @@ -42,8 +41,7 @@ public function it_generates_a_new_event_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); @@ -53,8 +51,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.event.path', 'SuperEvents'); @@ -66,8 +63,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.event.namespace', 'SuperEvents'); diff --git a/tests/Commands/FactoryMakeCommandTest.php b/tests/Commands/FactoryMakeCommandTest.php index 5db22855d..ebf2ee77c 100644 --- a/tests/Commands/FactoryMakeCommandTest.php +++ b/tests/Commands/FactoryMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_makes_factory() + public function test_it_makes_factory() { $code = $this->artisan('module:make-factory', ['name' => 'Post', 'module' => 'Blog']); diff --git a/tests/Commands/JobMakeCommandTest.php b/tests/Commands/JobMakeCommandTest.php index 88588dfa0..b205ef742 100644 --- a/tests/Commands/JobMakeCommandTest.php +++ b/tests/Commands/JobMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_the_job_class() + public function test_it_generates_the_job_class() { $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); @@ -41,8 +40,7 @@ public function it_generates_the_job_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); @@ -52,8 +50,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_sync_job_file_with_content() + public function test_it_generated_correct_sync_job_file_with_content() { $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog', '--sync' => true]); @@ -63,8 +60,7 @@ public function it_generated_correct_sync_job_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.jobs.path', 'SuperJobs'); @@ -76,8 +72,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.jobs.namespace', 'SuperJobs'); diff --git a/tests/Commands/ListCommandTest.php b/tests/Commands/ListCommandTest.php index 5bc5904e8..66a61c1bd 100644 --- a/tests/Commands/ListCommandTest.php +++ b/tests/Commands/ListCommandTest.php @@ -25,8 +25,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_can_list_modules() + public function test_it_can_list_modules() { $code = $this->artisan('module:list'); diff --git a/tests/Commands/ListenerMakeCommandTest.php b/tests/Commands/ListenerMakeCommandTest.php index 3bc70ef22..20dc73e03 100644 --- a/tests/Commands/ListenerMakeCommandTest.php +++ b/tests/Commands/ListenerMakeCommandTest.php @@ -33,8 +33,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_event_class() + public function test_it_generates_a_new_event_class() { $code = $this->artisan( 'module:make-listener', @@ -45,8 +44,7 @@ public function it_generates_a_new_event_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_sync_event_with_content() + public function test_it_generated_correct_sync_event_with_content() { $code = $this->artisan( 'module:make-listener', @@ -59,8 +57,7 @@ public function it_generated_correct_sync_event_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_sync_event_in_a_subdirectory_with_content() + public function test_it_generated_correct_sync_event_in_a_subdirectory_with_content() { $code = $this->artisan( 'module:make-listener', @@ -73,8 +70,7 @@ public function it_generated_correct_sync_event_in_a_subdirectory_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_sync_duck_event_with_content() + public function test_it_generated_correct_sync_duck_event_with_content() { $code = $this->artisan( 'module:make-listener', @@ -87,8 +83,7 @@ public function it_generated_correct_sync_duck_event_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_queued_event_with_content() + public function test_it_generated_correct_queued_event_with_content() { $code = $this->artisan( 'module:make-listener', @@ -101,8 +96,7 @@ public function it_generated_correct_queued_event_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_queued_event_in_a_subdirectory_with_content() + public function test_it_generated_correct_queued_event_in_a_subdirectory_with_content() { $code = $this->artisan( 'module:make-listener', @@ -115,8 +109,7 @@ public function it_generated_correct_queued_event_in_a_subdirectory_with_content $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_queued_duck_event_with_content() + public function test_it_generated_correct_queued_duck_event_with_content() { $code = $this->artisan( 'module:make-listener', @@ -129,8 +122,7 @@ public function it_generated_correct_queued_duck_event_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.listener.path', 'Events/Handlers'); @@ -145,8 +137,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.listener.namespace', 'Events\\Handlers'); diff --git a/tests/Commands/MailMakeCommandTest.php b/tests/Commands/MailMakeCommandTest.php index b26748214..c8e9d1522 100644 --- a/tests/Commands/MailMakeCommandTest.php +++ b/tests/Commands/MailMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_the_mail_class() + public function test_it_generates_the_mail_class() { $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); @@ -41,8 +40,7 @@ public function it_generates_the_mail_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); @@ -52,8 +50,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.emails.path', 'SuperEmails'); @@ -65,8 +62,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.emails.namespace', 'SuperEmails'); diff --git a/tests/Commands/MiddlewareMakeCommandTest.php b/tests/Commands/MiddlewareMakeCommandTest.php index 197c17855..0d5bb722c 100644 --- a/tests/Commands/MiddlewareMakeCommandTest.php +++ b/tests/Commands/MiddlewareMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_middleware_class() + public function test_it_generates_a_new_middleware_class() { $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); @@ -41,8 +40,7 @@ public function it_generates_a_new_middleware_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); @@ -52,8 +50,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.filter.path', 'Middleware'); @@ -65,8 +62,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.filter.namespace', 'Middleware'); diff --git a/tests/Commands/MigrationMakeCommandTest.php b/tests/Commands/MigrationMakeCommandTest.php index 88416613d..35f9a79e4 100644 --- a/tests/Commands/MigrationMakeCommandTest.php +++ b/tests/Commands/MigrationMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_migration_class() + public function test_it_generates_a_new_migration_class() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); @@ -43,8 +42,7 @@ public function it_generates_a_new_migration_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_create_migration_file_content() + public function test_it_generates_correct_create_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); @@ -56,8 +54,7 @@ public function it_generates_correct_create_migration_file_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_add_migration_file_content() + public function test_it_generates_correct_add_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'add_something_to_posts_table', 'module' => 'Blog']); @@ -69,8 +66,7 @@ public function it_generates_correct_add_migration_file_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_delete_migration_file_content() + public function test_it_generates_correct_delete_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'delete_something_from_posts_table', 'module' => 'Blog']); @@ -82,8 +78,7 @@ public function it_generates_correct_delete_migration_file_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_drop_migration_file_content() + public function test_it_generates_correct_drop_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'drop_posts_table', 'module' => 'Blog']); @@ -95,8 +90,7 @@ public function it_generates_correct_drop_migration_file_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_default_migration_file_content() + public function test_it_generates_correct_default_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'something_random_name', 'module' => 'Blog']); @@ -108,8 +102,7 @@ public function it_generates_correct_default_migration_file_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_foreign_key_constraints() + public function test_it_generates_foreign_key_constraints() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog', '--fields' => 'belongsTo:user:id:users']); diff --git a/tests/Commands/ModelMakeCommandTest.php b/tests/Commands/ModelMakeCommandTest.php index e3b7819a5..f1d38e89f 100644 --- a/tests/Commands/ModelMakeCommandTest.php +++ b/tests/Commands/ModelMakeCommandTest.php @@ -33,8 +33,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_model_class() + public function test_it_generates_a_new_model_class() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); @@ -42,8 +41,7 @@ public function it_generates_a_new_model_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); @@ -53,8 +51,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_fillable_fields() + public function test_it_generates_correct_fillable_fields() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--fillable' => 'title,slug']); @@ -64,8 +61,7 @@ public function it_generates_correct_fillable_fields() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_migration_file_with_model() + public function test_it_generates_migration_file_with_model() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--migration' => true]); @@ -77,8 +73,7 @@ public function it_generates_migration_file_with_model() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_migration_file_with_model_using_shortcut_option() + public function test_it_generates_migration_file_with_model_using_shortcut_option() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-m' => true]); @@ -90,8 +85,7 @@ public function it_generates_migration_file_with_model_using_shortcut_option() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_controller_file_with_model() + public function test_it_generates_controller_file_with_model() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--controller' => true]); $controllers = $this->finder->allFiles($this->modulePath . '/Http/Controllers'); @@ -102,8 +96,7 @@ public function it_generates_controller_file_with_model() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_controller_file_with_model_using_shortcut_option() + public function test_it_generates_controller_file_with_model_using_shortcut_option() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-c' => true]); @@ -115,8 +108,7 @@ public function it_generates_controller_file_with_model_using_shortcut_option() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_controller_and_migration_when_both_flags_are_present() + public function test_it_generates_controller_and_migration_when_both_flags_are_present() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-c' => true, '-m' => true]); @@ -135,8 +127,7 @@ public function it_generates_controller_and_migration_when_both_flags_are_presen $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_migration_file_name_with_multiple_words_model() + public function test_it_generates_correct_migration_file_name_with_multiple_words_model() { $code = $this->artisan('module:make-model', ['model' => 'ProductDetail', 'module' => 'Blog', '-m' => true]); @@ -149,8 +140,7 @@ public function it_generates_correct_migration_file_name_with_multiple_words_mod $this->assertSame(0, $code); } - /** @test */ - public function it_displays_error_if_model_already_exists() + public function test_it_displays_error_if_model_already_exists() { $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); @@ -159,8 +149,7 @@ public function it_displays_error_if_model_already_exists() $this->assertSame(E_ERROR, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.model.path', 'Models'); @@ -172,8 +161,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.model.namespace', 'Models'); diff --git a/tests/Commands/ModuleDeleteCommandTest.php b/tests/Commands/ModuleDeleteCommandTest.php index 083dec1c7..a46c9d5ed 100644 --- a/tests/Commands/ModuleDeleteCommandTest.php +++ b/tests/Commands/ModuleDeleteCommandTest.php @@ -27,8 +27,7 @@ public function setUp(): void $this->activator = new FileActivator($this->app); } - /** @test */ - public function it_can_delete_a_module_from_disk(): void + public function test_it_can_delete_a_module_from_disk(): void { $this->artisan('module:make', ['name' => ['WrongModule']]); $this->assertDirectoryExists(base_path('modules/WrongModule')); @@ -38,8 +37,7 @@ public function it_can_delete_a_module_from_disk(): void $this->assertSame(0, $code); } - /** @test */ - public function it_can_delete_array_module_from_disk(): void + public function test_it_can_delete_array_module_from_disk(): void { $modules = [ 'Foo', @@ -61,8 +59,7 @@ public function it_can_delete_array_module_from_disk(): void $this->app[RepositoryInterface::class]->delete('Zoo'); } - /** @test */ - public function it_can_delete_all_module_from_disk(): void + public function test_it_can_delete_all_module_from_disk(): void { $modules = [ 'Foo', @@ -82,8 +79,7 @@ public function it_can_delete_all_module_from_disk(): void $this->assertFileDoesNotExist($this->getModuleBasePath('Zoo')); } - /** @test */ - public function it_deletes_modules_from_status_file(): void + public function test_it_deletes_modules_from_status_file(): void { $this->artisan('module:make', ['name' => ['WrongModule']]); $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); diff --git a/tests/Commands/ModuleMakeCommandTest.php b/tests/Commands/ModuleMakeCommandTest.php index aaf786d7e..7ae2b9e87 100644 --- a/tests/Commands/ModuleMakeCommandTest.php +++ b/tests/Commands/ModuleMakeCommandTest.php @@ -50,8 +50,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_module() + public function test_it_generates_module() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -59,8 +58,7 @@ public function it_generates_module() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_module_folders() + public function test_it_generates_module_folders() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -70,8 +68,7 @@ public function it_generates_module_folders() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_module_files() + public function test_it_generates_module_files() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -85,8 +82,7 @@ public function it_generates_module_files() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_web_route_file() + public function test_it_generates_web_route_file() { $files = $this->app['modules']->config('stubs.files'); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -97,8 +93,7 @@ public function it_generates_web_route_file() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_api_route_file() + public function test_it_generates_api_route_file() { $files = $this->app['modules']->config('stubs.files'); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -109,8 +104,7 @@ public function it_generates_api_route_file() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_vite_file() + public function test_it_generates_vite_file() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -120,8 +114,7 @@ public function it_generates_vite_file() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_module_resources() + public function test_it_generates_module_resources() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -144,8 +137,7 @@ public function it_generates_module_resources() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_correct_composerjson_file() + public function test_it_generates_correct_composerjson_file() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -155,8 +147,7 @@ public function it_generates_correct_composerjson_file() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_module_folder_using_studly_case() + public function test_it_generates_module_folder_using_studly_case() { $code = $this->artisan('module:make', ['name' => ['ModuleName']]); @@ -164,8 +155,7 @@ public function it_generates_module_folder_using_studly_case() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_module_namespace_using_studly_case() + public function test_it_generates_module_namespace_using_studly_case() { $code = $this->artisan('module:make', ['name' => ['ModuleName']]); @@ -175,8 +165,7 @@ public function it_generates_module_namespace_using_studly_case() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_a_plain_module_with_no_resources() + public function test_it_generates_a_plain_module_with_no_resources() { $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); @@ -192,8 +181,7 @@ public function it_generates_a_plain_module_with_no_resources() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_a_plain_module_with_no_files() + public function test_it_generates_a_plain_module_with_no_files() { $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); @@ -206,8 +194,7 @@ public function it_generates_a_plain_module_with_no_files() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_plain_module_with_no_service_provider_in_modulejson_file() + public function test_it_generates_plain_module_with_no_service_provider_in_modulejson_file() { $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); @@ -218,8 +205,7 @@ public function it_generates_plain_module_with_no_service_provider_in_modulejson $this->assertSame(0, $code); } - /** @test */ - public function it_outputs_error_when_module_exists() + public function test_it_outputs_error_when_module_exists() { $this->artisan('module:make', ['name' => ['Blog']]); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -232,8 +218,7 @@ public function it_outputs_error_when_module_exists() $this->assertSame(E_ERROR, $code); } - /** @test */ - public function it_still_generates_module_if_it_exists_using_force_flag() + public function test_it_still_generates_module_if_it_exists_using_force_flag() { $this->artisan('module:make', ['name' => ['Blog']]); $code = $this->artisan('module:make', ['name' => ['Blog'], '--force' => true]); @@ -247,8 +232,7 @@ public function it_still_generates_module_if_it_exists_using_force_flag() $this->assertSame(0, $code); } - /** @test */ - public function it_can_generate_module_with_old_config_format() + public function test_it_can_generate_module_with_old_config_format() { $this->app['config']->set('modules.paths.generator', [ 'assets' => 'Assets', @@ -285,8 +269,7 @@ public function it_can_generate_module_with_old_config_format() $this->assertSame(0, $code); } - /** @test */ - public function it_can_ignore_some_folders_to_generate_with_old_format() + public function test_it_can_ignore_some_folders_to_generate_with_old_format() { $this->app['config']->set('modules.paths.generator.assets', false); $this->app['config']->set('modules.paths.generator.emails', false); @@ -298,8 +281,7 @@ public function it_can_ignore_some_folders_to_generate_with_old_format() $this->assertSame(0, $code); } - /** @test */ - public function it_can_ignore_some_folders_to_generate_with_new_format() + public function test_it_can_ignore_some_folders_to_generate_with_new_format() { $this->app['config']->set('modules.paths.generator.assets', ['path' => 'Assets', 'generate' => false]); $this->app['config']->set('modules.paths.generator.emails', ['path' => 'Emails', 'generate' => false]); @@ -311,8 +293,7 @@ public function it_can_ignore_some_folders_to_generate_with_new_format() $this->assertSame(0, $code); } - /** @test */ - public function it_can_ignore_resource_folders_to_generate() + public function test_it_can_ignore_resource_folders_to_generate() { $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false]); $this->app['config']->set('modules.paths.generator.provider', ['path' => 'Providers', 'generate' => false]); @@ -326,8 +307,7 @@ public function it_can_ignore_resource_folders_to_generate() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_enabled_module() + public function test_it_generates_enabled_module() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -335,8 +315,7 @@ public function it_generates_enabled_module() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_disabled_module_with_disabled_flag() + public function test_it_generates_disabled_module_with_disabled_flag() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--disabled' => true]); @@ -344,8 +323,7 @@ public function it_generates_disabled_module_with_disabled_flag() $this->assertSame(0, $code); } - /** @test */ - public function it_generes_module_with_new_provider_location() + public function test_it_generes_module_with_new_provider_location() { $this->app['config']->set('modules.paths.generator.provider', ['path' => 'Base/Providers', 'generate' => true]); @@ -359,8 +337,7 @@ public function it_generes_module_with_new_provider_location() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_web_module_with_resources() + public function test_it_generates_web_module_with_resources() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--web' => true]); @@ -383,8 +360,7 @@ public function it_generates_web_module_with_resources() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_api_module_with_resources() + public function test_it_generates_api_module_with_resources() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true]); @@ -407,8 +383,7 @@ public function it_generates_api_module_with_resources() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_web_module_with_resources_when_adding_more_than_one_option() + public function test_it_generates_web_module_with_resources_when_adding_more_than_one_option() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true, '--plain' => true]); diff --git a/tests/Commands/NotificationMakeCommandTest.php b/tests/Commands/NotificationMakeCommandTest.php index 3831495d2..2069c5106 100644 --- a/tests/Commands/NotificationMakeCommandTest.php +++ b/tests/Commands/NotificationMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_the_notification_class() + public function test_it_generates_the_notification_class() { $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); @@ -41,8 +40,7 @@ public function it_generates_the_notification_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); @@ -52,8 +50,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.notifications.path', 'SuperNotifications'); @@ -65,8 +62,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.notifications.namespace', 'SuperNotifications'); diff --git a/tests/Commands/ObserverMakeCommandTest.php b/tests/Commands/ObserverMakeCommandTest.php index 2afaca853..b20c096fc 100644 --- a/tests/Commands/ObserverMakeCommandTest.php +++ b/tests/Commands/ObserverMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_makes_observer() + public function test_it_makes_observer() { $code = $this->artisan('module:make-observer', ['name' => 'Post', 'module' => 'Blog']); diff --git a/tests/Commands/PolicyMakeCommandTest.php b/tests/Commands/PolicyMakeCommandTest.php index a75f3aa09..503171496 100644 --- a/tests/Commands/PolicyMakeCommandTest.php +++ b/tests/Commands/PolicyMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_makes_policy() + public function test_it_makes_policy() { $code = $this->artisan('module:make-policy', ['name' => 'PostPolicy', 'module' => 'Blog']); @@ -44,8 +43,7 @@ public function it_makes_policy() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.policies.path', 'SuperPolicies'); @@ -57,8 +55,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.policies.namespace', 'SuperPolicies'); diff --git a/tests/Commands/ProviderMakeCommandTest.php b/tests/Commands/ProviderMakeCommandTest.php index f93f1b383..44e2660ce 100644 --- a/tests/Commands/ProviderMakeCommandTest.php +++ b/tests/Commands/ProviderMakeCommandTest.php @@ -32,16 +32,14 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_service_provider() + public function test_it_generates_a_service_provider() { $code = $this->artisan('module:make-provider', ['name' => 'MyBlogServiceProvider', 'module' => 'Blog']); $this->assertTrue(is_file($this->modulePath . '/Providers/MyBlogServiceProvider.php')); $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-provider', ['name' => 'MyBlogServiceProvider', 'module' => 'Blog']); @@ -51,8 +49,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_a_master_service_provider_with_resource_loading() + public function test_it_generates_a_master_service_provider_with_resource_loading() { $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); @@ -62,8 +59,7 @@ public function it_generates_a_master_service_provider_with_resource_loading() $this->assertSame(0, $code); } - /** @test */ - public function it_can_have_custom_migration_resources_location_paths() + public function test_it_can_have_custom_migration_resources_location_paths() { $this->app['config']->set('modules.paths.generator.migration', 'migrations'); $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); @@ -74,8 +70,7 @@ public function it_can_have_custom_migration_resources_location_paths() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.provider.path', 'SuperProviders'); @@ -87,8 +82,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.provider.namespace', 'SuperProviders'); diff --git a/tests/Commands/PublishCommandTest.php b/tests/Commands/PublishCommandTest.php index cb55385af..f925a91ff 100644 --- a/tests/Commands/PublishCommandTest.php +++ b/tests/Commands/PublishCommandTest.php @@ -31,8 +31,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_published_module_assets() + public function test_it_published_module_assets() { $code = $this->artisan('module:publish', ['module' => 'Blog']); diff --git a/tests/Commands/PublishMigrationCommandTest.php b/tests/Commands/PublishMigrationCommandTest.php index fa5ba1897..519ac6dc7 100644 --- a/tests/Commands/PublishMigrationCommandTest.php +++ b/tests/Commands/PublishMigrationCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_publishes_module_migrations() + public function test_it_publishes_module_migrations() { $code = $this->artisan('module:publish-migration', ['module' => 'Blog']); diff --git a/tests/Commands/PublishTranslationCommandTest.php b/tests/Commands/PublishTranslationCommandTest.php index 6f0b73fe3..71797ed63 100644 --- a/tests/Commands/PublishTranslationCommandTest.php +++ b/tests/Commands/PublishTranslationCommandTest.php @@ -30,8 +30,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_published_module_translations() + public function test_it_published_module_translations() { $code = $this->artisan('module:publish-translation', ['module' => 'Blog']); diff --git a/tests/Commands/RequestMakeCommandTest.php b/tests/Commands/RequestMakeCommandTest.php index bb5a81249..b4b4546db 100644 --- a/tests/Commands/RequestMakeCommandTest.php +++ b/tests/Commands/RequestMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_form_request_class() + public function test_it_generates_a_new_form_request_class() { $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); @@ -41,8 +40,7 @@ public function it_generates_a_new_form_request_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); @@ -52,8 +50,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.request.path', 'SuperRequests'); @@ -65,8 +62,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.request.namespace', 'SuperRequests'); diff --git a/tests/Commands/ResourceMakeCommandTest.php b/tests/Commands/ResourceMakeCommandTest.php index 1ac05bf67..c6c53a57d 100644 --- a/tests/Commands/ResourceMakeCommandTest.php +++ b/tests/Commands/ResourceMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_resource_class() + public function test_it_generates_a_new_resource_class() { $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog']); @@ -41,8 +40,7 @@ public function it_generates_a_new_resource_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog']); @@ -52,8 +50,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_generate_a_collection_resource_class() + public function test_it_can_generate_a_collection_resource_class() { $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog', '--collection' => true]); @@ -63,8 +60,7 @@ public function it_can_generate_a_collection_resource_class() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.resource.path', 'app/Http/Resources'); @@ -76,8 +72,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.resource.namespace', 'Http\\Resources'); diff --git a/tests/Commands/RouteProviderMakeCommandTest.php b/tests/Commands/RouteProviderMakeCommandTest.php index f69a05f12..b1334f021 100644 --- a/tests/Commands/RouteProviderMakeCommandTest.php +++ b/tests/Commands/RouteProviderMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_service_provider_class() + public function test_it_generates_a_new_service_provider_class() { $path = $this->modulePath . '/Providers/RouteServiceProvider.php'; $this->finder->delete($path); @@ -43,8 +42,7 @@ public function it_generates_a_new_service_provider_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_file_with_content() + public function test_it_generated_correct_file_with_content() { $path = $this->modulePath . '/Providers/RouteServiceProvider.php'; $this->finder->delete($path); @@ -56,8 +54,7 @@ public function it_generated_correct_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.provider.path', 'SuperProviders'); @@ -69,8 +66,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.provider.namespace', 'SuperProviders'); @@ -84,8 +80,7 @@ public function it_can_change_the_default_namespace_specific() $this->assertSame(0, $code); } - /** @test */ - public function it_can_overwrite_route_file_names() + public function test_it_can_overwrite_route_file_names() { $this->app['config']->set('modules.stubs.files.routes/web', 'SuperRoutes/web.php'); $this->app['config']->set('modules.stubs.files.routes/api', 'SuperRoutes/api.php'); @@ -98,8 +93,7 @@ public function it_can_overwrite_route_file_names() $this->assertSame(0, $code); } - /** @test */ - public function it_can_overwrite_file(): void + public function test_it_can_overwrite_file(): void { $this->artisan('module:route-provider', ['module' => 'Blog']); $this->app['config']->set('modules.stubs.files.routes/web', 'SuperRoutes/web.php'); @@ -111,8 +105,7 @@ public function it_can_overwrite_file(): void $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_custom_controller_namespace(): void + public function test_it_can_change_the_custom_controller_namespace(): void { $this->app['config']->set('modules.paths.generator.controller.path', 'Base/Http/Controllers'); $this->app['config']->set('modules.paths.generator.provider.path', 'Base/Providers'); diff --git a/tests/Commands/RuleMakeCommandTest.php b/tests/Commands/RuleMakeCommandTest.php index b961f115b..9310029b9 100644 --- a/tests/Commands/RuleMakeCommandTest.php +++ b/tests/Commands/RuleMakeCommandTest.php @@ -32,8 +32,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_makes_rule() + public function test_it_makes_rule() { $code = $this->artisan('module:make-rule', ['name' => 'UniqueRule', 'module' => 'Blog']); @@ -44,8 +43,7 @@ public function it_makes_rule() $this->assertSame(0, $code); } - /** @test */ - public function it_makes_implicit_rule() + public function test_it_makes_implicit_rule() { $code = $this->artisan('module:make-rule', ['name' => 'ImplicitUniqueRule', 'module' => 'Blog', '--implicit' => true]); @@ -56,8 +54,7 @@ public function it_makes_implicit_rule() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace() + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.rules.path', 'SuperRules'); @@ -69,8 +66,7 @@ public function it_can_change_the_default_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_namespace_specific() + public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.rules.namespace', 'SuperRules'); diff --git a/tests/Commands/TestMakeCommandTest.php b/tests/Commands/TestMakeCommandTest.php index ff87c4689..9b57eb47c 100644 --- a/tests/Commands/TestMakeCommandTest.php +++ b/tests/Commands/TestMakeCommandTest.php @@ -40,8 +40,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_generates_a_new_unit_test_class() + public function test_it_generates_a_new_unit_test_class() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); @@ -49,8 +48,7 @@ public function it_generates_a_new_unit_test_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generates_a_new_feature_test_class() + public function test_it_generates_a_new_feature_test_class() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); @@ -58,8 +56,7 @@ public function it_generates_a_new_feature_test_class() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_unit_file_with_content() + public function test_it_generated_correct_unit_file_with_content() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); @@ -69,8 +66,7 @@ public function it_generated_correct_unit_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_generated_correct_feature_file_with_content() + public function test_it_generated_correct_feature_file_with_content() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); @@ -80,8 +76,7 @@ public function it_generated_correct_feature_file_with_content() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_unit_namespace() + public function test_it_can_change_the_default_unit_namespace() { $this->app['config']->set('modules.paths.generator.test-unit.path', 'SuperTests/Unit'); @@ -93,8 +88,7 @@ public function it_can_change_the_default_unit_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_unit_namespace_specific() + public function test_it_can_change_the_default_unit_namespace_specific() { $this->app['config']->set('modules.paths.generator.test.namespace', 'SuperTests\\Unit'); @@ -106,8 +100,7 @@ public function it_can_change_the_default_unit_namespace_specific() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_feature_namespace() + public function test_it_can_change_the_default_feature_namespace() { $this->app['config']->set('modules.paths.generator.test-feature.path', 'SuperTests/Feature'); @@ -119,8 +112,7 @@ public function it_can_change_the_default_feature_namespace() $this->assertSame(0, $code); } - /** @test */ - public function it_can_change_the_default_feature_namespace_specific() + public function test_it_can_change_the_default_feature_namespace_specific() { $this->app['config']->set('modules.paths.generator.test-feature.namespace', 'SuperTests\\Feature'); diff --git a/tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..55d364bf9 --- /dev/null +++ b/tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,24 @@ +json([]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + + return response()->json([]); + } + + /** + * Show the specified resource. + */ + public function show($id) + { + // + + return response()->json([]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + // + + return response()->json([]); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + // + + return response()->json([]); + } +} diff --git a/tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..7d9e697fe --- /dev/null +++ b/tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,34 @@ +view('view.name'); + } +} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..45f802ffe --- /dev/null +++ b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,29 @@ +view('view.name'); + } +} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..5bee369ee --- /dev/null +++ b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,29 @@ +view('view.name'); + } +} diff --git a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..e8b586751 --- /dev/null +++ b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,17 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt new file mode 100644 index 000000000..88fa2f36b --- /dev/null +++ b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt @@ -0,0 +1,24 @@ +id(); + + $table->timestamps(); + }); + } +}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt new file mode 100644 index 000000000..6546dae4d --- /dev/null +++ b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt @@ -0,0 +1,30 @@ +id(); + $table->integer('user_id')->unsigned(); + $table->foreign('user_id')->references('id')->on('users'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..5c74c8eca --- /dev/null +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,22 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt new file mode 100644 index 000000000..0006937ff --- /dev/null +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt @@ -0,0 +1,67 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('product_details'); + } +}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt new file mode 100644 index 000000000..36dc20e86 --- /dev/null +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt new file mode 100644 index 000000000..36dc20e86 --- /dev/null +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__1.txt b/tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__1.txt new file mode 100644 index 000000000..e817d836b --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__1.txt @@ -0,0 +1,3 @@ +{ + "WrongModule": true +} \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__2.txt b/tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__2.txt new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__2.txt @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt new file mode 100644 index 000000000..ad1ad48fd --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt new file mode 100644 index 000000000..bc3afb929 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt @@ -0,0 +1,59 @@ +json([]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + + return response()->json([]); + } + + /** + * Show the specified resource. + */ + public function show($id) + { + // + + return response()->json([]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + // + + return response()->json([]); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + // + + return response()->json([]); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt new file mode 100644 index 000000000..6abbddde9 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt new file mode 100644 index 000000000..bab850316 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt new file mode 100644 index 000000000..cbdf7602e --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('blog', BlogController::class)->names('blog'); +}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt new file mode 100644 index 000000000..746cae739 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt @@ -0,0 +1,30 @@ +{ + "name": "nwidart/blog", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Blog\\": "app/", + "Modules\\Blog\\Database\\Factories\\": "database/factories/", + "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Blog\\Tests\\": "tests/" + } + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt new file mode 100644 index 000000000..92e3b4504 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt @@ -0,0 +1,11 @@ +{ + "name": "Blog", + "alias": "blog", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Blog\\Providers\\BlogServiceProvider" + ], + "files": [] +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt new file mode 100644 index 000000000..da938d49a --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt new file mode 100644 index 000000000..ad1ad48fd --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt new file mode 100644 index 000000000..6a89e8c29 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt @@ -0,0 +1,67 @@ +call([]); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt new file mode 100644 index 000000000..bab850316 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt new file mode 100644 index 000000000..72d694d39 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-blog', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-blog', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/Blog/resources/assets/sass/app.scss', +// 'Modules/Blog/resources/assets/js/app.js', +//]; \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt new file mode 100644 index 000000000..ad1ad48fd --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt new file mode 100644 index 000000000..6a89e8c29 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt @@ -0,0 +1,67 @@ +call([]); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt new file mode 100644 index 000000000..bab850316 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt new file mode 100644 index 000000000..ad1ad48fd --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt new file mode 100644 index 000000000..6a89e8c29 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -0,0 +1,67 @@ +call([]); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt new file mode 100644 index 000000000..bab850316 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt new file mode 100644 index 000000000..082efd6d4 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt @@ -0,0 +1,19 @@ +names('blog'); +}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt new file mode 100644 index 000000000..c59f26953 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt @@ -0,0 +1,11 @@ +{ + "name": "Blog", + "alias": "blog", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Blog\\Base\\Providers\\BlogServiceProvider" + ], + "files": [] +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt new file mode 100644 index 000000000..746cae739 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt @@ -0,0 +1,30 @@ +{ + "name": "nwidart/blog", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Blog\\": "app/", + "Modules\\Blog\\Database\\Factories\\": "database/factories/", + "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Blog\\Tests\\": "tests/" + } + } +} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..4fb9ff311 --- /dev/null +++ b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,48 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..4fb9ff311 --- /dev/null +++ b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,48 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..53e7ab765 --- /dev/null +++ b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,48 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/tests/Commands/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt b/tests/Commands/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt new file mode 100644 index 000000000..f2b38c90d --- /dev/null +++ b/tests/Commands/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt @@ -0,0 +1,48 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..b4c6f48d6 --- /dev/null +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt new file mode 100644 index 000000000..4f132a028 --- /dev/null +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..922456f3d --- /dev/null +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,24 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..f217f1ecf --- /dev/null +++ b/tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,26 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..4d24c8e15 --- /dev/null +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..4d24c8e15 --- /dev/null +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt new file mode 100644 index 000000000..68d0fd9d6 --- /dev/null +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/SuperRoutes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt new file mode 100644 index 000000000..10aaad55e --- /dev/null +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/SuperRoutes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/SuperRoutes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..bab850316 --- /dev/null +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,59 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..23757e05f --- /dev/null +++ b/tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,17 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt new file mode 100644 index 000000000..dba6e35a1 --- /dev/null +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt @@ -0,0 +1,20 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt new file mode 100644 index 000000000..273dc9657 --- /dev/null +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt new file mode 100644 index 000000000..fa38564fb --- /dev/null +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt new file mode 100644 index 000000000..91888aa9d --- /dev/null +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt @@ -0,0 +1,20 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt new file mode 100644 index 000000000..fa38564fb --- /dev/null +++ b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/tests/ContractsServiceProviderTest.php b/tests/ContractsServiceProviderTest.php index cbd4f0e5c..08deba898 100644 --- a/tests/ContractsServiceProviderTest.php +++ b/tests/ContractsServiceProviderTest.php @@ -7,8 +7,7 @@ class ContractsServiceProviderTest extends BaseTestCase { - /** @test */ - public function it_binds_repository_interface_with_implementation() + public function test_it_binds_repository_interface_with_implementation() { $this->assertInstanceOf(LaravelFileRepository::class, app(RepositoryInterface::class)); } diff --git a/tests/GenerateConfigReaderTest.php b/tests/GenerateConfigReaderTest.php index 6b0e3a050..714aceb17 100644 --- a/tests/GenerateConfigReaderTest.php +++ b/tests/GenerateConfigReaderTest.php @@ -7,8 +7,7 @@ final class GenerateConfigReaderTest extends BaseTestCase { - /** @test */ - public function it_can_read_a_configuration_value_with_new_format() + public function test_it_can_read_a_configuration_value_with_new_format() { $seedConfig = GenerateConfigReader::read('seeder'); @@ -17,8 +16,7 @@ public function it_can_read_a_configuration_value_with_new_format() $this->assertTrue($seedConfig->generate()); } - /** @test */ - public function it_can_read_a_configuration_value_with_new_format_set_to_false() + public function test_it_can_read_a_configuration_value_with_new_format_set_to_false() { $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false]); @@ -29,8 +27,7 @@ public function it_can_read_a_configuration_value_with_new_format_set_to_false() $this->assertFalse($seedConfig->generate()); } - /** @test */ - public function it_can_read_a_configuration_value_with_old_format() + public function test_it_can_read_a_configuration_value_with_old_format() { $this->app['config']->set('modules.paths.generator.seeder', 'Database/Seeders'); @@ -41,8 +38,7 @@ public function it_can_read_a_configuration_value_with_old_format() $this->assertTrue($seedConfig->generate()); } - /** @test */ - public function it_can_read_a_configuration_value_with_old_format_set_to_false() + public function test_it_can_read_a_configuration_value_with_old_format_set_to_false() { $this->app['config']->set('modules.paths.generator.seeder', false); @@ -53,8 +49,7 @@ public function it_can_read_a_configuration_value_with_old_format_set_to_false() $this->assertFalse($seedConfig->generate()); } - /** @test */ - public function it_can_guess_namespace_from_path() + public function test_it_can_guess_namespace_from_path() { $this->app['config']->set('modules.paths.generator.provider', ['path' => 'Base/Providers', 'generate' => true]); diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php index 4c7f0751e..1db913561 100644 --- a/tests/HelpersTest.php +++ b/tests/HelpersTest.php @@ -30,14 +30,12 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_finds_the_module_path() + public function test_it_finds_the_module_path() { $this->assertTrue(Str::contains(module_path('Blog'), 'modules/Blog')); } - /** @test */ - public function it_can_bind_a_relative_path_to_module_path() + public function test_it_can_bind_a_relative_path_to_module_path() { $this->assertTrue(Str::contains(module_path('Blog', 'config/config.php'), 'modules/Blog/config/config.php')); } diff --git a/tests/JsonTest.php b/tests/JsonTest.php index 2cfe521d6..c5d1e2752 100644 --- a/tests/JsonTest.php +++ b/tests/JsonTest.php @@ -19,16 +19,14 @@ public function setUp(): void $this->json = new Json($path, $this->app['files']); } - /** @test */ - public function it_gets_the_file_path() + public function test_it_gets_the_file_path() { $path = __DIR__ . '/stubs/valid/module.json'; $this->assertEquals($path, $this->json->getPath()); } - /** @test */ - public function it_throws_an_exception_with_invalid_json() + public function test_it_throws_an_exception_with_invalid_json() { $path = __DIR__ . '/stubs/InvalidJsonModule/module.json'; @@ -38,8 +36,7 @@ public function it_throws_an_exception_with_invalid_json() new Json($path, $this->app['files']); } - /** @test */ - public function it_gets_attributes_from_json_file() + public function test_it_gets_attributes_from_json_file() { $this->assertEquals('Order', $this->json->get('name')); $this->assertEquals('order', $this->json->get('alias')); @@ -50,8 +47,7 @@ public function it_gets_attributes_from_json_file() $this->assertEquals(1, $this->json->get('order')); } - /** @test */ - public function it_reads_attributes_from_magic_get_method() + public function test_it_reads_attributes_from_magic_get_method() { $this->assertEquals('Order', $this->json->name); $this->assertEquals('order', $this->json->alias); @@ -62,8 +58,7 @@ public function it_reads_attributes_from_magic_get_method() $this->assertEquals(1, $this->json->order); } - /** @test */ - public function it_makes_json_class() + public function test_it_makes_json_class() { $path = __DIR__ . '/stubs/valid/module.json'; $json = Json::make($path, $this->app['files']); @@ -71,8 +66,7 @@ public function it_makes_json_class() $this->assertInstanceOf(Json::class, $json); } - /** @test */ - public function it_sets_a_path() + public function test_it_sets_a_path() { $path = __DIR__ . '/stubs/valid/module.json'; $this->assertEquals($path, $this->json->getPath()); @@ -81,8 +75,7 @@ public function it_sets_a_path() $this->assertEquals('some/path.json', $this->json->getPath()); } - /** @test */ - public function it_decodes_json() + public function test_it_decodes_json() { $expected = '{ "name": "Order", @@ -107,16 +100,14 @@ public function it_decodes_json() $this->assertEquals($expected, $this->json->toJsonPretty()); } - /** @test */ - public function it_sets_a_key_value() + public function test_it_sets_a_key_value() { $this->json->set('key', 'value'); $this->assertEquals('value', $this->json->get('key')); } - /** @test */ - public function it_can_be_casted_to_string() + public function test_it_can_be_casted_to_string() { $expected = '{ "name": "Order", diff --git a/tests/LaravelFileRepositoryTest.php b/tests/LaravelFileRepositoryTest.php index 9c544672f..77b28731b 100644 --- a/tests/LaravelFileRepositoryTest.php +++ b/tests/LaravelFileRepositoryTest.php @@ -35,8 +35,7 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_adds_location_to_paths() + public function test_it_adds_location_to_paths() { $this->repository->addLocation('some/path'); @@ -45,8 +44,7 @@ public function it_adds_location_to_paths() $this->assertEquals('some/path', $paths[0]); } - /** @test */ - public function it_returns_a_collection() + public function test_it_returns_a_collection() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -54,8 +52,7 @@ public function it_returns_a_collection() $this->assertInstanceOf(Collection::class, $this->repository->collections()); } - /** @test */ - public function it_returns_all_enabled_modules() + public function test_it_returns_all_enabled_modules() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -63,8 +60,7 @@ public function it_returns_all_enabled_modules() $this->assertCount(0, $this->repository->allEnabled()); } - /** @test */ - public function it_returns_all_disabled_modules() + public function test_it_returns_all_disabled_modules() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -72,32 +68,28 @@ public function it_returns_all_disabled_modules() $this->assertCount(2, $this->repository->allDisabled()); } - /** @test */ - public function it_counts_all_modules() + public function test_it_counts_all_modules() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); $this->assertEquals(2, $this->repository->count()); } - /** @test */ - public function it_finds_a_module() + public function test_it_finds_a_module() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); $this->assertInstanceOf(Module::class, $this->repository->find('recipe')); } - /** @test */ - public function it_find_or_fail_throws_exception_if_module_not_found() + public function test_it_find_or_fail_throws_exception_if_module_not_found() { $this->expectException(ModuleNotFoundException::class); $this->repository->findOrFail('something'); } - /** @test */ - public function it_finds_the_module_asset_path() + public function test_it_finds_the_module_asset_path() { $this->repository->addLocation(__DIR__ . '/stubs/valid/Recipe'); $assetPath = $this->repository->assetPath('recipe'); @@ -105,16 +97,14 @@ public function it_finds_the_module_asset_path() $this->assertEquals(public_path('modules/recipe'), $assetPath); } - /** @test */ - public function it_gets_the_used_storage_path() + public function test_it_gets_the_used_storage_path() { $path = $this->repository->getUsedStoragePath(); $this->assertEquals(storage_path('app/modules/modules.used'), $path); } - /** @test */ - public function it_sets_used_module() + public function test_it_sets_used_module() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -123,28 +113,24 @@ public function it_sets_used_module() $this->assertEquals('Recipe', $this->repository->getUsedNow()); } - /** @test */ - public function it_returns_laravel_filesystem() + public function test_it_returns_laravel_filesystem() { $this->assertInstanceOf(Filesystem::class, $this->repository->getFiles()); } - /** @test */ - public function it_gets_the_assets_path() + public function test_it_gets_the_assets_path() { $this->assertEquals(public_path('modules'), $this->repository->getAssetsPath()); } - /** @test */ - public function it_gets_a_specific_module_asset() + public function test_it_gets_a_specific_module_asset() { $path = $this->repository->asset('recipe:test.js'); $this->assertEquals('//localhost/modules/recipe/test.js', $path); } - /** @test */ - public function it_throws_exception_if_module_is_omitted() + public function test_it_throws_exception_if_module_is_omitted() { $this->expectException(InvalidAssetPath::class); $this->expectExceptionMessage('Module name was not specified in asset [test.js].'); @@ -152,8 +138,7 @@ public function it_throws_exception_if_module_is_omitted() $this->repository->asset('test.js'); } - /** @test */ - public function it_can_detect_if_module_is_active() + public function test_it_can_detect_if_module_is_active() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -162,8 +147,7 @@ public function it_can_detect_if_module_is_active() $this->assertTrue($this->repository->isEnabled('Recipe')); } - /** @test */ - public function it_can_detect_if_module_is_inactive() + public function test_it_can_detect_if_module_is_inactive() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -172,30 +156,26 @@ public function it_can_detect_if_module_is_inactive() $this->assertTrue($this->repository->isDisabled('Recipe')); } - /** @test */ - public function it_can_get_and_set_the_stubs_path() + public function test_it_can_get_and_set_the_stubs_path() { $this->repository->setStubPath('some/stub/path'); $this->assertEquals('some/stub/path', $this->repository->getStubPath()); } - /** @test */ - public function it_gets_the_configured_stubs_path_if_enabled() + public function test_it_gets_the_configured_stubs_path_if_enabled() { $this->app['config']->set('modules.stubs.enabled', true); $this->assertEquals(base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'), $this->repository->getStubPath()); } - /** @test */ - public function it_returns_default_stub_path() + public function test_it_returns_default_stub_path() { $this->assertNull($this->repository->getStubPath()); } - /** @test */ - public function it_can_disabled_a_module() + public function test_it_can_disabled_a_module() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -204,8 +184,7 @@ public function it_can_disabled_a_module() $this->assertTrue($this->repository->isDisabled('Recipe')); } - /** @test */ - public function it_can_enable_a_module() + public function test_it_can_enable_a_module() { $this->repository->addLocation(__DIR__ . '/stubs/valid'); @@ -214,8 +193,7 @@ public function it_can_enable_a_module() $this->assertTrue($this->repository->isEnabled('Recipe')); } - /** @test */ - public function it_can_delete_a_module() + public function test_it_can_delete_a_module() { $this->artisan('module:make', ['name' => ['Blog']]); @@ -224,8 +202,7 @@ public function it_can_delete_a_module() $this->assertFalse(is_dir(base_path('modules/Blog'))); } - /** @test */ - public function it_can_register_macros() + public function test_it_can_register_macros() { Module::macro('registeredMacro', function () { }); @@ -233,14 +210,12 @@ public function it_can_register_macros() $this->assertTrue(Module::hasMacro('registeredMacro')); } - /** @test */ - public function it_does_not_have_unregistered_macros() + public function test_it_does_not_have_unregistered_macros() { $this->assertFalse(Module::hasMacro('unregisteredMacro')); } - /** @test */ - public function it_calls_macros_on_modules() + public function test_it_calls_macros_on_modules() { Module::macro('getReverseName', function () { return strrev($this->getLowerName()); diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index e3933bd55..7d5ea7267 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -45,44 +45,37 @@ public static function tearDownAfterClass(): void unlink(__DIR__.'/stubs/valid_symlink'); } - /** @test */ - public function it_gets_module_name() + public function test_it_gets_module_name() { $this->assertEquals('Recipe Name', $this->module->getName()); } - /** @test */ - public function it_gets_lowercase_module_name() + public function test_it_gets_lowercase_module_name() { $this->assertEquals('recipe name', $this->module->getLowerName()); } - /** @test */ - public function it_gets_studly_name() + public function test_it_gets_studly_name() { $this->assertEquals('RecipeName', $this->module->getStudlyName()); } - /** @test */ - public function it_gets_snake_name() + public function test_it_gets_snake_name() { $this->assertEquals('recipe_name', $this->module->getSnakeName()); } - /** @test */ - public function it_gets_module_description() + public function test_it_gets_module_description() { $this->assertEquals('recipe module', $this->module->getDescription()); } - /** @test */ - public function it_gets_module_path() + public function test_it_gets_module_path() { $this->assertEquals(__DIR__.'/stubs/valid/Recipe', $this->module->getPath()); } - /** @test */ - public function it_gets_module_path_with_symlink() + public function test_it_gets_module_path_with_symlink() { // symlink created in setUpBeforeClass @@ -93,15 +86,13 @@ public function it_gets_module_path_with_symlink() // symlink deleted in tearDownAfterClass } - /** @test */ - public function it_loads_module_translations() + public function test_it_loads_module_translations() { (new TestingModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'))->boot(); $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); } - /** @test */ - public function it_reads_module_json_files() + public function test_it_reads_module_json_files() { $jsonModule = $this->module->json(); $composerJson = $this->module->json('composer.json'); @@ -112,8 +103,7 @@ public function it_reads_module_json_files() $this->assertEquals('asgard-module', $composerJson->get('type')); } - /** @test */ - public function it_reads_key_from_module_json_file_via_helper_method() + public function test_it_reads_key_from_module_json_file_via_helper_method() { $this->assertEquals('Recipe', $this->module->get('name')); $this->assertEquals('0.1', $this->module->get('version')); @@ -121,34 +111,29 @@ public function it_reads_key_from_module_json_file_via_helper_method() $this->assertEquals(['required_module'], $this->module->get('requires')); } - /** @test */ - public function it_reads_key_from_composer_json_file_via_helper_method() + public function test_it_reads_key_from_composer_json_file_via_helper_method() { $this->assertEquals('nwidart/recipe', $this->module->getComposerAttr('name')); } - /** @test */ - public function it_casts_module_to_string() + public function test_it_casts_module_to_string() { $this->assertEquals('RecipeName', (string) $this->module); } - /** @test */ - public function it_module_status_check() + public function test_it_module_status_check() { $this->assertFalse($this->module->isStatus(true)); $this->assertTrue($this->module->isStatus(false)); } - /** @test */ - public function it_checks_module_enabled_status() + public function test_it_checks_module_enabled_status() { $this->assertFalse($this->module->isEnabled()); $this->assertTrue($this->module->isDisabled()); } - /** @test */ - public function it_sets_active_status(): void + public function test_it_sets_active_status(): void { $this->module->setActive(true); $this->assertTrue($this->module->isEnabled()); @@ -156,8 +141,7 @@ public function it_sets_active_status(): void $this->assertFalse($this->module->isEnabled()); } - /** @test */ - public function it_fires_events_when_module_is_enabled() + public function test_it_fires_events_when_module_is_enabled() { Event::fake(); @@ -167,8 +151,7 @@ public function it_fires_events_when_module_is_enabled() Event::assertDispatched(sprintf('modules.%s.enabled', $this->module->getLowerName())); } - /** @test */ - public function it_fires_events_when_module_is_disabled() + public function test_it_fires_events_when_module_is_disabled() { Event::fake(); @@ -178,8 +161,7 @@ public function it_fires_events_when_module_is_disabled() Event::assertDispatched(sprintf('modules.%s.disabled', $this->module->getLowerName())); } - /** @test */ - public function it_has_a_good_providers_manifest_path() + public function test_it_has_a_good_providers_manifest_path() { $this->assertEquals( $this->app->bootstrapPath("cache/{$this->module->getSnakeName()}_module.php"), @@ -187,8 +169,7 @@ public function it_has_a_good_providers_manifest_path() ); } - /** @test */ - public function it_makes_a_manifest_file_when_providers_are_loaded() + public function test_it_makes_a_manifest_file_when_providers_are_loaded() { $cachedServicesPath = $this->module->getCachedServicesPath(); @@ -212,8 +193,7 @@ public function it_makes_a_manifest_file_when_providers_are_loaded() ], $manifest); } - /** @test */ - public function it_can_load_a_deferred_provider() + public function test_it_can_load_a_deferred_provider() { @unlink($this->module->getCachedServicesPath()); @@ -231,8 +211,7 @@ public function it_can_load_a_deferred_provider() $this->assertEquals('bar', app('foo')); } - /** @test */ - public function it_can_load_assets_is_empty_when_no_manifest_exists() + public function test_it_can_load_assets_is_empty_when_no_manifest_exists() { $this->assertEquals([], $this->module->getAssets()); } diff --git a/tests/LaravelModulesServiceProviderTest.php b/tests/LaravelModulesServiceProviderTest.php index 4cb35c11c..45cf67900 100644 --- a/tests/LaravelModulesServiceProviderTest.php +++ b/tests/LaravelModulesServiceProviderTest.php @@ -8,21 +8,18 @@ class LaravelModulesServiceProviderTest extends BaseTestCase { - /** @test */ - public function it_binds_modules_key_to_repository_class() + public function test_it_binds_modules_key_to_repository_class() { $this->assertInstanceOf(RepositoryInterface::class, app(RepositoryInterface::class)); $this->assertInstanceOf(RepositoryInterface::class, app('modules')); } - /** @test */ - public function it_binds_activator_to_activator_class() + public function test_it_binds_activator_to_activator_class() { $this->assertInstanceOf(ActivatorInterface::class, app(ActivatorInterface::class)); } - /** @test */ - public function it_throws_exception_if_config_is_invalid() + public function test_it_throws_exception_if_config_is_invalid() { $this->expectException(InvalidActivatorClass::class); diff --git a/tests/LumenModuleTest.php b/tests/LumenModuleTest.php index 73ab59522..a71362664 100644 --- a/tests/LumenModuleTest.php +++ b/tests/LumenModuleTest.php @@ -31,51 +31,43 @@ public function tearDown(): void parent::tearDown(); } - /** @test */ - public function it_gets_module_name() + public function test_it_gets_module_name() { $this->assertEquals('Recipe Name', $this->module->getName()); } - /** @test */ - public function it_gets_lowercase_module_name() + public function test_it_gets_lowercase_module_name() { $this->assertEquals('recipe name', $this->module->getLowerName()); } - /** @test */ - public function it_gets_studly_name() + public function test_it_gets_studly_name() { $this->assertEquals('RecipeName', $this->module->getStudlyName()); } - /** @test */ - public function it_gets_snake_name() + public function test_it_gets_snake_name() { $this->assertEquals('recipe_name', $this->module->getSnakeName()); } - /** @test */ - public function it_gets_module_description() + public function test_it_gets_module_description() { $this->assertEquals('recipe module', $this->module->getDescription()); } - /** @test */ - public function it_gets_module_path() + public function test_it_gets_module_path() { $this->assertEquals(__DIR__ . '/stubs/valid/Recipe', $this->module->getPath()); } - /** @test */ - public function it_loads_module_translations() + public function test_it_loads_module_translations() { (new LumenTestingModule($this->app, 'Recipe', __DIR__ . '/stubs/valid/Recipe'))->boot(); $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); } - /** @test */ - public function it_reads_module_json_files() + public function test_it_reads_module_json_files() { $jsonModule = $this->module->json(); $composerJson = $this->module->json('composer.json'); @@ -86,8 +78,7 @@ public function it_reads_module_json_files() $this->assertEquals('asgard-module', $composerJson->get('type')); } - /** @test */ - public function it_reads_key_from_module_json_file_via_helper_method() + public function test_it_reads_key_from_module_json_file_via_helper_method() { $this->assertEquals('Recipe', $this->module->get('name')); $this->assertEquals('0.1', $this->module->get('version')); @@ -95,34 +86,29 @@ public function it_reads_key_from_module_json_file_via_helper_method() $this->assertEquals(['required_module'], $this->module->get('requires')); } - /** @test */ - public function it_reads_key_from_composer_json_file_via_helper_method() + public function test_it_reads_key_from_composer_json_file_via_helper_method() { $this->assertEquals('nwidart/recipe', $this->module->getComposerAttr('name')); } - /** @test */ - public function it_casts_module_to_string() + public function test_it_casts_module_to_string() { $this->assertEquals('RecipeName', (string) $this->module); } - /** @test */ - public function it_module_status_check() + public function test_it_module_status_check() { $this->assertFalse($this->module->isStatus(true)); $this->assertTrue($this->module->isStatus(false)); } - /** @test */ - public function it_checks_module_enabled_status() + public function test_it_checks_module_enabled_status() { $this->assertFalse($this->module->isEnabled()); $this->assertTrue($this->module->isDisabled()); } - /** @test */ - public function it_fires_events_when_module_is_enabled() + public function test_it_fires_events_when_module_is_enabled() { Event::fake(); @@ -132,8 +118,7 @@ public function it_fires_events_when_module_is_enabled() Event::assertDispatched(sprintf('modules.%s.enabled', $this->module->getLowerName())); } - /** @test */ - public function it_fires_events_when_module_is_disabled() + public function test_it_fires_events_when_module_is_disabled() { Event::fake(); @@ -143,8 +128,7 @@ public function it_fires_events_when_module_is_disabled() Event::assertDispatched(sprintf('modules.%s.disabled', $this->module->getLowerName())); } - /** @test */ - public function it_has_a_good_providers_manifest_path() + public function test_it_has_a_good_providers_manifest_path() { $this->assertEquals( $this->app->basePath("storage/app/{$this->module->getSnakeName()}_module.php"), diff --git a/tests/ModuleFacadeTest.php b/tests/ModuleFacadeTest.php index 5bd37a56e..e015b03a0 100644 --- a/tests/ModuleFacadeTest.php +++ b/tests/ModuleFacadeTest.php @@ -6,16 +6,14 @@ class ModuleFacadeTest extends BaseTestCase { - /** @test */ - public function it_resolves_the_module_facade() + public function test_it_resolves_the_module_facade() { $modules = Module::all(); $this->assertTrue(is_array($modules)); } - /** @test */ - public function it_creates_macros_via_facade() + public function test_it_creates_macros_via_facade() { $modules = Module::macro('testMacro', function () { return true; @@ -24,8 +22,7 @@ public function it_creates_macros_via_facade() $this->assertTrue(Module::hasMacro('testMacro')); } - /** @test */ - public function it_calls_macros_via_facade() + public function test_it_calls_macros_via_facade() { $modules = Module::macro('testMacro', function () { return 'a value'; diff --git a/tests/NameParserTest.php b/tests/NameParserTest.php index 731e21ade..7360110f7 100644 --- a/tests/NameParserTest.php +++ b/tests/NameParserTest.php @@ -6,24 +6,21 @@ class NameParserTest extends \PHPUnit\Framework\TestCase { - /** @test */ - public function it_gets_the_original_name() + public function test_it_gets_the_original_name() { $parser = new NameParser('create_users_table'); self::assertEquals('create_users_table', $parser->getOriginalName()); } - /** @test */ - public function it_gets_the_table_name() + public function test_it_gets_the_table_name() { $parser = new NameParser('create_users_table'); self::assertEquals('users', $parser->getTableName()); } - /** @test */ - public function it_gets_the_action_name() + public function test_it_gets_the_action_name() { self::assertEquals('create', (new NameParser('create_users_table'))->getAction()); self::assertEquals('update', (new NameParser('update_users_table'))->getAction()); @@ -31,14 +28,12 @@ public function it_gets_the_action_name() self::assertEquals('remove', (new NameParser('remove_users_table'))->getAction()); } - /** @test */ - public function it_gets_first_part_of_name_if_no_action_was_guessed() + public function test_it_gets_first_part_of_name_if_no_action_was_guessed() { self::assertEquals('something', (new NameParser('something_random'))->getAction()); } - /** @test */ - public function it_gets_the_correct_matched_results() + public function test_it_gets_the_correct_matched_results() { $matches = (new NameParser('create_users_table'))->getMatches(); @@ -50,8 +45,7 @@ public function it_gets_the_correct_matched_results() self::assertEquals($expected, $matches); } - /** @test */ - public function it_gets_the_exploded_parts_of_migration_name() + public function test_it_gets_the_exploded_parts_of_migration_name() { $parser = new NameParser('create_users_table'); @@ -64,40 +58,34 @@ public function it_gets_the_exploded_parts_of_migration_name() self::assertEquals($expected, $parser->getData()); } - /** @test */ - public function it_can_check_if_current_migration_type_matches_given_type() + public function test_it_can_check_if_current_migration_type_matches_given_type() { $parser = new NameParser('create_users_table'); self::assertTrue($parser->is('create')); } - /** @test */ - public function it_can_check_if_current_migration_is_about_adding() + public function test_it_can_check_if_current_migration_is_about_adding() { self::assertTrue((new NameParser('add_users_table'))->isAdd()); } - /** @test */ - public function it_can_check_if_current_migration_is_about_deleting() + public function test_it_can_check_if_current_migration_is_about_deleting() { self::assertTrue((new NameParser('delete_users_table'))->isDelete()); } - /** @test */ - public function it_can_check_if_current_migration_is_about_creating() + public function test_it_can_check_if_current_migration_is_about_creating() { self::assertTrue((new NameParser('create_users_table'))->isCreate()); } - /** @test */ - public function it_can_check_if_current_migration_is_about_dropping() + public function test_it_can_check_if_current_migration_is_about_dropping() { self::assertTrue((new NameParser('drop_users_table'))->isDrop()); } - /** @test */ - public function it_makes_a_regex_pattern() + public function test_it_makes_a_regex_pattern() { self::assertEquals('/create_(.*)_table/', (new NameParser('create_users_table'))->getPattern()); self::assertEquals('/add_(.*)_to_(.*)_table/', (new NameParser('add_column_to_users_table'))->getPattern()); diff --git a/tests/SchemaParserTest.php b/tests/SchemaParserTest.php index d4016087a..c1730721b 100644 --- a/tests/SchemaParserTest.php +++ b/tests/SchemaParserTest.php @@ -6,8 +6,7 @@ class SchemaParserTest extends \PHPUnit\Framework\TestCase { - /** @test */ - public function it_generates_migration_method_calls() + public function test_it_generates_migration_method_calls() { $parser = new SchemaParser('username:string, password:integer'); @@ -19,8 +18,7 @@ public function it_generates_migration_method_calls() self::assertEquals($expected, $parser->render()); } - /** @test */ - public function it_generates_migration_methods_for_up_method() + public function test_it_generates_migration_methods_for_up_method() { $parser = new SchemaParser('username:string, password:integer'); @@ -32,8 +30,7 @@ public function it_generates_migration_methods_for_up_method() self::assertEquals($expected, $parser->up()); } - /** @test */ - public function it_generates_migration_methods_for_down_method() + public function test_it_generates_migration_methods_for_down_method() { $parser = new SchemaParser('username:string, password:integer'); diff --git a/tests/StubTest.php b/tests/StubTest.php index 6e5ee5ad1..76eda24cd 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -28,8 +28,7 @@ public function tearDown(): void ]); } - /** @test */ - public function it_initialises_a_stub_instance() + public function test_it_initialises_a_stub_instance() { $stub = new Stub('/model.stub', [ 'NAME' => 'Name', @@ -39,8 +38,7 @@ public function it_initialises_a_stub_instance() $this->assertEquals(['NAME' => 'Name', ], $stub->getReplaces()); } - /** @test */ - public function it_sets_new_replaces_array() + public function test_it_sets_new_replaces_array() { $stub = new Stub('/model.stub', [ 'NAME' => 'Name', @@ -50,8 +48,7 @@ public function it_sets_new_replaces_array() $this->assertEquals(['VENDOR' => 'MyVendor', ], $stub->getReplaces()); } - /** @test */ - public function it_stores_stub_to_specific_path() + public function test_it_stores_stub_to_specific_path() { $stub = new Stub('/command.stub', [ 'COMMAND_NAME' => 'my:command', @@ -64,8 +61,7 @@ public function it_stores_stub_to_specific_path() $this->assertTrue($this->finder->exists(base_path('my-command.php'))); } - /** @test */ - public function it_sets_new_path() + public function test_it_sets_new_path() { $stub = new Stub('/model.stub', [ 'NAME' => 'Name', @@ -76,8 +72,7 @@ public function it_sets_new_path() $this->assertTrue(Str::contains($stub->getPath(), 'Commands/stubs/new-path/')); } - /** @test */ - public function use_default_stub_if_override_not_exists() + public function test_use_default_stub_if_override_not_exists() { $stub = new Stub('/command.stub', [ 'COMMAND_NAME' => 'my:command', @@ -92,8 +87,7 @@ public function use_default_stub_if_override_not_exists() $this->assertTrue($this->finder->exists(base_path('stub-override-not-exists.php'))); } - /** @test */ - public function use_override_stub_if_exists() + public function test_use_override_stub_if_exists() { $stub = new Stub('/model.stub', [ 'NAME' => 'Name', From f2101f851517dd230293d9719a88b205d08225b1 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 19:28:54 +0000 Subject: [PATCH 217/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a95a20d7..e35c95656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.0 - 2024-03-19 + ## Fixed - [@Subtixx](https://github.com/subtixx) Fix Issue #1752 - Hardcoded string + undefined variable @@ -12,6 +14,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed +- [@dcblogdev](https://github.com/dcblogdev) Added support for Laravel 11 - [@solomon-ochepa](https://github.com/solomon-ochepa) updated API route stub to use controller - [@solomon-ochepa](https://github.com/solomon-ochepa) updated config comments - [@alissn](https://github.com/alissn) rearrange Command Classes into Folders and Update Namespace Structure @@ -20,6 +23,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Updated +- [@dcblogdev](https://github.com/dcblogdev) updated tests for compatability with PhpUnit 12 - [@dcblogdev](https://github.com/dcblogdev) added replacement placeholders in config for API stubs - [@dcblogdev](https://github.com/dcblogdev) updated vite to rename placeholder with module name - [@alissn](https://github.com/alissn) Updated commands to use Laravel Prompt From c025b5898a30fcc9a2202a1dc266b6c3e78080b4 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 19:36:23 +0000 Subject: [PATCH 218/422] test for php 8.2+ --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9d6479e14..966043c1e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -10,7 +10,7 @@ jobs: strategy: max-parallel: 2 matrix: - php-versions: ['8.1', '8.2', '8.3'] + php-versions: ['8.2', '8.3'] name: PHP ${{ matrix.php-versions }} From e7c4959898f3eef2e617acff29cf5901f07fc4d3 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 22:30:01 +0000 Subject: [PATCH 219/422] ensure class_exists for both Capital and lower case namespaces --- src/Commands/Database/SeedCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Commands/Database/SeedCommand.php b/src/Commands/Database/SeedCommand.php index 29069b27f..a0b42f468 100644 --- a/src/Commands/Database/SeedCommand.php +++ b/src/Commands/Database/SeedCommand.php @@ -101,6 +101,7 @@ public function moduleSeed(Module $module) $seeders = []; $name = $module->getName(); $config = $module->get('migration'); + if (is_array($config) && array_key_exists('seeds', $config)) { foreach ((array)$config['seeds'] as $class) { if (class_exists($class)) { @@ -109,6 +110,9 @@ public function moduleSeed(Module $module) } } else { $class = $this->getSeederName($name); //legacy support + + $class = implode('\\', array_map('ucwords', explode('\\', $class))); + if (class_exists($class)) { $seeders[] = $class; } else { From 0bf878965c1952fbedcdf2711824a31b9b43c30b Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 23:02:44 +0000 Subject: [PATCH 220/422] set route service provider to use blank namespace by default --- src/Commands/stubs/route-provider.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/route-provider.stub b/src/Commands/stubs/route-provider.stub index e5aa0b5f3..3c2082c9b 100644 --- a/src/Commands/stubs/route-provider.stub +++ b/src/Commands/stubs/route-provider.stub @@ -10,7 +10,7 @@ class $CLASS$ extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. From f22bf8f4ac5edff6465e98345c56d28303b051da Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 23:34:34 +0000 Subject: [PATCH 221/422] create database folders by default --- config/config.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/config.php b/config/config.php index 4674f121f..c57502d9d 100644 --- a/config/config.php +++ b/config/config.php @@ -128,7 +128,8 @@ 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], - // app/HTTP/ + + // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], 'filter' => ['path' => 'app/Http/Middleware', 'generate' => false], 'request' => ['path' => 'app/Http/Requests', 'generate' => false], @@ -137,15 +138,15 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ - 'migration' => ['path' => 'database/migrations', 'generate' => false], - 'seeder' => ['path' => 'database/seeders', 'generate' => false], - 'factory' => ['path' => 'database/factories', 'generate' => false], + 'migration' => ['path' => 'database/migrations', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], // resource/ - 'assets' => ['path' => 'resources/assets', 'generate' => false], + 'assets' => ['path' => 'resources/assets', 'generate' => true], 'views' => ['path' => 'resources/views', 'generate' => true], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], From 93a2bdff094a7cddd175a340602ee58cc17db829 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 19 Mar 2024 23:59:09 +0000 Subject: [PATCH 222/422] updated CHANGELOG.md --- CHANGELOG.md | 12 ++++++------ ...est_it_generates_api_module_with_resources__4.txt | 2 +- ...ndTest__test_it_generates_module_resources__4.txt | 2 +- ...est_it_generates_web_module_with_resources__4.txt | 2 +- ...resources_when_adding_more_than_one_option__4.txt | 2 +- ...can_change_the_custom_controller_namespace__1.txt | 2 +- ...__test_it_can_change_the_default_namespace__1.txt | 2 +- ..._can_change_the_default_namespace_specific__1.txt | 2 +- ...akeCommandTest__test_it_can_overwrite_file__1.txt | 2 +- ...st__test_it_can_overwrite_route_file_names__1.txt | 2 +- ...est_it_generated_correct_file_with_content__1.txt | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e35c95656..04307853e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,18 +14,18 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changed +- [@dcblogdev](https://github.com/dcblogdev) ensure class_exists for both Capital and lower case namespaces +- [@dcblogdev](https://github.com/dcblogdev) create database folders by default +- [@dcblogdev](https://github.com/dcblogdev) set route service provider to use blank namespace by default +- [@dcblogdev](https://github.com/dcblogdev) updated tests for compatability with PhpUnit 12 +- [@dcblogdev](https://github.com/dcblogdev) added replacement placeholders in config for API stubs +- [@dcblogdev](https://github.com/dcblogdev) updated vite to rename placeholder with module name - [@dcblogdev](https://github.com/dcblogdev) Added support for Laravel 11 - [@solomon-ochepa](https://github.com/solomon-ochepa) updated API route stub to use controller - [@solomon-ochepa](https://github.com/solomon-ochepa) updated config comments - [@alissn](https://github.com/alissn) rearrange Command Classes into Folders and Update Namespace Structure - [@alissn](https://github.com/alissn) delete command module:migrate-fresh - [@alissn](https://github.com/alissn) Fixing Case of tests/Unit and tests/Feature - -## Updated - -- [@dcblogdev](https://github.com/dcblogdev) updated tests for compatability with PhpUnit 12 -- [@dcblogdev](https://github.com/dcblogdev) added replacement placeholders in config for API stubs -- [@dcblogdev](https://github.com/dcblogdev) updated vite to rename placeholder with module name - [@alissn](https://github.com/alissn) Updated commands to use Laravel Prompt - [@dcblogdev](https://github.com/dcblogdev) updated event stub to include Dispatchable and InteractsWithSockets traits diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt index bab850316..2eb4671f7 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt index bab850316..2eb4671f7 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt index bab850316..2eb4671f7 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt index bab850316..2eb4671f7 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt index 4415d0ded..945cb4092 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\Base\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 4d24c8e15..6136997bc 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 4d24c8e15..6136997bc 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt index 68d0fd9d6..2b0e78ade 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt index 10aaad55e..5055401d7 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index bab850316..2eb4671f7 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -10,7 +10,7 @@ class RouteServiceProvider extends ServiceProvider /** * The module namespace to assume when generating URLs to actions. */ - protected string $moduleNamespace = 'Modules\Blog\app\Http\Controllers'; + protected string $moduleNamespace = ''; /** * Called before routes are registered. From 2244a055b2179c7655b229265e99ccd637058322 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 20 Mar 2024 01:23:43 +0000 Subject: [PATCH 223/422] create tests folders --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index c57502d9d..a27f9f2ff 100644 --- a/config/config.php +++ b/config/config.php @@ -154,8 +154,8 @@ 'routes' => ['path' => 'routes', 'generate' => true], // tests/ - 'test-unit' => ['path' => 'tests/Unit', 'generate' => false], - 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], + 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], ], ], From e5740b63ddcace83ac6173c07af2b86af28c6297 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 20 Mar 2024 02:04:19 +0000 Subject: [PATCH 224/422] updated README.md --- README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d76e3d964..c10215ebe 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ [![Latest Version on Packagist](https://img.shields.io/packagist/v/nwidart/laravel-modules.svg?style=flat-square)](https://packagist.org/packages/nwidart/laravel-modules) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) -[![Build Status](https://img.shields.io/travis/nWidart/laravel-modules/master.svg?style=flat-square)](https://travis-ci.org/nWidart/laravel-modules) [![Scrutinizer Coverage](https://img.shields.io/scrutinizer/coverage/g/nWidart/laravel-modules.svg?maxAge=86400&style=flat-square)](https://scrutinizer-ci.com/g/nWidart/laravel-modules/?branch=master) -[![Quality Score](https://img.shields.io/scrutinizer/g/nWidart/laravel-modules.svg?style=flat-square)](https://scrutinizer-ci.com/g/nWidart/laravel-modules) [![Total Downloads](https://img.shields.io/packagist/dt/nwidart/laravel-modules.svg?style=flat-square)](https://packagist.org/packages/nwidart/laravel-modules) | **Laravel** | **laravel-modules** | @@ -19,6 +17,7 @@ | 8.0 | ^8.0 | | 9.0 | ^9.0 | | 10.0 | ^10.0 | +| 11.0 | ^11.0 | `nwidart/laravel-modules` is a Laravel package which created to manage your large Laravel app using modules. Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 10. @@ -43,17 +42,20 @@ php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProv ``` ### Autoloading -By default, module classes aren't loaded automatically. To autoload them using psr-4, add the following line to the end of the root composer.json file under the autoload section: -``` json -{ - "autoload": { - "psr-4": { - "App\\": "app/", - "Database\\Factories\\": "database/factories/", - "Database\\Seeders\\": "database/seeders/", - "Modules\\": "Modules/" - } -} + +By default the module classes are not loaded automatically. You can autoload your modules by adding merge-plugin to the extra section: + +```json +"extra": { + "laravel": { + "dont-discover": [] + }, + "merge-plugin": { + "include": [ + "Modules/*/composer.json" + ] + } +}, ``` **Tip: don't forget to run `composer dump-autoload` afterwards.** From 9507a35092dc84e960acb66aad19a011dabc28e6 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Tue, 19 Mar 2024 19:57:06 -0700 Subject: [PATCH 225/422] Update route-provider.stub namespace() usage has been updated since Laravel 8.x - https://laravel.com/docs/8.x/upgrade?ref=BestOfLaravel.com#routing 2. The name('api.') method aids in prefixing API route names to differentiate them from web route names. --- src/Commands/stubs/route-provider.stub | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Commands/stubs/route-provider.stub b/src/Commands/stubs/route-provider.stub index 3c2082c9b..585a69146 100644 --- a/src/Commands/stubs/route-provider.stub +++ b/src/Commands/stubs/route-provider.stub @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class $CLASS$ extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class $CLASS$ extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('$MODULE$', '$WEB_ROUTES_PATH$')); + Route::middleware('web')->group(module_path('$MODULE$', '$WEB_ROUTES_PATH$')); } /** @@ -51,9 +44,6 @@ class $CLASS$ extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('$MODULE$', '$API_ROUTES_PATH$')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('$MODULE$', '$API_ROUTES_PATH$')); } } From 795015e4c27b55eeee5f23fcdcb75bd2d0a6f962 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 20 Mar 2024 12:59:03 +0330 Subject: [PATCH 226/422] [fix] fix erorr csFix with blank_lines_before_namespace --- .php-cs-fixer.dist.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index bc7239069..1efd6b3d4 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -19,8 +19,6 @@ 'no_whitespace_in_blank_line' => true, // There MUST be one blank line after the namespace declaration. 'blank_line_after_namespace' => true, - // There should be exactly one blank line before a namespace declaration. - 'single_blank_line_before_namespace' => true, // Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block. 'single_line_after_imports' => true, // Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline. From e01fc2d29fb634dce54d82fb627677165141289e Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 20 Mar 2024 12:59:45 +0330 Subject: [PATCH 227/422] [style] run command php-cs-fixer --- src/Commands/Actions/CheckLangCommand.php | 21 ++++++------ src/Commands/Actions/DisableCommand.php | 2 +- src/Commands/Actions/DumpCommand.php | 2 +- src/Commands/Actions/EnableCommand.php | 2 +- src/Commands/Actions/ModelPruneCommand.php | 32 +++++++++++-------- src/Commands/Actions/ModelShowCommand.php | 1 - src/Commands/Actions/UnUseCommand.php | 2 +- src/Commands/Actions/UpdateCommand.php | 2 +- src/Commands/Actions/UseCommand.php | 2 +- src/Commands/BaseCommand.php | 15 +++++---- src/Commands/ComposerUpdateCommand.php | 6 ++-- src/Commands/Database/MigrateCommand.php | 11 +++---- .../Database/MigrateRefreshCommand.php | 1 - src/Commands/Database/MigrateResetCommand.php | 8 ++--- .../Database/MigrateRollbackCommand.php | 12 +++---- .../Database/MigrateStatusCommand.php | 4 +-- src/Commands/Database/SeedCommand.php | 18 +++++------ .../Make/ComponentViewMakeCommand.php | 2 +- src/Commands/Make/ControllerMakeCommand.php | 4 +-- src/Commands/Make/GeneratorCommand.php | 26 +++++++-------- src/Commands/Make/ModelMakeCommand.php | 10 +++--- src/Commands/Make/ObserverMakeCommand.php | 7 ++-- .../Make/RouteProviderMakeCommand.php | 4 +-- src/Commands/Publish/PublishCommand.php | 3 +- .../Publish/PublishConfigurationCommand.php | 2 +- .../Publish/PublishMigrationCommand.php | 2 +- .../Publish/PublishTranslationCommand.php | 2 +- src/Generators/ModuleGenerator.php | 14 ++++---- src/Module.php | 1 + src/ModulesServiceProvider.php | 2 +- src/Publishing/Publisher.php | 4 +-- tests/LaravelModuleTest.php | 14 ++++---- .../stubs/valid/Recipe/Http/backendRoutes.php | 2 +- 33 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/Commands/Actions/CheckLangCommand.php b/src/Commands/Actions/CheckLangCommand.php index d15b0c516..991603125 100644 --- a/src/Commands/Actions/CheckLangCommand.php +++ b/src/Commands/Actions/CheckLangCommand.php @@ -7,7 +7,6 @@ class CheckLangCommand extends BaseCommand { - private $langPath; /** @@ -47,7 +46,7 @@ public function executeAction($name): void } - function getInfo(): string|null + public function getInfo(): string|null { return 'Checking languages ...'; } @@ -84,12 +83,14 @@ private function getDirectories($module) if (count($directories) == 0) { $this->components->info("No language files found in module $moduleName"); - return FALSE; + + return false; } if (count($directories) == 1) { $this->components->warn("Only one language file found in module $moduleName"); - return FALSE; + + return false; } return collect($directories); @@ -138,14 +139,13 @@ private function checkMissingKeys(Collection $directories) $uniqeLangFiles = $directories->pluck('files')->flatten()->unique(); $langDirectories = $directories->pluck('name'); - $missingKeysMessage = []; $directories->each(function ($directory) use ($uniqeLangFiles, $langDirectories, &$missingKeysMessage) { $uniqeLangFiles->each(function ($file) use ($directory, $langDirectories, &$missingKeysMessage) { $langKeys = $this->getLangKeys($directory['path'] . DIRECTORY_SEPARATOR . $file); - if ($langKeys == FALSE) { + if ($langKeys == false) { return; } @@ -157,7 +157,7 @@ private function checkMissingKeys(Collection $directories) $otherLangKeys = $this->getLangKeys($basePath . DIRECTORY_SEPARATOR . $file); - if ($otherLangKeys == FALSE) { + if ($otherLangKeys == false) { return; } @@ -174,7 +174,6 @@ private function checkMissingKeys(Collection $directories) }); }); - if (count($missingKeysMessage) > 0) { collect($missingKeysMessage)->each(function ($messages, $langDirectory) { @@ -194,10 +193,10 @@ private function getLangKeys($file) { if (\File::exists($file)) { $lang = \File::getRequire($file); + return collect(\Arr::dot($lang))->keys(); - } - else { - return FALSE; + } else { + return false; } } } diff --git a/src/Commands/Actions/DisableCommand.php b/src/Commands/Actions/DisableCommand.php index 9f1afda1d..f05372dbb 100644 --- a/src/Commands/Actions/DisableCommand.php +++ b/src/Commands/Actions/DisableCommand.php @@ -40,7 +40,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Disabling module ...'; } diff --git a/src/Commands/Actions/DumpCommand.php b/src/Commands/Actions/DumpCommand.php index 692bbcd40..5b632effa 100644 --- a/src/Commands/Actions/DumpCommand.php +++ b/src/Commands/Actions/DumpCommand.php @@ -31,7 +31,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Generating optimized autoload modules'; } diff --git a/src/Commands/Actions/EnableCommand.php b/src/Commands/Actions/EnableCommand.php index e9434557b..2ed80cb41 100644 --- a/src/Commands/Actions/EnableCommand.php +++ b/src/Commands/Actions/EnableCommand.php @@ -33,7 +33,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Disabling module ...'; } diff --git a/src/Commands/Actions/ModelPruneCommand.php b/src/Commands/Actions/ModelPruneCommand.php index 46bcef508..eacfb39f0 100644 --- a/src/Commands/Actions/ModelPruneCommand.php +++ b/src/Commands/Actions/ModelPruneCommand.php @@ -7,15 +7,17 @@ use Illuminate\Support\Collection; use Illuminate\Support\Str; use InvalidArgumentException; + +use function Laravel\Prompts\multiselect; + use Nwidart\Modules\Facades\Module; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; -use function Laravel\Prompts\multiselect; class ModelPruneCommand extends PruneCommand implements PromptsForMissingInput { - const ALL = 'All'; + public const ALL = 'All'; protected $name = 'module:prune'; @@ -43,6 +45,7 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf { if ($this->option('all')) { $input->setArgument('module', [self::ALL]); + return; } @@ -55,14 +58,14 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf required: 'You must select at least one module', ); - $input->setArgument('module', + $input->setArgument( + 'module', value: in_array(self::ALL, $selected_item) ? [self::ALL] : $selected_item ); } - /** * Determine the models that should be pruned. * @@ -83,27 +86,30 @@ protected function models(): Collection } if ($this->argument('module') == [self::ALL]) { - $path = sprintf('%s/*/%s', + $path = sprintf( + '%s/*/%s', config('modules.paths.modules'), config('modules.paths.generator.model.path') ); - } - else { - $path = sprintf('%s/{%s}/%s', + } else { + $path = sprintf( + '%s/{%s}/%s', config('modules.paths.modules'), collect($this->argument('module'))->implode(','), - config('modules.paths.generator.model.path')); + config('modules.paths.generator.model.path') + ); } return collect(Finder::create()->in($path)->files()->name('*.php')) ->map(function ($model) { $namespace = config('modules.namespace'); + return $namespace . str_replace( - ['/', '.php'], - ['\\', ''], - Str::after($model->getRealPath(), realpath(config('modules.paths.modules'))) - ); + ['/', '.php'], + ['\\', ''], + Str::after($model->getRealPath(), realpath(config('modules.paths.modules'))) + ); })->values() ->when(! empty($except), function ($models) use ($except) { return $models->reject(function ($model) use ($except) { diff --git a/src/Commands/Actions/ModelShowCommand.php b/src/Commands/Actions/ModelShowCommand.php index 43dc23c3b..9b48eeb91 100644 --- a/src/Commands/Actions/ModelShowCommand.php +++ b/src/Commands/Actions/ModelShowCommand.php @@ -31,7 +31,6 @@ class ModelShowCommand extends ShowModelCommand {--database= : The database connection to use} {--json : Output the model as JSON}'; - /** * Qualify the given model class base name. * diff --git a/src/Commands/Actions/UnUseCommand.php b/src/Commands/Actions/UnUseCommand.php index dcdd77803..c649d64bf 100644 --- a/src/Commands/Actions/UnUseCommand.php +++ b/src/Commands/Actions/UnUseCommand.php @@ -29,7 +29,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Forget Using Module ...'; } diff --git a/src/Commands/Actions/UpdateCommand.php b/src/Commands/Actions/UpdateCommand.php index 5befc36b7..69daf7223 100644 --- a/src/Commands/Actions/UpdateCommand.php +++ b/src/Commands/Actions/UpdateCommand.php @@ -29,7 +29,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Updating Module ...'; } diff --git a/src/Commands/Actions/UseCommand.php b/src/Commands/Actions/UseCommand.php index 78cad8a22..d5f0cf1e6 100644 --- a/src/Commands/Actions/UseCommand.php +++ b/src/Commands/Actions/UseCommand.php @@ -29,7 +29,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Using Module ...'; } diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 2a5f6ac6d..02b8e6bb5 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -4,16 +4,17 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Console\PromptsForMissingInput; -use Nwidart\Modules\Facades\Module; + +use function Laravel\Prompts\multiselect; + use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use function Laravel\Prompts\multiselect; abstract class BaseCommand extends Command implements PromptsForMissingInput { - const ALL = 'All'; + public const ALL = 'All'; /** * Create a new console command instance. @@ -37,11 +38,11 @@ public function __construct() )); } - abstract function executeAction($name); + abstract public function executeAction($name); public function getInfo(): string|null { - return NULL; + return null; } /** @@ -66,6 +67,7 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf if ($input->getOption(strtolower(self::ALL))) { $input->setArgument('module', $modules); + return; } @@ -82,7 +84,8 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf required: 'You must select at least one module', ); - $input->setArgument('module', + $input->setArgument( + 'module', value: in_array(self::ALL, $selected_item) ? $modules : $selected_item diff --git a/src/Commands/ComposerUpdateCommand.php b/src/Commands/ComposerUpdateCommand.php index 4a2614655..64b45279f 100644 --- a/src/Commands/ComposerUpdateCommand.php +++ b/src/Commands/ComposerUpdateCommand.php @@ -28,7 +28,7 @@ public function executeAction($name): void $composer_path = $module->getPath() . DIRECTORY_SEPARATOR . 'composer.json'; - $composer = json_decode(File::get($composer_path), TRUE); + $composer = json_decode(File::get($composer_path), true); $autoload = data_get($composer, 'autoload.psr-4'); @@ -38,7 +38,7 @@ public function executeAction($name): void $key_name_with_app = sprintf('Modules\\%s\\App\\', $module->getStudlyName()); - if (! array_key_exists($key_name_with_app, $autoload) ) { + if (! array_key_exists($key_name_with_app, $autoload)) { return; } @@ -53,7 +53,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Updating Composer.json of modules...'; } diff --git a/src/Commands/Database/MigrateCommand.php b/src/Commands/Database/MigrateCommand.php index ab970e8fe..eae23eef2 100644 --- a/src/Commands/Database/MigrateCommand.php +++ b/src/Commands/Database/MigrateCommand.php @@ -22,7 +22,6 @@ class MigrateCommand extends BaseCommand */ protected $description = 'Migrate the migrations from the specified module or from all modules.'; - public function executeAction($name): void { $module = $this->getModuleModel($name); @@ -57,11 +56,11 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], - ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], - ['pretend', NULL, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], - ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], - ['seed', NULL, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], - ['subpath', NULL, InputOption::VALUE_OPTIONAL, 'Indicate a subpath to run your migrations from'], + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], + ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath to run your migrations from'], ]; } } diff --git a/src/Commands/Database/MigrateRefreshCommand.php b/src/Commands/Database/MigrateRefreshCommand.php index 38350d38c..a7adfdcd0 100644 --- a/src/Commands/Database/MigrateRefreshCommand.php +++ b/src/Commands/Database/MigrateRefreshCommand.php @@ -21,7 +21,6 @@ class MigrateRefreshCommand extends BaseCommand */ protected $description = 'Rollback & re-migrate the modules migrations.'; - public function executeAction($name): void { $module = $this->getModuleModel($name); diff --git a/src/Commands/Database/MigrateResetCommand.php b/src/Commands/Database/MigrateResetCommand.php index 6f0494c58..58569b23e 100644 --- a/src/Commands/Database/MigrateResetCommand.php +++ b/src/Commands/Database/MigrateResetCommand.php @@ -52,7 +52,7 @@ public function executeAction($name): void public function getInfo(): string|null { - return NULL; + return null; } /** @@ -64,9 +64,9 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'], - ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], - ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], - ['pretend', NULL, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], ]; } } diff --git a/src/Commands/Database/MigrateRollbackCommand.php b/src/Commands/Database/MigrateRollbackCommand.php index cf87897de..3d48fbf37 100644 --- a/src/Commands/Database/MigrateRollbackCommand.php +++ b/src/Commands/Database/MigrateRollbackCommand.php @@ -41,7 +41,7 @@ public function executeAction($name): void if (count($migrated)) { foreach ($migrated as $migration) { - $this->components->task("Rollback: {$migration}",); + $this->components->task("Rollback: {$migration}", ); } return; @@ -53,7 +53,7 @@ public function executeAction($name): void public function getInfo(): string|null { - return NULL; + return null; } /** @@ -65,10 +65,10 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'], - ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], - ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], - ['pretend', NULL, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], - ['subpath', NULL, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file'], + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file'], ]; } } diff --git a/src/Commands/Database/MigrateStatusCommand.php b/src/Commands/Database/MigrateStatusCommand.php index 1e36012dc..83fae9cf5 100644 --- a/src/Commands/Database/MigrateStatusCommand.php +++ b/src/Commands/Database/MigrateStatusCommand.php @@ -41,7 +41,7 @@ public function executeAction($name): void public function getInfo(): string|null { - return NULL; + return null; } /** @@ -53,7 +53,7 @@ protected function getOptions() { return [ ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], - ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ]; } } diff --git a/src/Commands/Database/SeedCommand.php b/src/Commands/Database/SeedCommand.php index a0b42f468..29e9802c7 100644 --- a/src/Commands/Database/SeedCommand.php +++ b/src/Commands/Database/SeedCommand.php @@ -38,24 +38,22 @@ public function executeAction($name): void $this->components->task("Seeding {$module->getName()} Module", function () use ($module) { try { $this->moduleSeed($module); - } - catch (\Error $e) { + } catch (\Error $e) { $e = new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e); $this->reportException($e); $this->renderException($this->getOutput(), $e); - return FALSE; - } - catch (\Exception $e) { + return false; + } catch (\Exception $e) { $this->reportException($e); $this->renderException($this->getOutput(), $e); - return FALSE; + return false; } }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Seeding module ...'; } @@ -228,9 +226,9 @@ protected function reportException(\Exception $e) protected function getOptions() { return [ - ['class', NULL, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], - ['database', NULL, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'], - ['force', NULL, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'], + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ]; } } diff --git a/src/Commands/Make/ComponentViewMakeCommand.php b/src/Commands/Make/ComponentViewMakeCommand.php index 86812e3be..c797b7d65 100644 --- a/src/Commands/Make/ComponentViewMakeCommand.php +++ b/src/Commands/Make/ComponentViewMakeCommand.php @@ -52,7 +52,7 @@ protected function getArguments() */ protected function getTemplateContents() { - return (new Stub('/component-view.stub', ['QUOTE'=> Inspiring::quote()]))->render(); + return (new Stub('/component-view.stub', ['QUOTE' => Inspiring::quote()]))->render(); } /** diff --git a/src/Commands/Make/ControllerMakeCommand.php b/src/Commands/Make/ControllerMakeCommand.php index 04c91ae47..a1436e400 100644 --- a/src/Commands/Make/ControllerMakeCommand.php +++ b/src/Commands/Make/ControllerMakeCommand.php @@ -117,8 +117,8 @@ private function getControllerNameWithoutNamespace() public function getDefaultNamespace(): string { - return config('modules.paths.generator.controller.namespace' ) - ?? ltrim(config('modules.paths.generator.controller.path','Http/Controllers'),config('modules.paths.app_folder')); + return config('modules.paths.generator.controller.namespace') + ?? ltrim(config('modules.paths.generator.controller.path', 'Http/Controllers'), config('modules.paths.app_folder')); } /** diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index ee2d897e4..f305f7777 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -36,23 +36,23 @@ public function handle(): int { $path = str_replace('\\', '/', $this->getDestinationFilePath()); - if (!$this->laravel['files']->isDirectory($dir = dirname($path))) { - $this->laravel['files']->makeDirectory($dir, 0777, true); - } + if (!$this->laravel['files']->isDirectory($dir = dirname($path))) { + $this->laravel['files']->makeDirectory($dir, 0777, true); + } - $contents = $this->getTemplateContents(); + $contents = $this->getTemplateContents(); - try { - $this->components->task("Generating file {$path}",function () use ($path,$contents) { - $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; - (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); - }); + try { + $this->components->task("Generating file {$path}", function () use ($path, $contents) { + $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; + (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); + }); - } catch (FileAlreadyExistException $e) { - $this->components->error("File : {$path} already exists."); + } catch (FileAlreadyExistException $e) { + $this->components->error("File : {$path} already exists."); - return E_ERROR; - } + return E_ERROR; + } return 0; } diff --git a/src/Commands/Make/ModelMakeCommand.php b/src/Commands/Make/ModelMakeCommand.php index ed78a2333..a4a87215a 100644 --- a/src/Commands/Make/ModelMakeCommand.php +++ b/src/Commands/Make/ModelMakeCommand.php @@ -61,7 +61,7 @@ private function createMigrationName() $string = ''; foreach ($pieces as $i => $piece) { - if ($i+1 < count($pieces)) { + if ($i + 1 < count($pieces)) { $string .= strtolower($piece) . '_'; } else { $string .= Str::plural(strtolower($piece)); @@ -126,7 +126,7 @@ private function handleOptionalControllerOption() ])); } } - + /** * Create a seeder file for the model. * @@ -139,7 +139,7 @@ protected function handleOptionalSeedOption() $this->call('module:make-seed', array_filter([ 'name' => $seedName, - 'module' => $this->argument('module') + 'module' => $this->argument('module'), ])); } } @@ -154,7 +154,7 @@ protected function handleOptionalFactoryOption() if ($this->option('factory') === true) { $this->call('module:make-factory', array_filter([ 'name' => $this->getModelName(), - 'module' => $this->argument('module') + 'module' => $this->argument('module'), ])); } } @@ -171,7 +171,7 @@ protected function handleOptionalRequestOption() $this->call('module:make-request', array_filter([ 'name' => $requestName, - 'module' => $this->argument('module') + 'module' => $this->argument('module'), ])); } } diff --git a/src/Commands/Make/ObserverMakeCommand.php b/src/Commands/Make/ObserverMakeCommand.php index 98a1138ae..50aeae979 100644 --- a/src/Commands/Make/ObserverMakeCommand.php +++ b/src/Commands/Make/ObserverMakeCommand.php @@ -19,7 +19,6 @@ class ObserverMakeCommand extends GeneratorCommand */ protected $name = 'module:make-observer'; - /** * The name of argument name. * @@ -53,6 +52,7 @@ protected function getArguments() protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + return (new Stub('/observer.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), 'NAME' => $this->getModelName(), @@ -86,9 +86,9 @@ private function getModelName() /** * @return mixed|string */ - private function getModelVariable() : string + private function getModelVariable(): string { - return '$'.Str::lower($this->argument('name')); + return '$' . Str::lower($this->argument('name')); } /** @@ -111,7 +111,6 @@ private function getFileName() return Str::studly($this->argument('name')) . 'Observer.php'; } - public function handle(): int { $this->components->info('Creating observer...'); diff --git a/src/Commands/Make/RouteProviderMakeCommand.php b/src/Commands/Make/RouteProviderMakeCommand.php index c925f0423..2881019b4 100644 --- a/src/Commands/Make/RouteProviderMakeCommand.php +++ b/src/Commands/Make/RouteProviderMakeCommand.php @@ -108,8 +108,8 @@ protected function getApiRoutesPath() public function getDefaultNamespace(): string { - return config('modules.paths.generator.provider.namespace' ) - ?? ltrim(config('modules.paths.generator.provider.path','Providers'),config('modules.paths.app_folder','')); + return config('modules.paths.generator.provider.namespace') + ?? ltrim(config('modules.paths.generator.provider.path', 'Providers'), config('modules.paths.app_folder', '')); } /** diff --git a/src/Commands/Publish/PublishCommand.php b/src/Commands/Publish/PublishCommand.php index 291a4555c..65622d89f 100644 --- a/src/Commands/Publish/PublishCommand.php +++ b/src/Commands/Publish/PublishCommand.php @@ -21,7 +21,6 @@ class PublishCommand extends BaseCommand */ protected $description = 'Publish a module\'s assets to the application'; - public function executeAction($name): void { $module = $this->getModuleModel($name); @@ -35,7 +34,7 @@ public function executeAction($name): void } - function getInfo(): string|null + public function getInfo(): string|null { return 'Publishing module asset files ...'; } diff --git a/src/Commands/Publish/PublishConfigurationCommand.php b/src/Commands/Publish/PublishConfigurationCommand.php index 5e0ffda88..8c62b1fbf 100644 --- a/src/Commands/Publish/PublishConfigurationCommand.php +++ b/src/Commands/Publish/PublishConfigurationCommand.php @@ -31,7 +31,7 @@ public function executeAction($name): void ]); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Publishing module config files ...'; } diff --git a/src/Commands/Publish/PublishMigrationCommand.php b/src/Commands/Publish/PublishMigrationCommand.php index d2dc1f731..74e815ecd 100644 --- a/src/Commands/Publish/PublishMigrationCommand.php +++ b/src/Commands/Publish/PublishMigrationCommand.php @@ -34,7 +34,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Publishing module migrations ...'; } diff --git a/src/Commands/Publish/PublishTranslationCommand.php b/src/Commands/Publish/PublishTranslationCommand.php index 4afd6dce2..75979036a 100644 --- a/src/Commands/Publish/PublishTranslationCommand.php +++ b/src/Commands/Publish/PublishTranslationCommand.php @@ -33,7 +33,7 @@ public function executeAction($name): void }); } - function getInfo(): string|null + public function getInfo(): string|null { return 'Publishing module translations ...'; } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index e15a08ccc..be4567777 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -48,7 +48,6 @@ class ModuleGenerator extends Generator */ protected $component; - /** * The activator instance * @@ -246,6 +245,7 @@ public function getComponent(): \Illuminate\Console\View\Components\Factory public function setComponent(\Illuminate\Console\View\Components\Factory $component): self { $this->component = $component; + return $this; } @@ -386,7 +386,7 @@ public function generateFiles() foreach ($this->getFiles() as $stub => $file) { $path = $this->module->getModulePath($this->getName()) . $file; - $this->component->task("Generating file {$path}",function () use ($stub, $path) { + $this->component->task("Generating file {$path}", function () use ($stub, $path) { if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } @@ -421,11 +421,11 @@ public function generateResources() } if (GenerateConfigReader::read('controller')->generate() === true) { - $options = $this->type=='api' ? ['--api'=>true] : []; + $options = $this->type == 'api' ? ['--api' => true] : []; $this->console->call('module:make-controller', [ 'controller' => $this->getName() . 'Controller', 'module' => $this->getName(), - ]+$options); + ] + $options); } } @@ -445,8 +445,6 @@ protected function getStubContents($stub) )->render(); } - - /** * get the list for the replacements. */ @@ -497,7 +495,7 @@ private function generateModuleJsonFile() { $path = $this->module->getModulePath($this->getName()) . 'module.json'; - $this->component->task("Generating file $path",function () use ($path) { + $this->component->task("Generating file $path", function () use ($path) { if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } @@ -572,7 +570,7 @@ protected function getModuleNamespaceReplacement() */ private function getControllerNamespaceReplacement(): string { - return str_replace('/', '\\', $this->module->config('paths.generator.controller.namespace') ?: ltrim($this->module->config('paths.generator.controller.path', 'Controller'),config('modules.paths.app_folder'))); + return str_replace('/', '\\', $this->module->config('paths.generator.controller.namespace') ?: ltrim($this->module->config('paths.generator.controller.path', 'Controller'), config('modules.paths.app_folder'))); } /** diff --git a/src/Module.php b/src/Module.php index 8008d2573..584c223bb 100644 --- a/src/Module.php +++ b/src/Module.php @@ -181,6 +181,7 @@ public function getPath(): string public function getAppPath(): string { $app_path = rtrim($this->getExtraPath(config('modules.paths.app_folder', '')), '/'); + return is_dir($app_path) ? $app_path : $this->getPath(); } diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index d7c10c14a..75a7a93f1 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -48,7 +48,7 @@ protected function registerNamespaces() ], 'stubs'); $this->publishes([ - __DIR__.'/../scripts/vite-module-loader.js' => base_path('vite-module-loader.js'), + __DIR__ . '/../scripts/vite-module-loader.js' => base_path('vite-module-loader.js'), ], 'vite'); } diff --git a/src/Publishing/Publisher.php b/src/Publishing/Publisher.php index 3d1488a04..433951cb6 100644 --- a/src/Publishing/Publisher.php +++ b/src/Publishing/Publisher.php @@ -185,10 +185,10 @@ public function publish() if ($this->getFilesystem()->copyDirectory($sourcePath, $destinationPath)) { if ($this->showMessage === true) { - $this->console->components->task($this->module->getStudlyName(), fn() => true); + $this->console->components->task($this->module->getStudlyName(), fn () => true); } } else { - $this->console->components->task($this->module->getStudlyName(), fn() => false); + $this->console->components->task($this->module->getStudlyName(), fn () => false); $this->console->components->error($this->error); } } diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index 7d5ea7267..3050c5526 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -23,7 +23,7 @@ class LaravelModuleTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid/Recipe'); + $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid/Recipe'); $this->activator = $this->app[ActivatorInterface::class]; } @@ -36,13 +36,13 @@ public function tearDown(): void public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - symlink(__DIR__.'/stubs/valid', __DIR__.'/stubs/valid_symlink'); + symlink(__DIR__ . '/stubs/valid', __DIR__ . '/stubs/valid_symlink'); } public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); - unlink(__DIR__.'/stubs/valid_symlink'); + unlink(__DIR__ . '/stubs/valid_symlink'); } public function test_it_gets_module_name() @@ -72,23 +72,23 @@ public function test_it_gets_module_description() public function test_it_gets_module_path() { - $this->assertEquals(__DIR__.'/stubs/valid/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__ . '/stubs/valid/Recipe', $this->module->getPath()); } public function test_it_gets_module_path_with_symlink() { // symlink created in setUpBeforeClass - $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid_symlink/Recipe'); + $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid_symlink/Recipe'); - $this->assertEquals(__DIR__.'/stubs/valid_symlink/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__ . '/stubs/valid_symlink/Recipe', $this->module->getPath()); // symlink deleted in tearDownAfterClass } public function test_it_loads_module_translations() { - (new TestingModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'))->boot(); + (new TestingModule($this->app, 'Recipe', __DIR__ . '/stubs/valid/Recipe'))->boot(); $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); } diff --git a/tests/stubs/valid/Recipe/Http/backendRoutes.php b/tests/stubs/valid/Recipe/Http/backendRoutes.php index dbae56cff..255c485a3 100644 --- a/tests/stubs/valid/Recipe/Http/backendRoutes.php +++ b/tests/stubs/valid/Recipe/Http/backendRoutes.php @@ -3,7 +3,7 @@ use Illuminate\Routing\Router; /** @var Router $router */ -$router->group(['prefix' =>'/recipe'], function (Router $router) { +$router->group(['prefix' => '/recipe'], function (Router $router) { $router->bind('recipes', function ($id) { return app('Modules\Recipe\Repositories\RecipeRepository')->find($id); }); From e6ea5ae3942b555b7c421627f2fbc8dfc9e691bc Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 20 Mar 2024 11:57:26 +0000 Subject: [PATCH 228/422] updated snapshots --- CHANGELOG.md | 5 +++++ ...t_it_generates_api_module_with_resources__4.txt | 14 ++------------ ...Test__test_it_generates_module_resources__4.txt | 14 ++------------ ...t_it_generates_web_module_with_resources__4.txt | 14 ++------------ ...sources_when_adding_more_than_one_option__4.txt | 14 ++------------ ...n_change_the_custom_controller_namespace__1.txt | 14 ++------------ ...test_it_can_change_the_default_namespace__1.txt | 14 ++------------ ...an_change_the_default_namespace_specific__1.txt | 14 ++------------ ...eCommandTest__test_it_can_overwrite_file__1.txt | 14 ++------------ ...__test_it_can_overwrite_route_file_names__1.txt | 14 ++------------ ...t_it_generated_correct_file_with_content__1.txt | 14 ++------------ 11 files changed, 25 insertions(+), 120 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04307853e..f8d106c81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Changed + +- [@alissn](https://github.com/alissn) Run command php-cs-fixer fix +- [@solomon-ochepa](https://github.com/solomon-ochepa) updated route-provider.stub to loose the optional namespace + ## 11.0.0 - 2024-03-19 ## Fixed diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt index 2eb4671f7..dc17450cc 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt index 2eb4671f7..dc17450cc 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt index 2eb4671f7..dc17450cc 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt index 2eb4671f7..dc17450cc 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt index 945cb4092..79746f865 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 6136997bc..af40c469e 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 6136997bc..af40c469e 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt index 2b0e78ade..e8d7205d7 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt index 5055401d7..7c40e3d35 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/SuperRoutes/api.php')); } } diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 2eb4671f7..dc17450cc 100644 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -7,11 +7,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * The module namespace to assume when generating URLs to actions. - */ - protected string $moduleNamespace = ''; - /** * Called before routes are registered. * @@ -39,9 +34,7 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapWebRoutes(): void { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); } /** @@ -51,9 +44,6 @@ class RouteServiceProvider extends ServiceProvider */ protected function mapApiRoutes(): void { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } From 0aec674107c391d099a2bcf0316ce02a31202e0c Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 20 Mar 2024 22:41:40 +0000 Subject: [PATCH 229/422] add module:make-view command --- .php-cs-fixer.cache | 1 + src/Commands/Make/ViewMakeCommand.php | 48 ++++++++++++++++++ src/Commands/stubs/view.stub | 3 ++ src/Providers/ConsoleServiceProvider.php | 1 + src/Traits/ModuleCommandTrait.php | 7 +-- tests/Commands/ViewMakeCommandTest.php | 64 ++++++++++++++++++++++++ 6 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 .php-cs-fixer.cache create mode 100644 src/Commands/Make/ViewMakeCommand.php create mode 100644 src/Commands/stubs/view.stub create mode 100644 tests/Commands/ViewMakeCommandTest.php diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 000000000..763997ae0 --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.2.16","version":"3.52.0:v3.52.0#a3564bd66f4bce9bc871ef18b690e2dc67a7f969","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":true,"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"concat_space":{"spacing":"one"},"no_extra_blank_lines":true,"blank_line_before_statement":true,"no_unused_imports":true,"no_empty_statement":true,"trailing_comma_in_multiline":true,"no_blank_lines_after_phpdoc":true,"phpdoc_trim":true},"hashes":{"\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2446\/src\/Commands\/Make\/ProviderMakeCommand.php":"dee9e1bcba42fa2b609be1f7692e0419","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1726\/src\/Commands\/Make\/ComponentViewMakeCommand.php":"56db971b9aa1ab60d1984565f28b3dfc","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2759\/src\/Commands\/Make\/ProviderMakeCommand.php":"dee9e1bcba42fa2b609be1f7692e0419","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4295\/src\/Commands\/Make\/ViewMakeCommand.php":"ace3812c1cbf93c17bf57655a6da2a3f","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder964\/src\/Commands\/Make\/ViewMakeCommand.php":"0ae50a6e0a64ff2eebdb213c506f54ca","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7361\/src\/Commands\/Make\/ViewMakeCommand.php":"989a430e6f8a1693f96bfbb254406e42","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder382\/src\/Commands\/Make\/ViewMakeCommand.php":"0853a023e647e8eef06f030a521bfb6c","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3011\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder993\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7452\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder753\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder906\/src\/Commands\/Make\/ViewMakeCommand.php":"5730d6865a6499fae30e9a9af5f5f4fe","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1870\/src\/Commands\/Make\/ViewMakeCommand.php":"1f12b5be6f1b48d6ea2c305dad32406c","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6596\/src\/Commands\/Make\/ViewMakeCommand.php":"1bc4121d4efef4ce71f2a9689d1a65f4","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7441\/src\/Commands\/Make\/ViewMakeCommand.php":"1cc6f94cda6fd133393a437ce322e29a","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder67\/src\/Commands\/Make\/ViewMakeCommand.php":"251ba519116b2fc5211f8369999b3b6d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2166\/src\/Commands\/Make\/ViewMakeCommand.php":"251ba519116b2fc5211f8369999b3b6d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7761\/src\/Commands\/Make\/ViewMakeCommand.php":"d418a017999108e613363f4631271fb1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3378\/src\/Commands\/Make\/ViewMakeCommand.php":"d418a017999108e613363f4631271fb1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2558\/src\/Commands\/Make\/ViewMakeCommand.php":"49841bd8c34b6ca77686d6f90fac868d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4917\/src\/Commands\/Make\/ViewMakeCommand.php":"208ceb54a11ab409976b8a17a1dc1edf","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5986\/src\/Commands\/Make\/ViewMakeCommand.php":"424f60f2a9d84a272900bb4226775dbe","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7079\/src\/Commands\/Make\/ViewMakeCommand.php":"6ee7dc4603710b3a3ff34f597e85a601","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7775\/src\/Commands\/Make\/ViewMakeCommand.php":"6ee7dc4603710b3a3ff34f597e85a601","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6731\/src\/Commands\/Make\/ViewMakeCommand.php":"e3b2a88a6770b7789b5bea860a29f13a","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7642\/src\/Commands\/Make\/ViewMakeCommand.php":"f5a2909b2d1bcf15f8b3d1f66ed75e52","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5856\/src\/Commands\/Make\/ViewMakeCommand.php":"a14be053a7df949e82fac3c82dfe50d9","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3356\/src\/Commands\/Make\/ViewMakeCommand.php":"d63b1f3ba64a0855f2d11efdbc102035","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7548\/src\/Commands\/Make\/ViewMakeCommand.php":"d63b1f3ba64a0855f2d11efdbc102035","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3046\/src\/Commands\/Make\/ViewMakeCommand.php":"e41700e139e8ff94d6a25200986b3418","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3702\/src\/Commands\/Make\/ViewMakeCommand.php":"cf63217115858ccda0e1baecf00ce0b1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2587\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder891\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5578\/src\/Traits\/ModuleCommandTrait.php":"72f3cb3290f55aa437fe58663e93d8f3","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7932\/src\/Traits\/ModuleCommandTrait.php":"01b46fa0e265da5720d4505c3e0509d4","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder776\/src\/Traits\/ModuleCommandTrait.php":"0b9488e5bcdef2f1d9cd0efceec4fe94","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2205\/src\/Traits\/ModuleCommandTrait.php":"0b9488e5bcdef2f1d9cd0efceec4fe94","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2510\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5167\/src\/Commands\/Make\/ComponentViewMakeCommand.php":"56db971b9aa1ab60d1984565f28b3dfc","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2778\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder82\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5843\/src\/Commands\/Make\/ViewMakeCommand.php":"11f2ec56618e17b2d931b0efa662cc50","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7828\/src\/Commands\/Make\/ViewMakeCommand.php":"c02c3ddffbf78b1dbcd634c57b8aab8e","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5833\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5664\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5577\/src\/Commands\/ComposerUpdateCommand.php":"1bc90d22c8f32bd65921f8156edc63e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7376\/config\/config.php":"d599906a7ae112c5684a72b33d2c4c77","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1173\/src\/Providers\/ConsoleServiceProvider.php":"be948bebf22b25670979e54110e6ffa2","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7112\/src\/Providers\/ConsoleServiceProvider.php":"57ae0ae475d5ab6f3f23f0b3c58e2046","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7035\/src\/Providers\/ConsoleServiceProvider.php":"adf823dcf6aaecd34d85eb8ba68ae192","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3254\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6725\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7200\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2236\/src\/Support\/Config\/GenerateConfigReader.php":"d5796fb17e27657437dc3d2bf0cf89bf","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3708\/config\/config.php":"d599906a7ae112c5684a72b33d2c4c77","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7367\/src\/Commands\/Make\/ViewMakeCommand.php":"cec6c18dcbbde59400e3a9751a1da219","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7176\/src\/Commands\/Make\/ViewMakeCommand.php":"cec6c18dcbbde59400e3a9751a1da219","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3916\/src\/Commands\/Make\/ViewMakeCommand.php":"cec6c18dcbbde59400e3a9751a1da219","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4002\/src\/Commands\/Make\/ViewMakeCommand.php":"e55a075964763e521f6f96739b8e17df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7810\/src\/Commands\/Make\/ViewMakeCommand.php":"e55a075964763e521f6f96739b8e17df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2417\/tests\/Commands\/ComponentViewMakeCommandTest.php":"532f52478b2612192639937a7aae8fe1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2843\/tests\/Commands\/ViewMakeCommandTest.php":"03843d4ac8075c45960f00768dc61970","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4869\/tests\/Commands\/ViewMakeCommandTest.php":"9ea6231c50c6eb08dba9b2a783b0106d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2179\/tests\/Commands\/ViewMakeCommandTest.php":"c85051be38e75bd3e6ec6843c66b2cfa","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4709\/tests\/Commands\/ViewMakeCommandTest.php":"605224b1afc7c8038f9886461b6262cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5497\/tests\/Commands\/ViewMakeCommandTest.php":"f0b51290598e43dd55caefef53015148","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6984\/tests\/Commands\/ViewMakeCommandTest.php":"6e3b2204e22dd7aac450048dfe498710","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5831\/tests\/Commands\/ViewMakeCommandTest.php":"362a3672c9f2f8fab3c951fddad2a146","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7774\/tests\/Commands\/ViewMakeCommandTest.php":"6bf05ebb6f80b2ed98dab0683f32e8d7","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7083\/tests\/Commands\/ViewMakeCommandTest.php":"d18018ccc11938aea59cfbbbdcb9c6dc","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder8165\/tests\/Commands\/ViewMakeCommandTest.php":"d0c3325b39b0e3d91eab921f79424743","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3519\/tests\/Commands\/ViewMakeCommandTest.php":"1872dee921a21c546b639b098e189a7b","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7287\/tests\/Commands\/ViewMakeCommandTest.php":"d7c3a29b3de88108ea28683c2502ae65","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder8364\/tests\/Commands\/ViewMakeCommandTest.php":"b6e8510a7493d53b5117bb4249c2f03d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1826\/tests\/Commands\/ViewMakeCommandTest.php":"a12f71420fc17c5ece31b1a2319cadde","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1523\/tests\/Commands\/ViewMakeCommandTest.php":"40c91076a9a05c8ba868e350eba6b5f6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2641\/tests\/Commands\/ViewMakeCommandTest.php":"50f8ffdeb2631b4055c7be7a8a318e7f","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3828\/tests\/Commands\/ViewMakeCommandTest.php":"a6030a8215474ca645dab5deaac000d5","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2371\/tests\/Commands\/ViewMakeCommandTest.php":"eb18766d36bfd733acd0aa9a3311a2df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1185\/tests\/Commands\/ViewMakeCommandTest.php":"99a97443772441d664588f257378e290","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2271\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder607\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1796\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder8150\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4364\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4491\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1077\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2818\/src\/Providers\/ConsoleServiceProvider.php":"adf823dcf6aaecd34d85eb8ba68ae192","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5322\/src\/Commands\/Make\/ViewMakeCommand.php":"e55a075964763e521f6f96739b8e17df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder978\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4731\/src\/Traits\/ModuleCommandTrait.php":"0b9488e5bcdef2f1d9cd0efceec4fe94"}} \ No newline at end of file diff --git a/src/Commands/Make/ViewMakeCommand.php b/src/Commands/Make/ViewMakeCommand.php new file mode 100644 index 000000000..5834bffc0 --- /dev/null +++ b/src/Commands/Make/ViewMakeCommand.php @@ -0,0 +1,48 @@ + Inspiring::quotes()->random()]))->render(); + } + + protected function getDestinationFilePath(): string + { + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $factoryPath = GenerateConfigReader::read('views'); + + return $path . $factoryPath->getPath() . '/' . $this->getFileName(); + } + + /** + * @return string + */ + private function getFileName(): string + { + return Str::lower($this->argument('name')) . '.blade.php'; + } +} diff --git a/src/Commands/stubs/view.stub b/src/Commands/stubs/view.stub new file mode 100644 index 000000000..c7ab22bb2 --- /dev/null +++ b/src/Commands/stubs/view.stub @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index ee90bd4a8..78d9a44e9 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -73,6 +73,7 @@ public static function defaultCommands(): Collection Commands\Make\RuleMakeCommand::class, Commands\Make\SeedMakeCommand::class, Commands\Make\TestMakeCommand::class, + Commands\Make\ViewMakeCommand::class, //Publish Commands Commands\Publish\PublishCommand::class, diff --git a/src/Traits/ModuleCommandTrait.php b/src/Traits/ModuleCommandTrait.php index 969834a4a..65e31d83b 100644 --- a/src/Traits/ModuleCommandTrait.php +++ b/src/Traits/ModuleCommandTrait.php @@ -4,12 +4,7 @@ trait ModuleCommandTrait { - /** - * Get the module name. - * - * @return string - */ - public function getModuleName() + public function getModuleName(): string { $module = $this->argument('module') ?: app('modules')->getUsedNow(); diff --git a/tests/Commands/ViewMakeCommandTest.php b/tests/Commands/ViewMakeCommandTest.php new file mode 100644 index 000000000..371e8e784 --- /dev/null +++ b/tests/Commands/ViewMakeCommandTest.php @@ -0,0 +1,64 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_the_view() + { + $code = $this->artisan('module:make-view', ['name' => 'Blog', 'module' => 'Blog']); + $this->assertTrue(is_file($this->getModuleBasePath() . '/resources/views/blog.blade.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-view', ['name' => 'Blog', 'module' => 'Blog']); + $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/blog.blade.php'); + $this->assertTrue(str_contains($file, '
')); + $this->assertSame(0, $code); + } + + public function test_it_can_change_the_default_namespace() + { + $this->app['config']->set('modules.paths.generator.views.path', 'resources/views'); + + $code = $this->artisan('module:make-view', ['name' => 'Blog', 'module' => 'Blog']); + + $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/blog.blade.php'); + + $this->assertTrue(str_contains($file, '
')); + $this->assertSame(0, $code); + } +} From 5eb484f3920466ab47bf1d9e32642a3741538a4f Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 20 Mar 2024 22:43:27 +0000 Subject: [PATCH 230/422] ignore .php-cs-fixer.cache --- .gitignore | 1 + .php-cs-fixer.cache | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .php-cs-fixer.cache diff --git a/.gitignore b/.gitignore index 582942a3e..17aa6d40e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ coverage .php_cs.cache .phpunit.result.cache .idea +.php-cs-fixer.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index 763997ae0..000000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.2.16","version":"3.52.0:v3.52.0#a3564bd66f4bce9bc871ef18b690e2dc67a7f969","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":true,"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"concat_space":{"spacing":"one"},"no_extra_blank_lines":true,"blank_line_before_statement":true,"no_unused_imports":true,"no_empty_statement":true,"trailing_comma_in_multiline":true,"no_blank_lines_after_phpdoc":true,"phpdoc_trim":true},"hashes":{"\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2446\/src\/Commands\/Make\/ProviderMakeCommand.php":"dee9e1bcba42fa2b609be1f7692e0419","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1726\/src\/Commands\/Make\/ComponentViewMakeCommand.php":"56db971b9aa1ab60d1984565f28b3dfc","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2759\/src\/Commands\/Make\/ProviderMakeCommand.php":"dee9e1bcba42fa2b609be1f7692e0419","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4295\/src\/Commands\/Make\/ViewMakeCommand.php":"ace3812c1cbf93c17bf57655a6da2a3f","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder964\/src\/Commands\/Make\/ViewMakeCommand.php":"0ae50a6e0a64ff2eebdb213c506f54ca","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7361\/src\/Commands\/Make\/ViewMakeCommand.php":"989a430e6f8a1693f96bfbb254406e42","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder382\/src\/Commands\/Make\/ViewMakeCommand.php":"0853a023e647e8eef06f030a521bfb6c","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3011\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder993\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7452\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder753\/src\/Commands\/Make\/ViewMakeCommand.php":"053e1e9966a515aa7b72d11663d129cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder906\/src\/Commands\/Make\/ViewMakeCommand.php":"5730d6865a6499fae30e9a9af5f5f4fe","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1870\/src\/Commands\/Make\/ViewMakeCommand.php":"1f12b5be6f1b48d6ea2c305dad32406c","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6596\/src\/Commands\/Make\/ViewMakeCommand.php":"1bc4121d4efef4ce71f2a9689d1a65f4","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7441\/src\/Commands\/Make\/ViewMakeCommand.php":"1cc6f94cda6fd133393a437ce322e29a","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder67\/src\/Commands\/Make\/ViewMakeCommand.php":"251ba519116b2fc5211f8369999b3b6d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2166\/src\/Commands\/Make\/ViewMakeCommand.php":"251ba519116b2fc5211f8369999b3b6d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7761\/src\/Commands\/Make\/ViewMakeCommand.php":"d418a017999108e613363f4631271fb1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3378\/src\/Commands\/Make\/ViewMakeCommand.php":"d418a017999108e613363f4631271fb1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2558\/src\/Commands\/Make\/ViewMakeCommand.php":"49841bd8c34b6ca77686d6f90fac868d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4917\/src\/Commands\/Make\/ViewMakeCommand.php":"208ceb54a11ab409976b8a17a1dc1edf","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5986\/src\/Commands\/Make\/ViewMakeCommand.php":"424f60f2a9d84a272900bb4226775dbe","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7079\/src\/Commands\/Make\/ViewMakeCommand.php":"6ee7dc4603710b3a3ff34f597e85a601","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7775\/src\/Commands\/Make\/ViewMakeCommand.php":"6ee7dc4603710b3a3ff34f597e85a601","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6731\/src\/Commands\/Make\/ViewMakeCommand.php":"e3b2a88a6770b7789b5bea860a29f13a","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7642\/src\/Commands\/Make\/ViewMakeCommand.php":"f5a2909b2d1bcf15f8b3d1f66ed75e52","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5856\/src\/Commands\/Make\/ViewMakeCommand.php":"a14be053a7df949e82fac3c82dfe50d9","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3356\/src\/Commands\/Make\/ViewMakeCommand.php":"d63b1f3ba64a0855f2d11efdbc102035","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7548\/src\/Commands\/Make\/ViewMakeCommand.php":"d63b1f3ba64a0855f2d11efdbc102035","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3046\/src\/Commands\/Make\/ViewMakeCommand.php":"e41700e139e8ff94d6a25200986b3418","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3702\/src\/Commands\/Make\/ViewMakeCommand.php":"cf63217115858ccda0e1baecf00ce0b1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2587\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder891\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5578\/src\/Traits\/ModuleCommandTrait.php":"72f3cb3290f55aa437fe58663e93d8f3","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7932\/src\/Traits\/ModuleCommandTrait.php":"01b46fa0e265da5720d4505c3e0509d4","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder776\/src\/Traits\/ModuleCommandTrait.php":"0b9488e5bcdef2f1d9cd0efceec4fe94","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2205\/src\/Traits\/ModuleCommandTrait.php":"0b9488e5bcdef2f1d9cd0efceec4fe94","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2510\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5167\/src\/Commands\/Make\/ComponentViewMakeCommand.php":"56db971b9aa1ab60d1984565f28b3dfc","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2778\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder82\/src\/Commands\/Make\/ViewMakeCommand.php":"dd0c24139323c9968f0af51839ed86db","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5843\/src\/Commands\/Make\/ViewMakeCommand.php":"11f2ec56618e17b2d931b0efa662cc50","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7828\/src\/Commands\/Make\/ViewMakeCommand.php":"c02c3ddffbf78b1dbcd634c57b8aab8e","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5833\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5664\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5577\/src\/Commands\/ComposerUpdateCommand.php":"1bc90d22c8f32bd65921f8156edc63e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7376\/config\/config.php":"d599906a7ae112c5684a72b33d2c4c77","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1173\/src\/Providers\/ConsoleServiceProvider.php":"be948bebf22b25670979e54110e6ffa2","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7112\/src\/Providers\/ConsoleServiceProvider.php":"57ae0ae475d5ab6f3f23f0b3c58e2046","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7035\/src\/Providers\/ConsoleServiceProvider.php":"adf823dcf6aaecd34d85eb8ba68ae192","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3254\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6725\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7200\/src\/Commands\/Make\/ViewMakeCommand.php":"a17d29ed10858938eac1303490fe8b95","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2236\/src\/Support\/Config\/GenerateConfigReader.php":"d5796fb17e27657437dc3d2bf0cf89bf","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3708\/config\/config.php":"d599906a7ae112c5684a72b33d2c4c77","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7367\/src\/Commands\/Make\/ViewMakeCommand.php":"cec6c18dcbbde59400e3a9751a1da219","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7176\/src\/Commands\/Make\/ViewMakeCommand.php":"cec6c18dcbbde59400e3a9751a1da219","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3916\/src\/Commands\/Make\/ViewMakeCommand.php":"cec6c18dcbbde59400e3a9751a1da219","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4002\/src\/Commands\/Make\/ViewMakeCommand.php":"e55a075964763e521f6f96739b8e17df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7810\/src\/Commands\/Make\/ViewMakeCommand.php":"e55a075964763e521f6f96739b8e17df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2417\/tests\/Commands\/ComponentViewMakeCommandTest.php":"532f52478b2612192639937a7aae8fe1","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2843\/tests\/Commands\/ViewMakeCommandTest.php":"03843d4ac8075c45960f00768dc61970","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4869\/tests\/Commands\/ViewMakeCommandTest.php":"9ea6231c50c6eb08dba9b2a783b0106d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2179\/tests\/Commands\/ViewMakeCommandTest.php":"c85051be38e75bd3e6ec6843c66b2cfa","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4709\/tests\/Commands\/ViewMakeCommandTest.php":"605224b1afc7c8038f9886461b6262cb","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5497\/tests\/Commands\/ViewMakeCommandTest.php":"f0b51290598e43dd55caefef53015148","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder6984\/tests\/Commands\/ViewMakeCommandTest.php":"6e3b2204e22dd7aac450048dfe498710","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5831\/tests\/Commands\/ViewMakeCommandTest.php":"362a3672c9f2f8fab3c951fddad2a146","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7774\/tests\/Commands\/ViewMakeCommandTest.php":"6bf05ebb6f80b2ed98dab0683f32e8d7","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7083\/tests\/Commands\/ViewMakeCommandTest.php":"d18018ccc11938aea59cfbbbdcb9c6dc","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder8165\/tests\/Commands\/ViewMakeCommandTest.php":"d0c3325b39b0e3d91eab921f79424743","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3519\/tests\/Commands\/ViewMakeCommandTest.php":"1872dee921a21c546b639b098e189a7b","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder7287\/tests\/Commands\/ViewMakeCommandTest.php":"d7c3a29b3de88108ea28683c2502ae65","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder8364\/tests\/Commands\/ViewMakeCommandTest.php":"b6e8510a7493d53b5117bb4249c2f03d","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1826\/tests\/Commands\/ViewMakeCommandTest.php":"a12f71420fc17c5ece31b1a2319cadde","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1523\/tests\/Commands\/ViewMakeCommandTest.php":"40c91076a9a05c8ba868e350eba6b5f6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2641\/tests\/Commands\/ViewMakeCommandTest.php":"50f8ffdeb2631b4055c7be7a8a318e7f","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder3828\/tests\/Commands\/ViewMakeCommandTest.php":"a6030a8215474ca645dab5deaac000d5","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2371\/tests\/Commands\/ViewMakeCommandTest.php":"eb18766d36bfd733acd0aa9a3311a2df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1185\/tests\/Commands\/ViewMakeCommandTest.php":"99a97443772441d664588f257378e290","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2271\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder607\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1796\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder8150\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4364\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4491\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder1077\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder2818\/src\/Providers\/ConsoleServiceProvider.php":"adf823dcf6aaecd34d85eb8ba68ae192","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder5322\/src\/Commands\/Make\/ViewMakeCommand.php":"e55a075964763e521f6f96739b8e17df","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder978\/tests\/Commands\/ViewMakeCommandTest.php":"581a89aaad3e840a7485c510878f25e6","\/private\/var\/folders\/nz\/_tq2wnvj1pd_xb9784n6j8kw0000gn\/T\/PHP CS Fixertemp_folder4731\/src\/Traits\/ModuleCommandTrait.php":"0b9488e5bcdef2f1d9cd0efceec4fe94"}} \ No newline at end of file From e7610213a58b9021f9b9299d19398a2234729915 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 20 Mar 2024 23:00:34 +0000 Subject: [PATCH 231/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8d106c81..f958f63fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Added + +- [@dcblogdev](https://github.com/dcblogdev) Added view:make command to generate views + ## Changed - [@alissn](https://github.com/alissn) Run command php-cs-fixer fix From 3b9f7ec8ed0acf59856794e978d3ed3b2b565276 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 15:46:17 +0330 Subject: [PATCH 232/422] [feat] add package version to command 'about' --- src/LaravelModulesServiceProvider.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index c1b788456..da5ba6725 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -2,6 +2,8 @@ namespace Nwidart\Modules; +use Composer\InstalledVersions; +use Illuminate\Foundation\Console\AboutCommand; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; use Nwidart\Modules\Support\Stub; @@ -15,6 +17,10 @@ public function boot() { $this->registerNamespaces(); $this->registerModules(); + + AboutCommand::add('Laravel-Modules', [ + 'Version' => fn () => InstalledVersions::getVersion('nwidart/laravel-modules'), + ]); } /** From e214fd61a0b96ee6d4c3a1d2125603e103129a92 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 19:20:37 +0330 Subject: [PATCH 233/422] [feat] add config for route service provider --- config/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.php b/config/config.php index a27f9f2ff..6f102f776 100644 --- a/config/config.php +++ b/config/config.php @@ -124,6 +124,7 @@ 'observer' => ['path' => 'app/Observers', 'generate' => false], 'policies' => ['path' => 'app/Policies', 'generate' => false], 'provider' => ['path' => 'app/Providers', 'generate' => true], + 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], From d9cdcfa14062f4ea65199d3e6a956cc9395c0d37 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 19:21:28 +0330 Subject: [PATCH 234/422] [feat] handle create module without provider and change files after create module --- src/Generators/ModuleGenerator.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index be4567777..71d0009bc 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -409,15 +409,40 @@ public function generateResources() ]); } - if (GenerateConfigReader::read('provider')->generate() === true) { + $providerGenerator = GenerateConfigReader::read('provider'); + if ($providerGenerator->generate() === true) { $this->console->call('module:make-provider', [ 'name' => $this->getName() . 'ServiceProvider', 'module' => $this->getName(), '--master' => true, ]); + } else { + // delete register ServiceProvider on module.json + $path = $this->module->getModulePath($this->getName()) . DIRECTORY_SEPARATOR . 'module.json'; + $module_file = $this->filesystem->get($path); + $this->filesystem->put( + $path, + preg_replace('/"providers": \[.*?\],/s', '"providers": [ ],', $module_file) + ); + } + + $routeGeneratorConfig = GenerateConfigReader::read('route-provider'); + if ( + (is_null($routeGeneratorConfig->getPath()) && $providerGenerator->generate()) + || (!is_null($routeGeneratorConfig->getPath()) && $routeGeneratorConfig->generate()) + ) { $this->console->call('module:route-provider', [ 'module' => $this->getName(), ]); + } else { + if ($providerGenerator->generate()) { + // comment register RouteServiceProvider + $this->filesystem->replaceInFile( + '$this->app->register(Route', + '// $this->app->register(Route', + $this->module->getModulePath($this->getName()) . DIRECTORY_SEPARATOR . $providerGenerator->getPath() . DIRECTORY_SEPARATOR . sprintf('%sServiceProvider.php', $this->getName()) + ); + } } if (GenerateConfigReader::read('controller')->generate() === true) { From f6f65d46a10837004c7fdd8c0d6800b66fc37821 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 19:22:04 +0330 Subject: [PATCH 235/422] [fix] tiny change for solve create module issue --- src/Commands/Make/ModuleMakeCommand.php | 2 +- src/Generators/ModuleGenerator.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Make/ModuleMakeCommand.php b/src/Commands/Make/ModuleMakeCommand.php index 6378e4d24..15ee8e852 100644 --- a/src/Commands/Make/ModuleMakeCommand.php +++ b/src/Commands/Make/ModuleMakeCommand.php @@ -54,7 +54,7 @@ public function handle(): int // to discover new service providers Process::path(base_path()) ->command('composer dump-autoload') - ->run(); + ->run()->output(); return $success ? 0 : E_ERROR; } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 71d0009bc..509827152 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -361,7 +361,7 @@ public function generateFolders() $path = $this->module->getModulePath($this->getName()) . '/' . $folder->getPath(); - $this->filesystem->makeDirectory($path, 0755, true); + $this->filesystem->ensureDirectoryExists($path, 0755, true); if (config('modules.stubs.gitkeep')) { $this->generateGitKeep($path); } From a8ce408200205892e5f6e5dc58dc025dbfe321c9 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 19:54:19 +0330 Subject: [PATCH 236/422] [test] add test to provider generator --- tests/Commands/ModuleMakeCommandTest.php | 60 ++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/Commands/ModuleMakeCommandTest.php b/tests/Commands/ModuleMakeCommandTest.php index 7ae2b9e87..81db23506 100644 --- a/tests/Commands/ModuleMakeCommandTest.php +++ b/tests/Commands/ModuleMakeCommandTest.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Str; +use Modules\Bae\Providers\RouteServiceProvider; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; @@ -297,6 +298,7 @@ public function test_it_can_ignore_resource_folders_to_generate() { $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false]); $this->app['config']->set('modules.paths.generator.provider', ['path' => 'Providers', 'generate' => false]); + $this->app['config']->set('modules.paths.generator.route-provider', ['path' => 'Providers', 'generate' => false]); $this->app['config']->set('modules.paths.generator.controller', ['path' => 'Http/Controllers', 'generate' => false]); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -405,4 +407,62 @@ public function test_it_generates_web_module_with_resources_when_adding_more_tha $this->assertSame(0, $code); } + + public function test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable() + { + $this->app['config']->set('modules.paths.generator.provider.generate', true); + $this->app['config']->set('modules.paths.generator.route-provider.generate', true); + + $this->artisan('module:make', ['name' => ['Blog']]); + + $providerPath = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $this->assertTrue($this->finder->exists($providerPath)); + $this->assertMatchesSnapshot($this->finder->get($providerPath)); + + $RouteProviderPath = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $this->assertTrue($this->finder->exists($RouteProviderPath)); + $this->assertMatchesSnapshot($this->finder->get($RouteProviderPath)); + + $content = $this->finder->get($providerPath); + + $this->assertStringContainsString('$this->app->register(RouteServiceProvider::class);', $content); + $this->assertStringNotContainsString('// $this->app->register(RouteServiceProvider::class);', $content); + } + + public function test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable() + { + $this->app['config']->set('modules.paths.generator.provider.generate', true); + $this->app['config']->set('modules.paths.generator.route-provider.generate', false); + + $this->artisan('module:make', ['name' => ['Blog']]); + + $providerPath = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $this->assertTrue($this->finder->exists($providerPath)); + $this->assertMatchesSnapshot($this->finder->get($providerPath)); + + $RouteProviderPath = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $this->assertTrue(!$this->finder->exists($RouteProviderPath)); + + $content = $this->finder->get($providerPath); + + $this->assertStringContainsString('// $this->app->register(RouteServiceProvider::class);', $content); + } + + public function test_it_generate_module_when_provider_is_disable_and_route_provider_is_disable() + { + $this->app['config']->set('modules.paths.generator.provider.generate', false); + $this->app['config']->set('modules.paths.generator.route-provider.generate', false); + + $this->artisan('module:make', ['name' => ['Blog']]); + + $providerPath = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $this->assertTrue(!$this->finder->exists($providerPath)); + + $RouteProviderPath = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $this->assertTrue(!$this->finder->exists($RouteProviderPath)); + + $content = $this->finder->get($this->getModuleBasePath() . '/module.json'); + + $this->assertStringNotContainsString('Modules\Blog\Providers\BlogServiceProvider', $content); + } } From b569b610e705b33d5d2b8d3901e151f55d163447 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 19:54:36 +0330 Subject: [PATCH 237/422] [test] update snapshots --- ...nable_and_route_provider_is_disable__1.txt | 114 ++++++++++++++++++ ...enable_and_route_provider_is_enable__1.txt | 114 ++++++++++++++++++ ...enable_and_route_provider_is_enable__2.txt | 49 ++++++++ 3 files changed, 277 insertions(+) create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt new file mode 100644 index 000000000..9a5eac62d --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + // $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt new file mode 100644 index 000000000..ad1ad48fd --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} From 3f9a678c90b2453ef77cf8c81c677669e09abdf9 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 23 Mar 2024 20:08:03 +0330 Subject: [PATCH 238/422] [style] optimize imports --- tests/Commands/ModuleMakeCommandTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Commands/ModuleMakeCommandTest.php b/tests/Commands/ModuleMakeCommandTest.php index 81db23506..7a50ac22d 100644 --- a/tests/Commands/ModuleMakeCommandTest.php +++ b/tests/Commands/ModuleMakeCommandTest.php @@ -4,7 +4,6 @@ use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Str; -use Modules\Bae\Providers\RouteServiceProvider; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; From 5aa3e6c3f22ab4b8dffa291bb3cecd3f2c788fe7 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 23 Mar 2024 19:25:52 +0000 Subject: [PATCH 239/422] updated CHANGELOG.md and removed duplicate from replacements --- CHANGELOG.md | 2 ++ config/config.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f958f63fb..3ee060470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Added +- [@alissn](https://github.com/alissn) add RouteServiceProvider Configuration in Generator +- [@alissn](https://github.com/alissn) added Laravel Modules package version to command 'about' - [@dcblogdev](https://github.com/dcblogdev) Added view:make command to generate views ## Changed diff --git a/config/config.php b/config/config.php index 6f102f776..a9876c60c 100644 --- a/config/config.php +++ b/config/config.php @@ -42,7 +42,7 @@ ], 'replacements' => [ 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], - 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'STUDLY_NAME', 'CONTROLLER_NAMESPACE'], + 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], 'vite' => ['LOWER_NAME', 'STUDLY_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], 'views/index' => ['LOWER_NAME'], From 6d5c5daba7a8ee58c19753cce2ce0b922b1e974f Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 24 Mar 2024 10:39:46 +0000 Subject: [PATCH 240/422] updated README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c10215ebe..7a427c85f 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,12 @@ By default the module classes are not loaded automatically. You can autoload you You'll find installation instructions and full documentation on [https://laravelmodules.com/](https://laravelmodules.com/docs). +## Demo + +You can see a demo using Laravel Breeze at https://github.com/laravel-modules-com/breeze-demo + +This is a complete application using Auth, Base and Profile modules. + ## Community We also have a Discord community. [https://discord.gg/hkF7BRvRZK](https://discord.gg/hkF7BRvRZK) For quick help, ask questions in the appropriate channel. From ac1d1279deac9b78a736321b6fbbb8af36975e38 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 24 Mar 2024 16:53:16 +0000 Subject: [PATCH 241/422] fixed module:migrate-rollback --- CHANGELOG.md | 8 ++++++++ src/Migrations/Migrator.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee060470..09cadd54f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.2 - 2024-03-24 + +## Fixed + +- [@enterprime](https://github.com/enterprime) fixed module:migrate-rollback command + +## 11.0.1 - 2024-03-23 + ## Added - [@alissn](https://github.com/alissn) add RouteServiceProvider Configuration in Generator diff --git a/src/Migrations/Migrator.php b/src/Migrations/Migrator.php index c3a1afd61..982f491ff 100644 --- a/src/Migrations/Migrator.php +++ b/src/Migrations/Migrator.php @@ -243,7 +243,7 @@ public function requireFiles(array $files) */ public function table() { - return $this->laravel['db']->connection($this->database ?: null)->table(config('database.migrations')); + return $this->laravel['db']->connection($this->database ?: null)->table(config('database.migrations.table')); } /** From e616c8b3116252cc221ff725a2b68cd391ebf530 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Sun, 24 Mar 2024 23:27:33 +0300 Subject: [PATCH 242/422] Modified to control the author through the .env configuration file. --- config/config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.php b/config/config.php index a9876c60c..87a808e93 100644 --- a/config/config.php +++ b/config/config.php @@ -200,10 +200,10 @@ */ 'composer' => [ - 'vendor' => 'nwidart', + 'vendor' => env('MODULES_VENDOR', 'nwidart'), 'author' => [ - 'name' => 'Nicolas Widart', - 'email' => 'n.widart@gmail.com', + 'name' => env('MODULES_NAME', 'Nicolas Widart'), + 'email' => env('MODULES_EMAIL', 'n.widart@gmail.com'), ], 'composer-output' => false, ], From e003d42686f8c8a462da06c6046ab5bb941a033b Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 24 Mar 2024 21:01:09 +0000 Subject: [PATCH 243/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09cadd54f..2531ab5fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Added + +- [@enterprime](https://github.com/enterprime) control the author through the .env configuration file. + ## 11.0.2 - 2024-03-24 ## Fixed From 0e17c7244f3ab5351fc80db8affbd4330d5467c8 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Mon, 25 Mar 2024 00:40:48 +0300 Subject: [PATCH 244/422] Passing the values of vendor, author's name, and author's email in a line during module creation. --- src/Commands/Make/ModuleMakeCommand.php | 5 +++ src/Generators/ModuleGenerator.php | 50 +++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ModuleMakeCommand.php b/src/Commands/Make/ModuleMakeCommand.php index 15ee8e852..911b61782 100644 --- a/src/Commands/Make/ModuleMakeCommand.php +++ b/src/Commands/Make/ModuleMakeCommand.php @@ -44,6 +44,8 @@ public function handle(): int ->setForce($this->option('force')) ->setType($this->getModuleType()) ->setActive(!$this->option('disabled')) + ->setVendor($this->option('author-vendor')) + ->setAuthor($this->option('author-name'), $this->option('author-email')) ->generate(); if ($code === E_ERROR) { @@ -79,6 +81,9 @@ protected function getOptions() ['web', null, InputOption::VALUE_NONE, 'Generate a web module.'], ['disabled', 'd', InputOption::VALUE_NONE, 'Do not enable the module at creation.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the module already exists.'], + ['author-name', 'an', InputOption::VALUE_OPTIONAL, 'Author name.'], + ['author-email', 'ae', InputOption::VALUE_OPTIONAL, 'Author email.'], + ['author-vendor', 'av', InputOption::VALUE_OPTIONAL, 'Author vendor.'], ]; } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 509827152..ae2c70d52 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -83,6 +83,22 @@ class ModuleGenerator extends Generator */ protected $isActive = false; + /** + * Module author + * + * @var array + */ + protected array $author = [ + 'name', 'email' + ]; + + /** + * Vendor name + * + * @var string + */ + protected ?string $vendor = null; + /** * The constructor. * @param $name @@ -273,6 +289,34 @@ public function setModule($module) return $this; } + /** + * Setting the author from the command + * + * @param string|null $name + * @param string|null $email + * @return $this + */ + function setAuthor(string $name = null, string $email = null) + { + $this->author['name'] = $name; + $this->author['email'] = $email; + + return $this; + } + + /** + * Installing vendor from the command + * + * @param string|null $vendor + * @return $this + */ + function setVendor(string $vendor = null) + { + $this->vendor = $vendor; + + return $this; + } + /** * Get the list of folders will created. * @@ -575,7 +619,7 @@ protected function getStudlyNameReplacement() */ protected function getVendorReplacement() { - return $this->module->config('composer.vendor'); + return $this->vendor ?: $this->module->config('composer.vendor'); } /** @@ -605,7 +649,7 @@ private function getControllerNamespaceReplacement(): string */ protected function getAuthorNameReplacement() { - return $this->module->config('composer.author.name'); + return $this->author['name'] ?: $this->module->config('composer.author.name'); } /** @@ -615,7 +659,7 @@ protected function getAuthorNameReplacement() */ protected function getAuthorEmailReplacement() { - return $this->module->config('composer.author.email'); + return $this->author['email'] ?: $this->module->config('composer.author.email'); } protected function getProviderNamespaceReplacement(): string From 464f3a1f0ef53d594e75b069933ef6e6047797d5 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Mon, 25 Mar 2024 00:47:34 +0300 Subject: [PATCH 245/422] Passing the values of vendor, author's name, and author's email in a line during module creation. --- src/Commands/Make/ModuleMakeCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ModuleMakeCommand.php b/src/Commands/Make/ModuleMakeCommand.php index 911b61782..30a975e04 100644 --- a/src/Commands/Make/ModuleMakeCommand.php +++ b/src/Commands/Make/ModuleMakeCommand.php @@ -81,9 +81,9 @@ protected function getOptions() ['web', null, InputOption::VALUE_NONE, 'Generate a web module.'], ['disabled', 'd', InputOption::VALUE_NONE, 'Do not enable the module at creation.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the module already exists.'], - ['author-name', 'an', InputOption::VALUE_OPTIONAL, 'Author name.'], - ['author-email', 'ae', InputOption::VALUE_OPTIONAL, 'Author email.'], - ['author-vendor', 'av', InputOption::VALUE_OPTIONAL, 'Author vendor.'], + ['author-name', null, InputOption::VALUE_OPTIONAL, 'Author name.'], + ['author-email', null, InputOption::VALUE_OPTIONAL, 'Author email.'], + ['author-vendor', null, InputOption::VALUE_OPTIONAL, 'Author vendor.'], ]; } From 97d89d327a61e04853ae7fe2db75c99edd99019a Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 24 Mar 2024 23:31:12 +0000 Subject: [PATCH 246/422] added test to confirm author details --- tests/Commands/ModuleMakeCommandTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Commands/ModuleMakeCommandTest.php b/tests/Commands/ModuleMakeCommandTest.php index 7a50ac22d..ef0db2056 100644 --- a/tests/Commands/ModuleMakeCommandTest.php +++ b/tests/Commands/ModuleMakeCommandTest.php @@ -464,4 +464,17 @@ public function test_it_generate_module_when_provider_is_disable_and_route_provi $this->assertStringNotContainsString('Modules\Blog\Providers\BlogServiceProvider', $content); } + + public function test_it_can_set_author_details() + { + $code = $this->artisan('module:make', ['name' => ['Blog'], '--author-name' => 'Joe Blogs', '--author-email' => 'user@domain.com', '--author-vendor' => 'JoeBlogs']); + + $content = $this->finder->get($this->getModuleBasePath() . '/composer.json'); + + $this->assertStringContainsString('Joe Blogs', $content); + $this->assertStringContainsString('user@domain.com', $content); + $this->assertStringContainsString('JoeBlogs', $content); + + $this->assertSame(0, $code); + } } From 24c5ca340cf9d5cb8d71ebc27e8a5ac70e599a87 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 24 Mar 2024 23:33:15 +0000 Subject: [PATCH 247/422] updated CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2531ab5fb..4778a6f39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,11 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.3 - 2024-03-24 + ## Added +- [@enterprime](https://github.com/enterprime) Passing the values of vendor, author's name, and author's email in a line during module creation. - [@enterprime](https://github.com/enterprime) control the author through the .env configuration file. ## 11.0.2 - 2024-03-24 From 6c046a013969989b77ad2b57e9a4283dabe72d23 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Tue, 26 Mar 2024 18:51:02 +0300 Subject: [PATCH 248/422] issues/1788 fix --- src/Commands/stubs/model.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/model.stub b/src/Commands/stubs/model.stub index ac848e872..ba4f52919 100644 --- a/src/Commands/stubs/model.stub +++ b/src/Commands/stubs/model.stub @@ -4,7 +4,7 @@ namespace $NAMESPACE$; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use $MODULE_NAMESPACE$\$MODULE$\Database\factories\$NAME$Factory; +use $MODULE_NAMESPACE$\$MODULE$\Database\Factories\$NAME$Factory; class $CLASS$ extends Model { @@ -14,7 +14,7 @@ class $CLASS$ extends Model * The attributes that are mass assignable. */ protected $fillable = $FILLABLE$; - + protected static function newFactory(): $NAME$Factory { //return $NAME$Factory::new(); From 3d65c0df72129513526a92713fa53018f619666e Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Tue, 26 Mar 2024 20:17:31 +0300 Subject: [PATCH 249/422] issues/1788 fix --- ...akeCommandTest__it_can_change_the_default_namespace__1.php | 4 ++-- ...akeCommandTest__it_can_change_the_default_namespace__1.txt | 4 ++-- ...dTest__it_can_change_the_default_namespace_specific__1.php | 4 ++-- ...dTest__it_can_change_the_default_namespace_specific__1.txt | 4 ++-- ...CommandTest__it_generated_correct_file_with_content__1.php | 4 ++-- ...CommandTest__it_generated_correct_file_with_content__1.txt | 4 ++-- ...keCommandTest__it_generates_correct_fillable_fields__1.php | 4 ++-- ...keCommandTest__it_generates_correct_fillable_fields__1.txt | 4 ++-- ...mmandTest__test_it_can_change_the_default_namespace__1.txt | 4 ++-- ...__test_it_can_change_the_default_namespace_specific__1.txt | 4 ++-- ...ndTest__test_it_generated_correct_file_with_content__1.txt | 4 ++-- ...mandTest__test_it_generates_correct_fillable_fields__1.txt | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php index 6ddb78334..24f396c4b 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php @@ -10,10 +10,10 @@ class Post extends Model use HasFactory; protected $fillable = []; - + protected static function newFactory() { - return \\Modules\\Blog\\Database\\factories\\PostFactory::new(); + return \\Modules\\Blog\\Database\\Factories\\PostFactory::new(); } } '; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt index 5c74c8eca..395327120 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = []; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.php index 6ddb78334..24f396c4b 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.php @@ -10,10 +10,10 @@ class Post extends Model use HasFactory; protected $fillable = []; - + protected static function newFactory() { - return \\Modules\\Blog\\Database\\factories\\PostFactory::new(); + return \\Modules\\Blog\\Database\\Factories\\PostFactory::new(); } } '; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt index 5c74c8eca..395327120 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = []; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.php index e20017f28..f8dbb03f5 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.php +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.php @@ -10,10 +10,10 @@ class Post extends Model use HasFactory; protected $fillable = []; - + protected static function newFactory() { - return \\Modules\\Blog\\Database\\factories\\PostFactory::new(); + return \\Modules\\Blog\\Database\\Factories\\PostFactory::new(); } } '; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt index 5c74c8eca..395327120 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = []; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.php index 0129de5e5..51b25e0ec 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.php +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.php @@ -10,10 +10,10 @@ class Post extends Model use HasFactory; protected $fillable = ["title","slug"]; - + protected static function newFactory() { - return \\Modules\\Blog\\Database\\factories\\PostFactory::new(); + return \\Modules\\Blog\\Database\\Factories\\PostFactory::new(); } } '; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt index dcc1662aa..1d8cc95e6 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = ["title","slug"]; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 5c74c8eca..395327120 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = []; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 5c74c8eca..395327120 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = []; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 5c74c8eca..395327120 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = []; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt index dcc1662aa..1d8cc95e6 100644 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt +++ b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\factories\PostFactory; +use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -14,7 +14,7 @@ class Post extends Model * The attributes that are mass assignable. */ protected $fillable = ["title","slug"]; - + protected static function newFactory(): PostFactory { //return PostFactory::new(); From 4d303ec68f1c54386967c23b4f8f3c6db9b91e31 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Tue, 26 Mar 2024 21:31:49 +0300 Subject: [PATCH 250/422] Added environment variables for cache --- config/config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index 87a808e93..f371e1030 100644 --- a/config/config.php +++ b/config/config.php @@ -217,10 +217,10 @@ | */ 'cache' => [ - 'enabled' => false, - 'driver' => 'file', - 'key' => 'laravel-modules', - 'lifetime' => 60, + 'enabled' => env('MODULES_CACHE_ENABLED', false), + 'driver' => env('MODULES_CACHE_DRIVER', 'file'), + 'key' => env('MODULES_CACHE_KEY', 'laravel-modules'), + 'lifetime' => env('MODULES_CACHE_LIFETIME', 60), ], /* |-------------------------------------------------------------------------- From fd9c90fb3539c9fe0e3f90dee9f62998062c793d Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Wed, 27 Mar 2024 09:44:41 -0700 Subject: [PATCH 251/422] Update config.php Use a more generic name. --- config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index f371e1030..6d2799c9f 100644 --- a/config/config.php +++ b/config/config.php @@ -202,8 +202,8 @@ 'composer' => [ 'vendor' => env('MODULES_VENDOR', 'nwidart'), 'author' => [ - 'name' => env('MODULES_NAME', 'Nicolas Widart'), - 'email' => env('MODULES_EMAIL', 'n.widart@gmail.com'), + 'name' => env('MODULES_VENDOR_NAME', 'Nicolas Widart'), + 'email' => env('MODULES_VENDOR_EMAIL', 'n.widart@gmail.com'), ], 'composer-output' => false, ], From 95fcd08f6ffab60b191f46b07f1b563a21f5d9cf Mon Sep 17 00:00:00 2001 From: "Solomon O. Ochepa" Date: Wed, 27 Mar 2024 17:50:07 +0100 Subject: [PATCH 252/422] Normalize the comments. --- config/config.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index 6d2799c9f..aad8b9187 100644 --- a/config/config.php +++ b/config/config.php @@ -13,7 +13,6 @@ | Default module namespace. | */ - 'namespace' => 'Modules', /* @@ -24,7 +23,6 @@ | Default module stubs. | */ - 'stubs' => [ 'enabled' => false, 'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'), @@ -70,8 +68,8 @@ | This path will also be added automatically to the list of scanned folders. | */ - 'modules' => base_path('Modules'), + /* |-------------------------------------------------------------------------- | Modules assets path @@ -80,8 +78,8 @@ | Here you may update the modules' assets path. | */ - 'assets' => public_path('modules'), + /* |-------------------------------------------------------------------------- | The migrations' path @@ -91,7 +89,6 @@ | the migration files? | */ - 'migration' => base_path('database/migrations'), /* @@ -183,13 +180,13 @@ | directory. This is useful if you host the package in packagist website. | */ - 'scan' => [ 'enabled' => false, 'paths' => [ base_path('vendor/*/*'), ], ], + /* |-------------------------------------------------------------------------- | Composer File Template @@ -198,7 +195,6 @@ | Here is the config for the composer.json file, generated by this package | */ - 'composer' => [ 'vendor' => env('MODULES_VENDOR', 'nwidart'), 'author' => [ @@ -222,6 +218,7 @@ 'key' => env('MODULES_CACHE_KEY', 'laravel-modules'), 'lifetime' => env('MODULES_CACHE_LIFETIME', 60), ], + /* |-------------------------------------------------------------------------- | Choose what laravel-modules will register as custom namespaces. From 52ade52fb601da39118d33975b157be556d1a162 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 1 Apr 2024 18:13:37 +0100 Subject: [PATCH 253/422] added return type array definition --- src/Commands/stubs/scaffold/provider.stub | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index b6aa804c4..568b5f0fe 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -88,18 +88,23 @@ class $CLASS$ extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; From 7414dfc0f3e788ab61ac1d7580fd9e030194d638 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 1 Apr 2024 18:18:24 +0100 Subject: [PATCH 254/422] updated snapshots --- ...provider_is_enable_and_route_provider_is_disable__1.txt | 7 ++++++- ..._provider_is_enable_and_route_provider_is_enable__1.txt | 7 ++++++- ...est__test_it_generates_api_module_with_resources__1.txt | 7 ++++++- ..._it_generates_module_namespace_using_studly_case__1.txt | 7 ++++++- ...eCommandTest__test_it_generates_module_resources__1.txt | 7 ++++++- ...est__test_it_generates_web_module_with_resources__1.txt | 7 ++++++- ..._with_resources_when_adding_more_than_one_option__1.txt | 7 ++++++- ...ndTest__test_it_can_change_the_default_namespace__1.txt | 7 ++++++- ...est_it_can_change_the_default_namespace_specific__1.txt | 7 ++++++- ...n_have_custom_migration_resources_location_paths__1.txt | 7 ++++++- ..._a_master_service_provider_with_resource_loading__1.txt | 7 ++++++- 11 files changed, 66 insertions(+), 11 deletions(-) diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt index 9a5eac62d..e8bc4882a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt index ad1ad48fd..62afde970 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt index ad1ad48fd..62afde970 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt index da938d49a..4538229a6 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -88,18 +88,23 @@ class ModuleNameServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt index ad1ad48fd..62afde970 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt index ad1ad48fd..62afde970 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index ad1ad48fd..62afde970 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index b4c6f48d6..8c17ab8ee 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index b4c6f48d6..8c17ab8ee 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt index 4f132a028..f9ba976f1 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt index ad1ad48fd..62afde970 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -88,18 +88,23 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } /** * Get the services provided by the provider. + * + * @return array */ public function provides(): array { return []; } + /** + * @return array + */ private function getPublishableViewPaths(): array { $paths = []; From a5373928b648763ab38766af6a4dbef6cf2032f7 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 1 Apr 2024 19:00:20 +0100 Subject: [PATCH 255/422] updated CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4778a6f39..71fdd42f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Fixes + +- [@enterprime](https://github.com/enterprime) Corrected factories to Factories and added cache options to ENV + +## Added + +- [@dcblogdev](https://github.com/dcblogdev) Added return type array definition +- [@dcblogdev](https://github.com/dcblogdev) Added test to confirm author details + ## 11.0.3 - 2024-03-24 ## Added From 1e72493b842a63f05d71c260a3be983fbfb9b1e9 Mon Sep 17 00:00:00 2001 From: "Solomon O. Ochepa" Date: Mon, 1 Apr 2024 19:09:36 +0100 Subject: [PATCH 256/422] Update config.php --- config/config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.php b/config/config.php index aad8b9187..9db2781dd 100644 --- a/config/config.php +++ b/config/config.php @@ -196,10 +196,10 @@ | */ 'composer' => [ - 'vendor' => env('MODULES_VENDOR', 'nwidart'), + 'vendor' => env('MODULE_VENDOR', 'nwidart'), 'author' => [ - 'name' => env('MODULES_VENDOR_NAME', 'Nicolas Widart'), - 'email' => env('MODULES_VENDOR_EMAIL', 'n.widart@gmail.com'), + 'name' => env('MODULE_AUTHOR_NAME', 'Nicolas Widart'), + 'email' => env('MODULE_AUTHOR_EMAIL', 'n.widart@gmail.com'), ], 'composer-output' => false, ], From ea60fd027e784882d5648e4a948502336c9269fb Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 1 Apr 2024 19:13:15 +0100 Subject: [PATCH 257/422] updated CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71fdd42f2..9814c9ae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next -## Fixes +## Changes +- [@solomon-ochepa](https://github.com/solomon-ochepa) Updated vendor / author keys for config/.env - [@enterprime](https://github.com/enterprime) Corrected factories to Factories and added cache options to ENV ## Added From 6d6d39c0d56e6ab19dd977eecb62ff200ba9cfb9 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 1 Apr 2024 21:07:10 +0100 Subject: [PATCH 258/422] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7a427c85f..eab21e263 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ | 10.0 | ^10.0 | | 11.0 | ^11.0 | -`nwidart/laravel-modules` is a Laravel package which created to manage your large Laravel app using modules. Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 10. +`nwidart/laravel-modules` is a Laravel package created to manage your large Laravel app using modules. A Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 11. This package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. -With one big added bonus that the original package didn't have: **tests**. +With one big bonus that the original package didn't have: **tests**. ## Install @@ -43,7 +43,7 @@ php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProv ### Autoloading -By default the module classes are not loaded automatically. You can autoload your modules by adding merge-plugin to the extra section: +By default, the module classes are not loaded automatically. You can autoload your modules by adding merge-plugin to the extra section: ```json "extra": { From afb0ff60e923bba8c6c4313ba01a136e2586b938 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 4 Apr 2024 14:24:53 +0330 Subject: [PATCH 259/422] [feat] add upgrade guide to readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index eab21e263..a0d8528f7 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ This package is a re-published, re-organised and maintained version of [pingpong With one big bonus that the original package didn't have: **tests**. +## upgrade +To upgrade to version V11 follow [Upgrade Guide](https://laravelmodules.com/docs/v11/upgrade) on official document. + ## Install To install via Composer, run: From b818c279322b06ad7b322ac780fac13a108b2fa0 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 7 Apr 2024 17:33:01 +0100 Subject: [PATCH 260/422] set namespace for seeders and factories --- config/config.php | 4 ++-- .../FactoryMakeCommandTest__test_it_makes_factory__1.txt | 2 +- ...ndTest__test_it_generates_api_module_with_resources__3.txt | 2 +- ...MakeCommandTest__test_it_generates_module_resources__3.txt | 2 +- ...ndTest__test_it_generates_web_module_with_resources__3.txt | 2 +- ...ule_with_resources_when_adding_more_than_one_option__3.txt | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index 9db2781dd..cbdd520e4 100644 --- a/config/config.php +++ b/config/config.php @@ -137,8 +137,8 @@ // database/ 'migration' => ['path' => 'database/migrations', 'generate' => true], - 'seeder' => ['path' => 'database/seeders', 'generate' => true], - 'factory' => ['path' => 'database/factories', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], diff --git a/tests/Commands/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt b/tests/Commands/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt index 6d07e994d..92d5e5cb3 100644 --- a/tests/Commands/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt +++ b/tests/Commands/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt @@ -1,6 +1,6 @@ Date: Sun, 7 Apr 2024 17:45:49 +0100 Subject: [PATCH 261/422] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9814c9ae2..b550b2f6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changes +- [@dcblogdev](https://github.com/dcblogdev) Updated config to use namespace and path for seeders and factories - [@solomon-ochepa](https://github.com/solomon-ochepa) Updated vendor / author keys for config/.env - [@enterprime](https://github.com/enterprime) Corrected factories to Factories and added cache options to ENV From c526f1fc53e5763edc6e46333614075f5cc6f8e4 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 8 Apr 2024 00:01:20 +0100 Subject: [PATCH 262/422] updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b550b2f6c..f84dfe414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.4 - 2024-04-08 + ## Changes - [@dcblogdev](https://github.com/dcblogdev) Updated config to use namespace and path for seeders and factories From dc6addc485e2698bdb2aa38d3348e32e0982d06a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 16 Apr 2024 16:24:53 +0330 Subject: [PATCH 263/422] [fix] check command has direction option, load module with 'priority' --- src/Commands/BaseCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 02b8e6bb5..03b8f0e40 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -63,7 +63,9 @@ public function handle() protected function promptForMissingArguments(InputInterface $input, OutputInterface $output): void { - $modules = array_keys($this->laravel['modules']->all()); + $modules = $this->hasOption('direction') + ? array_keys($this->laravel['modules']->getOrdered($input->hasOption('direction'))) + : array_keys($this->laravel['modules']->all()); if ($input->getOption(strtolower(self::ALL))) { $input->setArgument('module', $modules); From 44b9b93714c29a55242ba59106b6ef076ecfc585 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 17 Apr 2024 07:30:10 +0100 Subject: [PATCH 264/422] Updated CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f84dfe414..75523d337 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.5 - 2024-04-17 + +## Changes + +- [@alissn](https://github.com/alissn) check command has direction option, load module with 'priority' + + ## 11.0.4 - 2024-04-08 ## Changes From df34440f1901f25559a51aec31e7ec5e40c3a24c Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 18 Apr 2024 07:42:18 +0100 Subject: [PATCH 265/422] added make-service class --- config/config.php | 1 + src/Commands/Make/ServiceMakeCommand.php | 66 +++++++++++++++ src/Commands/stubs/service.stub | 11 +++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/ServiceMakeCommandTest.php | 84 +++++++++++++++++++ ...it_can_change_the_default_namespace__1.txt | 11 +++ ...mespace_with_correct_generated_file__1.txt | 11 +++ ...generated_correct_file_with_content__1.txt | 11 +++ 8 files changed, 196 insertions(+) create mode 100644 src/Commands/Make/ServiceMakeCommand.php create mode 100644 src/Commands/stubs/service.stub create mode 100644 tests/Commands/ServiceMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/config/config.php b/config/config.php index cbdd520e4..f2625f76a 100644 --- a/config/config.php +++ b/config/config.php @@ -126,6 +126,7 @@ 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], + 'service' => ['path' => 'app/Services', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php new file mode 100644 index 000000000..3b864b538 --- /dev/null +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -0,0 +1,66 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $servicePath = GenerateConfigReader::read('service'); + + return $path . $servicePath->getPath() . '/' . $this->getServiceName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the service class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + protected function getServiceName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getServiceName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.service.namespace') + ?? ltrim(config('modules.paths.generator.service.path', 'Services'), config('modules.paths.app_folder')); + } + + protected function getStubName(): string + { + return '/service.stub'; + } +} diff --git a/src/Commands/stubs/service.stub b/src/Commands/stubs/service.stub new file mode 100644 index 000000000..d0a85c7af --- /dev/null +++ b/src/Commands/stubs/service.stub @@ -0,0 +1,11 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_service_class() + { + $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Services/MyService.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Services/MyService.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_change_the_default_namespace() + { + $this->app['config']->set('modules.paths.generator.service.path', 'Services'); + + $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); + + $file = $this->finder->get($this->getModuleBasePath() . '/Services/MyService.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_service_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-service', ['name' => 'Api\\MyService', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Services/Api/MyService.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-service', ['name' => 'Api\\MyService', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Services/Api/MyService.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..eae189216 --- /dev/null +++ b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,11 @@ + Date: Thu, 18 Apr 2024 07:49:42 +0100 Subject: [PATCH 266/422] switched to use construct --- src/Commands/stubs/service.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/service.stub b/src/Commands/stubs/service.stub index d0a85c7af..b0b5785e0 100644 --- a/src/Commands/stubs/service.stub +++ b/src/Commands/stubs/service.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __invoke() + public function __construct() { // } From 2455a1dcd3182ee28e8b32d769e96d2481186213 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 18 Apr 2024 07:51:05 +0100 Subject: [PATCH 267/422] updated snapshots --- ...CommandTest__test_it_can_change_the_default_namespace__1.txt | 2 +- ..._service_in_sub_namespace_with_correct_generated_file__1.txt | 2 +- ...mandTest__test_it_generated_correct_file_with_content__1.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index eae189216..942beff8d 100644 --- a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Services; class MyService { - public function __invoke() + public function __construct() { // } diff --git a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt index 36c4519e5..690ac7f7b 100644 --- a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Services\Api; class MyService { - public function __invoke() + public function __construct() { // } diff --git a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index eae189216..942beff8d 100644 --- a/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Services; class MyService { - public function __invoke() + public function __construct() { // } From 389f46b31e188fbc487b510cf6489a694658f376 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 22 Apr 2024 01:01:28 +0330 Subject: [PATCH 268/422] [fix] fix stubs composer for app_folder --- config/config.php | 1 + src/Commands/stubs/composer.stub | 2 +- src/Generators/ModuleGenerator.php | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index cbdd520e4..6438084c6 100644 --- a/config/config.php +++ b/config/config.php @@ -54,6 +54,7 @@ 'AUTHOR_EMAIL', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE', + 'APP_FOLDER_NAME', ], ], 'gitkeep' => true, diff --git a/src/Commands/stubs/composer.stub b/src/Commands/stubs/composer.stub index d1500a22e..d2ae16177 100644 --- a/src/Commands/stubs/composer.stub +++ b/src/Commands/stubs/composer.stub @@ -17,7 +17,7 @@ }, "autoload": { "psr-4": { - "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "app/", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "$APP_FOLDER_NAME$", "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Factories\\": "database/factories/", "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Seeders\\": "database/seeders/" } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index ae2c70d52..49a98fe6b 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -662,6 +662,16 @@ protected function getAuthorEmailReplacement() return $this->author['email'] ?: $this->module->config('composer.author.email'); } + /** + * Get replacement for $APP_FOLDER_NAME$. + * + * @return string + */ + protected function getAppFolderNameReplacement() + { + return $this->module->config('paths.app_folder'); + } + protected function getProviderNamespaceReplacement(): string { return str_replace('\\', '\\\\', GenerateConfigReader::read('provider')->getNamespace()); From a2f7101f5719556c04aef0a7b242ce03c67423bf Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 22 Apr 2024 01:07:49 +0330 Subject: [PATCH 269/422] [style] change package version to Pretty --- src/LaravelModulesServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index da5ba6725..3ca1e564c 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -19,7 +19,7 @@ public function boot() $this->registerModules(); AboutCommand::add('Laravel-Modules', [ - 'Version' => fn () => InstalledVersions::getVersion('nwidart/laravel-modules'), + 'Version' => fn () => InstalledVersions::getPrettyVersion('nwidart/laravel-modules'), ]); } From d6ac6b34350f7d434db3fb00eff2ba9efe898491 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 21 Apr 2024 22:56:09 +0100 Subject: [PATCH 270/422] updated snapshots --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75523d337..3a94c1434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All Notable changes to `laravel-modules` will be documented in this file. ## 11.0.5 - 2024-04-17 +- [@alissn](https://github.com/alissn) change package version to Pretty on php artisan about +- [@alissn](https://github.com/alissn) fix stubs composer for app_folder +- [@dcblogdev](https://github.com/dcblogdev) added make-service command + ## Changes - [@alissn](https://github.com/alissn) check command has direction option, load module with 'priority' From 3f65a38cbe82e486be845ed763d8f48beec45269 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 21 Apr 2024 23:14:23 +0100 Subject: [PATCH 271/422] updated snapshots --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a94c1434..545f6fada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,14 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next -## 11.0.5 - 2024-04-17 +## 11.0.6 - 2024-04-21 - [@alissn](https://github.com/alissn) change package version to Pretty on php artisan about - [@alissn](https://github.com/alissn) fix stubs composer for app_folder - [@dcblogdev](https://github.com/dcblogdev) added make-service command +## 11.0.5 - 2024-04-17 + ## Changes - [@alissn](https://github.com/alissn) check command has direction option, load module with 'priority' From f72391499184a80e0792bbc1b2b3072edffd5be4 Mon Sep 17 00:00:00 2001 From: kowston Date: Wed, 24 Apr 2024 15:26:43 +0100 Subject: [PATCH 272/422] Changed wording for command descriptions to be consistent. --- src/Commands/Make/SeedMakeCommand.php | 2 +- src/Commands/Make/ServiceMakeCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Make/SeedMakeCommand.php b/src/Commands/Make/SeedMakeCommand.php index cfd74e92c..f72b8a26c 100644 --- a/src/Commands/Make/SeedMakeCommand.php +++ b/src/Commands/Make/SeedMakeCommand.php @@ -25,7 +25,7 @@ class SeedMakeCommand extends GeneratorCommand /** * The console command description. */ - protected $description = 'Generate new seeder for the specified module.'; + protected $description = 'Create a new seeder for the specified module.'; /** * Get the console command arguments. diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index 3b864b538..e5707aed8 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -14,7 +14,7 @@ class ServiceMakeCommand extends GeneratorCommand protected $argumentName = 'name'; protected $name = 'module:make-service'; - protected $description = 'Generate a service class for the specified module.'; + protected $description = 'Create a new service class for the specified module.'; public function getDestinationFilePath(): string { From ec9bfd56ff1640f7dbe69a54e775ec22fc5b6967 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 24 Apr 2024 16:17:09 +0100 Subject: [PATCH 273/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 545f6fada..857a2bd6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## Changes + +- [@kowston](https://github.com/kowston) Changed wording for command descriptions to be consistent + ## 11.0.6 - 2024-04-21 - [@alissn](https://github.com/alissn) change package version to Pretty on php artisan about From 116597995a5d2fe850b55421f4ca9cc5dde519d6 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 24 Apr 2024 21:54:48 +0100 Subject: [PATCH 274/422] Changed Phrase --- src/Commands/Actions/ModelPruneCommand.php | 2 +- src/Commands/BaseCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Actions/ModelPruneCommand.php b/src/Commands/Actions/ModelPruneCommand.php index eacfb39f0..5d40051cb 100644 --- a/src/Commands/Actions/ModelPruneCommand.php +++ b/src/Commands/Actions/ModelPruneCommand.php @@ -50,7 +50,7 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf } $selected_item = multiselect( - label : 'What Module want to check?', + label : 'Select Modules', options : [ self::ALL, ...array_keys(Module::all()), diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 03b8f0e40..8faec7c95 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -78,7 +78,7 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf } $selected_item = multiselect( - label : 'What Module want to check?', + label : 'Select Modules', options : [ self::ALL, ...$modules, From 3481e3cc8bf8b6f18d4e23299b86e7127f7eb5be Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 24 Apr 2024 21:55:04 +0100 Subject: [PATCH 275/422] Moved Class to Database folder --- src/Commands/{ => Database}/MigrateFreshCommand.php | 12 +++++------- src/Providers/ConsoleServiceProvider.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) rename src/Commands/{ => Database}/MigrateFreshCommand.php (87%) diff --git a/src/Commands/MigrateFreshCommand.php b/src/Commands/Database/MigrateFreshCommand.php similarity index 87% rename from src/Commands/MigrateFreshCommand.php rename to src/Commands/Database/MigrateFreshCommand.php index 02863b674..4ba6f2d0a 100644 --- a/src/Commands/MigrateFreshCommand.php +++ b/src/Commands/Database/MigrateFreshCommand.php @@ -1,6 +1,6 @@ call('migrate:fresh'); - - $this->call('module:migrate', [ + $this->call('module:migrate-refresh', [ 'module' => $this->getModuleName(), '--database' => $this->option('database'), '--force' => $this->option('force'), @@ -55,7 +53,7 @@ public function handle(): int * * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], @@ -67,7 +65,7 @@ protected function getArguments() * * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 49bfeea56..fd4086706 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -87,7 +87,7 @@ public static function defaultCommands(): Collection Commands\LaravelModulesV6Migrator::class, Commands\SetupCommand::class, - Commands\MigrateFreshCommand::class, + Commands\Database\MigrateFreshCommand::class, ]); } } From 93a7193f43eb5e23e18a17be0b13de277be52069 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 24 Apr 2024 21:55:52 +0100 Subject: [PATCH 276/422] restrict migrate-fresh to reset only selected modules this way it's only in the scope of the module. --- src/Commands/Database/MigrateRefreshCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Database/MigrateRefreshCommand.php b/src/Commands/Database/MigrateRefreshCommand.php index a7adfdcd0..995e557bd 100644 --- a/src/Commands/Database/MigrateRefreshCommand.php +++ b/src/Commands/Database/MigrateRefreshCommand.php @@ -52,7 +52,7 @@ public function executeAction($name): void * * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], From d74e3aa8bf0267d3976da054adf57c203f542cdb Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 24 Apr 2024 22:20:26 +0100 Subject: [PATCH 277/422] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 857a2bd6b..7be5b01b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changes +- [@dcblogdev](https://github.com/dcblogdev) Restrict fresh migration to module scope - [@kowston](https://github.com/kowston) Changed wording for command descriptions to be consistent ## 11.0.6 - 2024-04-21 From 2a90fcd300c5f1ba9fb4d1b86e48e4b7b940a5e7 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 06:45:11 +0100 Subject: [PATCH 278/422] Create a PathNamespace trait Get a well-formatted StudlyCase representation of path components. Get a well-formatted StudlyCase namespace. Get a well-formatted namespace from a given path. Get a well-formatted StudlyCase namespace for a module, with an optional additional path. --- src/Traits/PathNamespace.php | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Traits/PathNamespace.php diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php new file mode 100644 index 000000000..45782f983 --- /dev/null +++ b/src/Traits/PathNamespace.php @@ -0,0 +1,46 @@ +replace("{$directory_separator}{$directory_separator}", $directory_separator)->trim($directory_separator))) + ->map(fn ($path) => Str::studly($path)) + ->implode($directory_separator); + } + + /** + * Get a well-formatted StudlyCase namespace. + */ + public function studly_namespace(string $namespace, $directory_separator = '\\'): string + { + return $this->studly_path($namespace, $directory_separator); + } + + /** + * Get a well-formatted namespace from a given path. + */ + public function path_namespace(string $path): string + { + return Str::of($this->studly_path($path))->replace('/', '\\')->trim('\\'); + } + + /** + * Get a well-formatted StudlyCase namespace for a module, with an optional additional path. + */ + public function module_namespace(string $module, string $path = null): string + { + $module_namespace = config('modules.namespace') . '\\' . ($module); + $module_namespace .= strlen($path) ? '\\' . $this->path_namespace($path) : ''; + + return $this->studly_namespace($module_namespace); + } +} From 0423387f8a68c3b3a11d6e1bb0ff64b928a08a10 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 07:29:51 +0100 Subject: [PATCH 279/422] [fix] Apply PathNamespace trait to GeneratorPath Fixed the issue with namespace mixed case format. Changes: Modules/Example/module.json Before: ```json "providers": [ "Modules\\Example\\app\\Providers\\ExampleServiceProvider" ] ``` After: ```json "providers": [ "Modules\\Example\\App\\Providers\\ExampleServiceProvider" ] ``` --- src/Support/Config/GeneratorPath.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Support/Config/GeneratorPath.php b/src/Support/Config/GeneratorPath.php index 385bf2c01..861c957f4 100644 --- a/src/Support/Config/GeneratorPath.php +++ b/src/Support/Config/GeneratorPath.php @@ -2,8 +2,12 @@ namespace Nwidart\Modules\Support\Config; +use Nwidart\Modules\Traits\PathNamespace; + class GeneratorPath { + use PathNamespace; + private $path; private $generate; private $namespace; @@ -13,13 +17,14 @@ public function __construct($config) if (is_array($config)) { $this->path = $config['path']; $this->generate = $config['generate']; - $this->namespace = $config['namespace'] ?? $this->convertPathToNamespace($config['path']); + $this->namespace = $config['namespace'] ?? $this->path_namespace(ltrim($config['path'], config('modules.paths.app_folder', ''))); return; } + $this->path = $config; $this->generate = (bool) $config; - $this->namespace = $config; + $this->namespace = $this->path_namespace(ltrim($config, config('modules.paths.app_folder', ''))); } public function getPath() @@ -34,11 +39,6 @@ public function generate(): bool public function getNamespace() { - return $this->namespace; - } - - private function convertPathToNamespace($path) - { - return str_replace('/', '\\', ltrim($path, config('modules.paths.app_folder', ''))); + return $this->studly_namespace($this->namespace); } } From 1c57fa57d4f6aa702f41ab0ee4231773f5f2d658 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 08:17:17 +0100 Subject: [PATCH 280/422] [fix] Fix getControllerNamespaceReplacement() 1. Maintain custom namespace. 2. Get a well-formatted namespace from the controllers path. --- src/Generators/ModuleGenerator.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 49a98fe6b..c3cd5c69d 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -10,9 +10,12 @@ use Nwidart\Modules\FileRepository; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; +use Nwidart\Modules\Traits\PathNamespace; class ModuleGenerator extends Generator { + use PathNamespace; + /** * The module name will created. * @@ -634,12 +637,14 @@ protected function getModuleNamespaceReplacement() /** * Get replacement for $CONTROLLER_NAMESPACE$. - * - * @return string */ private function getControllerNamespaceReplacement(): string { - return str_replace('/', '\\', $this->module->config('paths.generator.controller.namespace') ?: ltrim($this->module->config('paths.generator.controller.path', 'Controller'), config('modules.paths.app_folder'))); + if ($this->module->config('paths.generator.controller.namespace')) { + return $this->module->config('paths.generator.controller.namespace'); + } else { + return $this->path_namespace(ltrim($this->module->config('paths.generator.controller.path', 'app/Http/Controllers'), config('modules.paths.app_folder'))); + } } /** From 8acab22a10f8877e4d9117fddde92f3e74b0440a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 08:32:19 +0100 Subject: [PATCH 281/422] [feature] Add the ability to generate namespace from modules path. --- src/Generators/ModuleGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index c3cd5c69d..6232377a7 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -632,7 +632,7 @@ protected function getVendorReplacement() */ protected function getModuleNamespaceReplacement() { - return str_replace('\\', '\\\\', $this->module->config('namespace')); + return str_replace('\\', '\\\\', $this->module->config('namespace') ?? $this->path_namespace($this->module->config('paths.modules'))); } /** From c444e56d119e3b8415c575c2bbac24379a90ab3a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 08:39:57 +0100 Subject: [PATCH 282/422] [feature] Add the ability to generate modules namespace from path. --- src/Traits/PathNamespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php index 45782f983..ae6c59222 100644 --- a/src/Traits/PathNamespace.php +++ b/src/Traits/PathNamespace.php @@ -38,7 +38,7 @@ public function path_namespace(string $path): string */ public function module_namespace(string $module, string $path = null): string { - $module_namespace = config('modules.namespace') . '\\' . ($module); + $module_namespace = config('modules.namespace', $this->path_namespace(config('modules.paths.modules'))) . '\\' . ($module); $module_namespace .= strlen($path) ? '\\' . $this->path_namespace($path) : ''; return $this->studly_namespace($module_namespace); From 1b2b383cb7053e75553e210d5d949449b121dddc Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 08:59:12 +0100 Subject: [PATCH 283/422] [fix] Generate a well-formatted namespace using a module name and optional path. --- src/Commands/Make/GeneratorCommand.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index f305f7777..fdd7b41e3 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -5,9 +5,12 @@ use Illuminate\Console\Command; use Nwidart\Modules\Exceptions\FileAlreadyExistException; use Nwidart\Modules\Generators\FileGenerator; +use Nwidart\Modules\Traits\PathNamespace; abstract class GeneratorCommand extends Command { + use PathNamespace; + /** * The name of 'name' argument. * @@ -86,20 +89,8 @@ public function getDefaultNamespace(): string */ public function getClassNamespace($module) { - $extra = str_replace($this->getClass(), '', $this->argument($this->argumentName)); - - $extra = str_replace('/', '\\', $extra); - - $namespace = $this->laravel['modules']->config('namespace'); - - $namespace .= '\\' . $module->getStudlyName(); - - $namespace .= '\\' . $this->getDefaultNamespace(); - - $namespace .= '\\' . $extra; - - $namespace = str_replace('/', '\\', $namespace); + $path_namespace = $this->path_namespace(str_replace($this->getClass(), '', $this->argument($this->argumentName))); - return trim($namespace, '\\'); + return $this->module_namespace($module->getStudlyName(), $this->getDefaultNamespace() . ($path_namespace ? '\\' . $path_namespace : '')); } } From 0fe6c613e889447eb78c1aa47e66c0d53ee09053 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 10:28:57 +0100 Subject: [PATCH 284/422] [test] Update test --- ...sMakeCommandTest__it_can_change_the_default_namespace__1.txt | 2 +- ...CommandTest__test_it_can_change_the_default_namespace__1.txt | 2 +- ...st__it_can_change_the_default_unit_namespace_specific__1.txt | 2 +- ...dTest__it_generated_correct_feature_file_with_content__1.txt | 2 +- ...mandTest__it_generated_correct_unit_file_with_content__1.txt | 2 +- ...est_it_can_change_the_default_unit_namespace_specific__1.txt | 2 +- ...__test_it_generated_correct_feature_file_with_content__1.txt | 2 +- ...est__test_it_generated_correct_unit_file_with_content__1.txt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt index 98679cf0f..259ea2d5b 100644 --- a/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt @@ -1,6 +1,6 @@ Date: Mon, 1 Apr 2024 17:41:56 +0100 Subject: [PATCH 285/422] Create make:class command Description: Create a new class Usage: module:make:class [options] [--] Arguments: name The name of the class module The targeted module Options: -t, --type[=TYPE] The type of class, e.g. class, service, repository, contract, etc. [default: "service"] -p, --plain Create the class without suffix (type) -i, --invokable Generate a single method, invokable class -f, --force Create the class even if the class already exists -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi|--no-ansi Force (or disable --no-ansi) ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Examples: ``` php artisan module:make:class Example Example ``` ``` php artisan module:make:class Example Example -t class ``` ``` php artisan module:make:class Example Example -t repository ``` ``` php artisan module:make:class Example Example -p -t repository ``` --- config/config.php | 72 ++++++++--------- src/Commands/Make/ClassCommand.php | 95 +++++++++++++++++++++++ src/Commands/stubs/app/Classes/Class.stub | 14 ++++ src/Providers/ConsoleServiceProvider.php | 1 + 4 files changed, 146 insertions(+), 36 deletions(-) create mode 100644 src/Commands/Make/ClassCommand.php create mode 100644 src/Commands/stubs/app/Classes/Class.stub diff --git a/config/config.php b/config/config.php index f6fca59f8..34fed3bd7 100644 --- a/config/config.php +++ b/config/config.php @@ -71,37 +71,6 @@ */ 'modules' => base_path('Modules'), - /* - |-------------------------------------------------------------------------- - | Modules assets path - |-------------------------------------------------------------------------- - | - | Here you may update the modules' assets path. - | - */ - 'assets' => public_path('modules'), - - /* - |-------------------------------------------------------------------------- - | The migrations' path - |-------------------------------------------------------------------------- - | - | Where you run the 'module:publish-migration' command, where do you publish the - | the migration files? - | - */ - 'migration' => base_path('database/migrations'), - - /* - |-------------------------------------------------------------------------- - | The app path - |-------------------------------------------------------------------------- - | - | app folder name - | for example can change it to 'src' or 'App' - */ - 'app_folder' => 'app/', - /* |-------------------------------------------------------------------------- | Generator path @@ -112,7 +81,9 @@ 'generator' => [ // app/ 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], + 'class' => ['path' => 'app/Classes', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], @@ -126,8 +97,6 @@ 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], - 'service' => ['path' => 'app/Services', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], @@ -138,25 +107,56 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ + 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], 'migration' => ['path' => 'database/migrations', 'generate' => true], 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], - 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], // resource/ 'assets' => ['path' => 'resources/assets', 'generate' => true], - 'views' => ['path' => 'resources/views', 'generate' => true], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], + 'views' => ['path' => 'resources/views', 'generate' => true], // routes/ 'routes' => ['path' => 'routes', 'generate' => true], // tests/ - 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], + 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], ], + + /* + |-------------------------------------------------------------------------- + | Modules assets path + |-------------------------------------------------------------------------- + | + | Here you may update the modules' assets path. + | + */ + 'assets' => public_path('modules'), + + /* + |-------------------------------------------------------------------------- + | The migrations' path + |-------------------------------------------------------------------------- + | + | Where you run the 'module:publish-migration' command, where do you publish the + | the migration files? + | + */ + 'migration' => base_path('database/migrations'), + + /* + |-------------------------------------------------------------------------- + | The app path + |-------------------------------------------------------------------------- + | + | app folder name + | for example can change it to 'src' or 'App' + */ + 'app_folder' => 'app/', ], /* diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php new file mode 100644 index 000000000..b90fbd521 --- /dev/null +++ b/src/Commands/Make/ClassCommand.php @@ -0,0 +1,95 @@ +laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub('/app/Classes/Class.stub', [ + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + ]))->render(); + } + + /** + * Get class namespace. + */ + public function getClassNamespace($module): string + { + return $this->getModuleNamespace($this->getDefaultNamespace()); + } + + public function getDestinationFilePath() + { + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $config = GenerateConfigReader::read('class'); + $path .= $this->typePath($config->getPath()) . '/' . $this->getFileName() . '.php'; + + return $path; + } + + protected function getFileName() + { + $file = Str::studly($this->argument('name')); + + if ($this->option('plain') === false and $this->option('type') !== 'class') { + $file .= $this->type(); + } + + return $file; + } + + /** + * Get the type of class e.g. Class, Services, Repository, etc. + */ + protected function type() + { + return Str::studly($this->option('type')); + } + + protected function typePath(string $path) + { + return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); + } + + /** + * Get class name. + */ + public function getClass(): string + { + return $this->getFileName(); + } + + public function getDefaultNamespace(): string + { + $type = $this->option('type'); + + return config("modules.paths.generator.{$type}.namespace", $this->getPathNamespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + } +} diff --git a/src/Commands/stubs/app/Classes/Class.stub b/src/Commands/stubs/app/Classes/Class.stub new file mode 100644 index 000000000..27bf6b064 --- /dev/null +++ b/src/Commands/stubs/app/Classes/Class.stub @@ -0,0 +1,14 @@ + Date: Wed, 17 Apr 2024 07:48:18 +0100 Subject: [PATCH 286/422] Updated .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 17aa6d40e..7a0015c03 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ coverage .phpunit.result.cache .idea .php-cs-fixer.cache +.DS_Store +src/.DS_Store +tests/.DS_Store From 9c83ba6e7c59ad299e72d3d2ba7dde97b045626c Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 11:33:16 +0100 Subject: [PATCH 287/422] [misc] restored config data position --- config/config.php | 62 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/config/config.php b/config/config.php index 34fed3bd7..37059bffa 100644 --- a/config/config.php +++ b/config/config.php @@ -71,6 +71,37 @@ */ 'modules' => base_path('Modules'), + /* + |-------------------------------------------------------------------------- + | Modules assets path + |-------------------------------------------------------------------------- + | + | Here you may update the modules' assets path. + | + */ + 'assets' => public_path('modules'), + + /* + |-------------------------------------------------------------------------- + | The migrations' path + |-------------------------------------------------------------------------- + | + | Where you run the 'module:publish-migration' command, where do you publish the + | the migration files? + | + */ + 'migration' => base_path('database/migrations'), + + /* + |-------------------------------------------------------------------------- + | The app path + |-------------------------------------------------------------------------- + | + | app folder name + | for example can change it to 'src' or 'App' + */ + 'app_folder' => 'app/', + /* |-------------------------------------------------------------------------- | Generator path @@ -126,37 +157,6 @@ 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], ], - - /* - |-------------------------------------------------------------------------- - | Modules assets path - |-------------------------------------------------------------------------- - | - | Here you may update the modules' assets path. - | - */ - 'assets' => public_path('modules'), - - /* - |-------------------------------------------------------------------------- - | The migrations' path - |-------------------------------------------------------------------------- - | - | Where you run the 'module:publish-migration' command, where do you publish the - | the migration files? - | - */ - 'migration' => base_path('database/migrations'), - - /* - |-------------------------------------------------------------------------- - | The app path - |-------------------------------------------------------------------------- - | - | app folder name - | for example can change it to 'src' or 'App' - */ - 'app_folder' => 'app/', ], /* From cd07cb82e7ad681f8b5512dc2cd43e61e55418fc Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 13:18:21 +0100 Subject: [PATCH 288/422] [optimize] Check $this->argumentName is not null before adding extra path --- src/Commands/Make/GeneratorCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index f305f7777..6dc4395ee 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -86,7 +86,7 @@ public function getDefaultNamespace(): string */ public function getClassNamespace($module) { - $extra = str_replace($this->getClass(), '', $this->argument($this->argumentName)); + $extra = $this->argumentName ? str_replace($this->getClass(), '', $this->argument($this->argumentName)) : ''; $extra = str_replace('/', '\\', $extra); @@ -96,7 +96,7 @@ public function getClassNamespace($module) $namespace .= '\\' . $this->getDefaultNamespace(); - $namespace .= '\\' . $extra; + $namespace .= $extra ? '\\' . $extra : ''; $namespace = str_replace('/', '\\', $namespace); From a1c7b1d799a6b97958668501983d09ddce2d23fa Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 13:27:58 +0100 Subject: [PATCH 289/422] [complete] Update class --- src/Commands/Make/ClassCommand.php | 31 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index b90fbd521..39ab61982 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -15,7 +15,7 @@ class ClassCommand extends GeneratorCommand * The name and signature of the console command. */ protected $signature = 'module:make-class - {--t|type=service : The type of class, e.g. class, service, repository, contract, etc.} + {--t|type=class : The type of class, e.g. class, service, repository, contract, etc.} {--p|plain : Create the class without suffix (type)} {--i|invokable : Generate a single method, invokable class} {--f|force : Create the class even if the class already exists} @@ -37,14 +37,6 @@ public function getTemplateContents() ]))->render(); } - /** - * Get class namespace. - */ - public function getClassNamespace($module): string - { - return $this->getModuleNamespace($this->getDefaultNamespace()); - } - public function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); @@ -90,6 +82,25 @@ public function getDefaultNamespace(): string { $type = $this->option('type'); - return config("modules.paths.generator.{$type}.namespace", $this->getPathNamespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + } + + /** + * Get a well-formatted StudlyCase representation of path components. + */ + public function studly_path(string $path, $directory_separator = '/'): string + { + return collect(explode($directory_separator, Str::of($path) + ->replace("{$directory_separator}{$directory_separator}", $directory_separator)->trim($directory_separator))) + ->map(fn ($path) => Str::studly($path)) + ->implode($directory_separator); + } + + /** + * Get a well-formatted namespace from a given path. + */ + public function path_namespace(string $path): string + { + return Str::of($this->studly_path($path))->replace('/', '\\')->trim('\\'); } } From d40e10f16591061bd7dc92e0c14e3766f0ad2ec5 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 25 Apr 2024 13:29:17 +0100 Subject: [PATCH 290/422] added invokable and force options into make-service command --- src/Commands/Make/ServiceMakeCommand.php | 21 ++++++++++++++++----- src/Commands/stubs/service-invoke.stub | 11 +++++++++++ tests/Commands/ServiceMakeCommandTest.php | 17 +++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 src/Commands/stubs/service-invoke.stub diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index e5707aed8..80ccdaf39 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -7,6 +7,7 @@ use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; class ServiceMakeCommand extends GeneratorCommand { @@ -20,9 +21,9 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $servicePath = GenerateConfigReader::read('service'); + $servicePath = GenerateConfigReader::read('service')->getPath() ?? config('modules.paths.app_folder').'Services'; - return $path . $servicePath->getPath() . '/' . $this->getServiceName() . '.php'; + return $path . $servicePath . '/' . $this->getServiceName() . '.php'; } protected function getTemplateContents(): string @@ -43,6 +44,17 @@ protected function getArguments(): array ]; } + /** + * @return array + */ + protected function getOptions() + { + return [ + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable class', null], + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + protected function getServiceName(): array|string { return Str::studly($this->argument('name')); @@ -55,12 +67,11 @@ private function getClassNameWithoutNamespace(): array|string public function getDefaultNamespace(): string { - return config('modules.paths.generator.service.namespace') - ?? ltrim(config('modules.paths.generator.service.path', 'Services'), config('modules.paths.app_folder')); + return config('modules.paths.generator.service.namespace', 'Services'); } protected function getStubName(): string { - return '/service.stub'; + return $this->option('invokable') === true ? '/service-invoke.stub' : '/service.stub'; } } diff --git a/src/Commands/stubs/service-invoke.stub b/src/Commands/stubs/service-invoke.stub new file mode 100644 index 000000000..d91b100eb --- /dev/null +++ b/src/Commands/stubs/service-invoke.stub @@ -0,0 +1,11 @@ +assertSame(0, $code); } + public function test_it_generates_a_new_service_class_can_override_with_force_option() + { + $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); + $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Services/MyService.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_service_class_can_use_invoke_option() + { + $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog', '--invokable' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Services/MyService.php')); + $this->assertSame(0, $code); + } + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); From 4135c3a33b8262c19a4cda6669ba93e857ad3e59 Mon Sep 17 00:00:00 2001 From: korridor <26689068+korridor@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:46:50 +0200 Subject: [PATCH 291/422] Fixed public path for octane setup --- src/Module.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module.php b/src/Module.php index 584c223bb..2dc37a9a1 100644 --- a/src/Module.php +++ b/src/Module.php @@ -83,8 +83,8 @@ public static function getAssets(): array { $paths = []; - if (file_exists('build/manifest.json')) { - $files = json_decode(file_get_contents('build/manifest.json'), true); + if (file_exists(public_path('build/manifest.json'))) { + $files = json_decode(file_get_contents(public_path('build/manifest.json')), true); if (is_array($files)) { foreach ($files as $file) { From edcdb46cfb2517496af91aec463545848f158279 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 25 Apr 2024 14:11:54 +0100 Subject: [PATCH 292/422] updated CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be5b01b8..c255888a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changes +- [@solomon-ochepa](https://github.com/solomon-ochepa) Path Namespace - generate a well-formatted StudlyCase namespace from paths +- [@korridor](https://github.com/korridor) Fixed public path for octane setup +- [@dcblogdev](https://github.com/dcblogdev) added invokable and force options into make-service command - [@dcblogdev](https://github.com/dcblogdev) Restrict fresh migration to module scope - [@kowston](https://github.com/kowston) Changed wording for command descriptions to be consistent From f0ab778eef0f4ba1bfd2112339061a380de106c7 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 25 Apr 2024 14:53:14 +0100 Subject: [PATCH 293/422] enforce config option --- src/Generators/ModuleGenerator.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 6232377a7..9c9e02b05 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -92,7 +92,7 @@ class ModuleGenerator extends Generator * @var array */ protected array $author = [ - 'name', 'email' + 'name', 'email', ]; /** @@ -299,7 +299,7 @@ public function setModule($module) * @param string|null $email * @return $this */ - function setAuthor(string $name = null, string $email = null) + public function setAuthor(string $name = null, string $email = null) { $this->author['name'] = $name; $this->author['email'] = $email; @@ -313,7 +313,7 @@ function setAuthor(string $name = null, string $email = null) * @param string|null $vendor * @return $this */ - function setVendor(string $vendor = null) + public function setVendor(string $vendor = null) { $this->vendor = $vendor; @@ -536,6 +536,10 @@ protected function getReplacement($stub) { $replacements = $this->module->config('stubs.replacements'); + if (!isset($replacements['composer']['APP_FOLDER_NAME'])) { + $replacements['composer'][] = 'APP_FOLDER_NAME'; + } + if (!isset($replacements[$stub])) { return []; } From f6975a36cd0d7470faf4e53a0a4641cc813cdd69 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 25 Apr 2024 14:59:01 +0100 Subject: [PATCH 294/422] updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c255888a4..00ae76976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Changes +- [@dcblogdev](https://github.com/dcblogdev) Force the config replacement option for composer 'APP_FOLDER_NAME', to be handled even when its not present. - [@solomon-ochepa](https://github.com/solomon-ochepa) Path Namespace - generate a well-formatted StudlyCase namespace from paths - [@korridor](https://github.com/korridor) Fixed public path for octane setup - [@dcblogdev](https://github.com/dcblogdev) added invokable and force options into make-service command From c753da9e2cd635a1940932e3251d4eae80b333d3 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 25 Apr 2024 15:00:52 +0100 Subject: [PATCH 295/422] updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00ae76976..c2828f642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.7 - 2024-04-25 + ## Changes - [@dcblogdev](https://github.com/dcblogdev) Force the config replacement option for composer 'APP_FOLDER_NAME', to be handled even when its not present. From 8fe10578cbe4d7071fc75956b9b938d0c5efe9fc Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 05:23:49 +0100 Subject: [PATCH 296/422] [fix] Add $argumentName = "name" --- src/Commands/Make/ClassCommand.php | 8 +++++--- src/Commands/Make/GeneratorCommand.php | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index 39ab61982..fb31d0f51 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -27,6 +27,8 @@ class ClassCommand extends GeneratorCommand */ protected $description = 'Create a new class'; + protected $argumentName = "name"; + public function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); @@ -41,7 +43,7 @@ public function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $config = GenerateConfigReader::read('class'); - $path .= $this->typePath($config->getPath()) . '/' . $this->getFileName() . '.php'; + $path .= $this->type_path($config->getPath()) . '/' . $this->getFileName() . '.php'; return $path; } @@ -65,7 +67,7 @@ protected function type() return Str::studly($this->option('type')); } - protected function typePath(string $path) + protected function type_path(string $path) { return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); } @@ -82,7 +84,7 @@ public function getDefaultNamespace(): string { $type = $this->option('type'); - return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->type_path('app/Classes')))); } /** diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index 0cf07809b..fdd7b41e3 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -50,6 +50,7 @@ public function handle(): int $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); }); + } catch (FileAlreadyExistException $e) { $this->components->error("File : {$path} already exists."); From d16d194dfe096668e254b1efe93c0a7a8c88a127 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 05:41:27 +0100 Subject: [PATCH 297/422] Revert changes to config --- config/config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index 37059bffa..60f2ba15f 100644 --- a/config/config.php +++ b/config/config.php @@ -114,7 +114,6 @@ 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'class' => ['path' => 'app/Classes', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], @@ -128,6 +127,7 @@ 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], @@ -138,24 +138,24 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ - 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], 'migration' => ['path' => 'database/migrations', 'generate' => true], 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], // resource/ 'assets' => ['path' => 'resources/assets', 'generate' => true], - 'component-view' => ['path' => 'resources/views/components', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], + 'component-view' => ['path' => 'resources/views/components', 'generate' => false], // routes/ 'routes' => ['path' => 'routes', 'generate' => true], // tests/ - 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], ], ], From 2b6653cb92d4d7b91cd77d32828ff80d72540705 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 06:09:25 +0100 Subject: [PATCH 298/422] Create class stub --- src/Commands/stubs/app/Repositories/Class.stub | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/Commands/stubs/app/Repositories/Class.stub diff --git a/src/Commands/stubs/app/Repositories/Class.stub b/src/Commands/stubs/app/Repositories/Class.stub new file mode 100644 index 000000000..27bf6b064 --- /dev/null +++ b/src/Commands/stubs/app/Repositories/Class.stub @@ -0,0 +1,14 @@ + Date: Fri, 26 Apr 2024 06:12:49 +0100 Subject: [PATCH 299/422] [wip] Create RepositoryCommand --- src/Commands/Make/RepositoryCommand.php | 88 +++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/Commands/Make/RepositoryCommand.php diff --git a/src/Commands/Make/RepositoryCommand.php b/src/Commands/Make/RepositoryCommand.php new file mode 100644 index 000000000..bcdb0009e --- /dev/null +++ b/src/Commands/Make/RepositoryCommand.php @@ -0,0 +1,88 @@ +laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub('/app/Repositories/Class.stub', [ + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + ]))->render(); + } + + public function getDestinationFilePath() + { + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $config = GenerateConfigReader::read('repository'); + $path .= $this->type_path($config->getPath()) . '/' . $this->getFileName() . '.php'; + + return $path; + } + + protected function getFileName() + { + $file = Str::studly($this->argument('name')); + + if ($this->option('plain') === false and $this->option('type') !== 'class') { + $file .= $this->type(); + } + + return $file; + } + + /** + * Get the type of class - Repository. + */ + protected function type() + { + return Str::studly('Repository'); + } + + protected function type_path(string $path) + { + return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); + } + + /** + * Get class name. + */ + public function getClass(): string + { + return $this->getFileName(); + } + + public function getDefaultNamespace(): string + { + $type = $this->option('type'); + + return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->type_path('app/Classes')))); + } +} From 0da1993800f209076296272f6a6cf4f215c2200b Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 06:14:06 +0100 Subject: [PATCH 300/422] Register RepositoryCommand to default commands --- src/Providers/ConsoleServiceProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index c98b147da..2eb1c4834 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -68,6 +68,7 @@ public static function defaultCommands(): Collection Commands\Make\ObserverMakeCommand::class, Commands\Make\PolicyMakeCommand::class, Commands\Make\ProviderMakeCommand::class, + Commands\Make\RepositoryCommand::class, Commands\Make\RequestMakeCommand::class, Commands\Make\ResourceMakeCommand::class, Commands\Make\RouteProviderMakeCommand::class, From 03339b22883550278edadfaa7b9b78282402f528 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 06:58:52 +0100 Subject: [PATCH 301/422] Remove custom namespaces from generator [factory and seeder]. The newly merged PathNamespace feature can now generate a well-formatted StudlyCase namespace. Custom namespaces should only be utilized when modifying the default namespace structure. --- config/config.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/config.php b/config/config.php index f6fca59f8..55a57cd6b 100644 --- a/config/config.php +++ b/config/config.php @@ -113,6 +113,7 @@ // app/ 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], @@ -122,11 +123,10 @@ 'observer' => ['path' => 'app/Observers', 'generate' => false], 'policies' => ['path' => 'app/Policies', 'generate' => false], 'provider' => ['path' => 'app/Providers', 'generate' => true], - 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], + 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'rules' => ['path' => 'app/Rules', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'service' => ['path' => 'app/Services', 'generate' => false], // app/Http/ @@ -138,24 +138,24 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ + 'factory' => ['path' => 'database/factories', 'generate' => true], 'migration' => ['path' => 'database/migrations', 'generate' => true], - 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], - 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], // resource/ 'assets' => ['path' => 'resources/assets', 'generate' => true], - 'views' => ['path' => 'resources/views', 'generate' => true], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], + 'views' => ['path' => 'resources/views', 'generate' => true], // routes/ 'routes' => ['path' => 'routes', 'generate' => true], // tests/ - 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], + 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], ], ], From e11539bd694f83835014e5050b249b0047ae5e2e Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 14:45:20 +0100 Subject: [PATCH 302/422] added missing return type --- src/Commands/Make/ServiceMakeCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index 80ccdaf39..c510ad9df 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -21,7 +21,7 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $servicePath = GenerateConfigReader::read('service')->getPath() ?? config('modules.paths.app_folder').'Services'; + $servicePath = GenerateConfigReader::read('service')->getPath() ?? config('modules.paths.app_folder') . 'Services'; return $path . $servicePath . '/' . $this->getServiceName() . '.php'; } @@ -47,7 +47,7 @@ protected function getArguments(): array /** * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable class', null], From c6b4ae82d94e6686454f3a9f5506bed136cb9055 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 14:46:12 +0100 Subject: [PATCH 303/422] renamed variable --- src/Commands/Make/ServiceMakeCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index c510ad9df..98df4dc0d 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -21,9 +21,9 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $servicePath = GenerateConfigReader::read('service')->getPath() ?? config('modules.paths.app_folder') . 'Services'; + $filePath = GenerateConfigReader::read('service')->getPath() ?? config('modules.paths.app_folder') . 'Services'; - return $path . $servicePath . '/' . $this->getServiceName() . '.php'; + return $path . $filePath . '/' . $this->getServiceName() . '.php'; } protected function getTemplateContents(): string From 2265e5e5a43bd48a8dcb5edf3763d682ae5c8eb7 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 14:52:01 +0100 Subject: [PATCH 304/422] added make-enum command --- src/Commands/Make/EnumMakeCommand.php | 76 +++++++++++++++++ src/Commands/stubs/enum.stub | 8 ++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/EnumMakeCommandTest.php | 81 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 8 ++ ...generated_correct_file_with_content__1.txt | 8 ++ 6 files changed, 182 insertions(+) create mode 100644 src/Commands/Make/EnumMakeCommand.php create mode 100644 src/Commands/stubs/enum.stub create mode 100644 tests/Commands/EnumMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/src/Commands/Make/EnumMakeCommand.php b/src/Commands/Make/EnumMakeCommand.php new file mode 100644 index 000000000..dc7b3ffaf --- /dev/null +++ b/src/Commands/Make/EnumMakeCommand.php @@ -0,0 +1,76 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('enum')->getPath() ?? config('modules.paths.app_folder') . 'Enums'; + + return $path . $filePath . '/' . $this->getEnumName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the enum class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getEnumName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getEnumName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.enum.namespace', 'Enums'); + } + + protected function getStubName(): string + { + return '/enum.stub'; + } +} diff --git a/src/Commands/stubs/enum.stub b/src/Commands/stubs/enum.stub new file mode 100644 index 000000000..4cbbcbe50 --- /dev/null +++ b/src/Commands/stubs/enum.stub @@ -0,0 +1,8 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_enum_class() + { + $code = $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Enums/MyEnum.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_enum_class_can_override_with_force_option() + { + $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog']); + $code = $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Enums/MyEnum.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Enums/MyEnum.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_enum_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-enum', ['name' => 'Api\\MyEnum', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Enums/Api/MyEnum.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-enum', ['name' => 'Api\\MyEnum', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Enums/Api/MyEnum.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..c9edb0b1b --- /dev/null +++ b/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ + Date: Mon, 29 Apr 2024 14:55:44 +0100 Subject: [PATCH 305/422] added make-enum command --- src/Commands/Make/ActionMakeCommand.php | 77 ++++++++++++++++ src/Commands/stubs/action-invoke.stub | 11 +++ src/Commands/stubs/action.stub | 11 +++ src/Providers/ConsoleServiceProvider.php | 2 +- tests/Commands/ActionMakeCommandTest.php | 89 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 11 +++ ...generated_correct_file_with_content__1.txt | 11 +++ 7 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 src/Commands/Make/ActionMakeCommand.php create mode 100644 src/Commands/stubs/action-invoke.stub create mode 100644 src/Commands/stubs/action.stub create mode 100644 tests/Commands/ActionMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/src/Commands/Make/ActionMakeCommand.php b/src/Commands/Make/ActionMakeCommand.php new file mode 100644 index 000000000..a7e996f86 --- /dev/null +++ b/src/Commands/Make/ActionMakeCommand.php @@ -0,0 +1,77 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('action')->getPath() ?? config('modules.paths.app_folder') . 'Actions'; + + return $path . $filePath . '/' . $this->getActionName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the action class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable class', null], + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getActionName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getActionName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.action.namespace', 'Actions'); + } + + protected function getStubName(): string + { + return $this->option('invokable') === true ? '/action-invoke.stub' : '/action.stub'; + } +} diff --git a/src/Commands/stubs/action-invoke.stub b/src/Commands/stubs/action-invoke.stub new file mode 100644 index 000000000..d91b100eb --- /dev/null +++ b/src/Commands/stubs/action-invoke.stub @@ -0,0 +1,11 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_action_class() + { + $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Actions/MyAction.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_action_class_can_override_with_force_option() + { + $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog']); + $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Actions/MyAction.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_action_class_can_use_invoke_option() + { + $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog', '--invokable' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Actions/MyAction.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Actions/MyAction.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_action_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-action', ['name' => 'Api\\MyAction', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Actions/Api/MyAction.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-action', ['name' => 'Api\\MyAction', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Actions/Api/MyAction.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..3c7f43726 --- /dev/null +++ b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,11 @@ + Date: Mon, 29 Apr 2024 15:00:15 +0100 Subject: [PATCH 306/422] added make-enum command --- src/Commands/Make/HelperMakeCommand.php | 77 ++++++++++++++++ src/Commands/stubs/helper-invoke.stub | 11 +++ src/Commands/stubs/helper.stub | 11 +++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/HelperMakeCommandTest.php | 89 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 11 +++ ...generated_correct_file_with_content__1.txt | 11 +++ 7 files changed, 211 insertions(+) create mode 100644 src/Commands/Make/HelperMakeCommand.php create mode 100644 src/Commands/stubs/helper-invoke.stub create mode 100644 src/Commands/stubs/helper.stub create mode 100644 tests/Commands/HelperMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/src/Commands/Make/HelperMakeCommand.php b/src/Commands/Make/HelperMakeCommand.php new file mode 100644 index 000000000..efcd619a7 --- /dev/null +++ b/src/Commands/Make/HelperMakeCommand.php @@ -0,0 +1,77 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('helper')->getPath() ?? config('modules.paths.app_folder') . 'Helpers'; + + return $path . $filePath . '/' . $this->getHelperName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the helper class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable class', null], + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getHelperName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getHelperName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.helper.namespace', 'Helpers'); + } + + protected function getStubName(): string + { + return $this->option('invokable') === true ? '/helper-invoke.stub' : '/helper.stub'; + } +} diff --git a/src/Commands/stubs/helper-invoke.stub b/src/Commands/stubs/helper-invoke.stub new file mode 100644 index 000000000..d91b100eb --- /dev/null +++ b/src/Commands/stubs/helper-invoke.stub @@ -0,0 +1,11 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_helper_class() + { + $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Helpers/MyHelper.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_helper_class_can_override_with_force_option() + { + $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']); + $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Helpers/MyHelper.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_helper_class_can_use_invoke_option() + { + $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog', '--invokable' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Helpers/MyHelper.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Helpers/MyHelper.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_helper_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-helper', ['name' => 'Api\\MyHelper', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Helpers/Api/MyHelper.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-helper', ['name' => 'Api\\MyHelper', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Helpers/Api/MyHelper.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..0a0f9e701 --- /dev/null +++ b/tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,11 @@ + Date: Mon, 29 Apr 2024 15:06:38 +0100 Subject: [PATCH 307/422] corrected names --- config/config.php | 5 ++++- src/Commands/Make/ActionMakeCommand.php | 2 +- src/Commands/Make/EnumMakeCommand.php | 2 +- src/Commands/Make/HelperMakeCommand.php | 2 +- src/Commands/Make/ServiceMakeCommand.php | 2 +- src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/ServiceMakeCommandTest.php | 12 ------------ 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/config/config.php b/config/config.php index f6fca59f8..543eeb9e3 100644 --- a/config/config.php +++ b/config/config.php @@ -111,11 +111,14 @@ */ 'generator' => [ // app/ + 'actions' => ['path' => 'app/Actions', 'generate' => false], 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], + 'enums' => ['path' => 'app/Enums', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], + 'helpers' => ['path' => 'app/Helpers', 'generate' => false], 'listener' => ['path' => 'app/Listeners', 'generate' => false], 'model' => ['path' => 'app/Models', 'generate' => false], 'notifications' => ['path' => 'app/Notifications', 'generate' => false], @@ -127,7 +130,7 @@ 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], - 'service' => ['path' => 'app/Services', 'generate' => false], + 'services' => ['path' => 'app/Services', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], diff --git a/src/Commands/Make/ActionMakeCommand.php b/src/Commands/Make/ActionMakeCommand.php index a7e996f86..ad5ef3e7d 100644 --- a/src/Commands/Make/ActionMakeCommand.php +++ b/src/Commands/Make/ActionMakeCommand.php @@ -21,7 +21,7 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('action')->getPath() ?? config('modules.paths.app_folder') . 'Actions'; + $filePath = GenerateConfigReader::read('actions')->getPath() ?? config('modules.paths.app_folder') . 'Actions'; return $path . $filePath . '/' . $this->getActionName() . '.php'; } diff --git a/src/Commands/Make/EnumMakeCommand.php b/src/Commands/Make/EnumMakeCommand.php index dc7b3ffaf..dbd1d4354 100644 --- a/src/Commands/Make/EnumMakeCommand.php +++ b/src/Commands/Make/EnumMakeCommand.php @@ -21,7 +21,7 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('enum')->getPath() ?? config('modules.paths.app_folder') . 'Enums'; + $filePath = GenerateConfigReader::read('enums')->getPath() ?? config('modules.paths.app_folder') . 'Enums'; return $path . $filePath . '/' . $this->getEnumName() . '.php'; } diff --git a/src/Commands/Make/HelperMakeCommand.php b/src/Commands/Make/HelperMakeCommand.php index efcd619a7..ec3856f71 100644 --- a/src/Commands/Make/HelperMakeCommand.php +++ b/src/Commands/Make/HelperMakeCommand.php @@ -21,7 +21,7 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('helper')->getPath() ?? config('modules.paths.app_folder') . 'Helpers'; + $filePath = GenerateConfigReader::read('helpers')->getPath() ?? config('modules.paths.app_folder') . 'Helpers'; return $path . $filePath . '/' . $this->getHelperName() . '.php'; } diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index 98df4dc0d..be867a673 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -21,7 +21,7 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('service')->getPath() ?? config('modules.paths.app_folder') . 'Services'; + $filePath = GenerateConfigReader::read('services')->getPath() ?? config('modules.paths.app_folder') . 'Services'; return $path . $filePath . '/' . $this->getServiceName() . '.php'; } diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index c7c9f5875..c2fdb4d21 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -56,6 +56,7 @@ public static function defaultCommands(): Collection Commands\Make\ComponentViewMakeCommand::class, Commands\Make\ControllerMakeCommand::class, Commands\Make\EventMakeCommand::class, + Commands\Make\EnumMakeCommand::class, Commands\Make\FactoryMakeCommand::class, Commands\Make\HelperMakeCommand::class, Commands\Make\JobMakeCommand::class, diff --git a/tests/Commands/ServiceMakeCommandTest.php b/tests/Commands/ServiceMakeCommandTest.php index 0c6bea64c..fac91cfca 100644 --- a/tests/Commands/ServiceMakeCommandTest.php +++ b/tests/Commands/ServiceMakeCommandTest.php @@ -69,18 +69,6 @@ public function test_it_generated_correct_file_with_content() $this->assertSame(0, $code); } - public function test_it_can_change_the_default_namespace() - { - $this->app['config']->set('modules.paths.generator.service.path', 'Services'); - - $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); - - $file = $this->finder->get($this->getModuleBasePath() . '/Services/MyService.php'); - - $this->assertMatchesSnapshot($file); - $this->assertSame(0, $code); - } - public function test_it_can_generate_a_service_in_sub_namespace_in_correct_folder() { $code = $this->artisan('module:make-service', ['name' => 'Api\\MyService', 'module' => 'Blog']); From 45dc0823fb80e4a2e88cadc91f30c22c6a034c3e Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 15:10:28 +0100 Subject: [PATCH 308/422] Updated CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2828f642..cbf2af888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +- [@dcblogdev](https://github.com/dcblogdev) added make-action command +- [@dcblogdev](https://github.com/dcblogdev) added make-enum command +- [@dcblogdev](https://github.com/dcblogdev) added make-helper command +- [@dcblogdev](https://github.com/dcblogdev) added missing return type for make-service command +- [@dcblogdev](https://github.com/dcblogdev) updated config + ## 11.0.7 - 2024-04-25 ## Changes From b5d9ce2e84992ee2ccb9ccca000b79a20e4d4c5f Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 15:34:50 +0100 Subject: [PATCH 309/422] added make:trait --- CHANGELOG.md | 1 + config/config.php | 1 + src/Commands/Make/ActionMakeCommand.php | 2 +- src/Commands/Make/EnumMakeCommand.php | 2 +- src/Commands/Make/HelperMakeCommand.php | 2 +- src/Commands/Make/ServiceMakeCommand.php | 2 +- src/Commands/Make/TraitMakeCommand.php | 76 +++++++++++++++++ src/Commands/stubs/trait.stub | 8 ++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/TraitMakeCommandTest.php | 81 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 8 ++ ...generated_correct_file_with_content__1.txt | 8 ++ 12 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 src/Commands/Make/TraitMakeCommand.php create mode 100644 src/Commands/stubs/trait.stub create mode 100644 tests/Commands/TraitMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf2af888..212fb9b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@dcblogdev](https://github.com/dcblogdev) added make-action command - [@dcblogdev](https://github.com/dcblogdev) added make-enum command - [@dcblogdev](https://github.com/dcblogdev) added make-helper command +- [@dcblogdev](https://github.com/dcblogdev) added make-trait command - [@dcblogdev](https://github.com/dcblogdev) added missing return type for make-service command - [@dcblogdev](https://github.com/dcblogdev) updated config diff --git a/config/config.php b/config/config.php index 543eeb9e3..9a8348511 100644 --- a/config/config.php +++ b/config/config.php @@ -131,6 +131,7 @@ 'rules' => ['path' => 'app/Rules', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'services' => ['path' => 'app/Services', 'generate' => false], + 'traits' => ['path' => 'app/Traits', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], diff --git a/src/Commands/Make/ActionMakeCommand.php b/src/Commands/Make/ActionMakeCommand.php index ad5ef3e7d..af042bc39 100644 --- a/src/Commands/Make/ActionMakeCommand.php +++ b/src/Commands/Make/ActionMakeCommand.php @@ -67,7 +67,7 @@ private function getClassNameWithoutNamespace(): array|string public function getDefaultNamespace(): string { - return config('modules.paths.generator.action.namespace', 'Actions'); + return config('modules.paths.generator.actions.namespace', 'Actions'); } protected function getStubName(): string diff --git a/src/Commands/Make/EnumMakeCommand.php b/src/Commands/Make/EnumMakeCommand.php index dbd1d4354..f3cc6d193 100644 --- a/src/Commands/Make/EnumMakeCommand.php +++ b/src/Commands/Make/EnumMakeCommand.php @@ -66,7 +66,7 @@ private function getClassNameWithoutNamespace(): array|string public function getDefaultNamespace(): string { - return config('modules.paths.generator.enum.namespace', 'Enums'); + return config('modules.paths.generator.enums.namespace', 'Enums'); } protected function getStubName(): string diff --git a/src/Commands/Make/HelperMakeCommand.php b/src/Commands/Make/HelperMakeCommand.php index ec3856f71..3f5dd8203 100644 --- a/src/Commands/Make/HelperMakeCommand.php +++ b/src/Commands/Make/HelperMakeCommand.php @@ -67,7 +67,7 @@ private function getClassNameWithoutNamespace(): array|string public function getDefaultNamespace(): string { - return config('modules.paths.generator.helper.namespace', 'Helpers'); + return config('modules.paths.generator.helpers.namespace', 'Helpers'); } protected function getStubName(): string diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index be867a673..a1a05cc60 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -67,7 +67,7 @@ private function getClassNameWithoutNamespace(): array|string public function getDefaultNamespace(): string { - return config('modules.paths.generator.service.namespace', 'Services'); + return config('modules.paths.generator.services.namespace', 'Services'); } protected function getStubName(): string diff --git a/src/Commands/Make/TraitMakeCommand.php b/src/Commands/Make/TraitMakeCommand.php new file mode 100644 index 000000000..71632e088 --- /dev/null +++ b/src/Commands/Make/TraitMakeCommand.php @@ -0,0 +1,76 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('traits')->getPath() ?? config('modules.paths.app_folder') . 'Traits'; + + return $path . $filePath . '/' . $this->getTraitName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the trait class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getTraitName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getTraitName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.traits.namespace', 'Traits'); + } + + protected function getStubName(): string + { + return '/trait.stub'; + } +} diff --git a/src/Commands/stubs/trait.stub b/src/Commands/stubs/trait.stub new file mode 100644 index 000000000..0a03ae4fb --- /dev/null +++ b/src/Commands/stubs/trait.stub @@ -0,0 +1,8 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_trait_class() + { + $code = $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Traits/MyTrait.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_trait_class_can_override_with_force_option() + { + $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog']); + $code = $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Traits/MyTrait.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Traits/MyTrait.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_trait_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-trait', ['name' => 'Api\\MyTrait', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Traits/Api/MyTrait.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-trait', ['name' => 'Api\\MyTrait', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Traits/Api/MyTrait.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..81f87fd99 --- /dev/null +++ b/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ + Date: Mon, 29 Apr 2024 15:49:05 +0100 Subject: [PATCH 310/422] added make:cast command --- CHANGELOG.md | 1 + config/config.php | 1 + src/Commands/Make/CastMakeCommand.php | 76 +++++++++++++++++ src/Commands/stubs/cast.stub | 29 +++++++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/CastMakeCommandTest.php | 81 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 29 +++++++ ...generated_correct_file_with_content__1.txt | 29 +++++++ 8 files changed, 247 insertions(+) create mode 100644 src/Commands/Make/CastMakeCommand.php create mode 100644 src/Commands/stubs/cast.stub create mode 100644 tests/Commands/CastMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/CastMakeCommandTest__test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 212fb9b5f..9e5e56322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next - [@dcblogdev](https://github.com/dcblogdev) added make-action command +- [@dcblogdev](https://github.com/dcblogdev) added make-cast command - [@dcblogdev](https://github.com/dcblogdev) added make-enum command - [@dcblogdev](https://github.com/dcblogdev) added make-helper command - [@dcblogdev](https://github.com/dcblogdev) added make-trait command diff --git a/config/config.php b/config/config.php index 9a8348511..da12d2edc 100644 --- a/config/config.php +++ b/config/config.php @@ -112,6 +112,7 @@ 'generator' => [ // app/ 'actions' => ['path' => 'app/Actions', 'generate' => false], + 'casts' => ['path' => 'app/Casts', 'generate' => false], 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], diff --git a/src/Commands/Make/CastMakeCommand.php b/src/Commands/Make/CastMakeCommand.php new file mode 100644 index 000000000..d20e5287e --- /dev/null +++ b/src/Commands/Make/CastMakeCommand.php @@ -0,0 +1,76 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('casts')->getPath() ?? config('modules.paths.app_folder') . 'Casts'; + + return $path . $filePath . '/' . $this->getCastName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the cast class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getCastName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getCastName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.casts.namespace', 'Casts'); + } + + protected function getStubName(): string + { + return '/cast.stub'; + } +} diff --git a/src/Commands/stubs/cast.stub b/src/Commands/stubs/cast.stub new file mode 100644 index 000000000..5940d82b1 --- /dev/null +++ b/src/Commands/stubs/cast.stub @@ -0,0 +1,29 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index c07021502..2b4e655f9 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -50,6 +50,7 @@ public static function defaultCommands(): Collection // Make Commands Commands\Make\ActionMakeCommand::class, + Commands\Make\CastMakeCommand::class, Commands\Make\ChannelMakeCommand::class, Commands\Make\CommandMakeCommand::class, Commands\Make\ComponentClassMakeCommand::class, diff --git a/tests/Commands/CastMakeCommandTest.php b/tests/Commands/CastMakeCommandTest.php new file mode 100644 index 000000000..e7eab44ad --- /dev/null +++ b/tests/Commands/CastMakeCommandTest.php @@ -0,0 +1,81 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_cast_class() + { + $code = $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Casts/MyCast.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_cast_class_can_override_with_force_option() + { + $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog']); + $code = $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Casts/MyCast.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Casts/MyCast.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_cast_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-cast', ['name' => 'Api\\MyCast', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Casts/Api/MyCast.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-cast', ['name' => 'Api\\MyCast', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Casts/Api/MyCast.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..424d24700 --- /dev/null +++ b/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,29 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..05d8e3e37 --- /dev/null +++ b/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,29 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} From 254941be3e1af3155c32115d56a6013015cdb157 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 16:17:11 +0100 Subject: [PATCH 311/422] added make:exception command --- config/config.php | 1 + src/Commands/Make/ExceptionMakeCommand.php | 86 ++++++++++++++ .../stubs/exception-render-report.stub | 26 +++++ src/Commands/stubs/exception-render.stub | 18 +++ src/Commands/stubs/exception-report.stub | 16 +++ src/Commands/stubs/exception.stub | 10 ++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/ExceptionMakeCommandTest.php | 105 ++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 10 ++ ...generated_correct_file_with_content__1.txt | 10 ++ 10 files changed, 283 insertions(+) create mode 100644 src/Commands/Make/ExceptionMakeCommand.php create mode 100644 src/Commands/stubs/exception-render-report.stub create mode 100644 src/Commands/stubs/exception-render.stub create mode 100644 src/Commands/stubs/exception-report.stub create mode 100644 src/Commands/stubs/exception.stub create mode 100644 tests/Commands/ExceptionMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/config/config.php b/config/config.php index da12d2edc..f4dfe034b 100644 --- a/config/config.php +++ b/config/config.php @@ -118,6 +118,7 @@ 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], 'enums' => ['path' => 'app/Enums', 'generate' => false], + 'exceptions' => ['path' => 'app/Exceptions', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], 'helpers' => ['path' => 'app/Helpers', 'generate' => false], 'listener' => ['path' => 'app/Listeners', 'generate' => false], diff --git a/src/Commands/Make/ExceptionMakeCommand.php b/src/Commands/Make/ExceptionMakeCommand.php new file mode 100644 index 000000000..479f24dbb --- /dev/null +++ b/src/Commands/Make/ExceptionMakeCommand.php @@ -0,0 +1,86 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('exceptions')->getPath() ?? config('modules.paths.app_folder') . 'Exceptions'; + + return $path . $filePath . '/' . $this->getExceptionName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the action class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['render', '', InputOption::VALUE_NONE, 'Create the exception with an empty render method', null], + ['report', '', InputOption::VALUE_NONE, 'Create the exception with an empty report method', null], + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getExceptionName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getExceptionName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.exceptions.namespace', 'Exceptions'); + } + + protected function getStubName(): string + { + if ($this->option('render')) { + return $this->option('report') + ? '/exception-render-report.stub' + : '/exception-render.stub'; + } + + return $this->option('report') + ? '/exception-report.stub' + : '/exception.stub'; + } +} diff --git a/src/Commands/stubs/exception-render-report.stub b/src/Commands/stubs/exception-render-report.stub new file mode 100644 index 000000000..29fe5dafa --- /dev/null +++ b/src/Commands/stubs/exception-render-report.stub @@ -0,0 +1,26 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_exception_class() + { + $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_exception_class_can_override_with_force_option() + { + $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog']); + $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_exception_class_can_use_render_option() + { + $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--render' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_exception_class_can_use_report_option() + { + $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--report' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_exception_class_can_use_report_and_render_option() + { + $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--report' => true, '--render' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Exceptions/MyException.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_exception_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-exception', ['name' => 'Api\\MyException', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Exceptions/Api/MyException.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-exception', ['name' => 'Api\\MyException', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Exceptions/Api/MyException.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..4e24c9dc5 --- /dev/null +++ b/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,10 @@ + Date: Mon, 29 Apr 2024 16:17:19 +0100 Subject: [PATCH 312/422] added make:exception command --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e5e56322..6c3e5482f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@dcblogdev](https://github.com/dcblogdev) added make-action command - [@dcblogdev](https://github.com/dcblogdev) added make-cast command - [@dcblogdev](https://github.com/dcblogdev) added make-enum command +- [@dcblogdev](https://github.com/dcblogdev) added make-exception command - [@dcblogdev](https://github.com/dcblogdev) added make-helper command - [@dcblogdev](https://github.com/dcblogdev) added make-trait command - [@dcblogdev](https://github.com/dcblogdev) added missing return type for make-service command From 0eb3def3e9c53e17dba96d252c62a54d1755d677 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 29 Apr 2024 16:27:16 +0100 Subject: [PATCH 313/422] added make:interface command --- CHANGELOG.md | 1 + config/config.php | 1 + src/Commands/Make/InterfaceMakeCommand.php | 76 +++++++++++++++++ src/Commands/stubs/interface.stub | 8 ++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/InterfaceMakeCommandTest.php | 81 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 8 ++ ...generated_correct_file_with_content__1.txt | 8 ++ 8 files changed, 184 insertions(+) create mode 100644 src/Commands/Make/InterfaceMakeCommand.php create mode 100644 src/Commands/stubs/interface.stub create mode 100644 tests/Commands/InterfaceMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c3e5482f..bc3e4fac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@dcblogdev](https://github.com/dcblogdev) added make-enum command - [@dcblogdev](https://github.com/dcblogdev) added make-exception command - [@dcblogdev](https://github.com/dcblogdev) added make-helper command +- [@dcblogdev](https://github.com/dcblogdev) added make-interface command - [@dcblogdev](https://github.com/dcblogdev) added make-trait command - [@dcblogdev](https://github.com/dcblogdev) added missing return type for make-service command - [@dcblogdev](https://github.com/dcblogdev) updated config diff --git a/config/config.php b/config/config.php index f4dfe034b..661f7d32f 100644 --- a/config/config.php +++ b/config/config.php @@ -121,6 +121,7 @@ 'exceptions' => ['path' => 'app/Exceptions', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], 'helpers' => ['path' => 'app/Helpers', 'generate' => false], + 'interfaces' => ['path' => 'app/Interfaces', 'generate' => false], 'listener' => ['path' => 'app/Listeners', 'generate' => false], 'model' => ['path' => 'app/Models', 'generate' => false], 'notifications' => ['path' => 'app/Notifications', 'generate' => false], diff --git a/src/Commands/Make/InterfaceMakeCommand.php b/src/Commands/Make/InterfaceMakeCommand.php new file mode 100644 index 000000000..743809620 --- /dev/null +++ b/src/Commands/Make/InterfaceMakeCommand.php @@ -0,0 +1,76 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('interfaces')->getPath() ?? config('modules.paths.app_folder') . 'Interfaces'; + + return $path . $filePath . '/' . $this->getInterfaceName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the action class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getInterfaceName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getInterfaceName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.interfaces.namespace', 'Interfaces'); + } + + protected function getStubName(): string + { + return '/interface.stub'; + } +} diff --git a/src/Commands/stubs/interface.stub b/src/Commands/stubs/interface.stub new file mode 100644 index 000000000..7c231ba4b --- /dev/null +++ b/src/Commands/stubs/interface.stub @@ -0,0 +1,8 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_interface_class() + { + $code = $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Interfaces/MyInterface.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_interface_class_can_override_with_force_option() + { + $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog']); + $code = $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Interfaces/MyInterface.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Interfaces/MyInterface.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_interface_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-interface', ['name' => 'Api\\MyInterface', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Interfaces/Api/MyInterface.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-interface', ['name' => 'Api\\MyInterface', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Interfaces/Api/MyInterface.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..ad8e53b02 --- /dev/null +++ b/tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ + Date: Mon, 29 Apr 2024 16:58:41 +0100 Subject: [PATCH 314/422] added make:interface command --- CHANGELOG.md | 1 + config/config.php | 3 +- src/Commands/Make/ScopeMakeCommand.php | 81 +++++++++++++++++++ src/Commands/stubs/scope.stub | 18 +++++ src/Providers/ConsoleServiceProvider.php | 1 + tests/Commands/ScopeMakeCommandTest.php | 81 +++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 18 +++++ ...generated_correct_file_with_content__1.txt | 18 +++++ 8 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 src/Commands/Make/ScopeMakeCommand.php create mode 100644 src/Commands/stubs/scope.stub create mode 100644 tests/Commands/ScopeMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3e4fac0..e3984a1af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All Notable changes to `laravel-modules` will be documented in this file. - [@dcblogdev](https://github.com/dcblogdev) added make-exception command - [@dcblogdev](https://github.com/dcblogdev) added make-helper command - [@dcblogdev](https://github.com/dcblogdev) added make-interface command +- [@dcblogdev](https://github.com/dcblogdev) added make-scope command - [@dcblogdev](https://github.com/dcblogdev) added make-trait command - [@dcblogdev](https://github.com/dcblogdev) added missing return type for make-service command - [@dcblogdev](https://github.com/dcblogdev) updated config diff --git a/config/config.php b/config/config.php index 661f7d32f..3d8c6d4a2 100644 --- a/config/config.php +++ b/config/config.php @@ -115,6 +115,7 @@ 'casts' => ['path' => 'app/Casts', 'generate' => false], 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], 'enums' => ['path' => 'app/Enums', 'generate' => false], @@ -132,8 +133,8 @@ 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'services' => ['path' => 'app/Services', 'generate' => false], + 'scopes' => ['path' => 'app/Models/Scopes', 'generate' => false], 'traits' => ['path' => 'app/Traits', 'generate' => false], // app/Http/ diff --git a/src/Commands/Make/ScopeMakeCommand.php b/src/Commands/Make/ScopeMakeCommand.php new file mode 100644 index 000000000..476b0f9f2 --- /dev/null +++ b/src/Commands/Make/ScopeMakeCommand.php @@ -0,0 +1,81 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('scopes')->getPath() ?? config('modules.paths.generator.model.path') . '/Scopes'; + + return $path . $filePath . '/' . $this->getScopeName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the scope class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getScopeName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getScopeName()); + } + + public function getDefaultNamespace(): string + { + $namespace = config('modules.paths.generator.model.path'); + + $parts = explode("/", $namespace); + $models = end($parts); + + return $models.'\Scopes'; + } + + protected function getStubName(): string + { + return '/scope.stub'; + } +} diff --git a/src/Commands/stubs/scope.stub b/src/Commands/stubs/scope.stub new file mode 100644 index 000000000..0543ad05b --- /dev/null +++ b/src/Commands/stubs/scope.stub @@ -0,0 +1,18 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_scope_class() + { + $code = $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Models/Scopes/MyScope.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_scope_class_can_override_with_force_option() + { + $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog']); + $code = $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Models/Scopes/MyScope.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Models/Scopes/MyScope.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_scope_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-scope', ['name' => 'Api\\MyScope', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Models/Scopes/Api/MyScope.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-scope', ['name' => 'Api\\MyScope', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Models/Scopes/Api/MyScope.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..9814c83b7 --- /dev/null +++ b/tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,18 @@ + Date: Mon, 29 Apr 2024 17:10:00 +0100 Subject: [PATCH 315/422] updated CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3984a1af..835f472d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.8 - 2024-04-29 + +- [@solomon-ochepa](https://github.com/solomon-ochepa) Remove custom namespaces from generator [factory and seeder] - [@dcblogdev](https://github.com/dcblogdev) added make-action command - [@dcblogdev](https://github.com/dcblogdev) added make-cast command - [@dcblogdev](https://github.com/dcblogdev) added make-enum command From f6a196ac6581f4bdc4297684f4be93c23cff66d5 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Apr 2024 00:25:17 +0100 Subject: [PATCH 316/422] added make-event-provider command, generate by default with new modules see https://github.com/nWidart/laravel-modules/issues/1824 for why. --- CHANGELOG.md | 2 + .../Make/EventProviderMakeCommand.php | 76 +++++++++++++++++++ src/Commands/stubs/event-provider.stub | 32 ++++++++ src/Commands/stubs/scaffold/provider.stub | 1 + src/Generators/ModuleGenerator.php | 19 +++++ src/Providers/ConsoleServiceProvider.php | 1 + .../Commands/EventProviderMakeCommandTest.php | 63 +++++++++++++++ tests/Commands/ModuleMakeCommandTest.php | 10 ++- ...generated_correct_file_with_content__1.txt | 32 ++++++++ ...nable_and_route_provider_is_disable__1.txt | 1 + ...enable_and_route_provider_is_enable__1.txt | 1 + ...generates_api_module_with_resources__1.txt | 1 + ..._module_namespace_using_studly_case__1.txt | 1 + ..._test_it_generates_module_resources__1.txt | 1 + ..._test_it_generates_module_resources__2.txt | 65 ++++------------ ..._test_it_generates_module_resources__3.txt | 45 +++++++++-- ..._test_it_generates_module_resources__4.txt | 64 ++++++++++------ ..._test_it_generates_module_resources__5.txt | 16 ++++ ...generates_web_module_with_resources__1.txt | 1 + ...es_when_adding_more_than_one_option__1.txt | 1 + ...it_can_change_the_default_namespace__1.txt | 1 + ...ange_the_default_namespace_specific__1.txt | 1 + ..._migration_resources_location_paths__1.txt | 1 + ...vice_provider_with_resource_loading__1.txt | 1 + 24 files changed, 355 insertions(+), 82 deletions(-) create mode 100644 src/Commands/Make/EventProviderMakeCommand.php create mode 100644 src/Commands/stubs/event-provider.stub create mode 100644 tests/Commands/EventProviderMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__5.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 835f472d1..59fa9ffd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +- [@dcblogdev](https://github.com/dcblogdev) added make-event-provider command, modules come with event as default now + ## 11.0.8 - 2024-04-29 - [@solomon-ochepa](https://github.com/solomon-ochepa) Remove custom namespaces from generator [factory and seeder] diff --git a/src/Commands/Make/EventProviderMakeCommand.php b/src/Commands/Make/EventProviderMakeCommand.php new file mode 100644 index 000000000..59cfb345e --- /dev/null +++ b/src/Commands/Make/EventProviderMakeCommand.php @@ -0,0 +1,76 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('provider')->getPath(); + + return $path . $filePath . '/' . $this->getEventServiceProviderName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getEventServiceProviderName(): array|string + { + return Str::studly('EventServiceProvider'); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getEventServiceProviderName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.provider.namespace') + ?? ltrim(config('modules.paths.generator.provider.path', 'Providers'), config('modules.paths.app_folder', '')); + } + + protected function getStubName(): string + { + return '/event-provider.stub'; + } +} diff --git a/src/Commands/stubs/event-provider.stub b/src/Commands/stubs/event-provider.stub new file mode 100644 index 000000000..4ed5a033a --- /dev/null +++ b/src/Commands/stubs/event-provider.stub @@ -0,0 +1,32 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + * + * @return void + */ + protected function configureEmailVerification(): void + { + + } +} diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 568b5f0fe..494f100a3 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -29,6 +29,7 @@ class $CLASS$ extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 9c9e02b05..fcb0dd605 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -473,6 +473,25 @@ public function generateResources() ); } + $eventGeneratorConfig = GenerateConfigReader::read('event-provider'); + if ( + (is_null($eventGeneratorConfig->getPath()) && $providerGenerator->generate()) + || (!is_null($eventGeneratorConfig->getPath()) && $eventGeneratorConfig->generate()) + ) { + $this->console->call('module:make-event-provider', [ + 'module' => $this->getName(), + ]); + } else { + if ($providerGenerator->generate()) { + // comment register EventServiceProvider + $this->filesystem->replaceInFile( + '$this->app->register(Event', + '// $this->app->register(Event', + $this->module->getModulePath($this->getName()) . DIRECTORY_SEPARATOR . $providerGenerator->getPath() . DIRECTORY_SEPARATOR . sprintf('%sServiceProvider.php', $this->getName()) + ); + } + } + $routeGeneratorConfig = GenerateConfigReader::read('route-provider'); if ( (is_null($routeGeneratorConfig->getPath()) && $providerGenerator->generate()) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 71c6721b5..1dbbeca04 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -57,6 +57,7 @@ public static function defaultCommands(): Collection Commands\Make\ComponentViewMakeCommand::class, Commands\Make\ControllerMakeCommand::class, Commands\Make\EventMakeCommand::class, + Commands\Make\EventProviderMakeCommand::class, Commands\Make\EnumMakeCommand::class, Commands\Make\ExceptionMakeCommand::class, Commands\Make\FactoryMakeCommand::class, diff --git a/tests/Commands/EventProviderMakeCommandTest.php b/tests/Commands/EventProviderMakeCommandTest.php new file mode 100644 index 000000000..066d9983a --- /dev/null +++ b/tests/Commands/EventProviderMakeCommandTest.php @@ -0,0 +1,63 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_event_provider_class() + { + $code = $this->artisan('module:make-event-provider', ['module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Providers/EventServiceProvider.php')); + $this->assertSame(1, $code); + } + + public function test_it_generates_a_new_event_provider_class_can_override_with_force_option() + { + $this->artisan('module:make-event-provider', ['module' => 'Blog']); + $code = $this->artisan('module:make-event-provider', ['module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Providers/EventServiceProvider.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-event-provider', ['module' => 'Blog', '--force' => true]); + + $file = $this->finder->get($this->modulePath . '/Providers/EventServiceProvider.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/ModuleMakeCommandTest.php b/tests/Commands/ModuleMakeCommandTest.php index ef0db2056..149046b69 100644 --- a/tests/Commands/ModuleMakeCommandTest.php +++ b/tests/Commands/ModuleMakeCommandTest.php @@ -122,15 +122,19 @@ public function test_it_generates_module_resources() $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath() . '/Providers/EventServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; + $this->assertTrue($this->finder->exists($path)); + $this->assertMatchesSnapshot($this->finder->get($path)); + + $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); diff --git a/tests/Commands/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..4130adfaa --- /dev/null +++ b/tests/Commands/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,32 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + * + * @return void + */ + protected function configureEmailVerification(): void + { + + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt index e8bc4882a..ea1386145 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); // $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt index 62afde970..713ae6f3a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt index 62afde970..713ae6f3a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt index 4538229a6..560ac5db1 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -29,6 +29,7 @@ class ModuleNameServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt index 62afde970..713ae6f3a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt index 6a89e8c29..4130adfaa 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt @@ -1,67 +1,32 @@ > */ - public function index() - { - return view('blog::index'); - } - - /** - * Show the form for creating a new resource. - */ - public function create() - { - return view('blog::create'); - } + protected $listen = []; /** - * Store a newly created resource in storage. + * Indicates if events should be discovered. + * + * @var bool */ - public function store(Request $request): RedirectResponse - { - // - } + protected static $shouldDiscoverEvents = true; /** - * Show the specified resource. + * Configure the proper event listeners for email verification. + * + * @return void */ - public function show($id) + protected function configureEmailVerification(): void { - return view('blog::show'); - } - /** - * Show the form for editing the specified resource. - */ - public function edit($id) - { - return view('blog::edit'); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id): RedirectResponse - { - // - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt index 97e7e2a48..dc17450cc 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt @@ -1,16 +1,49 @@ call([]); + parent::boot(); + } + + /** + * Define the routes for the application. + */ + public function map(): void + { + $this->mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt index dc17450cc..6a89e8c29 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -1,49 +1,67 @@ mapApiRoutes(); + return view('blog::create'); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request): RedirectResponse + { + // + } + + /** + * Show the specified resource. + */ + public function show($id) + { + return view('blog::show'); + } - $this->mapWebRoutes(); + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + return view('blog::edit'); } /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. + * Update the specified resource in storage. */ - protected function mapWebRoutes(): void + public function update(Request $request, $id): RedirectResponse { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + // } /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. + * Remove the specified resource from storage. */ - protected function mapApiRoutes(): void + public function destroy($id) { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + // } } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__5.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__5.txt new file mode 100644 index 000000000..97e7e2a48 --- /dev/null +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__5.txt @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt index 62afde970..713ae6f3a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 62afde970..713ae6f3a 100644 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 8c17ab8ee..bb17c3614 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 8c17ab8ee..bb17c3614 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt index f9ba976f1..26918b859 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt index 62afde970..713ae6f3a 100644 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -29,6 +29,7 @@ class BlogServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->register(EventServiceProvider::class); $this->app->register(RouteServiceProvider::class); } From f70f91e0d0d1f6bf16c62c9b17be3eaa3763f7cb Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Apr 2024 01:31:39 +0100 Subject: [PATCH 317/422] Updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59fa9ffd3..f86f71061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +## 11.0.9 - 2024-04-30 + - [@dcblogdev](https://github.com/dcblogdev) added make-event-provider command, modules come with event as default now ## 11.0.8 - 2024-04-29 From 4bac73d2ee050a2443a2e315bc34437618426f6d Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 30 Apr 2024 09:30:59 +0330 Subject: [PATCH 318/422] [feat] add direction option to command module:seed --- src/Commands/Database/SeedCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/Database/SeedCommand.php b/src/Commands/Database/SeedCommand.php index 29e9802c7..63a6ac8f0 100644 --- a/src/Commands/Database/SeedCommand.php +++ b/src/Commands/Database/SeedCommand.php @@ -226,6 +226,7 @@ protected function reportException(\Exception $e) protected function getOptions() { return [ + ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], ['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], From 150f15dc9992de7b9239823324b29512e48bbd88 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Apr 2024 07:54:49 +0100 Subject: [PATCH 319/422] Updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f86f71061..a80eb3bab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +- [@alissn](https://github.com/alissn) Added direction option to command module:seed + ## 11.0.9 - 2024-04-30 - [@dcblogdev](https://github.com/dcblogdev) added make-event-provider command, modules come with event as default now From b7c8feb993f1c77328dd08a3b246f8cbe2f92216 Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Apr 2024 08:05:22 +0100 Subject: [PATCH 320/422] Updated vite-module-loader.js --- scripts/vite-module-loader.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/vite-module-loader.js b/scripts/vite-module-loader.js index ab41f226d..ffaa429d0 100644 --- a/scripts/vite-module-loader.js +++ b/scripts/vite-module-loader.js @@ -23,15 +23,17 @@ async function collectModuleAssetsPaths(paths, modulesPath) { // Check if the module is enabled (status is true) if (moduleStatuses[moduleDir] === true) { const viteConfigPath = path.join(modulesPath, moduleDir, 'vite.config.js'); - const stat = await fs.stat(viteConfigPath); - if (stat.isFile()) { + try { + await fs.access(viteConfigPath); // Import the module-specific Vite configuration const moduleConfig = await import(viteConfigPath); if (moduleConfig.paths && Array.isArray(moduleConfig.paths)) { paths.push(...moduleConfig.paths); } + } catch (error) { + // vite.config.js does not exist, skip this module } } } From cb62db8fc87bcbcf63951b4fc89edf865489ce7e Mon Sep 17 00:00:00 2001 From: David Carr Date: Tue, 30 Apr 2024 08:10:13 +0100 Subject: [PATCH 321/422] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a80eb3bab..3b353cc28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +- [@dcblogdev](https://github.com/dcblogdev) Updated vite-module-loader.js to handle case when a modules does not have a vite.config.js file - [@alissn](https://github.com/alissn) Added direction option to command module:seed ## 11.0.9 - 2024-04-30 From 8e6fa52e2d1c1aba23d466758048c36ef854171c Mon Sep 17 00:00:00 2001 From: Abdulkarim Omer Date: Thu, 2 May 2024 16:18:24 +0300 Subject: [PATCH 322/422] Added invokable option into make-controller command --- src/Commands/Make/ControllerMakeCommand.php | 3 +++ src/Commands/stubs/controller.invokable.stub | 18 ++++++++++++++++++ tests/Commands/ControllerMakeCommandTest.php | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/Commands/stubs/controller.invokable.stub diff --git a/src/Commands/Make/ControllerMakeCommand.php b/src/Commands/Make/ControllerMakeCommand.php index a1436e400..4fbe00de1 100644 --- a/src/Commands/Make/ControllerMakeCommand.php +++ b/src/Commands/Make/ControllerMakeCommand.php @@ -90,6 +90,7 @@ protected function getOptions() return [ ['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain controller', null], ['api', null, InputOption::VALUE_NONE, 'Exclude the create and edit methods from the controller.'], + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate a single method, invokable controller class'], ]; } @@ -131,6 +132,8 @@ protected function getStubName() $stub = '/controller-plain.stub'; } elseif ($this->option('api') === true) { $stub = '/controller-api.stub'; + } elseif ($this->option('invokable') === true) { + $stub = '/controller.invokable.stub'; } else { $stub = '/controller.stub'; } diff --git a/src/Commands/stubs/controller.invokable.stub b/src/Commands/stubs/controller.invokable.stub new file mode 100644 index 000000000..783b8fd34 --- /dev/null +++ b/src/Commands/stubs/controller.invokable.stub @@ -0,0 +1,18 @@ +assertSame(0, $code); } + public function test_it_generates_an_invokable_controller() + { + $code = $this->artisan('module:make-controller', [ + 'controller' => 'MyController', + 'module' => 'Blog', + '--invokable' => true, + ]); + + $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + public function test_it_can_change_the_default_namespace() { $this->app['config']->set('modules.paths.generator.controller.path', 'Controllers'); From 31b54d028006a939dc23f5bb7444fd046ebc27b0 Mon Sep 17 00:00:00 2001 From: Omer Baflah Date: Sun, 5 May 2024 19:24:19 +0300 Subject: [PATCH 323/422] Update action stubs --- src/Commands/Make/ActionMakeCommand.php | 2 +- src/Commands/stubs/action-invoke.stub | 2 +- src/Commands/stubs/action.stub | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ActionMakeCommand.php b/src/Commands/Make/ActionMakeCommand.php index af042bc39..f9527bda6 100644 --- a/src/Commands/Make/ActionMakeCommand.php +++ b/src/Commands/Make/ActionMakeCommand.php @@ -50,7 +50,7 @@ protected function getArguments(): array protected function getOptions(): array { return [ - ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable class', null], + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable action class', null], ['force', 'f', InputOption::VALUE_NONE, 'su.'], ]; } diff --git a/src/Commands/stubs/action-invoke.stub b/src/Commands/stubs/action-invoke.stub index d91b100eb..d0a85c7af 100644 --- a/src/Commands/stubs/action-invoke.stub +++ b/src/Commands/stubs/action-invoke.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __invokable() + public function __invoke() { // } diff --git a/src/Commands/stubs/action.stub b/src/Commands/stubs/action.stub index b0b5785e0..c276ff626 100644 --- a/src/Commands/stubs/action.stub +++ b/src/Commands/stubs/action.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __construct() + public function handle() { // } From e85a2da7af1f9e847d324d50f08a54cc4eb5c24e Mon Sep 17 00:00:00 2001 From: Omer Baflah Date: Sun, 5 May 2024 19:59:14 +0300 Subject: [PATCH 324/422] Update service stubs --- src/Commands/Make/ServiceMakeCommand.php | 2 +- src/Commands/stubs/service-invoke.stub | 2 +- src/Commands/stubs/service.stub | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index a1a05cc60..72e3d8f63 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -50,7 +50,7 @@ protected function getArguments(): array protected function getOptions(): array { return [ - ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable class', null], + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable service class', null], ['force', 'f', InputOption::VALUE_NONE, 'su.'], ]; } diff --git a/src/Commands/stubs/service-invoke.stub b/src/Commands/stubs/service-invoke.stub index d91b100eb..d0a85c7af 100644 --- a/src/Commands/stubs/service-invoke.stub +++ b/src/Commands/stubs/service-invoke.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __invokable() + public function __invoke() { // } diff --git a/src/Commands/stubs/service.stub b/src/Commands/stubs/service.stub index b0b5785e0..c276ff626 100644 --- a/src/Commands/stubs/service.stub +++ b/src/Commands/stubs/service.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __construct() + public function handle() { // } From 5ab05d026e770cf0e19ed36f9796719968b6a0eb Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 5 May 2024 19:05:18 +0100 Subject: [PATCH 325/422] Update controller, service, helper, and action methods This commit replaces the __construct() method in generated controller, service, helper, and action classes with handle(). Also, it changes __invokable() in the helper-invoke.stub to __invoke(). This makes them more immediately useful for handling requests or other actions. --- src/Commands/stubs/helper-invoke.stub | 2 +- src/Commands/stubs/helper.stub | 2 +- ...amespace_with_correct_generated_file__1.txt | 2 +- ..._generated_correct_file_with_content__1.txt | 2 +- ...it_generates_an_invokable_controller__1.txt | 18 ++++++++++++++++++ ...amespace_with_correct_generated_file__1.txt | 2 +- ..._generated_correct_file_with_content__1.txt | 2 +- ...amespace_with_correct_generated_file__1.txt | 2 +- ..._generated_correct_file_with_content__1.txt | 2 +- 9 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt diff --git a/src/Commands/stubs/helper-invoke.stub b/src/Commands/stubs/helper-invoke.stub index d91b100eb..d0a85c7af 100644 --- a/src/Commands/stubs/helper-invoke.stub +++ b/src/Commands/stubs/helper-invoke.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __invokable() + public function __invoke() { // } diff --git a/src/Commands/stubs/helper.stub b/src/Commands/stubs/helper.stub index b0b5785e0..c276ff626 100644 --- a/src/Commands/stubs/helper.stub +++ b/src/Commands/stubs/helper.stub @@ -4,7 +4,7 @@ namespace $CLASS_NAMESPACE$; class $CLASS$ { - public function __construct() + public function handle() { // } diff --git a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt index 3c7f43726..b21fb56ef 100644 --- a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Actions\Api; class MyAction { - public function __construct() + public function handle() { // } diff --git a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index a72b1f1aa..a90bb9726 100644 --- a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Actions; class MyAction { - public function __construct() + public function handle() { // } diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt new file mode 100644 index 000000000..f56e98708 --- /dev/null +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt @@ -0,0 +1,18 @@ + Date: Sun, 5 May 2024 20:04:38 +0100 Subject: [PATCH 326/422] updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b353cc28..8dd232d89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All Notable changes to `laravel-modules` will be documented in this file. ## Next +- [@dcblogdev](https://github.com/dcblogdev) Update controller, service, helper, and action methods +- [@omerbaflah](https://github.com/omerbaflah) Update service stubs +- [@omerbaflah](https://github.com/omerbaflah) Update action stubs +- [@AbdulkarimOmer](https://github.com/AbdulkarimOmer) Added invokable option into make-controller command - [@dcblogdev](https://github.com/dcblogdev) Updated vite-module-loader.js to handle case when a modules does not have a vite.config.js file - [@alissn](https://github.com/alissn) Added direction option to command module:seed From 4522002fc94cf4a1555337394f7268dd14651806 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 5 May 2024 20:07:30 +0100 Subject: [PATCH 327/422] updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dd232d89..cad5e663a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All Notable changes to `laravel-modules` will be documented in this file. +## 11.0.10 - 2024-05-05 + ## Next - [@dcblogdev](https://github.com/dcblogdev) Update controller, service, helper, and action methods From f3a0a67add6513a9a6c191ae2a30eed1bda7c920 Mon Sep 17 00:00:00 2001 From: Omer Baflah Date: Thu, 9 May 2024 18:10:16 +0300 Subject: [PATCH 328/422] fixes invokable controller stub --- src/Commands/stubs/controller.invokable.stub | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Commands/stubs/controller.invokable.stub b/src/Commands/stubs/controller.invokable.stub index 783b8fd34..516117ac0 100644 --- a/src/Commands/stubs/controller.invokable.stub +++ b/src/Commands/stubs/controller.invokable.stub @@ -1,10 +1,9 @@ json([]); } } From a09301a14dce7692d3e1396f1c3d809126054231 Mon Sep 17 00:00:00 2001 From: Omer Baflah Date: Thu, 9 May 2024 18:35:42 +0300 Subject: [PATCH 329/422] Update invokable controller snapshot [skip ci]] --- ...andTest__test_it_generates_an_invokable_controller__1.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt index f56e98708..41a1b8ced 100644 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt +++ b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt @@ -1,10 +1,9 @@ json([]); } } From dcb4c48ec3713fed7fe04552b085a808fdf0ee7f Mon Sep 17 00:00:00 2001 From: "Solomon O. Ochepa" Date: Mon, 1 Apr 2024 17:41:56 +0100 Subject: [PATCH 330/422] Create make:class command Description: Create a new class Usage: module:make:class [options] [--] Arguments: name The name of the class module The targeted module Options: -t, --type[=TYPE] The type of class, e.g. class, service, repository, contract, etc. [default: "service"] -p, --plain Create the class without suffix (type) -i, --invokable Generate a single method, invokable class -f, --force Create the class even if the class already exists -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi|--no-ansi Force (or disable --no-ansi) ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Examples: ``` php artisan module:make:class Example Example ``` ``` php artisan module:make:class Example Example -t class ``` ``` php artisan module:make:class Example Example -t repository ``` ``` php artisan module:make:class Example Example -p -t repository ``` --- config/config.php | 78 +++++++++---------- src/Commands/Make/ClassCommand.php | 95 +++++++++++++++++++++++ src/Commands/stubs/app/Classes/Class.stub | 14 ++++ src/Providers/ConsoleServiceProvider.php | 1 + 4 files changed, 145 insertions(+), 43 deletions(-) create mode 100644 src/Commands/Make/ClassCommand.php create mode 100644 src/Commands/stubs/app/Classes/Class.stub diff --git a/config/config.php b/config/config.php index 57290c90f..34fed3bd7 100644 --- a/config/config.php +++ b/config/config.php @@ -71,37 +71,6 @@ */ 'modules' => base_path('Modules'), - /* - |-------------------------------------------------------------------------- - | Modules assets path - |-------------------------------------------------------------------------- - | - | Here you may update the modules' assets path. - | - */ - 'assets' => public_path('modules'), - - /* - |-------------------------------------------------------------------------- - | The migrations' path - |-------------------------------------------------------------------------- - | - | Where you run the 'module:publish-migration' command, where do you publish the - | the migration files? - | - */ - 'migration' => base_path('database/migrations'), - - /* - |-------------------------------------------------------------------------- - | The app path - |-------------------------------------------------------------------------- - | - | app folder name - | for example can change it to 'src' or 'App' - */ - 'app_folder' => 'app/', - /* |-------------------------------------------------------------------------- | Generator path @@ -111,31 +80,23 @@ */ 'generator' => [ // app/ - 'actions' => ['path' => 'app/Actions', 'generate' => false], - 'casts' => ['path' => 'app/Casts', 'generate' => false], 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], + 'class' => ['path' => 'app/Classes', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], - 'enums' => ['path' => 'app/Enums', 'generate' => false], - 'exceptions' => ['path' => 'app/Exceptions', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], - 'helpers' => ['path' => 'app/Helpers', 'generate' => false], - 'interfaces' => ['path' => 'app/Interfaces', 'generate' => false], 'listener' => ['path' => 'app/Listeners', 'generate' => false], 'model' => ['path' => 'app/Models', 'generate' => false], 'notifications' => ['path' => 'app/Notifications', 'generate' => false], 'observer' => ['path' => 'app/Observers', 'generate' => false], 'policies' => ['path' => 'app/Policies', 'generate' => false], 'provider' => ['path' => 'app/Providers', 'generate' => true], + 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], - 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'rules' => ['path' => 'app/Rules', 'generate' => false], - 'services' => ['path' => 'app/Services', 'generate' => false], - 'scopes' => ['path' => 'app/Models/Scopes', 'generate' => false], - 'traits' => ['path' => 'app/Traits', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], @@ -146,9 +107,9 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ - 'factory' => ['path' => 'database/factories', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], 'migration' => ['path' => 'database/migrations', 'generate' => true], - 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], @@ -165,6 +126,37 @@ 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], ], + + /* + |-------------------------------------------------------------------------- + | Modules assets path + |-------------------------------------------------------------------------- + | + | Here you may update the modules' assets path. + | + */ + 'assets' => public_path('modules'), + + /* + |-------------------------------------------------------------------------- + | The migrations' path + |-------------------------------------------------------------------------- + | + | Where you run the 'module:publish-migration' command, where do you publish the + | the migration files? + | + */ + 'migration' => base_path('database/migrations'), + + /* + |-------------------------------------------------------------------------- + | The app path + |-------------------------------------------------------------------------- + | + | app folder name + | for example can change it to 'src' or 'App' + */ + 'app_folder' => 'app/', ], /* diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php new file mode 100644 index 000000000..b90fbd521 --- /dev/null +++ b/src/Commands/Make/ClassCommand.php @@ -0,0 +1,95 @@ +laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub('/app/Classes/Class.stub', [ + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + ]))->render(); + } + + /** + * Get class namespace. + */ + public function getClassNamespace($module): string + { + return $this->getModuleNamespace($this->getDefaultNamespace()); + } + + public function getDestinationFilePath() + { + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $config = GenerateConfigReader::read('class'); + $path .= $this->typePath($config->getPath()) . '/' . $this->getFileName() . '.php'; + + return $path; + } + + protected function getFileName() + { + $file = Str::studly($this->argument('name')); + + if ($this->option('plain') === false and $this->option('type') !== 'class') { + $file .= $this->type(); + } + + return $file; + } + + /** + * Get the type of class e.g. Class, Services, Repository, etc. + */ + protected function type() + { + return Str::studly($this->option('type')); + } + + protected function typePath(string $path) + { + return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); + } + + /** + * Get class name. + */ + public function getClass(): string + { + return $this->getFileName(); + } + + public function getDefaultNamespace(): string + { + $type = $this->option('type'); + + return config("modules.paths.generator.{$type}.namespace", $this->getPathNamespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + } +} diff --git a/src/Commands/stubs/app/Classes/Class.stub b/src/Commands/stubs/app/Classes/Class.stub new file mode 100644 index 000000000..27bf6b064 --- /dev/null +++ b/src/Commands/stubs/app/Classes/Class.stub @@ -0,0 +1,14 @@ + Date: Wed, 17 Apr 2024 07:48:18 +0100 Subject: [PATCH 331/422] Updated .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 17aa6d40e..7a0015c03 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ coverage .phpunit.result.cache .idea .php-cs-fixer.cache +.DS_Store +src/.DS_Store +tests/.DS_Store From e8a736b6f3cf311b62a32a1df7505c1a8fcc2f44 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 11:33:16 +0100 Subject: [PATCH 332/422] [misc] restored config data position --- config/config.php | 62 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/config/config.php b/config/config.php index 34fed3bd7..37059bffa 100644 --- a/config/config.php +++ b/config/config.php @@ -71,6 +71,37 @@ */ 'modules' => base_path('Modules'), + /* + |-------------------------------------------------------------------------- + | Modules assets path + |-------------------------------------------------------------------------- + | + | Here you may update the modules' assets path. + | + */ + 'assets' => public_path('modules'), + + /* + |-------------------------------------------------------------------------- + | The migrations' path + |-------------------------------------------------------------------------- + | + | Where you run the 'module:publish-migration' command, where do you publish the + | the migration files? + | + */ + 'migration' => base_path('database/migrations'), + + /* + |-------------------------------------------------------------------------- + | The app path + |-------------------------------------------------------------------------- + | + | app folder name + | for example can change it to 'src' or 'App' + */ + 'app_folder' => 'app/', + /* |-------------------------------------------------------------------------- | Generator path @@ -126,37 +157,6 @@ 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], ], - - /* - |-------------------------------------------------------------------------- - | Modules assets path - |-------------------------------------------------------------------------- - | - | Here you may update the modules' assets path. - | - */ - 'assets' => public_path('modules'), - - /* - |-------------------------------------------------------------------------- - | The migrations' path - |-------------------------------------------------------------------------- - | - | Where you run the 'module:publish-migration' command, where do you publish the - | the migration files? - | - */ - 'migration' => base_path('database/migrations'), - - /* - |-------------------------------------------------------------------------- - | The app path - |-------------------------------------------------------------------------- - | - | app folder name - | for example can change it to 'src' or 'App' - */ - 'app_folder' => 'app/', ], /* From 945fd2e6512a23666617cf675410a029362a3646 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 13:18:21 +0100 Subject: [PATCH 333/422] [optimize] Check $this->argumentName is not null before adding extra path --- src/Commands/Make/GeneratorCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index fdd7b41e3..0cf07809b 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -50,7 +50,6 @@ public function handle(): int $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); }); - } catch (FileAlreadyExistException $e) { $this->components->error("File : {$path} already exists."); From bc97a64f3f117a9df1c5ecc3e5f3a7c8bb93792b Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Apr 2024 13:27:58 +0100 Subject: [PATCH 334/422] [complete] Update class --- src/Commands/Make/ClassCommand.php | 31 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index b90fbd521..39ab61982 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -15,7 +15,7 @@ class ClassCommand extends GeneratorCommand * The name and signature of the console command. */ protected $signature = 'module:make-class - {--t|type=service : The type of class, e.g. class, service, repository, contract, etc.} + {--t|type=class : The type of class, e.g. class, service, repository, contract, etc.} {--p|plain : Create the class without suffix (type)} {--i|invokable : Generate a single method, invokable class} {--f|force : Create the class even if the class already exists} @@ -37,14 +37,6 @@ public function getTemplateContents() ]))->render(); } - /** - * Get class namespace. - */ - public function getClassNamespace($module): string - { - return $this->getModuleNamespace($this->getDefaultNamespace()); - } - public function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); @@ -90,6 +82,25 @@ public function getDefaultNamespace(): string { $type = $this->option('type'); - return config("modules.paths.generator.{$type}.namespace", $this->getPathNamespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + } + + /** + * Get a well-formatted StudlyCase representation of path components. + */ + public function studly_path(string $path, $directory_separator = '/'): string + { + return collect(explode($directory_separator, Str::of($path) + ->replace("{$directory_separator}{$directory_separator}", $directory_separator)->trim($directory_separator))) + ->map(fn ($path) => Str::studly($path)) + ->implode($directory_separator); + } + + /** + * Get a well-formatted namespace from a given path. + */ + public function path_namespace(string $path): string + { + return Str::of($this->studly_path($path))->replace('/', '\\')->trim('\\'); } } From 910cc159ae1161de0bcdfb4fc094433cf1134979 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 05:23:49 +0100 Subject: [PATCH 335/422] [fix] Add $argumentName = "name" --- src/Commands/Make/ClassCommand.php | 8 +++++--- src/Commands/Make/GeneratorCommand.php | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index 39ab61982..fb31d0f51 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -27,6 +27,8 @@ class ClassCommand extends GeneratorCommand */ protected $description = 'Create a new class'; + protected $argumentName = "name"; + public function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); @@ -41,7 +43,7 @@ public function getDestinationFilePath() { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $config = GenerateConfigReader::read('class'); - $path .= $this->typePath($config->getPath()) . '/' . $this->getFileName() . '.php'; + $path .= $this->type_path($config->getPath()) . '/' . $this->getFileName() . '.php'; return $path; } @@ -65,7 +67,7 @@ protected function type() return Str::studly($this->option('type')); } - protected function typePath(string $path) + protected function type_path(string $path) { return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); } @@ -82,7 +84,7 @@ public function getDefaultNamespace(): string { $type = $this->option('type'); - return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->typePath('app/Classes')))); + return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->type_path('app/Classes')))); } /** diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index 0cf07809b..fdd7b41e3 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -50,6 +50,7 @@ public function handle(): int $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); }); + } catch (FileAlreadyExistException $e) { $this->components->error("File : {$path} already exists."); From 4f701a7b7eb311731d500ea1f835b70d629d2e17 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Fri, 26 Apr 2024 05:41:27 +0100 Subject: [PATCH 336/422] Revert changes to config --- config/config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index 37059bffa..60f2ba15f 100644 --- a/config/config.php +++ b/config/config.php @@ -114,7 +114,6 @@ 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'class' => ['path' => 'app/Classes', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], @@ -128,6 +127,7 @@ 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], 'rules' => ['path' => 'app/Rules', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], @@ -138,24 +138,24 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ - 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], 'migration' => ['path' => 'database/migrations', 'generate' => true], 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], // resource/ 'assets' => ['path' => 'resources/assets', 'generate' => true], - 'component-view' => ['path' => 'resources/views/components', 'generate' => false], 'views' => ['path' => 'resources/views', 'generate' => true], + 'component-view' => ['path' => 'resources/views/components', 'generate' => false], // routes/ 'routes' => ['path' => 'routes', 'generate' => true], // tests/ - 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], ], ], From 2ce3880a04b10512ea7890f18c5e81b7df54755f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 06:28:55 +0100 Subject: [PATCH 337/422] Create clean_path() method - PathNamespace --- src/Traits/PathNamespace.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php index ae6c59222..2f4e16150 100644 --- a/src/Traits/PathNamespace.php +++ b/src/Traits/PathNamespace.php @@ -9,20 +9,17 @@ trait PathNamespace /** * Get a well-formatted StudlyCase representation of path components. */ - public function studly_path(string $path, $directory_separator = '/'): string + public function studly_path(string $path, $ds = '/'): string { - return collect(explode($directory_separator, Str::of($path) - ->replace("{$directory_separator}{$directory_separator}", $directory_separator)->trim($directory_separator))) - ->map(fn ($path) => Str::studly($path)) - ->implode($directory_separator); + return collect(explode($ds, $this->clean_path($path, $ds)))->map(fn ($path) => Str::studly($path))->implode($ds); } /** * Get a well-formatted StudlyCase namespace. */ - public function studly_namespace(string $namespace, $directory_separator = '\\'): string + public function studly_namespace(string $namespace, $ds = '\\'): string { - return $this->studly_path($namespace, $directory_separator); + return $this->studly_path($namespace, $ds); } /** @@ -36,11 +33,19 @@ public function path_namespace(string $path): string /** * Get a well-formatted StudlyCase namespace for a module, with an optional additional path. */ - public function module_namespace(string $module, string $path = null): string + public function module_namespace(string $module, ?string $path = null): string { $module_namespace = config('modules.namespace', $this->path_namespace(config('modules.paths.modules'))) . '\\' . ($module); $module_namespace .= strlen($path) ? '\\' . $this->path_namespace($path) : ''; return $this->studly_namespace($module_namespace); } + + /** + * Clean path + */ + public function clean_path(string $path, $ds = '/'): string + { + return Str::of($path)->explode($ds)->reject(empty($path))->implode($ds); + } } From 5f276ee3ff727fdea93311a9e252ac7f085d2ef2 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 06:52:10 +0100 Subject: [PATCH 338/422] Create app_path() method --- src/Traits/PathNamespace.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php index 2f4e16150..e70def015 100644 --- a/src/Traits/PathNamespace.php +++ b/src/Traits/PathNamespace.php @@ -48,4 +48,16 @@ public function clean_path(string $path, $ds = '/'): string { return Str::of($path)->explode($ds)->reject(empty($path))->implode($ds); } + + /** + * Get the app path basename. + */ + public function app_path(?string $path = null): string + { + $config_path = config('modules.paths.app_folder'); + $app_path = strlen($config_path) ? trim($config_path, '/') : 'app'; + $app_path .= ($path) ? '/' . $path : ''; + + return $this->clean_path($app_path); + } } From dafd7779b87bb609faa5932424c252647b1eebaa Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 07:17:27 +0100 Subject: [PATCH 339/422] Apply app_path() method to ClassCommand class --- src/Commands/Make/ClassCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index fb31d0f51..7d657857c 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -27,7 +27,7 @@ class ClassCommand extends GeneratorCommand */ protected $description = 'Create a new class'; - protected $argumentName = "name"; + protected $argumentName = 'name'; public function getTemplateContents() { @@ -41,9 +41,9 @@ public function getTemplateContents() public function getDestinationFilePath() { + $app_path = GenerateConfigReader::read('class')->getPath() ?? $this->app_path('Classes'); $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $config = GenerateConfigReader::read('class'); - $path .= $this->type_path($config->getPath()) . '/' . $this->getFileName() . '.php'; + $path .= $this->type_path($app_path) . '/' . $this->getFileName(); return $path; } @@ -56,7 +56,7 @@ protected function getFileName() $file .= $this->type(); } - return $file; + return $file . '.php'; } /** @@ -84,7 +84,7 @@ public function getDefaultNamespace(): string { $type = $this->option('type'); - return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->type_path('app/Classes')))); + return config("modules.paths.generator.{$type}.namespace") ?? $this->path_namespace(config("modules.paths.generator.{$type}.path") ?? $this->type_path($this->app_path('Classes'))); } /** From 3f1fcf8929ae5f7322f5b3d0970e0bbc552a109f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 07:41:11 +0100 Subject: [PATCH 340/422] Remove studly_path() and path_namespace() --- src/Commands/Make/ClassCommand.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index 7d657857c..9214a7cf0 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -77,7 +77,7 @@ protected function type_path(string $path) */ public function getClass(): string { - return $this->getFileName(); + return Str::of($this->getFileName())->remove('.php')->studly(); } public function getDefaultNamespace(): string @@ -86,23 +86,4 @@ public function getDefaultNamespace(): string return config("modules.paths.generator.{$type}.namespace") ?? $this->path_namespace(config("modules.paths.generator.{$type}.path") ?? $this->type_path($this->app_path('Classes'))); } - - /** - * Get a well-formatted StudlyCase representation of path components. - */ - public function studly_path(string $path, $directory_separator = '/'): string - { - return collect(explode($directory_separator, Str::of($path) - ->replace("{$directory_separator}{$directory_separator}", $directory_separator)->trim($directory_separator))) - ->map(fn ($path) => Str::studly($path)) - ->implode($directory_separator); - } - - /** - * Get a well-formatted namespace from a given path. - */ - public function path_namespace(string $path): string - { - return Str::of($this->studly_path($path))->replace('/', '\\')->trim('\\'); - } } From f0ac74aea8ede8b97fdeb6af1bc15ba507c212e8 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 12:56:40 +0100 Subject: [PATCH 341/422] Update ClassCommand --- src/Commands/Make/ClassCommand.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index 9214a7cf0..f32513d08 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -16,7 +16,7 @@ class ClassCommand extends GeneratorCommand */ protected $signature = 'module:make-class {--t|type=class : The type of class, e.g. class, service, repository, contract, etc.} - {--p|plain : Create the class without suffix (type)} + {--p|plain : Create the class without the type suffix} {--i|invokable : Generate a single method, invokable class} {--f|force : Create the class even if the class already exists} {name : The name of the class} @@ -39,37 +39,37 @@ public function getTemplateContents() ]))->render(); } - public function getDestinationFilePath() + public function getDestinationFilePath(): string { $app_path = GenerateConfigReader::read('class')->getPath() ?? $this->app_path('Classes'); $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $path .= $this->type_path($app_path) . '/' . $this->getFileName(); + $path .= $this->type_path($app_path) . '/' . $this->getFileName() . '.php'; return $path; } - protected function getFileName() + protected function getFileName(): string { $file = Str::studly($this->argument('name')); - if ($this->option('plain') === false and $this->option('type') !== 'class') { - $file .= $this->type(); + if ($this->option('plain') === false and $this->type() != 'class') { + $file .= Str::of($this->type())->studly(); } - return $file . '.php'; + return $file; } /** - * Get the type of class e.g. Class, Services, Repository, etc. + * Get the type of class e.g. class, service, repository, etc. */ - protected function type() + protected function type(): string { - return Str::studly($this->option('type')); + return Str::of($this->option('type'))->remove('=')->singular(); } - protected function type_path(string $path) + protected function type_path(string $path): string { - return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); + return ($this->type() == 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::of($this->type())->plural()->studly()); } /** @@ -77,12 +77,12 @@ protected function type_path(string $path) */ public function getClass(): string { - return Str::of($this->getFileName())->remove('.php')->studly(); + return Str::of($this->getFileName())->basename()->studly(); } public function getDefaultNamespace(): string { - $type = $this->option('type'); + $type = $this->type(); return config("modules.paths.generator.{$type}.namespace") ?? $this->path_namespace(config("modules.paths.generator.{$type}.path") ?? $this->type_path($this->app_path('Classes'))); } From 190cf20d11c58a4e988bf2ff329b97d328f9f41e Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 13:39:10 +0100 Subject: [PATCH 342/422] Update PathNamespace --- src/Traits/PathNamespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php index e70def015..d0680bcd2 100644 --- a/src/Traits/PathNamespace.php +++ b/src/Traits/PathNamespace.php @@ -56,7 +56,7 @@ public function app_path(?string $path = null): string { $config_path = config('modules.paths.app_folder'); $app_path = strlen($config_path) ? trim($config_path, '/') : 'app'; - $app_path .= ($path) ? '/' . $path : ''; + $app_path .= strlen($path) ? '/' . $path : ''; return $this->clean_path($app_path); } From bb7af6c449aab9180376940306f67dd95f470c2d Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 14:23:45 +0100 Subject: [PATCH 343/422] Create path() method in GeneratorCommand Get the module root path + extra $path --- src/Commands/Make/GeneratorCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index fdd7b41e3..12ec7386b 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -50,7 +50,6 @@ public function handle(): int $overwriteFile = $this->hasOption('force') ? $this->option('force') : false; (new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate(); }); - } catch (FileAlreadyExistException $e) { $this->components->error("File : {$path} already exists."); @@ -93,4 +92,12 @@ public function getClassNamespace($module) return $this->module_namespace($module->getStudlyName(), $this->getDefaultNamespace() . ($path_namespace ? '\\' . $path_namespace : '')); } + + /** + * Get the module root path + extra $path + */ + public function path(?string $path = null): string + { + return $this->clean_path($this->laravel['modules']->getModulePath($this->getModuleName()) . (strlen($path) ? '/' . $path : '')); + } } From 95347cfabdbad77bf403d1476a3d9037fbee3c28 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 14:25:15 +0100 Subject: [PATCH 344/422] Improve getDestinationFilePath() using the newly path() method --- src/Commands/Make/ClassCommand.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index f32513d08..c0b647422 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -42,10 +42,8 @@ public function getTemplateContents() public function getDestinationFilePath(): string { $app_path = GenerateConfigReader::read('class')->getPath() ?? $this->app_path('Classes'); - $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $path .= $this->type_path($app_path) . '/' . $this->getFileName() . '.php'; - return $path; + return $this->path($this->type_path($app_path) . '/' . $this->getFileName() . '.php'); } protected function getFileName(): string From fdcbb4249e7a16280b36d4829115c08c218a6f1f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 14:37:51 +0100 Subject: [PATCH 345/422] Merge master config --- .gitignore | 4 +--- config/config.php | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 7a0015c03..d9892de33 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,4 @@ coverage .phpunit.result.cache .idea .php-cs-fixer.cache -.DS_Store -src/.DS_Store -tests/.DS_Store +**/.DS_Store diff --git a/config/config.php b/config/config.php index 60f2ba15f..44c699e7c 100644 --- a/config/config.php +++ b/config/config.php @@ -111,23 +111,32 @@ */ 'generator' => [ // app/ + 'actions' => ['path' => 'app/Actions', 'generate' => false], + 'casts' => ['path' => 'app/Casts', 'generate' => false], 'channels' => ['path' => 'app/Broadcasting', 'generate' => false], 'class' => ['path' => 'app/Classes', 'generate' => false], 'command' => ['path' => 'app/Console', 'generate' => false], + 'component-class' => ['path' => 'app/View/Components', 'generate' => false], 'emails' => ['path' => 'app/Emails', 'generate' => false], 'event' => ['path' => 'app/Events', 'generate' => false], + 'enums' => ['path' => 'app/Enums', 'generate' => false], + 'exceptions' => ['path' => 'app/Exceptions', 'generate' => false], 'jobs' => ['path' => 'app/Jobs', 'generate' => false], + 'helpers' => ['path' => 'app/Helpers', 'generate' => false], + 'interfaces' => ['path' => 'app/Interfaces', 'generate' => false], 'listener' => ['path' => 'app/Listeners', 'generate' => false], 'model' => ['path' => 'app/Models', 'generate' => false], 'notifications' => ['path' => 'app/Notifications', 'generate' => false], 'observer' => ['path' => 'app/Observers', 'generate' => false], 'policies' => ['path' => 'app/Policies', 'generate' => false], 'provider' => ['path' => 'app/Providers', 'generate' => true], - 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'repository' => ['path' => 'app/Repositories', 'generate' => false], 'resource' => ['path' => 'app/Transformers', 'generate' => false], + 'route-provider' => ['path' => 'app/Providers', 'generate' => true], 'rules' => ['path' => 'app/Rules', 'generate' => false], - 'component-class' => ['path' => 'app/View/Components', 'generate' => false], + 'services' => ['path' => 'app/Services', 'generate' => false], + 'scopes' => ['path' => 'app/Models/Scopes', 'generate' => false], + 'traits' => ['path' => 'app/Traits', 'generate' => false], // app/Http/ 'controller' => ['path' => 'app/Http/Controllers', 'generate' => true], @@ -138,24 +147,24 @@ 'config' => ['path' => 'config', 'generate' => true], // database/ + 'factory' => ['path' => 'database/factories', 'generate' => true], 'migration' => ['path' => 'database/migrations', 'generate' => true], - 'seeder' => ['path' => 'database/seeders', 'namespace' => 'Database\Seeders', 'generate' => true], - 'factory' => ['path' => 'database/factories', 'namespace' => 'Database\Factories', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], // lang/ 'lang' => ['path' => 'lang', 'generate' => false], // resource/ 'assets' => ['path' => 'resources/assets', 'generate' => true], - 'views' => ['path' => 'resources/views', 'generate' => true], 'component-view' => ['path' => 'resources/views/components', 'generate' => false], + 'views' => ['path' => 'resources/views', 'generate' => true], // routes/ 'routes' => ['path' => 'routes', 'generate' => true], // tests/ - 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], 'test-feature' => ['path' => 'tests/Feature', 'generate' => true], + 'test-unit' => ['path' => 'tests/Unit', 'generate' => true], ], ], From 871696fa4d024479240e8b6eeaa2547fd37001ae Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 16:43:43 +0100 Subject: [PATCH 346/422] Fix issue with namespace including class name. --- src/Commands/Make/ClassCommand.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index c0b647422..0deffeeb3 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -35,7 +35,7 @@ public function getTemplateContents() return (new Stub('/app/Classes/Class.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->type_class(), ]))->render(); } @@ -70,10 +70,7 @@ protected function type_path(string $path): string return ($this->type() == 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::of($this->type())->plural()->studly()); } - /** - * Get class name. - */ - public function getClass(): string + public function type_class(): string { return Str::of($this->getFileName())->basename()->studly(); } From 740caa356154c550852ffb0e4eb627ae22d47a86 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sat, 4 May 2024 17:56:37 +0100 Subject: [PATCH 347/422] Avoid double suffix --- src/Commands/Make/ClassCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index 0deffeeb3..995145697 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -50,7 +50,9 @@ protected function getFileName(): string { $file = Str::studly($this->argument('name')); - if ($this->option('plain') === false and $this->type() != 'class') { + if ($this->option('plain') == false and $this->type() != 'class') { + $names = [Str::plural($this->type()), Str::singular($this->type())]; + $file = Str::of($file)->remove($names, false); $file .= Str::of($this->type())->studly(); } From 2eb2353510fc2a1fd2f21c02d468e023f955de9d Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 6 May 2024 01:30:52 +0100 Subject: [PATCH 348/422] Impliment invokable feature and move stubs to base path. --- src/Commands/Make/ClassCommand.php | 7 ++++++- src/Commands/stubs/class-invoke.stub | 11 +++++++++++ .../stubs/{app/Classes/Class.stub => class.stub} | 0 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/Commands/stubs/class-invoke.stub rename src/Commands/stubs/{app/Classes/Class.stub => class.stub} (100%) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index 995145697..dec729edf 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -33,12 +33,17 @@ public function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); - return (new Stub('/app/Classes/Class.stub', [ + return (new Stub($this->stub(), [ 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->type_class(), ]))->render(); } + public function stub() + { + return $this->option('invokable') ? '/class-invoke.stub' : '/class.stub'; + } + public function getDestinationFilePath(): string { $app_path = GenerateConfigReader::read('class')->getPath() ?? $this->app_path('Classes'); diff --git a/src/Commands/stubs/class-invoke.stub b/src/Commands/stubs/class-invoke.stub new file mode 100644 index 000000000..25117cb86 --- /dev/null +++ b/src/Commands/stubs/class-invoke.stub @@ -0,0 +1,11 @@ + Date: Mon, 6 May 2024 02:07:43 +0100 Subject: [PATCH 349/422] Optimize calling of module instance --- src/Commands/Make/ClassCommand.php | 4 +--- src/Commands/Make/GeneratorCommand.php | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php index dec729edf..73ddac328 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassCommand.php @@ -31,10 +31,8 @@ class ClassCommand extends GeneratorCommand public function getTemplateContents() { - $module = $this->laravel['modules']->findOrFail($this->getModuleName()); - return (new Stub($this->stub(), [ - 'NAMESPACE' => $this->getClassNamespace($module), + 'NAMESPACE' => $this->getClassNamespace($this->module()), 'CLASS' => $this->type_class(), ]))->render(); } diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index 12ec7386b..3f759f884 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Nwidart\Modules\Exceptions\FileAlreadyExistException; use Nwidart\Modules\Generators\FileGenerator; +use Nwidart\Modules\Module; use Nwidart\Modules\Traits\PathNamespace; abstract class GeneratorCommand extends Command @@ -100,4 +101,9 @@ public function path(?string $path = null): string { return $this->clean_path($this->laravel['modules']->getModulePath($this->getModuleName()) . (strlen($path) ? '/' . $path : '')); } + + public function module(?string $name = null): Module + { + return $this->laravel['modules']->findOrFail($name ?? $this->getModuleName()); + } } From a6ddf1594858e26d2d87d3824b6e1d689871f698 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 12 May 2024 12:00:08 +0100 Subject: [PATCH 350/422] updated invokable to invoke --- src/Commands/stubs/class-invoke.stub | 2 +- src/Commands/stubs/class.stub | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Commands/stubs/class-invoke.stub b/src/Commands/stubs/class-invoke.stub index 25117cb86..d1981df7c 100644 --- a/src/Commands/stubs/class-invoke.stub +++ b/src/Commands/stubs/class-invoke.stub @@ -4,7 +4,7 @@ namespace $NAMESPACE$; class $CLASS$ { - public function __invokable() + public function __invoke() { // } diff --git a/src/Commands/stubs/class.stub b/src/Commands/stubs/class.stub index 27bf6b064..eb9550a49 100644 --- a/src/Commands/stubs/class.stub +++ b/src/Commands/stubs/class.stub @@ -4,9 +4,6 @@ namespace $NAMESPACE$; class $CLASS$ { - /** - * Create a new class instance. - */ public function __construct() { // From f2a08f7ae8b9a3d2fc3e102cbc7dd701f01924bc Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 12 May 2024 12:00:36 +0100 Subject: [PATCH 351/422] added tests for make:class --- tests/Commands/ClassMakeCommandTest.php | 105 ++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 11 ++ ...generated_correct_file_with_content__1.txt | 11 ++ 3 files changed, 127 insertions(+) create mode 100644 tests/Commands/ClassMakeCommandTest.php create mode 100644 tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/tests/Commands/ClassMakeCommandTest.php b/tests/Commands/ClassMakeCommandTest.php new file mode 100644 index 000000000..4c71fdd2a --- /dev/null +++ b/tests/Commands/ClassMakeCommandTest.php @@ -0,0 +1,105 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_class() + { + $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Classes/Demo.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_class_can_override_with_force_option() + { + $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog']); + $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Classes/Demo.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_class_can_use_invoke_option() + { + $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--invokable' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Classes/Demo.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_class_can_use_suffix_option() + { + $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--suffix' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Classes/DemoClass.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_class_use_type_option() + { + $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--type' => 'contract']); + + $this->assertTrue(is_file($this->modulePath . '/Contracts/Demo.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Classes/Demo.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_class_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-class', ['name' => 'Api\\Demo', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Classes/Api/Demo.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-class', ['name' => 'Api\\Demo', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Classes/Api/Demo.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} diff --git a/tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..95a14846e --- /dev/null +++ b/tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,11 @@ + Date: Sun, 12 May 2024 12:01:11 +0100 Subject: [PATCH 352/422] added make:class command to ConsoleServiceProvider --- src/Providers/ConsoleServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 702edb813..9cf84f6f1 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -52,7 +52,7 @@ public static function defaultCommands(): Collection Commands\Make\ActionMakeCommand::class, Commands\Make\CastMakeCommand::class, Commands\Make\ChannelMakeCommand::class, - Commands\Make\ClassCommand::class, + Commands\Make\ClassMakeCommand::class, Commands\Make\CommandMakeCommand::class, Commands\Make\ComponentClassMakeCommand::class, Commands\Make\ComponentViewMakeCommand::class, From 50291d1a623fffe3914e7f76656801ca1b98ad3a Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 12 May 2024 12:03:13 +0100 Subject: [PATCH 353/422] updated make:class to use suffix instead of plain --- ...{ClassCommand.php => ClassMakeCommand.php} | 26 ++++++++++--------- src/Commands/Make/GeneratorCommand.php | 8 ------ 2 files changed, 14 insertions(+), 20 deletions(-) rename src/Commands/Make/{ClassCommand.php => ClassMakeCommand.php} (69%) diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassMakeCommand.php similarity index 69% rename from src/Commands/Make/ClassCommand.php rename to src/Commands/Make/ClassMakeCommand.php index 73ddac328..1dd42b5f0 100644 --- a/src/Commands/Make/ClassCommand.php +++ b/src/Commands/Make/ClassMakeCommand.php @@ -7,7 +7,7 @@ use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; -class ClassCommand extends GeneratorCommand +class ClassMakeCommand extends GeneratorCommand { use ModuleCommandTrait; @@ -16,7 +16,7 @@ class ClassCommand extends GeneratorCommand */ protected $signature = 'module:make-class {--t|type=class : The type of class, e.g. class, service, repository, contract, etc.} - {--p|plain : Create the class without the type suffix} + {--s|suffix : Create the class without the type suffix} {--i|invokable : Generate a single method, invokable class} {--f|force : Create the class even if the class already exists} {name : The name of the class} @@ -29,31 +29,33 @@ class ClassCommand extends GeneratorCommand protected $argumentName = 'name'; - public function getTemplateContents() + public function getTemplateContents(): string { return (new Stub($this->stub(), [ 'NAMESPACE' => $this->getClassNamespace($this->module()), - 'CLASS' => $this->type_class(), + 'CLASS' => $this->typeClass(), ]))->render(); } - public function stub() + public function stub(): string { return $this->option('invokable') ? '/class-invoke.stub' : '/class.stub'; } public function getDestinationFilePath(): string { - $app_path = GenerateConfigReader::read('class')->getPath() ?? $this->app_path('Classes'); + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - return $this->path($this->type_path($app_path) . '/' . $this->getFileName() . '.php'); + $filePath = GenerateConfigReader::read('class')->getPath() ?? config('modules.paths.app_folder') . 'Classes'; + + return $this->typePath($path . $filePath . '/' . $this->getFileName() . '.php'); } protected function getFileName(): string { $file = Str::studly($this->argument('name')); - if ($this->option('plain') == false and $this->type() != 'class') { + if ($this->option('suffix') === true) { $names = [Str::plural($this->type()), Str::singular($this->type())]; $file = Str::of($file)->remove($names, false); $file .= Str::of($this->type())->studly(); @@ -70,12 +72,12 @@ protected function type(): string return Str::of($this->option('type'))->remove('=')->singular(); } - protected function type_path(string $path): string + protected function typePath(string $path): string { - return ($this->type() == 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::of($this->type())->plural()->studly()); + return ($this->type() === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::of($this->type())->plural()->studly()); } - public function type_class(): string + public function typeClass(): string { return Str::of($this->getFileName())->basename()->studly(); } @@ -84,6 +86,6 @@ public function getDefaultNamespace(): string { $type = $this->type(); - return config("modules.paths.generator.{$type}.namespace") ?? $this->path_namespace(config("modules.paths.generator.{$type}.path") ?? $this->type_path($this->app_path('Classes'))); + return config("modules.paths.generator.{$type}.namespace", 'Classes'); } } diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index 3f759f884..b30288104 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -94,14 +94,6 @@ public function getClassNamespace($module) return $this->module_namespace($module->getStudlyName(), $this->getDefaultNamespace() . ($path_namespace ? '\\' . $path_namespace : '')); } - /** - * Get the module root path + extra $path - */ - public function path(?string $path = null): string - { - return $this->clean_path($this->laravel['modules']->getModulePath($this->getModuleName()) . (strlen($path) ? '/' . $path : '')); - } - public function module(?string $name = null): Module { return $this->laravel['modules']->findOrFail($name ?? $this->getModuleName()); From 567a6893b56c013ffc4b445179757702a6134e7e Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 4 Jun 2024 01:04:05 +0330 Subject: [PATCH 354/422] [feat] implement ConfirmableCommand and handle on BaseCommand --- src/Commands/BaseCommand.php | 16 ++++++++++++++++ src/Contracts/ConfirmableCommand.php | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 src/Contracts/ConfirmableCommand.php diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 8faec7c95..3a2d2cedb 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -7,6 +7,7 @@ use function Laravel\Prompts\multiselect; +use Nwidart\Modules\Contracts\ConfirmableCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -36,6 +37,10 @@ public function __construct() InputArgument::IS_ARRAY, 'The name of module will be used.', )); + + if ($this instanceof ConfirmableCommand) { + $this->configureConfirmable(); + } } abstract public function executeAction($name); @@ -101,4 +106,15 @@ protected function getModuleModel($name) : $this->laravel['modules']->findOrFail($name); } + private function configureConfirmable(): void + { + $this->getDefinition() + ->addOption(new InputOption( + 'force', + null, + InputOption::VALUE_NONE, + 'Force the operation to run without confirmation.', + )); + } + } diff --git a/src/Contracts/ConfirmableCommand.php b/src/Contracts/ConfirmableCommand.php new file mode 100644 index 000000000..772b56114 --- /dev/null +++ b/src/Contracts/ConfirmableCommand.php @@ -0,0 +1,7 @@ + Date: Tue, 4 Jun 2024 01:06:31 +0330 Subject: [PATCH 355/422] [feat] change comamnd module:delete to ConfirmableCommand --- src/Commands/Actions/ModuleDeleteCommand.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Commands/Actions/ModuleDeleteCommand.php b/src/Commands/Actions/ModuleDeleteCommand.php index da3ba6f14..ca16509c4 100644 --- a/src/Commands/Actions/ModuleDeleteCommand.php +++ b/src/Commands/Actions/ModuleDeleteCommand.php @@ -2,13 +2,28 @@ namespace Nwidart\Modules\Commands\Actions; +use Illuminate\Console\ConfirmableTrait; +use Illuminate\Console\Prohibitable; use Nwidart\Modules\Commands\BaseCommand; +use Nwidart\Modules\Contracts\ConfirmableCommand; -class ModuleDeleteCommand extends BaseCommand +class ModuleDeleteCommand extends BaseCommand implements ConfirmableCommand { + use ConfirmableTrait, Prohibitable; + protected $name = 'module:delete'; protected $description = 'Delete a module from the application'; + public function handle() + { + if ($this->isProhibited() || + ! $this->confirmToProceed('Warning: Do you want to remove the module?', fn () => TRUE)) { + return 1; + } + + parent::handle(); + } + public function executeAction($name): void { $module = $this->getModuleModel($name); From e0821505d17ea933c07a1f115ea7aa0650525b28 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 4 Jun 2024 01:07:13 +0330 Subject: [PATCH 356/422] [test] update test of delete modules --- tests/Commands/ModuleDeleteCommandTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Commands/ModuleDeleteCommandTest.php b/tests/Commands/ModuleDeleteCommandTest.php index a46c9d5ed..33bf9868c 100644 --- a/tests/Commands/ModuleDeleteCommandTest.php +++ b/tests/Commands/ModuleDeleteCommandTest.php @@ -32,7 +32,7 @@ public function test_it_can_delete_a_module_from_disk(): void $this->artisan('module:make', ['name' => ['WrongModule']]); $this->assertDirectoryExists(base_path('modules/WrongModule')); - $code = $this->artisan('module:delete', ['module' => 'WrongModule']); + $code = $this->artisan('module:delete', ['module' => 'WrongModule','--force' => true]); $this->assertFileDoesNotExist(base_path('modules/WrongModule')); $this->assertSame(0, $code); } @@ -50,7 +50,7 @@ public function test_it_can_delete_array_module_from_disk(): void $this->assertDirectoryExists($this->getModuleBasePath($module)); } - $code = $this->artisan('module:delete', ['module' => ['Foo', 'Bar']]); + $code = $this->artisan('module:delete', ['module' => ['Foo', 'Bar'], '--force' => true]); $this->assertSame(0, $code); $this->assertFileDoesNotExist($this->getModuleBasePath('Foo')); $this->assertFileDoesNotExist($this->getModuleBasePath('Bar')); @@ -72,7 +72,7 @@ public function test_it_can_delete_all_module_from_disk(): void $this->assertDirectoryExists($this->getModuleBasePath($module)); } - $code = $this->artisan('module:delete', ['--all' => true]); + $code = $this->artisan('module:delete', ['--all' => true, '--force' => true]); $this->assertSame(0, $code); $this->assertFileDoesNotExist($this->getModuleBasePath('Foo')); $this->assertFileDoesNotExist($this->getModuleBasePath('Bar')); @@ -84,7 +84,7 @@ public function test_it_deletes_modules_from_status_file(): void $this->artisan('module:make', ['name' => ['WrongModule']]); $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); - $code = $this->artisan('module:delete', ['module' => 'WrongModule']); + $code = $this->artisan('module:delete', ['module' => 'WrongModule', '--force' => true]); $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); $this->assertSame(0, $code); } From 5bf36a443d7b89bebc2907f0043dc5cefdab2053 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 4 Jun 2024 10:56:06 +0330 Subject: [PATCH 357/422] [feat] move logic to baseCommand --- src/Commands/Actions/ModuleDeleteCommand.php | 18 ++++-------------- src/Commands/BaseCommand.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Commands/Actions/ModuleDeleteCommand.php b/src/Commands/Actions/ModuleDeleteCommand.php index ca16509c4..3aa1b1ebf 100644 --- a/src/Commands/Actions/ModuleDeleteCommand.php +++ b/src/Commands/Actions/ModuleDeleteCommand.php @@ -2,28 +2,14 @@ namespace Nwidart\Modules\Commands\Actions; -use Illuminate\Console\ConfirmableTrait; -use Illuminate\Console\Prohibitable; use Nwidart\Modules\Commands\BaseCommand; use Nwidart\Modules\Contracts\ConfirmableCommand; class ModuleDeleteCommand extends BaseCommand implements ConfirmableCommand { - use ConfirmableTrait, Prohibitable; - protected $name = 'module:delete'; protected $description = 'Delete a module from the application'; - public function handle() - { - if ($this->isProhibited() || - ! $this->confirmToProceed('Warning: Do you want to remove the module?', fn () => TRUE)) { - return 1; - } - - parent::handle(); - } - public function executeAction($name): void { $module = $this->getModuleModel($name); @@ -37,4 +23,8 @@ public function getInfo(): string|null return 'deleting module ...'; } + public function getConfirmableLabel(): string + { + return 'Warning: Do you want to remove the module?'; + } } diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 3a2d2cedb..57ecb1f2d 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -3,6 +3,8 @@ namespace Nwidart\Modules\Commands; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; +use Illuminate\Console\Prohibitable; use Illuminate\Contracts\Console\PromptsForMissingInput; use function Laravel\Prompts\multiselect; @@ -15,6 +17,9 @@ abstract class BaseCommand extends Command implements PromptsForMissingInput { + use ConfirmableTrait; + use Prohibitable; + public const ALL = 'All'; /** @@ -50,11 +55,23 @@ public function getInfo(): string|null return null; } + public function getConfirmableLabel(): string|null + { + return 'Warning'; + } + /** * Execute the console command. */ public function handle() { + if ($this instanceof ConfirmableCommand) { + if ($this->isProhibited() || + ! $this->confirmToProceed($this->getConfirmableLabel(), fn () => true)) { + return 1; + } + } + if (! is_null($info = $this->getInfo())) { $this->components->info($info); } From f660a3f67689152756ebd15ce39a1d1eaac8fbdc Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 5 Jun 2024 00:54:11 +0330 Subject: [PATCH 358/422] [refactor] change structure of command 'module:migrate-fresh' and refactor functionality of command --- src/Commands/Database/MigrateFreshCommand.php | 101 ++++++++++-------- 1 file changed, 59 insertions(+), 42 deletions(-) diff --git a/src/Commands/Database/MigrateFreshCommand.php b/src/Commands/Database/MigrateFreshCommand.php index 4ba6f2d0a..530ca8408 100644 --- a/src/Commands/Database/MigrateFreshCommand.php +++ b/src/Commands/Database/MigrateFreshCommand.php @@ -2,15 +2,13 @@ namespace Nwidart\Modules\Commands\Database; -use Illuminate\Console\Command; -use Nwidart\Modules\Traits\ModuleCommandTrait; -use Symfony\Component\Console\Input\InputArgument; +use Illuminate\Database\Migrations\Migrator; +use Illuminate\Support\Collection; +use Nwidart\Modules\Commands\BaseCommand; use Symfony\Component\Console\Input\InputOption; -class MigrateFreshCommand extends Command +class MigrateFreshCommand extends BaseCommand { - use ModuleCommandTrait; - /** * The console command name. * @@ -26,38 +24,66 @@ class MigrateFreshCommand extends Command protected $description = 'Reset all database tables and re-run the modules migrations.'; /** - * Execute the console command. + * The migrator instance. + * + * @var Migrator */ - public function handle(): int - { - $module = $this->argument('module'); + protected Migrator $migrator; - if ($module && !$this->getModuleName()) { - $this->error("Module [$module] does not exists."); + protected Collection $migration_paths; - return E_ERROR; - } + public function __construct() + { + parent::__construct(); + + $this->migrator = app('migrator'); + $this->migration_paths = collect($this->migrator->paths()); + } - $this->call('module:migrate-refresh', [ - 'module' => $this->getModuleName(), + public function handle(): void + { + // drop tables + $this->components->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ + '--database' => $this->option('database'), + '--drop-views' => $this->option('drop-views'), + '--drop-types' => $this->option('drop-types'), + '--force' => true, + ])) == 0); + + // create migration table + $this->call('migrate:install', array_filter([ '--database' => $this->option('database'), - '--force' => $this->option('force'), - '--seed' => $this->option('seed'), - ]); + ])) == 0; + + // run migration of root + $root_paths = $this->migration_paths + ->reject(fn (string $path) => str_starts_with($path, config('modules.paths.modules'))); + + if ($root_paths->count() > 0) { + $this->components->twoColumnDetail("Running Migration of Root"); + + $this->call('migrate', array_filter([ + '--path' => $root_paths->toArray(), + '--database' => $this->option('database'), + '--pretend' => $this->option('pretend'), + '--force' => $this->option('force'), + '--realpath' => true, + ])); + } - return 0; + parent::handle(); } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments(): array + public function executeAction($name): void { - return [ - ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], - ]; + $module = $this->getModuleModel($name); + + $this->call('module:migrate', array_filter([ + 'module' => $module->getStudlyName(), + '--database' => $this->option('database'), + '--force' => $this->option('force'), + '--seed' => $this->option('seed'), + ])); } /** @@ -68,22 +94,13 @@ protected function getArguments(): array protected function getOptions(): array { return [ + ['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'], ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], + ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'], + ['drop-views', null, InputOption::VALUE_NONE, 'Drop all tables and views'], + ['drop-types', null, InputOption::VALUE_NONE, 'Drop all tables and types (Postgres only)'], ]; } - - public function getModuleName() - { - $module = $this->argument('module'); - - if (!$module) { - return null; - } - - $module = app('modules')->find($module); - - return $module ? $module->getStudlyName() : null; - } } From 90896958bc572188d4c91b41a5d657b51236a0c5 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 5 Jun 2024 00:54:34 +0330 Subject: [PATCH 359/422] [feat] get migration path of module from migrator laravel --- src/Commands/Database/MigrateCommand.php | 50 ++++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Commands/Database/MigrateCommand.php b/src/Commands/Database/MigrateCommand.php index eae23eef2..a2253c995 100644 --- a/src/Commands/Database/MigrateCommand.php +++ b/src/Commands/Database/MigrateCommand.php @@ -2,8 +2,9 @@ namespace Nwidart\Modules\Commands\Database; +use Illuminate\Database\Migrations\Migrator; +use Illuminate\Support\Collection; use Nwidart\Modules\Commands\BaseCommand; -use Nwidart\Modules\Migrations\Migrator; use Symfony\Component\Console\Input\InputOption; class MigrateCommand extends BaseCommand @@ -22,28 +23,45 @@ class MigrateCommand extends BaseCommand */ protected $description = 'Migrate the migrations from the specified module or from all modules.'; + /** + * The migrator instance. + * + * @var Migrator + */ + protected Migrator $migrator; + + protected Collection $migration_list; + + public function __construct() + { + parent::__construct(); + + $this->migrator = app('migrator'); + $this->migration_list = collect($this->migrator->paths()); + } + public function executeAction($name): void { $module = $this->getModuleModel($name); - $this->components->task("Running Migration {$module->getName()} Module", function () use ($module) { - $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); + $this->components->twoColumnDetail("Running Migration {$module->getName()} Module"); + + $module_path = $module->getPath(); - if ($this->option('subpath')) { - $path = $path . "/" . $this->option("subpath"); - } + $paths = $this->migration_list + ->filter(fn ($path) => str_starts_with($path, $module_path)); - $this->call('migrate', [ - '--path' => $path, - '--database' => $this->option('database'), - '--pretend' => $this->option('pretend'), - '--force' => $this->option('force'), - ]); + $this->call('migrate', array_filter([ + '--path' => $paths->toArray(), + '--database' => $this->option('database'), + '--pretend' => $this->option('pretend'), + '--force' => $this->option('force'), + '--realpath' => true, + ])); - if ($this->option('seed')) { - $this->call('module:seed', ['module' => $module->getName(), '--force' => $this->option('force')]); - } - }); + if ($this->option('seed')) { + $this->call('module:seed', ['module' => $module->getName(), '--force' => $this->option('force')]); + } } From df927e5c568b278284ef5aeda1a24845f6ecc005 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 15 Jun 2024 18:06:34 +0100 Subject: [PATCH 360/422] added contributing guide --- CHANGELOG.md | 7 +++++-- CONTRIBUTING.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CHANGELOG.md b/CHANGELOG.md index cad5e663a..2b3ec5196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,13 @@ All Notable changes to `laravel-modules` will be documented in this file. -## 11.0.10 - 2024-05-05 - ## Next +- [@omerbaflah](https://github.com/omerbaflah) Fixes Invokable Controller Stub +- [@solomon-ochepa](https://github.com/solomon-ochepa) Added create module:make-class command + +## 11.0.10 - 2024-05-05 + - [@dcblogdev](https://github.com/dcblogdev) Update controller, service, helper, and action methods - [@omerbaflah](https://github.com/omerbaflah) Update service stubs - [@omerbaflah](https://github.com/omerbaflah) Update action stubs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..10bdde2e0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,41 @@ +# CONTRIBUTING + +Contributions are welcome, and are accepted via pull requests. +Please review these guidelines before submitting any pull requests. + +## Process + +1. Fork the project +1. Create a new branch +1. Code, test, commit and push +1. Open a pull request detailing your changes. + +## Guidelines + +* Please ensure the coding style running `composer pcf`. +* * Pull requests should be accompanied by passing tests. +* Please remember ensure you commit to the correct major version, IE v11 for Laravel 11. + +## Setup + +Clone your fork, then install the dev dependencies: +```bash +composer install +``` +## PHP CS Fixer + +Run php-cs-fixer: +```bash +composer pcf +``` +## Tests + +Run all tests: +```bash +composer test +``` + +Check coverage: +```bash +composer test-coverage +``` From 3dd30cc2b8f040b2878fc0e77414281ac2740221 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 16 Jun 2024 16:23:57 +0100 Subject: [PATCH 361/422] reverted class changes --- src/Commands/Make/ClassCommand.php | 108 ------------------ src/Commands/stubs/app/Classes/Class.stub | 14 --- .../stubs/app/Repositories/Class.stub | 14 --- 3 files changed, 136 deletions(-) delete mode 100644 src/Commands/Make/ClassCommand.php delete mode 100644 src/Commands/stubs/app/Classes/Class.stub delete mode 100644 src/Commands/stubs/app/Repositories/Class.stub diff --git a/src/Commands/Make/ClassCommand.php b/src/Commands/Make/ClassCommand.php deleted file mode 100644 index fb31d0f51..000000000 --- a/src/Commands/Make/ClassCommand.php +++ /dev/null @@ -1,108 +0,0 @@ -laravel['modules']->findOrFail($this->getModuleName()); - - return (new Stub('/app/Classes/Class.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), - ]))->render(); - } - - public function getDestinationFilePath() - { - $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $config = GenerateConfigReader::read('class'); - $path .= $this->type_path($config->getPath()) . '/' . $this->getFileName() . '.php'; - - return $path; - } - - protected function getFileName() - { - $file = Str::studly($this->argument('name')); - - if ($this->option('plain') === false and $this->option('type') !== 'class') { - $file .= $this->type(); - } - - return $file; - } - - /** - * Get the type of class e.g. Class, Services, Repository, etc. - */ - protected function type() - { - return Str::studly($this->option('type')); - } - - protected function type_path(string $path) - { - return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); - } - - /** - * Get class name. - */ - public function getClass(): string - { - return $this->getFileName(); - } - - public function getDefaultNamespace(): string - { - $type = $this->option('type'); - - return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->type_path('app/Classes')))); - } - - /** - * Get a well-formatted StudlyCase representation of path components. - */ - public function studly_path(string $path, $directory_separator = '/'): string - { - return collect(explode($directory_separator, Str::of($path) - ->replace("{$directory_separator}{$directory_separator}", $directory_separator)->trim($directory_separator))) - ->map(fn ($path) => Str::studly($path)) - ->implode($directory_separator); - } - - /** - * Get a well-formatted namespace from a given path. - */ - public function path_namespace(string $path): string - { - return Str::of($this->studly_path($path))->replace('/', '\\')->trim('\\'); - } -} diff --git a/src/Commands/stubs/app/Classes/Class.stub b/src/Commands/stubs/app/Classes/Class.stub deleted file mode 100644 index 27bf6b064..000000000 --- a/src/Commands/stubs/app/Classes/Class.stub +++ /dev/null @@ -1,14 +0,0 @@ - Date: Sun, 16 Jun 2024 16:24:20 +0100 Subject: [PATCH 362/422] updated stubs and snapshots --- src/Commands/stubs/repository-invoke.stub | 11 +++++++++++ src/Commands/stubs/repository.stub | 11 +++++++++++ ...n_sub_namespace_with_correct_generated_file__1.txt | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/Commands/stubs/repository-invoke.stub create mode 100644 src/Commands/stubs/repository.stub create mode 100644 tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt diff --git a/src/Commands/stubs/repository-invoke.stub b/src/Commands/stubs/repository-invoke.stub new file mode 100644 index 000000000..d0a85c7af --- /dev/null +++ b/src/Commands/stubs/repository-invoke.stub @@ -0,0 +1,11 @@ + Date: Sun, 16 Jun 2024 16:24:24 +0100 Subject: [PATCH 363/422] updated stubs and snapshots --- ...test_it_generated_correct_file_with_content__1.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..b691473b4 --- /dev/null +++ b/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,11 @@ + Date: Sun, 16 Jun 2024 16:25:46 +0100 Subject: [PATCH 364/422] added tests for repositories --- src/Commands/Make/RepositoryCommand.php | 88 ------------------- src/Commands/Make/RepositoryMakeCommand.php | 78 +++++++++++++++++ src/Providers/ConsoleServiceProvider.php | 2 +- tests/Commands/RepositoryMakeCommandTest.php | 89 ++++++++++++++++++++ 4 files changed, 168 insertions(+), 89 deletions(-) delete mode 100644 src/Commands/Make/RepositoryCommand.php create mode 100644 src/Commands/Make/RepositoryMakeCommand.php create mode 100644 tests/Commands/RepositoryMakeCommandTest.php diff --git a/src/Commands/Make/RepositoryCommand.php b/src/Commands/Make/RepositoryCommand.php deleted file mode 100644 index bcdb0009e..000000000 --- a/src/Commands/Make/RepositoryCommand.php +++ /dev/null @@ -1,88 +0,0 @@ -laravel['modules']->findOrFail($this->getModuleName()); - - return (new Stub('/app/Repositories/Class.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), - ]))->render(); - } - - public function getDestinationFilePath() - { - $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $config = GenerateConfigReader::read('repository'); - $path .= $this->type_path($config->getPath()) . '/' . $this->getFileName() . '.php'; - - return $path; - } - - protected function getFileName() - { - $file = Str::studly($this->argument('name')); - - if ($this->option('plain') === false and $this->option('type') !== 'class') { - $file .= $this->type(); - } - - return $file; - } - - /** - * Get the type of class - Repository. - */ - protected function type() - { - return Str::studly('Repository'); - } - - protected function type_path(string $path) - { - return ($this->option('type') === 'class') ? $path : Str::of($path)->replaceLast('Classes', Str::pluralStudly($this->type())); - } - - /** - * Get class name. - */ - public function getClass(): string - { - return $this->getFileName(); - } - - public function getDefaultNamespace(): string - { - $type = $this->option('type'); - - return config("modules.paths.generator.{$type}.namespace", $this->path_namespace(config("modules.paths.generator.{$type}.path", $this->type_path('app/Classes')))); - } -} diff --git a/src/Commands/Make/RepositoryMakeCommand.php b/src/Commands/Make/RepositoryMakeCommand.php new file mode 100644 index 000000000..92e52cbef --- /dev/null +++ b/src/Commands/Make/RepositoryMakeCommand.php @@ -0,0 +1,78 @@ +laravel['modules']->getModulePath($this->getModuleName()); + + $filePath = GenerateConfigReader::read('repository')->getPath() ?? config('modules.paths.app_folder') . 'Repositories'; + + return $path . $filePath . '/' . $this->getRepositoryName() . '.php'; + } + + protected function getTemplateContents(): string + { + $module = $this->laravel['modules']->findOrFail($this->getModuleName()); + + return (new Stub($this->getStubName(), [ + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), + ]))->render(); + } + + protected function getArguments(): array + { + return [ + ['name', InputArgument::REQUIRED, 'The name of the repository class.'], + ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], + ]; + } + + /** + * @return array + */ + protected function getOptions(): array + { + return [ + ['invokable', 'i', InputOption::VALUE_NONE, 'Generate an invokable action class', null], + ['force', 'f', InputOption::VALUE_NONE, 'su.'], + ]; + } + + protected function getRepositoryName(): array|string + { + return Str::studly($this->argument('name')); + } + + private function getClassNameWithoutNamespace(): array|string + { + return class_basename($this->getRepositoryName()); + } + + public function getDefaultNamespace(): string + { + return config('modules.paths.generator.repository.namespace', 'Repositories'); + } + + protected function getStubName(): string + { + return $this->option('invokable') === true ? '/repository-invoke.stub' : '/repository.stub'; + } +} diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 24fbff854..5f8224c32 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -75,7 +75,7 @@ public static function defaultCommands(): Collection Commands\Make\ObserverMakeCommand::class, Commands\Make\PolicyMakeCommand::class, Commands\Make\ProviderMakeCommand::class, - Commands\Make\RepositoryCommand::class, + Commands\Make\RepositoryMakeCommand::class, Commands\Make\RequestMakeCommand::class, Commands\Make\ResourceMakeCommand::class, Commands\Make\RouteProviderMakeCommand::class, diff --git a/tests/Commands/RepositoryMakeCommandTest.php b/tests/Commands/RepositoryMakeCommandTest.php new file mode 100644 index 000000000..7559477e1 --- /dev/null +++ b/tests/Commands/RepositoryMakeCommandTest.php @@ -0,0 +1,89 @@ +finder = $this->app['files']; + $this->createModule(); + $this->modulePath = $this->getModuleAppPath(); + + } + + public function tearDown(): void + { + $this->app[RepositoryInterface::class]->delete('Blog'); + parent::tearDown(); + } + + public function test_it_generates_a_new_repository_class() + { + $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Repositories/MyRepository.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_repository_class_can_override_with_force_option() + { + $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog']); + $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog', '--force' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Repositories/MyRepository.php')); + $this->assertSame(0, $code); + } + + public function test_it_generates_a_new_repository_class_can_use_invoke_option() + { + $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog', '--invokable' => true]); + + $this->assertTrue(is_file($this->modulePath . '/Repositories/MyRepository.php')); + $this->assertSame(0, $code); + } + + public function test_it_generated_correct_file_with_content() + { + $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Repositories/MyRepository.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_repository_in_sub_namespace_in_correct_folder() + { + $code = $this->artisan('module:make-repository', ['name' => 'Api\\MyRepository', 'module' => 'Blog']); + + $this->assertTrue(is_file($this->modulePath . '/Repositories/Api/MyRepository.php')); + $this->assertSame(0, $code); + } + + public function test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file() + { + $code = $this->artisan('module:make-repository', ['name' => 'Api\\MyRepository', 'module' => 'Blog']); + + $file = $this->finder->get($this->modulePath . '/Repositories/Api/MyRepository.php'); + + $this->assertMatchesSnapshot($file); + $this->assertSame(0, $code); + } +} From c071f3343105248e271c861d2257992e664ed2f9 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sun, 16 Jun 2024 17:11:00 +0100 Subject: [PATCH 365/422] moved tests into folders --- tests/CollectionTest.php | 4 +- .../{ => Actions}/DisableCommandTest.php | 2 +- .../{ => Actions}/EnableCommandTest.php | 2 +- .../{ => Actions}/ListCommandTest.php | 0 .../{ => Actions}/ModuleDeleteCommandTest.php | 0 ...it_deletes_modules_from_status_file__1.txt | 3 + ...it_deletes_modules_from_status_file__2.txt | 1 + .../{ => Make}/ActionMakeCommandTest.php | 2 +- .../{ => Make}/CastMakeCommandTest.php | 2 +- .../{ => Make}/ChannelMakeCommandTest.php | 2 +- .../{ => Make}/ClassMakeCommandTest.php | 2 +- .../{ => Make}/CommandMakeCommandTest.php | 2 +- .../ComponentClassMakeCommandTest.php | 2 +- .../ComponentViewMakeCommandTest.php | 2 +- .../{ => Make}/ControllerMakeCommandTest.php | 2 +- .../{ => Make}/EnumMakeCommandTest.php | 2 +- .../{ => Make}/EventMakeCommandTest.php | 2 +- .../EventProviderMakeCommandTest.php | 2 +- .../{ => Make}/ExceptionMakeCommandTest.php | 2 +- .../{ => Make}/FactoryMakeCommandTest.php | 2 +- .../{ => Make}/HelperMakeCommandTest.php | 2 +- .../{ => Make}/InterfaceMakeCommandTest.php | 2 +- .../{ => Make}/JobMakeCommandTest.php | 2 +- .../{ => Make}/ListenerMakeCommandTest.php | 2 +- .../{ => Make}/MailMakeCommandTest.php | 2 +- .../{ => Make}/MiddlewareMakeCommandTest.php | 2 +- .../{ => Make}/MigrationMakeCommandTest.php | 2 +- .../{ => Make}/ModelMakeCommandTest.php | 2 +- .../{ => Make}/ModuleMakeCommandTest.php | 2 +- .../NotificationMakeCommandTest.php | 2 +- .../{ => Make}/ObserverMakeCommandTest.php | 2 +- .../{ => Make}/PolicyMakeCommandTest.php | 2 +- .../{ => Make}/ProviderMakeCommandTest.php | 2 +- .../{ => Make}/RepositoryMakeCommandTest.php | 2 +- .../{ => Make}/RequestMakeCommandTest.php | 2 +- .../{ => Make}/ResourceMakeCommandTest.php | 2 +- .../RouteProviderMakeCommandTest.php | 2 +- .../{ => Make}/RuleMakeCommandTest.php | 2 +- .../{ => Make}/ScopeMakeCommandTest.php | 2 +- .../{ => Make}/ServiceMakeCommandTest.php | 2 +- .../{ => Make}/TestMakeCommandTest.php | 2 +- .../{ => Make}/TraitMakeCommandTest.php | 2 +- .../{ => Make}/ViewMakeCommandTest.php | 2 +- ...mespace_with_correct_generated_file__1.txt | 11 ++ ...generated_correct_file_with_content__1.txt | 11 ++ ...mespace_with_correct_generated_file__1.txt | 29 +++++ ...generated_correct_file_with_content__1.txt | 29 +++++ ...it_can_change_the_default_namespace__1.txt | 24 ++++ ...ange_the_default_namespace_specific__1.txt | 24 ++++ ...generated_correct_file_with_content__1.txt | 24 ++++ ...mespace_with_correct_generated_file__1.txt | 11 ++ ...generated_correct_file_with_content__1.txt | 11 ++ ...it_can_change_the_default_namespace__1.txt | 56 ++++++++ ...ange_the_default_namespace_specific__1.txt | 56 ++++++++ ...generated_correct_file_with_content__1.txt | 56 ++++++++ ...t_it_uses_set_command_name_in_class__1.txt | 56 ++++++++ ...it_can_change_the_default_namespace__1.txt | 25 ++++ ...generated_correct_file_with_content__1.txt | 25 ++++ ...roller_to_class_name_if_not_present__1.txt | 67 ++++++++++ ...it_can_change_the_default_namespace__1.txt | 67 ++++++++++ ...ange_the_default_namespace_specific__1.txt | 67 ++++++++++ ...mespace_with_correct_generated_file__1.txt | 67 ++++++++++ ...generated_correct_file_with_content__1.txt | 67 ++++++++++ ...est_it_generates_a_plain_controller__1.txt | 9 ++ ...test_it_generates_an_api_controller__1.txt | 59 +++++++++ ...t_generates_an_invokable_controller__1.txt | 17 +++ ...mespace_with_correct_generated_file__1.txt | 8 ++ ...generated_correct_file_with_content__1.txt | 8 ++ ...it_can_change_the_default_namespace__1.txt | 34 +++++ ...ange_the_default_namespace_specific__1.txt | 34 +++++ ...generated_correct_file_with_content__1.txt | 34 +++++ ...generated_correct_file_with_content__1.txt | 32 +++++ ...mespace_with_correct_generated_file__1.txt | 10 ++ ...generated_correct_file_with_content__1.txt | 10 ++ ...eCommandTest__test_it_makes_factory__1.txt | 22 ++++ ...mespace_with_correct_generated_file__1.txt | 11 ++ ...generated_correct_file_with_content__1.txt | 11 ++ ...mespace_with_correct_generated_file__1.txt | 8 ++ ...generated_correct_file_with_content__1.txt | 8 ++ ...it_can_change_the_default_namespace__1.txt | 30 +++++ ...ange_the_default_namespace_specific__1.txt | 30 +++++ ...generated_correct_file_with_content__1.txt | 30 +++++ ..._correct_sync_job_file_with_content__1.txt | 27 ++++ ...it_can_change_the_default_namespace__1.txt | 25 ++++ ...ange_the_default_namespace_specific__1.txt | 25 ++++ ...rect_queued_duck_event_with_content__1.txt | 27 ++++ ...vent_in_a_subdirectory_with_content__1.txt | 28 ++++ ...d_correct_queued_event_with_content__1.txt | 28 ++++ ...orrect_sync_duck_event_with_content__1.txt | 25 ++++ ...vent_in_a_subdirectory_with_content__1.txt | 26 ++++ ...ted_correct_sync_event_with_content__1.txt | 26 ++++ ...it_can_change_the_default_namespace__1.txt | 29 +++++ ...ange_the_default_namespace_specific__1.txt | 29 +++++ ...generated_correct_file_with_content__1.txt | 29 +++++ ...it_can_change_the_default_namespace__1.txt | 17 +++ ...ange_the_default_namespace_specific__1.txt | 17 +++ ...generated_correct_file_with_content__1.txt | 17 +++ ..._correct_add_migration_file_content__1.txt | 28 ++++ ...rrect_create_migration_file_content__1.txt | 28 ++++ ...rect_default_migration_file_content__1.txt | 24 ++++ ...rrect_delete_migration_file_content__1.txt | 28 ++++ ...correct_drop_migration_file_content__1.txt | 28 ++++ ...t_generates_foreign_key_constraints__1.txt | 30 +++++ ...it_can_change_the_default_namespace__1.txt | 22 ++++ ...ange_the_default_namespace_specific__1.txt | 22 ++++ ...generated_correct_file_with_content__1.txt | 22 ++++ ...gration_when_both_flags_are_present__1.txt | 67 ++++++++++ ...gration_when_both_flags_are_present__2.txt | 28 ++++ ...enerates_controller_file_with_model__1.txt | 67 ++++++++++ ...le_with_model_using_shortcut_option__1.txt | 67 ++++++++++ ...t_generates_correct_fillable_fields__1.txt | 22 ++++ ...file_name_with_multiple_words_model__1.txt | 28 ++++ ...generates_migration_file_with_model__1.txt | 28 ++++ ...le_with_model_using_shortcut_option__1.txt | 28 ++++ ...nable_and_route_provider_is_disable__1.txt | 120 ++++++++++++++++++ ...enable_and_route_provider_is_enable__1.txt | 120 ++++++++++++++++++ ...enable_and_route_provider_is_enable__2.txt | 49 +++++++ ...generates_api_module_with_resources__1.txt | 120 ++++++++++++++++++ ...generates_api_module_with_resources__2.txt | 59 +++++++++ ...generates_api_module_with_resources__3.txt | 16 +++ ...generates_api_module_with_resources__4.txt | 49 +++++++ ...t__test_it_generates_api_route_file__1.txt | 19 +++ ...generates_correct_composerjson_file__1.txt | 30 +++++ ...est__test_it_generates_module_files__1.txt | 11 ++ ..._module_namespace_using_studly_case__1.txt | 120 ++++++++++++++++++ ..._test_it_generates_module_resources__1.txt | 120 ++++++++++++++++++ ..._test_it_generates_module_resources__2.txt | 32 +++++ ..._test_it_generates_module_resources__3.txt | 49 +++++++ ..._test_it_generates_module_resources__4.txt | 67 ++++++++++ ..._test_it_generates_module_resources__5.txt | 16 +++ ...ndTest__test_it_generates_vite_file__1.txt | 26 ++++ ...generates_web_module_with_resources__1.txt | 120 ++++++++++++++++++ ...generates_web_module_with_resources__2.txt | 67 ++++++++++ ...generates_web_module_with_resources__3.txt | 16 +++ ...generates_web_module_with_resources__4.txt | 49 +++++++ ...es_when_adding_more_than_one_option__1.txt | 120 ++++++++++++++++++ ...es_when_adding_more_than_one_option__2.txt | 67 ++++++++++ ...es_when_adding_more_than_one_option__3.txt | 16 +++ ...es_when_adding_more_than_one_option__4.txt | 49 +++++++ ...t__test_it_generates_web_route_file__1.txt | 19 +++ ...s_module_with_new_provider_location__1.txt | 11 ++ ...s_module_with_new_provider_location__2.txt | 30 +++++ ...it_can_change_the_default_namespace__1.txt | 48 +++++++ ...ange_the_default_namespace_specific__1.txt | 48 +++++++ ...generated_correct_file_with_content__1.txt | 48 +++++++ ...CommandTest__test_it_makes_observer__1.txt | 48 +++++++ ...it_can_change_the_default_namespace__1.txt | 18 +++ ...ange_the_default_namespace_specific__1.txt | 18 +++ ...keCommandTest__test_it_makes_policy__1.txt | 18 +++ ...it_can_change_the_default_namespace__1.txt | 120 ++++++++++++++++++ ...ange_the_default_namespace_specific__1.txt | 120 ++++++++++++++++++ ..._migration_resources_location_paths__1.txt | 120 ++++++++++++++++++ ...generated_correct_file_with_content__1.txt | 24 ++++ ...vice_provider_with_resource_loading__1.txt | 120 ++++++++++++++++++ ...mespace_with_correct_generated_file__1.txt | 11 ++ ...generated_correct_file_with_content__1.txt | 11 ++ ...it_can_change_the_default_namespace__1.txt | 26 ++++ ...ange_the_default_namespace_specific__1.txt | 26 ++++ ...generated_correct_file_with_content__1.txt | 26 ++++ ...it_can_change_the_default_namespace__1.txt | 17 +++ ...ange_the_default_namespace_specific__1.txt | 17 +++ ...enerate_a_collection_resource_class__1.txt | 17 +++ ...generated_correct_file_with_content__1.txt | 17 +++ ...nge_the_custom_controller_namespace__1.txt | 49 +++++++ ...it_can_change_the_default_namespace__1.txt | 49 +++++++ ...ange_the_default_namespace_specific__1.txt | 49 +++++++ ...andTest__test_it_can_overwrite_file__1.txt | 49 +++++++ ...t_it_can_overwrite_route_file_names__1.txt | 49 +++++++ ...generated_correct_file_with_content__1.txt | 49 +++++++ ...it_can_change_the_default_namespace__1.txt | 17 +++ ...ange_the_default_namespace_specific__1.txt | 17 +++ ...ndTest__test_it_makes_implicit_rule__1.txt | 22 ++++ ...MakeCommandTest__test_it_makes_rule__1.txt | 17 +++ ...mespace_with_correct_generated_file__1.txt | 18 +++ ...generated_correct_file_with_content__1.txt | 18 +++ ...mespace_with_correct_generated_file__1.txt | 11 ++ ...generated_correct_file_with_content__1.txt | 11 ++ ...hange_the_default_feature_namespace__1.txt | 20 +++ ..._default_feature_namespace_specific__1.txt | 20 +++ ...n_change_the_default_unit_namespace__1.txt | 20 +++ ...the_default_unit_namespace_specific__1.txt | 20 +++ ...d_correct_feature_file_with_content__1.txt | 20 +++ ...ated_correct_unit_file_with_content__1.txt | 20 +++ ...mespace_with_correct_generated_file__1.txt | 8 ++ ...generated_correct_file_with_content__1.txt | 8 ++ .../{ => Publish}/PublishCommandTest.php | 2 +- .../PublishMigrationCommandTest.php | 2 +- .../PublishTranslationCommandTest.php | 2 +- .../RepositoryInterfaceTest.php} | 5 +- tests/{ => Facades}/ModuleFacadeTest.php | 3 +- .../Config}/GenerateConfigReaderTest.php | 3 +- .../Migrations}/NameParserTest.php | 5 +- .../Migrations}/SchemaParserTest.php | 5 +- 193 files changed, 5256 insertions(+), 51 deletions(-) rename tests/Commands/{ => Actions}/DisableCommandTest.php (97%) rename tests/Commands/{ => Actions}/EnableCommandTest.php (97%) rename tests/Commands/{ => Actions}/ListCommandTest.php (100%) rename tests/Commands/{ => Actions}/ModuleDeleteCommandTest.php (100%) create mode 100644 tests/Commands/Actions/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__1.txt create mode 100644 tests/Commands/Actions/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__2.txt rename tests/Commands/{ => Make}/ActionMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/CastMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ChannelMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/ClassMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/CommandMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ComponentClassMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/ComponentViewMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/ControllerMakeCommandTest.php (99%) rename tests/Commands/{ => Make}/EnumMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/EventMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/EventProviderMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/ExceptionMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/FactoryMakeCommandTest.php (96%) rename tests/Commands/{ => Make}/HelperMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/InterfaceMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/JobMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ListenerMakeCommandTest.php (99%) rename tests/Commands/{ => Make}/MailMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/MiddlewareMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/MigrationMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ModelMakeCommandTest.php (99%) rename tests/Commands/{ => Make}/ModuleMakeCommandTest.php (99%) rename tests/Commands/{ => Make}/NotificationMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ObserverMakeCommandTest.php (96%) rename tests/Commands/{ => Make}/PolicyMakeCommandTest.php (97%) rename tests/Commands/{ => Make}/ProviderMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/RepositoryMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/RequestMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ResourceMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/RouteProviderMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/RuleMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ScopeMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ServiceMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/TestMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/TraitMakeCommandTest.php (98%) rename tests/Commands/{ => Make}/ViewMakeCommandTest.php (97%) create mode 100644 tests/Commands/Make/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ClassMakeCommandTest__test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ClassMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/CommandMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/CommandMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/CommandMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/CommandMakeCommandTest__test_it_uses_set_command_name_in_class__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ComponentClassMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ComponentClassMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_a_plain_controller__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_api_controller__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt create mode 100644 tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/EventMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt create mode 100644 tests/Commands/Make/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/HelperMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/InterfaceMakeCommandTest__test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/InterfaceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/JobMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/JobMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/JobMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/JobMakeCommandTest__test_it_generated_correct_sync_job_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_duck_event_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_event_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_duck_event_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_event_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_create_migration_file_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_delete_migration_file_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_drop_migration_file_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__2.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_migration_file_name_with_multiple_words_model__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__5.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__3.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt create mode 100644 tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt create mode 100644 tests/Commands/Make/__snapshots__/PolicyMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/PolicyMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/PolicyMakeCommandTest__test_it_makes_policy__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RequestMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ResourceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ResourceMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ResourceMakeCommandTest__test_it_can_generate_a_collection_resource_class__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ResourceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_makes_implicit_rule__1.txt create mode 100644 tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_makes_rule__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ScopeMakeCommandTest__test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ScopeMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt create mode 100644 tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_generated_correct_file_with_content__1.txt rename tests/Commands/{ => Publish}/PublishCommandTest.php (95%) rename tests/Commands/{ => Publish}/PublishMigrationCommandTest.php (95%) rename tests/Commands/{ => Publish}/PublishTranslationCommandTest.php (94%) rename tests/{ContractsServiceProviderTest.php => Contracts/RepositoryInterfaceTest.php} (69%) rename tests/{ => Facades}/ModuleFacadeTest.php (89%) rename tests/{ => Support/Config}/GenerateConfigReaderTest.php (96%) rename tests/{ => Support/Migrations}/NameParserTest.php (95%) rename tests/{ => Support/Migrations}/SchemaParserTest.php (89%) diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 5c3571275..784313b39 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -1,9 +1,9 @@ $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..05d8e3e37 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,29 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..55d364bf9 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,24 @@ +json([]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + + return response()->json([]); + } + + /** + * Show the specified resource. + */ + public function show($id) + { + // + + return response()->json([]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + // + + return response()->json([]); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + // + + return response()->json([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt new file mode 100644 index 000000000..41a1b8ced --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt @@ -0,0 +1,17 @@ +json([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..c9edb0b1b --- /dev/null +++ b/tests/Commands/Make/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + * + * @return void + */ + protected function configureEmailVerification(): void + { + + } +} diff --git a/tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..4e24c9dc5 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,10 @@ +view('view.name'); + } +} diff --git a/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..45f802ffe --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,29 @@ +view('view.name'); + } +} diff --git a/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..5bee369ee --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,29 @@ +view('view.name'); + } +} diff --git a/tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..e8b586751 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,17 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt new file mode 100644 index 000000000..88fa2f36b --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt @@ -0,0 +1,24 @@ +id(); + + $table->timestamps(); + }); + } +}; diff --git a/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt new file mode 100644 index 000000000..6546dae4d --- /dev/null +++ b/tests/Commands/Make/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt @@ -0,0 +1,30 @@ +id(); + $table->integer('user_id')->unsigned(); + $table->foreign('user_id')->references('id')->on('users'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..395327120 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,22 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt new file mode 100644 index 000000000..0006937ff --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt @@ -0,0 +1,67 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('product_details'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt new file mode 100644 index 000000000..36dc20e86 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt new file mode 100644 index 000000000..36dc20e86 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt new file mode 100644 index 000000000..ea1386145 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + // $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt new file mode 100644 index 000000000..713ae6f3a --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt new file mode 100644 index 000000000..713ae6f3a --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt new file mode 100644 index 000000000..bc3afb929 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt @@ -0,0 +1,59 @@ +json([]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + + return response()->json([]); + } + + /** + * Show the specified resource. + */ + public function show($id) + { + // + + return response()->json([]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + // + + return response()->json([]); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + // + + return response()->json([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt new file mode 100644 index 000000000..97e7e2a48 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt new file mode 100644 index 000000000..cbdf7602e --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('blog', BlogController::class)->names('blog'); +}); diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt new file mode 100644 index 000000000..746cae739 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt @@ -0,0 +1,30 @@ +{ + "name": "nwidart/blog", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Blog\\": "app/", + "Modules\\Blog\\Database\\Factories\\": "database/factories/", + "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Blog\\Tests\\": "tests/" + } + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt new file mode 100644 index 000000000..92e3b4504 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt @@ -0,0 +1,11 @@ +{ + "name": "Blog", + "alias": "blog", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Blog\\Providers\\BlogServiceProvider" + ], + "files": [] +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt new file mode 100644 index 000000000..560ac5db1 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt new file mode 100644 index 000000000..713ae6f3a --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt new file mode 100644 index 000000000..4130adfaa --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt @@ -0,0 +1,32 @@ +> + */ + protected $listen = []; + + /** + * Indicates if events should be discovered. + * + * @var bool + */ + protected static $shouldDiscoverEvents = true; + + /** + * Configure the proper event listeners for email verification. + * + * @return void + */ + protected function configureEmailVerification(): void + { + + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt new file mode 100644 index 000000000..6a89e8c29 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -0,0 +1,67 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt new file mode 100644 index 000000000..72d694d39 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-blog', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-blog', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/Blog/resources/assets/sass/app.scss', +// 'Modules/Blog/resources/assets/js/app.js', +//]; \ No newline at end of file diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt new file mode 100644 index 000000000..713ae6f3a --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt new file mode 100644 index 000000000..6a89e8c29 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt @@ -0,0 +1,67 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt new file mode 100644 index 000000000..713ae6f3a --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt new file mode 100644 index 000000000..6a89e8c29 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -0,0 +1,67 @@ +call([]); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt new file mode 100644 index 000000000..082efd6d4 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt @@ -0,0 +1,19 @@ +names('blog'); +}); diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt new file mode 100644 index 000000000..c59f26953 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt @@ -0,0 +1,11 @@ +{ + "name": "Blog", + "alias": "blog", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Blog\\Base\\Providers\\BlogServiceProvider" + ], + "files": [] +} diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt new file mode 100644 index 000000000..746cae739 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt @@ -0,0 +1,30 @@ +{ + "name": "nwidart/blog", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Blog\\": "app/", + "Modules\\Blog\\Database\\Factories\\": "database/factories/", + "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Blog\\Tests\\": "tests/" + } + } +} diff --git a/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..4fb9ff311 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,48 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..4fb9ff311 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,48 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..53e7ab765 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,48 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/tests/Commands/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt b/tests/Commands/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt new file mode 100644 index 000000000..f2b38c90d --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt @@ -0,0 +1,48 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..bb17c3614 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt new file mode 100644 index 000000000..26918b859 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -0,0 +1,120 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..922456f3d --- /dev/null +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,24 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(EventServiceProvider::class); + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return []; + } + + /** + * @return array + */ + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..6ddffc7b9 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,11 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..af40c469e --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt new file mode 100644 index 000000000..af40c469e --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt new file mode 100644 index 000000000..e8d7205d7 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt new file mode 100644 index 000000000..7c40e3d35 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/SuperRoutes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt new file mode 100644 index 000000000..dc17450cc --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); + } +} diff --git a/tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt new file mode 100644 index 000000000..23757e05f --- /dev/null +++ b/tests/Commands/Make/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -0,0 +1,17 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt new file mode 100644 index 000000000..dba6e35a1 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt @@ -0,0 +1,20 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt new file mode 100644 index 000000000..273dc9657 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt new file mode 100644 index 000000000..fcbfc0da3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt new file mode 100644 index 000000000..6378738a3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt @@ -0,0 +1,20 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt new file mode 100644 index 000000000..fcbfc0da3 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt new file mode 100644 index 000000000..81f87fd99 --- /dev/null +++ b/tests/Commands/Make/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt @@ -0,0 +1,8 @@ + Date: Sun, 16 Jun 2024 17:23:56 +0100 Subject: [PATCH 366/422] added and ran pint with laravel preset --- composer.json | 10 +- pint.json | 3 + src/Activators/FileActivator.php | 32 ++-- src/Collection.php | 2 +- src/Commands/Actions/CheckLangCommand.php | 22 +-- src/Commands/Actions/DisableCommand.php | 2 +- src/Commands/Actions/DumpCommand.php | 2 +- src/Commands/Actions/EnableCommand.php | 2 +- src/Commands/Actions/InstallCommand.php | 12 +- src/Commands/Actions/ModelPruneCommand.php | 10 +- src/Commands/Actions/ModelShowCommand.php | 11 +- src/Commands/Actions/ModuleDeleteCommand.php | 5 +- src/Commands/Actions/UnUseCommand.php | 2 +- src/Commands/Actions/UpdateCommand.php | 2 +- src/Commands/Actions/UseCommand.php | 2 +- src/Commands/BaseCommand.php | 10 +- src/Commands/ComposerUpdateCommand.php | 6 +- src/Commands/Database/MigrateCommand.php | 10 +- src/Commands/Database/MigrateFreshCommand.php | 30 ++-- .../Database/MigrateRefreshCommand.php | 10 +- src/Commands/Database/MigrateResetCommand.php | 2 +- .../Database/MigrateRollbackCommand.php | 4 +- .../Database/MigrateStatusCommand.php | 4 +- src/Commands/Database/SeedCommand.php | 27 ++- src/Commands/LaravelModulesV6Migrator.php | 1 + src/Commands/Make/ActionMakeCommand.php | 13 +- src/Commands/Make/CastMakeCommand.php | 13 +- src/Commands/Make/ChannelMakeCommand.php | 4 +- src/Commands/Make/ClassMakeCommand.php | 4 +- src/Commands/Make/CommandMakeCommand.php | 6 +- .../Make/ComponentClassMakeCommand.php | 16 +- .../Make/ComponentViewMakeCommand.php | 4 +- src/Commands/Make/ControllerMakeCommand.php | 23 +-- src/Commands/Make/EnumMakeCommand.php | 13 +- src/Commands/Make/EventMakeCommand.php | 4 +- .../Make/EventProviderMakeCommand.php | 11 +- src/Commands/Make/ExceptionMakeCommand.php | 13 +- src/Commands/Make/FactoryMakeCommand.php | 14 +- src/Commands/Make/GeneratorCommand.php | 9 +- src/Commands/Make/HelperMakeCommand.php | 13 +- src/Commands/Make/InterfaceMakeCommand.php | 13 +- src/Commands/Make/JobMakeCommand.php | 7 +- src/Commands/Make/ListenerMakeCommand.php | 9 +- src/Commands/Make/MailMakeCommand.php | 4 +- src/Commands/Make/MiddlewareMakeCommand.php | 4 +- src/Commands/Make/MigrationMakeCommand.php | 8 +- src/Commands/Make/ModelMakeCommand.php | 27 ++- src/Commands/Make/ModuleMakeCommand.php | 10 +- src/Commands/Make/NotificationMakeCommand.php | 4 +- src/Commands/Make/ObserverMakeCommand.php | 24 ++- src/Commands/Make/PolicyMakeCommand.php | 4 +- src/Commands/Make/ProviderMakeCommand.php | 26 +-- src/Commands/Make/RepositoryMakeCommand.php | 14 +- src/Commands/Make/RequestMakeCommand.php | 4 +- src/Commands/Make/ResourceMakeCommand.php | 11 +- .../Make/RouteProviderMakeCommand.php | 23 ++- src/Commands/Make/RuleMakeCommand.php | 4 +- src/Commands/Make/ScopeMakeCommand.php | 15 +- src/Commands/Make/SeedMakeCommand.php | 2 +- src/Commands/Make/ServiceMakeCommand.php | 13 +- src/Commands/Make/TestMakeCommand.php | 6 +- src/Commands/Make/TraitMakeCommand.php | 13 +- src/Commands/Make/ViewMakeCommand.php | 9 +- src/Commands/Publish/PublishCommand.php | 3 +- .../Publish/PublishConfigurationCommand.php | 18 +- .../Publish/PublishMigrationCommand.php | 2 +- .../Publish/PublishTranslationCommand.php | 2 +- src/Commands/SetupCommand.php | 7 +- src/Contracts/ActivatorInterface.php | 17 -- src/Contracts/RepositoryInterface.php | 25 +-- src/Contracts/RunableInterface.php | 2 +- src/FileRepository.php | 129 +++++--------- src/Generators/FileGenerator.php | 14 +- src/Generators/ModuleGenerator.php | 98 ++++------ src/Json.php | 43 ++--- src/Laravel/Module.php | 6 +- src/LaravelModulesServiceProvider.php | 6 +- src/Lumen/Module.php | 2 +- src/LumenModulesServiceProvider.php | 4 +- src/Migrations/Migrator.php | 42 ++--- src/Module.php | 86 ++------- src/ModulesServiceProvider.php | 6 +- src/Process/Installer.php | 24 +-- src/Process/Runner.php | 3 +- src/Process/Updater.php | 15 +- src/Providers/ConsoleServiceProvider.php | 2 - src/Publishing/MigrationPublisher.php | 1 - src/Publishing/Publisher.php | 12 +- src/Support/Config/GeneratorPath.php | 10 +- src/Support/Migrations/NameParser.php | 3 +- src/Support/Migrations/SchemaParser.php | 73 ++++---- src/Support/Stub.php | 26 ++- src/Traits/MigrationLoaderTrait.php | 6 +- src/Traits/PathNamespace.php | 6 +- src/helpers.php | 8 +- tests/Activators/FileActivatorTest.php | 2 +- tests/BaseTestCase.php | 18 +- tests/CollectionTest.php | 8 +- .../Actions/ModuleDeleteCommandTest.php | 5 +- tests/Commands/Make/ActionMakeCommandTest.php | 13 +- tests/Commands/Make/CastMakeCommandTest.php | 11 +- .../Commands/Make/ChannelMakeCommandTest.php | 9 +- tests/Commands/Make/ClassMakeCommandTest.php | 17 +- .../Commands/Make/CommandMakeCommandTest.php | 11 +- .../Make/ComponentClassMakeCommandTest.php | 9 +- .../Make/ComponentViewMakeCommandTest.php | 7 +- .../Make/ControllerMakeCommandTest.php | 35 ++-- tests/Commands/Make/EnumMakeCommandTest.php | 11 +- tests/Commands/Make/EventMakeCommandTest.php | 9 +- .../Make/EventProviderMakeCommandTest.php | 7 +- .../Make/ExceptionMakeCommandTest.php | 17 +- .../Commands/Make/FactoryMakeCommandTest.php | 4 +- tests/Commands/Make/HelperMakeCommandTest.php | 13 +- .../Make/InterfaceMakeCommandTest.php | 11 +- tests/Commands/Make/JobMakeCommandTest.php | 12 +- .../Commands/Make/ListenerMakeCommandTest.php | 19 +- tests/Commands/Make/MailMakeCommandTest.php | 10 +- .../Make/MiddlewareMakeCommandTest.php | 10 +- .../Make/MigrationMakeCommandTest.php | 28 +-- tests/Commands/Make/ModelMakeCommandTest.php | 40 +++-- tests/Commands/Make/ModuleMakeCommandTest.php | 168 +++++++++--------- .../Make/NotificationMakeCommandTest.php | 10 +- .../Commands/Make/ObserverMakeCommandTest.php | 4 +- tests/Commands/Make/PolicyMakeCommandTest.php | 8 +- .../Commands/Make/ProviderMakeCommandTest.php | 17 +- .../Make/RepositoryMakeCommandTest.php | 13 +- .../Commands/Make/RequestMakeCommandTest.php | 10 +- .../Commands/Make/ResourceMakeCommandTest.php | 12 +- .../Make/RouteProviderMakeCommandTest.php | 16 +- tests/Commands/Make/RuleMakeCommandTest.php | 10 +- tests/Commands/Make/ScopeMakeCommandTest.php | 11 +- .../Commands/Make/ServiceMakeCommandTest.php | 13 +- tests/Commands/Make/TestMakeCommandTest.php | 18 +- tests/Commands/Make/TraitMakeCommandTest.php | 11 +- tests/Commands/Make/ViewMakeCommandTest.php | 9 +- tests/Commands/Publish/PublishCommandTest.php | 3 +- .../Publish/PublishMigrationCommandTest.php | 1 + .../Publish/PublishTranslationCommandTest.php | 1 + ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...__it_uses_set_command_name_in_class__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...roller_to_class_name_if_not_present__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...mespace_with_correct_generated_file__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...st__it_generates_a_plain_controller__1.php | 4 +- ...est__it_generates_an_api_controller__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...ryMakeCommandTest__it_makes_factory__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ..._correct_sync_job_file_with_content__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...rect_queued_duck_event_with_content__1.php | 4 +- ...vent_in_a_subdirectory_with_content__1.php | 4 +- ...d_correct_queued_event_with_content__1.php | 4 +- ...orrect_sync_duck_event_with_content__1.php | 4 +- ...vent_in_a_subdirectory_with_content__1.php | 4 +- ...ted_correct_sync_event_with_content__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ..._correct_add_migration_file_content__1.php | 4 +- ...rrect_create_migration_file_content__1.php | 4 +- ...rect_default_migration_file_content__1.php | 4 +- ...rrect_delete_migration_file_content__1.php | 4 +- ...correct_drop_migration_file_content__1.php | 4 +- ...t_generates_foreign_key_constraints__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...gration_when_both_flags_are_present__1.php | 4 +- ...gration_when_both_flags_are_present__2.php | 4 +- ...enerates_controller_file_with_model__1.php | 4 +- ...le_with_model_using_shortcut_option__1.php | 4 +- ...t_generates_correct_fillable_fields__1.php | 4 +- ...file_name_with_multiple_words_model__1.php | 4 +- ...generates_migration_file_with_model__1.php | 4 +- ...le_with_model_using_shortcut_option__1.php | 4 +- ...it_deletes_modules_from_status_file__1.php | 4 +- ...it_deletes_modules_from_status_file__2.php | 4 +- ...generates_api_module_with_resources__1.php | 4 +- ...generates_api_module_with_resources__2.php | 4 +- ...generates_api_module_with_resources__3.php | 4 +- ...generates_api_module_with_resources__4.php | 4 +- ...ndTest__it_generates_api_route_file__1.php | 4 +- ...generates_correct_composerjson_file__1.php | 4 +- ...es_correct_service_provider_content__1.php | 4 +- ...mandTest__it_generates_module_files__1.php | 4 +- ..._module_namespace_using_studly_case__1.php | 4 +- ...Test__it_generates_module_resources__1.php | 4 +- ...Test__it_generates_module_resources__2.php | 4 +- ...Test__it_generates_module_resources__3.php | 4 +- ...Test__it_generates_module_resources__4.php | 4 +- ...ommandTest__it_generates_route_file__1.php | 4 +- ...CommandTest__it_generates_vite_file__1.php | 2 +- ...generates_web_module_with_resources__1.php | 4 +- ...generates_web_module_with_resources__2.php | 4 +- ...generates_web_module_with_resources__3.php | 4 +- ...generates_web_module_with_resources__4.php | 4 +- ...es_when_adding_more_than_one_option__1.php | 4 +- ...es_when_adding_more_than_one_option__2.php | 4 +- ...es_when_adding_more_than_one_option__3.php | 4 +- ...es_when_adding_more_than_one_option__4.php | 4 +- ...ndTest__it_generates_web_route_file__1.php | 4 +- ...s_module_with_new_provider_location__1.php | 4 +- ...s_module_with_new_provider_location__2.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...rMakeCommandTest__it_makes_observer__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...icyMakeCommandTest__it_makes_policy__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ..._migration_resources_location_paths__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...vice_provider_with_resource_loading__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...enerate_a_collection_resource_class__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...nge_the_custom_controller_namespace__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- ...eCommandTest__it_can_overwrite_file__1.php | 4 +- ...__it_can_overwrite_route_file_names__1.php | 4 +- ...generated_correct_file_with_content__1.php | 4 +- ...it_can_change_the_default_namespace__1.php | 4 +- ...ange_the_default_namespace_specific__1.php | 4 +- .../RuleMakeCommandTest__it_makes_rule__1.php | 4 +- ...hange_the_default_feature_namespace__1.php | 4 +- ..._default_feature_namespace_specific__1.php | 4 +- ...n_change_the_default_unit_namespace__1.php | 4 +- ...the_default_unit_namespace_specific__1.php | 4 +- ...d_correct_feature_file_with_content__1.php | 4 +- ...ated_correct_unit_file_with_content__1.php | 4 +- tests/HelpersTest.php | 1 + tests/JsonTest.php | 14 +- tests/LaravelFileRepositoryTest.php | 24 +-- tests/LaravelModuleTest.php | 17 +- tests/LumenModuleTest.php | 6 +- tests/StubTest.php | 10 +- .../stubs/valid/Recipe/Config/permissions.php | 2 +- tests/stubs/valid/Recipe/Entities/Recipe.php | 4 +- .../Recipe/Entities/RecipeTranslation.php | 2 + .../valid/Recipe/Events/RecipeWasCreated.php | 9 +- .../Controllers/Admin/RecipeController.php | 6 +- .../stubs/valid/Recipe/Http/backendRoutes.php | 14 +- .../Providers/DeferredServiceProvider.php | 2 +- .../Providers/RecipeServiceProvider.php | 2 +- .../valid/Recipe/Sidebar/SidebarExtender.php | 4 - 267 files changed, 1300 insertions(+), 1280 deletions(-) create mode 100644 pint.json diff --git a/composer.json b/composer.json index 1fbd48599..3d4941b2e 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "require": { "php": ">=8.2", "ext-json": "*", - "wikimedia/composer-merge-plugin": "^2.1" + "wikimedia/composer-merge-plugin": "^2.1", + "laravel/pint": "^1.16" }, "require-dev": { "phpunit/phpunit": "^11.0", @@ -64,9 +65,10 @@ } }, "scripts": { - "update-snapshots": "./vendor/bin/phpunit --no-coverage -d --update-snapshots", - "test": "vendor/bin/phpunit", - "test-coverage": "vendor/bin/phpunit --coverage-html coverage", + "update-snapshots": "./phpunit --no-coverage -d --update-snapshots", + "lint": "pint", + "test": "phpunit", + "test-coverage": "phpunit --coverage-html coverage", "pcf": "vendor/bin/php-cs-fixer fix --verbose" }, "minimum-stability": "dev", diff --git a/pint.json b/pint.json new file mode 100644 index 000000000..93061b6bd --- /dev/null +++ b/pint.json @@ -0,0 +1,3 @@ +{ + "preset": "laravel" +} diff --git a/src/Activators/FileActivator.php b/src/Activators/FileActivator.php index 6e09c06d4..9548583a6 100644 --- a/src/Activators/FileActivator.php +++ b/src/Activators/FileActivator.php @@ -70,8 +70,6 @@ public function __construct(Container $app) /** * Get the path of the file where statuses are stored - * - * @return string */ public function getStatusesFilePath(): string { @@ -79,7 +77,7 @@ public function getStatusesFilePath(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function reset(): void { @@ -91,7 +89,7 @@ public function reset(): void } /** - * @inheritDoc + * {@inheritDoc} */ public function enable(Module $module): void { @@ -99,7 +97,7 @@ public function enable(Module $module): void } /** - * @inheritDoc + * {@inheritDoc} */ public function disable(Module $module): void { @@ -107,11 +105,11 @@ public function disable(Module $module): void } /** - * @inheritDoc + * {@inheritDoc} */ public function hasStatus(Module $module, bool $status): bool { - if (!isset($this->modulesStatuses[$module->getName()])) { + if (! isset($this->modulesStatuses[$module->getName()])) { return $status === false; } @@ -119,7 +117,7 @@ public function hasStatus(Module $module, bool $status): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function setActive(Module $module, bool $active): void { @@ -127,7 +125,7 @@ public function setActive(Module $module, bool $active): void } /** - * @inheritDoc + * {@inheritDoc} */ public function setActiveByName(string $name, bool $status): void { @@ -137,11 +135,11 @@ public function setActiveByName(string $name, bool $status): void } /** - * @inheritDoc + * {@inheritDoc} */ public function delete(Module $module): void { - if (!isset($this->modulesStatuses[$module->getName()])) { + if (! isset($this->modulesStatuses[$module->getName()])) { return; } unset($this->modulesStatuses[$module->getName()]); @@ -159,12 +157,12 @@ private function writeJson(): void /** * Reads the json file that contains the activation statuses. - * @return array + * * @throws FileNotFoundException */ private function readJson(): array { - if (!$this->files->exists($this->statusesFile)) { + if (! $this->files->exists($this->statusesFile)) { return []; } @@ -174,12 +172,12 @@ private function readJson(): array /** * Get modules statuses, either from the cache or from * the json statuses file if the cache is disabled. - * @return array + * * @throws FileNotFoundException */ private function getModulesStatuses(): array { - if (!$this->config->get('modules.cache.enabled')) { + if (! $this->config->get('modules.cache.enabled')) { return $this->readJson(); } @@ -191,13 +189,11 @@ private function getModulesStatuses(): array /** * Reads a config parameter under the 'activators.file' key * - * @param string $key - * @param $default * @return mixed */ private function config(string $key, $default = null) { - return $this->config->get('modules.activators.file.' . $key, $default); + return $this->config->get('modules.activators.file.'.$key, $default); } /** diff --git a/src/Collection.php b/src/Collection.php index 05ac08328..36351fcd2 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -27,7 +27,7 @@ public function toArray() return array_map(function ($value) { if ($value instanceof Module) { $attributes = $value->json()->getAttributes(); - $attributes["path"] = $value->getPath(); + $attributes['path'] = $value->getPath(); return $attributes; } diff --git a/src/Commands/Actions/CheckLangCommand.php b/src/Commands/Actions/CheckLangCommand.php index 991603125..73111f971 100644 --- a/src/Commands/Actions/CheckLangCommand.php +++ b/src/Commands/Actions/CheckLangCommand.php @@ -27,7 +27,7 @@ public function __construct() { parent::__construct(); - $this->langPath = DIRECTORY_SEPARATOR . config('modules.paths.generator.lang.path', 'Resources/lang'); + $this->langPath = DIRECTORY_SEPARATOR.config('modules.paths.generator.lang.path', 'Resources/lang'); } public function executeAction($name): void @@ -46,7 +46,7 @@ public function executeAction($name): void } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Checking languages ...'; } @@ -54,7 +54,7 @@ public function getInfo(): string|null private function getLangFiles($module) { $files = []; - $path = $module->getPath() . $this->langPath; + $path = $module->getPath().$this->langPath; if (is_dir($path)) { $files = array_merge($files, $this->laravel['files']->all($path)); } @@ -65,18 +65,18 @@ private function getLangFiles($module) private function getDirectories($module) { $moduleName = $module->getStudlyName(); - $path = $module->getPath() . $this->langPath; + $path = $module->getPath().$this->langPath; $directories = []; if (is_dir($path)) { $directories = $this->laravel['files']->directories($path); $directories = array_map(function ($directory) use ($moduleName) { return [ - 'name' => basename($directory), + 'name' => basename($directory), 'module' => $moduleName, - 'path' => $directory, - 'files' => array_map(function ($file) { + 'path' => $directory, + 'files' => array_map(function ($file) { return basename($file); - }, \File::glob($directory . DIRECTORY_SEPARATOR . "*")), + }, \File::glob($directory.DIRECTORY_SEPARATOR.'*')), ]; }, $directories); } @@ -136,14 +136,14 @@ private function checkMissingFiles(Collection $directories) private function checkMissingKeys(Collection $directories) { //show missing keys - $uniqeLangFiles = $directories->pluck('files')->flatten()->unique(); + $uniqeLangFiles = $directories->pluck('files')->flatten()->unique(); $langDirectories = $directories->pluck('name'); $missingKeysMessage = []; $directories->each(function ($directory) use ($uniqeLangFiles, $langDirectories, &$missingKeysMessage) { $uniqeLangFiles->each(function ($file) use ($directory, $langDirectories, &$missingKeysMessage) { - $langKeys = $this->getLangKeys($directory['path'] . DIRECTORY_SEPARATOR . $file); + $langKeys = $this->getLangKeys($directory['path'].DIRECTORY_SEPARATOR.$file); if ($langKeys == false) { return; @@ -155,7 +155,7 @@ private function checkMissingKeys(Collection $directories) $basePath = str_replace($directory['name'], $langDirectory, $directory['path']); - $otherLangKeys = $this->getLangKeys($basePath . DIRECTORY_SEPARATOR . $file); + $otherLangKeys = $this->getLangKeys($basePath.DIRECTORY_SEPARATOR.$file); if ($otherLangKeys == false) { return; diff --git a/src/Commands/Actions/DisableCommand.php b/src/Commands/Actions/DisableCommand.php index f05372dbb..03c192a61 100644 --- a/src/Commands/Actions/DisableCommand.php +++ b/src/Commands/Actions/DisableCommand.php @@ -40,7 +40,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Disabling module ...'; } diff --git a/src/Commands/Actions/DumpCommand.php b/src/Commands/Actions/DumpCommand.php index 5b632effa..094aad8d3 100644 --- a/src/Commands/Actions/DumpCommand.php +++ b/src/Commands/Actions/DumpCommand.php @@ -31,7 +31,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Generating optimized autoload modules'; } diff --git a/src/Commands/Actions/EnableCommand.php b/src/Commands/Actions/EnableCommand.php index 2ed80cb41..10e3be36e 100644 --- a/src/Commands/Actions/EnableCommand.php +++ b/src/Commands/Actions/EnableCommand.php @@ -33,7 +33,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Disabling module ...'; } diff --git a/src/Commands/Actions/InstallCommand.php b/src/Commands/Actions/InstallCommand.php index 755f99cd1..3d8e707a9 100644 --- a/src/Commands/Actions/InstallCommand.php +++ b/src/Commands/Actions/InstallCommand.php @@ -56,7 +56,7 @@ public function handle(): int */ protected function installFromFile(): int { - if (!file_exists($path = base_path('modules.json'))) { + if (! file_exists($path = base_path('modules.json'))) { $this->error("File 'modules.json' does not exist in your project root."); return E_ERROR; @@ -82,10 +82,10 @@ protected function installFromFile(): int /** * Install the specified module. * - * @param string $name - * @param string $version - * @param string $type - * @param bool $tree + * @param string $name + * @param string $version + * @param string $type + * @param bool $tree */ protected function install($name, $version = 'dev-master', $type = 'composer', $tree = false) { @@ -110,7 +110,7 @@ protected function install($name, $version = 'dev-master', $type = 'composer', $ $installer->run(); - if (!$this->option('no-update')) { + if (! $this->option('no-update')) { $this->call('module:update', [ 'module' => $installer->getModuleName(), ]); diff --git a/src/Commands/Actions/ModelPruneCommand.php b/src/Commands/Actions/ModelPruneCommand.php index 5d40051cb..210b2ff88 100644 --- a/src/Commands/Actions/ModelPruneCommand.php +++ b/src/Commands/Actions/ModelPruneCommand.php @@ -7,14 +7,13 @@ use Illuminate\Support\Collection; use Illuminate\Support\Str; use InvalidArgumentException; - -use function Laravel\Prompts\multiselect; - use Nwidart\Modules\Facades\Module; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; +use function Laravel\Prompts\multiselect; + class ModelPruneCommand extends PruneCommand implements PromptsForMissingInput { public const ALL = 'All'; @@ -68,8 +67,6 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf /** * Determine the models that should be pruned. - * - * @return Collection */ protected function models(): Collection { @@ -105,7 +102,7 @@ protected function models(): Collection $namespace = config('modules.namespace'); - return $namespace . str_replace( + return $namespace.str_replace( ['/', '.php'], ['\\', ''], Str::after($model->getRealPath(), realpath(config('modules.paths.modules'))) @@ -121,5 +118,4 @@ protected function models(): Collection return $this->isPrunable($model); })->values(); } - } diff --git a/src/Commands/Actions/ModelShowCommand.php b/src/Commands/Actions/ModelShowCommand.php index 9b48eeb91..1fe385a75 100644 --- a/src/Commands/Actions/ModelShowCommand.php +++ b/src/Commands/Actions/ModelShowCommand.php @@ -34,8 +34,6 @@ class ModelShowCommand extends ShowModelCommand /** * Qualify the given model class base name. * - * @param string $model - * @return string * * @see \Illuminate\Console\GeneratorCommand */ @@ -47,16 +45,15 @@ protected function qualifyModel(string $model): string $rootNamespace = config('modules.namespace'); - $modelPath = glob($rootNamespace . DIRECTORY_SEPARATOR . - '*' . DIRECTORY_SEPARATOR . - config('modules.paths.generator.model.path') . DIRECTORY_SEPARATOR . + $modelPath = glob($rootNamespace.DIRECTORY_SEPARATOR. + '*'.DIRECTORY_SEPARATOR. + config('modules.paths.generator.model.path').DIRECTORY_SEPARATOR. "$model.php"); - if (!count($modelPath)) { + if (! count($modelPath)) { return $model; } return str_replace(['/', '.php'], ['\\', ''], $modelPath[0]); } - } diff --git a/src/Commands/Actions/ModuleDeleteCommand.php b/src/Commands/Actions/ModuleDeleteCommand.php index 3aa1b1ebf..e3d81e66c 100644 --- a/src/Commands/Actions/ModuleDeleteCommand.php +++ b/src/Commands/Actions/ModuleDeleteCommand.php @@ -7,7 +7,8 @@ class ModuleDeleteCommand extends BaseCommand implements ConfirmableCommand { - protected $name = 'module:delete'; + protected $name = 'module:delete'; + protected $description = 'Delete a module from the application'; public function executeAction($name): void @@ -18,7 +19,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'deleting module ...'; } diff --git a/src/Commands/Actions/UnUseCommand.php b/src/Commands/Actions/UnUseCommand.php index c649d64bf..4e94d86fe 100644 --- a/src/Commands/Actions/UnUseCommand.php +++ b/src/Commands/Actions/UnUseCommand.php @@ -29,7 +29,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Forget Using Module ...'; } diff --git a/src/Commands/Actions/UpdateCommand.php b/src/Commands/Actions/UpdateCommand.php index 69daf7223..cbdbf3c03 100644 --- a/src/Commands/Actions/UpdateCommand.php +++ b/src/Commands/Actions/UpdateCommand.php @@ -29,7 +29,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Updating Module ...'; } diff --git a/src/Commands/Actions/UseCommand.php b/src/Commands/Actions/UseCommand.php index d5f0cf1e6..e9d9852e7 100644 --- a/src/Commands/Actions/UseCommand.php +++ b/src/Commands/Actions/UseCommand.php @@ -29,7 +29,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Using Module ...'; } diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 57ecb1f2d..6706e0f2d 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -6,15 +6,14 @@ use Illuminate\Console\ConfirmableTrait; use Illuminate\Console\Prohibitable; use Illuminate\Contracts\Console\PromptsForMissingInput; - -use function Laravel\Prompts\multiselect; - use Nwidart\Modules\Contracts\ConfirmableCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use function Laravel\Prompts\multiselect; + abstract class BaseCommand extends Command implements PromptsForMissingInput { use ConfirmableTrait; @@ -50,12 +49,12 @@ public function __construct() abstract public function executeAction($name); - public function getInfo(): string|null + public function getInfo(): ?string { return null; } - public function getConfirmableLabel(): string|null + public function getConfirmableLabel(): ?string { return 'Warning'; } @@ -133,5 +132,4 @@ private function configureConfirmable(): void 'Force the operation to run without confirmation.', )); } - } diff --git a/src/Commands/ComposerUpdateCommand.php b/src/Commands/ComposerUpdateCommand.php index 64b45279f..753148fd1 100644 --- a/src/Commands/ComposerUpdateCommand.php +++ b/src/Commands/ComposerUpdateCommand.php @@ -26,7 +26,7 @@ public function executeAction($name): void $this->components->task("Updating Composer.json {$module->getName()} Module", function () use ($module) { - $composer_path = $module->getPath() . DIRECTORY_SEPARATOR . 'composer.json'; + $composer_path = $module->getPath().DIRECTORY_SEPARATOR.'composer.json'; $composer = json_decode(File::get($composer_path), true); @@ -43,7 +43,7 @@ public function executeAction($name): void } unset($autoload[$key_name_with_app]); - $key_name_with_out_app = sprintf('Modules\\%s\\', $module->getStudlyName()); + $key_name_with_out_app = sprintf('Modules\\%s\\', $module->getStudlyName()); $autoload[$key_name_with_out_app] = 'app/'; data_set($composer, 'autoload.psr-4', $autoload); @@ -53,7 +53,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Updating Composer.json of modules...'; } diff --git a/src/Commands/Database/MigrateCommand.php b/src/Commands/Database/MigrateCommand.php index a2253c995..9d6a35154 100644 --- a/src/Commands/Database/MigrateCommand.php +++ b/src/Commands/Database/MigrateCommand.php @@ -25,8 +25,6 @@ class MigrateCommand extends BaseCommand /** * The migrator instance. - * - * @var Migrator */ protected Migrator $migrator; @@ -36,7 +34,7 @@ public function __construct() { parent::__construct(); - $this->migrator = app('migrator'); + $this->migrator = app('migrator'); $this->migration_list = collect($this->migrator->paths()); } @@ -52,10 +50,10 @@ public function executeAction($name): void ->filter(fn ($path) => str_starts_with($path, $module_path)); $this->call('migrate', array_filter([ - '--path' => $paths->toArray(), + '--path' => $paths->toArray(), '--database' => $this->option('database'), - '--pretend' => $this->option('pretend'), - '--force' => $this->option('force'), + '--pretend' => $this->option('pretend'), + '--force' => $this->option('force'), '--realpath' => true, ])); diff --git a/src/Commands/Database/MigrateFreshCommand.php b/src/Commands/Database/MigrateFreshCommand.php index 530ca8408..94940b8aa 100644 --- a/src/Commands/Database/MigrateFreshCommand.php +++ b/src/Commands/Database/MigrateFreshCommand.php @@ -25,8 +25,6 @@ class MigrateFreshCommand extends BaseCommand /** * The migrator instance. - * - * @var Migrator */ protected Migrator $migrator; @@ -36,7 +34,7 @@ public function __construct() { parent::__construct(); - $this->migrator = app('migrator'); + $this->migrator = app('migrator'); $this->migration_paths = collect($this->migrator->paths()); } @@ -44,11 +42,11 @@ public function handle(): void { // drop tables $this->components->task('Dropping all tables', fn () => $this->callSilent('db:wipe', array_filter([ - '--database' => $this->option('database'), - '--drop-views' => $this->option('drop-views'), - '--drop-types' => $this->option('drop-types'), - '--force' => true, - ])) == 0); + '--database' => $this->option('database'), + '--drop-views' => $this->option('drop-views'), + '--drop-types' => $this->option('drop-types'), + '--force' => true, + ])) == 0); // create migration table $this->call('migrate:install', array_filter([ @@ -60,13 +58,13 @@ public function handle(): void ->reject(fn (string $path) => str_starts_with($path, config('modules.paths.modules'))); if ($root_paths->count() > 0) { - $this->components->twoColumnDetail("Running Migration of Root"); + $this->components->twoColumnDetail('Running Migration of Root'); $this->call('migrate', array_filter([ - '--path' => $root_paths->toArray(), + '--path' => $root_paths->toArray(), '--database' => $this->option('database'), - '--pretend' => $this->option('pretend'), - '--force' => $this->option('force'), + '--pretend' => $this->option('pretend'), + '--force' => $this->option('force'), '--realpath' => true, ])); } @@ -79,17 +77,15 @@ public function executeAction($name): void $module = $this->getModuleModel($name); $this->call('module:migrate', array_filter([ - 'module' => $module->getStudlyName(), + 'module' => $module->getStudlyName(), '--database' => $this->option('database'), - '--force' => $this->option('force'), - '--seed' => $this->option('seed'), + '--force' => $this->option('force'), + '--seed' => $this->option('seed'), ])); } /** * Get the console command options. - * - * @return array */ protected function getOptions(): array { diff --git a/src/Commands/Database/MigrateRefreshCommand.php b/src/Commands/Database/MigrateRefreshCommand.php index 995e557bd..29aceb060 100644 --- a/src/Commands/Database/MigrateRefreshCommand.php +++ b/src/Commands/Database/MigrateRefreshCommand.php @@ -27,15 +27,15 @@ public function executeAction($name): void $this->components->task("Refreshing Migration {$module->getName()} module", function () use ($module) { $this->call('module:migrate-reset', [ - 'module' => $module->getStudlyName(), + 'module' => $module->getStudlyName(), '--database' => $this->option('database'), - '--force' => $this->option('force'), + '--force' => $this->option('force'), ]); $this->call('module:migrate', [ - 'module' => $module->getStudlyName(), + 'module' => $module->getStudlyName(), '--database' => $this->option('database'), - '--force' => $this->option('force'), + '--force' => $this->option('force'), ]); if ($this->option('seed')) { @@ -49,8 +49,6 @@ public function executeAction($name): void /** * Get the console command options. - * - * @return array */ protected function getOptions(): array { diff --git a/src/Commands/Database/MigrateResetCommand.php b/src/Commands/Database/MigrateResetCommand.php index 58569b23e..1d71430c3 100644 --- a/src/Commands/Database/MigrateResetCommand.php +++ b/src/Commands/Database/MigrateResetCommand.php @@ -50,7 +50,7 @@ public function executeAction($name): void $this->components->warn("Nothing to rollback on module {$module->getName()}"); } - public function getInfo(): string|null + public function getInfo(): ?string { return null; } diff --git a/src/Commands/Database/MigrateRollbackCommand.php b/src/Commands/Database/MigrateRollbackCommand.php index 3d48fbf37..c7bf80f19 100644 --- a/src/Commands/Database/MigrateRollbackCommand.php +++ b/src/Commands/Database/MigrateRollbackCommand.php @@ -41,7 +41,7 @@ public function executeAction($name): void if (count($migrated)) { foreach ($migrated as $migration) { - $this->components->task("Rollback: {$migration}", ); + $this->components->task("Rollback: {$migration}"); } return; @@ -51,7 +51,7 @@ public function executeAction($name): void } - public function getInfo(): string|null + public function getInfo(): ?string { return null; } diff --git a/src/Commands/Database/MigrateStatusCommand.php b/src/Commands/Database/MigrateStatusCommand.php index 83fae9cf5..70ab2205f 100644 --- a/src/Commands/Database/MigrateStatusCommand.php +++ b/src/Commands/Database/MigrateStatusCommand.php @@ -34,12 +34,12 @@ public function executeAction($name): void $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath()); $this->call('migrate:status', [ - '--path' => $path, + '--path' => $path, '--database' => $this->option('database'), ]); } - public function getInfo(): string|null + public function getInfo(): ?string { return null; } diff --git a/src/Commands/Database/SeedCommand.php b/src/Commands/Database/SeedCommand.php index 63a6ac8f0..a3ae3fe1f 100644 --- a/src/Commands/Database/SeedCommand.php +++ b/src/Commands/Database/SeedCommand.php @@ -53,19 +53,18 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Seeding module ...'; } /** * @throws RuntimeException - * @return RepositoryInterface */ public function getModuleRepository(): RepositoryInterface { $modules = $this->laravel['modules']; - if (!$modules instanceof RepositoryInterface) { + if (! $modules instanceof RepositoryInterface) { throw new RuntimeException('Module repository not found!'); } @@ -73,11 +72,9 @@ public function getModuleRepository(): RepositoryInterface } /** - * @param $name + * @return Module * * @throws RuntimeException - * - * @return Module */ public function getModuleByName($name) { @@ -90,8 +87,6 @@ public function getModuleByName($name) } /** - * @param Module $module - * * @return void */ public function moduleSeed(Module $module) @@ -101,7 +96,7 @@ public function moduleSeed(Module $module) $config = $module->get('migration'); if (is_array($config) && array_key_exists('seeds', $config)) { - foreach ((array)$config['seeds'] as $class) { + foreach ((array) $config['seeds'] as $class) { if (class_exists($class)) { $seeders[] = $class; } @@ -133,12 +128,12 @@ public function moduleSeed(Module $module) /** * Seed the specified module. * - * @param string $className + * @param string $className */ protected function dbSeed($className) { if ($option = $this->option('class')) { - $params['--class'] = Str::finish(substr($className, 0, strrpos($className, '\\')), '\\') . $option; + $params['--class'] = Str::finish(substr($className, 0, strrpos($className, '\\')), '\\').$option; } else { $params = ['--class' => $className]; } @@ -157,8 +152,7 @@ protected function dbSeed($className) /** * Get master database seeder name for the specified module. * - * @param string $name - * + * @param string $name * @return string */ public function getSeederName($name) @@ -169,14 +163,13 @@ public function getSeederName($name) $config = GenerateConfigReader::read('seeder'); $seederPath = str_replace('/', '\\', $config->getPath()); - return $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder'; + return $namespace.'\\'.$name.'\\'.$seederPath.'\\'.$name.'DatabaseSeeder'; } /** * Get master database seeder name for the specified module under a different namespace than Modules. * - * @param string $name - * + * @param string $name * @return array $foundModules array containing namespace paths */ public function getSeederNames($name) @@ -189,7 +182,7 @@ public function getSeederNames($name) $foundModules = []; foreach ($this->laravel['modules']->config('scan.paths') as $path) { $namespace = array_slice(explode('/', $path), -1)[0]; - $foundModules[] = $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder'; + $foundModules[] = $namespace.'\\'.$name.'\\'.$seederPath.'\\'.$name.'DatabaseSeeder'; } return $foundModules; diff --git a/src/Commands/LaravelModulesV6Migrator.php b/src/Commands/LaravelModulesV6Migrator.php index f4c788af2..9766b3bfe 100644 --- a/src/Commands/LaravelModulesV6Migrator.php +++ b/src/Commands/LaravelModulesV6Migrator.php @@ -11,6 +11,7 @@ class LaravelModulesV6Migrator extends Command { protected $name = 'module:v6:migrate'; + protected $description = 'Migrate laravel-modules v5 modules statuses to v6.'; public function handle(): int diff --git a/src/Commands/Make/ActionMakeCommand.php b/src/Commands/Make/ActionMakeCommand.php index f9527bda6..58182868f 100644 --- a/src/Commands/Make/ActionMakeCommand.php +++ b/src/Commands/Make/ActionMakeCommand.php @@ -14,16 +14,18 @@ class ActionMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-action'; + protected $description = 'Create a new action class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('actions')->getPath() ?? config('modules.paths.app_folder') . 'Actions'; + $filePath = GenerateConfigReader::read('actions')->getPath() ?? config('modules.paths.app_folder').'Actions'; - return $path . $filePath . '/' . $this->getActionName() . '.php'; + return $path.$filePath.'/'.$this->getActionName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/CastMakeCommand.php b/src/Commands/Make/CastMakeCommand.php index d20e5287e..13ba40b11 100644 --- a/src/Commands/Make/CastMakeCommand.php +++ b/src/Commands/Make/CastMakeCommand.php @@ -14,16 +14,18 @@ class CastMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-cast'; + protected $description = 'Create a new Eloquent cast class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('casts')->getPath() ?? config('modules.paths.app_folder') . 'Casts'; + $filePath = GenerateConfigReader::read('casts')->getPath() ?? config('modules.paths.app_folder').'Casts'; - return $path . $filePath . '/' . $this->getCastName() . '.php'; + return $path.$filePath.'/'.$this->getCastName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/ChannelMakeCommand.php b/src/Commands/Make/ChannelMakeCommand.php index b65836fac..405d8400b 100644 --- a/src/Commands/Make/ChannelMakeCommand.php +++ b/src/Commands/Make/ChannelMakeCommand.php @@ -45,7 +45,7 @@ protected function getTemplateContents() return (new Stub('/channel.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -60,7 +60,7 @@ protected function getDestinationFilePath() $channelPath = GenerateConfigReader::read('channels'); - return $path . $channelPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$channelPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/ClassMakeCommand.php b/src/Commands/Make/ClassMakeCommand.php index 1dd42b5f0..a69ada417 100644 --- a/src/Commands/Make/ClassMakeCommand.php +++ b/src/Commands/Make/ClassMakeCommand.php @@ -46,9 +46,9 @@ public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('class')->getPath() ?? config('modules.paths.app_folder') . 'Classes'; + $filePath = GenerateConfigReader::read('class')->getPath() ?? config('modules.paths.app_folder').'Classes'; - return $this->typePath($path . $filePath . '/' . $this->getFileName() . '.php'); + return $this->typePath($path.$filePath.'/'.$this->getFileName().'.php'); } protected function getFileName(): string diff --git a/src/Commands/Make/CommandMakeCommand.php b/src/Commands/Make/CommandMakeCommand.php index d4aa9aafb..66def43bc 100644 --- a/src/Commands/Make/CommandMakeCommand.php +++ b/src/Commands/Make/CommandMakeCommand.php @@ -74,8 +74,8 @@ protected function getTemplateContents() return (new Stub('/command.stub', [ 'COMMAND_NAME' => $this->getCommandName(), - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -96,7 +96,7 @@ protected function getDestinationFilePath() $commandPath = GenerateConfigReader::read('command'); - return $path . $commandPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$commandPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/ComponentClassMakeCommand.php b/src/Commands/Make/ComponentClassMakeCommand.php index 04637fbd7..d18d9caac 100644 --- a/src/Commands/Make/ComponentClassMakeCommand.php +++ b/src/Commands/Make/ComponentClassMakeCommand.php @@ -42,6 +42,7 @@ public function handle(): int return 0; } + /** * Write the view template for the component. * @@ -49,7 +50,7 @@ public function handle(): int */ protected function writeComponentViewTemplate() { - $this->call('module:make-component-view', ['name' => $this->argument('name') , 'module' => $this->argument('module')]); + $this->call('module:make-component-view', ['name' => $this->argument('name'), 'module' => $this->argument('module')]); } public function getDefaultNamespace(): string @@ -70,6 +71,7 @@ protected function getArguments() ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], ]; } + /** * @return mixed */ @@ -78,10 +80,10 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/component-class.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), - 'LOWER_NAME' => $module->getLowerName(), - 'COMPONENT_NAME' => 'components.' . Str::lower($this->argument('name')), + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + 'LOWER_NAME' => $module->getLowerName(), + 'COMPONENT_NAME' => 'components.'.Str::lower($this->argument('name')), ]))->render(); } @@ -93,7 +95,7 @@ protected function getDestinationFilePath() $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $factoryPath = GenerateConfigReader::read('component-class'); - return $path . $factoryPath->getPath() . '/' . $this->getFileName(); + return $path.$factoryPath->getPath().'/'.$this->getFileName(); } /** @@ -101,6 +103,6 @@ protected function getDestinationFilePath() */ private function getFileName() { - return Str::studly($this->argument('name')) . '.php'; + return Str::studly($this->argument('name')).'.php'; } } diff --git a/src/Commands/Make/ComponentViewMakeCommand.php b/src/Commands/Make/ComponentViewMakeCommand.php index c797b7d65..7a75ad95a 100644 --- a/src/Commands/Make/ComponentViewMakeCommand.php +++ b/src/Commands/Make/ComponentViewMakeCommand.php @@ -63,7 +63,7 @@ protected function getDestinationFilePath() $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $factoryPath = GenerateConfigReader::read('component-view'); - return $path . $factoryPath->getPath() . '/' . $this->getFileName(); + return $path.$factoryPath->getPath().'/'.$this->getFileName(); } /** @@ -71,6 +71,6 @@ protected function getDestinationFilePath() */ private function getFileName() { - return Str::lower($this->argument('name')) . '.blade.php'; + return Str::lower($this->argument('name')).'.blade.php'; } } diff --git a/src/Commands/Make/ControllerMakeCommand.php b/src/Commands/Make/ControllerMakeCommand.php index 4fbe00de1..474c72919 100644 --- a/src/Commands/Make/ControllerMakeCommand.php +++ b/src/Commands/Make/ControllerMakeCommand.php @@ -45,7 +45,7 @@ public function getDestinationFilePath() $controllerPath = GenerateConfigReader::read('controller'); - return $path . $controllerPath->getPath() . '/' . $this->getControllerName() . '.php'; + return $path.$controllerPath->getPath().'/'.$this->getControllerName().'.php'; } /** @@ -56,16 +56,16 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'MODULENAME' => $module->getStudlyName(), - 'CONTROLLERNAME' => $this->getControllerName(), - 'NAMESPACE' => $module->getStudlyName(), - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getControllerNameWithoutNamespace(), - 'LOWER_NAME' => $module->getLowerName(), - 'MODULE' => $this->getModuleName(), - 'NAME' => $this->getModuleName(), - 'STUDLY_NAME' => $module->getStudlyName(), - 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), + 'MODULENAME' => $module->getStudlyName(), + 'CONTROLLERNAME' => $this->getControllerName(), + 'NAMESPACE' => $module->getStudlyName(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getControllerNameWithoutNamespace(), + 'LOWER_NAME' => $module->getLowerName(), + 'MODULE' => $this->getModuleName(), + 'NAME' => $this->getModuleName(), + 'STUDLY_NAME' => $module->getStudlyName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), ]))->render(); } @@ -124,6 +124,7 @@ public function getDefaultNamespace(): string /** * Get the stub file name based on the options + * * @return string */ protected function getStubName() diff --git a/src/Commands/Make/EnumMakeCommand.php b/src/Commands/Make/EnumMakeCommand.php index f3cc6d193..48d34ccdc 100644 --- a/src/Commands/Make/EnumMakeCommand.php +++ b/src/Commands/Make/EnumMakeCommand.php @@ -14,16 +14,18 @@ class EnumMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-enum'; + protected $description = 'Create a new enum class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('enums')->getPath() ?? config('modules.paths.app_folder') . 'Enums'; + $filePath = GenerateConfigReader::read('enums')->getPath() ?? config('modules.paths.app_folder').'Enums'; - return $path . $filePath . '/' . $this->getEnumName() . '.php'; + return $path.$filePath.'/'.$this->getEnumName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/EventMakeCommand.php b/src/Commands/Make/EventMakeCommand.php index 0275b5f8c..d411beb2f 100644 --- a/src/Commands/Make/EventMakeCommand.php +++ b/src/Commands/Make/EventMakeCommand.php @@ -40,11 +40,11 @@ public function getTemplateContents() public function getDestinationFilePath() { - $path = $this->laravel['modules']->getModulePath($this->getModuleName()); + $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $eventPath = GenerateConfigReader::read('event'); - return $path . $eventPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$eventPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/EventProviderMakeCommand.php b/src/Commands/Make/EventProviderMakeCommand.php index 59cfb345e..d5722dc8b 100644 --- a/src/Commands/Make/EventProviderMakeCommand.php +++ b/src/Commands/Make/EventProviderMakeCommand.php @@ -14,7 +14,9 @@ class EventProviderMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'module'; + protected $name = 'module:make-event-provider'; + protected $description = 'Create a new event service provider class for the specified module.'; public function getDestinationFilePath(): string @@ -23,7 +25,7 @@ public function getDestinationFilePath(): string $filePath = GenerateConfigReader::read('provider')->getPath(); - return $path . $filePath . '/' . $this->getEventServiceProviderName() . '.php'; + return $path.$filePath.'/'.$this->getEventServiceProviderName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -43,9 +45,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/ExceptionMakeCommand.php b/src/Commands/Make/ExceptionMakeCommand.php index 479f24dbb..343ebae6f 100644 --- a/src/Commands/Make/ExceptionMakeCommand.php +++ b/src/Commands/Make/ExceptionMakeCommand.php @@ -14,16 +14,18 @@ class ExceptionMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-exception'; + protected $description = 'Create a new exception class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('exceptions')->getPath() ?? config('modules.paths.app_folder') . 'Exceptions'; + $filePath = GenerateConfigReader::read('exceptions')->getPath() ?? config('modules.paths.app_folder').'Exceptions'; - return $path . $filePath . '/' . $this->getExceptionName() . '.php'; + return $path.$filePath.'/'.$this->getExceptionName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/FactoryMakeCommand.php b/src/Commands/Make/FactoryMakeCommand.php index 39ca32ff5..1542f7235 100644 --- a/src/Commands/Make/FactoryMakeCommand.php +++ b/src/Commands/Make/FactoryMakeCommand.php @@ -54,8 +54,8 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/factory.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'NAME' => $this->getModelName(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'NAME' => $this->getModelName(), 'MODEL_NAMESPACE' => $this->getModelNamespace(), ]))->render(); } @@ -69,7 +69,7 @@ protected function getDestinationFilePath() $factoryPath = GenerateConfigReader::read('factory'); - return $path . $factoryPath->getPath() . '/' . $this->getFileName(); + return $path.$factoryPath->getPath().'/'.$this->getFileName(); } /** @@ -77,7 +77,7 @@ protected function getDestinationFilePath() */ private function getFileName() { - return Str::studly($this->argument('name')) . 'Factory.php'; + return Str::studly($this->argument('name')).'Factory.php'; } /** @@ -90,8 +90,6 @@ private function getModelName() /** * Get default namespace. - * - * @return string */ public function getDefaultNamespace(): string { @@ -101,8 +99,6 @@ public function getDefaultNamespace(): string /** * Get model namespace. - * - * @return string */ public function getModelNamespace(): string { @@ -110,6 +106,6 @@ public function getModelNamespace(): string $path = str_replace('/', '\\', $path); - return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path; + return $this->laravel['modules']->config('namespace').'\\'.$this->laravel['modules']->findOrFail($this->getModuleName()).'\\'.$path; } } diff --git a/src/Commands/Make/GeneratorCommand.php b/src/Commands/Make/GeneratorCommand.php index b30288104..94e8e0d8b 100644 --- a/src/Commands/Make/GeneratorCommand.php +++ b/src/Commands/Make/GeneratorCommand.php @@ -40,7 +40,7 @@ public function handle(): int { $path = str_replace('\\', '/', $this->getDestinationFilePath()); - if (!$this->laravel['files']->isDirectory($dir = dirname($path))) { + if (! $this->laravel['files']->isDirectory($dir = dirname($path))) { $this->laravel['files']->makeDirectory($dir, 0777, true); } @@ -72,8 +72,6 @@ public function getClass() /** * Get default namespace. - * - * @return string */ public function getDefaultNamespace(): string { @@ -83,15 +81,14 @@ public function getDefaultNamespace(): string /** * Get class namespace. * - * @param \Nwidart\Modules\Module $module - * + * @param \Nwidart\Modules\Module $module * @return string */ public function getClassNamespace($module) { $path_namespace = $this->path_namespace(str_replace($this->getClass(), '', $this->argument($this->argumentName))); - return $this->module_namespace($module->getStudlyName(), $this->getDefaultNamespace() . ($path_namespace ? '\\' . $path_namespace : '')); + return $this->module_namespace($module->getStudlyName(), $this->getDefaultNamespace().($path_namespace ? '\\'.$path_namespace : '')); } public function module(?string $name = null): Module diff --git a/src/Commands/Make/HelperMakeCommand.php b/src/Commands/Make/HelperMakeCommand.php index 3f5dd8203..b4f1bf072 100644 --- a/src/Commands/Make/HelperMakeCommand.php +++ b/src/Commands/Make/HelperMakeCommand.php @@ -14,16 +14,18 @@ class HelperMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-helper'; + protected $description = 'Create a new helper class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('helpers')->getPath() ?? config('modules.paths.app_folder') . 'Helpers'; + $filePath = GenerateConfigReader::read('helpers')->getPath() ?? config('modules.paths.app_folder').'Helpers'; - return $path . $filePath . '/' . $this->getHelperName() . '.php'; + return $path.$filePath.'/'.$this->getHelperName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/InterfaceMakeCommand.php b/src/Commands/Make/InterfaceMakeCommand.php index 743809620..050843fc0 100644 --- a/src/Commands/Make/InterfaceMakeCommand.php +++ b/src/Commands/Make/InterfaceMakeCommand.php @@ -14,16 +14,18 @@ class InterfaceMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-interface'; + protected $description = 'Create a new interface class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('interfaces')->getPath() ?? config('modules.paths.app_folder') . 'Interfaces'; + $filePath = GenerateConfigReader::read('interfaces')->getPath() ?? config('modules.paths.app_folder').'Interfaces'; - return $path . $filePath . '/' . $this->getInterfaceName() . '.php'; + return $path.$filePath.'/'.$this->getInterfaceName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/JobMakeCommand.php b/src/Commands/Make/JobMakeCommand.php index 692e826eb..a6aa66e08 100644 --- a/src/Commands/Make/JobMakeCommand.php +++ b/src/Commands/Make/JobMakeCommand.php @@ -71,7 +71,7 @@ protected function getTemplateContents() return (new Stub($this->getStubName(), [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -86,7 +86,7 @@ protected function getDestinationFilePath() $jobPath = GenerateConfigReader::read('jobs'); - return $path . $jobPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$jobPath->getPath().'/'.$this->getFileName().'.php'; } /** @@ -97,9 +97,6 @@ private function getFileName() return Str::studly($this->argument('name')); } - /** - * @return string - */ protected function getStubName(): string { if ($this->option('sync')) { diff --git a/src/Commands/Make/ListenerMakeCommand.php b/src/Commands/Make/ListenerMakeCommand.php index 316181206..72052892f 100644 --- a/src/Commands/Make/ListenerMakeCommand.php +++ b/src/Commands/Make/ListenerMakeCommand.php @@ -76,10 +76,10 @@ public function getDefaultNamespace(): string protected function getEventName(Module $module) { - $namespace = $this->laravel['modules']->config('namespace') . "\\" . $module->getStudlyName(); + $namespace = $this->laravel['modules']->config('namespace').'\\'.$module->getStudlyName(); $eventPath = GenerateConfigReader::read('event'); - $eventName = $namespace . "\\" . $eventPath->getPath() . "\\" . $this->option('event'); + $eventName = $namespace.'\\'.$eventPath->getPath().'\\'.$this->option('event'); return str_replace('/', '\\', $eventName); } @@ -95,7 +95,7 @@ protected function getDestinationFilePath() $listenerPath = GenerateConfigReader::read('listener'); - return $path . $listenerPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$listenerPath->getPath().'/'.$this->getFileName().'.php'; } /** @@ -106,9 +106,6 @@ protected function getFileName() return Str::studly($this->argument('name')); } - /** - * @return string - */ protected function getStubName(): string { if ($this->option('queued')) { diff --git a/src/Commands/Make/MailMakeCommand.php b/src/Commands/Make/MailMakeCommand.php index 76a546593..e07f76d9b 100644 --- a/src/Commands/Make/MailMakeCommand.php +++ b/src/Commands/Make/MailMakeCommand.php @@ -58,7 +58,7 @@ protected function getTemplateContents() return (new Stub('/mail.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -73,7 +73,7 @@ protected function getDestinationFilePath() $mailPath = GenerateConfigReader::read('emails'); - return $path . $mailPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$mailPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/MiddlewareMakeCommand.php b/src/Commands/Make/MiddlewareMakeCommand.php index 5ac21805f..a31ece951 100644 --- a/src/Commands/Make/MiddlewareMakeCommand.php +++ b/src/Commands/Make/MiddlewareMakeCommand.php @@ -61,7 +61,7 @@ protected function getTemplateContents() return (new Stub('/middleware.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -74,7 +74,7 @@ protected function getDestinationFilePath() $middlewarePath = GenerateConfigReader::read('filter'); - return $path . $middlewarePath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$middlewarePath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/MigrationMakeCommand.php b/src/Commands/Make/MigrationMakeCommand.php index 2f3330f4c..7bbedfc9a 100644 --- a/src/Commands/Make/MigrationMakeCommand.php +++ b/src/Commands/Make/MigrationMakeCommand.php @@ -66,9 +66,9 @@ public function getSchemaParser() } /** - * @throws \InvalidArgumentException - * * @return mixed + * + * @throws \InvalidArgumentException */ protected function getTemplateContents() { @@ -116,7 +116,7 @@ protected function getDestinationFilePath() $generatorPath = GenerateConfigReader::read('migration'); - return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$generatorPath->getPath().'/'.$this->getFileName().'.php'; } /** @@ -124,7 +124,7 @@ protected function getDestinationFilePath() */ private function getFileName() { - return date('Y_m_d_His_') . $this->getSchemaName(); + return date('Y_m_d_His_').$this->getSchemaName(); } /** diff --git a/src/Commands/Make/ModelMakeCommand.php b/src/Commands/Make/ModelMakeCommand.php index a4a87215a..4bca6906c 100644 --- a/src/Commands/Make/ModelMakeCommand.php +++ b/src/Commands/Make/ModelMakeCommand.php @@ -53,6 +53,7 @@ public function handle(): int * Create a proper migration name: * ProductDetail: product_details * Product: products + * * @return string */ private function createMigrationName() @@ -62,7 +63,7 @@ private function createMigrationName() $string = ''; foreach ($pieces as $i => $piece) { if ($i + 1 < count($pieces)) { - $string .= strtolower($piece) . '_'; + $string .= strtolower($piece).'_'; } else { $string .= Str::plural(strtolower($piece)); } @@ -107,7 +108,7 @@ protected function getOptions() private function handleOptionalMigrationOption() { if ($this->option('migration') === true) { - $migrationName = 'create_' . $this->createMigrationName() . '_table'; + $migrationName = 'create_'.$this->createMigrationName().'_table'; $this->call('module:make-migration', ['name' => $migrationName, 'module' => $this->argument('module')]); } } @@ -184,14 +185,14 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/model.stub', [ - 'NAME' => $this->getModelName(), - 'FILLABLE' => $this->getFillable(), - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), - 'LOWER_NAME' => $module->getLowerName(), - 'MODULE' => $this->getModuleName(), - 'STUDLY_NAME' => $module->getStudlyName(), - 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), + 'NAME' => $this->getModelName(), + 'FILLABLE' => $this->getFillable(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + 'LOWER_NAME' => $module->getLowerName(), + 'MODULE' => $this->getModuleName(), + 'STUDLY_NAME' => $module->getStudlyName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), ]))->render(); } @@ -204,7 +205,7 @@ protected function getDestinationFilePath() $modelPath = GenerateConfigReader::read('model'); - return $path . $modelPath->getPath() . '/' . $this->getModelName() . '.php'; + return $path.$modelPath->getPath().'/'.$this->getModelName().'.php'; } /** @@ -222,7 +223,7 @@ private function getFillable() { $fillable = $this->option('fillable'); - if (!is_null($fillable)) { + if (! is_null($fillable)) { $arrays = explode(',', $fillable); return json_encode($arrays); @@ -233,8 +234,6 @@ private function getFillable() /** * Get default namespace. - * - * @return string */ public function getDefaultNamespace(): string { diff --git a/src/Commands/Make/ModuleMakeCommand.php b/src/Commands/Make/ModuleMakeCommand.php index 30a975e04..28b4e9b82 100644 --- a/src/Commands/Make/ModuleMakeCommand.php +++ b/src/Commands/Make/ModuleMakeCommand.php @@ -43,7 +43,7 @@ public function handle(): int ->setComponent($this->components) ->setForce($this->option('force')) ->setType($this->getModuleType()) - ->setActive(!$this->option('disabled')) + ->setActive(! $this->option('disabled')) ->setVendor($this->option('author-vendor')) ->setAuthor($this->option('author-name'), $this->option('author-email')) ->generate(); @@ -88,10 +88,10 @@ protected function getOptions() } /** - * Get module type . - * - * @return string - */ + * Get module type . + * + * @return string + */ private function getModuleType() { $isPlain = $this->option('plain'); diff --git a/src/Commands/Make/NotificationMakeCommand.php b/src/Commands/Make/NotificationMakeCommand.php index 024925619..28ccdeefa 100644 --- a/src/Commands/Make/NotificationMakeCommand.php +++ b/src/Commands/Make/NotificationMakeCommand.php @@ -45,7 +45,7 @@ protected function getTemplateContents() return (new Stub('/notification.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -60,7 +60,7 @@ protected function getDestinationFilePath() $notificationPath = GenerateConfigReader::read('notifications'); - return $path . $notificationPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$notificationPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/ObserverMakeCommand.php b/src/Commands/Make/ObserverMakeCommand.php index 50aeae979..e1ae7a0af 100644 --- a/src/Commands/Make/ObserverMakeCommand.php +++ b/src/Commands/Make/ObserverMakeCommand.php @@ -54,17 +54,15 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/observer.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'NAME' => $this->getModelName(), - 'MODEL_NAMESPACE' => $this->getModelNamespace(), - 'NAME_VARIABLE' => $this->getModelVariable(), - ]))->render(); + 'NAMESPACE' => $this->getClassNamespace($module), + 'NAME' => $this->getModelName(), + 'MODEL_NAMESPACE' => $this->getModelNamespace(), + 'NAME_VARIABLE' => $this->getModelVariable(), + ]))->render(); } /** * Get model namespace. - * - * @return string */ public function getModelNamespace(): string { @@ -72,7 +70,7 @@ public function getModelNamespace(): string $path = str_replace('/', '\\', $path); - return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path; + return $this->laravel['modules']->config('namespace').'\\'.$this->laravel['modules']->findOrFail($this->getModuleName()).'\\'.$path; } /** @@ -84,11 +82,11 @@ private function getModelName() } /** - * @return mixed|string + * @return mixed|string */ private function getModelVariable(): string { - return '$' . Str::lower($this->argument('name')); + return '$'.Str::lower($this->argument('name')); } /** @@ -100,7 +98,7 @@ protected function getDestinationFilePath() $observerPath = GenerateConfigReader::read('observer'); - return $path . $observerPath->getPath() . '/' . $this->getFileName(); + return $path.$observerPath->getPath().'/'.$this->getFileName(); } /** @@ -108,7 +106,7 @@ protected function getDestinationFilePath() */ private function getFileName() { - return Str::studly($this->argument('name')) . 'Observer.php'; + return Str::studly($this->argument('name')).'Observer.php'; } public function handle(): int @@ -122,8 +120,6 @@ public function handle(): int /** * Get default namespace. - * - * @return string */ public function getDefaultNamespace(): string { diff --git a/src/Commands/Make/PolicyMakeCommand.php b/src/Commands/Make/PolicyMakeCommand.php index fb424fbe7..c4dfd6d78 100644 --- a/src/Commands/Make/PolicyMakeCommand.php +++ b/src/Commands/Make/PolicyMakeCommand.php @@ -61,7 +61,7 @@ protected function getTemplateContents() return (new Stub('/policy.plain.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -74,7 +74,7 @@ protected function getDestinationFilePath() $policyPath = GenerateConfigReader::read('policies'); - return $path . $policyPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$policyPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/ProviderMakeCommand.php b/src/Commands/Make/ProviderMakeCommand.php index 2e579bdec..98315e3d4 100644 --- a/src/Commands/Make/ProviderMakeCommand.php +++ b/src/Commands/Make/ProviderMakeCommand.php @@ -76,19 +76,19 @@ protected function getTemplateContents() /** @var Module $module */ $module = $this->laravel['modules']->findOrFail($this->getModuleName()); - return (new Stub('/' . $stub . '.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), - 'LOWER_NAME' => $module->getLowerName(), - 'MODULE' => $this->getModuleName(), - 'NAME' => $this->getFileName(), - 'STUDLY_NAME' => $module->getStudlyName(), + return (new Stub('/'.$stub.'.stub', [ + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClass(), + 'LOWER_NAME' => $module->getLowerName(), + 'MODULE' => $this->getModuleName(), + 'NAME' => $this->getFileName(), + 'STUDLY_NAME' => $module->getStudlyName(), 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), - 'PATH_VIEWS' => GenerateConfigReader::read('views')->getPath(), - 'PATH_LANG' => GenerateConfigReader::read('lang')->getPath(), - 'PATH_CONFIG' => GenerateConfigReader::read('config')->getPath(), - 'MIGRATIONS_PATH' => GenerateConfigReader::read('migration')->getPath(), - 'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(), + 'PATH_VIEWS' => GenerateConfigReader::read('views')->getPath(), + 'PATH_LANG' => GenerateConfigReader::read('lang')->getPath(), + 'PATH_CONFIG' => GenerateConfigReader::read('config')->getPath(), + 'MIGRATIONS_PATH' => GenerateConfigReader::read('migration')->getPath(), + 'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(), ]))->render(); } @@ -101,7 +101,7 @@ protected function getDestinationFilePath() $generatorPath = GenerateConfigReader::read('provider'); - return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$generatorPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/RepositoryMakeCommand.php b/src/Commands/Make/RepositoryMakeCommand.php index 92e52cbef..7f8d14591 100644 --- a/src/Commands/Make/RepositoryMakeCommand.php +++ b/src/Commands/Make/RepositoryMakeCommand.php @@ -3,7 +3,6 @@ namespace Nwidart\Modules\Commands\Make; use Illuminate\Support\Str; -use Illuminate\Support\Stringable; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\ModuleCommandTrait; @@ -15,16 +14,18 @@ class RepositoryMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-repository'; + protected $description = 'Create a new repository class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('repository')->getPath() ?? config('modules.paths.app_folder') . 'Repositories'; + $filePath = GenerateConfigReader::read('repository')->getPath() ?? config('modules.paths.app_folder').'Repositories'; - return $path . $filePath . '/' . $this->getRepositoryName() . '.php'; + return $path.$filePath.'/'.$this->getRepositoryName().'.php'; } protected function getTemplateContents(): string @@ -32,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -45,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/RequestMakeCommand.php b/src/Commands/Make/RequestMakeCommand.php index 22a5ae517..3847e22f6 100644 --- a/src/Commands/Make/RequestMakeCommand.php +++ b/src/Commands/Make/RequestMakeCommand.php @@ -61,7 +61,7 @@ protected function getTemplateContents() return (new Stub('/request.stub', [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -74,7 +74,7 @@ protected function getDestinationFilePath() $requestPath = GenerateConfigReader::read('request'); - return $path . $requestPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$requestPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/ResourceMakeCommand.php b/src/Commands/Make/ResourceMakeCommand.php index 50766aff1..2b98f26bd 100644 --- a/src/Commands/Make/ResourceMakeCommand.php +++ b/src/Commands/Make/ResourceMakeCommand.php @@ -14,7 +14,9 @@ class ResourceMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-resource'; + protected $description = 'Create a new resource class for the specified module.'; public function getDefaultNamespace(): string @@ -52,7 +54,7 @@ protected function getTemplateContents() return (new Stub($this->getStubName(), [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -65,7 +67,7 @@ protected function getDestinationFilePath() $resourcePath = GenerateConfigReader::read('resource'); - return $path . $resourcePath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$resourcePath->getPath().'/'.$this->getFileName().'.php'; } /** @@ -78,8 +80,6 @@ private function getFileName() /** * Determine if the command is generating a resource collection. - * - * @return bool */ protected function collection(): bool { @@ -87,9 +87,6 @@ protected function collection(): bool Str::endsWith($this->argument('name'), 'Collection'); } - /** - * @return string - */ protected function getStubName(): string { if ($this->collection()) { diff --git a/src/Commands/Make/RouteProviderMakeCommand.php b/src/Commands/Make/RouteProviderMakeCommand.php index 2881019b4..cd97e019f 100644 --- a/src/Commands/Make/RouteProviderMakeCommand.php +++ b/src/Commands/Make/RouteProviderMakeCommand.php @@ -57,14 +57,14 @@ protected function getTemplateContents() $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub('/route-provider.stub', [ - 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getFileName(), - 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), - 'MODULE' => $this->getModuleName(), + 'NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getFileName(), + 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), + 'MODULE' => $this->getModuleName(), 'CONTROLLER_NAMESPACE' => $this->getControllerNameSpace(), - 'WEB_ROUTES_PATH' => $this->getWebRoutesPath(), - 'API_ROUTES_PATH' => $this->getApiRoutesPath(), - 'LOWER_NAME' => $module->getLowerName(), + 'WEB_ROUTES_PATH' => $this->getWebRoutesPath(), + 'API_ROUTES_PATH' => $this->getApiRoutesPath(), + 'LOWER_NAME' => $module->getLowerName(), ]))->render(); } @@ -87,7 +87,7 @@ protected function getDestinationFilePath() $generatorPath = GenerateConfigReader::read('provider'); - return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$generatorPath->getPath().'/'.$this->getFileName().'.php'; } /** @@ -95,7 +95,7 @@ protected function getDestinationFilePath() */ protected function getWebRoutesPath() { - return '/' . $this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php'); + return '/'.$this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php'); } /** @@ -103,7 +103,7 @@ protected function getWebRoutesPath() */ protected function getApiRoutesPath() { - return '/' . $this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php'); + return '/'.$this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php'); } public function getDefaultNamespace(): string @@ -112,9 +112,6 @@ public function getDefaultNamespace(): string ?? ltrim(config('modules.paths.generator.provider.path', 'Providers'), config('modules.paths.app_folder', '')); } - /** - * @return string - */ private function getControllerNameSpace(): string { $module = $this->laravel['modules']; diff --git a/src/Commands/Make/RuleMakeCommand.php b/src/Commands/Make/RuleMakeCommand.php index 45964221b..9242e5f4e 100644 --- a/src/Commands/Make/RuleMakeCommand.php +++ b/src/Commands/Make/RuleMakeCommand.php @@ -78,7 +78,7 @@ protected function getTemplateContents() return (new Stub($stub, [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getFileName(), + 'CLASS' => $this->getFileName(), ]))->render(); } @@ -91,7 +91,7 @@ protected function getDestinationFilePath() $rulePath = GenerateConfigReader::read('rules'); - return $path . $rulePath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$rulePath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/ScopeMakeCommand.php b/src/Commands/Make/ScopeMakeCommand.php index 476b0f9f2..eef79316c 100644 --- a/src/Commands/Make/ScopeMakeCommand.php +++ b/src/Commands/Make/ScopeMakeCommand.php @@ -14,16 +14,18 @@ class ScopeMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-scope'; + protected $description = 'Create a new scope class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('scopes')->getPath() ?? config('modules.paths.generator.model.path') . '/Scopes'; + $filePath = GenerateConfigReader::read('scopes')->getPath() ?? config('modules.paths.generator.model.path').'/Scopes'; - return $path . $filePath . '/' . $this->getScopeName() . '.php'; + return $path.$filePath.'/'.$this->getScopeName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ @@ -68,7 +67,7 @@ public function getDefaultNamespace(): string { $namespace = config('modules.paths.generator.model.path'); - $parts = explode("/", $namespace); + $parts = explode('/', $namespace); $models = end($parts); return $models.'\Scopes'; diff --git a/src/Commands/Make/SeedMakeCommand.php b/src/Commands/Make/SeedMakeCommand.php index f72b8a26c..e598eae85 100644 --- a/src/Commands/Make/SeedMakeCommand.php +++ b/src/Commands/Make/SeedMakeCommand.php @@ -73,7 +73,7 @@ protected function getDestinationFilePath(): mixed $seederPath = GenerateConfigReader::read('seeder'); - return $path . $seederPath->getPath() . '/' . $this->getSeederName() . '.php'; + return $path.$seederPath->getPath().'/'.$this->getSeederName().'.php'; } /** diff --git a/src/Commands/Make/ServiceMakeCommand.php b/src/Commands/Make/ServiceMakeCommand.php index 72e3d8f63..0f4a1cdb5 100644 --- a/src/Commands/Make/ServiceMakeCommand.php +++ b/src/Commands/Make/ServiceMakeCommand.php @@ -14,16 +14,18 @@ class ServiceMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-service'; + protected $description = 'Create a new service class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('services')->getPath() ?? config('modules.paths.app_folder') . 'Services'; + $filePath = GenerateConfigReader::read('services')->getPath() ?? config('modules.paths.app_folder').'Services'; - return $path . $filePath . '/' . $this->getServiceName() . '.php'; + return $path.$filePath.'/'.$this->getServiceName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/TestMakeCommand.php b/src/Commands/Make/TestMakeCommand.php index 6994769b7..105861903 100644 --- a/src/Commands/Make/TestMakeCommand.php +++ b/src/Commands/Make/TestMakeCommand.php @@ -14,7 +14,9 @@ class TestMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-test'; + protected $description = 'Create a new test class for the specified module.'; public function getDefaultNamespace(): string @@ -67,7 +69,7 @@ protected function getTemplateContents() return (new Stub($stub, [ 'NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClass(), + 'CLASS' => $this->getClass(), ]))->render(); } @@ -84,7 +86,7 @@ protected function getDestinationFilePath() $testPath = GenerateConfigReader::read('test-unit'); } - return $path . $testPath->getPath() . '/' . $this->getFileName() . '.php'; + return $path.$testPath->getPath().'/'.$this->getFileName().'.php'; } /** diff --git a/src/Commands/Make/TraitMakeCommand.php b/src/Commands/Make/TraitMakeCommand.php index 71632e088..7b0567d1a 100644 --- a/src/Commands/Make/TraitMakeCommand.php +++ b/src/Commands/Make/TraitMakeCommand.php @@ -14,16 +14,18 @@ class TraitMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-trait'; + protected $description = 'Create a new trait class for the specified module.'; public function getDestinationFilePath(): string { $path = $this->laravel['modules']->getModulePath($this->getModuleName()); - $filePath = GenerateConfigReader::read('traits')->getPath() ?? config('modules.paths.app_folder') . 'Traits'; + $filePath = GenerateConfigReader::read('traits')->getPath() ?? config('modules.paths.app_folder').'Traits'; - return $path . $filePath . '/' . $this->getTraitName() . '.php'; + return $path.$filePath.'/'.$this->getTraitName().'.php'; } protected function getTemplateContents(): string @@ -31,8 +33,8 @@ protected function getTemplateContents(): string $module = $this->laravel['modules']->findOrFail($this->getModuleName()); return (new Stub($this->getStubName(), [ - 'CLASS_NAMESPACE' => $this->getClassNamespace($module), - 'CLASS' => $this->getClassNameWithoutNamespace(), + 'CLASS_NAMESPACE' => $this->getClassNamespace($module), + 'CLASS' => $this->getClassNameWithoutNamespace(), ]))->render(); } @@ -44,9 +46,6 @@ protected function getArguments(): array ]; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Make/ViewMakeCommand.php b/src/Commands/Make/ViewMakeCommand.php index 5834bffc0..47b929439 100644 --- a/src/Commands/Make/ViewMakeCommand.php +++ b/src/Commands/Make/ViewMakeCommand.php @@ -14,7 +14,9 @@ class ViewMakeCommand extends GeneratorCommand use ModuleCommandTrait; protected $argumentName = 'name'; + protected $name = 'module:make-view'; + protected $description = 'Create a new view for the specified module.'; protected function getArguments(): array @@ -35,14 +37,11 @@ protected function getDestinationFilePath(): string $path = $this->laravel['modules']->getModulePath($this->getModuleName()); $factoryPath = GenerateConfigReader::read('views'); - return $path . $factoryPath->getPath() . '/' . $this->getFileName(); + return $path.$factoryPath->getPath().'/'.$this->getFileName(); } - /** - * @return string - */ private function getFileName(): string { - return Str::lower($this->argument('name')) . '.blade.php'; + return Str::lower($this->argument('name')).'.blade.php'; } } diff --git a/src/Commands/Publish/PublishCommand.php b/src/Commands/Publish/PublishCommand.php index 65622d89f..584b1e100 100644 --- a/src/Commands/Publish/PublishCommand.php +++ b/src/Commands/Publish/PublishCommand.php @@ -34,9 +34,8 @@ public function executeAction($name): void } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Publishing module asset files ...'; } - } diff --git a/src/Commands/Publish/PublishConfigurationCommand.php b/src/Commands/Publish/PublishConfigurationCommand.php index 8c62b1fbf..4ec517a29 100644 --- a/src/Commands/Publish/PublishConfigurationCommand.php +++ b/src/Commands/Publish/PublishConfigurationCommand.php @@ -26,33 +26,29 @@ public function executeAction($name): void { $this->call('vendor:publish', [ '--provider' => $this->getServiceProviderForModule($name), - '--force' => $this->option('force'), - '--tag' => ['config'], + '--force' => $this->option('force'), + '--tag' => ['config'], ]); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Publishing module config files ...'; } /** - * @param string $module - * @return string + * @param string $module */ private function getServiceProviderForModule($module): string { - $namespace = $this->laravel['config']->get('modules.namespace'); + $namespace = $this->laravel['config']->get('modules.namespace'); $studlyName = Str::studly($module); - $provider = $this->laravel['config']->get('modules.paths.generator.provider.path'); - $provider = str_replace('/', '\\', $provider); + $provider = $this->laravel['config']->get('modules.paths.generator.provider.path'); + $provider = str_replace('/', '\\', $provider); return "$namespace\\$studlyName\\$provider\\{$studlyName}ServiceProvider"; } - /** - * @return array - */ protected function getOptions(): array { return [ diff --git a/src/Commands/Publish/PublishMigrationCommand.php b/src/Commands/Publish/PublishMigrationCommand.php index 74e815ecd..159e33d4f 100644 --- a/src/Commands/Publish/PublishMigrationCommand.php +++ b/src/Commands/Publish/PublishMigrationCommand.php @@ -34,7 +34,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Publishing module migrations ...'; } diff --git a/src/Commands/Publish/PublishTranslationCommand.php b/src/Commands/Publish/PublishTranslationCommand.php index 75979036a..a018764f7 100644 --- a/src/Commands/Publish/PublishTranslationCommand.php +++ b/src/Commands/Publish/PublishTranslationCommand.php @@ -33,7 +33,7 @@ public function executeAction($name): void }); } - public function getInfo(): string|null + public function getInfo(): ?string { return 'Publishing module translations ...'; } diff --git a/src/Commands/SetupCommand.php b/src/Commands/SetupCommand.php index 470869221..53eb9897e 100644 --- a/src/Commands/SetupCommand.php +++ b/src/Commands/SetupCommand.php @@ -56,15 +56,10 @@ public function generateAssetsFolder() /** * Generate the specified directory by given $dir. - * - * @param $dir - * @param $success - * @param $error - * @return int */ protected function generateDirectory($dir, $success, $error): int { - if (!$this->laravel['files']->isDirectory($dir)) { + if (! $this->laravel['files']->isDirectory($dir)) { $this->laravel['files']->makeDirectory($dir, 0755, true, true); $this->components->info($success); diff --git a/src/Contracts/ActivatorInterface.php b/src/Contracts/ActivatorInterface.php index e6db2a88a..a226fd19c 100644 --- a/src/Contracts/ActivatorInterface.php +++ b/src/Contracts/ActivatorInterface.php @@ -8,48 +8,31 @@ interface ActivatorInterface { /** * Enables a module - * - * @param Module $module */ public function enable(Module $module): void; /** * Disables a module - * - * @param Module $module */ public function disable(Module $module): void; /** * Determine whether the given status same with a module status. - * - * @param Module $module - * @param bool $status - * - * @return bool */ public function hasStatus(Module $module, bool $status): bool; /** * Set active state for a module. - * - * @param Module $module - * @param bool $active */ public function setActive(Module $module, bool $active): void; /** * Sets a module status by its name - * - * @param string $name - * @param bool $active */ public function setActiveByName(string $name, bool $active): void; /** * Deletes a module activation status - * - * @param Module $module */ public function delete(Module $module): void; diff --git a/src/Contracts/RepositoryInterface.php b/src/Contracts/RepositoryInterface.php index af225657e..3741dbeee 100644 --- a/src/Contracts/RepositoryInterface.php +++ b/src/Contracts/RepositoryInterface.php @@ -65,7 +65,8 @@ public function count(); /** * Get all ordered modules. - * @param string $direction + * + * @param string $direction * @return mixed */ public function getOrdered($direction = 'asc'); @@ -73,8 +74,7 @@ public function getOrdered($direction = 'asc'); /** * Get modules by the given status. * - * @param int $status - * + * @param int $status * @return mixed */ public function getByStatus($status); @@ -82,7 +82,6 @@ public function getByStatus($status); /** * Find a specific module. * - * @param $name * @return Module|null */ public function find(string $name); @@ -90,7 +89,6 @@ public function find(string $name); /** * Find a specific module. If there return that, otherwise throw exception. * - * @param $name * * @return mixed */ @@ -105,17 +103,14 @@ public function getFiles(); /** * Get a specific config data from a configuration file. - * @param string $key * - * @param string|null $default + * @param string|null $default * @return mixed */ public function config(string $key, $default = null); /** * Get a module path. - * - * @return string */ public function getPath(): string; @@ -131,32 +126,26 @@ public function register(): void; /** * Get asset path for a specific module. - * - * @param string $module - * @return string */ public function assetPath(string $module): string; /** * Delete a specific module. - * @param string $module - * @return bool + * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function delete(string $module): bool; /** * Determine whether the given module is activated. - * @param string $name - * @return bool + * * @throws ModuleNotFoundException */ public function isEnabled(string $name): bool; /** * Determine whether the given module is not activated. - * @param string $name - * @return bool + * * @throws ModuleNotFoundException */ public function isDisabled(string $name): bool; diff --git a/src/Contracts/RunableInterface.php b/src/Contracts/RunableInterface.php index 0d52cf514..7cd50b66a 100644 --- a/src/Contracts/RunableInterface.php +++ b/src/Contracts/RunableInterface.php @@ -7,7 +7,7 @@ interface RunableInterface /** * Run the specified command. * - * @param string $command + * @param string $command */ public function run($command); } diff --git a/src/FileRepository.php b/src/FileRepository.php index 854984411..6dc22b7c8 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -16,7 +16,7 @@ use Nwidart\Modules\Process\Installer; use Nwidart\Modules\Process\Updater; -abstract class FileRepository implements RepositoryInterface, Countable +abstract class FileRepository implements Countable, RepositoryInterface { use Macroable; @@ -45,18 +45,22 @@ abstract class FileRepository implements RepositoryInterface, Countable * @var string */ protected $stubPath; + /** * @var UrlGenerator */ private $url; + /** * @var ConfigRepository */ private $config; + /** * @var Filesystem */ private $files; + /** * @var CacheManager */ @@ -64,8 +68,8 @@ abstract class FileRepository implements RepositoryInterface, Countable /** * The constructor. - * @param Container $app - * @param string|null $path + * + * @param string|null $path */ public function __construct(Container $app, $path = null) { @@ -80,8 +84,7 @@ public function __construct(Container $app, $path = null) /** * Add other module location. * - * @param string $path - * + * @param string $path * @return $this */ public function addLocation($path) @@ -93,8 +96,6 @@ public function addLocation($path) /** * Get all additional paths. - * - * @return array */ public function getPaths(): array { @@ -103,8 +104,6 @@ public function getPaths(): array /** * Get scanned modules paths. - * - * @return array */ public function getScanPaths(): array { @@ -126,9 +125,9 @@ public function getScanPaths(): array /** * Creates a new Module instance * - * @param Container $app - * @param string $args - * @param string $path + * @param Container $app + * @param string $args + * @param string $path * @return \Nwidart\Modules\Module */ abstract protected function createModule(...$args); @@ -161,12 +160,10 @@ public function scan() /** * Get all modules. - * - * @return array */ public function all(): array { - if (!$this->config('cache.enabled')) { + if (! $this->config('cache.enabled')) { return $this->scan(); } @@ -176,8 +173,7 @@ public function all(): array /** * Format the cached data as array of modules. * - * @param array $cached - * + * @param array $cached * @return array */ protected function formatCached($cached) @@ -207,8 +203,6 @@ public function getCached() /** * Get all modules as collection instance. - * - * @return Collection */ public function toCollection(): Collection { @@ -217,10 +211,6 @@ public function toCollection(): Collection /** * Get modules by status. - * - * @param $status - * - * @return array */ public function getByStatus($status): array { @@ -238,10 +228,6 @@ public function getByStatus($status): array /** * Determine whether the given module exist. - * - * @param $name - * - * @return bool */ public function has($name): bool { @@ -250,8 +236,6 @@ public function has($name): bool /** * Get list of enabled modules. - * - * @return array */ public function allEnabled(): array { @@ -260,8 +244,6 @@ public function allEnabled(): array /** * Get list of disabled modules. - * - * @return array */ public function allDisabled(): array { @@ -270,8 +252,6 @@ public function allDisabled(): array /** * Get count from all modules. - * - * @return int */ public function count(): int { @@ -281,9 +261,7 @@ public function count(): int /** * Get all ordered modules. * - * @param string $direction - * - * @return array + * @param string $direction */ public function getOrdered($direction = 'asc'): array { @@ -305,7 +283,7 @@ public function getOrdered($direction = 'asc'): array } /** - * @inheritDoc + * {@inheritDoc} */ public function getPath(): string { @@ -313,7 +291,7 @@ public function getPath(): string } /** - * @inheritDoc + * {@inheritDoc} */ public function register(): void { @@ -323,7 +301,7 @@ public function register(): void } /** - * @inheritDoc + * {@inheritDoc} */ public function boot(): void { @@ -333,7 +311,7 @@ public function boot(): void } /** - * @inheritDoc + * {@inheritDoc} */ public function find(string $name) { @@ -343,13 +321,11 @@ public function find(string $name) } } - return; } /** * Find a specific module, if there return that, otherwise throw exception. * - * @param $name * * @return Module * @@ -368,10 +344,6 @@ public function findOrFail(string $name) /** * Get all modules as laravel collection instance. - * - * @param $status - * - * @return Collection */ public function collections($status = 1): Collection { @@ -381,39 +353,36 @@ public function collections($status = 1): Collection /** * Get module path for a specific module. * - * @param $module * * @return string */ public function getModulePath($module) { try { - return $this->findOrFail($module)->getPath() . '/'; + return $this->findOrFail($module)->getPath().'/'; } catch (ModuleNotFoundException $e) { - return $this->getPath() . '/' . Str::studly($module) . '/'; + return $this->getPath().'/'.Str::studly($module).'/'; } } /** - * @inheritDoc + * {@inheritDoc} */ public function assetPath(string $module): string { - return $this->config('paths.assets') . '/' . $module; + return $this->config('paths.assets').'/'.$module; } /** - * @inheritDoc + * {@inheritDoc} */ public function config(string $key, $default = null) { - return $this->config->get('modules.' . $key, $default); + return $this->config->get('modules.'.$key, $default); } /** * Get storage path for module used. - * - * @return string */ public function getUsedStoragePath(): string { @@ -423,7 +392,7 @@ public function getUsedStoragePath(): string } $path = storage_path('app/modules/modules.used'); - if (!$this->getFiles()->exists($path)) { + if (! $this->getFiles()->exists($path)) { $this->getFiles()->put($path, ''); } @@ -433,7 +402,6 @@ public function getUsedStoragePath(): string /** * Set module used for cli session. * - * @param $name * * @throws ModuleNotFoundException */ @@ -456,7 +424,7 @@ public function forgetUsed() /** * Get module used for cli session. - * @return string + * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function getUsedNow(): string @@ -466,8 +434,6 @@ public function getUsedNow(): string /** * Get laravel filesystem instance. - * - * @return Filesystem */ public function getFiles(): Filesystem { @@ -476,8 +442,6 @@ public function getFiles(): Filesystem /** * Get module assets path. - * - * @return string */ public function getAssetsPath(): string { @@ -486,8 +450,9 @@ public function getAssetsPath(): string /** * Get asset url from a specific module. - * @param string $asset - * @return string + * + * @param string $asset + * * @throws InvalidAssetPath */ public function asset($asset): string @@ -495,17 +460,17 @@ public function asset($asset): string if (Str::contains($asset, ':') === false) { throw InvalidAssetPath::missingModuleName($asset); } - list($name, $url) = explode(':', $asset); + [$name, $url] = explode(':', $asset); - $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); + $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); - $url = $this->url->asset($baseUrl . "/{$name}/" . $url); + $url = $this->url->asset($baseUrl."/{$name}/".$url); return str_replace(['http://', 'https://'], '//', $url); } /** - * @inheritDoc + * {@inheritDoc} */ public function isEnabled(string $name): bool { @@ -513,17 +478,19 @@ public function isEnabled(string $name): bool } /** - * @inheritDoc + * {@inheritDoc} */ public function isDisabled(string $name): bool { - return !$this->isEnabled($name); + return ! $this->isEnabled($name); } /** * Enabling a specific module. - * @param string $name + * + * @param string $name * @return void + * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function enable($name) @@ -533,8 +500,10 @@ public function enable($name) /** * Disabling a specific module. - * @param string $name + * + * @param string $name * @return void + * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ public function disable($name) @@ -543,7 +512,7 @@ public function disable($name) } /** - * @inheritDoc + * {@inheritDoc} */ public function delete(string $name): bool { @@ -553,7 +522,7 @@ public function delete(string $name): bool /** * Update dependencies for the specified module. * - * @param string $module + * @param string $module */ public function update($module) { @@ -563,11 +532,10 @@ public function update($module) /** * Install the specified module. * - * @param string $name - * @param string $version - * @param string $type - * @param bool $subtree - * + * @param string $name + * @param string $version + * @param string $type + * @param bool $subtree * @return \Symfony\Component\Process\Process */ public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false) @@ -598,8 +566,7 @@ public function getStubPath() /** * Set stub path. * - * @param string $stubPath - * + * @param string $stubPath * @return $this */ public function setStubPath($stubPath) diff --git a/src/Generators/FileGenerator.php b/src/Generators/FileGenerator.php index 6b90d4ddf..4c935617a 100644 --- a/src/Generators/FileGenerator.php +++ b/src/Generators/FileGenerator.php @@ -27,6 +27,7 @@ class FileGenerator extends Generator * @var \Illuminate\Filesystem\Filesystem|null */ protected $filesystem; + /** * @var bool */ @@ -35,9 +36,7 @@ class FileGenerator extends Generator /** * The constructor. * - * @param $path - * @param $contents - * @param null $filesystem + * @param null $filesystem */ public function __construct($path, $contents, $filesystem = null) { @@ -59,8 +58,7 @@ public function getContents() /** * Set contents. * - * @param mixed $contents - * + * @param mixed $contents * @return $this */ public function setContents($contents) @@ -83,7 +81,6 @@ public function getFilesystem() /** * Set filesystem. * - * @param Filesystem $filesystem * * @return $this */ @@ -107,8 +104,7 @@ public function getPath() /** * Set path. * - * @param mixed $path - * + * @param mixed $path * @return $this */ public function setPath($path) @@ -131,7 +127,7 @@ public function withFileOverwrite(bool $overwrite): FileGenerator public function generate() { $path = $this->getPath(); - if (!$this->filesystem->exists($path)) { + if (! $this->filesystem->exists($path)) { return $this->filesystem->put($path, $this->getContents()); } if ($this->overwriteFile === true) { diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index fcb0dd605..8befb6287 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -88,8 +88,6 @@ class ModuleGenerator extends Generator /** * Module author - * - * @var array */ protected array $author = [ 'name', 'email', @@ -97,26 +95,19 @@ class ModuleGenerator extends Generator /** * Vendor name - * - * @var string */ protected ?string $vendor = null; /** * The constructor. - * @param $name - * @param FileRepository $module - * @param Config $config - * @param Filesystem $filesystem - * @param Console $console */ public function __construct( $name, - FileRepository $module = null, - Config $config = null, - Filesystem $filesystem = null, - Console $console = null, - ActivatorInterface $activator = null + ?FileRepository $module = null, + ?Config $config = null, + ?Filesystem $filesystem = null, + ?Console $console = null, + ?ActivatorInterface $activator = null ) { $this->name = $name; $this->config = $config; @@ -129,8 +120,7 @@ public function __construct( /** * Set type. * - * @param string $type - * + * @param string $type * @return $this */ public function setType($type) @@ -143,7 +133,6 @@ public function setType($type) /** * Set active flag. * - * @param bool $active * * @return $this */ @@ -177,8 +166,7 @@ public function getConfig() /** * Set the laravel config instance. * - * @param Config $config - * + * @param Config $config * @return $this */ public function setConfig($config) @@ -191,7 +179,6 @@ public function setConfig($config) /** * Set the modules activator * - * @param ActivatorInterface $activator * * @return $this */ @@ -215,8 +202,7 @@ public function getFilesystem() /** * Set the laravel filesystem instance. * - * @param Filesystem $filesystem - * + * @param Filesystem $filesystem * @return $this */ public function setFilesystem($filesystem) @@ -239,8 +225,7 @@ public function getConsole() /** * Set the laravel console instance. * - * @param Console $console - * + * @param Console $console * @return $this */ public function setConsole($console) @@ -250,17 +235,11 @@ public function setConsole($console) return $this; } - /** - * @return \Illuminate\Console\View\Components\Factory - */ public function getComponent(): \Illuminate\Console\View\Components\Factory { return $this->component; } - /** - * @param \Illuminate\Console\View\Components\Factory $component - */ public function setComponent(\Illuminate\Console\View\Components\Factory $component): self { $this->component = $component; @@ -281,8 +260,7 @@ public function getModule() /** * Set the module instance. * - * @param mixed $module - * + * @param mixed $module * @return $this */ public function setModule($module) @@ -295,11 +273,9 @@ public function setModule($module) /** * Setting the author from the command * - * @param string|null $name - * @param string|null $email * @return $this */ - public function setAuthor(string $name = null, string $email = null) + public function setAuthor(?string $name = null, ?string $email = null) { $this->author['name'] = $name; $this->author['email'] = $email; @@ -310,10 +286,9 @@ public function setAuthor(string $name = null, string $email = null) /** * Installing vendor from the command * - * @param string|null $vendor * @return $this */ - public function setVendor(string $vendor = null) + public function setVendor(?string $vendor = null) { $this->vendor = $vendor; @@ -343,8 +318,7 @@ public function getFiles() /** * Set force status. * - * @param bool|int $force - * + * @param bool|int $force * @return $this */ public function setForce($force) @@ -406,7 +380,7 @@ public function generateFolders() continue; } - $path = $this->module->getModulePath($this->getName()) . '/' . $folder->getPath(); + $path = $this->module->getModulePath($this->getName()).'/'.$folder->getPath(); $this->filesystem->ensureDirectoryExists($path, 0755, true); if (config('modules.stubs.gitkeep')) { @@ -418,11 +392,11 @@ public function generateFolders() /** * Generate git keep to the specified path. * - * @param string $path + * @param string $path */ public function generateGitKeep($path) { - $this->filesystem->put($path . '/.gitkeep', ''); + $this->filesystem->put($path.'/.gitkeep', ''); } /** @@ -431,10 +405,10 @@ public function generateGitKeep($path) public function generateFiles() { foreach ($this->getFiles() as $stub => $file) { - $path = $this->module->getModulePath($this->getName()) . $file; + $path = $this->module->getModulePath($this->getName()).$file; $this->component->task("Generating file {$path}", function () use ($stub, $path) { - if (!$this->filesystem->isDirectory($dir = dirname($path))) { + if (! $this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } @@ -459,14 +433,14 @@ public function generateResources() $providerGenerator = GenerateConfigReader::read('provider'); if ($providerGenerator->generate() === true) { $this->console->call('module:make-provider', [ - 'name' => $this->getName() . 'ServiceProvider', + 'name' => $this->getName().'ServiceProvider', 'module' => $this->getName(), '--master' => true, ]); } else { // delete register ServiceProvider on module.json - $path = $this->module->getModulePath($this->getName()) . DIRECTORY_SEPARATOR . 'module.json'; - $module_file = $this->filesystem->get($path); + $path = $this->module->getModulePath($this->getName()).DIRECTORY_SEPARATOR.'module.json'; + $module_file = $this->filesystem->get($path); $this->filesystem->put( $path, preg_replace('/"providers": \[.*?\],/s', '"providers": [ ],', $module_file) @@ -476,7 +450,7 @@ public function generateResources() $eventGeneratorConfig = GenerateConfigReader::read('event-provider'); if ( (is_null($eventGeneratorConfig->getPath()) && $providerGenerator->generate()) - || (!is_null($eventGeneratorConfig->getPath()) && $eventGeneratorConfig->generate()) + || (! is_null($eventGeneratorConfig->getPath()) && $eventGeneratorConfig->generate()) ) { $this->console->call('module:make-event-provider', [ 'module' => $this->getName(), @@ -487,7 +461,7 @@ public function generateResources() $this->filesystem->replaceInFile( '$this->app->register(Event', '// $this->app->register(Event', - $this->module->getModulePath($this->getName()) . DIRECTORY_SEPARATOR . $providerGenerator->getPath() . DIRECTORY_SEPARATOR . sprintf('%sServiceProvider.php', $this->getName()) + $this->module->getModulePath($this->getName()).DIRECTORY_SEPARATOR.$providerGenerator->getPath().DIRECTORY_SEPARATOR.sprintf('%sServiceProvider.php', $this->getName()) ); } } @@ -495,7 +469,7 @@ public function generateResources() $routeGeneratorConfig = GenerateConfigReader::read('route-provider'); if ( (is_null($routeGeneratorConfig->getPath()) && $providerGenerator->generate()) - || (!is_null($routeGeneratorConfig->getPath()) && $routeGeneratorConfig->generate()) + || (! is_null($routeGeneratorConfig->getPath()) && $routeGeneratorConfig->generate()) ) { $this->console->call('module:route-provider', [ 'module' => $this->getName(), @@ -506,7 +480,7 @@ public function generateResources() $this->filesystem->replaceInFile( '$this->app->register(Route', '// $this->app->register(Route', - $this->module->getModulePath($this->getName()) . DIRECTORY_SEPARATOR . $providerGenerator->getPath() . DIRECTORY_SEPARATOR . sprintf('%sServiceProvider.php', $this->getName()) + $this->module->getModulePath($this->getName()).DIRECTORY_SEPARATOR.$providerGenerator->getPath().DIRECTORY_SEPARATOR.sprintf('%sServiceProvider.php', $this->getName()) ); } } @@ -514,7 +488,7 @@ public function generateResources() if (GenerateConfigReader::read('controller')->generate() === true) { $options = $this->type == 'api' ? ['--api' => true] : []; $this->console->call('module:make-controller', [ - 'controller' => $this->getName() . 'Controller', + 'controller' => $this->getName().'Controller', 'module' => $this->getName(), ] + $options); } @@ -523,14 +497,13 @@ public function generateResources() /** * Get the contents of the specified stub file by given stub name. * - * @param $stub * * @return string */ protected function getStubContents($stub) { return (new Stub( - '/' . $stub . '.stub', + '/'.$stub.'.stub', $this->getReplacement($stub) ) )->render(); @@ -547,7 +520,6 @@ public function getReplacements() /** * Get array replacement for the specified stub. * - * @param $stub * * @return array */ @@ -555,11 +527,11 @@ protected function getReplacement($stub) { $replacements = $this->module->config('stubs.replacements'); - if (!isset($replacements['composer']['APP_FOLDER_NAME'])) { + if (! isset($replacements['composer']['APP_FOLDER_NAME'])) { $replacements['composer'][] = 'APP_FOLDER_NAME'; } - if (!isset($replacements[$stub])) { + if (! isset($replacements[$stub])) { return []; } @@ -573,7 +545,7 @@ protected function getReplacement($stub) } } foreach ($keys as $key) { - if (method_exists($this, $method = 'get' . ucfirst(Str::studly(strtolower($key))) . 'Replacement')) { + if (method_exists($this, $method = 'get'.ucfirst(Str::studly(strtolower($key))).'Replacement')) { $replaces[$key] = $this->$method(); } else { $replaces[$key] = null; @@ -588,10 +560,10 @@ protected function getReplacement($stub) */ private function generateModuleJsonFile() { - $path = $this->module->getModulePath($this->getName()) . 'module.json'; + $path = $this->module->getModulePath($this->getName()).'module.json'; $this->component->task("Generating file $path", function () use ($path) { - if (!$this->filesystem->isDirectory($dir = dirname($path))) { + if (! $this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } @@ -605,13 +577,13 @@ private function generateModuleJsonFile() */ private function cleanModuleJsonFile() { - $path = $this->module->getModulePath($this->getName()) . 'module.json'; + $path = $this->module->getModulePath($this->getName()).'module.json'; $content = $this->filesystem->get($path); $namespace = $this->getModuleNamespaceReplacement(); $studlyName = $this->getStudlyNameReplacement(); - $provider = '"' . $namespace . '\\\\' . $studlyName . '\\\\Providers\\\\' . $studlyName . 'ServiceProvider"'; + $provider = '"'.$namespace.'\\\\'.$studlyName.'\\\\Providers\\\\'.$studlyName.'ServiceProvider"'; $content = str_replace($provider, '', $content); @@ -697,7 +669,7 @@ protected function getAuthorEmailReplacement() */ protected function getAppFolderNameReplacement() { - return $this->module->config('paths.app_folder'); + return $this->module->config('paths.app_folder'); } protected function getProviderNamespaceReplacement(): string diff --git a/src/Json.php b/src/Json.php index 1aa0f1120..eaf94063b 100644 --- a/src/Json.php +++ b/src/Json.php @@ -31,10 +31,9 @@ class Json /** * The constructor. * - * @param mixed $path - * @param \Illuminate\Filesystem\Filesystem $filesystem + * @param mixed $path */ - public function __construct($path, Filesystem $filesystem = null) + public function __construct($path, ?Filesystem $filesystem = null) { $this->path = (string) $path; $this->filesystem = $filesystem ?: new Filesystem(); @@ -54,7 +53,6 @@ public function getFilesystem() /** * Set filesystem. * - * @param Filesystem $filesystem * * @return $this */ @@ -78,8 +76,7 @@ public function getPath() /** * Set path. * - * @param mixed $path - * + * @param mixed $path * @return $this */ public function setPath($path) @@ -92,12 +89,10 @@ public function setPath($path) /** * Make new instance. * - * @param string $path - * @param \Illuminate\Filesystem\Filesystem $filesystem - * + * @param string $path * @return static */ - public static function make($path, Filesystem $filesystem = null) + public static function make($path, ?Filesystem $filesystem = null) { return new static($path, $filesystem); } @@ -116,15 +111,16 @@ public function getContents() * Decode contents as array. * * @return array + * * @throws InvalidJsonException */ public function decodeContents() { - $attributes = json_decode($this->getContents(), 1); + $attributes = json_decode($this->getContents(), 1); // any JSON parsing errors should throw an exception if (json_last_error() > 0) { - throw new InvalidJsonException('Error processing file: ' . $this->getPath() . '. Error: ' . json_last_error_msg()); + throw new InvalidJsonException('Error processing file: '.$this->getPath().'. Error: '.json_last_error_msg()); } return $attributes; @@ -133,7 +129,9 @@ public function decodeContents() /** * Get file contents as array, either from the cache or from * the json content file if the cache is disabled. + * * @return array + * * @throws \Exception */ public function getAttributes() @@ -150,11 +148,10 @@ public function getAttributes() /** * Convert the given array data to pretty json. * - * @param array $data * * @return string */ - public function toJsonPretty(array $data = null) + public function toJsonPretty(?array $data = null) { return json_encode($data ?: $this->attributes, JSON_PRETTY_PRINT); } @@ -162,7 +159,6 @@ public function toJsonPretty(array $data = null) /** * Update json contents from array data. * - * @param array $data * * @return bool */ @@ -176,9 +172,8 @@ public function update(array $data) /** * Set a specific key & value. * - * @param string $key - * @param mixed $value - * + * @param string $key + * @param mixed $value * @return $this */ public function set($key, $value) @@ -201,8 +196,7 @@ public function save() /** * Handle magic method __get. * - * @param string $key - * + * @param string $key * @return mixed */ public function __get($key) @@ -213,9 +207,7 @@ public function __get($key) /** * Get the specified attribute from json file. * - * @param $key - * @param null $default - * + * @param null $default * @return mixed */ public function get($key, $default = null) @@ -226,9 +218,8 @@ public function get($key, $default = null) /** * Handle call to __call method. * - * @param string $method - * @param array $arguments - * + * @param string $method + * @param array $arguments * @return mixed */ public function __call($method, $arguments = []) diff --git a/src/Laravel/Module.php b/src/Laravel/Module.php index d545f977e..019c81be3 100644 --- a/src/Laravel/Module.php +++ b/src/Laravel/Module.php @@ -17,11 +17,11 @@ public function getCachedServicesPath(): string { // This checks if we are running on a Laravel Vapor managed instance // and sets the path to a writable one (services path is not on a writable storage in Vapor). - if (!is_null(env('VAPOR_MAINTENANCE_MODE', null))) { - return Str::replaceLast('config.php', $this->getSnakeName() . '_module.php', $this->app->getCachedConfigPath()); + if (! is_null(env('VAPOR_MAINTENANCE_MODE', null))) { + return Str::replaceLast('config.php', $this->getSnakeName().'_module.php', $this->app->getCachedConfigPath()); } - return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->getCachedServicesPath()); + return Str::replaceLast('services.php', $this->getSnakeName().'_module.php', $this->app->getCachedServicesPath()); } /** diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index 3ca1e564c..7fd540e85 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -32,7 +32,7 @@ public function register() $this->setupStubPath(); $this->registerProviders(); - $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'modules'); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules'); } /** @@ -40,7 +40,7 @@ public function register() */ public function setupStubPath() { - $path = $this->app['config']->get('modules.stubs.path') ?? __DIR__ . '/Commands/stubs'; + $path = $this->app['config']->get('modules.stubs.path') ?? __DIR__.'/Commands/stubs'; Stub::setBasePath($path); $this->app->booted(function ($app) { @@ -64,7 +64,7 @@ protected function registerServices() }); $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { $activator = $app['config']->get('modules.activator'); - $class = $app['config']->get('modules.activators.' . $activator)['class']; + $class = $app['config']->get('modules.activators.'.$activator)['class']; if ($class === null) { throw InvalidActivatorClass::missingConfig(); diff --git a/src/Lumen/Module.php b/src/Lumen/Module.php index a25013606..0e477aeb6 100644 --- a/src/Lumen/Module.php +++ b/src/Lumen/Module.php @@ -12,7 +12,7 @@ class Module extends BaseModule */ public function getCachedServicesPath(): string { - return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->basePath('storage/app/') . 'services.php'); + return Str::replaceLast('services.php', $this->getSnakeName().'_module.php', $this->app->basePath('storage/app/').'services.php'); } /** diff --git a/src/LumenModulesServiceProvider.php b/src/LumenModulesServiceProvider.php index 462a48092..aedb0b217 100644 --- a/src/LumenModulesServiceProvider.php +++ b/src/LumenModulesServiceProvider.php @@ -30,7 +30,7 @@ public function register() */ public function setupStubPath() { - Stub::setBasePath(__DIR__ . '/Commands/stubs'); + Stub::setBasePath(__DIR__.'/Commands/stubs'); if (app('modules')->config('stubs.enabled') === true) { Stub::setBasePath(app('modules')->config('stubs.path')); @@ -49,7 +49,7 @@ protected function registerServices() }); $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { $activator = $app['config']->get('modules.activator'); - $class = $app['config']->get('modules.activators.' . $activator)['class']; + $class = $app['config']->get('modules.activators.'.$activator)['class']; return new $class($app); }); diff --git a/src/Migrations/Migrator.php b/src/Migrations/Migrator.php index 982f491ff..5467b1128 100644 --- a/src/Migrations/Migrator.php +++ b/src/Migrations/Migrator.php @@ -12,6 +12,7 @@ class Migrator { /** * Module instance. + * * @var Module */ protected $module; @@ -27,6 +28,7 @@ class Migrator * Optional subpath for specific migration file. * * @var string|null + * * @example subpath 2000_01_01_000000_create_example_table.php */ protected $subpath = ''; @@ -40,9 +42,8 @@ class Migrator /** * Create new instance. - * @param Module $module - * @param Application $application - * @param string|null $subpath + * + * @param string|null $subpath */ public function __construct(Module $module, Application $application, $subpath = null) { @@ -54,7 +55,6 @@ public function __construct(Module $module, Application $application, $subpath = /** * Set the database connection to be used * - * @param $database * * @return $this */ @@ -93,15 +93,15 @@ public function getPath() /** * Get migration files. * - * @param boolean $reverse + * @param bool $reverse * @return array */ public function getMigrations($reverse = false) { - if (!empty($this->subpath)) { - $files = $this->laravel['files']->glob($this->getPath() . '/' . $this->subpath); + if (! empty($this->subpath)) { + $files = $this->laravel['files']->glob($this->getPath().'/'.$this->subpath); } else { - $files = $this->laravel['files']->glob($this->getPath() . '/*_*.php'); + $files = $this->laravel['files']->glob($this->getPath().'/*_*.php'); } // Once we have the array of files in the directory we will just remove the @@ -186,7 +186,7 @@ public function reset() /** * Run down schema from the given migration name. * - * @param string $migration + * @param string $migration */ public function down($migration) { @@ -196,7 +196,7 @@ public function down($migration) /** * Run up schema from the given migration name. * - * @param string $migration + * @param string $migration */ public function up($migration) { @@ -206,8 +206,7 @@ public function up($migration) /** * Resolve a migration instance from a file. * - * @param string $file - * + * @param string $file * @return object */ public function resolve($file) @@ -216,8 +215,8 @@ public function resolve($file) $class = Str::studly($name); - if (!class_exists($class) && file_exists($this->getPath() . '/' . $file . '.php')) { - return include $this->getPath() . '/' . $file . '.php'; + if (! class_exists($class) && file_exists($this->getPath().'/'.$file.'.php')) { + return include $this->getPath().'/'.$file.'.php'; } return new $class(); @@ -225,14 +224,12 @@ public function resolve($file) /** * Require in all the migration files in a given path. - * - * @param array $files */ public function requireFiles(array $files) { $path = $this->getPath(); foreach ($files as $file) { - $this->laravel['files']->requireOnce($path . '/' . $file . '.php'); + $this->laravel['files']->requireOnce($path.'/'.$file.'.php'); } } @@ -249,8 +246,7 @@ public function table() /** * Find migration data from database by given migration name. * - * @param string $migration - * + * @param string $migration * @return object */ public function find($migration) @@ -261,8 +257,7 @@ public function find($migration) /** * Save new migration to database. * - * @param string $migration - * + * @param string $migration * @return mixed */ public function log($migration) @@ -286,7 +281,7 @@ public function getNextBatchNumber() /** * Get the last migration batch number. * - * @param array|null $migrations + * @param array|null $migrations * @return int */ public function getLastBatchNumber($migrations = null) @@ -303,8 +298,7 @@ public function getLastBatchNumber($migrations = null) /** * Get the last migration batch. * - * @param array $migrations - * + * @param array $migrations * @return Collection */ public function getLast($migrations) diff --git a/src/Module.php b/src/Module.php index 2dc37a9a1..aa75af6d4 100644 --- a/src/Module.php +++ b/src/Module.php @@ -24,8 +24,6 @@ abstract class Module /** * The module name. - * - * @var */ protected $name; @@ -40,18 +38,22 @@ abstract class Module * @var array of cached Json objects, keyed by filename */ protected $moduleJson = []; + /** * @var CacheManager */ private $cache; + /** * @var Filesystem */ private $files; + /** * @var Translator */ private $translator; + /** * @var ActivatorInterface */ @@ -59,9 +61,6 @@ abstract class Module /** * The constructor. - * @param Container $app - * @param $name - * @param $path */ public function __construct(Container $app, string $name, $path) { @@ -76,8 +75,6 @@ public function __construct(Container $app, string $name, $path) /** * Returns an array of assets - * - * @return array */ public static function getAssets(): array { @@ -105,8 +102,6 @@ public static function getAssets(): array /** * Get name. - * - * @return string */ public function getName(): string { @@ -115,8 +110,6 @@ public function getName(): string /** * Get name in lower case. - * - * @return string */ public function getLowerName(): string { @@ -125,8 +118,6 @@ public function getLowerName(): string /** * Get name in studly case. - * - * @return string */ public function getStudlyName(): string { @@ -135,8 +126,6 @@ public function getStudlyName(): string /** * Get name in snake case. - * - * @return string */ public function getSnakeName(): string { @@ -145,8 +134,6 @@ public function getSnakeName(): string /** * Get description. - * - * @return string */ public function getDescription(): string { @@ -155,8 +142,6 @@ public function getDescription(): string /** * Get priority. - * - * @return string */ public function getPriority(): string { @@ -165,8 +150,6 @@ public function getPriority(): string /** * Get path. - * - * @return string */ public function getPath(): string { @@ -175,8 +158,6 @@ public function getPath(): string /** * Get app path. - * - * @return string */ public function getAppPath(): string { @@ -188,8 +169,7 @@ public function getAppPath(): string /** * Set path. * - * @param string $path - * + * @param string $path * @return $this */ public function setPath($path): Module @@ -217,14 +197,12 @@ public function boot(): void /** * Register module's translation. - * - * @return void */ protected function registerTranslation(): void { $lowerName = $this->getLowerName(); - $langPath = $this->getPath() . '/Resources/lang'; + $langPath = $this->getPath().'/Resources/lang'; if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $lowerName); @@ -234,9 +212,7 @@ protected function registerTranslation(): void /** * Get json contents from the cache, setting as needed. * - * @param string $file - * - * @return Json + * @param string $file */ public function json($file = null): Json { @@ -245,16 +221,14 @@ public function json($file = null): Json } return Arr::get($this->moduleJson, $file, function () use ($file) { - return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->files); + return $this->moduleJson[$file] = new Json($this->getPath().'/'.$file, $this->files); }); } /** * Get a specific data from json file by given the key. * - * @param string $key - * @param null $default - * + * @param null $default * @return mixed */ public function get(string $key, $default = null) @@ -265,9 +239,7 @@ public function get(string $key, $default = null) /** * Get a specific data from composer.json file by given the key. * - * @param $key - * @param null $default - * + * @param null $default * @return mixed */ public function getComposerAttr($key, $default = null) @@ -294,11 +266,11 @@ public function register(): void /** * Register the module event. * - * @param string $event + * @param string $event */ protected function fireEvent($event): void { - $this->app['events']->dispatch(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]); + $this->app['events']->dispatch(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]); } /** @@ -313,8 +285,6 @@ abstract public function registerProviders(): void; /** * Get the path to the cached *_module.php file. - * - * @return string */ abstract public function getCachedServicesPath(): string; @@ -324,7 +294,7 @@ abstract public function getCachedServicesPath(): string; protected function registerFiles(): void { foreach ($this->get('files', []) as $file) { - include $this->path . '/' . $file; + include $this->path.'/'.$file; } } @@ -340,10 +310,6 @@ public function __toString() /** * Determine whether the given status same with the current module status. - * - * @param bool $status - * - * @return bool */ public function isStatus(bool $status): bool { @@ -352,8 +318,6 @@ public function isStatus(bool $status): bool /** * Determine whether the current module activated. - * - * @return bool */ public function isEnabled(): bool { @@ -362,20 +326,14 @@ public function isEnabled(): bool /** * Determine whether the current module not disabled. - * - * @return bool */ public function isDisabled(): bool { - return !$this->isEnabled(); + return ! $this->isEnabled(); } /** * Set active state for current module. - * - * @param bool $active - * - * @return void */ public function setActive(bool $active): void { @@ -410,8 +368,6 @@ public function enable(): void /** * Delete the current module. - * - * @return bool */ public function delete(): bool { @@ -422,26 +378,20 @@ public function delete(): bool /** * Get extra path. - * - * @param string $path - * - * @return string */ public function getExtraPath(string $path): string { - return $this->getPath() . '/' . $path; + return $this->getPath().'/'.$path; } /** * Check if can load files of module on boot method. - * - * @return bool */ protected function isLoadFilesOnBoot(): bool { return config('modules.register.files', 'register') === 'boot' && // force register method if option == boot && app is AsgardCms - !class_exists('\Modules\Core\Foundation\AsgardCms'); + ! class_exists('\Modules\Core\Foundation\AsgardCms'); } private function flushCache(): void @@ -453,10 +403,6 @@ private function flushCache(): void /** * Register a translation file namespace. - * - * @param string $path - * @param string $namespace - * @return void */ private function loadTranslationsFrom(string $path, string $namespace): void { diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index 75a7a93f1..ae6cbc1d4 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -36,8 +36,8 @@ protected function registerModules() */ protected function registerNamespaces() { - $configPath = __DIR__ . '/../config/config.php'; - $stubsPath = dirname(__DIR__) . '/src/Commands/stubs'; + $configPath = __DIR__.'/../config/config.php'; + $stubsPath = dirname(__DIR__).'/src/Commands/stubs'; $this->publishes([ $configPath => config_path('modules.php'), @@ -48,7 +48,7 @@ protected function registerNamespaces() ], 'stubs'); $this->publishes([ - __DIR__ . '/../scripts/vite-module-loader.js' => base_path('vite-module-loader.js'), + __DIR__.'/../scripts/vite-module-loader.js' => base_path('vite-module-loader.js'), ], 'vite'); } diff --git a/src/Process/Installer.php b/src/Process/Installer.php index d973bc742..be992bdb9 100644 --- a/src/Process/Installer.php +++ b/src/Process/Installer.php @@ -25,6 +25,7 @@ class Installer /** * The module repository instance. + * * @var \Nwidart\Modules\Contracts\RepositoryInterface */ protected $repository; @@ -49,10 +50,12 @@ class Installer * @var int */ protected $timeout = 3360; + /** * @var null|string */ private $type; + /** * @var bool */ @@ -61,10 +64,10 @@ class Installer /** * The constructor. * - * @param string $name - * @param string $version - * @param string $type - * @param bool $tree + * @param string $name + * @param string $version + * @param string $type + * @param bool $tree */ public function __construct($name, $version = null, $type = null, $tree = false) { @@ -77,8 +80,7 @@ public function __construct($name, $version = null, $type = null, $tree = false) /** * Set destination path. * - * @param string $path - * + * @param string $path * @return $this */ public function setPath($path) @@ -90,7 +92,7 @@ public function setPath($path) /** * Set the module repository instance. - * @param \Nwidart\Modules\Contracts\RepositoryInterface $repository + * * @return $this */ public function setRepository(RepositoryInterface $repository) @@ -103,7 +105,6 @@ public function setRepository(RepositoryInterface $repository) /** * Set console command instance. * - * @param \Illuminate\Console\Command $console * * @return $this */ @@ -117,8 +118,7 @@ public function setConsole(Command $console) /** * Set process timeout. * - * @param int $timeout - * + * @param int $timeout * @return $this */ public function setTimeout($timeout) @@ -250,10 +250,10 @@ public function getModuleName() public function getPackageName() { if (is_null($this->version)) { - return $this->name . ':dev-master'; + return $this->name.':dev-master'; } - return $this->name . ':' . $this->version; + return $this->name.':'.$this->version; } /** diff --git a/src/Process/Runner.php b/src/Process/Runner.php index bbe5c8f00..489ce677a 100644 --- a/src/Process/Runner.php +++ b/src/Process/Runner.php @@ -9,6 +9,7 @@ class Runner implements RunableInterface { /** * The module instance. + * * @var RepositoryInterface */ protected $module; @@ -21,7 +22,7 @@ public function __construct(RepositoryInterface $module) /** * Run the given command. * - * @param string $command + * @param string $command */ public function run($command) { diff --git a/src/Process/Updater.php b/src/Process/Updater.php index 7bfdda9df..e80b79f08 100644 --- a/src/Process/Updater.php +++ b/src/Process/Updater.php @@ -9,7 +9,7 @@ class Updater extends Runner /** * Update the dependencies for the specified module by given the module name. * - * @param string $module + * @param string $module */ public function update($module) { @@ -32,9 +32,6 @@ private function isComposerSilenced() return config('modules.composer.composer-output') === false ? ' --quiet' : ''; } - /** - * @param Module $module - */ private function installRequires(Module $module) { $packages = $module->getComposerAttr('require', []); @@ -44,14 +41,11 @@ private function installRequires(Module $module) $concatenatedPackages .= "\"{$name}:{$version}\" "; } - if (!empty($concatenatedPackages)) { + if (! empty($concatenatedPackages)) { $this->run("composer require {$concatenatedPackages}{$this->isComposerSilenced()}"); } } - /** - * @param Module $module - */ private function installDevRequires(Module $module) { $devPackages = $module->getComposerAttr('require-dev', []); @@ -61,14 +55,11 @@ private function installDevRequires(Module $module) $concatenatedPackages .= "\"{$name}:{$version}\" "; } - if (!empty($concatenatedPackages)) { + if (! empty($concatenatedPackages)) { $this->run("composer require --dev {$concatenatedPackages}{$this->isComposerSilenced()}"); } } - /** - * @param Module $module - */ private function copyScriptsToMainComposerJson(Module $module) { $scripts = $module->getComposerAttr('scripts', []); diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 5f8224c32..28a2f3163 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -20,8 +20,6 @@ public function provides(): array /** * Get the package default commands. - * - * @return Collection */ public static function defaultCommands(): Collection { diff --git a/src/Publishing/MigrationPublisher.php b/src/Publishing/MigrationPublisher.php index 8dd2a2576..7d03e3b2c 100644 --- a/src/Publishing/MigrationPublisher.php +++ b/src/Publishing/MigrationPublisher.php @@ -13,7 +13,6 @@ class MigrationPublisher extends AssetPublisher /** * MigrationPublisher constructor. - * @param Migrator $migrator */ public function __construct(Migrator $migrator) { diff --git a/src/Publishing/Publisher.php b/src/Publishing/Publisher.php index 433951cb6..e8416faee 100644 --- a/src/Publishing/Publisher.php +++ b/src/Publishing/Publisher.php @@ -18,6 +18,7 @@ abstract class Publisher implements PublisherInterface /** * The modules repository instance. + * * @var RepositoryInterface */ protected $repository; @@ -52,8 +53,6 @@ abstract class Publisher implements PublisherInterface /** * The constructor. - * - * @param Module $module */ public function __construct(Module $module) { @@ -96,7 +95,7 @@ public function getModule() /** * Set modules repository instance. - * @param RepositoryInterface $repository + * * @return $this */ public function setRepository(RepositoryInterface $repository) @@ -119,7 +118,6 @@ public function getRepository() /** * Set console instance. * - * @param \Illuminate\Console\Command $console * * @return $this */ @@ -169,17 +167,17 @@ abstract public function getSourcePath(); */ public function publish() { - if (!$this->console instanceof Command) { + if (! $this->console instanceof Command) { $message = "The 'console' property must instance of \\Illuminate\\Console\\Command."; throw new \RuntimeException($message); } - if (!$this->getFilesystem()->isDirectory($sourcePath = $this->getSourcePath())) { + if (! $this->getFilesystem()->isDirectory($sourcePath = $this->getSourcePath())) { return; } - if (!$this->getFilesystem()->isDirectory($destinationPath = $this->getDestinationPath())) { + if (! $this->getFilesystem()->isDirectory($destinationPath = $this->getDestinationPath())) { $this->getFilesystem()->makeDirectory($destinationPath, 0775, true); } diff --git a/src/Support/Config/GeneratorPath.php b/src/Support/Config/GeneratorPath.php index 861c957f4..70df7998f 100644 --- a/src/Support/Config/GeneratorPath.php +++ b/src/Support/Config/GeneratorPath.php @@ -9,21 +9,23 @@ class GeneratorPath use PathNamespace; private $path; + private $generate; + private $namespace; public function __construct($config) { if (is_array($config)) { - $this->path = $config['path']; - $this->generate = $config['generate']; + $this->path = $config['path']; + $this->generate = $config['generate']; $this->namespace = $config['namespace'] ?? $this->path_namespace(ltrim($config['path'], config('modules.paths.app_folder', ''))); return; } - $this->path = $config; - $this->generate = (bool) $config; + $this->path = $config; + $this->generate = (bool) $config; $this->namespace = $this->path_namespace(ltrim($config, config('modules.paths.app_folder', ''))); } diff --git a/src/Support/Migrations/NameParser.php b/src/Support/Migrations/NameParser.php index 4069b815d..3e4d7003f 100644 --- a/src/Support/Migrations/NameParser.php +++ b/src/Support/Migrations/NameParser.php @@ -47,7 +47,7 @@ class NameParser /** * The constructor. * - * @param string $name + * @param string $name */ public function __construct($name) { @@ -152,7 +152,6 @@ public function getData() /** * Determine whether the given type is same with the current schema action or type. * - * @param $type * * @return bool */ diff --git a/src/Support/Migrations/SchemaParser.php b/src/Support/Migrations/SchemaParser.php index 1ef45ae5b..924ecdfbb 100644 --- a/src/Support/Migrations/SchemaParser.php +++ b/src/Support/Migrations/SchemaParser.php @@ -37,7 +37,7 @@ class SchemaParser implements Arrayable /** * Create new instance. * - * @param string|null $schema + * @param string|null $schema */ public function __construct($schema = null) { @@ -47,8 +47,7 @@ public function __construct($schema = null) /** * Parse a string to array of formatted schema. * - * @param string $schema - * + * @param string $schema * @return array */ public function parse($schema) @@ -138,15 +137,14 @@ public function down() /** * Create field. * - * @param string $column - * @param array $attributes - * @param string $type - * + * @param string $column + * @param array $attributes + * @param string $type * @return string */ public function createField($column, $attributes, $type = 'add') { - $results = "\t\t\t" . '$table'; + $results = "\t\t\t".'$table'; foreach ($attributes as $key => $field) { if (in_array($column, $this->relationshipKeys)) { @@ -156,24 +154,23 @@ public function createField($column, $attributes, $type = 'add') } } - return $results . ';' . PHP_EOL; + return $results.';'.PHP_EOL; } /** * Add relation column. * - * @param int $key - * @param string $field - * @param string $column - * + * @param int $key + * @param string $field + * @param string $column * @return string */ protected function addRelationColumn($key, $field, $column) { if ($key === 0) { - $relatedColumn = Str::snake(class_basename($field)) . '_id'; + $relatedColumn = Str::snake(class_basename($field)).'_id'; - return "->integer('{$relatedColumn}')->unsigned();" . PHP_EOL . "\t\t\t" . "\$table->foreign('{$relatedColumn}')"; + return "->integer('{$relatedColumn}')->unsigned();".PHP_EOL."\t\t\t"."\$table->foreign('{$relatedColumn}')"; } if ($key === 1) { return "->references('{$field}')"; @@ -182,61 +179,58 @@ protected function addRelationColumn($key, $field, $column) return "->on('{$field}')"; } if (Str::contains($field, '(')) { - return '->' . $field; + return '->'.$field; } - return '->' . $field . '()'; + return '->'.$field.'()'; } /** * Format field to script. * - * @param int $key - * @param string $field - * @param string $column - * + * @param int $key + * @param string $field + * @param string $column * @return string */ protected function addColumn($key, $field, $column) { if ($this->hasCustomAttribute($column)) { - return '->' . $field; + return '->'.$field; } if ($key == 0) { - return '->' . $field . "('" . $column . "')"; + return '->'.$field."('".$column."')"; } if (Str::contains($field, '(')) { - return '->' . $field; + return '->'.$field; } - return '->' . $field . '()'; + return '->'.$field.'()'; } /** * Format field to script. * - * @param int $key - * @param string $field - * @param string $column - * + * @param int $key + * @param string $field + * @param string $column * @return string */ protected function removeColumn($key, $field, $column) { if ($this->hasCustomAttribute($column)) { - return '->' . $field; + return '->'.$field; } - return '->dropColumn(' . "'" . $column . "')"; + return '->dropColumn('."'".$column."')"; } /** * Get column name from schema. * - * @param string $schema - * + * @param string $schema * @return string */ public function getColumn($schema) @@ -247,14 +241,13 @@ public function getColumn($schema) /** * Get column attributes. * - * @param string $column - * @param string $schema - * + * @param string $column + * @param string $schema * @return array */ public function getAttributes($column, $schema) { - $fields = str_replace($column . ':', '', $schema); + $fields = str_replace($column.':', '', $schema); return $this->hasCustomAttribute($column) ? $this->getCustomAttribute($column) : explode(':', $fields); } @@ -262,8 +255,7 @@ public function getAttributes($column, $schema) /** * Determine whether the given column is exist in customAttributes array. * - * @param string $column - * + * @param string $column * @return bool */ public function hasCustomAttribute($column) @@ -274,8 +266,7 @@ public function hasCustomAttribute($column) /** * Get custom attributes value. * - * @param string $column - * + * @param string $column * @return array */ public function getCustomAttribute($column) diff --git a/src/Support/Stub.php b/src/Support/Stub.php index 3de15b089..ca6dfc18a 100644 --- a/src/Support/Stub.php +++ b/src/Support/Stub.php @@ -28,8 +28,7 @@ class Stub /** * The contructor. * - * @param string $path - * @param array $replaces + * @param string $path */ public function __construct($path, array $replaces = []) { @@ -40,9 +39,7 @@ public function __construct($path, array $replaces = []) /** * Create new self instance. * - * @param string $path - * @param array $replaces - * + * @param string $path * @return self */ public static function create($path, array $replaces = []) @@ -53,8 +50,7 @@ public static function create($path, array $replaces = []) /** * Set stub path. * - * @param string $path - * + * @param string $path * @return self */ public function setPath($path) @@ -71,15 +67,15 @@ public function setPath($path) */ public function getPath() { - $path = static::getBasePath() . $this->path; + $path = static::getBasePath().$this->path; - return file_exists($path) ? $path : __DIR__ . '/../Commands/stubs' . $this->path; + return file_exists($path) ? $path : __DIR__.'/../Commands/stubs'.$this->path; } /** * Set base path. * - * @param string $path + * @param string $path */ public static function setBasePath($path) { @@ -106,7 +102,7 @@ public function getContents() $contents = file_get_contents($this->getPath()); foreach ($this->replaces as $search => $replace) { - $contents = str_replace('$' . strtoupper($search) . '$', $replace, $contents); + $contents = str_replace('$'.strtoupper($search).'$', $replace, $contents); } return $contents; @@ -125,20 +121,18 @@ public function render() /** * Save stub to specific path. * - * @param string $path - * @param string $filename - * + * @param string $path + * @param string $filename * @return bool */ public function saveTo($path, $filename) { - return file_put_contents($path . '/' . $filename, $this->getContents()); + return file_put_contents($path.'/'.$filename, $this->getContents()); } /** * Set replacements array. * - * @param array $replaces * * @return $this */ diff --git a/src/Traits/MigrationLoaderTrait.php b/src/Traits/MigrationLoaderTrait.php index bde0dd1e6..ae274ca34 100644 --- a/src/Traits/MigrationLoaderTrait.php +++ b/src/Traits/MigrationLoaderTrait.php @@ -7,13 +7,13 @@ trait MigrationLoaderTrait /** * Include all migrations files from the specified module. * - * @param string $module + * @param string $module */ protected function loadMigrationFiles($module) { - $path = $this->laravel['modules']->getModulePath($module) . $this->getMigrationGeneratorPath(); + $path = $this->laravel['modules']->getModulePath($module).$this->getMigrationGeneratorPath(); - $files = $this->laravel['files']->glob($path . '/*_*.php'); + $files = $this->laravel['files']->glob($path.'/*_*.php'); foreach ($files as $file) { $this->laravel['files']->requireOnce($file); diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php index d0680bcd2..6467ad56c 100644 --- a/src/Traits/PathNamespace.php +++ b/src/Traits/PathNamespace.php @@ -35,8 +35,8 @@ public function path_namespace(string $path): string */ public function module_namespace(string $module, ?string $path = null): string { - $module_namespace = config('modules.namespace', $this->path_namespace(config('modules.paths.modules'))) . '\\' . ($module); - $module_namespace .= strlen($path) ? '\\' . $this->path_namespace($path) : ''; + $module_namespace = config('modules.namespace', $this->path_namespace(config('modules.paths.modules'))).'\\'.($module); + $module_namespace .= strlen($path) ? '\\'.$this->path_namespace($path) : ''; return $this->studly_namespace($module_namespace); } @@ -56,7 +56,7 @@ public function app_path(?string $path = null): string { $config_path = config('modules.paths.app_folder'); $app_path = strlen($config_path) ? trim($config_path, '/') : 'app'; - $app_path .= strlen($path) ? '/' . $path : ''; + $app_path .= strlen($path) ? '/'.$path : ''; return $this->clean_path($app_path); } diff --git a/src/helpers.php b/src/helpers.php index 166d9d036..8d39f267e 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -8,7 +8,7 @@ function module_path($name, $path = '') { $module = app('modules')->find($name); - return $module->getPath() . ($path ? DIRECTORY_SEPARATOR . $path : $path); + return $module->getPath().($path ? DIRECTORY_SEPARATOR.$path : $path); } } @@ -16,12 +16,12 @@ function module_path($name, $path = '') /** * Get the configuration path. * - * @param string $path + * @param string $path * @return string */ function config_path($path = '') { - return app()->basePath() . '/config' . ($path ? DIRECTORY_SEPARATOR . $path : $path); + return app()->basePath().'/config'.($path ? DIRECTORY_SEPARATOR.$path : $path); } } @@ -34,7 +34,7 @@ function config_path($path = '') */ function public_path($path = '') { - return app()->make('path.public') . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path); + return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path); } } diff --git a/tests/Activators/FileActivatorTest.php b/tests/Activators/FileActivatorTest.php index 139de5f6a..1ac75197d 100644 --- a/tests/Activators/FileActivatorTest.php +++ b/tests/Activators/FileActivatorTest.php @@ -28,7 +28,7 @@ class FileActivatorTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->module = new TestModule($this->app, 'Recipe', __DIR__ . '/stubs/valid/Recipe'); + $this->module = new TestModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'); $this->finder = $this->app['files']; $this->activator = new FileActivator($this->app); } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index e43f49236..7d69a8c51 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -35,11 +35,11 @@ protected function getPackageProviders($app) /** * Set up the environment. * - * @param \Illuminate\Foundation\Application $app + * @param \Illuminate\Foundation\Application $app */ protected function getEnvironmentSetUp($app) { - $module_config = require __DIR__ . '/../config/config.php'; + $module_config = require __DIR__.'/../config/config.php'; // enable all generators array_walk($module_config['paths']['generator'], function (&$item) { @@ -49,17 +49,17 @@ protected function getEnvironmentSetUp($app) $app['config']->set('app.asset_url', null); $app['config']->set('database.default', 'sqlite'); $app['config']->set('database.connections.sqlite', [ - 'driver' => 'sqlite', + 'driver' => 'sqlite', 'database' => ':memory:', - 'prefix' => '', + 'prefix' => '', ]); $app['config']->set('modules.paths.modules', base_path('modules')); $app['config']->set('modules.paths', [ - 'modules' => base_path('modules'), - 'assets' => public_path('modules'), - 'migration' => base_path('database/migrations'), + 'modules' => base_path('modules'), + 'assets' => public_path('modules'), + 'migration' => base_path('database/migrations'), 'app_folder' => $module_config['paths']['app_folder'], - 'generator' => $module_config['paths']['generator'], + 'generator' => $module_config['paths']['generator'], ]); $app['config']->set('modules.composer-output', true); @@ -79,7 +79,7 @@ protected function createModule(string $moduleName = 'Blog'): int protected function getModuleAppPath(string $moduleName = 'Blog'): string { - return base_path("modules/$moduleName/") . rtrim(config('modules.paths.app_folder'), '/'); + return base_path("modules/$moduleName/").rtrim(config('modules.paths.app_folder'), '/'); } protected function getModuleBasePath(string $moduleName = 'Blog'): string diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 784313b39..5b6f755b4 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -9,8 +9,8 @@ class CollectionTest extends BaseTestCase { public function test_toArraySetsPathAttribute() { - $moduleOnePath = __DIR__ . '/stubs/valid/Recipe'; - $moduleTwoPath = __DIR__ . '/stubs/valid/Requirement'; + $moduleOnePath = __DIR__.'/stubs/valid/Recipe'; + $moduleTwoPath = __DIR__.'/stubs/valid/Requirement'; $modules = [ new Module($this->app, 'module-one', $moduleOnePath), new Module($this->app, 'module-two', $moduleTwoPath), @@ -27,8 +27,8 @@ public function test_toArraySetsPathAttribute() public function test_getItemsReturnsTheCollectionItems() { $modules = [ - new Module($this->app, 'module-one', __DIR__ . '/stubs/valid/Recipe'), - new Module($this->app, 'module-two', __DIR__ . '/stubs/valid/Requirement'), + new Module($this->app, 'module-one', __DIR__.'/stubs/valid/Recipe'), + new Module($this->app, 'module-two', __DIR__.'/stubs/valid/Requirement'), ]; $collection = new Collection($modules); $items = $collection->getItems(); diff --git a/tests/Commands/Actions/ModuleDeleteCommandTest.php b/tests/Commands/Actions/ModuleDeleteCommandTest.php index 33bf9868c..85d454733 100644 --- a/tests/Commands/Actions/ModuleDeleteCommandTest.php +++ b/tests/Commands/Actions/ModuleDeleteCommandTest.php @@ -15,6 +15,7 @@ class ModuleDeleteCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var FileActivator */ @@ -23,7 +24,7 @@ class ModuleDeleteCommandTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->finder = $this->app['files']; + $this->finder = $this->app['files']; $this->activator = new FileActivator($this->app); } @@ -32,7 +33,7 @@ public function test_it_can_delete_a_module_from_disk(): void $this->artisan('module:make', ['name' => ['WrongModule']]); $this->assertDirectoryExists(base_path('modules/WrongModule')); - $code = $this->artisan('module:delete', ['module' => 'WrongModule','--force' => true]); + $code = $this->artisan('module:delete', ['module' => 'WrongModule', '--force' => true]); $this->assertFileDoesNotExist(base_path('modules/WrongModule')); $this->assertSame(0, $code); } diff --git a/tests/Commands/Make/ActionMakeCommandTest.php b/tests/Commands/Make/ActionMakeCommandTest.php index 148404aa1..0631781a7 100644 --- a/tests/Commands/Make/ActionMakeCommandTest.php +++ b/tests/Commands/Make/ActionMakeCommandTest.php @@ -14,6 +14,7 @@ class ActionMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_action_class() { $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Actions/MyAction.php')); + $this->assertTrue(is_file($this->modulePath.'/Actions/MyAction.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_action_class_can_override_with_force_opt $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog']); $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Actions/MyAction.php')); + $this->assertTrue(is_file($this->modulePath.'/Actions/MyAction.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generates_a_new_action_class_can_use_invoke_option() { $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog', '--invokable' => true]); - $this->assertTrue(is_file($this->modulePath . '/Actions/MyAction.php')); + $this->assertTrue(is_file($this->modulePath.'/Actions/MyAction.php')); $this->assertSame(0, $code); } @@ -63,7 +64,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-action', ['name' => 'MyAction', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Actions/MyAction.php'); + $file = $this->finder->get($this->modulePath.'/Actions/MyAction.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -73,7 +74,7 @@ public function test_it_can_generate_a_action_in_sub_namespace_in_correct_folder { $code = $this->artisan('module:make-action', ['name' => 'Api\\MyAction', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Actions/Api/MyAction.php')); + $this->assertTrue(is_file($this->modulePath.'/Actions/Api/MyAction.php')); $this->assertSame(0, $code); } @@ -81,7 +82,7 @@ public function test_it_can_generate_a_action_in_sub_namespace_with_correct_gene { $code = $this->artisan('module:make-action', ['name' => 'Api\\MyAction', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Actions/Api/MyAction.php'); + $file = $this->finder->get($this->modulePath.'/Actions/Api/MyAction.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/CastMakeCommandTest.php b/tests/Commands/Make/CastMakeCommandTest.php index cd2e8f25d..4c41ee2ee 100644 --- a/tests/Commands/Make/CastMakeCommandTest.php +++ b/tests/Commands/Make/CastMakeCommandTest.php @@ -14,6 +14,7 @@ class CastMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_cast_class() { $code = $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Casts/MyCast.php')); + $this->assertTrue(is_file($this->modulePath.'/Casts/MyCast.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_cast_class_can_override_with_force_optio $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog']); $code = $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Casts/MyCast.php')); + $this->assertTrue(is_file($this->modulePath.'/Casts/MyCast.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-cast', ['name' => 'MyCast', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Casts/MyCast.php'); + $file = $this->finder->get($this->modulePath.'/Casts/MyCast.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -65,7 +66,7 @@ public function test_it_can_generate_a_cast_in_sub_namespace_in_correct_folder() { $code = $this->artisan('module:make-cast', ['name' => 'Api\\MyCast', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Casts/Api/MyCast.php')); + $this->assertTrue(is_file($this->modulePath.'/Casts/Api/MyCast.php')); $this->assertSame(0, $code); } @@ -73,7 +74,7 @@ public function test_it_can_generate_a_cast_in_sub_namespace_with_correct_genera { $code = $this->artisan('module:make-cast', ['name' => 'Api\\MyCast', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Casts/Api/MyCast.php'); + $file = $this->finder->get($this->modulePath.'/Casts/Api/MyCast.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ChannelMakeCommandTest.php b/tests/Commands/Make/ChannelMakeCommandTest.php index a728b71c6..c622f764d 100644 --- a/tests/Commands/Make/ChannelMakeCommandTest.php +++ b/tests/Commands/Make/ChannelMakeCommandTest.php @@ -14,6 +14,7 @@ class ChannelMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -37,7 +38,7 @@ public function test_it_generates_the_channel_class() { $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Broadcasting/WelcomeChannel.php')); + $this->assertTrue(is_file($this->modulePath.'/Broadcasting/WelcomeChannel.php')); $this->assertSame(0, $code); } @@ -45,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); + $file = $this->finder->get($this->modulePath.'/Broadcasting/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -57,7 +58,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperChannel/WelcomeChannel.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperChannel/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -69,7 +70,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-channel', ['name' => 'WelcomeChannel', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Broadcasting/WelcomeChannel.php'); + $file = $this->finder->get($this->modulePath.'/Broadcasting/WelcomeChannel.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ClassMakeCommandTest.php b/tests/Commands/Make/ClassMakeCommandTest.php index 98040f07f..63ef4eb7e 100644 --- a/tests/Commands/Make/ClassMakeCommandTest.php +++ b/tests/Commands/Make/ClassMakeCommandTest.php @@ -14,6 +14,7 @@ class ClassMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_class() { $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Classes/Demo.php')); + $this->assertTrue(is_file($this->modulePath.'/Classes/Demo.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_class_can_override_with_force_option() $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog']); $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Classes/Demo.php')); + $this->assertTrue(is_file($this->modulePath.'/Classes/Demo.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generates_a_new_class_can_use_invoke_option() { $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--invokable' => true]); - $this->assertTrue(is_file($this->modulePath . '/Classes/Demo.php')); + $this->assertTrue(is_file($this->modulePath.'/Classes/Demo.php')); $this->assertSame(0, $code); } @@ -63,7 +64,7 @@ public function test_it_generates_a_new_class_can_use_suffix_option() { $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--suffix' => true]); - $this->assertTrue(is_file($this->modulePath . '/Classes/DemoClass.php')); + $this->assertTrue(is_file($this->modulePath.'/Classes/DemoClass.php')); $this->assertSame(0, $code); } @@ -71,7 +72,7 @@ public function test_it_generates_a_new_class_use_type_option() { $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog', '--type' => 'contract']); - $this->assertTrue(is_file($this->modulePath . '/Contracts/Demo.php')); + $this->assertTrue(is_file($this->modulePath.'/Contracts/Demo.php')); $this->assertSame(0, $code); } @@ -79,7 +80,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-class', ['name' => 'Demo', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Classes/Demo.php'); + $file = $this->finder->get($this->modulePath.'/Classes/Demo.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -89,7 +90,7 @@ public function test_it_can_generate_a_class_in_sub_namespace_in_correct_folder( { $code = $this->artisan('module:make-class', ['name' => 'Api\\Demo', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Classes/Api/Demo.php')); + $this->assertTrue(is_file($this->modulePath.'/Classes/Api/Demo.php')); $this->assertSame(0, $code); } @@ -97,7 +98,7 @@ public function test_it_can_generate_a_class_in_sub_namespace_with_correct_gener { $code = $this->artisan('module:make-class', ['name' => 'Api\\Demo', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Classes/Api/Demo.php'); + $file = $this->finder->get($this->modulePath.'/Classes/Api/Demo.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/CommandMakeCommandTest.php b/tests/Commands/Make/CommandMakeCommandTest.php index 5e377b500..b2e6612c2 100644 --- a/tests/Commands/Make/CommandMakeCommandTest.php +++ b/tests/Commands/Make/CommandMakeCommandTest.php @@ -14,6 +14,7 @@ class CommandMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -37,7 +38,7 @@ public function test_it_generates_a_new_console_command_class() { $code = $this->artisan('module:make-command', ['name' => 'MyAwesomeCommand', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Console/MyAwesomeCommand.php')); + $this->assertTrue(is_file($this->modulePath.'/Console/MyAwesomeCommand.php')); $this->assertSame(0, $code); } @@ -45,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-command', ['name' => 'MyAwesomeCommand', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Console/MyAwesomeCommand.php'); + $file = $this->finder->get($this->modulePath.'/Console/MyAwesomeCommand.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -58,7 +59,7 @@ public function test_it_uses_set_command_name_in_class() ['name' => 'MyAwesomeCommand', 'module' => 'Blog', '--command' => 'my:awesome'] ); - $file = $this->finder->get($this->modulePath . '/Console/MyAwesomeCommand.php'); + $file = $this->finder->get($this->modulePath.'/Console/MyAwesomeCommand.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -70,7 +71,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-command', ['name' => 'AwesomeCommand', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/CustomCommands/AwesomeCommand.php'); + $file = $this->finder->get($this->modulePath.'/CustomCommands/AwesomeCommand.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -82,7 +83,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-command', ['name' => 'AwesomeCommand', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Console/AwesomeCommand.php'); + $file = $this->finder->get($this->modulePath.'/Console/AwesomeCommand.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ComponentClassMakeCommandTest.php b/tests/Commands/Make/ComponentClassMakeCommandTest.php index 91c9b4b19..868ea6da6 100644 --- a/tests/Commands/Make/ComponentClassMakeCommandTest.php +++ b/tests/Commands/Make/ComponentClassMakeCommandTest.php @@ -14,6 +14,7 @@ class ComponentClassMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,14 +37,14 @@ public function tearDown(): void public function test_it_generates_the_component_class() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/View/Components/Blog.php')); + $this->assertTrue(is_file($this->modulePath.'/View/Components/Blog.php')); $this->assertSame(0, $code); } public function test_it_generates_the_component_view_from_component_class_command() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/components/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath().'/resources/views/components/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); } @@ -51,7 +52,7 @@ public function test_it_generates_the_component_view_from_component_class_comman public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/View/Components/Blog.php'); + $file = $this->finder->get($this->modulePath.'/View/Components/Blog.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); } @@ -62,7 +63,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-component', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/View/Components/newDirectory/Blog.php'); + $file = $this->finder->get($this->getModuleBasePath().'/View/Components/newDirectory/Blog.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ComponentViewMakeCommandTest.php b/tests/Commands/Make/ComponentViewMakeCommandTest.php index 871dc39aa..b7aaddde6 100644 --- a/tests/Commands/Make/ComponentViewMakeCommandTest.php +++ b/tests/Commands/Make/ComponentViewMakeCommandTest.php @@ -14,6 +14,7 @@ class ComponentViewMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,14 +37,14 @@ public function tearDown(): void public function test_it_generates_the_component_view() { $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); - $this->assertTrue(is_file($this->getModuleBasePath() . '/resources/views/components/blog.blade.php')); + $this->assertTrue(is_file($this->getModuleBasePath().'/resources/views/components/blog.blade.php')); $this->assertSame(0, $code); } public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/components/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath().'/resources/views/components/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); } @@ -54,7 +55,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-component-view', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/Resources/views/components/newDirectory/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath().'/Resources/views/components/newDirectory/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ControllerMakeCommandTest.php b/tests/Commands/Make/ControllerMakeCommandTest.php index 68e90af6e..860ac6536 100644 --- a/tests/Commands/Make/ControllerMakeCommandTest.php +++ b/tests/Commands/Make/ControllerMakeCommandTest.php @@ -14,6 +14,7 @@ class ControllerMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_controller_class() { $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Http/Controllers/MyController.php')); + $this->assertTrue(is_file($this->modulePath.'/Http/Controllers/MyController.php')); $this->assertSame(0, $code); } @@ -46,7 +47,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -56,7 +57,7 @@ public function test_it_appends_controller_to_name_if_not_present() { $code = $this->artisan('module:make-controller', ['controller' => 'My', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Http/Controllers/MyController.php')); + $this->assertTrue(is_file($this->modulePath.'/Http/Controllers/MyController.php')); $this->assertSame(0, $code); } @@ -64,7 +65,7 @@ public function test_it_appends_controller_to_class_name_if_not_present() { $code = $this->artisan('module:make-controller', ['controller' => 'My', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -74,11 +75,11 @@ public function test_it_generates_a_plain_controller() { $code = $this->artisan('module:make-controller', [ 'controller' => 'MyController', - 'module' => 'Blog', - '--plain' => true, + 'module' => 'Blog', + '--plain' => true, ]); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -88,11 +89,11 @@ public function test_it_generates_an_api_controller() { $code = $this->artisan('module:make-controller', [ 'controller' => 'MyController', - 'module' => 'Blog', - '--api' => true, + 'module' => 'Blog', + '--api' => true, ]); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -101,12 +102,12 @@ public function test_it_generates_an_api_controller() public function test_it_generates_an_invokable_controller() { $code = $this->artisan('module:make-controller', [ - 'controller' => 'MyController', - 'module' => 'Blog', + 'controller' => 'MyController', + 'module' => 'Blog', '--invokable' => true, ]); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -118,7 +119,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/Controllers/MyController.php'); + $file = $this->finder->get($this->getModuleBasePath().'/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -130,7 +131,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-controller', ['controller' => 'MyController', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -140,7 +141,7 @@ public function test_it_can_generate_a_controller_in_sub_namespace_in_correct_fo { $code = $this->artisan('module:make-controller', ['controller' => 'Api\\MyController', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Http/Controllers/Api/MyController.php')); + $this->assertTrue(is_file($this->modulePath.'/Http/Controllers/Api/MyController.php')); $this->assertSame(0, $code); } @@ -148,7 +149,7 @@ public function test_it_can_generate_a_controller_in_sub_namespace_with_correct_ { $code = $this->artisan('module:make-controller', ['controller' => 'Api\\MyController', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Controllers/Api/MyController.php'); + $file = $this->finder->get($this->modulePath.'/Http/Controllers/Api/MyController.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/EnumMakeCommandTest.php b/tests/Commands/Make/EnumMakeCommandTest.php index 0e9ff2860..1cb65afcf 100644 --- a/tests/Commands/Make/EnumMakeCommandTest.php +++ b/tests/Commands/Make/EnumMakeCommandTest.php @@ -14,6 +14,7 @@ class EnumMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_enum_class() { $code = $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Enums/MyEnum.php')); + $this->assertTrue(is_file($this->modulePath.'/Enums/MyEnum.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_enum_class_can_override_with_force_optio $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog']); $code = $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Enums/MyEnum.php')); + $this->assertTrue(is_file($this->modulePath.'/Enums/MyEnum.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-enum', ['name' => 'MyEnum', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Enums/MyEnum.php'); + $file = $this->finder->get($this->modulePath.'/Enums/MyEnum.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -65,7 +66,7 @@ public function test_it_can_generate_a_enum_in_sub_namespace_in_correct_folder() { $code = $this->artisan('module:make-enum', ['name' => 'Api\\MyEnum', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Enums/Api/MyEnum.php')); + $this->assertTrue(is_file($this->modulePath.'/Enums/Api/MyEnum.php')); $this->assertSame(0, $code); } @@ -73,7 +74,7 @@ public function test_it_can_generate_a_enum_in_sub_namespace_with_correct_genera { $code = $this->artisan('module:make-enum', ['name' => 'Api\\MyEnum', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Enums/Api/MyEnum.php'); + $file = $this->finder->get($this->modulePath.'/Enums/Api/MyEnum.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/EventMakeCommandTest.php b/tests/Commands/Make/EventMakeCommandTest.php index 82f2398f9..bbd2f63d2 100644 --- a/tests/Commands/Make/EventMakeCommandTest.php +++ b/tests/Commands/Make/EventMakeCommandTest.php @@ -9,6 +9,7 @@ class EventMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -37,7 +38,7 @@ public function test_it_generates_a_new_event_class() { $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Events/PostWasCreated.php')); + $this->assertTrue(is_file($this->modulePath.'/Events/PostWasCreated.php')); $this->assertSame(0, $code); } @@ -45,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Events/PostWasCreated.php'); + $file = $this->finder->get($this->modulePath.'/Events/PostWasCreated.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -57,7 +58,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperEvents/PostWasCreated.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperEvents/PostWasCreated.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -69,7 +70,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-event', ['name' => 'PostWasCreated', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Events/PostWasCreated.php'); + $file = $this->finder->get($this->modulePath.'/Events/PostWasCreated.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/EventProviderMakeCommandTest.php b/tests/Commands/Make/EventProviderMakeCommandTest.php index 8abd7e633..6b7e87527 100644 --- a/tests/Commands/Make/EventProviderMakeCommandTest.php +++ b/tests/Commands/Make/EventProviderMakeCommandTest.php @@ -14,6 +14,7 @@ class EventProviderMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_event_provider_class() { $code = $this->artisan('module:make-event-provider', ['module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Providers/EventServiceProvider.php')); + $this->assertTrue(is_file($this->modulePath.'/Providers/EventServiceProvider.php')); $this->assertSame(1, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_event_provider_class_can_override_with_f $this->artisan('module:make-event-provider', ['module' => 'Blog']); $code = $this->artisan('module:make-event-provider', ['module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Providers/EventServiceProvider.php')); + $this->assertTrue(is_file($this->modulePath.'/Providers/EventServiceProvider.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-event-provider', ['module' => 'Blog', '--force' => true]); - $file = $this->finder->get($this->modulePath . '/Providers/EventServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/EventServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ExceptionMakeCommandTest.php b/tests/Commands/Make/ExceptionMakeCommandTest.php index 019ff4ab6..0b8694e09 100644 --- a/tests/Commands/Make/ExceptionMakeCommandTest.php +++ b/tests/Commands/Make/ExceptionMakeCommandTest.php @@ -14,6 +14,7 @@ class ExceptionMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_exception_class() { $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertTrue(is_file($this->modulePath.'/Exceptions/MyException.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_exception_class_can_override_with_force_ $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog']); $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertTrue(is_file($this->modulePath.'/Exceptions/MyException.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generates_a_new_exception_class_can_use_render_option() { $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--render' => true]); - $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertTrue(is_file($this->modulePath.'/Exceptions/MyException.php')); $this->assertSame(0, $code); } @@ -63,7 +64,7 @@ public function test_it_generates_a_new_exception_class_can_use_report_option() { $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--report' => true]); - $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertTrue(is_file($this->modulePath.'/Exceptions/MyException.php')); $this->assertSame(0, $code); } @@ -71,7 +72,7 @@ public function test_it_generates_a_new_exception_class_can_use_report_and_rende { $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog', '--report' => true, '--render' => true]); - $this->assertTrue(is_file($this->modulePath . '/Exceptions/MyException.php')); + $this->assertTrue(is_file($this->modulePath.'/Exceptions/MyException.php')); $this->assertSame(0, $code); } @@ -79,7 +80,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-exception', ['name' => 'MyException', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Exceptions/MyException.php'); + $file = $this->finder->get($this->modulePath.'/Exceptions/MyException.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -89,7 +90,7 @@ public function test_it_can_generate_a_exception_in_sub_namespace_in_correct_fol { $code = $this->artisan('module:make-exception', ['name' => 'Api\\MyException', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Exceptions/Api/MyException.php')); + $this->assertTrue(is_file($this->modulePath.'/Exceptions/Api/MyException.php')); $this->assertSame(0, $code); } @@ -97,7 +98,7 @@ public function test_it_can_generate_a_exception_in_sub_namespace_with_correct_g { $code = $this->artisan('module:make-exception', ['name' => 'Api\\MyException', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Exceptions/Api/MyException.php'); + $file = $this->finder->get($this->modulePath.'/Exceptions/Api/MyException.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/FactoryMakeCommandTest.php b/tests/Commands/Make/FactoryMakeCommandTest.php index cea00766b..6cafbf5a1 100644 --- a/tests/Commands/Make/FactoryMakeCommandTest.php +++ b/tests/Commands/Make/FactoryMakeCommandTest.php @@ -9,10 +9,12 @@ class FactoryMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_makes_factory() { $code = $this->artisan('module:make-factory', ['name' => 'Post', 'module' => 'Blog']); - $factoryFile = $this->getModuleBasePath() . '/database/factories/PostFactory.php'; + $factoryFile = $this->getModuleBasePath().'/database/factories/PostFactory.php'; $this->assertTrue(is_file($factoryFile), 'Factory file was not created.'); $this->assertMatchesSnapshot($this->finder->get($factoryFile)); diff --git a/tests/Commands/Make/HelperMakeCommandTest.php b/tests/Commands/Make/HelperMakeCommandTest.php index b6c84d4ef..aaa28f66c 100644 --- a/tests/Commands/Make/HelperMakeCommandTest.php +++ b/tests/Commands/Make/HelperMakeCommandTest.php @@ -14,6 +14,7 @@ class HelperMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_helper_class() { $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Helpers/MyHelper.php')); + $this->assertTrue(is_file($this->modulePath.'/Helpers/MyHelper.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_helper_class_can_override_with_force_opt $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']); $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Helpers/MyHelper.php')); + $this->assertTrue(is_file($this->modulePath.'/Helpers/MyHelper.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generates_a_new_helper_class_can_use_invoke_option() { $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog', '--invokable' => true]); - $this->assertTrue(is_file($this->modulePath . '/Helpers/MyHelper.php')); + $this->assertTrue(is_file($this->modulePath.'/Helpers/MyHelper.php')); $this->assertSame(0, $code); } @@ -63,7 +64,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Helpers/MyHelper.php'); + $file = $this->finder->get($this->modulePath.'/Helpers/MyHelper.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -73,7 +74,7 @@ public function test_it_can_generate_a_helper_in_sub_namespace_in_correct_folder { $code = $this->artisan('module:make-helper', ['name' => 'Api\\MyHelper', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Helpers/Api/MyHelper.php')); + $this->assertTrue(is_file($this->modulePath.'/Helpers/Api/MyHelper.php')); $this->assertSame(0, $code); } @@ -81,7 +82,7 @@ public function test_it_can_generate_a_helper_in_sub_namespace_with_correct_gene { $code = $this->artisan('module:make-helper', ['name' => 'Api\\MyHelper', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Helpers/Api/MyHelper.php'); + $file = $this->finder->get($this->modulePath.'/Helpers/Api/MyHelper.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/InterfaceMakeCommandTest.php b/tests/Commands/Make/InterfaceMakeCommandTest.php index c5ec05d94..c913baa56 100644 --- a/tests/Commands/Make/InterfaceMakeCommandTest.php +++ b/tests/Commands/Make/InterfaceMakeCommandTest.php @@ -14,6 +14,7 @@ class InterfaceMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_interface_class() { $code = $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Interfaces/MyInterface.php')); + $this->assertTrue(is_file($this->modulePath.'/Interfaces/MyInterface.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_interface_class_can_override_with_force_ $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog']); $code = $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Interfaces/MyInterface.php')); + $this->assertTrue(is_file($this->modulePath.'/Interfaces/MyInterface.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-interface', ['name' => 'MyInterface', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Interfaces/MyInterface.php'); + $file = $this->finder->get($this->modulePath.'/Interfaces/MyInterface.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -65,7 +66,7 @@ public function test_it_can_generate_a_interface_in_sub_namespace_in_correct_fol { $code = $this->artisan('module:make-interface', ['name' => 'Api\\MyInterface', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Interfaces/Api/MyInterface.php')); + $this->assertTrue(is_file($this->modulePath.'/Interfaces/Api/MyInterface.php')); $this->assertSame(0, $code); } @@ -73,7 +74,7 @@ public function test_it_can_generate_a_interface_in_sub_namespace_with_correct_g { $code = $this->artisan('module:make-interface', ['name' => 'Api\\MyInterface', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Interfaces/Api/MyInterface.php'); + $file = $this->finder->get($this->modulePath.'/Interfaces/Api/MyInterface.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/JobMakeCommandTest.php b/tests/Commands/Make/JobMakeCommandTest.php index 2b258a5bd..3ce343299 100644 --- a/tests/Commands/Make/JobMakeCommandTest.php +++ b/tests/Commands/Make/JobMakeCommandTest.php @@ -9,10 +9,12 @@ class JobMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_the_job_class() { $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Jobs/SomeJob.php')); + $this->assertTrue(is_file($this->modulePath.'/Jobs/SomeJob.php')); $this->assertSame(0, $code); } @@ -44,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Jobs/SomeJob.php'); + $file = $this->finder->get($this->modulePath.'/Jobs/SomeJob.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -54,7 +56,7 @@ public function test_it_generated_correct_sync_job_file_with_content() { $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog', '--sync' => true]); - $file = $this->finder->get($this->modulePath . '/Jobs/SomeJob.php'); + $file = $this->finder->get($this->modulePath.'/Jobs/SomeJob.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -66,7 +68,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperJobs/SomeJob.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperJobs/SomeJob.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -78,7 +80,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-job', ['name' => 'SomeJob', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Jobs/SomeJob.php'); + $file = $this->finder->get($this->modulePath.'/Jobs/SomeJob.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ListenerMakeCommandTest.php b/tests/Commands/Make/ListenerMakeCommandTest.php index 50d3db1b1..13e706d7a 100644 --- a/tests/Commands/Make/ListenerMakeCommandTest.php +++ b/tests/Commands/Make/ListenerMakeCommandTest.php @@ -9,6 +9,7 @@ class ListenerMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ @@ -40,7 +41,7 @@ public function test_it_generates_a_new_event_class() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog', '--event' => 'UserWasCreated'] ); - $this->assertTrue(is_file($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php')); + $this->assertTrue(is_file($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php')); $this->assertSame(0, $code); } @@ -51,7 +52,7 @@ public function test_it_generated_correct_sync_event_with_content() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog', '--event' => 'UserWasCreated'] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -64,7 +65,7 @@ public function test_it_generated_correct_sync_event_in_a_subdirectory_with_cont ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog', '--event' => 'User/WasCreated'] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -77,7 +78,7 @@ public function test_it_generated_correct_sync_duck_event_with_content() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog'] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -90,7 +91,7 @@ public function test_it_generated_correct_queued_event_with_content() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog', '--event' => 'UserWasCreated', '--queued' => true] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -103,7 +104,7 @@ public function test_it_generated_correct_queued_event_in_a_subdirectory_with_co ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog', '--event' => 'User/WasCreated', '--queued' => true] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -116,7 +117,7 @@ public function test_it_generated_correct_queued_duck_event_with_content() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog', '--queued' => true] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -131,7 +132,7 @@ public function test_it_can_change_the_default_namespace() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog'] ); - $file = $this->finder->get($this->getModuleBasePath() . '/Events/Handlers/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->getModuleBasePath().'/Events/Handlers/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -146,7 +147,7 @@ public function test_it_can_change_the_default_namespace_specific() ['name' => 'NotifyUsersOfANewPost', 'module' => 'Blog'] ); - $file = $this->finder->get($this->modulePath . '/Listeners/NotifyUsersOfANewPost.php'); + $file = $this->finder->get($this->modulePath.'/Listeners/NotifyUsersOfANewPost.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/MailMakeCommandTest.php b/tests/Commands/Make/MailMakeCommandTest.php index eccdfd3c4..a90f5e67f 100644 --- a/tests/Commands/Make/MailMakeCommandTest.php +++ b/tests/Commands/Make/MailMakeCommandTest.php @@ -9,10 +9,12 @@ class MailMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_the_mail_class() { $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Emails/SomeMail.php')); + $this->assertTrue(is_file($this->modulePath.'/Emails/SomeMail.php')); $this->assertSame(0, $code); } @@ -44,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Emails/SomeMail.php'); + $file = $this->finder->get($this->modulePath.'/Emails/SomeMail.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -56,7 +58,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperEmails/SomeMail.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperEmails/SomeMail.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,7 +70,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-mail', ['name' => 'SomeMail', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Emails/SomeMail.php'); + $file = $this->finder->get($this->modulePath.'/Emails/SomeMail.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/MiddlewareMakeCommandTest.php b/tests/Commands/Make/MiddlewareMakeCommandTest.php index 513687724..452901f6f 100644 --- a/tests/Commands/Make/MiddlewareMakeCommandTest.php +++ b/tests/Commands/Make/MiddlewareMakeCommandTest.php @@ -9,10 +9,12 @@ class MiddlewareMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_a_new_middleware_class() { $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Http/Middleware/SomeMiddleware.php')); + $this->assertTrue(is_file($this->modulePath.'/Http/Middleware/SomeMiddleware.php')); $this->assertSame(0, $code); } @@ -44,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Middleware/SomeMiddleware.php'); + $file = $this->finder->get($this->modulePath.'/Http/Middleware/SomeMiddleware.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -56,7 +58,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/Middleware/SomeMiddleware.php'); + $file = $this->finder->get($this->getModuleBasePath().'/Middleware/SomeMiddleware.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,7 +70,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Middleware/SomeMiddleware.php'); + $file = $this->finder->get($this->modulePath.'/Http/Middleware/SomeMiddleware.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/MigrationMakeCommandTest.php b/tests/Commands/Make/MigrationMakeCommandTest.php index 0d81b5548..5158b5474 100644 --- a/tests/Commands/Make/MigrationMakeCommandTest.php +++ b/tests/Commands/Make/MigrationMakeCommandTest.php @@ -9,10 +9,12 @@ class MigrationMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_a_new_migration_class() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); - $files = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $files = $this->finder->allFiles($this->modulePath.'/database/migrations'); $this->assertCount(1, $files); $this->assertSame(0, $code); @@ -46,9 +48,9 @@ public function test_it_generates_correct_create_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $migrations = $this->finder->allFiles($this->modulePath.'/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); + $file = $this->finder->get($this->modulePath.'/database/migrations/'.$fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -58,9 +60,9 @@ public function test_it_generates_correct_add_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'add_something_to_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $migrations = $this->finder->allFiles($this->modulePath.'/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); + $file = $this->finder->get($this->modulePath.'/database/migrations/'.$fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -70,9 +72,9 @@ public function test_it_generates_correct_delete_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'delete_something_from_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $migrations = $this->finder->allFiles($this->modulePath.'/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); + $file = $this->finder->get($this->modulePath.'/database/migrations/'.$fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -82,9 +84,9 @@ public function test_it_generates_correct_drop_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'drop_posts_table', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $migrations = $this->finder->allFiles($this->modulePath.'/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); + $file = $this->finder->get($this->modulePath.'/database/migrations/'.$fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -94,9 +96,9 @@ public function test_it_generates_correct_default_migration_file_content() { $code = $this->artisan('module:make-migration', ['name' => 'something_random_name', 'module' => 'Blog']); - $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $migrations = $this->finder->allFiles($this->modulePath.'/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); + $file = $this->finder->get($this->modulePath.'/database/migrations/'.$fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -106,9 +108,9 @@ public function test_it_generates_foreign_key_constraints() { $code = $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog', '--fields' => 'belongsTo:user:id:users']); - $migrations = $this->finder->allFiles($this->modulePath . '/database/migrations'); + $migrations = $this->finder->allFiles($this->modulePath.'/database/migrations'); $fileName = $migrations[0]->getRelativePathname(); - $file = $this->finder->get($this->modulePath . '/database/migrations/' . $fileName); + $file = $this->finder->get($this->modulePath.'/database/migrations/'.$fileName); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ModelMakeCommandTest.php b/tests/Commands/Make/ModelMakeCommandTest.php index 8ae1e3947..65eb8fde4 100644 --- a/tests/Commands/Make/ModelMakeCommandTest.php +++ b/tests/Commands/Make/ModelMakeCommandTest.php @@ -10,10 +10,12 @@ class ModelMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -37,7 +39,7 @@ public function test_it_generates_a_new_model_class() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Models/Post.php')); + $this->assertTrue(is_file($this->modulePath.'/Models/Post.php')); $this->assertSame(0, $code); } @@ -45,7 +47,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Models/Post.php'); + $file = $this->finder->get($this->modulePath.'/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -55,7 +57,7 @@ public function test_it_generates_correct_fillable_fields() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--fillable' => 'title,slug']); - $file = $this->finder->get($this->modulePath . '/Models/Post.php'); + $file = $this->finder->get($this->modulePath.'/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -65,9 +67,9 @@ public function test_it_generates_migration_file_with_model() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--migration' => true]); - $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath().'/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath().'/database/migrations/'.$migrationFile->getFilename()); $this->assertCount(1, $migrations); $this->assertMatchesSnapshot($migrationContent); $this->assertSame(0, $code); @@ -77,9 +79,9 @@ public function test_it_generates_migration_file_with_model_using_shortcut_optio { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-m' => true]); - $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath().'/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath().'/database/migrations/'.$migrationFile->getFilename()); $this->assertCount(1, $migrations); $this->assertMatchesSnapshot($migrationContent); $this->assertSame(0, $code); @@ -88,9 +90,9 @@ public function test_it_generates_migration_file_with_model_using_shortcut_optio public function test_it_generates_controller_file_with_model() { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '--controller' => true]); - $controllers = $this->finder->allFiles($this->modulePath . '/Http/Controllers'); + $controllers = $this->finder->allFiles($this->modulePath.'/Http/Controllers'); $controllerFile = $controllers[1]; - $controllerContent = $this->finder->get($this->modulePath . '/Http/Controllers/' . $controllerFile->getFilename()); + $controllerContent = $this->finder->get($this->modulePath.'/Http/Controllers/'.$controllerFile->getFilename()); $this->assertCount(2, $controllers); $this->assertMatchesSnapshot($controllerContent); $this->assertSame(0, $code); @@ -100,9 +102,9 @@ public function test_it_generates_controller_file_with_model_using_shortcut_opti { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-c' => true]); - $controllers = $this->finder->allFiles($this->modulePath . '/Http/Controllers'); + $controllers = $this->finder->allFiles($this->modulePath.'/Http/Controllers'); $controllerFile = $controllers[1]; - $controllerContent = $this->finder->get($this->modulePath . '/Http/Controllers/' . $controllerFile->getFilename()); + $controllerContent = $this->finder->get($this->modulePath.'/Http/Controllers/'.$controllerFile->getFilename()); $this->assertCount(2, $controllers); $this->assertMatchesSnapshot($controllerContent); $this->assertSame(0, $code); @@ -112,15 +114,15 @@ public function test_it_generates_controller_and_migration_when_both_flags_are_p { $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog', '-c' => true, '-m' => true]); - $controllers = $this->finder->allFiles($this->modulePath . '/Http/Controllers'); + $controllers = $this->finder->allFiles($this->modulePath.'/Http/Controllers'); $controllerFile = $controllers[1]; - $controllerContent = $this->finder->get($this->modulePath . '/Http/Controllers/' . $controllerFile->getFilename()); + $controllerContent = $this->finder->get($this->modulePath.'/Http/Controllers/'.$controllerFile->getFilename()); $this->assertCount(2, $controllers); $this->assertMatchesSnapshot($controllerContent); - $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath().'/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath().'/database/migrations/'.$migrationFile->getFilename()); $this->assertCount(1, $migrations); $this->assertMatchesSnapshot($migrationContent); @@ -131,9 +133,9 @@ public function test_it_generates_correct_migration_file_name_with_multiple_word { $code = $this->artisan('module:make-model', ['model' => 'ProductDetail', 'module' => 'Blog', '-m' => true]); - $migrations = $this->finder->allFiles($this->getModuleBasePath() . '/database/migrations'); + $migrations = $this->finder->allFiles($this->getModuleBasePath().'/database/migrations'); $migrationFile = $migrations[0]; - $migrationContent = $this->finder->get($this->getModuleBasePath() . '/database/migrations/' . $migrationFile->getFilename()); + $migrationContent = $this->finder->get($this->getModuleBasePath().'/database/migrations/'.$migrationFile->getFilename()); $this->assertStringContainsString('create_product_details_table', $migrationFile->getFilename()); $this->assertMatchesSnapshot($migrationContent); @@ -155,7 +157,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/Models/Post.php'); + $file = $this->finder->get($this->getModuleBasePath().'/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -167,7 +169,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-model', ['model' => 'Post', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Models/Post.php'); + $file = $this->finder->get($this->modulePath.'/Models/Post.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index be7934266..d2ce2924c 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -17,6 +17,7 @@ class ModuleMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -26,6 +27,7 @@ class ModuleMakeCommandTest extends BaseTestCase * @var ActivatorInterface */ private $activator; + /** * @var RepositoryInterface */ @@ -35,9 +37,9 @@ public function setUp(): void { parent::setUp(); $this->modulePath = $this->getModuleBasePath(); - $this->finder = $this->app['files']; + $this->finder = $this->app['files']; $this->repository = $this->app[RepositoryInterface::class]; - $this->activator = $this->app[ActivatorInterface::class]; + $this->activator = $this->app[ActivatorInterface::class]; } public function tearDown(): void @@ -63,7 +65,7 @@ public function test_it_generates_module_folders() $code = $this->artisan('module:make', ['name' => ['Blog']]); foreach (config('modules.paths.generator') as $directory) { - $this->assertDirectoryExists($this->modulePath . '/' . $directory['path']); + $this->assertDirectoryExists($this->modulePath.'/'.$directory['path']); } $this->assertSame(0, $code); } @@ -73,10 +75,10 @@ public function test_it_generates_module_files() $code = $this->artisan('module:make', ['name' => ['Blog']]); foreach (config('modules.stubs.files') as $file) { - $path = base_path('modules/Blog') . '/' . $file; + $path = base_path('modules/Blog').'/'.$file; $this->assertTrue($this->finder->exists($path), "[$file] does not exists"); } - $path = base_path('modules/Blog') . '/module.json'; + $path = base_path('modules/Blog').'/module.json'; $this->assertTrue($this->finder->exists($path), '[module.json] does not exists'); $this->assertMatchesSnapshot($this->finder->get($path)); $this->assertSame(0, $code); @@ -85,9 +87,9 @@ public function test_it_generates_module_files() public function test_it_generates_web_route_file() { $files = $this->app['modules']->config('stubs.files'); - $code = $this->artisan('module:make', ['name' => ['Blog']]); + $code = $this->artisan('module:make', ['name' => ['Blog']]); - $path = $this->modulePath . '/' . $files['routes/web']; + $path = $this->modulePath.'/'.$files['routes/web']; $this->assertMatchesSnapshot($this->finder->get($path)); $this->assertSame(0, $code); @@ -96,9 +98,9 @@ public function test_it_generates_web_route_file() public function test_it_generates_api_route_file() { $files = $this->app['modules']->config('stubs.files'); - $code = $this->artisan('module:make', ['name' => ['Blog']]); + $code = $this->artisan('module:make', ['name' => ['Blog']]); - $path = $this->modulePath . '/' . $files['routes/api']; + $path = $this->modulePath.'/'.$files['routes/api']; $this->assertMatchesSnapshot($this->finder->get($path)); $this->assertSame(0, $code); @@ -108,7 +110,7 @@ public function test_it_generates_vite_file() { $code = $this->artisan('module:make', ['name' => ['Blog']]); - $path = $this->modulePath . '/' . $this->app['modules']->config('stubs.files.vite'); + $path = $this->modulePath.'/'.$this->app['modules']->config('stubs.files.vite'); $this->assertMatchesSnapshot($this->finder->get($path)); $this->assertSame(0, $code); @@ -118,23 +120,23 @@ public function test_it_generates_module_resources() { $code = $this->artisan('module:make', ['name' => ['Blog']]); - $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Providers/EventServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/EventServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath().'/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath().'/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); @@ -145,7 +147,7 @@ public function test_it_generates_correct_composerjson_file() { $code = $this->artisan('module:make', ['name' => ['Blog']]); - $file = $this->finder->get($this->modulePath . '/composer.json'); + $file = $this->finder->get($this->modulePath.'/composer.json'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -163,7 +165,7 @@ public function test_it_generates_module_namespace_using_studly_case() { $code = $this->artisan('module:make', ['name' => ['ModuleName']]); - $file = $this->finder->get($this->getModuleAppPath('ModuleName') . '/Providers/ModuleNameServiceProvider.php'); + $file = $this->finder->get($this->getModuleAppPath('ModuleName').'/Providers/ModuleNameServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -173,13 +175,13 @@ public function test_it_generates_a_plain_module_with_no_resources() { $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); - $path = base_path('modules/ModuleName') . '/Providers/ModuleNameServiceProvider.php'; + $path = base_path('modules/ModuleName').'/Providers/ModuleNameServiceProvider.php'; $this->assertFalse($this->finder->exists($path)); - $path = base_path('modules/ModuleName') . '/Http/Controllers/ModuleNameController.php'; + $path = base_path('modules/ModuleName').'/Http/Controllers/ModuleNameController.php'; $this->assertFalse($this->finder->exists($path)); - $path = base_path('modules/ModuleName') . '/Database/Seeders/ModuleNameDatabaseSeeder.php'; + $path = base_path('modules/ModuleName').'/Database/Seeders/ModuleNameDatabaseSeeder.php'; $this->assertFalse($this->finder->exists($path)); $this->assertSame(0, $code); @@ -190,10 +192,10 @@ public function test_it_generates_a_plain_module_with_no_files() $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); foreach (config('modules.stubs.files') as $file) { - $path = base_path('modules/ModuleName') . '/' . $file; + $path = base_path('modules/ModuleName').'/'.$file; $this->assertFalse($this->finder->exists($path), "[$file] exists"); } - $path = base_path('modules/ModuleName') . '/module.json'; + $path = base_path('modules/ModuleName').'/module.json'; $this->assertTrue($this->finder->exists($path), '[module.json] does not exists'); $this->assertSame(0, $code); } @@ -202,7 +204,7 @@ public function test_it_generates_plain_module_with_no_service_provider_in_modul { $code = $this->artisan('module:make', ['name' => ['ModuleName'], '--plain' => true]); - $path = base_path('modules/ModuleName') . '/module.json'; + $path = base_path('modules/ModuleName').'/module.json'; $content = json_decode($this->finder->get($path)); $this->assertCount(0, $content->providers); @@ -214,7 +216,7 @@ public function test_it_outputs_error_when_module_exists() $this->artisan('module:make', ['name' => ['Blog']]); $code = $this->artisan('module:make', ['name' => ['Blog']]); - $output = Artisan::output(); + $output = Artisan::output(); $expected = 'ERROR Module [Blog] already exists!'; $this->assertTrue(Str::contains($output, $expected)); @@ -239,37 +241,37 @@ public function test_it_still_generates_module_if_it_exists_using_force_flag() public function test_it_can_generate_module_with_old_config_format() { $this->app['config']->set('modules.paths.generator', [ - 'assets' => 'Assets', - 'config' => 'Config', - 'command' => 'Console', - 'event' => 'Events', - 'listener' => 'Listeners', - 'migration' => 'Database/Migrations', - 'factory' => 'Database/factories', - 'model' => 'Entities', - 'repository' => 'Repositories', - 'seeder' => 'Database/Seeders', - 'controller' => 'Http/Controllers', - 'filter' => 'Http/Middleware', - 'request' => 'Http/Requests', - 'provider' => 'Providers', - 'lang' => 'Resources/lang', - 'views' => 'Resources/views', - 'policies' => false, - 'rules' => false, - 'test' => 'Tests', - 'jobs' => 'Jobs', - 'emails' => 'Emails', + 'assets' => 'Assets', + 'config' => 'Config', + 'command' => 'Console', + 'event' => 'Events', + 'listener' => 'Listeners', + 'migration' => 'Database/Migrations', + 'factory' => 'Database/factories', + 'model' => 'Entities', + 'repository' => 'Repositories', + 'seeder' => 'Database/Seeders', + 'controller' => 'Http/Controllers', + 'filter' => 'Http/Middleware', + 'request' => 'Http/Requests', + 'provider' => 'Providers', + 'lang' => 'Resources/lang', + 'views' => 'Resources/views', + 'policies' => false, + 'rules' => false, + 'test' => 'Tests', + 'jobs' => 'Jobs', + 'emails' => 'Emails', 'notifications' => 'Notifications', - 'resource' => false, + 'resource' => false, ]); $code = $this->artisan('module:make', ['name' => ['Blog']]); - $this->assertDirectoryExists($this->modulePath . '/Assets'); - $this->assertDirectoryExists($this->modulePath . '/Emails'); - $this->assertFileDoesNotExist($this->modulePath . '/Rules'); - $this->assertFileDoesNotExist($this->modulePath . '/Policies'); + $this->assertDirectoryExists($this->modulePath.'/Assets'); + $this->assertDirectoryExists($this->modulePath.'/Emails'); + $this->assertFileDoesNotExist($this->modulePath.'/Rules'); + $this->assertFileDoesNotExist($this->modulePath.'/Policies'); $this->assertSame(0, $code); } @@ -280,8 +282,8 @@ public function test_it_can_ignore_some_folders_to_generate_with_old_format() $code = $this->artisan('module:make', ['name' => ['Blog']]); - $this->assertFileDoesNotExist($this->modulePath . '/Assets'); - $this->assertFileDoesNotExist($this->modulePath . '/Emails'); + $this->assertFileDoesNotExist($this->modulePath.'/Assets'); + $this->assertFileDoesNotExist($this->modulePath.'/Emails'); $this->assertSame(0, $code); } @@ -292,8 +294,8 @@ public function test_it_can_ignore_some_folders_to_generate_with_new_format() $code = $this->artisan('module:make', ['name' => ['Blog']]); - $this->assertFileDoesNotExist($this->modulePath . '/Assets'); - $this->assertFileDoesNotExist($this->modulePath . '/Emails'); + $this->assertFileDoesNotExist($this->modulePath.'/Assets'); + $this->assertFileDoesNotExist($this->modulePath.'/Emails'); $this->assertSame(0, $code); } @@ -306,9 +308,9 @@ public function test_it_can_ignore_resource_folders_to_generate() $code = $this->artisan('module:make', ['name' => ['Blog']]); - $this->assertFileDoesNotExist($this->modulePath . '/Database/Seeders'); - $this->assertFileDoesNotExist($this->modulePath . '/Providers'); - $this->assertFileDoesNotExist($this->modulePath . '/Http/Controllers'); + $this->assertFileDoesNotExist($this->modulePath.'/Database/Seeders'); + $this->assertFileDoesNotExist($this->modulePath.'/Providers'); + $this->assertFileDoesNotExist($this->modulePath.'/Http/Controllers'); $this->assertSame(0, $code); } @@ -334,10 +336,10 @@ public function test_it_generes_module_with_new_provider_location() $code = $this->artisan('module:make', ['name' => ['Blog']]); - $this->assertDirectoryExists($this->modulePath . '/Base/Providers'); - $file = $this->finder->get($this->modulePath . '/module.json'); + $this->assertDirectoryExists($this->modulePath.'/Base/Providers'); + $file = $this->finder->get($this->modulePath.'/module.json'); $this->assertMatchesSnapshot($file); - $file = $this->finder->get($this->modulePath . '/composer.json'); + $file = $this->finder->get($this->modulePath.'/composer.json'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); } @@ -346,19 +348,19 @@ public function test_it_generates_web_module_with_resources() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--web' => true]); - $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath().'/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath().'/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); @@ -369,19 +371,19 @@ public function test_it_generates_api_module_with_resources() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true]); - $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath().'/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath().'/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); @@ -392,19 +394,19 @@ public function test_it_generates_web_module_with_resources_when_adding_more_tha { $code = $this->artisan('module:make', ['name' => ['Blog'], '--api' => true, '--plain' => true]); - $path = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Http/Controllers/BlogController.php'; + $path = $this->getModuleAppPath().'/Http/Controllers/BlogController.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleBasePath() . '/database/seeders/BlogDatabaseSeeder.php'; + $path = $this->getModuleBasePath().'/database/seeders/BlogDatabaseSeeder.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); - $path = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $path = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($path)); $this->assertMatchesSnapshot($this->finder->get($path)); @@ -418,11 +420,11 @@ public function test_it_generate_module_when_provider_is_enable_and_route_provid $this->artisan('module:make', ['name' => ['Blog']]); - $providerPath = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $providerPath = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($providerPath)); $this->assertMatchesSnapshot($this->finder->get($providerPath)); - $RouteProviderPath = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; + $RouteProviderPath = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; $this->assertTrue($this->finder->exists($RouteProviderPath)); $this->assertMatchesSnapshot($this->finder->get($RouteProviderPath)); @@ -439,12 +441,12 @@ public function test_it_generate_module_when_provider_is_enable_and_route_provid $this->artisan('module:make', ['name' => ['Blog']]); - $providerPath = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; + $providerPath = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; $this->assertTrue($this->finder->exists($providerPath)); $this->assertMatchesSnapshot($this->finder->get($providerPath)); - $RouteProviderPath = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; - $this->assertTrue(!$this->finder->exists($RouteProviderPath)); + $RouteProviderPath = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; + $this->assertTrue(! $this->finder->exists($RouteProviderPath)); $content = $this->finder->get($providerPath); @@ -458,13 +460,13 @@ public function test_it_generate_module_when_provider_is_disable_and_route_provi $this->artisan('module:make', ['name' => ['Blog']]); - $providerPath = $this->getModuleAppPath() . '/Providers/BlogServiceProvider.php'; - $this->assertTrue(!$this->finder->exists($providerPath)); + $providerPath = $this->getModuleAppPath().'/Providers/BlogServiceProvider.php'; + $this->assertTrue(! $this->finder->exists($providerPath)); - $RouteProviderPath = $this->getModuleAppPath() . '/Providers/RouteServiceProvider.php'; - $this->assertTrue(!$this->finder->exists($RouteProviderPath)); + $RouteProviderPath = $this->getModuleAppPath().'/Providers/RouteServiceProvider.php'; + $this->assertTrue(! $this->finder->exists($RouteProviderPath)); - $content = $this->finder->get($this->getModuleBasePath() . '/module.json'); + $content = $this->finder->get($this->getModuleBasePath().'/module.json'); $this->assertStringNotContainsString('Modules\Blog\Providers\BlogServiceProvider', $content); } @@ -473,7 +475,7 @@ public function test_it_can_set_author_details() { $code = $this->artisan('module:make', ['name' => ['Blog'], '--author-name' => 'Joe Blogs', '--author-email' => 'user@domain.com', '--author-vendor' => 'JoeBlogs']); - $content = $this->finder->get($this->getModuleBasePath() . '/composer.json'); + $content = $this->finder->get($this->getModuleBasePath().'/composer.json'); $this->assertStringContainsString('Joe Blogs', $content); $this->assertStringContainsString('user@domain.com', $content); diff --git a/tests/Commands/Make/NotificationMakeCommandTest.php b/tests/Commands/Make/NotificationMakeCommandTest.php index 422c4ac47..432f4c177 100644 --- a/tests/Commands/Make/NotificationMakeCommandTest.php +++ b/tests/Commands/Make/NotificationMakeCommandTest.php @@ -9,10 +9,12 @@ class NotificationMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_the_notification_class() { $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Notifications/WelcomeNotification.php')); + $this->assertTrue(is_file($this->modulePath.'/Notifications/WelcomeNotification.php')); $this->assertSame(0, $code); } @@ -44,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath.'/Notifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -56,7 +58,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperNotifications/WelcomeNotification.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperNotifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,7 +70,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-notification', ['name' => 'WelcomeNotification', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Notifications/WelcomeNotification.php'); + $file = $this->finder->get($this->modulePath.'/Notifications/WelcomeNotification.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ObserverMakeCommandTest.php b/tests/Commands/Make/ObserverMakeCommandTest.php index cb45c5d4a..b043d8f41 100644 --- a/tests/Commands/Make/ObserverMakeCommandTest.php +++ b/tests/Commands/Make/ObserverMakeCommandTest.php @@ -9,10 +9,12 @@ class ObserverMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_makes_observer() { $code = $this->artisan('module:make-observer', ['name' => 'Post', 'module' => 'Blog']); - $observerFile = $this->modulePath . '/Observers/PostObserver.php'; + $observerFile = $this->modulePath.'/Observers/PostObserver.php'; $this->assertTrue(is_file($observerFile), 'Observer file was not created.'); $this->assertMatchesSnapshot($this->finder->get($observerFile)); diff --git a/tests/Commands/Make/PolicyMakeCommandTest.php b/tests/Commands/Make/PolicyMakeCommandTest.php index a7afbaf75..fec1f1a1c 100644 --- a/tests/Commands/Make/PolicyMakeCommandTest.php +++ b/tests/Commands/Make/PolicyMakeCommandTest.php @@ -9,10 +9,12 @@ class PolicyMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_makes_policy() { $code = $this->artisan('module:make-policy', ['name' => 'PostPolicy', 'module' => 'Blog']); - $policyFile = $this->modulePath . '/Policies/PostPolicy.php'; + $policyFile = $this->modulePath.'/Policies/PostPolicy.php'; $this->assertTrue(is_file($policyFile), 'Policy file was not created.'); $this->assertMatchesSnapshot($this->finder->get($policyFile)); @@ -49,7 +51,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-policy', ['name' => 'PostPolicy', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperPolicies/PostPolicy.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperPolicies/PostPolicy.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -61,7 +63,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-policy', ['name' => 'PostPolicy', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Policies/PostPolicy.php'); + $file = $this->finder->get($this->modulePath.'/Policies/PostPolicy.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ProviderMakeCommandTest.php b/tests/Commands/Make/ProviderMakeCommandTest.php index 1a422cfca..32909db35 100644 --- a/tests/Commands/Make/ProviderMakeCommandTest.php +++ b/tests/Commands/Make/ProviderMakeCommandTest.php @@ -9,10 +9,12 @@ class ProviderMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -23,7 +25,7 @@ public function setUp(): void parent::setUp(); $this->finder = $this->app['files']; $this->modulePath = $this->getModuleAppPath(); - $this->artisan('module:make', ['name' => ['Blog'], '--plain' => true, ]); + $this->artisan('module:make', ['name' => ['Blog'], '--plain' => true]); } public function tearDown(): void @@ -36,14 +38,15 @@ public function test_it_generates_a_service_provider() { $code = $this->artisan('module:make-provider', ['name' => 'MyBlogServiceProvider', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Providers/MyBlogServiceProvider.php')); + $this->assertTrue(is_file($this->modulePath.'/Providers/MyBlogServiceProvider.php')); $this->assertSame(0, $code); } + public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-provider', ['name' => 'MyBlogServiceProvider', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Providers/MyBlogServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/MyBlogServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -53,7 +56,7 @@ public function test_it_generates_a_master_service_provider_with_resource_loadin { $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); - $file = $this->finder->get($this->modulePath . '/Providers/BlogServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/BlogServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -64,7 +67,7 @@ public function test_it_can_have_custom_migration_resources_location_paths() $this->app['config']->set('modules.paths.generator.migration', 'migrations'); $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); - $file = $this->finder->get($this->modulePath . '/Providers/BlogServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/BlogServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -76,7 +79,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperProviders/BlogServiceProvider.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperProviders/BlogServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -88,7 +91,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-provider', ['name' => 'BlogServiceProvider', 'module' => 'Blog', '--master' => true]); - $file = $this->finder->get($this->modulePath . '/Providers/BlogServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/BlogServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/RepositoryMakeCommandTest.php b/tests/Commands/Make/RepositoryMakeCommandTest.php index 1518f2424..a6ea60a00 100644 --- a/tests/Commands/Make/RepositoryMakeCommandTest.php +++ b/tests/Commands/Make/RepositoryMakeCommandTest.php @@ -14,6 +14,7 @@ class RepositoryMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_repository_class() { $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Repositories/MyRepository.php')); + $this->assertTrue(is_file($this->modulePath.'/Repositories/MyRepository.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_repository_class_can_override_with_force $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog']); $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Repositories/MyRepository.php')); + $this->assertTrue(is_file($this->modulePath.'/Repositories/MyRepository.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generates_a_new_repository_class_can_use_invoke_option() { $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog', '--invokable' => true]); - $this->assertTrue(is_file($this->modulePath . '/Repositories/MyRepository.php')); + $this->assertTrue(is_file($this->modulePath.'/Repositories/MyRepository.php')); $this->assertSame(0, $code); } @@ -63,7 +64,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-repository', ['name' => 'MyRepository', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Repositories/MyRepository.php'); + $file = $this->finder->get($this->modulePath.'/Repositories/MyRepository.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -73,7 +74,7 @@ public function test_it_can_generate_a_repository_in_sub_namespace_in_correct_fo { $code = $this->artisan('module:make-repository', ['name' => 'Api\\MyRepository', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Repositories/Api/MyRepository.php')); + $this->assertTrue(is_file($this->modulePath.'/Repositories/Api/MyRepository.php')); $this->assertSame(0, $code); } @@ -81,7 +82,7 @@ public function test_it_can_generate_a_repository_in_sub_namespace_with_correct_ { $code = $this->artisan('module:make-repository', ['name' => 'Api\\MyRepository', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Repositories/Api/MyRepository.php'); + $file = $this->finder->get($this->modulePath.'/Repositories/Api/MyRepository.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/RequestMakeCommandTest.php b/tests/Commands/Make/RequestMakeCommandTest.php index 847a77d1a..ada86afa7 100644 --- a/tests/Commands/Make/RequestMakeCommandTest.php +++ b/tests/Commands/Make/RequestMakeCommandTest.php @@ -9,10 +9,12 @@ class RequestMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_a_new_form_request_class() { $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Http/Requests/CreateBlogPostRequest.php')); + $this->assertTrue(is_file($this->modulePath.'/Http/Requests/CreateBlogPostRequest.php')); $this->assertSame(0, $code); } @@ -44,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Requests/CreateBlogPostRequest.php'); + $file = $this->finder->get($this->modulePath.'/Http/Requests/CreateBlogPostRequest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -56,7 +58,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperRequests/CreateBlogPostRequest.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperRequests/CreateBlogPostRequest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -68,7 +70,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-request', ['name' => 'CreateBlogPostRequest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Http/Requests/CreateBlogPostRequest.php'); + $file = $this->finder->get($this->modulePath.'/Http/Requests/CreateBlogPostRequest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ResourceMakeCommandTest.php b/tests/Commands/Make/ResourceMakeCommandTest.php index 7d7aeaa4d..a8b040806 100644 --- a/tests/Commands/Make/ResourceMakeCommandTest.php +++ b/tests/Commands/Make/ResourceMakeCommandTest.php @@ -9,10 +9,12 @@ class ResourceMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_generates_a_new_resource_class() { $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Transformers/PostsTransformer.php')); + $this->assertTrue(is_file($this->modulePath.'/Transformers/PostsTransformer.php')); $this->assertSame(0, $code); } @@ -44,7 +46,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Transformers/PostsTransformer.php'); + $file = $this->finder->get($this->modulePath.'/Transformers/PostsTransformer.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -54,7 +56,7 @@ public function test_it_can_generate_a_collection_resource_class() { $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog', '--collection' => true]); - $file = $this->finder->get($this->modulePath . '/Transformers/PostsTransformer.php'); + $file = $this->finder->get($this->modulePath.'/Transformers/PostsTransformer.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -66,7 +68,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog', '--collection' => true]); - $file = $this->finder->get($this->modulePath . '/Http/Resources/PostsTransformer.php'); + $file = $this->finder->get($this->modulePath.'/Http/Resources/PostsTransformer.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -78,7 +80,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-resource', ['name' => 'PostsTransformer', 'module' => 'Blog', '--collection' => true]); - $file = $this->finder->get($this->modulePath . '/Transformers/PostsTransformer.php'); + $file = $this->finder->get($this->modulePath.'/Transformers/PostsTransformer.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/RouteProviderMakeCommandTest.php b/tests/Commands/Make/RouteProviderMakeCommandTest.php index a14962e52..110492fe6 100644 --- a/tests/Commands/Make/RouteProviderMakeCommandTest.php +++ b/tests/Commands/Make/RouteProviderMakeCommandTest.php @@ -9,10 +9,12 @@ class RouteProviderMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -34,7 +36,7 @@ public function tearDown(): void public function test_it_generates_a_new_service_provider_class() { - $path = $this->modulePath . '/Providers/RouteServiceProvider.php'; + $path = $this->modulePath.'/Providers/RouteServiceProvider.php'; $this->finder->delete($path); $code = $this->artisan('module:route-provider', ['module' => 'Blog']); @@ -44,7 +46,7 @@ public function test_it_generates_a_new_service_provider_class() public function test_it_generated_correct_file_with_content() { - $path = $this->modulePath . '/Providers/RouteServiceProvider.php'; + $path = $this->modulePath.'/Providers/RouteServiceProvider.php'; $this->finder->delete($path); $code = $this->artisan('module:route-provider', ['module' => 'Blog']); @@ -60,7 +62,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:route-provider', ['module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperProviders/RouteServiceProvider.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperProviders/RouteServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -70,7 +72,7 @@ public function test_it_can_change_the_default_namespace_specific() { $this->app['config']->set('modules.paths.generator.provider.namespace', 'SuperProviders'); - $path = $this->modulePath . '/Providers/RouteServiceProvider.php'; + $path = $this->modulePath.'/Providers/RouteServiceProvider.php'; $this->finder->delete($path); $code = $this->artisan('module:route-provider', ['module' => 'Blog']); @@ -87,7 +89,7 @@ public function test_it_can_overwrite_route_file_names() $code = $this->artisan('module:route-provider', ['module' => 'Blog', '--force' => true]); - $file = $this->finder->get($this->modulePath . '/Providers/RouteServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/RouteServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -99,7 +101,7 @@ public function test_it_can_overwrite_file(): void $this->app['config']->set('modules.stubs.files.routes/web', 'SuperRoutes/web.php'); $code = $this->artisan('module:route-provider', ['module' => 'Blog', '--force' => true]); - $file = $this->finder->get($this->modulePath . '/Providers/RouteServiceProvider.php'); + $file = $this->finder->get($this->modulePath.'/Providers/RouteServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -111,7 +113,7 @@ public function test_it_can_change_the_custom_controller_namespace(): void $this->app['config']->set('modules.paths.generator.provider.path', 'Base/Providers'); $code = $this->artisan('module:route-provider', ['module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/Base/Providers/RouteServiceProvider.php'); + $file = $this->finder->get($this->getModuleBasePath().'/Base/Providers/RouteServiceProvider.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/RuleMakeCommandTest.php b/tests/Commands/Make/RuleMakeCommandTest.php index 8f5602292..288b411c3 100644 --- a/tests/Commands/Make/RuleMakeCommandTest.php +++ b/tests/Commands/Make/RuleMakeCommandTest.php @@ -9,10 +9,12 @@ class RuleMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -36,7 +38,7 @@ public function test_it_makes_rule() { $code = $this->artisan('module:make-rule', ['name' => 'UniqueRule', 'module' => 'Blog']); - $ruleFile = $this->modulePath . '/Rules/UniqueRule.php'; + $ruleFile = $this->modulePath.'/Rules/UniqueRule.php'; $this->assertTrue(is_file($ruleFile), 'Rule file was not created.'); $this->assertMatchesSnapshot($this->finder->get($ruleFile)); @@ -47,7 +49,7 @@ public function test_it_makes_implicit_rule() { $code = $this->artisan('module:make-rule', ['name' => 'ImplicitUniqueRule', 'module' => 'Blog', '--implicit' => true]); - $ruleFile = $this->modulePath . '/Rules/ImplicitUniqueRule.php'; + $ruleFile = $this->modulePath.'/Rules/ImplicitUniqueRule.php'; $this->assertTrue(is_file($ruleFile), 'Rule file was not created.'); $this->assertMatchesSnapshot($this->finder->get($ruleFile)); @@ -60,7 +62,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-rule', ['name' => 'UniqueRule', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperRules/UniqueRule.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperRules/UniqueRule.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -72,7 +74,7 @@ public function test_it_can_change_the_default_namespace_specific() $code = $this->artisan('module:make-rule', ['name' => 'UniqueRule', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Rules/UniqueRule.php'); + $file = $this->finder->get($this->modulePath.'/Rules/UniqueRule.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ScopeMakeCommandTest.php b/tests/Commands/Make/ScopeMakeCommandTest.php index 260de1a2a..8033a5bc6 100644 --- a/tests/Commands/Make/ScopeMakeCommandTest.php +++ b/tests/Commands/Make/ScopeMakeCommandTest.php @@ -14,6 +14,7 @@ class ScopeMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_scope_class() { $code = $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Models/Scopes/MyScope.php')); + $this->assertTrue(is_file($this->modulePath.'/Models/Scopes/MyScope.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_scope_class_can_override_with_force_opti $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog']); $code = $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Models/Scopes/MyScope.php')); + $this->assertTrue(is_file($this->modulePath.'/Models/Scopes/MyScope.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-scope', ['name' => 'MyScope', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Models/Scopes/MyScope.php'); + $file = $this->finder->get($this->modulePath.'/Models/Scopes/MyScope.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -65,7 +66,7 @@ public function test_it_can_generate_a_scope_in_sub_namespace_in_correct_folder( { $code = $this->artisan('module:make-scope', ['name' => 'Api\\MyScope', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Models/Scopes/Api/MyScope.php')); + $this->assertTrue(is_file($this->modulePath.'/Models/Scopes/Api/MyScope.php')); $this->assertSame(0, $code); } @@ -73,7 +74,7 @@ public function test_it_can_generate_a_scope_in_sub_namespace_with_correct_gener { $code = $this->artisan('module:make-scope', ['name' => 'Api\\MyScope', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Models/Scopes/Api/MyScope.php'); + $file = $this->finder->get($this->modulePath.'/Models/Scopes/Api/MyScope.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ServiceMakeCommandTest.php b/tests/Commands/Make/ServiceMakeCommandTest.php index 390652979..cd9179e52 100644 --- a/tests/Commands/Make/ServiceMakeCommandTest.php +++ b/tests/Commands/Make/ServiceMakeCommandTest.php @@ -14,6 +14,7 @@ class ServiceMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_service_class() { $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Services/MyService.php')); + $this->assertTrue(is_file($this->modulePath.'/Services/MyService.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_service_class_can_override_with_force_op $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Services/MyService.php')); + $this->assertTrue(is_file($this->modulePath.'/Services/MyService.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generates_a_new_service_class_can_use_invoke_option() { $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog', '--invokable' => true]); - $this->assertTrue(is_file($this->modulePath . '/Services/MyService.php')); + $this->assertTrue(is_file($this->modulePath.'/Services/MyService.php')); $this->assertSame(0, $code); } @@ -63,7 +64,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-service', ['name' => 'MyService', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Services/MyService.php'); + $file = $this->finder->get($this->modulePath.'/Services/MyService.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -73,7 +74,7 @@ public function test_it_can_generate_a_service_in_sub_namespace_in_correct_folde { $code = $this->artisan('module:make-service', ['name' => 'Api\\MyService', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Services/Api/MyService.php')); + $this->assertTrue(is_file($this->modulePath.'/Services/Api/MyService.php')); $this->assertSame(0, $code); } @@ -81,7 +82,7 @@ public function test_it_can_generate_a_service_in_sub_namespace_with_correct_gen { $code = $this->artisan('module:make-service', ['name' => 'Api\\MyService', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Services/Api/MyService.php'); + $file = $this->finder->get($this->modulePath.'/Services/Api/MyService.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/TestMakeCommandTest.php b/tests/Commands/Make/TestMakeCommandTest.php index 8316c2c8c..b0d7432b9 100644 --- a/tests/Commands/Make/TestMakeCommandTest.php +++ b/tests/Commands/Make/TestMakeCommandTest.php @@ -10,10 +10,12 @@ class TestMakeCommandTest extends BaseTestCase { use MatchesSnapshots; + /** * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -44,7 +46,7 @@ public function test_it_generates_a_new_unit_test_class() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/tests/Unit/EloquentPostRepositoryTest.php')); + $this->assertTrue(is_file($this->modulePath.'/tests/Unit/EloquentPostRepositoryTest.php')); $this->assertSame(0, $code); } @@ -52,7 +54,7 @@ public function test_it_generates_a_new_feature_test_class() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $this->assertTrue(is_file($this->modulePath . '/tests/Feature/EloquentPostRepositoryTest.php')); + $this->assertTrue(is_file($this->modulePath.'/tests/Feature/EloquentPostRepositoryTest.php')); $this->assertSame(0, $code); } @@ -60,7 +62,7 @@ public function test_it_generated_correct_unit_file_with_content() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/tests/Unit/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath.'/tests/Unit/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -70,7 +72,7 @@ public function test_it_generated_correct_feature_file_with_content() { $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $file = $this->finder->get($this->modulePath . '/tests/Feature/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath.'/tests/Feature/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -82,7 +84,7 @@ public function test_it_can_change_the_default_unit_namespace() $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/SuperTests/Unit/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->getModuleBasePath().'/SuperTests/Unit/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -94,7 +96,7 @@ public function test_it_can_change_the_default_unit_namespace_specific() $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/tests/Unit/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath.'/tests/Unit/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -106,7 +108,7 @@ public function test_it_can_change_the_default_feature_namespace() $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $file = $this->finder->get($this->modulePath . '/SuperTests/Feature/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->modulePath.'/SuperTests/Feature/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -118,7 +120,7 @@ public function test_it_can_change_the_default_feature_namespace_specific() $code = $this->artisan('module:make-test', ['name' => 'EloquentPostRepositoryTest', 'module' => 'Blog', '--feature' => true]); - $file = $this->finder->get($this->getModuleBasePath() . '/tests/Feature/EloquentPostRepositoryTest.php'); + $file = $this->finder->get($this->getModuleBasePath().'/tests/Feature/EloquentPostRepositoryTest.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/TraitMakeCommandTest.php b/tests/Commands/Make/TraitMakeCommandTest.php index 563c8c77f..d8c6adf23 100644 --- a/tests/Commands/Make/TraitMakeCommandTest.php +++ b/tests/Commands/Make/TraitMakeCommandTest.php @@ -14,6 +14,7 @@ class TraitMakeCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -38,7 +39,7 @@ public function test_it_generates_a_new_trait_class() { $code = $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Traits/MyTrait.php')); + $this->assertTrue(is_file($this->modulePath.'/Traits/MyTrait.php')); $this->assertSame(0, $code); } @@ -47,7 +48,7 @@ public function test_it_generates_a_new_trait_class_can_override_with_force_opti $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog']); $code = $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog', '--force' => true]); - $this->assertTrue(is_file($this->modulePath . '/Traits/MyTrait.php')); + $this->assertTrue(is_file($this->modulePath.'/Traits/MyTrait.php')); $this->assertSame(0, $code); } @@ -55,7 +56,7 @@ public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-trait', ['name' => 'MyTrait', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Traits/MyTrait.php'); + $file = $this->finder->get($this->modulePath.'/Traits/MyTrait.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); @@ -65,7 +66,7 @@ public function test_it_can_generate_a_trait_in_sub_namespace_in_correct_folder( { $code = $this->artisan('module:make-trait', ['name' => 'Api\\MyTrait', 'module' => 'Blog']); - $this->assertTrue(is_file($this->modulePath . '/Traits/Api/MyTrait.php')); + $this->assertTrue(is_file($this->modulePath.'/Traits/Api/MyTrait.php')); $this->assertSame(0, $code); } @@ -73,7 +74,7 @@ public function test_it_can_generate_a_trait_in_sub_namespace_with_correct_gener { $code = $this->artisan('module:make-trait', ['name' => 'Api\\MyTrait', 'module' => 'Blog']); - $file = $this->finder->get($this->modulePath . '/Traits/Api/MyTrait.php'); + $file = $this->finder->get($this->modulePath.'/Traits/Api/MyTrait.php'); $this->assertMatchesSnapshot($file); $this->assertSame(0, $code); diff --git a/tests/Commands/Make/ViewMakeCommandTest.php b/tests/Commands/Make/ViewMakeCommandTest.php index cbb8e3345..8651e5680 100644 --- a/tests/Commands/Make/ViewMakeCommandTest.php +++ b/tests/Commands/Make/ViewMakeCommandTest.php @@ -16,9 +16,6 @@ class ViewMakeCommandTest extends BaseTestCase */ private mixed $finder; - /** - * @var string - */ private string $modulePath; public function setUp(): void @@ -38,14 +35,14 @@ public function tearDown(): void public function test_it_generates_the_view() { $code = $this->artisan('module:make-view', ['name' => 'Blog', 'module' => 'Blog']); - $this->assertTrue(is_file($this->getModuleBasePath() . '/resources/views/blog.blade.php')); + $this->assertTrue(is_file($this->getModuleBasePath().'/resources/views/blog.blade.php')); $this->assertSame(0, $code); } public function test_it_generated_correct_file_with_content() { $code = $this->artisan('module:make-view', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath().'/resources/views/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); } @@ -56,7 +53,7 @@ public function test_it_can_change_the_default_namespace() $code = $this->artisan('module:make-view', ['name' => 'Blog', 'module' => 'Blog']); - $file = $this->finder->get($this->getModuleBasePath() . '/resources/views/blog.blade.php'); + $file = $this->finder->get($this->getModuleBasePath().'/resources/views/blog.blade.php'); $this->assertTrue(str_contains($file, '
')); $this->assertSame(0, $code); diff --git a/tests/Commands/Publish/PublishCommandTest.php b/tests/Commands/Publish/PublishCommandTest.php index 4adf556cf..7aa02e1e2 100644 --- a/tests/Commands/Publish/PublishCommandTest.php +++ b/tests/Commands/Publish/PublishCommandTest.php @@ -11,6 +11,7 @@ class PublishCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ @@ -22,7 +23,7 @@ public function setUp(): void $this->createModule(); $this->modulePath = $this->getModuleBasePath(); $this->finder = $this->app['files']; - $this->finder->put($this->modulePath . '/resources/assets/script.js', 'assetfile'); + $this->finder->put($this->modulePath.'/resources/assets/script.js', 'assetfile'); } public function tearDown(): void diff --git a/tests/Commands/Publish/PublishMigrationCommandTest.php b/tests/Commands/Publish/PublishMigrationCommandTest.php index 0e7ec84f9..9eb005726 100644 --- a/tests/Commands/Publish/PublishMigrationCommandTest.php +++ b/tests/Commands/Publish/PublishMigrationCommandTest.php @@ -11,6 +11,7 @@ class PublishMigrationCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ diff --git a/tests/Commands/Publish/PublishTranslationCommandTest.php b/tests/Commands/Publish/PublishTranslationCommandTest.php index 04fee0848..0e8da296d 100644 --- a/tests/Commands/Publish/PublishTranslationCommandTest.php +++ b/tests/Commands/Publish/PublishTranslationCommandTest.php @@ -11,6 +11,7 @@ class PublishTranslationCommandTest extends BaseTestCase * @var \Illuminate\Filesystem\Filesystem */ private $finder; + /** * @var string */ diff --git a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.php index 99de97898..1289f84e2 100644 --- a/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.php +++ b/tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.php @@ -1,4 +1,6 @@ -json = new Json($path, $this->app['files']); } public function test_it_gets_the_file_path() { - $path = __DIR__ . '/stubs/valid/module.json'; + $path = __DIR__.'/stubs/valid/module.json'; $this->assertEquals($path, $this->json->getPath()); } public function test_it_throws_an_exception_with_invalid_json() { - $path = __DIR__ . '/stubs/InvalidJsonModule/module.json'; + $path = __DIR__.'/stubs/InvalidJsonModule/module.json'; $this->expectException(InvalidJsonException::class); - $this->expectExceptionMessage('Error processing file: ' . $path . '. Error: Syntax error'); + $this->expectExceptionMessage('Error processing file: '.$path.'. Error: Syntax error'); new Json($path, $this->app['files']); } @@ -60,7 +60,7 @@ public function test_it_reads_attributes_from_magic_get_method() public function test_it_makes_json_class() { - $path = __DIR__ . '/stubs/valid/module.json'; + $path = __DIR__.'/stubs/valid/module.json'; $json = Json::make($path, $this->app['files']); $this->assertInstanceOf(Json::class, $json); @@ -68,7 +68,7 @@ public function test_it_makes_json_class() public function test_it_sets_a_path() { - $path = __DIR__ . '/stubs/valid/module.json'; + $path = __DIR__.'/stubs/valid/module.json'; $this->assertEquals($path, $this->json->getPath()); $this->json->setPath('some/path.json'); @@ -131,6 +131,6 @@ public function test_it_can_be_casted_to_string() ] } '; - $this->assertEquals($expected, (string)$this->json); + $this->assertEquals($expected, (string) $this->json); } } diff --git a/tests/LaravelFileRepositoryTest.php b/tests/LaravelFileRepositoryTest.php index 77b28731b..17bffa4a4 100644 --- a/tests/LaravelFileRepositoryTest.php +++ b/tests/LaravelFileRepositoryTest.php @@ -46,7 +46,7 @@ public function test_it_adds_location_to_paths() public function test_it_returns_a_collection() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->assertInstanceOf(Collection::class, $this->repository->toCollection()); $this->assertInstanceOf(Collection::class, $this->repository->collections()); @@ -54,7 +54,7 @@ public function test_it_returns_a_collection() public function test_it_returns_all_enabled_modules() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->assertCount(0, $this->repository->getByStatus(true)); $this->assertCount(0, $this->repository->allEnabled()); @@ -62,7 +62,7 @@ public function test_it_returns_all_enabled_modules() public function test_it_returns_all_disabled_modules() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->assertCount(2, $this->repository->getByStatus(false)); $this->assertCount(2, $this->repository->allDisabled()); @@ -70,14 +70,14 @@ public function test_it_returns_all_disabled_modules() public function test_it_counts_all_modules() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->assertEquals(2, $this->repository->count()); } public function test_it_finds_a_module() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->assertInstanceOf(Module::class, $this->repository->find('recipe')); } @@ -91,7 +91,7 @@ public function test_it_find_or_fail_throws_exception_if_module_not_found() public function test_it_finds_the_module_asset_path() { - $this->repository->addLocation(__DIR__ . '/stubs/valid/Recipe'); + $this->repository->addLocation(__DIR__.'/stubs/valid/Recipe'); $assetPath = $this->repository->assetPath('recipe'); $this->assertEquals(public_path('modules/recipe'), $assetPath); @@ -106,7 +106,7 @@ public function test_it_gets_the_used_storage_path() public function test_it_sets_used_module() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->repository->setUsed('Recipe'); @@ -140,7 +140,7 @@ public function test_it_throws_exception_if_module_is_omitted() public function test_it_can_detect_if_module_is_active() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->repository->enable('Recipe'); @@ -149,7 +149,7 @@ public function test_it_can_detect_if_module_is_active() public function test_it_can_detect_if_module_is_inactive() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->repository->isDisabled('Recipe'); @@ -177,7 +177,7 @@ public function test_it_returns_default_stub_path() public function test_it_can_disabled_a_module() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->repository->disable('Recipe'); @@ -186,7 +186,7 @@ public function test_it_can_disabled_a_module() public function test_it_can_enable_a_module() { - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $this->repository->enable('Recipe'); @@ -221,7 +221,7 @@ public function test_it_calls_macros_on_modules() return strrev($this->getLowerName()); }); - $this->repository->addLocation(__DIR__ . '/stubs/valid'); + $this->repository->addLocation(__DIR__.'/stubs/valid'); $module = $this->repository->find('recipe'); $this->assertEquals('epicer', $module->getReverseName()); diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index 3050c5526..a529d7001 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -23,7 +23,7 @@ class LaravelModuleTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid/Recipe'); + $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid/Recipe'); $this->activator = $this->app[ActivatorInterface::class]; } @@ -36,13 +36,13 @@ public function tearDown(): void public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - symlink(__DIR__ . '/stubs/valid', __DIR__ . '/stubs/valid_symlink'); + symlink(__DIR__.'/stubs/valid', __DIR__.'/stubs/valid_symlink'); } public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); - unlink(__DIR__ . '/stubs/valid_symlink'); + unlink(__DIR__.'/stubs/valid_symlink'); } public function test_it_gets_module_name() @@ -72,23 +72,23 @@ public function test_it_gets_module_description() public function test_it_gets_module_path() { - $this->assertEquals(__DIR__ . '/stubs/valid/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__.'/stubs/valid/Recipe', $this->module->getPath()); } public function test_it_gets_module_path_with_symlink() { // symlink created in setUpBeforeClass - $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid_symlink/Recipe'); + $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid_symlink/Recipe'); - $this->assertEquals(__DIR__ . '/stubs/valid_symlink/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__.'/stubs/valid_symlink/Recipe', $this->module->getPath()); // symlink deleted in tearDownAfterClass } public function test_it_loads_module_translations() { - (new TestingModule($this->app, 'Recipe', __DIR__ . '/stubs/valid/Recipe'))->boot(); + (new TestingModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'))->boot(); $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); } @@ -188,8 +188,7 @@ public function test_it_makes_a_manifest_file_when_providers_are_loaded() ], 'eager' => [RecipeServiceProvider::class], 'deferred' => ['deferred' => DeferredServiceProvider::class], - 'when' => - [DeferredServiceProvider::class => []], + 'when' => [DeferredServiceProvider::class => []], ], $manifest); } diff --git a/tests/LumenModuleTest.php b/tests/LumenModuleTest.php index a71362664..2f2b1a8bc 100644 --- a/tests/LumenModuleTest.php +++ b/tests/LumenModuleTest.php @@ -21,7 +21,7 @@ class LumenModuleTest extends BaseTestCase public function setUp(): void { parent::setUp(); - $this->module = new LumenTestingModule($this->app, 'Recipe Name', __DIR__ . '/stubs/valid/Recipe'); + $this->module = new LumenTestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid/Recipe'); $this->activator = $this->app[ActivatorInterface::class]; } @@ -58,12 +58,12 @@ public function test_it_gets_module_description() public function test_it_gets_module_path() { - $this->assertEquals(__DIR__ . '/stubs/valid/Recipe', $this->module->getPath()); + $this->assertEquals(__DIR__.'/stubs/valid/Recipe', $this->module->getPath()); } public function test_it_loads_module_translations() { - (new LumenTestingModule($this->app, 'Recipe', __DIR__ . '/stubs/valid/Recipe'))->boot(); + (new LumenTestingModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'))->boot(); $this->assertEquals('Recipe', trans('recipe::recipes.title.recipes')); } diff --git a/tests/StubTest.php b/tests/StubTest.php index 76eda24cd..00089f026 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -35,7 +35,7 @@ public function test_it_initialises_a_stub_instance() ]); $this->assertTrue(Str::contains($stub->getPath(), 'src/Commands/stubs/model.stub')); - $this->assertEquals(['NAME' => 'Name', ], $stub->getReplaces()); + $this->assertEquals(['NAME' => 'Name'], $stub->getReplaces()); } public function test_it_sets_new_replaces_array() @@ -44,8 +44,8 @@ public function test_it_sets_new_replaces_array() 'NAME' => 'Name', ]); - $stub->replace(['VENDOR' => 'MyVendor', ]); - $this->assertEquals(['VENDOR' => 'MyVendor', ], $stub->getReplaces()); + $stub->replace(['VENDOR' => 'MyVendor']); + $this->assertEquals(['VENDOR' => 'MyVendor'], $stub->getReplaces()); } public function test_it_stores_stub_to_specific_path() @@ -80,7 +80,7 @@ public function test_use_default_stub_if_override_not_exists() 'CLASS' => 'MyCommand', ]); - $stub->setBasePath(__DIR__ . '/stubs'); + $stub->setBasePath(__DIR__.'/stubs'); $stub->saveTo(base_path(), 'stub-override-not-exists.php'); @@ -93,7 +93,7 @@ public function test_use_override_stub_if_exists() 'NAME' => 'Name', ]); - $stub->setBasePath(__DIR__ . '/stubs'); + $stub->setBasePath(__DIR__.'/stubs'); $stub->saveTo(base_path(), 'stub-override-exists.php'); diff --git a/tests/stubs/valid/Recipe/Config/permissions.php b/tests/stubs/valid/Recipe/Config/permissions.php index d08af9b1d..52e145034 100644 --- a/tests/stubs/valid/Recipe/Config/permissions.php +++ b/tests/stubs/valid/Recipe/Config/permissions.php @@ -9,6 +9,6 @@ 'update', 'destroy', ], -// append + // append ]; diff --git a/tests/stubs/valid/Recipe/Entities/Recipe.php b/tests/stubs/valid/Recipe/Entities/Recipe.php index cf640e89e..4fe8ccc0e 100644 --- a/tests/stubs/valid/Recipe/Entities/Recipe.php +++ b/tests/stubs/valid/Recipe/Entities/Recipe.php @@ -8,10 +8,12 @@ class Recipe extends Model { - use Translatable; use MediaRelation; + use Translatable; protected $table = 'recipe__recipes'; + public $translatedAttributes = ['name', 'content']; + protected $fillable = ['name', 'content']; } diff --git a/tests/stubs/valid/Recipe/Entities/RecipeTranslation.php b/tests/stubs/valid/Recipe/Entities/RecipeTranslation.php index 98d0aac7d..ac2e993a6 100644 --- a/tests/stubs/valid/Recipe/Entities/RecipeTranslation.php +++ b/tests/stubs/valid/Recipe/Entities/RecipeTranslation.php @@ -7,6 +7,8 @@ class RecipeTranslation extends Model { public $timestamps = false; + protected $fillable = ['name', 'content']; + protected $table = 'recipe__recipe_translations'; } diff --git a/tests/stubs/valid/Recipe/Events/RecipeWasCreated.php b/tests/stubs/valid/Recipe/Events/RecipeWasCreated.php index f1957f1dd..da788b84f 100644 --- a/tests/stubs/valid/Recipe/Events/RecipeWasCreated.php +++ b/tests/stubs/valid/Recipe/Events/RecipeWasCreated.php @@ -6,13 +6,8 @@ class RecipeWasCreated implements StoringMedia { - /** - * @var - */ private $recipe; - /** - * @var - */ + private $data; public function __construct($recipe, $data) @@ -23,6 +18,7 @@ public function __construct($recipe, $data) /** * Return the entity + * * @return \Illuminate\Database\Eloquent\Model */ public function getEntity() @@ -32,6 +28,7 @@ public function getEntity() /** * Return the ALL data sent + * * @return array */ public function getSubmissionData() diff --git a/tests/stubs/valid/Recipe/Http/Controllers/Admin/RecipeController.php b/tests/stubs/valid/Recipe/Http/Controllers/Admin/RecipeController.php index 6136da9d0..43cf708b0 100644 --- a/tests/stubs/valid/Recipe/Http/Controllers/Admin/RecipeController.php +++ b/tests/stubs/valid/Recipe/Http/Controllers/Admin/RecipeController.php @@ -14,6 +14,7 @@ class RecipeController extends AdminBaseController * @var RecipeRepository */ private $recipe; + /** * @var FileRepository */ @@ -52,7 +53,6 @@ public function create() /** * Store a newly created resource in storage. * - * @param Request $request * @return Response */ public function store(Request $request) @@ -67,7 +67,6 @@ public function store(Request $request) /** * Show the form for editing the specified resource. * - * @param Recipe $recipe * @return Response */ public function edit(Recipe $recipe) @@ -81,8 +80,6 @@ public function edit(Recipe $recipe) /** * Update the specified resource in storage. * - * @param Recipe $recipe - * @param Request $request * @return Response */ public function update(Recipe $recipe, Request $request) @@ -97,7 +94,6 @@ public function update(Recipe $recipe, Request $request) /** * Remove the specified resource from storage. * - * @param Recipe $recipe * @return Response */ public function destroy(Recipe $recipe) diff --git a/tests/stubs/valid/Recipe/Http/backendRoutes.php b/tests/stubs/valid/Recipe/Http/backendRoutes.php index 255c485a3..f5bd5efc9 100644 --- a/tests/stubs/valid/Recipe/Http/backendRoutes.php +++ b/tests/stubs/valid/Recipe/Http/backendRoutes.php @@ -8,12 +8,12 @@ return app('Modules\Recipe\Repositories\RecipeRepository')->find($id); }); $router->resource('recipes', 'RecipeController', ['except' => ['show'], 'names' => [ - 'index' => 'admin.recipe.recipe.index', - 'create' => 'admin.recipe.recipe.create', - 'store' => 'admin.recipe.recipe.store', - 'edit' => 'admin.recipe.recipe.edit', - 'update' => 'admin.recipe.recipe.update', - 'destroy' => 'admin.recipe.recipe.destroy', - ]]); + 'index' => 'admin.recipe.recipe.index', + 'create' => 'admin.recipe.recipe.create', + 'store' => 'admin.recipe.recipe.store', + 'edit' => 'admin.recipe.recipe.edit', + 'update' => 'admin.recipe.recipe.update', + 'destroy' => 'admin.recipe.recipe.destroy', + ]]); // append }); diff --git a/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php b/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php index 446473628..65ba14f66 100644 --- a/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php +++ b/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php @@ -19,7 +19,7 @@ public function register() }); app()->bind('deferred', function () { - return; + }); } diff --git a/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php b/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php index 3ef5fd411..a914dee15 100644 --- a/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php +++ b/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php @@ -30,7 +30,7 @@ public function register() */ public function provides() { - return array(); + return []; } private function registerBindings() diff --git a/tests/stubs/valid/Recipe/Sidebar/SidebarExtender.php b/tests/stubs/valid/Recipe/Sidebar/SidebarExtender.php index 47d27eee2..fce3410d2 100644 --- a/tests/stubs/valid/Recipe/Sidebar/SidebarExtender.php +++ b/tests/stubs/valid/Recipe/Sidebar/SidebarExtender.php @@ -15,8 +15,6 @@ class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender protected $auth; /** - * @param Authentication $auth - * * @internal param Guard $guard */ public function __construct(Authentication $auth) @@ -25,8 +23,6 @@ public function __construct(Authentication $auth) } /** - * @param Menu $menu - * * @return Menu */ public function extendWith(Menu $menu) From f804ead6878394b8e331ac42ca7e258451b2a901 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 20 Jun 2024 08:42:13 +0100 Subject: [PATCH 367/422] Update provider.stub Generates proper component namespace (custom namespace is fully supported). --- src/Commands/stubs/scaffold/provider.stub | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 494f100a3..0273ebbe5 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -4,9 +4,12 @@ namespace $NAMESPACE$; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class $CLASS$ extends ServiceProvider { + use PathNamespace; + protected string $moduleName = '$MODULE$'; protected string $moduleNameLower = '$LOWER_NAME$'; @@ -89,7 +92,7 @@ class $CLASS$ extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('$MODULE$', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From d03897aa17099b0dce40ffee235b6be5d1861d6a Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 20 Jun 2024 09:05:19 +0100 Subject: [PATCH 368/422] Update app_path Replace duplicate custom|default app paths properly --- src/Traits/PathNamespace.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Traits/PathNamespace.php b/src/Traits/PathNamespace.php index 6467ad56c..537aafe28 100644 --- a/src/Traits/PathNamespace.php +++ b/src/Traits/PathNamespace.php @@ -55,8 +55,20 @@ public function clean_path(string $path, $ds = '/'): string public function app_path(?string $path = null): string { $config_path = config('modules.paths.app_folder'); - $app_path = strlen($config_path) ? trim($config_path, '/') : 'app'; - $app_path .= strlen($path) ? '/'.$path : ''; + + // Get modules config app path or use Laravel default app path. + $app_path = strlen($config_path) ? $config_path : 'app/'; + + if ($path) { + // Replace duplicate custom|default app paths + $replaces = array_unique([$this->clean_path($app_path).'/', 'app/']); + do { + $path = Str::of($path)->replaceStart($app_path, '')->replaceStart('app/', ''); + } while (Str::of($path)->startsWith($replaces)); + + // Append additional path + $app_path .= strlen($path) ? '/'.$path : ''; + } return $this->clean_path($app_path); } From 586e8e78ef8f02928e7ad0274f37cc7030efdf95 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 20 Jun 2024 09:45:12 +0100 Subject: [PATCH 369/422] Updated snapshots Implemented the PathNamespace trait in the BlogServiceProvider class, enhancing the process of defining the component namespace. This change should make the process of configuring module-based namespaces more efficient and readable. --- ...mandTest__test_it_can_change_the_default_namespace__1.txt | 5 ++++- ..._test_it_can_change_the_default_namespace_specific__1.txt | 5 ++++- ...can_have_custom_migration_resources_location_paths__1.txt | 5 ++++- ...es_a_master_service_provider_with_resource_loading__1.txt | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index bb17c3614..c408147d2 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\SuperProviders; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index bb17c3614..c408147d2 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\SuperProviders; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt index 26918b859..4fb63f250 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt index 713ae6f3a..0fecf660c 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From 4158e8b651090478d16585a4ec20521d6d3823d8 Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 20 Jun 2024 10:02:04 +0100 Subject: [PATCH 370/422] Updated snapshots Implemented the PathNamespace trait in the BlogServiceProvider class, enhancing the process of defining the component namespace. This change should make the process of configuring module-based namespaces more efficient and readable. --- ...n_provider_is_enable_and_route_provider_is_disable__1.txt | 5 ++++- ...en_provider_is_enable_and_route_provider_is_enable__1.txt | 5 ++++- ...dTest__test_it_generates_api_module_with_resources__1.txt | 5 ++++- ...st_it_generates_module_namespace_using_studly_case__1.txt | 5 ++++- ...akeCommandTest__test_it_generates_module_resources__1.txt | 5 ++++- ...dTest__test_it_generates_web_module_with_resources__1.txt | 5 ++++- ...le_with_resources_when_adding_more_than_one_option__1.txt | 5 ++++- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt index ea1386145..dc364ea70 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt index 713ae6f3a..0fecf660c 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt index 713ae6f3a..0fecf660c 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt index 560ac5db1..4d8fb5124 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -4,9 +4,12 @@ namespace Modules\ModuleName\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class ModuleNameServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'ModuleName'; protected string $moduleNameLower = 'modulename'; @@ -89,7 +92,7 @@ class ModuleNameServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('ModuleName', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt index 713ae6f3a..0fecf660c 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt index 713ae6f3a..0fecf660c 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 713ae6f3a..0fecf660c 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -4,9 +4,12 @@ namespace Modules\Blog\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Nwidart\Modules\Traits\PathNamespace; class BlogServiceProvider extends ServiceProvider { + use PathNamespace; + protected string $moduleName = 'Blog'; protected string $moduleNameLower = 'blog'; @@ -89,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); + $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From 7325a3610718115b63cb643d1d6da2e0b30cf560 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 20 Jun 2024 10:53:14 +0100 Subject: [PATCH 371/422] [patch] Use class property Use class property for `$this->moduleName` instead of static string. --- src/Commands/stubs/scaffold/provider.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 0273ebbe5..7199be96a 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -92,7 +92,7 @@ class $CLASS$ extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('$MODULE$', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From 69d88aaf2d767f368b037ff069451672e336e3d4 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 20 Jun 2024 11:16:42 +0100 Subject: [PATCH 372/422] [test] Update snapshots --- ...when_provider_is_enable_and_route_provider_is_disable__1.txt | 2 +- ..._when_provider_is_enable_and_route_provider_is_enable__1.txt | 2 +- ...mandTest__test_it_generates_api_module_with_resources__1.txt | 2 +- ..._test_it_generates_module_namespace_using_studly_case__1.txt | 2 +- ...leMakeCommandTest__test_it_generates_module_resources__1.txt | 2 +- ...mandTest__test_it_generates_web_module_with_resources__1.txt | 2 +- ...odule_with_resources_when_adding_more_than_one_option__1.txt | 2 +- ...CommandTest__test_it_can_change_the_default_namespace__1.txt | 2 +- ...st__test_it_can_change_the_default_namespace_specific__1.txt | 2 +- ...it_can_have_custom_migration_resources_location_paths__1.txt | 2 +- ...rates_a_master_service_provider_with_resource_loading__1.txt | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt index dc364ea70..cd8b623df 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt index 0fecf660c..62bd6a496 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt index 0fecf660c..62bd6a496 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt index 4d8fb5124..f6c99ebc3 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt @@ -92,7 +92,7 @@ class ModuleNameServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('ModuleName', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt index 0fecf660c..62bd6a496 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt index 0fecf660c..62bd6a496 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt index 0fecf660c..62bd6a496 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index c408147d2..86ef5859a 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index c408147d2..86ef5859a 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt index 4fb63f250..991b8969b 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } diff --git a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt index 0fecf660c..62bd6a496 100644 --- a/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt +++ b/tests/Commands/Make/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt @@ -92,7 +92,7 @@ class BlogServiceProvider extends ServiceProvider $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - $componentNamespace = $this->module_namespace('Blog', $this->app_path(config('modules.paths.generator.component-class.path'))); + $componentNamespace = $this->module_namespace($this->moduleName, $this->app_path(config('modules.paths.generator.component-class.path'))); Blade::componentNamespace($componentNamespace, $this->moduleNameLower); } From 68928b2853c155ef797ef6e269bb1d181f01b3bd Mon Sep 17 00:00:00 2001 From: David Carr Date: Thu, 20 Jun 2024 14:46:24 +0100 Subject: [PATCH 373/422] added tests --- tests/Traits/PathNamespaceTest.php | 51 ++++++++++++++++++++++++++ tests/Traits/UsePathNamespaceTrait.php | 10 +++++ 2 files changed, 61 insertions(+) create mode 100644 tests/Traits/PathNamespaceTest.php create mode 100644 tests/Traits/UsePathNamespaceTrait.php diff --git a/tests/Traits/PathNamespaceTest.php b/tests/Traits/PathNamespaceTest.php new file mode 100644 index 000000000..ceffac04e --- /dev/null +++ b/tests/Traits/PathNamespaceTest.php @@ -0,0 +1,51 @@ +class = new UsePathNamespaceTrait(); + } + + public function test_studly_path() + { + $this->assertSame('Blog/Services', $this->class->studly_path('/blog/services')); + } + + public function test_studly_namespace() + { + $this->assertSame('/blog/services', $this->class->studly_namespace('/blog/services')); + } + + public function test_path_namespace() + { + $this->assertSame('Blog\Services', $this->class->path_namespace('/blog/services')); + } + + public function test_module_namespace() + { + $this->assertSame('Modules\Blog/services', $this->class->module_namespace('blog/services')); + } + + public function test_clean_path() + { + $this->assertSame('blog/services', $this->class->clean_path('blog/services')); + $this->assertSame('', $this->class->clean_path('')); + } + + public function test_app_path() + { + $configPath = config('modules.paths.app_folder'); + $configPath = rtrim($configPath, '/'); + + $this->assertSame($configPath, $this->class->app_path()); + $this->assertSame($configPath, $this->class->app_path(null)); + $this->assertSame('app/blog/services', $this->class->app_path('blog/services')); + } +} diff --git a/tests/Traits/UsePathNamespaceTrait.php b/tests/Traits/UsePathNamespaceTrait.php new file mode 100644 index 000000000..1eaff1d60 --- /dev/null +++ b/tests/Traits/UsePathNamespaceTrait.php @@ -0,0 +1,10 @@ + Date: Fri, 21 Jun 2024 02:48:09 +0330 Subject: [PATCH 374/422] [fix] delete read json file form cache --- src/Json.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Json.php b/src/Json.php index eaf94063b..ff1d1a0cd 100644 --- a/src/Json.php +++ b/src/Json.php @@ -116,7 +116,7 @@ public function getContents() */ public function decodeContents() { - $attributes = json_decode($this->getContents(), 1); + $attributes = $this->filesystem->json($this->getPath()); // any JSON parsing errors should throw an exception if (json_last_error() > 0) { @@ -136,13 +136,7 @@ public function decodeContents() */ public function getAttributes() { - if (config('modules.cache.enabled') === false) { - return $this->decodeContents(); - } - - return app('cache')->store(config('modules.cache.driver'))->remember($this->getPath(), config('modules.cache.lifetime'), function () { - return $this->decodeContents(); - }); + return $this->decodeContents(); } /** From b9cbb420e1e9a316b8bdf56182c235d16bea0025 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 21 Jun 2024 14:43:32 +0330 Subject: [PATCH 375/422] [feat] implement class manifest and register it on provider --- src/LaravelModulesServiceProvider.php | 11 ++ src/ModuleManifest.php | 163 ++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 src/ModuleManifest.php diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index 7fd540e85..a42e2046d 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules; use Composer\InstalledVersions; +use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Console\AboutCommand; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; @@ -16,6 +17,16 @@ class LaravelModulesServiceProvider extends ModulesServiceProvider public function boot() { $this->registerNamespaces(); + + $this->app->singleton( + ModuleManifest::class, + fn () => new ModuleManifest( + new Filesystem(), + app(Contracts\RepositoryInterface::class)->getScanPaths(), + $this->getCachedModulePath() + ) + ); + $this->registerModules(); AboutCommand::add('Laravel-Modules', [ diff --git a/src/ModuleManifest.php b/src/ModuleManifest.php new file mode 100644 index 000000000..76555bcac --- /dev/null +++ b/src/ModuleManifest.php @@ -0,0 +1,163 @@ +files = $files; + $this->paths = collect($paths); + $this->manifestPath = $manifestPath; + } + + /** + * Get all of the service provider class names for all packages. + * + * @return array + */ + public function providers() + { + return $this->config('providers'); + } + + /** + * Get all of the service provider class names for all packages. + * + * @return array + */ + public function providersArray() + { + return $this->getManifest()['providers'] ?? []; + } + + /** + * Get all of the aliases for all packages. + * + * @return array + */ + public function aliases() + { + return $this->config('aliases'); + } + + /** + * Get all of the values for all packages for the given configuration name. + * + * @param string $key + * @return array + */ + public function config($key) + { + return collect($this->getManifest())->flatMap(function ($configuration) use ($key) { + return (array) ($configuration[$key] ?? []); + })->filter()->all(); + } + + /** + * Get the current package manifest. + * + * @return array + */ + protected function getManifest() + { + if (! is_null($this->manifest)) { + return $this->manifest; + } + + if (! is_file($this->manifestPath)) { + $this->build(); + } + + return $this->manifest = is_file($this->manifestPath) ? + $this->files->getRequire($this->manifestPath) : []; + } + + /** + * Build the manifest and write it to disk. + * + * @return void + */ + public function build() + { + $providers = $this->paths + ->flatMap(function ($path) { + $manifests = $this->files->glob("{$path}/module.json"); + is_array($manifests) || $manifests = []; + + return collect($manifests) + ->map(function ($manifest) { + return $this->files->json($manifest); + }); + }) + ->sortBy(fn ($module) => $module['priority'] ?? 0) + ->pluck('providers') + ->flatten() + ->filter() + ->toArray(); + + $this->write( + [ + 'providers' => $providers, + 'eager' => $providers, + 'deferred' => [], + ] + ); + } + + /** + * Write the given manifest array to disk. + * + * @return void + * + * @throws \Exception + */ + protected function write(array $manifest) + { + if (! is_writable($dirname = dirname($this->manifestPath))) { + throw new Exception("The {$dirname} directory must be present and writable."); + } + $this->files->replace( + $this->manifestPath, + ' Date: Fri, 21 Jun 2024 14:49:12 +0330 Subject: [PATCH 376/422] [feat] register provider with manifeset class --- src/ModulesServiceProvider.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index ae6cbc1d4..0a7658d1e 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -2,8 +2,10 @@ namespace Nwidart\Modules; +use Illuminate\Filesystem\Filesystem; +use Illuminate\Foundation\ProviderRepository; use Illuminate\Support\ServiceProvider; -use Nwidart\Modules\Providers\BootstrapServiceProvider; +use Illuminate\Support\Str; use Nwidart\Modules\Providers\ConsoleServiceProvider; use Nwidart\Modules\Providers\ContractsServiceProvider; @@ -12,23 +14,25 @@ abstract class ModulesServiceProvider extends ServiceProvider /** * Booting the package. */ - public function boot() - { - } + public function boot() {} /** * Register all modules. */ - public function register() - { - } + public function register() {} /** * Register all modules. */ protected function registerModules() { - $this->app->register(BootstrapServiceProvider::class); + // $this->app->register(\Nwidart\Modules\Providers\BootstrapServiceProvider::class); + + $providers = app()->make(ModuleManifest::class)->providersArray(); + + (new ProviderRepository($this->app, new Filesystem(), $this->getCachedModulePath())) + ->load($providers); + } /** @@ -75,4 +79,9 @@ protected function registerProviders() $this->app->register(ConsoleServiceProvider::class); $this->app->register(ContractsServiceProvider::class); } + + protected function getCachedModulePath() + { + return Str::replaceLast('services.php', 'modules.php', $this->app->getCachedServicesPath()); + } } From 69094ce2065d83c38ff86c39049a9fa2f8d643a8 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 21 Jun 2024 15:08:12 +0330 Subject: [PATCH 377/422] [feat] add command module:discover to create manifest --- src/Commands/ModuleDiscoverCommand.php | 36 ++++++++++++++++++++++++ src/Providers/ConsoleServiceProvider.php | 1 + 2 files changed, 37 insertions(+) create mode 100644 src/Commands/ModuleDiscoverCommand.php diff --git a/src/Commands/ModuleDiscoverCommand.php b/src/Commands/ModuleDiscoverCommand.php new file mode 100644 index 000000000..f83f071cb --- /dev/null +++ b/src/Commands/ModuleDiscoverCommand.php @@ -0,0 +1,36 @@ +components->info('Discovering modules'); + + $manifest->build(); + + collect($manifest->providersArray()) + ->map(fn ($provider) => preg_match('/Modules\\\\(.*?)\\\\/', $provider, $matches) ? $matches[1] : null) + ->unique() + ->each(fn ($description) => $this->components->task($description)) + ->whenNotEmpty(fn () => $this->newLine()); + } +} diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 28a2f3163..3313ea2f3 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -95,6 +95,7 @@ public static function defaultCommands(): Collection Commands\ComposerUpdateCommand::class, Commands\LaravelModulesV6Migrator::class, Commands\SetupCommand::class, + Commands\ModuleDiscoverCommand::class, Commands\Database\MigrateFreshCommand::class, ]); From 4cfd817a07baff6e6d66f5e1ca0f84d1bc783cf4 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 21 Jun 2024 15:28:23 +0330 Subject: [PATCH 378/422] [feat] add command module:clear-compiled to clear module.php file --- src/Commands/ModuleClearCompiledCommand.php | 32 +++++++++++++++++++++ src/Providers/ConsoleServiceProvider.php | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/Commands/ModuleClearCompiledCommand.php diff --git a/src/Commands/ModuleClearCompiledCommand.php b/src/Commands/ModuleClearCompiledCommand.php new file mode 100644 index 000000000..c02cb0bf4 --- /dev/null +++ b/src/Commands/ModuleClearCompiledCommand.php @@ -0,0 +1,32 @@ +manifestPath)) { + @unlink($manifest->manifestPath); + } + + $this->components->info('Compiled module files removed successfully.'); + } +} diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 3313ea2f3..eb39dbec9 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -94,8 +94,9 @@ public static function defaultCommands(): Collection // Other Commands Commands\ComposerUpdateCommand::class, Commands\LaravelModulesV6Migrator::class, - Commands\SetupCommand::class, Commands\ModuleDiscoverCommand::class, + Commands\ModuleClearCompiledCommand::class, + Commands\SetupCommand::class, Commands\Database\MigrateFreshCommand::class, ]); From fce7b3b6bebfe4074e21b63de83cb0400714034f Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 30 Jun 2024 11:49:53 +0100 Subject: [PATCH 379/422] Update ModuleGenerator methods DocBlock --- src/Generators/ModuleGenerator.php | 119 +++++++---------------------- 1 file changed, 28 insertions(+), 91 deletions(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 8befb6287..de95fde57 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -8,6 +8,7 @@ use Illuminate\Support\Str; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\FileRepository; +use Nwidart\Modules\Module; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; use Nwidart\Modules\Traits\PathNamespace; @@ -119,11 +120,8 @@ public function __construct( /** * Set type. - * - * @param string $type - * @return $this */ - public function setType($type) + public function setType(string $type): self { $this->type = $type; @@ -132,11 +130,8 @@ public function setType($type) /** * Set active flag. - * - * - * @return $this */ - public function setActive(bool $active) + public function setActive(bool $active): self { $this->isActive = $active; @@ -145,31 +140,24 @@ public function setActive(bool $active) /** * Get the name of module will created. By default in studly case. - * - * @return string */ - public function getName() + public function getName(): string { return Str::studly($this->name); } /** * Get the laravel config instance. - * - * @return Config */ - public function getConfig() + public function getConfig(): Config { return $this->config; } /** * Set the laravel config instance. - * - * @param Config $config - * @return $this */ - public function setConfig($config) + public function setConfig(Config $config): self { $this->config = $config; @@ -178,11 +166,8 @@ public function setConfig($config) /** * Set the modules activator - * - * - * @return $this */ - public function setActivator(ActivatorInterface $activator) + public function setActivator(ActivatorInterface $activator): self { $this->activator = $activator; @@ -191,21 +176,16 @@ public function setActivator(ActivatorInterface $activator) /** * Get the laravel filesystem instance. - * - * @return Filesystem */ - public function getFilesystem() + public function getFilesystem(): Filesystem { return $this->filesystem; } /** * Set the laravel filesystem instance. - * - * @param Filesystem $filesystem - * @return $this */ - public function setFilesystem($filesystem) + public function setFilesystem(Filesystem $filesystem): self { $this->filesystem = $filesystem; @@ -214,21 +194,16 @@ public function setFilesystem($filesystem) /** * Get the laravel console instance. - * - * @return Console */ - public function getConsole() + public function getConsole(): Console { return $this->console; } /** * Set the laravel console instance. - * - * @param Console $console - * @return $this */ - public function setConsole($console) + public function setConsole(Console $console): self { $this->console = $console; @@ -249,21 +224,16 @@ public function setComponent(\Illuminate\Console\View\Components\Factory $compon /** * Get the module instance. - * - * @return \Nwidart\Modules\Module */ - public function getModule() + public function getModule(): Module { return $this->module; } /** * Set the module instance. - * - * @param mixed $module - * @return $this */ - public function setModule($module) + public function setModule(mixed $module): self { $this->module = $module; @@ -272,10 +242,8 @@ public function setModule($module) /** * Setting the author from the command - * - * @return $this */ - public function setAuthor(?string $name = null, ?string $email = null) + public function setAuthor(?string $name = null, ?string $email = null): self { $this->author['name'] = $name; $this->author['email'] = $email; @@ -285,10 +253,8 @@ public function setAuthor(?string $name = null, ?string $email = null) /** * Installing vendor from the command - * - * @return $this */ - public function setVendor(?string $vendor = null) + public function setVendor(?string $vendor = null): self { $this->vendor = $vendor; @@ -297,31 +263,24 @@ public function setVendor(?string $vendor = null) /** * Get the list of folders will created. - * - * @return array */ - public function getFolders() + public function getFolders(): array { return $this->module->config('paths.generator'); } /** * Get the list of files will created. - * - * @return array */ - public function getFiles() + public function getFiles(): array { return $this->module->config('stubs.files'); } /** * Set force status. - * - * @param bool|int $force - * @return $this */ - public function setForce($force) + public function setForce(bool|int $force): self { $this->force = $force; @@ -391,10 +350,8 @@ public function generateFolders() /** * Generate git keep to the specified path. - * - * @param string $path */ - public function generateGitKeep($path) + public function generateGitKeep(string $path) { $this->filesystem->put($path.'/.gitkeep', ''); } @@ -496,11 +453,8 @@ public function generateResources() /** * Get the contents of the specified stub file by given stub name. - * - * - * @return string */ - protected function getStubContents($stub) + protected function getStubContents($stub): string { return (new Stub( '/'.$stub.'.stub', @@ -519,11 +473,8 @@ public function getReplacements() /** * Get array replacement for the specified stub. - * - * - * @return array */ - protected function getReplacement($stub) + protected function getReplacement($stub): array { $replacements = $this->module->config('stubs.replacements'); @@ -592,40 +543,32 @@ private function cleanModuleJsonFile() /** * Get the module name in lower case. - * - * @return string */ - protected function getLowerNameReplacement() + protected function getLowerNameReplacement(): string { return strtolower($this->getName()); } /** * Get the module name in studly case. - * - * @return string */ - protected function getStudlyNameReplacement() + protected function getStudlyNameReplacement(): string { return $this->getName(); } /** * Get replacement for $VENDOR$. - * - * @return string */ - protected function getVendorReplacement() + protected function getVendorReplacement(): string { return $this->vendor ?: $this->module->config('composer.vendor'); } /** * Get replacement for $MODULE_NAMESPACE$. - * - * @return string */ - protected function getModuleNamespaceReplacement() + protected function getModuleNamespaceReplacement(): string { return str_replace('\\', '\\\\', $this->module->config('namespace') ?? $this->path_namespace($this->module->config('paths.modules'))); } @@ -644,30 +587,24 @@ private function getControllerNamespaceReplacement(): string /** * Get replacement for $AUTHOR_NAME$. - * - * @return string */ - protected function getAuthorNameReplacement() + protected function getAuthorNameReplacement(): string { return $this->author['name'] ?: $this->module->config('composer.author.name'); } /** * Get replacement for $AUTHOR_EMAIL$. - * - * @return string */ - protected function getAuthorEmailReplacement() + protected function getAuthorEmailReplacement(): string { return $this->author['email'] ?: $this->module->config('composer.author.email'); } /** * Get replacement for $APP_FOLDER_NAME$. - * - * @return string */ - protected function getAppFolderNameReplacement() + protected function getAppFolderNameReplacement(): string { return $this->module->config('paths.app_folder'); } From 98df97e2f2e87ddba4044fad5e50b9e161fd4511 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 1 Jul 2024 00:45:17 +0330 Subject: [PATCH 380/422] [feat] add ModuleEvent constants --- src/Constants/ModuleEvent.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Constants/ModuleEvent.php diff --git a/src/Constants/ModuleEvent.php b/src/Constants/ModuleEvent.php new file mode 100644 index 000000000..464f13c8d --- /dev/null +++ b/src/Constants/ModuleEvent.php @@ -0,0 +1,26 @@ + Date: Mon, 1 Jul 2024 00:46:46 +0330 Subject: [PATCH 381/422] [feat] use Const for fire event and add missing event for create, delete, use, unused --- src/FileRepository.php | 3 +++ src/Generators/ModuleGenerator.php | 17 +++++++++++++++++ src/Module.php | 25 ++++++++++++++----------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/FileRepository.php b/src/FileRepository.php index 6dc22b7c8..5a0ae7991 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -10,6 +10,7 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidAssetPath; use Nwidart\Modules\Exceptions\ModuleNotFoundException; @@ -410,6 +411,8 @@ public function setUsed($name) $module = $this->findOrFail($name); $this->getFiles()->put($this->getUsedStoragePath(), $module); + + $module->fireEvent(ModuleEvent::USED); } /** diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 8befb6287..44db8f6cc 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -5,8 +5,11 @@ use Illuminate\Config\Repository as Config; use Illuminate\Console\Command as Console; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; +use Nwidart\Modules\Facades\Module; use Nwidart\Modules\FileRepository; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; @@ -365,6 +368,8 @@ public function generate(): int $this->component->info("Module [{$name}] created successfully."); + $this->fireEvent(ModuleEvent::CREATE); + return 0; } @@ -676,4 +681,16 @@ protected function getProviderNamespaceReplacement(): string { return str_replace('\\', '\\\\', GenerateConfigReader::read('provider')->getNamespace()); } + + /** + * fire the module event. + * + * @param string $event + */ + protected function fireEvent(string $event): void + { + $module = $this->module->find($this->name); + + $module->fireEvent($event); + } } diff --git a/src/Module.php b/src/Module.php index aa75af6d4..f11715a8f 100644 --- a/src/Module.php +++ b/src/Module.php @@ -9,6 +9,7 @@ use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Illuminate\Translation\Translator; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; abstract class Module @@ -192,7 +193,7 @@ public function boot(): void $this->registerFiles(); } - $this->fireEvent('boot'); + $this->fireEvent(ModuleEvent::BOOT); } /** @@ -260,15 +261,13 @@ public function register(): void $this->registerFiles(); } - $this->fireEvent('register'); + $this->fireEvent(ModuleEvent::REGISTER); } /** - * Register the module event. - * - * @param string $event + * fire the module event. */ - protected function fireEvent($event): void + public function fireEvent(string $event): void { $this->app['events']->dispatch(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]); } @@ -345,12 +344,12 @@ public function setActive(bool $active): void */ public function disable(): void { - $this->fireEvent('disabling'); + $this->fireEvent(ModuleEvent::DISABLING); $this->activator->disable($this); $this->flushCache(); - $this->fireEvent('disabled'); + $this->fireEvent(ModuleEvent::DISABLED); } /** @@ -358,12 +357,12 @@ public function disable(): void */ public function enable(): void { - $this->fireEvent('enabling'); + $this->fireEvent(ModuleEvent::ENABLING); $this->activator->enable($this); $this->flushCache(); - $this->fireEvent('enabled'); + $this->fireEvent(ModuleEvent::ENABLED); } /** @@ -373,7 +372,11 @@ public function delete(): bool { $this->activator->delete($this); - return $this->json()->getFilesystem()->deleteDirectory($this->getPath()); + $result = $this->json()->getFilesystem()->deleteDirectory($this->getPath()); + + $this->fireEvent(ModuleEvent::DELETE); + + return $result; } /** From 1cff39340fc8b9126ecf7014da7bea7632c569ad Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 1 Jul 2024 00:52:55 +0330 Subject: [PATCH 382/422] [test] update event name, use const ModuleEvent --- tests/LaravelModuleTest.php | 9 +++++---- tests/LumenModuleTest.php | 13 ++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index a529d7001..dd8878c53 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Event; use Modules\Recipe\Providers\DeferredServiceProvider; use Modules\Recipe\Providers\RecipeServiceProvider; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Json; @@ -147,8 +148,8 @@ public function test_it_fires_events_when_module_is_enabled() $this->module->enable(); - Event::assertDispatched(sprintf('modules.%s.enabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.enabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLED, $this->module->getLowerName())); } public function test_it_fires_events_when_module_is_disabled() @@ -157,8 +158,8 @@ public function test_it_fires_events_when_module_is_disabled() $this->module->disable(); - Event::assertDispatched(sprintf('modules.%s.disabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.disabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLED, $this->module->getLowerName())); } public function test_it_has_a_good_providers_manifest_path() diff --git a/tests/LumenModuleTest.php b/tests/LumenModuleTest.php index 2f2b1a8bc..1dc142ea6 100644 --- a/tests/LumenModuleTest.php +++ b/tests/LumenModuleTest.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules\Tests; use Illuminate\Support\Facades\Event; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Json; @@ -114,8 +115,8 @@ public function test_it_fires_events_when_module_is_enabled() $this->module->enable(); - Event::assertDispatched(sprintf('modules.%s.enabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.enabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::ENABLED, $this->module->getLowerName())); } public function test_it_fires_events_when_module_is_disabled() @@ -124,8 +125,8 @@ public function test_it_fires_events_when_module_is_disabled() $this->module->disable(); - Event::assertDispatched(sprintf('modules.%s.disabling', $this->module->getLowerName())); - Event::assertDispatched(sprintf('modules.%s.disabled', $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLING, $this->module->getLowerName())); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DISABLED, $this->module->getLowerName())); } public function test_it_has_a_good_providers_manifest_path() @@ -137,6 +138,4 @@ public function test_it_has_a_good_providers_manifest_path() } } -class LumenTestingModule extends \Nwidart\Modules\Lumen\Module -{ -} +class LumenTestingModule extends \Nwidart\Modules\Lumen\Module {} From 1de903442e45fca796ea117ede616cadcd575f7a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 1 Jul 2024 01:05:58 +0330 Subject: [PATCH 383/422] [test] add test for envents when module create and delete --- .../Actions/ModuleDeleteCommandTest.php | 40 +++++++++++++++++++ tests/Commands/Make/ModuleMakeCommandTest.php | 34 ++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/tests/Commands/Actions/ModuleDeleteCommandTest.php b/tests/Commands/Actions/ModuleDeleteCommandTest.php index 85d454733..1fce2f0a6 100644 --- a/tests/Commands/Actions/ModuleDeleteCommandTest.php +++ b/tests/Commands/Actions/ModuleDeleteCommandTest.php @@ -2,7 +2,9 @@ namespace Nwidart\Modules\Commands; +use Illuminate\Support\Facades\Event; use Nwidart\Modules\Activators\FileActivator; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; use Spatie\Snapshots\MatchesSnapshots; @@ -89,4 +91,42 @@ public function test_it_deletes_modules_from_status_file(): void $this->assertMatchesSnapshot($this->finder->get($this->activator->getStatusesFilePath())); $this->assertSame(0, $code); } + + public function test_it_fires_events_when_module_deleted() + { + $module_name = 'Blog'; + + $this->createModule($module_name); + + Event::fake(); + + $code = $this->artisan('module:delete', ['module' => [$module_name], '--force' => true]); + + $this->assertSame(0, $code); + + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETE, strtolower($module_name))); + } + + public function test_it_fires_events_when_multi_module_deleted() + { + $modules = [ + 'Foo', + 'Bar', + 'Zoo', + ]; + + foreach ($modules as $module) { + $this->createModule($module); + } + + Event::fake(); + + $code = $this->artisan('module:delete', ['--all' => true, '--force' => true]); + + $this->assertSame(0, $code); + + foreach ($modules as $module) { + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETE, strtolower($module))); + } + } } diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index d2ce2924c..3671ff625 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -3,7 +3,9 @@ namespace Nwidart\Modules\Tests\Commands\Make; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Tests\BaseTestCase; @@ -483,4 +485,36 @@ public function test_it_can_set_author_details() $this->assertSame(0, $code); } + + public function test_it_fires_events_when_module_created() + { + $module_name = 'Blog'; + Event::fake(); + + $code = $this->createModule($module_name); + + $this->assertSame(0, $code); + + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATE, strtolower($module_name))); + } + + public function test_it_fires_events_when_multi_module_created() + { + Event::fake(); + + $modules = [ + 'Foo', + 'Bar', + 'Zoo', + ]; + + $code = $this->artisan('module:make', ['name' => $modules]); + + $this->assertSame(0, $code); + + foreach ($modules as $module) { + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATE, strtolower($module))); + } + + } } From 49b2c657648f200ee32b0d82d9d93eedbb5c2eeb Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 1 Jul 2024 01:32:59 +0330 Subject: [PATCH 384/422] [fix] fix test, delete modules after run tests --- tests/LaravelFileRepositoryTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/LaravelFileRepositoryTest.php b/tests/LaravelFileRepositoryTest.php index 17bffa4a4..4dc0adb72 100644 --- a/tests/LaravelFileRepositoryTest.php +++ b/tests/LaravelFileRepositoryTest.php @@ -32,6 +32,7 @@ public function setUp(): void public function tearDown(): void { $this->activator->reset(); + $this->artisan('module:delete', ['--all' => true, '--force' => true]); parent::tearDown(); } From 35456083446ffa3a0e0678ae7ccac1bdab6f99e1 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 1 Jul 2024 01:37:12 +0330 Subject: [PATCH 385/422] [delete] delete old snapshots --- ...mespace_with_correct_generated_file__1.txt | 11 -- ...generated_correct_file_with_content__1.txt | 11 -- ...mespace_with_correct_generated_file__1.txt | 29 ----- ...generated_correct_file_with_content__1.txt | 29 ----- ...it_can_change_the_default_namespace__1.txt | 24 ---- ...ange_the_default_namespace_specific__1.txt | 24 ---- ...generated_correct_file_with_content__1.txt | 24 ---- ...it_can_change_the_default_namespace__1.txt | 24 ---- ...ange_the_default_namespace_specific__1.txt | 24 ---- ...generated_correct_file_with_content__1.txt | 24 ---- ...mespace_with_correct_generated_file__1.txt | 11 -- ...generated_correct_file_with_content__1.txt | 11 -- ...it_can_change_the_default_namespace__1.php | 71 ----------- ...it_can_change_the_default_namespace__1.txt | 56 -------- ...ange_the_default_namespace_specific__1.php | 71 ----------- ...ange_the_default_namespace_specific__1.txt | 56 -------- ...generated_correct_file_with_content__1.php | 71 ----------- ...generated_correct_file_with_content__1.txt | 56 -------- ...__it_uses_set_command_name_in_class__1.php | 71 ----------- ...__it_uses_set_command_name_in_class__1.txt | 56 -------- ...it_can_change_the_default_namespace__1.txt | 56 -------- ...ange_the_default_namespace_specific__1.txt | 56 -------- ...generated_correct_file_with_content__1.txt | 56 -------- ...t_it_uses_set_command_name_in_class__1.txt | 56 -------- ...it_can_change_the_default_namespace__1.php | 28 ---- ...it_can_change_the_default_namespace__1.txt | 28 ---- ...generated_correct_file_with_content__1.php | 28 ---- ...generated_correct_file_with_content__1.txt | 28 ---- ...it_can_change_the_default_namespace__1.txt | 25 ---- ...generated_correct_file_with_content__1.txt | 25 ---- ...it_can_change_the_default_namespace__1.txt | 25 ---- ...generated_correct_file_with_content__1.txt | 25 ---- ...roller_to_class_name_if_not_present__1.php | 82 ------------ ...roller_to_class_name_if_not_present__1.txt | 67 ---------- ...it_can_change_the_default_namespace__1.php | 82 ------------ ...it_can_change_the_default_namespace__1.txt | 67 ---------- ...ange_the_default_namespace_specific__1.php | 82 ------------ ...ange_the_default_namespace_specific__1.txt | 67 ---------- ...mespace_with_correct_generated_file__1.php | 82 ------------ ...mespace_with_correct_generated_file__1.txt | 67 ---------- ...generated_correct_file_with_content__1.php | 82 ------------ ...generated_correct_file_with_content__1.txt | 67 ---------- ...st__it_generates_a_plain_controller__1.php | 12 -- ...st__it_generates_a_plain_controller__1.txt | 9 -- ...est__it_generates_an_api_controller__1.php | 63 --------- ...est__it_generates_an_api_controller__1.txt | 59 --------- ...roller_to_class_name_if_not_present__1.txt | 67 ---------- ...it_can_change_the_default_namespace__1.txt | 67 ---------- ...ange_the_default_namespace_specific__1.txt | 67 ---------- ...mespace_with_correct_generated_file__1.txt | 67 ---------- ...generated_correct_file_with_content__1.txt | 67 ---------- ...est_it_generates_a_plain_controller__1.txt | 9 -- ...test_it_generates_an_api_controller__1.txt | 59 --------- ...t_generates_an_invokable_controller__1.txt | 17 --- ...mespace_with_correct_generated_file__1.txt | 8 -- ...generated_correct_file_with_content__1.txt | 8 -- ...it_can_change_the_default_namespace__1.php | 33 ----- ...it_can_change_the_default_namespace__1.txt | 34 ----- ...ange_the_default_namespace_specific__1.php | 33 ----- ...ange_the_default_namespace_specific__1.txt | 34 ----- ...generated_correct_file_with_content__1.php | 33 ----- ...generated_correct_file_with_content__1.txt | 34 ----- ...it_can_change_the_default_namespace__1.txt | 34 ----- ...ange_the_default_namespace_specific__1.txt | 34 ----- ...generated_correct_file_with_content__1.txt | 34 ----- ...generated_correct_file_with_content__1.txt | 32 ----- ...mespace_with_correct_generated_file__1.txt | 10 -- ...generated_correct_file_with_content__1.txt | 10 -- ...ryMakeCommandTest__it_makes_factory__1.php | 30 ----- ...ryMakeCommandTest__it_makes_factory__1.txt | 22 ---- ...eCommandTest__test_it_makes_factory__1.txt | 22 ---- ...mespace_with_correct_generated_file__1.txt | 11 -- ...generated_correct_file_with_content__1.txt | 11 -- ...mespace_with_correct_generated_file__1.txt | 8 -- ...generated_correct_file_with_content__1.txt | 8 -- ...it_can_change_the_default_namespace__1.php | 37 ------ ...it_can_change_the_default_namespace__1.txt | 30 ----- ...ange_the_default_namespace_specific__1.php | 37 ------ ...ange_the_default_namespace_specific__1.txt | 30 ----- ...generated_correct_file_with_content__1.php | 37 ------ ...generated_correct_file_with_content__1.txt | 30 ----- ..._correct_sync_job_file_with_content__1.php | 34 ----- ..._correct_sync_job_file_with_content__1.txt | 27 ---- ...it_can_change_the_default_namespace__1.txt | 30 ----- ...ange_the_default_namespace_specific__1.txt | 30 ----- ...generated_correct_file_with_content__1.txt | 30 ----- ..._correct_sync_job_file_with_content__1.txt | 27 ---- ...it_can_change_the_default_namespace__1.php | 33 ----- ...it_can_change_the_default_namespace__1.txt | 25 ---- ...ange_the_default_namespace_specific__1.php | 33 ----- ...ange_the_default_namespace_specific__1.txt | 25 ---- ...rect_queued_duck_event_with_content__1.php | 35 ----- ...rect_queued_duck_event_with_content__1.txt | 27 ---- ...vent_in_a_subdirectory_with_content__1.php | 36 ------ ...vent_in_a_subdirectory_with_content__1.txt | 28 ---- ...d_correct_queued_event_with_content__1.php | 36 ------ ...d_correct_queued_event_with_content__1.txt | 28 ---- ...orrect_sync_duck_event_with_content__1.php | 33 ----- ...orrect_sync_duck_event_with_content__1.txt | 25 ---- ...vent_in_a_subdirectory_with_content__1.php | 34 ----- ...vent_in_a_subdirectory_with_content__1.txt | 26 ---- ...ted_correct_sync_event_with_content__1.php | 34 ----- ...ted_correct_sync_event_with_content__1.txt | 26 ---- ...it_can_change_the_default_namespace__1.txt | 25 ---- ...ange_the_default_namespace_specific__1.txt | 25 ---- ...rect_queued_duck_event_with_content__1.txt | 27 ---- ...vent_in_a_subdirectory_with_content__1.txt | 28 ---- ...d_correct_queued_event_with_content__1.txt | 28 ---- ...orrect_sync_duck_event_with_content__1.txt | 25 ---- ...vent_in_a_subdirectory_with_content__1.txt | 26 ---- ...ted_correct_sync_event_with_content__1.txt | 26 ---- ...it_can_change_the_default_namespace__1.php | 36 ------ ...it_can_change_the_default_namespace__1.txt | 29 ----- ...ange_the_default_namespace_specific__1.php | 36 ------ ...ange_the_default_namespace_specific__1.txt | 29 ----- ...generated_correct_file_with_content__1.php | 36 ------ ...generated_correct_file_with_content__1.txt | 29 ----- ...it_can_change_the_default_namespace__1.txt | 29 ----- ...ange_the_default_namespace_specific__1.txt | 29 ----- ...generated_correct_file_with_content__1.txt | 29 ----- ...it_can_change_the_default_namespace__1.php | 24 ---- ...it_can_change_the_default_namespace__1.txt | 17 --- ...ange_the_default_namespace_specific__1.php | 24 ---- ...ange_the_default_namespace_specific__1.txt | 17 --- ...generated_correct_file_with_content__1.php | 24 ---- ...generated_correct_file_with_content__1.txt | 17 --- ...it_can_change_the_default_namespace__1.txt | 17 --- ...ange_the_default_namespace_specific__1.txt | 17 --- ...generated_correct_file_with_content__1.txt | 17 --- ..._correct_add_migration_file_content__1.php | 35 ----- ..._correct_add_migration_file_content__1.txt | 28 ---- ...rrect_create_migration_file_content__1.php | 35 ----- ...rrect_create_migration_file_content__1.txt | 28 ---- ...rect_default_migration_file_content__1.php | 31 ----- ...rect_default_migration_file_content__1.txt | 24 ---- ...rrect_delete_migration_file_content__1.php | 35 ----- ...rrect_delete_migration_file_content__1.txt | 28 ---- ...correct_drop_migration_file_content__1.php | 35 ----- ...correct_drop_migration_file_content__1.txt | 28 ---- ...t_generates_foreign_key_constraints__1.php | 37 ------ ...t_generates_foreign_key_constraints__1.txt | 30 ----- ..._correct_add_migration_file_content__1.txt | 28 ---- ...rrect_create_migration_file_content__1.txt | 28 ---- ...rect_default_migration_file_content__1.txt | 24 ---- ...rrect_delete_migration_file_content__1.txt | 28 ---- ...correct_drop_migration_file_content__1.txt | 28 ---- ...t_generates_foreign_key_constraints__1.txt | 30 ----- ...it_can_change_the_default_namespace__1.php | 21 --- ...it_can_change_the_default_namespace__1.txt | 22 ---- ...ange_the_default_namespace_specific__1.php | 21 --- ...ange_the_default_namespace_specific__1.txt | 22 ---- ...generated_correct_file_with_content__1.php | 21 --- ...generated_correct_file_with_content__1.txt | 22 ---- ...gration_when_both_flags_are_present__1.php | 82 ------------ ...gration_when_both_flags_are_present__1.txt | 67 ---------- ...gration_when_both_flags_are_present__2.php | 35 ----- ...gration_when_both_flags_are_present__2.txt | 28 ---- ...enerates_controller_file_with_model__1.php | 82 ------------ ...enerates_controller_file_with_model__1.txt | 67 ---------- ...le_with_model_using_shortcut_option__1.php | 82 ------------ ...le_with_model_using_shortcut_option__1.txt | 67 ---------- ...t_generates_correct_fillable_fields__1.php | 21 --- ...t_generates_correct_fillable_fields__1.txt | 22 ---- ...file_name_with_multiple_words_model__1.php | 35 ----- ...file_name_with_multiple_words_model__1.txt | 28 ---- ...generates_migration_file_with_model__1.php | 35 ----- ...generates_migration_file_with_model__1.txt | 28 ---- ...le_with_model_using_shortcut_option__1.php | 35 ----- ...le_with_model_using_shortcut_option__1.txt | 28 ---- ...it_can_change_the_default_namespace__1.txt | 22 ---- ...ange_the_default_namespace_specific__1.txt | 22 ---- ...generated_correct_file_with_content__1.txt | 22 ---- ...gration_when_both_flags_are_present__1.txt | 67 ---------- ...gration_when_both_flags_are_present__2.txt | 28 ---- ...enerates_controller_file_with_model__1.txt | 67 ---------- ...le_with_model_using_shortcut_option__1.txt | 67 ---------- ...t_generates_correct_fillable_fields__1.txt | 22 ---- ...file_name_with_multiple_words_model__1.txt | 28 ---- ...generates_migration_file_with_model__1.txt | 28 ---- ...le_with_model_using_shortcut_option__1.txt | 28 ---- ...it_deletes_modules_from_status_file__1.php | 5 - ...it_deletes_modules_from_status_file__1.txt | 3 - ...it_deletes_modules_from_status_file__2.php | 3 - ...it_deletes_modules_from_status_file__2.txt | 1 - ...it_deletes_modules_from_status_file__1.txt | 3 - ...it_deletes_modules_from_status_file__2.txt | 1 - ...generates_api_module_with_resources__1.php | 115 ----------------- ...generates_api_module_with_resources__1.txt | 114 ----------------- ...generates_api_module_with_resources__2.php | 63 --------- ...generates_api_module_with_resources__2.txt | 59 --------- ...generates_api_module_with_resources__3.php | 24 ---- ...generates_api_module_with_resources__3.txt | 16 --- ...generates_api_module_with_resources__4.php | 72 ----------- ...generates_api_module_with_resources__4.txt | 59 --------- ...ndTest__it_generates_api_route_file__1.php | 20 --- ...ndTest__it_generates_api_route_file__1.txt | 19 --- ...generates_correct_composerjson_file__1.php | 26 ---- ...generates_correct_composerjson_file__1.txt | 30 ----- ...es_correct_service_provider_content__1.php | 116 ----------------- ...mandTest__it_generates_module_files__1.php | 16 --- ...mandTest__it_generates_module_files__1.txt | 11 -- ..._module_namespace_using_studly_case__1.php | 115 ----------------- ..._module_namespace_using_studly_case__1.txt | 114 ----------------- ...Test__it_generates_module_resources__1.php | 115 ----------------- ...Test__it_generates_module_resources__1.txt | 114 ----------------- ...Test__it_generates_module_resources__2.php | 82 ------------ ...Test__it_generates_module_resources__2.txt | 67 ---------- ...Test__it_generates_module_resources__3.php | 24 ---- ...Test__it_generates_module_resources__3.txt | 16 --- ...Test__it_generates_module_resources__4.php | 72 ----------- ...Test__it_generates_module_resources__4.txt | 59 --------- ...ommandTest__it_generates_route_file__1.php | 6 - ...CommandTest__it_generates_vite_file__1.php | 27 ---- ...CommandTest__it_generates_vite_file__1.txt | 26 ---- ...generates_web_module_with_resources__1.php | 115 ----------------- ...generates_web_module_with_resources__1.txt | 114 ----------------- ...generates_web_module_with_resources__2.php | 82 ------------ ...generates_web_module_with_resources__2.txt | 67 ---------- ...generates_web_module_with_resources__3.php | 24 ---- ...generates_web_module_with_resources__3.txt | 16 --- ...generates_web_module_with_resources__4.php | 72 ----------- ...generates_web_module_with_resources__4.txt | 59 --------- ...es_when_adding_more_than_one_option__1.php | 115 ----------------- ...es_when_adding_more_than_one_option__1.txt | 114 ----------------- ...es_when_adding_more_than_one_option__2.php | 82 ------------ ...es_when_adding_more_than_one_option__2.txt | 67 ---------- ...es_when_adding_more_than_one_option__3.php | 24 ---- ...es_when_adding_more_than_one_option__3.txt | 16 --- ...es_when_adding_more_than_one_option__4.php | 72 ----------- ...es_when_adding_more_than_one_option__4.txt | 59 --------- ...ndTest__it_generates_web_route_file__1.php | 19 --- ...ndTest__it_generates_web_route_file__1.txt | 19 --- ...s_module_with_new_provider_location__1.php | 16 --- ...s_module_with_new_provider_location__1.txt | 11 -- ...s_module_with_new_provider_location__2.php | 26 ---- ...s_module_with_new_provider_location__2.txt | 30 ----- ...nable_and_route_provider_is_disable__1.txt | 120 ------------------ ...enable_and_route_provider_is_enable__1.txt | 120 ------------------ ...enable_and_route_provider_is_enable__2.txt | 49 ------- ...generates_api_module_with_resources__1.txt | 120 ------------------ ...generates_api_module_with_resources__2.txt | 59 --------- ...generates_api_module_with_resources__3.txt | 16 --- ...generates_api_module_with_resources__4.txt | 49 ------- ...t__test_it_generates_api_route_file__1.txt | 19 --- ...generates_correct_composerjson_file__1.txt | 30 ----- ...est__test_it_generates_module_files__1.txt | 11 -- ..._module_namespace_using_studly_case__1.txt | 120 ------------------ ..._test_it_generates_module_resources__1.txt | 120 ------------------ ..._test_it_generates_module_resources__2.txt | 32 ----- ..._test_it_generates_module_resources__3.txt | 49 ------- ..._test_it_generates_module_resources__4.txt | 67 ---------- ..._test_it_generates_module_resources__5.txt | 16 --- ...ndTest__test_it_generates_vite_file__1.txt | 26 ---- ...generates_web_module_with_resources__1.txt | 120 ------------------ ...generates_web_module_with_resources__2.txt | 67 ---------- ...generates_web_module_with_resources__3.txt | 16 --- ...generates_web_module_with_resources__4.txt | 49 ------- ...es_when_adding_more_than_one_option__1.txt | 120 ------------------ ...es_when_adding_more_than_one_option__2.txt | 67 ---------- ...es_when_adding_more_than_one_option__3.txt | 16 --- ...es_when_adding_more_than_one_option__4.txt | 49 ------- ...t__test_it_generates_web_route_file__1.txt | 19 --- ...s_module_with_new_provider_location__1.txt | 11 -- ...s_module_with_new_provider_location__2.txt | 30 ----- ...it_can_change_the_default_namespace__1.php | 64 ---------- ...it_can_change_the_default_namespace__1.txt | 48 ------- ...ange_the_default_namespace_specific__1.php | 64 ---------- ...ange_the_default_namespace_specific__1.txt | 48 ------- ...generated_correct_file_with_content__1.php | 64 ---------- ...generated_correct_file_with_content__1.txt | 48 ------- ...it_can_change_the_default_namespace__1.txt | 48 ------- ...ange_the_default_namespace_specific__1.txt | 48 ------- ...generated_correct_file_with_content__1.txt | 48 ------- ...rMakeCommandTest__it_makes_observer__1.php | 52 -------- ...rMakeCommandTest__it_makes_observer__1.txt | 48 ------- ...CommandTest__test_it_makes_observer__1.txt | 48 ------- ...it_can_change_the_default_namespace__1.php | 23 ---- ...it_can_change_the_default_namespace__1.txt | 18 --- ...ange_the_default_namespace_specific__1.php | 23 ---- ...ange_the_default_namespace_specific__1.txt | 18 --- ...icyMakeCommandTest__it_makes_policy__1.php | 23 ---- ...icyMakeCommandTest__it_makes_policy__1.txt | 18 --- ...it_can_change_the_default_namespace__1.txt | 18 --- ...ange_the_default_namespace_specific__1.txt | 18 --- ...keCommandTest__test_it_makes_policy__1.txt | 18 --- ...it_can_change_the_default_namespace__1.php | 115 ----------------- ...it_can_change_the_default_namespace__1.txt | 114 ----------------- ...ange_the_default_namespace_specific__1.php | 115 ----------------- ...ange_the_default_namespace_specific__1.txt | 114 ----------------- ..._migration_resources_location_paths__1.php | 115 ----------------- ..._migration_resources_location_paths__1.txt | 114 ----------------- ...generated_correct_file_with_content__1.php | 31 ----- ...generated_correct_file_with_content__1.txt | 24 ---- ...vice_provider_with_resource_loading__1.php | 115 ----------------- ...vice_provider_with_resource_loading__1.txt | 114 ----------------- ...it_can_change_the_default_namespace__1.txt | 120 ------------------ ...ange_the_default_namespace_specific__1.txt | 120 ------------------ ..._migration_resources_location_paths__1.txt | 120 ------------------ ...generated_correct_file_with_content__1.txt | 24 ---- ...vice_provider_with_resource_loading__1.txt | 120 ------------------ ...mespace_with_correct_generated_file__1.txt | 11 -- ...generated_correct_file_with_content__1.txt | 11 -- ...it_can_change_the_default_namespace__1.php | 33 ----- ...it_can_change_the_default_namespace__1.txt | 26 ---- ...ange_the_default_namespace_specific__1.php | 33 ----- ...ange_the_default_namespace_specific__1.txt | 26 ---- ...generated_correct_file_with_content__1.php | 33 ----- ...generated_correct_file_with_content__1.txt | 26 ---- ...it_can_change_the_default_namespace__1.txt | 26 ---- ...ange_the_default_namespace_specific__1.txt | 26 ---- ...generated_correct_file_with_content__1.txt | 26 ---- ...it_can_change_the_default_namespace__1.php | 22 ---- ...it_can_change_the_default_namespace__1.txt | 17 --- ...ange_the_default_namespace_specific__1.php | 22 ---- ...ange_the_default_namespace_specific__1.txt | 17 --- ...enerate_a_collection_resource_class__1.php | 22 ---- ...enerate_a_collection_resource_class__1.txt | 17 --- ...generated_correct_file_with_content__1.php | 22 ---- ...generated_correct_file_with_content__1.txt | 17 --- ...it_can_change_the_default_namespace__1.txt | 17 --- ...ange_the_default_namespace_specific__1.txt | 17 --- ...enerate_a_collection_resource_class__1.txt | 17 --- ...generated_correct_file_with_content__1.txt | 17 --- ...nge_the_custom_controller_namespace__1.php | 72 ----------- ...nge_the_custom_controller_namespace__1.txt | 59 --------- ...it_can_change_the_default_namespace__1.php | 72 ----------- ...it_can_change_the_default_namespace__1.txt | 59 --------- ...ange_the_default_namespace_specific__1.php | 72 ----------- ...ange_the_default_namespace_specific__1.txt | 59 --------- ...eCommandTest__it_can_overwrite_file__1.php | 72 ----------- ...eCommandTest__it_can_overwrite_file__1.txt | 59 --------- ...__it_can_overwrite_route_file_names__1.php | 72 ----------- ...__it_can_overwrite_route_file_names__1.txt | 59 --------- ...generated_correct_file_with_content__1.php | 72 ----------- ...generated_correct_file_with_content__1.txt | 59 --------- ...nge_the_custom_controller_namespace__1.txt | 49 ------- ...it_can_change_the_default_namespace__1.txt | 49 ------- ...ange_the_default_namespace_specific__1.txt | 49 ------- ...andTest__test_it_can_overwrite_file__1.txt | 49 ------- ...t_it_can_overwrite_route_file_names__1.txt | 49 ------- ...generated_correct_file_with_content__1.txt | 49 ------- ...it_can_change_the_default_namespace__1.php | 43 ------- ...it_can_change_the_default_namespace__1.txt | 17 --- ...ange_the_default_namespace_specific__1.php | 43 ------- ...ange_the_default_namespace_specific__1.txt | 17 --- ...CommandTest__it_makes_implicit_rule__1.txt | 22 ---- .../RuleMakeCommandTest__it_makes_rule__1.php | 43 ------- .../RuleMakeCommandTest__it_makes_rule__1.txt | 17 --- ...it_can_change_the_default_namespace__1.txt | 17 --- ...ange_the_default_namespace_specific__1.txt | 17 --- ...ndTest__test_it_makes_implicit_rule__1.txt | 22 ---- ...MakeCommandTest__test_it_makes_rule__1.txt | 17 --- ...mespace_with_correct_generated_file__1.txt | 18 --- ...generated_correct_file_with_content__1.txt | 18 --- ...it_can_change_the_default_namespace__1.txt | 11 -- ...mespace_with_correct_generated_file__1.txt | 11 -- ...generated_correct_file_with_content__1.txt | 11 -- ...hange_the_default_feature_namespace__1.php | 25 ---- ...hange_the_default_feature_namespace__1.txt | 20 --- ..._default_feature_namespace_specific__1.php | 25 ---- ..._default_feature_namespace_specific__1.txt | 20 --- ...n_change_the_default_unit_namespace__1.php | 23 ---- ...n_change_the_default_unit_namespace__1.txt | 20 --- ...the_default_unit_namespace_specific__1.php | 23 ---- ...the_default_unit_namespace_specific__1.txt | 20 --- ...d_correct_feature_file_with_content__1.php | 25 ---- ...d_correct_feature_file_with_content__1.txt | 20 --- ...ated_correct_unit_file_with_content__1.php | 23 ---- ...ated_correct_unit_file_with_content__1.txt | 20 --- ...hange_the_default_feature_namespace__1.txt | 20 --- ..._default_feature_namespace_specific__1.txt | 20 --- ...n_change_the_default_unit_namespace__1.txt | 20 --- ...the_default_unit_namespace_specific__1.txt | 20 --- ...d_correct_feature_file_with_content__1.txt | 20 --- ...ated_correct_unit_file_with_content__1.txt | 20 --- ...mespace_with_correct_generated_file__1.txt | 8 -- ...generated_correct_file_with_content__1.txt | 8 -- 377 files changed, 15346 deletions(-) delete mode 100644 tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/CastMakeCommandTest__test_it_can_generate_a_cast_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ChannelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_can_generate_a_class_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ClassMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_uses_set_command_name_in_class__1.php delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__it_uses_set_command_name_in_class__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/CommandMakeCommandTest__test_it_uses_set_command_name_in_class__1.txt delete mode 100644 tests/Commands/__snapshots__/ComponentClassCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/ComponentClassCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ComponentClassCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ComponentClassCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ComponentClassMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_appends_controller_to_class_name_if_not_present__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_a_plain_controller__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_a_plain_controller__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.php delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__it_generates_an_api_controller__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_a_plain_controller__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_api_controller__1.txt delete mode 100644 tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt delete mode 100644 tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/EventMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/FactoryMakeCommandTest__it_makes_factory__1.php delete mode 100644 tests/Commands/__snapshots__/FactoryMakeCommandTest__it_makes_factory__1.txt delete mode 100644 tests/Commands/__snapshots__/FactoryMakeCommandTest__test_it_makes_factory__1.txt delete mode 100644 tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/HelperMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_can_generate_a_interface_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/InterfaceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_sync_job_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__it_generated_correct_sync_job_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/JobMakeCommandTest__test_it_generated_correct_sync_job_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_duck_event_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_duck_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_in_a_subdirectory_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_queued_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_duck_event_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_duck_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_in_a_subdirectory_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__it_generated_correct_sync_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_duck_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_event_in_a_subdirectory_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_queued_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_duck_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_event_in_a_subdirectory_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ListenerMakeCommandTest__test_it_generated_correct_sync_event_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/MiddlewareMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_add_migration_file_content__1.php delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_add_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.php delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_delete_migration_file_content__1.php delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_delete_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.php delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_create_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_delete_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_drop_migration_file_content__1.txt delete mode 100644 tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model_using_shortcut_option__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_fillable_fields__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__2.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_migration_file_name_with_multiple_words_model__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt delete mode 100644 tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__2.php delete mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleDeleteCommandTest__test_it_deletes_modules_from_status_file__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_service_provider_content__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_vite_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.php delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_disable__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__5.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt delete mode 100644 tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php delete mode 100644 tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.txt delete mode 100644 tests/Commands/__snapshots__/ObserverMakeCommandTest__test_it_makes_observer__1.txt delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__it_makes_policy__1.php delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__it_makes_policy__1.txt delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/PolicyMakeCommandTest__test_it_makes_policy__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.php delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generates_a_master_service_provider_with_resource_loading__1.txt delete mode 100644 tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/RequestMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.php delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_can_generate_a_collection_resource_class__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_can_generate_a_collection_resource_class__1.txt delete mode 100644 tests/Commands/__snapshots__/ResourceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt delete mode 100644 tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_implicit_rule__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.php delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__it_makes_rule__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_makes_implicit_rule__1.txt delete mode 100644 tests/Commands/__snapshots__/RuleMakeCommandTest__test_it_makes_rule__1.txt delete mode 100644 tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_can_generate_a_scope_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ScopeMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_change_the_default_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_can_generate_a_service_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/ServiceMakeCommandTest__test_it_generated_correct_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt delete mode 100644 tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt delete mode 100644 tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_generated_correct_file_with_content__1.txt diff --git a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index b21fb56ef..000000000 --- a/tests/Commands/__snapshots__/ActionMakeCommandTest__test_it_can_generate_a_action_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,11 +0,0 @@ - $attributes - */ - public function get(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } - - /** - * Prepare the given value for storage. - * - * @param array $attributes - */ - public function set(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } -} diff --git a/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 05d8e3e37..000000000 --- a/tests/Commands/__snapshots__/CastMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,29 +0,0 @@ - $attributes - */ - public function get(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } - - /** - * Prepare the given value for storage. - * - * @param array $attributes - */ - public function set(Model $model, string $key, mixed $value, array $attributes): mixed - { - return $value; - } -} diff --git a/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 55d364bf9..000000000 --- a/tests/Commands/__snapshots__/ChannelMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,24 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt deleted file mode 100644 index 863f2f9d1..000000000 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt +++ /dev/null @@ -1,67 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt b/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt deleted file mode 100644 index 41a1b8ced..000000000 --- a/tests/Commands/__snapshots__/ControllerMakeCommandTest__test_it_generates_an_invokable_controller__1.txt +++ /dev/null @@ -1,17 +0,0 @@ -json([]); - } -} diff --git a/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index c9edb0b1b..000000000 --- a/tests/Commands/__snapshots__/EnumMakeCommandTest__test_it_can_generate_a_enum_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,8 +0,0 @@ -> - */ - protected $listen = []; - - /** - * Indicates if events should be discovered. - * - * @var bool - */ - protected static $shouldDiscoverEvents = true; - - /** - * Configure the proper event listeners for email verification. - * - * @return void - */ - protected function configureEmailVerification(): void - { - - } -} diff --git a/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index 4e24c9dc5..000000000 --- a/tests/Commands/__snapshots__/ExceptionMakeCommandTest__test_it_can_generate_a_exception_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,10 +0,0 @@ -view(\'view.name\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index de57ce98c..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,36 +0,0 @@ -view(\'view.name\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index 721ca773a..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,36 +0,0 @@ -view(\'view.name\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 5bee369ee..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 45f802ffe..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 5bee369ee..000000000 --- a/tests/Commands/__snapshots__/MailMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,29 +0,0 @@ -view('view.name'); - } -} diff --git a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index f908a99b1..000000000 --- a/tests/Commands/__snapshots__/MiddlewareMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,24 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_create_migration_file_content__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php deleted file mode 100644 index 638fa8f70..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_default_migration_file_content__1.php +++ /dev/null @@ -1,31 +0,0 @@ -bigIncrements(\'id\'); - - $table->timestamps(); - }); - } -} -'; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt deleted file mode 100644 index e14933dcd..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_correct_drop_migration_file_content__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php deleted file mode 100644 index b268cb945..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->integer(\'user_id\')->unsigned(); - $table->foreign(\'user_id\')->references(\'id\')->on(\'users\'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt deleted file mode 100644 index 6546dae4d..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__it_generates_foreign_key_constraints__1.txt +++ /dev/null @@ -1,30 +0,0 @@ -id(); - $table->integer('user_id')->unsigned(); - $table->foreign('user_id')->references('id')->on('users'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt deleted file mode 100644 index ec659d5fe..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_add_migration_file_content__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt deleted file mode 100644 index 88fa2f36b..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_correct_default_migration_file_content__1.txt +++ /dev/null @@ -1,24 +0,0 @@ -id(); - - $table->timestamps(); - }); - } -}; diff --git a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt b/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt deleted file mode 100644 index 6546dae4d..000000000 --- a/tests/Commands/__snapshots__/MigrationMakeCommandTest__test_it_generates_foreign_key_constraints__1.txt +++ /dev/null @@ -1,30 +0,0 @@ -id(); - $table->integer('user_id')->unsigned(); - $table->foreign('user_id')->references('id')->on('users'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index b9dc5670f..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,21 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_and_migration_when_both_flags_are_present__2.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php deleted file mode 100644 index 96c430491..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_controller_file_with_model__1.php +++ /dev/null @@ -1,82 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'product_details\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt deleted file mode 100644 index 1e0f11a0a..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_correct_migration_file_name_with_multiple_words_model__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('product_details'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php deleted file mode 100644 index cd1d8ef83..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php deleted file mode 100644 index cd1d8ef83..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists(\'posts\'); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__it_generates_migration_file_with_model_using_shortcut_option__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 395327120..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,22 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt deleted file mode 100644 index 0006937ff..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt +++ /dev/null @@ -1,67 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('product_details'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt b/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt deleted file mode 100644 index 36dc20e86..000000000 --- a/tests/Commands/__snapshots__/ModelMakeCommandTest__test_it_generates_migration_file_with_model_using_shortcut_option__1.txt +++ /dev/null @@ -1,28 +0,0 @@ -id(); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php b/tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php deleted file mode 100644 index b168a77d4..000000000 --- a/tests/Commands/__snapshots__/ModuleDeleteCommandTest__it_deletes_modules_from_status_file__1.php +++ /dev/null @@ -1,5 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php deleted file mode 100644 index 83c177982..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__2.php +++ /dev/null @@ -1,63 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php deleted file mode 100644 index 6e21400e5..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.php +++ /dev/null @@ -1,24 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_module_with_resources__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php deleted file mode 100644 index aeda47cc3..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.php +++ /dev/null @@ -1,20 +0,0 @@ -get(\'/blog\', function (Request $request) { - return $request->user(); -});'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt deleted file mode 100644 index cbdf7602e..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_api_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -prefix('v1')->group(function () { - Route::apiResource('blog', BlogController::class)->names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php deleted file mode 100644 index d59c9fbab..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_correct_composerjson_file__1.php +++ /dev/null @@ -1,26 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->registerFactories(); - $this->loadMigrationsFrom(__DIR__ . \'/../Database/Migrations\'); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - __DIR__.\'/../Config/config.php\' => config_path(\'blog.php\'), - ], \'config\'); - $this->mergeConfigFrom( - __DIR__.\'/../Config/config.php\', \'blog\' - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/blog\'); - - $sourcePath = __DIR__.\'/../Resources/views\'; - - $this->publishes([ - $sourcePath => $viewPath - ],\'views\'); - - $this->loadViewsFrom(array_merge(array_map(function ($path) { - return $path . \'/modules/blog\'; - }, \\Config::get(\'view.paths\')), [$sourcePath]), \'blog\'); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/blog\'); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, \'blog\'); - } else { - $this->loadTranslationsFrom(__DIR__ .\'/../Resources/lang\', \'blog\'); - } - } - - /** - * Register an additional directory of factories. - * - * @return void - */ - public function registerFactories() - { - if (! app()->environment(\'production\')) { - app(Factory::class)->load(__DIR__ . \'/../Database/factories\'); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php deleted file mode 100644 index e18455549..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_files__1.php +++ /dev/null @@ -1,16 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt deleted file mode 100644 index da938d49a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_namespace_using_studly_case__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php deleted file mode 100644 index 116c300ac..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php deleted file mode 100644 index 70eda9111..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__2.php +++ /dev/null @@ -1,82 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_module_resources__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php deleted file mode 100644 index 964652b2e..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_route_file__1.php +++ /dev/null @@ -1,6 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php deleted file mode 100644 index 7167823ee..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__2.php +++ /dev/null @@ -1,82 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php deleted file mode 100644 index 116c300ac..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php deleted file mode 100644 index 7167823ee..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__2.php +++ /dev/null @@ -1,82 +0,0 @@ -call("OthersTableSeeder"); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt deleted file mode 100644 index 6abbddde9..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php deleted file mode 100644 index 92a328a04..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.php +++ /dev/null @@ -1,19 +0,0 @@ -group(function() { - Route::get(\'/\', \'BlogController@index\'); -}); -'; diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt deleted file mode 100644 index 082efd6d4..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generates_web_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php b/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php deleted file mode 100644 index ddb6e2084..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__it_generes_module_with_new_provider_location__1.php +++ /dev/null @@ -1,16 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - // $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generate_module_when_provider_is_enable_and_route_provider_is_enable__2.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt deleted file mode 100644 index bc3afb929..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__2.txt +++ /dev/null @@ -1,59 +0,0 @@ -json([]); - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - - return response()->json([]); - } - - /** - * Show the specified resource. - */ - public function show($id) - { - // - - return response()->json([]); - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - // - - return response()->json([]); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy($id) - { - // - - return response()->json([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt deleted file mode 100644 index 97e7e2a48..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__3.txt +++ /dev/null @@ -1,16 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_module_with_resources__4.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt deleted file mode 100644 index cbdf7602e..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_api_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -prefix('v1')->group(function () { - Route::apiResource('blog', BlogController::class)->names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt deleted file mode 100644 index 746cae739..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_correct_composerjson_file__1.txt +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "nwidart/blog", - "description": "", - "authors": [ - { - "name": "Nicolas Widart", - "email": "n.widart@gmail.com" - } - ], - "extra": { - "laravel": { - "providers": [], - "aliases": { - - } - } - }, - "autoload": { - "psr-4": { - "Modules\\Blog\\": "app/", - "Modules\\Blog\\Database\\Factories\\": "database/factories/", - "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" - } - }, - "autoload-dev": { - "psr-4": { - "Modules\\Blog\\Tests\\": "tests/" - } - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt deleted file mode 100644 index 92e3b4504..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_files__1.txt +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Blog", - "alias": "blog", - "description": "", - "keywords": [], - "priority": 0, - "providers": [ - "Modules\\Blog\\Providers\\BlogServiceProvider" - ], - "files": [] -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt deleted file mode 100644 index 560ac5db1..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_namespace_using_studly_case__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt deleted file mode 100644 index 4130adfaa..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt +++ /dev/null @@ -1,32 +0,0 @@ -> - */ - protected $listen = []; - - /** - * Indicates if events should be discovered. - * - * @var bool - */ - protected static $shouldDiscoverEvents = true; - - /** - * Configure the proper event listeners for email verification. - * - * @return void - */ - protected function configureEmailVerification(): void - { - - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__3.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt deleted file mode 100644 index 6a89e8c29..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ /dev/null @@ -1,67 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt deleted file mode 100644 index 72d694d39..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_vite_file__1.txt +++ /dev/null @@ -1,26 +0,0 @@ -import { defineConfig } from 'vite'; -import laravel from 'laravel-vite-plugin'; - -export default defineConfig({ - build: { - outDir: '../../public/build-blog', - emptyOutDir: true, - manifest: true, - }, - plugins: [ - laravel({ - publicDirectory: '../../public', - buildDirectory: 'build-blog', - input: [ - __dirname + '/resources/assets/sass/app.scss', - __dirname + '/resources/assets/js/app.js' - ], - refresh: true, - }), - ], -}); - -//export const paths = [ -// 'Modules/Blog/resources/assets/sass/app.scss', -// 'Modules/Blog/resources/assets/js/app.js', -//]; \ No newline at end of file diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt deleted file mode 100644 index 6a89e8c29..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt +++ /dev/null @@ -1,67 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__4.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt deleted file mode 100644 index 713ae6f3a..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt deleted file mode 100644 index 6a89e8c29..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ /dev/null @@ -1,67 +0,0 @@ -call([]); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__4.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt deleted file mode 100644 index 082efd6d4..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_route_file__1.txt +++ /dev/null @@ -1,19 +0,0 @@ -names('blog'); -}); diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt deleted file mode 100644 index c59f26953..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__1.txt +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Blog", - "alias": "blog", - "description": "", - "keywords": [], - "priority": 0, - "providers": [ - "Modules\\Blog\\Base\\Providers\\BlogServiceProvider" - ], - "files": [] -} diff --git a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt b/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt deleted file mode 100644 index 746cae739..000000000 --- a/tests/Commands/__snapshots__/ModuleMakeCommandTest__test_it_generes_module_with_new_provider_location__2.txt +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "nwidart/blog", - "description": "", - "authors": [ - { - "name": "Nicolas Widart", - "email": "n.widart@gmail.com" - } - ], - "extra": { - "laravel": { - "providers": [], - "aliases": { - - } - } - }, - "autoload": { - "psr-4": { - "Modules\\Blog\\": "app/", - "Modules\\Blog\\Database\\Factories\\": "database/factories/", - "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" - } - }, - "autoload-dev": { - "psr-4": { - "Modules\\Blog\\Tests\\": "tests/" - } - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index 941a05c26..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,64 +0,0 @@ -line(\'The introduction to the notification.\') - ->action(\'Notification Action\', \'https://laravel.com\') - ->line(\'Thank you for using our application!\'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} -'; diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index 941a05c26..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,64 +0,0 @@ -line(\'The introduction to the notification.\') - ->action(\'Notification Action\', \'https://laravel.com\') - ->line(\'Thank you for using our application!\'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} -'; diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index 98a1b6e9c..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,64 +0,0 @@ -line(\'The introduction to the notification.\') - ->action(\'Notification Action\', \'https://laravel.com\') - ->line(\'Thank you for using our application!\'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} -'; diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 53e7ab765..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 4fb9ff311..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 53e7ab765..000000000 --- a/tests/Commands/__snapshots__/NotificationMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,48 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - */ - public function toArray($notifiable): array - { - return []; - } -} diff --git a/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php b/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php deleted file mode 100644 index 7e8a21ea2..000000000 --- a/tests/Commands/__snapshots__/ObserverMakeCommandTest__it_makes_observer__1.php +++ /dev/null @@ -1,52 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index b4c6f48d6..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index 4b1d92d74..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index b4c6f48d6..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php deleted file mode 100644 index e9af8c60a..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.php +++ /dev/null @@ -1,115 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt deleted file mode 100644 index 4f132a028..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_can_have_custom_migration_resources_location_paths__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index c5ec999ae..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,31 +0,0 @@ -registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, \'Database/Migrations\')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, \'Config/config.php\') => config_path($this->moduleNameLower . \'.php\'), - ], \'config\'); - $this->mergeConfigFrom( - module_path($this->moduleName, \'Config/config.php\'), $this->moduleNameLower - ); - } - - /** - * Register views. - * - * @return void - */ - public function registerViews() - { - $viewPath = resource_path(\'views/modules/\' . $this->moduleNameLower); - - $sourcePath = module_path($this->moduleName, \'Resources/views\'); - - $this->publishes([ - $sourcePath => $viewPath - ], [\'views\', $this->moduleNameLower . \'-module-views\']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - } - - /** - * Register translations. - * - * @return void - */ - public function registerTranslations() - { - $langPath = resource_path(\'lang/modules/\' . $this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, \'Resources/lang\'), $this->moduleNameLower); - } - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (\\Config::get(\'view.paths\') as $path) { - if (is_dir($path . \'/modules/\' . $this->moduleNameLower)) { - $paths[] = $path . \'/modules/\' . $this->moduleNameLower; - } - } - return $paths; - } -} -'; diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt deleted file mode 100644 index ad1ad48fd..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__it_generates_a_master_service_provider_with_resource_loading__1.txt +++ /dev/null @@ -1,114 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - */ - public function provides(): array - { - return []; - } - - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index bb17c3614..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index bb17c3614..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt deleted file mode 100644 index 26918b859..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_can_have_custom_migration_resources_location_paths__1.txt +++ /dev/null @@ -1,120 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index 922456f3d..000000000 --- a/tests/Commands/__snapshots__/ProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,24 +0,0 @@ -registerCommands(); - $this->registerCommandSchedules(); - $this->registerTranslations(); - $this->registerConfig(); - $this->registerViews(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); - } - - /** - * Register the service provider. - */ - public function register(): void - { - $this->app->register(EventServiceProvider::class); - $this->app->register(RouteServiceProvider::class); - } - - /** - * Register commands in the format of Command::class - */ - protected function registerCommands(): void - { - // $this->commands([]); - } - - /** - * Register command Schedules. - */ - protected function registerCommandSchedules(): void - { - // $this->app->booted(function () { - // $schedule = $this->app->make(Schedule::class); - // $schedule->command('inspire')->hourly(); - // }); - } - - /** - * Register translations. - */ - public function registerTranslations(): void - { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); - - if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, $this->moduleNameLower); - $this->loadJsonTranslationsFrom($langPath); - } else { - $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); - $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); - } - } - - /** - * Register config. - */ - protected function registerConfig(): void - { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); - $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); - } - - /** - * Register views. - */ - public function registerViews(): void - { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); - $sourcePath = module_path($this->moduleName, 'resources/views'); - - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); - - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); - - $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', ''))); - Blade::componentNamespace($componentNamespace, $this->moduleNameLower); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides(): array - { - return []; - } - - /** - * @return array - */ - private function getPublishableViewPaths(): array - { - $paths = []; - foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; - } - } - - return $paths; - } -} diff --git a/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index 6ddffc7b9..000000000 --- a/tests/Commands/__snapshots__/RepositoryMakeCommandTest__test_it_can_generate_a_repository_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,11 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt deleted file mode 100644 index 4415d0ded..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_custom_controller_namespace__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index 92c4b0049..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt deleted file mode 100644 index 4d24c8e15..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php deleted file mode 100644 index 92c4b0049..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index 4d24c8e15..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php deleted file mode 100644 index 3c1840372..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/SuperRoutes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt deleted file mode 100644 index 68d0fd9d6..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_file__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php deleted file mode 100644 index e51b25a48..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/SuperRoutes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/SuperRoutes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt deleted file mode 100644 index 10aaad55e..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_can_overwrite_route_file_names__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/SuperRoutes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php deleted file mode 100644 index fed5497ea..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.php +++ /dev/null @@ -1,72 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapWebRoutes() - { - Route::middleware(\'web\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/web.php\')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::prefix(\'api\') - ->middleware(\'api\') - ->namespace($this->moduleNamespace) - ->group(module_path(\'Blog\', \'/Routes/api.php\')); - } -} -'; diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt deleted file mode 100644 index bab850316..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,59 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::prefix('api') - ->middleware('api') - ->namespace($this->moduleNamespace) - ->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt deleted file mode 100644 index 79746f865..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_custom_controller_namespace__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt deleted file mode 100644 index af40c469e..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt deleted file mode 100644 index af40c469e..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt deleted file mode 100644 index e8d7205d7..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_file__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt deleted file mode 100644 index 7c40e3d35..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_can_overwrite_route_file_names__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/SuperRoutes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/SuperRoutes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt deleted file mode 100644 index dc17450cc..000000000 --- a/tests/Commands/__snapshots__/RouteProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ /dev/null @@ -1,49 +0,0 @@ -mapApiRoutes(); - - $this->mapWebRoutes(); - } - - /** - * Define the "web" routes for the application. - * - * These routes all receive session state, CSRF protection, etc. - */ - protected function mapWebRoutes(): void - { - Route::middleware('web')->group(module_path('Blog', '/routes/web.php')); - } - - /** - * Define the "api" routes for the application. - * - * These routes are typically stateless. - */ - protected function mapApiRoutes(): void - { - Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Blog', '/routes/api.php')); - } -} diff --git a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php b/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php deleted file mode 100644 index 4bdb9a702..000000000 --- a/tests/Commands/__snapshots__/RuleMakeCommandTest__it_can_change_the_default_namespace__1.php +++ /dev/null @@ -1,43 +0,0 @@ -get(\'/\'); - - $response->assertStatus(200); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php deleted file mode 100644 index 2ce31ff0d..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.php +++ /dev/null @@ -1,25 +0,0 @@ -get(\'/\'); - - $response->assertStatus(200); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_feature_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php deleted file mode 100644 index 2da859821..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.php +++ /dev/null @@ -1,23 +0,0 @@ -assertTrue(true); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt deleted file mode 100644 index 273dc9657..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php deleted file mode 100644 index 2da859821..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.php +++ /dev/null @@ -1,23 +0,0 @@ -assertTrue(true); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_can_change_the_default_unit_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php deleted file mode 100644 index 7b9c70d06..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.php +++ /dev/null @@ -1,25 +0,0 @@ -get(\'/\'); - - $response->assertStatus(200); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt deleted file mode 100644 index 6378738a3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_feature_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php deleted file mode 100644 index b927d166c..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.php +++ /dev/null @@ -1,23 +0,0 @@ -assertTrue(true); - } -} -'; diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__it_generated_correct_unit_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt deleted file mode 100644 index dba6e35a1..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt deleted file mode 100644 index 273dc9657..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt deleted file mode 100644 index 6378738a3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt deleted file mode 100644 index fcbfc0da3..000000000 --- a/tests/Commands/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt deleted file mode 100644 index 81f87fd99..000000000 --- a/tests/Commands/__snapshots__/TraitMakeCommandTest__test_it_can_generate_a_trait_in_sub_namespace_with_correct_generated_file__1.txt +++ /dev/null @@ -1,8 +0,0 @@ - Date: Mon, 1 Jul 2024 06:51:28 +0100 Subject: [PATCH 386/422] Update properties Docblock --- src/Generators/ModuleGenerator.php | 43 +++++++++--------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index de95fde57..daaeefa84 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -4,6 +4,7 @@ use Illuminate\Config\Repository as Config; use Illuminate\Console\Command as Console; +use Illuminate\Console\View\Components\Factory; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; use Nwidart\Modules\Contracts\ActivatorInterface; @@ -19,73 +20,53 @@ class ModuleGenerator extends Generator /** * The module name will created. - * - * @var string */ - protected $name; + protected ?string $name = null; /** * The laravel config instance. - * - * @var Config */ - protected $config; + protected ?Config $config = null; /** * The laravel filesystem instance. - * - * @var Filesystem */ - protected $filesystem; + protected ?Filesystem $filesystem = null; /** * The laravel console instance. - * - * @var Console */ - protected $console; + protected ?Console $console = null; /** * The laravel component Factory instance. - * - * @var \Illuminate\Console\View\Components\Factory */ - protected $component; + protected ?Factory $component = null; /** * The activator instance - * - * @var ActivatorInterface */ - protected $activator; + protected ?ActivatorInterface $activator = null; /** * The module instance. - * - * @var \Nwidart\Modules\Module */ - protected $module; + protected ?Module $module = null; /** * Force status. - * - * @var bool */ - protected $force = false; + protected bool $force = false; /** * set default module type. - * - * @var string */ - protected $type = 'web'; + protected string $type = 'web'; /** * Enables the module. - * - * @var bool */ - protected $isActive = false; + protected bool $isActive = false; /** * Module author @@ -139,7 +120,7 @@ public function setActive(bool $active): self } /** - * Get the name of module will created. By default in studly case. + * Get the name of module that will be created (in StudlyCase). */ public function getName(): string { From ab610f1fb54f3f675183de7649dcd4ceb03fbdc0 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Mon, 1 Jul 2024 07:05:44 +0100 Subject: [PATCH 387/422] [bug] Update `$module` property typecasting to `mixed` --- src/Generators/ModuleGenerator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index daaeefa84..04b249f9f 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -51,7 +51,8 @@ class ModuleGenerator extends Generator /** * The module instance. */ - protected ?Module $module = null; + /*?Module*/ + protected mixed $module = null; /** * Force status. From d9ac5cc9a2d2bdff6e61d5ba499c03eea8ce9284 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 2 Jul 2024 10:51:34 +0330 Subject: [PATCH 388/422] [feat] update event names --- src/Constants/ModuleEvent.php | 8 ++++++-- src/Generators/ModuleGenerator.php | 4 +++- src/Module.php | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Constants/ModuleEvent.php b/src/Constants/ModuleEvent.php index 464f13c8d..d19c8d365 100644 --- a/src/Constants/ModuleEvent.php +++ b/src/Constants/ModuleEvent.php @@ -16,9 +16,13 @@ class ModuleEvent const ENABLED = 'enabled'; - const CREATE = 'create'; + const CREATING = 'creating'; - const DELETE = 'delete'; + const CREATED = 'created'; + + const DELETING = 'deleting'; + + const DELETED = 'deleted'; const USED = 'used'; diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 44db8f6cc..bd2b010a7 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -336,6 +336,8 @@ public function setForce($force) */ public function generate(): int { + $this->fireEvent(ModuleEvent::CREATING); + $name = $this->getName(); if ($this->module->has($name)) { @@ -368,7 +370,7 @@ public function generate(): int $this->component->info("Module [{$name}] created successfully."); - $this->fireEvent(ModuleEvent::CREATE); + $this->fireEvent(ModuleEvent::CREATED); return 0; } diff --git a/src/Module.php b/src/Module.php index f11715a8f..e5f8f0c29 100644 --- a/src/Module.php +++ b/src/Module.php @@ -370,11 +370,13 @@ public function enable(): void */ public function delete(): bool { + $this->fireEvent(ModuleEvent::DELETING); + $this->activator->delete($this); $result = $this->json()->getFilesystem()->deleteDirectory($this->getPath()); - $this->fireEvent(ModuleEvent::DELETE); + $this->fireEvent(ModuleEvent::DELETED); return $result; } From a842a9f5afcedff7c31a7f4818276913586b7f1f Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 2 Jul 2024 10:52:26 +0330 Subject: [PATCH 389/422] [test] update test with new events --- tests/Commands/Actions/ModuleDeleteCommandTest.php | 6 ++++-- tests/Commands/Make/ModuleMakeCommandTest.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/Commands/Actions/ModuleDeleteCommandTest.php b/tests/Commands/Actions/ModuleDeleteCommandTest.php index 1fce2f0a6..faba96e00 100644 --- a/tests/Commands/Actions/ModuleDeleteCommandTest.php +++ b/tests/Commands/Actions/ModuleDeleteCommandTest.php @@ -104,7 +104,8 @@ public function test_it_fires_events_when_module_deleted() $this->assertSame(0, $code); - Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETE, strtolower($module_name))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETING, strtolower($module_name))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETED, strtolower($module_name))); } public function test_it_fires_events_when_multi_module_deleted() @@ -126,7 +127,8 @@ public function test_it_fires_events_when_multi_module_deleted() $this->assertSame(0, $code); foreach ($modules as $module) { - Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETE, strtolower($module))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETING, strtolower($module))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETED, strtolower($module))); } } } diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index 3671ff625..773bf8081 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -495,7 +495,8 @@ public function test_it_fires_events_when_module_created() $this->assertSame(0, $code); - Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATE, strtolower($module_name))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATING, strtolower($module_name))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower($module_name))); } public function test_it_fires_events_when_multi_module_created() @@ -513,7 +514,8 @@ public function test_it_fires_events_when_multi_module_created() $this->assertSame(0, $code); foreach ($modules as $module) { - Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATE, strtolower($module))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATING, strtolower($module))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower($module))); } } From 9c632cf342386730a5b2e20513247c03325459f7 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 2 Jul 2024 11:08:00 +0330 Subject: [PATCH 390/422] [fix] fix fire event of CREATING --- src/Generators/ModuleGenerator.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index bd2b010a7..93f7a6fba 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -9,7 +9,6 @@ use Illuminate\Support\Str; use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\ActivatorInterface; -use Nwidart\Modules\Facades\Module; use Nwidart\Modules\FileRepository; use Nwidart\Modules\Support\Config\GenerateConfigReader; use Nwidart\Modules\Support\Stub; @@ -336,10 +335,10 @@ public function setForce($force) */ public function generate(): int { - $this->fireEvent(ModuleEvent::CREATING); - $name = $this->getName(); + Event::dispatch(sprintf('modules.%s.%s', strtolower($name), ModuleEvent::CREATING)); + if ($this->module->has($name)) { if ($this->force) { $this->module->delete($name); @@ -686,8 +685,6 @@ protected function getProviderNamespaceReplacement(): string /** * fire the module event. - * - * @param string $event */ protected function fireEvent(string $event): void { From 8edcec73ac99902969308754d70983125ed2b881 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 2 Jul 2024 11:09:23 +0330 Subject: [PATCH 391/422] [style] update logic of event name --- src/Module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module.php b/src/Module.php index e5f8f0c29..e2338360e 100644 --- a/src/Module.php +++ b/src/Module.php @@ -269,7 +269,7 @@ public function register(): void */ public function fireEvent(string $event): void { - $this->app['events']->dispatch(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]); + $this->app['events']->dispatch(sprintf('modules.%s.%s', $this->getLowerName(), $event), [$this]); } /** From dfa59b51ddd7aa1087e6ec789cdb0b732065b048 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 5 Jul 2024 01:54:50 +0330 Subject: [PATCH 392/422] [feat] add module discover config --- config/config.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/config/config.php b/config/config.php index 44c699e7c..d7228eaef 100644 --- a/config/config.php +++ b/config/config.php @@ -168,6 +168,28 @@ ], ], + /* + |-------------------------------------------------------------------------- + | Auto Discover of Modules + |-------------------------------------------------------------------------- + | + | Here you configure auto discover of module + | This is useful for simplify module providers. + | + */ + 'auto-discover' => [ + /* + |-------------------------------------------------------------------------- + | Migrations + |-------------------------------------------------------------------------- + | + | This option for register migration automatically. + | + */ + 'migrations' => true, + + ], + /* |-------------------------------------------------------------------------- | Package commands From 33de0b26495e770b3c9f761f8a842302b0759e14 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Fri, 5 Jul 2024 02:01:29 +0330 Subject: [PATCH 393/422] [feat] register migration automatically --- src/LaravelModulesServiceProvider.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index 7fd540e85..0cd29c897 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules; use Composer\InstalledVersions; +use Illuminate\Database\Migrations\Migrator; use Illuminate\Foundation\Console\AboutCommand; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; @@ -32,6 +33,8 @@ public function register() $this->setupStubPath(); $this->registerProviders(); + $this->registerMigrations(); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules'); } @@ -74,4 +77,27 @@ protected function registerServices() }); $this->app->alias(Contracts\RepositoryInterface::class, 'modules'); } + + protected function registerMigrations(): void + { + if (! $this->app['config']->get('modules.auto-discover.migrations', true)) { + return; + } + + $this->app->resolving(Migrator::class, function (Migrator $migrator) { + + $path = implode(DIRECTORY_SEPARATOR, [ + $this->app['config']->get('modules.paths.modules'), + '*', + '[Dd]atabase', + 'migrations', + ]); + + collect(glob($path, GLOB_ONLYDIR)) + ->each(function (string $path) use ($migrator) { + $migrator->path($path); + }); + }); + + } } From 3c71341d4deb2dabe9c9f4e3e682e70af4dea0fc Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 21 Jul 2024 15:03:17 +0100 Subject: [PATCH 394/422] Optimize FileRepository Update DocBlock (methods documentation comments) Rearranged methods based on operations and relativity. Update: all() -> all(?bool $enabled = null) Add the ability to filter modules by status Update: count() -> count(?bool $enabled = null) Add the ability to filter modules by status Add: collect(?bool $status = true): Collection Simplified methods name: - addLocation() -> add_path() - getPaths() -> paths() - getScanPaths() -> scanPaths() - createModule() -> module() - getCached() -> cached() - getByStatus() - > status() - allEnabled() -> all(true) - allDisabled() -> all(false) - getOrdered() -> ordered() - getPath() -> path() - getModulePath() -> modulePath() - getUsedStoragePath() -> usedStoragePath() - setUsed() -> use() - getUsedNow() -> used() - getFiles() -> files() - getAssetsPath() -> assetsPath() - isEnabled() ->enabled() - isDisabled() -> disabled() - getStubPath() -> stubPath() --- src/Contracts/RepositoryInterface.php | 171 ++++---- src/FileRepository.php | 568 +++++++++++++++----------- src/Laravel/LaravelFileRepository.php | 2 +- src/Lumen/LumenFileRepository.php | 2 +- 4 files changed, 439 insertions(+), 304 deletions(-) diff --git a/src/Contracts/RepositoryInterface.php b/src/Contracts/RepositoryInterface.php index 3741dbeee..f7331bbfc 100644 --- a/src/Contracts/RepositoryInterface.php +++ b/src/Contracts/RepositoryInterface.php @@ -2,132 +2,97 @@ namespace Nwidart\Modules\Contracts; +use Illuminate\Filesystem\Filesystem; +use Nwidart\Modules\Collection; use Nwidart\Modules\Exceptions\ModuleNotFoundException; use Nwidart\Modules\Module; interface RepositoryInterface { /** - * Get all modules. - * - * @return mixed + * Boot the modules. */ - public function all(); + public function boot(): void; /** - * Get cached modules. - * - * @return array + * Register the modules. */ - public function getCached(); + public function register(): void; /** - * Scan & get all available modules. - * - * @return array + * Get all modules. */ - public function scan(); + public function all(): array; /** - * Get modules as modules collection instance. - * - * @return \Nwidart\Modules\Collection + * @deprecated 10.0.11 use all(true) or status(true) */ - public function toCollection(); + public function allEnabled(): array; /** - * Get scanned paths. - * - * @return array + * @deprecated 10.0.11 use all(false) or status(false) */ - public function getScanPaths(); + public function allDisabled(): array; /** - * Get list of enabled modules. - * - * @return mixed + * Find a specific module. */ - public function allEnabled(); + public function find(string $name): ?Module; /** - * Get list of disabled modules. - * - * @return mixed + * Find a specific module. If there return that, otherwise throw exception. */ - public function allDisabled(); + public function findOrFail(string $name): Module; /** - * Get count from all modules. - * - * @return int + * Get modules by active status [true|false]. */ - public function count(); + public function status(bool $status): array; /** - * Get all ordered modules. - * - * @param string $direction - * @return mixed + * @deprecated 10.0.11 use status() */ - public function getOrdered($direction = 'asc'); + public function getByStatus(int $status): array; /** - * Get modules by the given status. - * - * @param int $status - * @return mixed + * Scan & get all available modules. */ - public function getByStatus($status); + public function scan(): array; /** - * Find a specific module. - * - * @return Module|null + * Get scanned modules paths. */ - public function find(string $name); + public function scanPaths(): array; /** - * Find a specific module. If there return that, otherwise throw exception. - * - * - * @return mixed + * @deprecated 10.0.11 use scanPaths() */ - public function findOrFail(string $name); - - public function getModulePath($moduleName); + public function getScanPaths(): array; /** - * @return \Illuminate\Filesystem\Filesystem - */ - public function getFiles(); - - /** - * Get a specific config data from a configuration file. - * - * @param string|null $default - * @return mixed + * Get cached modules. */ - public function config(string $key, $default = null); + public function cached(): array; /** - * Get a module path. + * @deprecated 10.0.11 use cached() */ - public function getPath(): string; + public function getCached(): array; /** - * Boot the modules. + * Get all modules as collection instance. */ - public function boot(): void; + public function toCollection(): Collection; /** - * Register the modules. + * Get all ordered modules. */ - public function register(): void; + public function ordered(string $sort = 'asc'): array; /** - * Get asset path for a specific module. + * @deprecated 10.0.11 use ordered() */ - public function assetPath(string $module): string; + public function getOrdered(string $direction = 'asc'): array; /** * Delete a specific module. @@ -137,16 +102,76 @@ public function assetPath(string $module): string; public function delete(string $module): bool; /** - * Determine whether the given module is activated. + * Get a specific config data from a configuration file. + */ + public function config(string $key, ?string $default = null): mixed; + + /** + * Get count from all modules. + */ + public function count(): int; + + /** + * Determine whether the given module exist. + */ + public function has(string $name): bool; + + /** + * Determine if the given module is enabled. * * @throws ModuleNotFoundException */ + public function enabled(string $name): bool; + + /** + * @deprecated 10.0.11 use enabled() + */ public function isEnabled(string $name): bool; /** - * Determine whether the given module is not activated. + * Determine if the given module is disabled. * * @throws ModuleNotFoundException */ + public function disabled(string $name): bool; + + /** + * @deprecated 10.0.11 use disabled() + */ public function isDisabled(string $name): bool; + + /** + * Get laravel filesystem instance. + */ + public function files(): Filesystem; + + /** + * @deprecated 10.0.11 use files() + */ + public function getFiles(): Filesystem; + + /** + * Get a module path. + */ + public function path(): string; + + /** + * @deprecated 10.0.11 use path() + */ + public function getPath(): string; + + /** + * Get module path for a specific module. + */ + public function modulePath($moduleName): string; + + /** + * @deprecated 10.0.11 use modulePath() + */ + public function getModulePath($moduleName): string; + + /** + * Get asset path for a specific module. + */ + public function assetPath(string $module): string; } diff --git a/src/FileRepository.php b/src/FileRepository.php index 6dc22b7c8..5d50ebfa2 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -15,6 +15,7 @@ use Nwidart\Modules\Exceptions\ModuleNotFoundException; use Nwidart\Modules\Process\Installer; use Nwidart\Modules\Process\Updater; +use Symfony\Component\Process\Process; abstract class FileRepository implements Countable, RepositoryInterface { @@ -68,10 +69,8 @@ abstract class FileRepository implements Countable, RepositoryInterface /** * The constructor. - * - * @param string|null $path */ - public function __construct(Container $app, $path = null) + public function __construct(Container $app, ?string $path = null) { $this->app = $app; $this->path = $path; @@ -82,76 +81,159 @@ public function __construct(Container $app, $path = null) } /** - * Add other module location. + * {@inheritDoc} + */ + public function boot(): void + { + foreach ($this->ordered() as $module) { + $module->boot(); + } + } + + /** + * {@inheritDoc} + */ + public function register(): void + { + foreach ($this->ordered() as $module) { + $module->register(); + } + } + + /** + * Creates a new Module instance * + * @param Container $app + * @param string $args * @param string $path - * @return $this */ - public function addLocation($path) + abstract protected function module(...$args): Module; + + /** + * @deprecated 10.0.11 use module() + */ + protected function createModule(...$args) { - $this->paths[] = $path; + return $this->module(...$args); + } - return $this; + /** + * Install the specified module. + */ + public function install(string $name, string $version = 'dev-master', string $type = 'composer', bool $subtree = false): Process + { + $installer = new Installer($name, $version, $type, $subtree); + + return $installer->run(); } /** - * Get all additional paths. + * {@inheritDoc} */ - public function getPaths(): array + public function all(?bool $enabled = null): array { - return $this->paths; + if (is_bool($enabled)) { + if ($enabled) { + return $this->status(true); + } + + return $this->status(false); + } + + if (!$this->config('cache.enabled')) { + return $this->scan(); + } + + return $this->formatCached($this->cached()); } /** - * Get scanned modules paths. + * @deprecated 10.0.11 use all(true) or status(true) */ - public function getScanPaths(): array + public function allEnabled(): array { - $paths = $this->paths; + return $this->status(true); + } - $paths[] = $this->getPath(); + /** + * @deprecated 10.0.11 use all(false) or status(false) + */ + public function allDisabled(): array + { + return $this->status(false); + } - if ($this->config('scan.enabled')) { - $paths = array_merge($paths, $this->config('scan.paths')); + /** + * {@inheritDoc} + */ + public function find(string $name): ?Module + { + foreach ($this->all() as $module) { + if ($module->getLowerName() === strtolower($name)) { + return $module; + } } - $paths = array_map(function ($path) { - return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); - }, $paths); + return null; + } - return $paths; + /** + * {@inheritDoc} + */ + public function findOrFail(string $name): Module + { + $module = $this->find($name); + + if ($module !== null) { + return $module; + } + + throw new ModuleNotFoundException("Module [{$name}] does not exist!"); } /** - * Creates a new Module instance - * - * @param Container $app - * @param string $args - * @param string $path - * @return \Nwidart\Modules\Module + * Get modules by the given status. */ - abstract protected function createModule(...$args); + public function status(bool $status): array + { + $modules = []; + + /** @var Module $module */ + foreach ($this->all() as $name => $module) { + if ($module->isStatus($status)) { + $modules[$name] = $module; + } + } + + return $modules; + } /** - * Get & scan all modules. - * - * @return array + * @deprecated 10.0.11 use status() */ - public function scan() + public function getByStatus($status): array { - $paths = $this->getScanPaths(); + return $this->status($status); + } + + /** + * {@inheritDoc} + */ + public function scan(): array + { + $paths = $this->scanPaths(); $modules = []; foreach ($paths as $key => $path) { - $manifests = $this->getFiles()->glob("{$path}/module.json"); + $manifests = $this->files()->glob("{$path}/module.json"); is_array($manifests) || $manifests = []; foreach ($manifests as $manifest) { $name = Json::make($manifest)->get('name'); - $modules[$name] = $this->createModule($this->app, $name, dirname($manifest)); + $modules[$name] = $this->module($this->app, $name, dirname($manifest)); } } @@ -159,42 +241,37 @@ public function scan() } /** - * Get all modules. + * {@inheritDoc} */ - public function all(): array + public function scanPaths(): array { - if (! $this->config('cache.enabled')) { - return $this->scan(); + $paths = $this->paths; + + $paths[] = $this->path(); + + if ($this->config('scan.enabled')) { + $paths = array_merge($paths, $this->config('scan.paths')); } - return $this->formatCached($this->getCached()); + $paths = array_map(function ($path) { + return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); + }, $paths); + + return $paths; } /** - * Format the cached data as array of modules. - * - * @param array $cached - * @return array + * @deprecated 10.0.11 use scanPaths() */ - protected function formatCached($cached) + public function getScanPaths(): array { - $modules = []; - - foreach ($cached as $name => $module) { - $path = $module['path']; - - $modules[$name] = $this->createModule($this->app, $name, $path); - } - - return $modules; + return $this->scanPaths(); } /** - * Get cached modules. - * - * @return array + * {@inheritDoc} */ - public function getCached() + public function cached(): array { return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { return $this->toCollection()->toArray(); @@ -202,77 +279,66 @@ public function getCached() } /** - * Get all modules as collection instance. + * @deprecated 10.0.11 use cached() */ - public function toCollection(): Collection + public function getCached(): array { - return new Collection($this->scan()); + return $this->cached(); } /** - * Get modules by status. + * Format the cached data as array of modules. */ - public function getByStatus($status): array + protected function formatCached(array $cached): array { $modules = []; - /** @var Module $module */ - foreach ($this->all() as $name => $module) { - if ($module->isStatus($status)) { - $modules[$name] = $module; - } + foreach ($cached as $name => $module) { + $path = $module['path']; + + $modules[$name] = $this->module($this->app, $name, $path); } return $modules; } /** - * Determine whether the given module exist. - */ - public function has($name): bool - { - return array_key_exists($name, $this->all()); - } - - /** - * Get list of enabled modules. + * {@inheritDoc} */ - public function allEnabled(): array + public function toCollection(): Collection { - return $this->getByStatus(true); + return new Collection($this->scan()); } /** - * Get list of disabled modules. + * Get all modules as laravel collection instance. */ - public function allDisabled(): array + public function collect(?bool $status = true): Collection { - return $this->getByStatus(false); + return new Collection($this->all((bool) $status)); } /** - * Get count from all modules. + * Get all modules as laravel collection instance. */ - public function count(): int + public function collections(?bool $status = true): Collection { - return count($this->all()); + return new Collection($this->all((bool) $status)); } /** - * Get all ordered modules. - * - * @param string $direction + * {@inheritDoc} */ - public function getOrdered($direction = 'asc'): array + public function ordered(string $sort = 'asc'): array { - $modules = $this->allEnabled(); + $modules = $this->all(true); - uasort($modules, function (Module $a, Module $b) use ($direction) { + uasort($modules, function (Module $a, Module $b) use ($sort) { if ($a->get('priority') === $b->get('priority')) { return 0; } - if ($direction === 'desc') { + if ($sort === 'desc') { return $a->get('priority') < $b->get('priority') ? 1 : -1; } @@ -283,183 +349,244 @@ public function getOrdered($direction = 'asc'): array } /** - * {@inheritDoc} + * @deprecated 10.0.11 use ordered() */ - public function getPath(): string + public function getOrdered(string $direction = 'asc'): array { - return $this->path ?: $this->config('paths.modules', base_path('Modules')); + return $this->ordered($direction); + } + + /** + * Update dependencies for the specified module. + */ + public function update(string $module): void + { + with(new Updater($this))->update($module); } /** * {@inheritDoc} */ - public function register(): void + public function delete(string $name): bool { - foreach ($this->getOrdered() as $module) { - $module->register(); - } + return $this->findOrFail($name)->delete(); } /** * {@inheritDoc} */ - public function boot(): void + public function config(string $key, ?string $default = null): mixed { - foreach ($this->getOrdered() as $module) { - $module->boot(); - } + return $this->config->get('modules.' . $key, $default); } /** * {@inheritDoc} */ - public function find(string $name) + public function count(?bool $enabled = null): int { - foreach ($this->all() as $module) { - if ($module->getLowerName() === strtolower($name)) { - return $module; + if (is_bool($enabled)) { + if ($enabled) { + return count($this->all(true)); } + + return count($this->all(false)); } + return count($this->all()); } /** - * Find a specific module, if there return that, otherwise throw exception. - * - * - * @return Module - * - * @throws ModuleNotFoundException + * {@inheritDoc} */ - public function findOrFail(string $name) + public function has(string $name): bool { - $module = $this->find($name); + return array_key_exists($name, $this->all()); + } - if ($module !== null) { - return $module; - } + /** + * Enabling a specific module. + * + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + */ + public function enable(string $name): void + { + $this->findOrFail($name)->enable(); + } - throw new ModuleNotFoundException("Module [{$name}] does not exist!"); + /** + * {@inheritDoc} + */ + public function enabled(string $name): bool + { + return $this->findOrFail($name)->isEnabled(); } /** - * Get all modules as laravel collection instance. + * @deprecated 10.0.11 use enabled() */ - public function collections($status = 1): Collection + public function isEnabled(string $name): bool { - return new Collection($this->getByStatus($status)); + return $this->enabled($name); } /** - * Get module path for a specific module. - * + * Disabling a specific module. * - * @return string + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function getModulePath($module) + public function disable(string $name): void { - try { - return $this->findOrFail($module)->getPath().'/'; - } catch (ModuleNotFoundException $e) { - return $this->getPath().'/'.Str::studly($module).'/'; - } + $this->findOrFail($name)->disable(); } /** * {@inheritDoc} */ - public function assetPath(string $module): string + public function disabled(string $name): bool { - return $this->config('paths.assets').'/'.$module; + return !$this->enabled($name); + } + + /** + * @deprecated 10.0.11 use disabled() + */ + public function isDisabled(string $name): bool + { + return $this->disabled($name); } /** * {@inheritDoc} */ - public function config(string $key, $default = null) + public function files(): Filesystem { - return $this->config->get('modules.'.$key, $default); + return $this->files; } /** - * Get storage path for module used. + * @deprecated 10.0.11 use files() */ - public function getUsedStoragePath(): string + public function getFiles(): Filesystem { - $directory = storage_path('app/modules'); - if ($this->getFiles()->exists($directory) === false) { - $this->getFiles()->makeDirectory($directory, 0777, true); - } + return $this->files(); + } - $path = storage_path('app/modules/modules.used'); - if (! $this->getFiles()->exists($path)) { - $this->getFiles()->put($path, ''); - } + /** + * {@inheritDoc} + */ + public function path(): string + { + return $this->path ?: $this->config('paths.modules', base_path('Modules')); + } - return $path; + /** + * @deprecated 10.0.11 use path() + */ + public function getPath(): string + { + return $this->path(); } /** - * Set module used for cli session. - * - * - * @throws ModuleNotFoundException + * Get all additional paths. */ - public function setUsed($name) + public function extra_paths(): array { - $module = $this->findOrFail($name); + return $this->paths; + } - $this->getFiles()->put($this->getUsedStoragePath(), $module); + /** + * @deprecated 10.0.11 use extra_paths() + */ + public function getPaths(): array + { + return $this->extra_paths(); } /** - * Forget the module used for cli session. + * {@inheritDoc} */ - public function forgetUsed() + public function modulePath($module): string { - if ($this->getFiles()->exists($this->getUsedStoragePath())) { - $this->getFiles()->delete($this->getUsedStoragePath()); + try { + return $this->findOrFail($module)->getPath() . '/'; + } catch (ModuleNotFoundException $e) { + return $this->path() . '/' . Str::studly($module) . '/'; } } /** - * Get module used for cli session. - * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + * @deprecated 10.0.11 use modulePath() */ - public function getUsedNow(): string + public function getModulePath($module): string { - return $this->findOrFail($this->getFiles()->get($this->getUsedStoragePath())); + return $this->modulePath($module); } /** - * Get laravel filesystem instance. + * Add extra module path. */ - public function getFiles(): Filesystem + public function add_path(string $path): self { - return $this->files; + $this->paths[] = $path; + + return $this; } /** - * Get module assets path. + * @deprecated 10.0.11 use add_path($path) */ - public function getAssetsPath(): string + public function addLocation(string $path): self { - return $this->config('paths.assets'); + return $this->add_path($path); + } + + /** + * Get stub path. + */ + public function stubPath(): ?string + { + if ($this->stubPath !== null) { + return $this->stubPath; + } + + if ($this->config('stubs.enabled') === true) { + return $this->config('stubs.path'); + } + + return $this->stubPath; + } + + /** + * @deprecated 10.0.11 use stubPath() + */ + public function getStubPath(): ?string + { + return $this->stubPath(); + } + + /** + * Set stub path. + */ + public function setStubPath(string $stubPath): self + { + $this->stubPath = $stubPath; + + return $this; } /** * Get asset url from a specific module. * - * @param string $asset - * * @throws InvalidAssetPath */ - public function asset($asset): string + public function asset(string $asset): string { if (Str::contains($asset, ':') === false) { throw InvalidAssetPath::missingModuleName($asset); } + [$name, $url] = explode(':', $asset); $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); @@ -472,107 +599,90 @@ public function asset($asset): string /** * {@inheritDoc} */ - public function isEnabled(string $name): bool - { - return $this->findOrFail($name)->isEnabled(); - } - - /** - * {@inheritDoc} - */ - public function isDisabled(string $name): bool + public function assetPath(string $module): string { - return ! $this->isEnabled($name); + return $this->config('paths.assets') . '/' . $module; } /** - * Enabling a specific module. - * - * @param string $name - * @return void - * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + * Get module assets path. */ - public function enable($name) + public function getAssetsPath(): string { - $this->findOrFail($name)->enable(); + return $this->config('paths.assets'); } /** - * Disabling a specific module. - * - * @param string $name - * @return void + * Get module used for cli session. * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function disable($name) + public function used(): string { - $this->findOrFail($name)->disable(); + return $this->findOrFail($this->files()->get($this->usedStoragePath())); } /** - * {@inheritDoc} + * @deprecated 10.0.11 use used() */ - public function delete(string $name): bool + public function getUsedNow(): string { - return $this->findOrFail($name)->delete(); + return $this->used(); } /** - * Update dependencies for the specified module. + * Set module used for cli session. * - * @param string $module + * @throws ModuleNotFoundException */ - public function update($module) + public function use($name) { - with(new Updater($this))->update($module); + $module = $this->findOrFail($name); + + $this->files()->put($this->usedStoragePath(), $module); } /** - * Install the specified module. - * - * @param string $name - * @param string $version - * @param string $type - * @param bool $subtree - * @return \Symfony\Component\Process\Process + * @deprecated 10.0.11 use use($name) */ - public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false) + public function setUsed($name) { - $installer = new Installer($name, $version, $type, $subtree); - - return $installer->run(); + $this->use($name); } /** - * Get stub path. - * - * @return string|null + * Get storage path for module used. */ - public function getStubPath() + public function usedStoragePath(): string { - if ($this->stubPath !== null) { - return $this->stubPath; + $directory = storage_path('app/modules'); + if ($this->files()->exists($directory) === false) { + $this->files()->makeDirectory($directory, 0777, true); } - if ($this->config('stubs.enabled') === true) { - return $this->config('stubs.path'); + $path = storage_path('app/modules/modules.used'); + if (!$this->files()->exists($path)) { + $this->files()->put($path, ''); } - return $this->stubPath; + return $path; } /** - * Set stub path. - * - * @param string $stubPath - * @return $this + * @deprecated 10.0.11 use usedStoragePath() */ - public function setStubPath($stubPath) + public function getUsedStoragePath(): string { - $this->stubPath = $stubPath; + return $this->usedStoragePath(); + } - return $this; + /** + * Forget the module used for cli session. + */ + public function forgetUsed() + { + if ($this->files()->exists($this->usedStoragePath())) { + $this->files()->delete($this->usedStoragePath()); + } } } diff --git a/src/Laravel/LaravelFileRepository.php b/src/Laravel/LaravelFileRepository.php index 600f298fd..20455a303 100644 --- a/src/Laravel/LaravelFileRepository.php +++ b/src/Laravel/LaravelFileRepository.php @@ -9,7 +9,7 @@ class LaravelFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function createModule(...$args) + protected function module(...$args): Module { return new Module(...$args); } diff --git a/src/Lumen/LumenFileRepository.php b/src/Lumen/LumenFileRepository.php index de2b783f0..69dc095c9 100644 --- a/src/Lumen/LumenFileRepository.php +++ b/src/Lumen/LumenFileRepository.php @@ -9,7 +9,7 @@ class LumenFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function createModule(...$args) + protected function module(...$args): Module { return new Module(...$args); } From b947b2fc7e1a0d3ecb2a37b8bbe51790bb0b0c27 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 21 Jul 2024 16:01:19 +0100 Subject: [PATCH 395/422] Update controller.stub Remove default method return types. --- src/Commands/stubs/controller.stub | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Commands/stubs/controller.stub b/src/Commands/stubs/controller.stub index 04aaefd2b..610fbd341 100644 --- a/src/Commands/stubs/controller.stub +++ b/src/Commands/stubs/controller.stub @@ -3,9 +3,7 @@ namespace $CLASS_NAMESPACE$; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class $CLASS$ extends Controller { @@ -28,7 +26,7 @@ class $CLASS$ extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class $CLASS$ extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } From 87642d036936a6ef06beaf76e8b5f6628cc9c305 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 21 Jul 2024 15:41:01 +0100 Subject: [PATCH 396/422] Update model.stub The Factory class doesn't exist by default. --- src/Commands/stubs/model.stub | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Commands/stubs/model.stub b/src/Commands/stubs/model.stub index ba4f52919..57107e9ba 100644 --- a/src/Commands/stubs/model.stub +++ b/src/Commands/stubs/model.stub @@ -4,7 +4,6 @@ namespace $NAMESPACE$; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use $MODULE_NAMESPACE$\$MODULE$\Database\Factories\$NAME$Factory; class $CLASS$ extends Model { @@ -15,8 +14,8 @@ class $CLASS$ extends Model */ protected $fillable = $FILLABLE$; - protected static function newFactory(): $NAME$Factory + protected static function newFactory() { - //return $NAME$Factory::new(); + // return $NAME$Factory::new(); } } From 904b15216d47fecf991bbc50dcb5f5dd34e29b63 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Jul 2024 16:51:04 +0100 Subject: [PATCH 397/422] [fix] Comment out the factory method - Instead of removing the methods, it should be commented out as it holds a specif format of using factory in module. --- src/Commands/stubs/model.stub | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Commands/stubs/model.stub b/src/Commands/stubs/model.stub index 57107e9ba..1d45d1dfa 100644 --- a/src/Commands/stubs/model.stub +++ b/src/Commands/stubs/model.stub @@ -4,6 +4,7 @@ namespace $NAMESPACE$; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +// use $MODULE_NAMESPACE$\$MODULE$\Database\Factories\$NAME$Factory; class $CLASS$ extends Model { @@ -14,8 +15,8 @@ class $CLASS$ extends Model */ protected $fillable = $FILLABLE$; - protected static function newFactory() - { - // return $NAME$Factory::new(); - } + // protected static function newFactory(): $NAME$Factory + // { + // // return $NAME$Factory::new(); + // } } From 261c5f5441c6acd2854f20c9db5941182295b2cb Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Jul 2024 16:51:33 +0100 Subject: [PATCH 398/422] [test] Update the model.stub snapshots --- ...st__test_it_can_change_the_default_namespace__1.txt | 10 +++++----- ...it_can_change_the_default_namespace_specific__1.txt | 10 +++++----- ..._test_it_generated_correct_file_with_content__1.txt | 10 +++++----- ...t__test_it_generates_correct_fillable_fields__1.txt | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 395327120..7355e76a1 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = []; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 395327120..7355e76a1 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = []; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 395327120..7355e76a1 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = []; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt index 1d8cc95e6..8cd255f13 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_correct_fillable_fields__1.txt @@ -4,7 +4,7 @@ namespace Modules\Blog\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Blog\Database\Factories\PostFactory; +// use Modules\Blog\Database\Factories\PostFactory; class Post extends Model { @@ -15,8 +15,8 @@ class Post extends Model */ protected $fillable = ["title","slug"]; - protected static function newFactory(): PostFactory - { - //return PostFactory::new(); - } + // protected static function newFactory(): PostFactory + // { + // // return PostFactory::new(); + // } } From 9476284172e8d8f8bfeddc094b1d5eef5f6ee6c7 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Sun, 21 Jul 2024 15:36:58 +0100 Subject: [PATCH 399/422] Update event-provider.stub Remove double return type declaration. --- src/Commands/stubs/event-provider.stub | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Commands/stubs/event-provider.stub b/src/Commands/stubs/event-provider.stub index 4ed5a033a..f2f67fc8e 100644 --- a/src/Commands/stubs/event-provider.stub +++ b/src/Commands/stubs/event-provider.stub @@ -22,11 +22,9 @@ class $CLASS$ extends ServiceProvider /** * Configure the proper event listeners for email verification. - * - * @return void */ protected function configureEmailVerification(): void { - + // } } From bbb1946abc0efbbab7ca80240355937f27bbe802 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Jul 2024 17:07:33 +0100 Subject: [PATCH 400/422] [test] Update test snapshot --- ...MakeCommandTest__test_it_generates_module_resources__2.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt index 4130adfaa..5f4668484 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__2.txt @@ -22,11 +22,9 @@ class EventServiceProvider extends ServiceProvider /** * Configure the proper event listeners for email verification. - * - * @return void */ protected function configureEmailVerification(): void { - + // } } From 3cfcb884fb1e1e5ad6bba2e832e82990716df337 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Jul 2024 17:24:39 +0100 Subject: [PATCH 401/422] [test] Update snapshots --- ...t_appends_controller_to_class_name_if_not_present__1.txt | 6 ++---- ...andTest__test_it_can_change_the_default_namespace__1.txt | 6 ++---- ...test_it_can_change_the_default_namespace_specific__1.txt | 6 ++---- ...ller_in_sub_namespace_with_correct_generated_file__1.txt | 6 ++---- ...Test__test_it_generated_correct_file_with_content__1.txt | 6 ++---- ...troller_and_migration_when_both_flags_are_present__1.txt | 6 ++---- ...est__test_it_generates_controller_file_with_model__1.txt | 6 ++---- ..._controller_file_with_model_using_shortcut_option__1.txt | 6 ++---- ...keCommandTest__test_it_generates_module_resources__4.txt | 6 ++---- ...Test__test_it_generates_web_module_with_resources__2.txt | 6 ++---- ...e_with_resources_when_adding_more_than_one_option__2.txt | 6 ++---- 11 files changed, 22 insertions(+), 44 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt index 863f2f9d1..ebb6e6b8c 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_appends_controller_to_class_name_if_not_present__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt index 8d94acf97..f6ad657b7 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt index 8d94acf97..f6ad657b7 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_change_the_default_namespace_specific__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt index 5001fb01e..7f1d535a9 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_can_generate_a_controller_in_sub_namespace_with_correct_generated_file__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers\Api; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 863f2f9d1..ebb6e6b8c 100644 --- a/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/ControllerMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MyController extends Controller { @@ -28,7 +26,7 @@ class MyController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class MyController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt index 0006937ff..3a09e23cb 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_and_migration_when_both_flags_are_present__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class PostController extends Controller { @@ -28,7 +26,7 @@ class PostController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class PostController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt index 0006937ff..3a09e23cb 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class PostController extends Controller { @@ -28,7 +26,7 @@ class PostController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class PostController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt index 0006937ff..3a09e23cb 100644 --- a/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt +++ b/tests/Commands/Make/__snapshots__/ModelMakeCommandTest__test_it_generates_controller_file_with_model_using_shortcut_option__1.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class PostController extends Controller { @@ -28,7 +26,7 @@ class PostController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class PostController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt index 6a89e8c29..21acf68c4 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_module_resources__4.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class BlogController extends Controller { @@ -28,7 +26,7 @@ class BlogController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class BlogController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt index 6a89e8c29..21acf68c4 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources__2.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class BlogController extends Controller { @@ -28,7 +26,7 @@ class BlogController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class BlogController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } diff --git a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt index 6a89e8c29..21acf68c4 100644 --- a/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt +++ b/tests/Commands/Make/__snapshots__/ModuleMakeCommandTest__test_it_generates_web_module_with_resources_when_adding_more_than_one_option__2.txt @@ -3,9 +3,7 @@ namespace Modules\Blog\Http\Controllers; use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class BlogController extends Controller { @@ -28,7 +26,7 @@ class BlogController extends Controller /** * Store a newly created resource in storage. */ - public function store(Request $request): RedirectResponse + public function store(Request $request) { // } @@ -52,7 +50,7 @@ class BlogController extends Controller /** * Update the specified resource in storage. */ - public function update(Request $request, $id): RedirectResponse + public function update(Request $request, $id) { // } From c0a8d70297e3c5bb2e74b0936be84102d417d128 Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 25 Jul 2024 17:28:45 +0100 Subject: [PATCH 402/422] [test] Update snapshots --- ...ndTest__test_it_generated_correct_file_with_content__1.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt index 4130adfaa..5f4668484 100644 --- a/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/EventProviderMakeCommandTest__test_it_generated_correct_file_with_content__1.txt @@ -22,11 +22,9 @@ class EventServiceProvider extends ServiceProvider /** * Configure the proper event listeners for email verification. - * - * @return void */ protected function configureEmailVerification(): void { - + // } } From 959a7d6bdd27fb35f0dd7c2d8f9b0d95c7610d68 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 31 Jul 2024 21:06:43 +0330 Subject: [PATCH 403/422] [feat] change 'multiselect' to 'multiSearch' --- src/Commands/BaseCommand.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 6706e0f2d..7330e9829 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -6,13 +6,14 @@ use Illuminate\Console\ConfirmableTrait; use Illuminate\Console\Prohibitable; use Illuminate\Contracts\Console\PromptsForMissingInput; +use Illuminate\Support\Collection; use Nwidart\Modules\Contracts\ConfirmableCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use function Laravel\Prompts\multiselect; +use function Laravel\Prompts\multisearch; abstract class BaseCommand extends Command implements PromptsForMissingInput { @@ -98,12 +99,16 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf return; } - $selected_item = multiselect( - label : 'Select Modules', - options : [ - self::ALL, - ...$modules, - ], + $selected_item = multisearch( + label: 'Select Modules', + options: function (string $search_value) use ($modules) { + return collect([ + self::ALL, + ...$modules, + ])->when(strlen($search_value) > 0, function (Collection &$modules) use ($search_value) { + return $modules->filter(fn ($item) => str_contains(strtolower($item), strtolower($search_value))); + })->toArray(); + }, required: 'You must select at least one module', ); From 2c3662e8c84f1f9cd0d83641c2702398fa5e042c Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 31 Jul 2024 21:07:24 +0330 Subject: [PATCH 404/422] [style] add argument names --- src/Commands/BaseCommand.php | 42 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 7330e9829..11563ec5e 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -30,18 +30,22 @@ abstract class BaseCommand extends Command implements PromptsForMissingInput public function __construct() { parent::__construct(); - $this->getDefinition()->addOption(new InputOption( - strtolower(self::ALL), - 'a', - InputOption::VALUE_NONE, - 'Check all Modules', - )); - - $this->getDefinition()->addArgument(new InputArgument( - 'module', - InputArgument::IS_ARRAY, - 'The name of module will be used.', - )); + $this->getDefinition()->addOption( + option: new InputOption( + name: strtolower(self::ALL), + shortcut: 'a', + mode: InputOption::VALUE_NONE, + description: 'Check all Modules', + ) + ); + + $this->getDefinition()->addArgument( + argument: new InputArgument( + name: 'module', + mode: InputArgument::IS_ARRAY, + description: 'The name of module will be used.', + ) + ); if ($this instanceof ConfirmableCommand) { $this->configureConfirmable(); @@ -130,11 +134,13 @@ protected function getModuleModel($name) private function configureConfirmable(): void { $this->getDefinition() - ->addOption(new InputOption( - 'force', - null, - InputOption::VALUE_NONE, - 'Force the operation to run without confirmation.', - )); + ->addOption( + option: new InputOption( + name: 'force', + shortcut: null, + mode: InputOption::VALUE_NONE, + description: 'Force the operation to run without confirmation.', + ) + ); } } From 56e139acc95bb10ede08de7be4178da5c1b7364b Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Wed, 31 Jul 2024 21:22:46 +0330 Subject: [PATCH 405/422] [fix] bug fix after search and select items --- src/Commands/BaseCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/BaseCommand.php b/src/Commands/BaseCommand.php index 11563ec5e..dcb740df1 100644 --- a/src/Commands/BaseCommand.php +++ b/src/Commands/BaseCommand.php @@ -111,7 +111,7 @@ protected function promptForMissingArguments(InputInterface $input, OutputInterf ...$modules, ])->when(strlen($search_value) > 0, function (Collection &$modules) use ($search_value) { return $modules->filter(fn ($item) => str_contains(strtolower($item), strtolower($search_value))); - })->toArray(); + })->values()->toArray(); }, required: 'You must select at least one module', ); From c7c440a095b15b627b7b9227522d349f649170f0 Mon Sep 17 00:00:00 2001 From: Samuel Mwangi Date: Sun, 11 Aug 2024 22:13:40 +0300 Subject: [PATCH 406/422] Lavavel Pint as a dev-dependency #1872 introduced Laravel pint but incorrectly marked it a dependency instead of as a dev-dependency. The result of this is that Laravel pint gets installed in production --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3d4941b2e..2bce92201 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,7 @@ "require": { "php": ">=8.2", "ext-json": "*", - "wikimedia/composer-merge-plugin": "^2.1", - "laravel/pint": "^1.16" + "wikimedia/composer-merge-plugin": "^2.1" }, "require-dev": { "phpunit/phpunit": "^11.0", @@ -29,6 +28,7 @@ "orchestra/testbench": "^v9.0", "friendsofphp/php-cs-fixer": "^v3.52", "laravel/framework": "^v11.0", + "laravel/pint": "^1.16", "spatie/phpunit-snapshot-assertions": "^5.0", "phpstan/phpstan": "^1.4" }, From babddcaabc0721afa5530f00b3949fed0a1d5414 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sun, 11 Aug 2024 23:35:14 +0330 Subject: [PATCH 407/422] [style] simplify code --- src/Providers/BootstrapServiceProvider.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Providers/BootstrapServiceProvider.php b/src/Providers/BootstrapServiceProvider.php index 82dc07d07..849ffdabf 100644 --- a/src/Providers/BootstrapServiceProvider.php +++ b/src/Providers/BootstrapServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Support\ServiceProvider; use Nwidart\Modules\Contracts\RepositoryInterface; +use Nwidart\Modules\Laravel\LaravelFileRepository; class BootstrapServiceProvider extends ServiceProvider { @@ -12,7 +13,7 @@ class BootstrapServiceProvider extends ServiceProvider */ public function boot(): void { - $this->app[RepositoryInterface::class]->boot(); + $this->getRepositoryInterface()->boot(); } /** @@ -20,6 +21,14 @@ public function boot(): void */ public function register(): void { - $this->app[RepositoryInterface::class]->register(); + $this->getRepositoryInterface()->register(); + } + + /** + * @return LaravelFileRepository + */ + public function getRepositoryInterface() + { + return $this->app[RepositoryInterface::class]; } } From 333a4004304cae9fde4b827665e3146f2d33e80a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sun, 11 Aug 2024 23:35:54 +0330 Subject: [PATCH 408/422] [feat] register listner to call clear complied command --- src/LaravelModulesServiceProvider.php | 30 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index ffbb13015..15de56602 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -6,6 +6,9 @@ use Illuminate\Database\Migrations\Migrator; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Console\AboutCommand; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Event; +use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; use Nwidart\Modules\Support\Stub; @@ -30,6 +33,8 @@ public function boot() $this->registerModules(); + $this->registerEvents(); + AboutCommand::add('Laravel-Modules', [ 'Version' => fn () => InstalledVersions::getPrettyVersion('nwidart/laravel-modules'), ]); @@ -46,7 +51,7 @@ public function register() $this->registerMigrations(); - $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'modules'); + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules'); } /** @@ -54,13 +59,13 @@ public function register() */ public function setupStubPath() { - $path = $this->app['config']->get('modules.stubs.path') ?? __DIR__ . '/Commands/stubs'; + $path = $this->app['config']->get('modules.stubs.path') ?? __DIR__.'/Commands/stubs'; Stub::setBasePath($path); $this->app->booted(function ($app) { /** @var RepositoryInterface $moduleRepository */ $moduleRepository = $app[RepositoryInterface::class]; - if ($moduleRepository->config('stubs.enabled') === TRUE) { + if ($moduleRepository->config('stubs.enabled') === true) { Stub::setBasePath($moduleRepository->config('stubs.path')); } }); @@ -78,9 +83,9 @@ protected function registerServices() }); $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { $activator = $app['config']->get('modules.activator'); - $class = $app['config']->get('modules.activators.' . $activator)['class']; + $class = $app['config']->get('modules.activators.'.$activator)['class']; - if ($class === NULL) { + if ($class === null) { throw InvalidActivatorClass::missingConfig(); } @@ -91,12 +96,11 @@ protected function registerServices() protected function registerMigrations(): void { - if (! $this->app['config']->get('modules.auto-discover.migrations', TRUE)) { + if (! $this->app['config']->get('modules.auto-discover.migrations', true)) { return; } $this->app->resolving(Migrator::class, function (Migrator $migrator) { - $path = implode(DIRECTORY_SEPARATOR, [ $this->app['config']->get('modules.paths.modules'), '*', @@ -109,6 +113,18 @@ protected function registerMigrations(): void $migrator->path($path); }); }); + } + private function registerEvents(): void + { + Event::listen( + [ + 'modules.*.'.ModuleEvent::DELETED, + 'modules.*.'.ModuleEvent::CREATED, + 'modules.*.'.ModuleEvent::DISABLED, + 'modules.*.'.ModuleEvent::ENABLED, + ], + fn () => Artisan::call('module:clear-compiled') + ); } } From ed8f8dcb780d73e90d707ae8606dbdcdbdaf2b85 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sun, 11 Aug 2024 23:37:21 +0330 Subject: [PATCH 409/422] [test] add test for command 'module:discover' and 'module:clear-compiled' --- .../Actions/ClearCompiledCommandTest.php | 82 ++++++++++++++++++ .../Actions/ModuleDiscoverCommandTest.php | 84 +++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/Commands/Actions/ClearCompiledCommandTest.php create mode 100644 tests/Commands/Actions/ModuleDiscoverCommandTest.php diff --git a/tests/Commands/Actions/ClearCompiledCommandTest.php b/tests/Commands/Actions/ClearCompiledCommandTest.php new file mode 100644 index 000000000..1f141cd2a --- /dev/null +++ b/tests/Commands/Actions/ClearCompiledCommandTest.php @@ -0,0 +1,82 @@ +finder = $this->app['files']; + $this->manifestPath = app()->make(ModuleManifest::class)->manifestPath; + $this->repository = $this->app[RepositoryInterface::class]; + } + + public function tearDown(): void + { + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + parent::tearDown(); + } + + public function test_manifest_file_clear_when_call_command() + { + $this->createModule(); + $code = $this->artisan('module:clear-compiled'); + + $this->assertFileDoesNotExist($this->manifestPath); + $this->assertSame(0, $code); + } + + public function test_manifest_file_clear_when_create_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->assertFileDoesNotExist($this->manifestPath); + } + + public function test_manifest_file_clear_when_delete_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->artisan('module:delete', ['module' => 'Foo', '--force' => true]); + + $this->assertFileDoesNotExist($this->manifestPath); + } + + public function test_manifest_file_clear_when_disable_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->artisan('module:disable', ['module' => 'Foo']); + + $this->assertFileDoesNotExist($this->manifestPath); + } + + public function test_manifest_file_clear_when_enable_module() + { + $this->assertFileExists($this->manifestPath); + + $this->createModule('Foo'); + + $this->artisan('module:enable', ['module' => 'Foo']); + + $this->assertFileDoesNotExist($this->manifestPath); + } +} diff --git a/tests/Commands/Actions/ModuleDiscoverCommandTest.php b/tests/Commands/Actions/ModuleDiscoverCommandTest.php new file mode 100644 index 000000000..f0f0a4a7e --- /dev/null +++ b/tests/Commands/Actions/ModuleDiscoverCommandTest.php @@ -0,0 +1,84 @@ +finder = $this->app['files']; + $this->manifestPath = app()->make(ModuleManifest::class)->manifestPath; + $this->repository = $this->app[RepositoryInterface::class]; + } + + public function tearDown(): void + { + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + parent::tearDown(); + } + + public function test_run_command_without_error() + { + $this->createModule(); + + $code = $this->artisan('module:discover'); + + $this->assertSame(0, $code); + } + + public function test_manifest_file_contain_new_module_provider() + { + $this->createModule('Foo'); + + $path = base_path('modules/Foo').'/module.json'; + $provider = json_decode($this->finder->get($path))->providers[0]; + + $code = $this->artisan('module:discover'); + $this->assertSame(0, $code); + + $manifest = require $this->manifestPath; + + $this->assertContains($provider, $manifest['providers'], 'provider not found in manifest file'); + $this->assertContains($provider, $manifest['eager'], 'provider not found in manifest file'); + } + + public function test_manifest_file_contain_multi_module_provider() + { + $modules = [ + 'Foo', + 'Bar', + 'Baz', + ]; + + foreach ($modules as $module) { + $this->createModule($module); + } + + $code = $this->artisan('module:discover'); + $this->assertSame(0, $code); + + $manifest = require $this->manifestPath; + + foreach ($modules as $module) { + $path = module_path($module).'/module.json'; + $provider = json_decode($this->finder->get($path))->providers[0]; + + $this->assertContains($provider, $manifest['providers'], 'provider not found in manifest file'); + $this->assertContains($provider, $manifest['eager'], 'provider not found in manifest file'); + } + } + + +} From 041da93149d8a0721e50bbae7fcee42a59fbdf6f Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 12 Aug 2024 00:09:09 +0330 Subject: [PATCH 410/422] [fix] fix output buffer on listener --- src/LaravelModulesServiceProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index 15de56602..1fd804373 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -12,6 +12,7 @@ use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; use Nwidart\Modules\Support\Stub; +use Symfony\Component\Console\Output\NullOutput; class LaravelModulesServiceProvider extends ModulesServiceProvider { @@ -124,7 +125,7 @@ private function registerEvents(): void 'modules.*.'.ModuleEvent::DISABLED, 'modules.*.'.ModuleEvent::ENABLED, ], - fn () => Artisan::call('module:clear-compiled') + fn () => Artisan::call('module:clear-compiled', outputBuffer: new NullOutput) ); } } From 2153c43c7ab3fde76f763059592ecb2890554701 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 12 Aug 2024 00:16:39 +0330 Subject: [PATCH 411/422] [test] fix test, delete all module after each test --- tests/Commands/Make/ModuleMakeCommandTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index 773bf8081..364483391 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -46,10 +46,8 @@ public function setUp(): void public function tearDown(): void { - $this->finder->deleteDirectory($this->modulePath); - if ($this->finder->isDirectory(base_path('modules/ModuleName'))) { - $this->finder->deleteDirectory(base_path('modules/ModuleName')); - } + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + $this->activator->reset(); parent::tearDown(); } From 4f3ca4120f78585e61a7dbe697ebce679990f0fb Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 12 Aug 2024 00:30:00 +0330 Subject: [PATCH 412/422] [test] fix test create modeule with flag force --- tests/Commands/Make/ModuleMakeCommandTest.php | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index 364483391..6a1a1e811 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -226,16 +226,15 @@ public function test_it_outputs_error_when_module_exists() public function test_it_still_generates_module_if_it_exists_using_force_flag() { + Event::fake(); + $this->artisan('module:make', ['name' => ['Blog']]); $code = $this->artisan('module:make', ['name' => ['Blog'], '--force' => true]); - - $output = Artisan::output(); - - $notExpected = 'Module [Blog] already exist! -'; - $this->assertNotEquals($notExpected, $output); - $this->assertTrue(Str::contains($output, 'Module [Blog] created successfully.')); $this->assertSame(0, $code); + + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETING, strtolower('Blog'))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::DELETED, strtolower('Blog'))); + Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower('Blog'))); } public function test_it_can_generate_module_with_old_config_format() @@ -301,10 +300,15 @@ public function test_it_can_ignore_some_folders_to_generate_with_new_format() public function test_it_can_ignore_resource_folders_to_generate() { - $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false]); + $this->app['config']->set('modules.paths.generator.seeder', ['path' => 'Database/Seeders', 'generate' => false] + ); $this->app['config']->set('modules.paths.generator.provider', ['path' => 'Providers', 'generate' => false]); - $this->app['config']->set('modules.paths.generator.route-provider', ['path' => 'Providers', 'generate' => false]); - $this->app['config']->set('modules.paths.generator.controller', ['path' => 'Http/Controllers', 'generate' => false]); + $this->app['config']->set('modules.paths.generator.route-provider', ['path' => 'Providers', 'generate' => false] + ); + $this->app['config']->set( + 'modules.paths.generator.controller', + ['path' => 'Http/Controllers', 'generate' => false] + ); $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -473,7 +477,15 @@ public function test_it_generate_module_when_provider_is_disable_and_route_provi public function test_it_can_set_author_details() { - $code = $this->artisan('module:make', ['name' => ['Blog'], '--author-name' => 'Joe Blogs', '--author-email' => 'user@domain.com', '--author-vendor' => 'JoeBlogs']); + $code = $this->artisan( + 'module:make', + [ + 'name' => ['Blog'], + '--author-name' => 'Joe Blogs', + '--author-email' => 'user@domain.com', + '--author-vendor' => 'JoeBlogs' + ] + ); $content = $this->finder->get($this->getModuleBasePath().'/composer.json'); @@ -515,6 +527,5 @@ public function test_it_fires_events_when_multi_module_created() Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATING, strtolower($module))); Event::assertDispatched(sprintf('modules.%s.'.ModuleEvent::CREATED, strtolower($module))); } - } } From 8b03c5e7636451464f869834198639986c0efd31 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Mon, 12 Aug 2024 23:26:25 +0330 Subject: [PATCH 413/422] [feat] add default migration path, and call before run module commands --- src/Commands/Database/MigrateFreshCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/Database/MigrateFreshCommand.php b/src/Commands/Database/MigrateFreshCommand.php index 94940b8aa..24a3c4639 100644 --- a/src/Commands/Database/MigrateFreshCommand.php +++ b/src/Commands/Database/MigrateFreshCommand.php @@ -55,6 +55,7 @@ public function handle(): void // run migration of root $root_paths = $this->migration_paths + ->push($this->laravel->databasePath().DIRECTORY_SEPARATOR.'migrations') ->reject(fn (string $path) => str_starts_with($path, config('modules.paths.modules'))); if ($root_paths->count() > 0) { From ef6b3ba13970e02712fab4256478d0ce86306fa0 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 13 Aug 2024 01:13:17 +0330 Subject: [PATCH 414/422] [feat] add auto register lang files --- config/config.php | 10 +++++++++ src/LaravelModulesServiceProvider.php | 31 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/config/config.php b/config/config.php index d7228eaef..c233e1329 100644 --- a/config/config.php +++ b/config/config.php @@ -188,6 +188,16 @@ */ 'migrations' => true, + /* + |-------------------------------------------------------------------------- + | Translations + |-------------------------------------------------------------------------- + | + | This option for register lang file automatically. + | + */ + 'translations' => false, + ], /* diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index 1fd804373..c65c97c45 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -3,11 +3,13 @@ namespace Nwidart\Modules; use Composer\InstalledVersions; +use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Illuminate\Database\Migrations\Migrator; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Console\AboutCommand; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Event; +use Illuminate\Translation\Translator; use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; @@ -51,6 +53,7 @@ public function register() $this->registerProviders(); $this->registerMigrations(); + $this->registerTransactions(); $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules'); } @@ -116,6 +119,34 @@ protected function registerMigrations(): void }); } + protected function registerTransactions(): void + { + if (! $this->app['config']->get('modules.auto-discover.translations', true)) { + return; + } + + $this->callAfterResolving('translator', function (TranslatorContract $translator) { + if (! $translator instanceof Translator) { + return; + } + + $path = implode(DIRECTORY_SEPARATOR, [ + $this->app['config']->get('modules.paths.modules'), + '*', + 'lang', + ]); + + collect(glob($path, GLOB_ONLYDIR)) + ->each(function (string $path) use ($translator) { + preg_match('/Modules\/([^\/]+)/', $path, $matches); + + $translator->addNamespace(strtolower($matches[1]), $path); + $translator->addJsonPath($path); + }); + }); + } + + private function registerEvents(): void { Event::listen( From 7092f06cee637eea279018c67631cca058c1e855 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Tue, 13 Aug 2024 01:47:29 +0330 Subject: [PATCH 415/422] [fix] fix regex of , get module name --- src/LaravelModulesServiceProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index c65c97c45..db8d27274 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -124,7 +124,6 @@ protected function registerTransactions(): void if (! $this->app['config']->get('modules.auto-discover.translations', true)) { return; } - $this->callAfterResolving('translator', function (TranslatorContract $translator) { if (! $translator instanceof Translator) { return; @@ -138,8 +137,7 @@ protected function registerTransactions(): void collect(glob($path, GLOB_ONLYDIR)) ->each(function (string $path) use ($translator) { - preg_match('/Modules\/([^\/]+)/', $path, $matches); - + preg_match('/\/([^\/]+)\/lang/', $path, $matches); $translator->addNamespace(strtolower($matches[1]), $path); $translator->addJsonPath($path); }); From 822ed106ea4ecd1eed49652e570714ed4f081f62 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 15 Aug 2024 16:12:57 +0330 Subject: [PATCH 416/422] [fix] prevent duplicate read from file --- src/Json.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Json.php b/src/Json.php index ff1d1a0cd..357eff2e7 100644 --- a/src/Json.php +++ b/src/Json.php @@ -136,7 +136,7 @@ public function decodeContents() */ public function getAttributes() { - return $this->decodeContents(); + return $this->attributes ?? $this->decodeContents(); } /** From 018fc88e3912086e9da685c81c0bdfae661ed9e3 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 15 Aug 2024 16:15:11 +0330 Subject: [PATCH 417/422] [fix] fix dispatch event create when create duplicate module --- src/Generators/ModuleGenerator.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index 2cf399bb3..8d4c70979 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -278,8 +278,6 @@ public function generate(): int { $name = $this->getName(); - Event::dispatch(sprintf('modules.%s.%s', strtolower($name), ModuleEvent::CREATING)); - if ($this->module->has($name)) { if ($this->force) { $this->module->delete($name); @@ -289,6 +287,9 @@ public function generate(): int return E_ERROR; } } + + Event::dispatch(sprintf('modules.%s.%s', strtolower($name), ModuleEvent::CREATING)); + $this->component->info("Creating module: [$name]"); $this->generateFolders(); From 8cbe2939c516fa014fb9fc15b884200e36aa489a Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 15 Aug 2024 16:18:57 +0330 Subject: [PATCH 418/422] [Perf] change logic of FileRepository to improve performance --- src/FileRepository.php | 41 ++++++++++++++++++++--------- src/Traits/CanClearModulesCache.php | 2 ++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/FileRepository.php b/src/FileRepository.php index 5a0ae7991..d62f944bf 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -67,6 +67,8 @@ abstract class FileRepository implements Countable, RepositoryInterface */ private $cache; + private static $modules = []; + /** * The constructor. * @@ -140,6 +142,10 @@ abstract protected function createModule(...$args); */ public function scan() { + if (! empty(self::$modules) && ! $this->app->runningUnitTests()) { + return self::$modules; + } + $paths = $this->getScanPaths(); $modules = []; @@ -150,13 +156,16 @@ public function scan() is_array($manifests) || $manifests = []; foreach ($manifests as $manifest) { - $name = Json::make($manifest)->get('name'); + $json = Json::make($manifest); + $name = $json->get('name'); - $modules[$name] = $this->createModule($this->app, $name, dirname($manifest)); + $modules[strtolower($name)] = $this->createModule($this->app, $name, dirname($manifest)); } } - return $modules; + self::$modules = $modules; + + return self::$modules; } /** @@ -197,9 +206,13 @@ protected function formatCached($cached) */ public function getCached() { - return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { - return $this->toCollection()->toArray(); - }); + return $this->cache->store($this->config->get('modules.cache.driver'))->remember( + key: $this->config('cache.key'), + ttl: $this->config('cache.lifetime'), + callback: function () { + return $this->toCollection()->toArray(); + } + ); } /** @@ -232,7 +245,7 @@ public function getByStatus($status): array */ public function has($name): bool { - return array_key_exists($name, $this->all()); + return array_key_exists(strtolower($name), $this->all()); } /** @@ -316,12 +329,7 @@ public function boot(): void */ public function find(string $name) { - foreach ($this->all() as $module) { - if ($module->getLowerName() === strtolower($name)) { - return $module; - } - } - + return $this->all()[strtolower($name)] ?? null; } /** @@ -578,4 +586,11 @@ public function setStubPath($stubPath) return $this; } + + public function resetModules(): static + { + self::$modules = []; + + return $this; + } } diff --git a/src/Traits/CanClearModulesCache.php b/src/Traits/CanClearModulesCache.php index 52c9db5a4..b6ea2e499 100644 --- a/src/Traits/CanClearModulesCache.php +++ b/src/Traits/CanClearModulesCache.php @@ -12,5 +12,7 @@ public function clearCache() if (config('modules.cache.enabled') === true) { app('cache')->forget(config('modules.cache.key')); } + + $this->laravel['modules']->resetModules(); } } From e0404586ad9980bd12f01f7f9f81b8a908b2e65f Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Thu, 15 Aug 2024 16:19:22 +0330 Subject: [PATCH 419/422] [test] fix test --- tests/Commands/Actions/ModuleDeleteCommandTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Commands/Actions/ModuleDeleteCommandTest.php b/tests/Commands/Actions/ModuleDeleteCommandTest.php index faba96e00..59bca661b 100644 --- a/tests/Commands/Actions/ModuleDeleteCommandTest.php +++ b/tests/Commands/Actions/ModuleDeleteCommandTest.php @@ -30,6 +30,14 @@ public function setUp(): void $this->activator = new FileActivator($this->app); } + public function tearDown(): void + { + $this->artisan('module:delete', ['--all' => true, '--force' => true]); + + $this->activator->reset(); + parent::tearDown(); + } + public function test_it_can_delete_a_module_from_disk(): void { $this->artisan('module:make', ['name' => ['WrongModule']]); From a7e64353516d0fc6b5ee8c8bc3f76ceb09fe7231 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 17 Aug 2024 20:10:57 +0100 Subject: [PATCH 420/422] Revert "Merge pull request #1898 from solomon-ochepa/optiomize-file-repository" This reverts commit ecea05a0cb492141c1796f11d0abb8eed3414052, reversing changes made to fa92a63394f542d464e726dea8945c9326784971. --- src/Contracts/RepositoryInterface.php | 171 ++++---- src/FileRepository.php | 570 +++++++++++--------------- src/Laravel/LaravelFileRepository.php | 2 +- src/Lumen/LumenFileRepository.php | 2 +- 4 files changed, 306 insertions(+), 439 deletions(-) diff --git a/src/Contracts/RepositoryInterface.php b/src/Contracts/RepositoryInterface.php index f7331bbfc..3741dbeee 100644 --- a/src/Contracts/RepositoryInterface.php +++ b/src/Contracts/RepositoryInterface.php @@ -2,176 +2,151 @@ namespace Nwidart\Modules\Contracts; -use Illuminate\Filesystem\Filesystem; -use Nwidart\Modules\Collection; use Nwidart\Modules\Exceptions\ModuleNotFoundException; use Nwidart\Modules\Module; interface RepositoryInterface { - /** - * Boot the modules. - */ - public function boot(): void; - - /** - * Register the modules. - */ - public function register(): void; - /** * Get all modules. + * + * @return mixed */ - public function all(): array; + public function all(); /** - * @deprecated 10.0.11 use all(true) or status(true) + * Get cached modules. + * + * @return array */ - public function allEnabled(): array; + public function getCached(); /** - * @deprecated 10.0.11 use all(false) or status(false) + * Scan & get all available modules. + * + * @return array */ - public function allDisabled(): array; + public function scan(); /** - * Find a specific module. + * Get modules as modules collection instance. + * + * @return \Nwidart\Modules\Collection */ - public function find(string $name): ?Module; + public function toCollection(); /** - * Find a specific module. If there return that, otherwise throw exception. + * Get scanned paths. + * + * @return array */ - public function findOrFail(string $name): Module; + public function getScanPaths(); /** - * Get modules by active status [true|false]. + * Get list of enabled modules. + * + * @return mixed */ - public function status(bool $status): array; + public function allEnabled(); /** - * @deprecated 10.0.11 use status() + * Get list of disabled modules. + * + * @return mixed */ - public function getByStatus(int $status): array; + public function allDisabled(); /** - * Scan & get all available modules. + * Get count from all modules. + * + * @return int */ - public function scan(): array; + public function count(); /** - * Get scanned modules paths. + * Get all ordered modules. + * + * @param string $direction + * @return mixed */ - public function scanPaths(): array; + public function getOrdered($direction = 'asc'); /** - * @deprecated 10.0.11 use scanPaths() + * Get modules by the given status. + * + * @param int $status + * @return mixed */ - public function getScanPaths(): array; + public function getByStatus($status); /** - * Get cached modules. + * Find a specific module. + * + * @return Module|null */ - public function cached(): array; + public function find(string $name); /** - * @deprecated 10.0.11 use cached() + * Find a specific module. If there return that, otherwise throw exception. + * + * + * @return mixed */ - public function getCached(): array; + public function findOrFail(string $name); - /** - * Get all modules as collection instance. - */ - public function toCollection(): Collection; + public function getModulePath($moduleName); /** - * Get all ordered modules. + * @return \Illuminate\Filesystem\Filesystem */ - public function ordered(string $sort = 'asc'): array; + public function getFiles(); /** - * @deprecated 10.0.11 use ordered() + * Get a specific config data from a configuration file. + * + * @param string|null $default + * @return mixed */ - public function getOrdered(string $direction = 'asc'): array; + public function config(string $key, $default = null); /** - * Delete a specific module. - * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + * Get a module path. */ - public function delete(string $module): bool; + public function getPath(): string; /** - * Get a specific config data from a configuration file. + * Boot the modules. */ - public function config(string $key, ?string $default = null): mixed; + public function boot(): void; /** - * Get count from all modules. + * Register the modules. */ - public function count(): int; + public function register(): void; /** - * Determine whether the given module exist. + * Get asset path for a specific module. */ - public function has(string $name): bool; + public function assetPath(string $module): string; /** - * Determine if the given module is enabled. + * Delete a specific module. * - * @throws ModuleNotFoundException + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function enabled(string $name): bool; + public function delete(string $module): bool; /** - * @deprecated 10.0.11 use enabled() + * Determine whether the given module is activated. + * + * @throws ModuleNotFoundException */ public function isEnabled(string $name): bool; /** - * Determine if the given module is disabled. + * Determine whether the given module is not activated. * * @throws ModuleNotFoundException */ - public function disabled(string $name): bool; - - /** - * @deprecated 10.0.11 use disabled() - */ public function isDisabled(string $name): bool; - - /** - * Get laravel filesystem instance. - */ - public function files(): Filesystem; - - /** - * @deprecated 10.0.11 use files() - */ - public function getFiles(): Filesystem; - - /** - * Get a module path. - */ - public function path(): string; - - /** - * @deprecated 10.0.11 use path() - */ - public function getPath(): string; - - /** - * Get module path for a specific module. - */ - public function modulePath($moduleName): string; - - /** - * @deprecated 10.0.11 use modulePath() - */ - public function getModulePath($moduleName): string; - - /** - * Get asset path for a specific module. - */ - public function assetPath(string $module): string; } diff --git a/src/FileRepository.php b/src/FileRepository.php index e9946a0fe..5a0ae7991 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -16,7 +16,6 @@ use Nwidart\Modules\Exceptions\ModuleNotFoundException; use Nwidart\Modules\Process\Installer; use Nwidart\Modules\Process\Updater; -use Symfony\Component\Process\Process; abstract class FileRepository implements Countable, RepositoryInterface { @@ -70,8 +69,10 @@ abstract class FileRepository implements Countable, RepositoryInterface /** * The constructor. + * + * @param string|null $path */ - public function __construct(Container $app, ?string $path = null) + public function __construct(Container $app, $path = null) { $this->app = $app; $this->path = $path; @@ -82,159 +83,76 @@ public function __construct(Container $app, ?string $path = null) } /** - * {@inheritDoc} - */ - public function boot(): void - { - foreach ($this->ordered() as $module) { - $module->boot(); - } - } - - /** - * {@inheritDoc} - */ - public function register(): void - { - foreach ($this->ordered() as $module) { - $module->register(); - } - } - - /** - * Creates a new Module instance + * Add other module location. * - * @param Container $app - * @param string $args * @param string $path + * @return $this */ - abstract protected function module(...$args): Module; - - /** - * @deprecated 10.0.11 use module() - */ - protected function createModule(...$args) - { - return $this->module(...$args); - } - - /** - * Install the specified module. - */ - public function install(string $name, string $version = 'dev-master', string $type = 'composer', bool $subtree = false): Process + public function addLocation($path) { - $installer = new Installer($name, $version, $type, $subtree); - - return $installer->run(); - } - - /** - * {@inheritDoc} - */ - public function all(?bool $enabled = null): array - { - if (is_bool($enabled)) { - if ($enabled) { - return $this->status(true); - } - - return $this->status(false); - } - - if (!$this->config('cache.enabled')) { - return $this->scan(); - } + $this->paths[] = $path; - return $this->formatCached($this->cached()); + return $this; } /** - * @deprecated 10.0.11 use all(true) or status(true) + * Get all additional paths. */ - public function allEnabled(): array + public function getPaths(): array { - return $this->status(true); + return $this->paths; } /** - * @deprecated 10.0.11 use all(false) or status(false) + * Get scanned modules paths. */ - public function allDisabled(): array - { - return $this->status(false); - } - - /** - * {@inheritDoc} - */ - public function find(string $name): ?Module + public function getScanPaths(): array { - foreach ($this->all() as $module) { - if ($module->getLowerName() === strtolower($name)) { - return $module; - } - } - - return null; - } + $paths = $this->paths; - /** - * {@inheritDoc} - */ - public function findOrFail(string $name): Module - { - $module = $this->find($name); + $paths[] = $this->getPath(); - if ($module !== null) { - return $module; + if ($this->config('scan.enabled')) { + $paths = array_merge($paths, $this->config('scan.paths')); } - throw new ModuleNotFoundException("Module [{$name}] does not exist!"); - } - - /** - * Get modules by the given status. - */ - public function status(bool $status): array - { - $modules = []; - - /** @var Module $module */ - foreach ($this->all() as $name => $module) { - if ($module->isStatus($status)) { - $modules[$name] = $module; - } - } + $paths = array_map(function ($path) { + return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); + }, $paths); - return $modules; + return $paths; } /** - * @deprecated 10.0.11 use status() + * Creates a new Module instance + * + * @param Container $app + * @param string $args + * @param string $path + * @return \Nwidart\Modules\Module */ - public function getByStatus($status): array - { - return $this->status($status); - } + abstract protected function createModule(...$args); /** - * {@inheritDoc} + * Get & scan all modules. + * + * @return array */ - public function scan(): array + public function scan() { - $paths = $this->scanPaths(); + $paths = $this->getScanPaths(); $modules = []; foreach ($paths as $key => $path) { - $manifests = $this->files()->glob("{$path}/module.json"); + $manifests = $this->getFiles()->glob("{$path}/module.json"); is_array($manifests) || $manifests = []; foreach ($manifests as $manifest) { $name = Json::make($manifest)->get('name'); - $modules[$name] = $this->module($this->app, $name, dirname($manifest)); + $modules[$name] = $this->createModule($this->app, $name, dirname($manifest)); } } @@ -242,37 +160,42 @@ public function scan(): array } /** - * {@inheritDoc} + * Get all modules. */ - public function scanPaths(): array + public function all(): array { - $paths = $this->paths; - - $paths[] = $this->path(); - - if ($this->config('scan.enabled')) { - $paths = array_merge($paths, $this->config('scan.paths')); + if (! $this->config('cache.enabled')) { + return $this->scan(); } - $paths = array_map(function ($path) { - return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); - }, $paths); - - return $paths; + return $this->formatCached($this->getCached()); } /** - * @deprecated 10.0.11 use scanPaths() + * Format the cached data as array of modules. + * + * @param array $cached + * @return array */ - public function getScanPaths(): array + protected function formatCached($cached) { - return $this->scanPaths(); + $modules = []; + + foreach ($cached as $name => $module) { + $path = $module['path']; + + $modules[$name] = $this->createModule($this->app, $name, $path); + } + + return $modules; } /** - * {@inheritDoc} + * Get cached modules. + * + * @return array */ - public function cached(): array + public function getCached() { return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { return $this->toCollection()->toArray(); @@ -280,66 +203,77 @@ public function cached(): array } /** - * @deprecated 10.0.11 use cached() + * Get all modules as collection instance. */ - public function getCached(): array + public function toCollection(): Collection { - return $this->cached(); + return new Collection($this->scan()); } /** - * Format the cached data as array of modules. + * Get modules by status. */ - protected function formatCached(array $cached): array + public function getByStatus($status): array { $modules = []; - foreach ($cached as $name => $module) { - $path = $module['path']; - - $modules[$name] = $this->module($this->app, $name, $path); + /** @var Module $module */ + foreach ($this->all() as $name => $module) { + if ($module->isStatus($status)) { + $modules[$name] = $module; + } } return $modules; } /** - * {@inheritDoc} + * Determine whether the given module exist. */ - public function toCollection(): Collection + public function has($name): bool { - return new Collection($this->scan()); + return array_key_exists($name, $this->all()); } /** - * Get all modules as laravel collection instance. + * Get list of enabled modules. */ - public function collect(?bool $status = true): Collection + public function allEnabled(): array { - return new Collection($this->all((bool) $status)); + return $this->getByStatus(true); } /** - * Get all modules as laravel collection instance. + * Get list of disabled modules. */ - public function collections(?bool $status = true): Collection + public function allDisabled(): array { - return new Collection($this->all((bool) $status)); + return $this->getByStatus(false); } /** - * {@inheritDoc} + * Get count from all modules. */ - public function ordered(string $sort = 'asc'): array + public function count(): int { - $modules = $this->all(true); + return count($this->all()); + } - uasort($modules, function (Module $a, Module $b) use ($sort) { + /** + * Get all ordered modules. + * + * @param string $direction + */ + public function getOrdered($direction = 'asc'): array + { + $modules = $this->allEnabled(); + + uasort($modules, function (Module $a, Module $b) use ($direction) { if ($a->get('priority') === $b->get('priority')) { return 0; } - if ($sort === 'desc') { + if ($direction === 'desc') { return $a->get('priority') < $b->get('priority') ? 1 : -1; } @@ -350,244 +284,185 @@ public function ordered(string $sort = 'asc'): array } /** - * @deprecated 10.0.11 use ordered() - */ - public function getOrdered(string $direction = 'asc'): array - { - return $this->ordered($direction); - } - - /** - * Update dependencies for the specified module. + * {@inheritDoc} */ - public function update(string $module): void + public function getPath(): string { - with(new Updater($this))->update($module); + return $this->path ?: $this->config('paths.modules', base_path('Modules')); } /** * {@inheritDoc} */ - public function delete(string $name): bool + public function register(): void { - return $this->findOrFail($name)->delete(); + foreach ($this->getOrdered() as $module) { + $module->register(); + } } /** * {@inheritDoc} */ - public function config(string $key, ?string $default = null): mixed + public function boot(): void { - return $this->config->get('modules.' . $key, $default); + foreach ($this->getOrdered() as $module) { + $module->boot(); + } } /** * {@inheritDoc} */ - public function count(?bool $enabled = null): int + public function find(string $name) { - if (is_bool($enabled)) { - if ($enabled) { - return count($this->all(true)); + foreach ($this->all() as $module) { + if ($module->getLowerName() === strtolower($name)) { + return $module; } - - return count($this->all(false)); } - return count($this->all()); - } - - /** - * {@inheritDoc} - */ - public function has(string $name): bool - { - return array_key_exists($name, $this->all()); } /** - * Enabling a specific module. + * Find a specific module, if there return that, otherwise throw exception. * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException - */ - public function enable(string $name): void - { - $this->findOrFail($name)->enable(); - } - - /** - * {@inheritDoc} - */ - public function enabled(string $name): bool - { - return $this->findOrFail($name)->isEnabled(); - } - - /** - * @deprecated 10.0.11 use enabled() - */ - public function isEnabled(string $name): bool - { - return $this->enabled($name); - } - - /** - * Disabling a specific module. * - * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException + * @return Module + * + * @throws ModuleNotFoundException */ - public function disable(string $name): void + public function findOrFail(string $name) { - $this->findOrFail($name)->disable(); - } + $module = $this->find($name); - /** - * {@inheritDoc} - */ - public function disabled(string $name): bool - { - return !$this->enabled($name); - } + if ($module !== null) { + return $module; + } - /** - * @deprecated 10.0.11 use disabled() - */ - public function isDisabled(string $name): bool - { - return $this->disabled($name); + throw new ModuleNotFoundException("Module [{$name}] does not exist!"); } /** - * {@inheritDoc} + * Get all modules as laravel collection instance. */ - public function files(): Filesystem + public function collections($status = 1): Collection { - return $this->files; + return new Collection($this->getByStatus($status)); } /** - * @deprecated 10.0.11 use files() + * Get module path for a specific module. + * + * + * @return string */ - public function getFiles(): Filesystem + public function getModulePath($module) { - return $this->files(); + try { + return $this->findOrFail($module)->getPath().'/'; + } catch (ModuleNotFoundException $e) { + return $this->getPath().'/'.Str::studly($module).'/'; + } } /** * {@inheritDoc} */ - public function path(): string - { - return $this->path ?: $this->config('paths.modules', base_path('Modules')); - } - - /** - * @deprecated 10.0.11 use path() - */ - public function getPath(): string + public function assetPath(string $module): string { - return $this->path(); + return $this->config('paths.assets').'/'.$module; } /** - * Get all additional paths. + * {@inheritDoc} */ - public function extra_paths(): array + public function config(string $key, $default = null) { - return $this->paths; + return $this->config->get('modules.'.$key, $default); } /** - * @deprecated 10.0.11 use extra_paths() + * Get storage path for module used. */ - public function getPaths(): array + public function getUsedStoragePath(): string { - return $this->extra_paths(); - } + $directory = storage_path('app/modules'); + if ($this->getFiles()->exists($directory) === false) { + $this->getFiles()->makeDirectory($directory, 0777, true); + } - /** - * {@inheritDoc} - */ - public function modulePath($module): string - { - try { - return $this->findOrFail($module)->getPath() . '/'; - } catch (ModuleNotFoundException $e) { - return $this->path() . '/' . Str::studly($module) . '/'; + $path = storage_path('app/modules/modules.used'); + if (! $this->getFiles()->exists($path)) { + $this->getFiles()->put($path, ''); } - } - /** - * @deprecated 10.0.11 use modulePath() - */ - public function getModulePath($module): string - { - return $this->modulePath($module); + return $path; } /** - * Add extra module path. + * Set module used for cli session. + * + * + * @throws ModuleNotFoundException */ - public function add_path(string $path): self + public function setUsed($name) { - $this->paths[] = $path; + $module = $this->findOrFail($name); - return $this; + $this->getFiles()->put($this->getUsedStoragePath(), $module); + + $module->fireEvent(ModuleEvent::USED); } /** - * @deprecated 10.0.11 use add_path($path) + * Forget the module used for cli session. */ - public function addLocation(string $path): self + public function forgetUsed() { - return $this->add_path($path); + if ($this->getFiles()->exists($this->getUsedStoragePath())) { + $this->getFiles()->delete($this->getUsedStoragePath()); + } } /** - * Get stub path. + * Get module used for cli session. + * + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function stubPath(): ?string + public function getUsedNow(): string { - if ($this->stubPath !== null) { - return $this->stubPath; - } - - if ($this->config('stubs.enabled') === true) { - return $this->config('stubs.path'); - } - - return $this->stubPath; + return $this->findOrFail($this->getFiles()->get($this->getUsedStoragePath())); } /** - * @deprecated 10.0.11 use stubPath() + * Get laravel filesystem instance. */ - public function getStubPath(): ?string + public function getFiles(): Filesystem { - return $this->stubPath(); + return $this->files; } /** - * Set stub path. + * Get module assets path. */ - public function setStubPath(string $stubPath): self + public function getAssetsPath(): string { - $this->stubPath = $stubPath; - - return $this; + return $this->config('paths.assets'); } /** * Get asset url from a specific module. * + * @param string $asset + * * @throws InvalidAssetPath */ - public function asset(string $asset): string + public function asset($asset): string { if (Str::contains($asset, ':') === false) { throw InvalidAssetPath::missingModuleName($asset); } - [$name, $url] = explode(':', $asset); $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath()); @@ -600,90 +475,107 @@ public function asset(string $asset): string /** * {@inheritDoc} */ - public function assetPath(string $module): string + public function isEnabled(string $name): bool { - return $this->config('paths.assets') . '/' . $module; + return $this->findOrFail($name)->isEnabled(); } /** - * Get module assets path. + * {@inheritDoc} */ - public function getAssetsPath(): string + public function isDisabled(string $name): bool { - return $this->config('paths.assets'); + return ! $this->isEnabled($name); } /** - * Get module used for cli session. + * Enabling a specific module. + * + * @param string $name + * @return void * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function used(): string + public function enable($name) { - return $this->findOrFail($this->files()->get($this->usedStoragePath())); + $this->findOrFail($name)->enable(); } /** - * @deprecated 10.0.11 use used() + * Disabling a specific module. + * + * @param string $name + * @return void + * + * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function getUsedNow(): string + public function disable($name) { - return $this->used(); + $this->findOrFail($name)->disable(); } /** - * Set module used for cli session. - * - * @throws ModuleNotFoundException + * {@inheritDoc} */ - public function use($name) + public function delete(string $name): bool { - $module = $this->findOrFail($name); - - $this->files()->put($this->usedStoragePath(), $module); + return $this->findOrFail($name)->delete(); } /** - * @deprecated 10.0.11 use use($name) + * Update dependencies for the specified module. + * + * @param string $module */ - public function setUsed($name) + public function update($module) { - $this->use($name); + with(new Updater($this))->update($module); } /** - * Get storage path for module used. + * Install the specified module. + * + * @param string $name + * @param string $version + * @param string $type + * @param bool $subtree + * @return \Symfony\Component\Process\Process */ - public function usedStoragePath(): string + public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false) { - $directory = storage_path('app/modules'); - if ($this->files()->exists($directory) === false) { - $this->files()->makeDirectory($directory, 0777, true); - } - - $path = storage_path('app/modules/modules.used'); - if (!$this->files()->exists($path)) { - $this->files()->put($path, ''); - } + $installer = new Installer($name, $version, $type, $subtree); - return $path; + return $installer->run(); } /** - * @deprecated 10.0.11 use usedStoragePath() + * Get stub path. + * + * @return string|null */ - public function getUsedStoragePath(): string + public function getStubPath() { - return $this->usedStoragePath(); + if ($this->stubPath !== null) { + return $this->stubPath; + } + + if ($this->config('stubs.enabled') === true) { + return $this->config('stubs.path'); + } + + return $this->stubPath; } /** - * Forget the module used for cli session. + * Set stub path. + * + * @param string $stubPath + * @return $this */ - public function forgetUsed() + public function setStubPath($stubPath) { - if ($this->files()->exists($this->usedStoragePath())) { - $this->files()->delete($this->usedStoragePath()); - } + $this->stubPath = $stubPath; + + return $this; } } diff --git a/src/Laravel/LaravelFileRepository.php b/src/Laravel/LaravelFileRepository.php index 20455a303..600f298fd 100644 --- a/src/Laravel/LaravelFileRepository.php +++ b/src/Laravel/LaravelFileRepository.php @@ -9,7 +9,7 @@ class LaravelFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function module(...$args): Module + protected function createModule(...$args) { return new Module(...$args); } diff --git a/src/Lumen/LumenFileRepository.php b/src/Lumen/LumenFileRepository.php index 69dc095c9..de2b783f0 100644 --- a/src/Lumen/LumenFileRepository.php +++ b/src/Lumen/LumenFileRepository.php @@ -9,7 +9,7 @@ class LumenFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function module(...$args): Module + protected function createModule(...$args) { return new Module(...$args); } From b51e39ce8283b118349bcc8510205020a8539080 Mon Sep 17 00:00:00 2001 From: David Carr Date: Sat, 17 Aug 2024 20:16:44 +0100 Subject: [PATCH 421/422] Revert "Merge pull request #1920 from alissn/RegisterLangFiles" This reverts commit fa92a63394f542d464e726dea8945c9326784971, reversing changes made to 7079478f1606d2d56f31c96af8cb4b321eeac2de. --- config/config.php | 10 --------- src/LaravelModulesServiceProvider.php | 29 --------------------------- 2 files changed, 39 deletions(-) diff --git a/config/config.php b/config/config.php index c233e1329..d7228eaef 100644 --- a/config/config.php +++ b/config/config.php @@ -188,16 +188,6 @@ */ 'migrations' => true, - /* - |-------------------------------------------------------------------------- - | Translations - |-------------------------------------------------------------------------- - | - | This option for register lang file automatically. - | - */ - 'translations' => false, - ], /* diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index db8d27274..1fd804373 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -3,13 +3,11 @@ namespace Nwidart\Modules; use Composer\InstalledVersions; -use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Illuminate\Database\Migrations\Migrator; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Console\AboutCommand; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Event; -use Illuminate\Translation\Translator; use Nwidart\Modules\Constants\ModuleEvent; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Exceptions\InvalidActivatorClass; @@ -53,7 +51,6 @@ public function register() $this->registerProviders(); $this->registerMigrations(); - $this->registerTransactions(); $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules'); } @@ -119,32 +116,6 @@ protected function registerMigrations(): void }); } - protected function registerTransactions(): void - { - if (! $this->app['config']->get('modules.auto-discover.translations', true)) { - return; - } - $this->callAfterResolving('translator', function (TranslatorContract $translator) { - if (! $translator instanceof Translator) { - return; - } - - $path = implode(DIRECTORY_SEPARATOR, [ - $this->app['config']->get('modules.paths.modules'), - '*', - 'lang', - ]); - - collect(glob($path, GLOB_ONLYDIR)) - ->each(function (string $path) use ($translator) { - preg_match('/\/([^\/]+)\/lang/', $path, $matches); - $translator->addNamespace(strtolower($matches[1]), $path); - $translator->addJsonPath($path); - }); - }); - } - - private function registerEvents(): void { Event::listen( From d7f17015635d5dfa31ad4b61cf3747d361c06917 Mon Sep 17 00:00:00 2001 From: Ali Sasani Date: Sat, 17 Aug 2024 23:02:45 +0330 Subject: [PATCH 422/422] [feat] delete cache of module repository --- src/Contracts/RepositoryInterface.php | 7 ----- src/FileRepository.php | 41 +-------------------------- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/src/Contracts/RepositoryInterface.php b/src/Contracts/RepositoryInterface.php index 3741dbeee..37acd59bc 100644 --- a/src/Contracts/RepositoryInterface.php +++ b/src/Contracts/RepositoryInterface.php @@ -14,13 +14,6 @@ interface RepositoryInterface */ public function all(); - /** - * Get cached modules. - * - * @return array - */ - public function getCached(); - /** * Scan & get all available modules. * diff --git a/src/FileRepository.php b/src/FileRepository.php index d62f944bf..1adf5e704 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -173,46 +173,7 @@ public function scan() */ public function all(): array { - if (! $this->config('cache.enabled')) { - return $this->scan(); - } - - return $this->formatCached($this->getCached()); - } - - /** - * Format the cached data as array of modules. - * - * @param array $cached - * @return array - */ - protected function formatCached($cached) - { - $modules = []; - - foreach ($cached as $name => $module) { - $path = $module['path']; - - $modules[$name] = $this->createModule($this->app, $name, $path); - } - - return $modules; - } - - /** - * Get cached modules. - * - * @return array - */ - public function getCached() - { - return $this->cache->store($this->config->get('modules.cache.driver'))->remember( - key: $this->config('cache.key'), - ttl: $this->config('cache.lifetime'), - callback: function () { - return $this->toCollection()->toArray(); - } - ); + return $this->scan(); } /**