Skip to content

Commit

Permalink
Optimize console commands (#186)
Browse files Browse the repository at this point in the history
* Optimize console commands
  • Loading branch information
antonkomarev committed Dec 8, 2020
1 parent 0041b81 commit bc466e4
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 13 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,6 +4,13 @@ All notable changes to `laravel-love` will be documented in this file.

## [Unreleased]

## [8.7.1] - 2020-12-06

### Fixed

- ([#186]) Improve CLI application performance by replacing `$name` with `$defaultName` static property in commands
- ([#187]) Fixed inconsistency in method parameter names

## [8.7.0] - 2020-12-06

### Added
Expand Down Expand Up @@ -462,7 +469,8 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to

- Initial release

[Unreleased]: https://github.com/cybercog/laravel-love/compare/8.7.0...master
[Unreleased]: https://github.com/cybercog/laravel-love/compare/8.7.1...master
[8.7.1]: https://github.com/cybercog/laravel-love/compare/8.7.0...8.7.1
[8.7.0]: https://github.com/cybercog/laravel-love/compare/8.6.1...8.7.0
[8.6.1]: https://github.com/cybercog/laravel-love/compare/8.6.0...8.6.1
[8.6.0]: https://github.com/cybercog/laravel-love/compare/8.5.0...8.6.0
Expand Down Expand Up @@ -507,6 +515,8 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to
[1.1.1]: https://github.com/cybercog/laravel-love/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/cybercog/laravel-love/compare/1.0.0...1.1.0

[#187]: https://github.com/cybercog/laravel-love/pull/187
[#186]: https://github.com/cybercog/laravel-love/pull/186
[#185]: https://github.com/cybercog/laravel-love/pull/185
[#178]: https://github.com/cybercog/laravel-love/pull/178
[#177]: https://github.com/cybercog/laravel-love/pull/177
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/ReactionTypeAdd.php
Expand Up @@ -25,7 +25,7 @@ final class ReactionTypeAdd extends Command
*
* @var string
*/
protected $name = 'love:reaction-type-add';
protected static $defaultName = 'love:reaction-type-add';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/Recount.php
Expand Up @@ -30,7 +30,7 @@ final class Recount extends Command
*
* @var string
*/
protected $name = 'love:recount';
protected static $defaultName = 'love:recount';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/RegisterReactants.php
Expand Up @@ -27,7 +27,7 @@ final class RegisterReactants extends Command
*
* @var string
*/
protected $name = 'love:register-reactants';
protected static $defaultName = 'love:register-reactants';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/RegisterReacters.php
Expand Up @@ -27,7 +27,7 @@ final class RegisterReacters extends Command
*
* @var string
*/
protected $name = 'love:register-reacters';
protected static $defaultName = 'love:register-reacters';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/SetupReactable.php
Expand Up @@ -33,7 +33,7 @@ final class SetupReactable extends Command
*
* @var string
*/
protected $name = 'love:setup-reactable';
protected static $defaultName = 'love:setup-reactable';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/SetupReacterable.php
Expand Up @@ -33,7 +33,7 @@ final class SetupReacterable extends Command
*
* @var string
*/
protected $name = 'love:setup-reacterable';
protected static $defaultName = 'love:setup-reacterable';

/**
* The console command description.
Expand Down
8 changes: 5 additions & 3 deletions src/Console/Commands/UpgradeV5ToV6.php
Expand Up @@ -33,7 +33,7 @@ final class UpgradeV5ToV6 extends Command
*
* @var string
*/
protected $name = 'love:upgrade-v5-to-v6';
protected static $defaultName = 'love:upgrade-v5-to-v6';

/**
* The console command description.
Expand All @@ -57,9 +57,9 @@ public function __construct(Builder $queryBuilder)
/**
* Execute the console command.
*
* @return void
* @return int
*/
public function handle(): void
public function handle(): int
{
$this->dbMigrate();
$this->populateReactionTypes();
Expand All @@ -68,6 +68,8 @@ public function handle(): void
$this->populateReactions();
$this->dbCleanup();
$this->filesystemCleanup();

return 0;
}

private function dbMigrate(): void
Expand Down
8 changes: 5 additions & 3 deletions src/Console/Commands/UpgradeV7ToV8.php
Expand Up @@ -29,7 +29,7 @@ final class UpgradeV7ToV8 extends Command
*
* @var string
*/
protected $name = 'love:upgrade-v7-to-v8';
protected static $defaultName = 'love:upgrade-v7-to-v8';

/**
* The console command description.
Expand All @@ -41,9 +41,9 @@ final class UpgradeV7ToV8 extends Command
/**
* Execute the console command.
*
* @return void
* @return int
*/
public function handle(): void
public function handle(): int
{
$this->assertRequirements();
$this->warn('Started Laravel Love v7 to v8 upgrade process.');
Expand All @@ -52,6 +52,8 @@ public function handle(): void
$this->dbChangeReactantReactionCounters();
$this->dbChangeReactantReactionTotals();
$this->info('Completed Laravel Love v7 to v8 upgrade process.');

return 0;
}

private function assertRequirements(): void
Expand Down

0 comments on commit bc466e4

Please sign in to comment.