Skip to content

Commit

Permalink
Merge pull request nWidart#1720 from alissn/MergeCommands
Browse files Browse the repository at this point in the history
Command Synchronization and Alphabetical Sorting in ConsoleServiceProvider
  • Loading branch information
dcblogdev authored Jan 21, 2024
2 parents f6dc7ff + 69cebb1 commit 9e3170f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 107 deletions.
59 changes: 9 additions & 50 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Nwidart\Modules\Activators\FileActivator;
use Nwidart\Modules\Commands;
use Nwidart\Modules\Providers\ConsoleServiceProvider;

return [

Expand Down Expand Up @@ -144,57 +144,16 @@
|
| 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 simply comment them out.
| you can add them to except section. and can add own command to merge section.
|
*/
'commands' => [
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\InstallCommand::class,
Commands\LaravelModulesV6Migrator::class,
Commands\ListCommand::class,
Commands\ModuleDeleteCommand::class,
Commands\ModuleMakeCommand::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\ResourceMakeCommand::class,
Commands\RequestMakeCommand::class,
Commands\RuleMakeCommand::class,
Commands\RouteProviderMakeCommand::class,
Commands\PublishCommand::class,
Commands\PublishConfigurationCommand::class,
Commands\PublishMigrationCommand::class,
Commands\PublishTranslationCommand::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(),

/*
|--------------------------------------------------------------------------
Expand Down
118 changes: 61 additions & 57 deletions src/Providers/ConsoleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,72 @@

class ConsoleServiceProvider extends ServiceProvider
{
/**
* The available commands
* @var array
*/
protected $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\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,
];

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\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,
]);
}
}

0 comments on commit 9e3170f

Please sign in to comment.