diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 2276e311..d057360c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -14,13 +14,13 @@ body: attributes: label: Environment description: | - Tip: Use the `composer info dragon-code/laravel-actions` command to get information for Laravel Lang. + Tip: Use the `composer info dragon-code/laravel-deploy-operations` command to get information for Laravel Lang. Tip: Use the `php artisan --version` command to get information for Laravel Framework. Tip: Use the `php -v` command to get information for PHP. value: | - PHP Version: - Database Driver & Version: - - Actions Version: + - Deploy Operations Version: - Laravel Version: validations: required: true diff --git a/README.md b/README.md index 468ee843..2aa0c3ec 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ This package is licensed under the [MIT License](LICENSE). [badge_build]: https://img.shields.io/github/actions/workflow/status/TheDragonCode/laravel-actions/phpunit.yml?style=flat-square -[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/laravel-actions.svg?style=flat-square +[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/laravel-deploy-operations.svg?style=flat-square -[badge_license]: https://img.shields.io/packagist/l/dragon-code/laravel-actions.svg?style=flat-square +[badge_license]: https://img.shields.io/packagist/l/dragon-code/laravel-deploy-operations.svg?style=flat-square [badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/laravel-actions?label=stable&style=flat-square @@ -34,4 +34,4 @@ This package is licensed under the [MIT License](LICENSE). [link_license]: LICENSE -[link_packagist]: https://packagist.org/packages/dragon-code/laravel-actions +[link_packagist]: https://packagist.org/packages/dragon-code/laravel-deploy-operations diff --git a/composer.json b/composer.json index eb9d2d6e..2dfbc18b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "dragon-code/laravel-actions", + "name": "dragon-code/laravel-deploy-operations", "description": "Performing any actions during the deployment process", "license": "MIT", "type": "library", @@ -58,6 +58,7 @@ }, "conflict": { "andrey-helldar/laravel-actions": "*", + "dragon-code/laravel-actions": "*", "dragon-code/laravel-migration-actions": "*" }, "suggest": { @@ -67,7 +68,7 @@ "prefer-stable": true, "autoload": { "psr-4": { - "DragonCode\\LaravelActions\\": "src/" + "DragonCode\\LaravelDeployOperations\\": "src/" } }, "autoload-dev": { @@ -88,7 +89,7 @@ "extra": { "laravel": { "providers": [ - "DragonCode\\LaravelActions\\ServiceProvider" + "DragonCode\\LaravelDeployOperations\\ServiceProvider" ] } } diff --git a/config/actions.php b/config/deploy-operations.php similarity index 78% rename from config/actions.php rename to config/deploy-operations.php index d076d361..51321934 100644 --- a/config/actions.php +++ b/config/deploy-operations.php @@ -3,11 +3,11 @@ return [ /* |-------------------------------------------------------------------------- - | Actions Repository Connection + | Operations Repository Connection |-------------------------------------------------------------------------- | | This option controls the database connection used to store the table - | of executed actions. + | of executed operations. | */ @@ -15,27 +15,27 @@ /* |-------------------------------------------------------------------------- - | Actions Repository Table + | Operations Repository Table |-------------------------------------------------------------------------- | - | This table keeps track of all the actions that have already run for + | This table keeps track of all the operations that have already run for | your application. Using this information, we can determine which of - | the actions on disk haven't actually been run in the database. + | the operations on disk haven't actually been run in the database. | */ - 'table' => 'actions', + 'table' => 'operations', /* |-------------------------------------------------------------------------- - | Actions Path + | Operations Path |-------------------------------------------------------------------------- | - | This option defines the path to the action directory. + | This option defines the path to the operation directory. | */ - 'path' => base_path('actions'), + 'path' => base_path('operations'), /* |-------------------------------------------------------------------------- @@ -64,7 +64,7 @@ |-------------------------------------------------------------------------- | | This option specifies the queue settings that will process - | asynchronous actions. + | asynchronous operations. | */ @@ -78,7 +78,7 @@ | */ - 'connection' => env('ACTIONS_QUEUE_CONNECTION', env('QUEUE_CONNECTION', 'sync')), + 'connection' => env('DEPLOY_OPERATIONS_QUEUE_CONNECTION', env('QUEUE_CONNECTION', 'sync')), /* |-------------------------------------------------------------------------- @@ -90,6 +90,6 @@ | */ - 'name' => env('ACTIONS_QUEUE_NAME'), + 'name' => env('DEPLOY_OPERATIONS_QUEUE_NAME'), ], ]; diff --git a/database/migrations/2022_08_18_180137_change_migration_actions_table.php b/database/migrations/2022_08_18_180137_change_migration_actions_table.php index 1694e9b7..db230954 100644 --- a/database/migrations/2022_08_18_180137_change_migration_actions_table.php +++ b/database/migrations/2022_08_18_180137_change_migration_actions_table.php @@ -2,12 +2,12 @@ declare(strict_types=1); -use DragonCode\LaravelActions\Action; -use DragonCode\LaravelActions\Helpers\Config; +use DragonCode\LaravelDeployOperations\Helpers\Config; +use DragonCode\LaravelDeployOperations\Operation; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Action { +return new class extends Operation { public function up(): void { if ($this->hasTable()) { diff --git a/database/migrations/2023_01_21_172923_rename_migrations_actions_table_to_actions.php b/database/migrations/2023_01_21_172923_rename_migrations_actions_table_to_actions.php index d4ed8947..cba1f950 100644 --- a/database/migrations/2023_01_21_172923_rename_migrations_actions_table_to_actions.php +++ b/database/migrations/2023_01_21_172923_rename_migrations_actions_table_to_actions.php @@ -2,11 +2,11 @@ declare(strict_types=1); -use DragonCode\LaravelActions\Action; -use DragonCode\LaravelActions\Helpers\Config; +use DragonCode\LaravelDeployOperations\Helpers\Config; +use DragonCode\LaravelDeployOperations\Operation; use Illuminate\Support\Facades\Schema; -return new class extends Action { +return new class extends Operation { public function up(): void { if (Schema::hasTable('migration_actions') && $this->doesntSame('migration_actions', $this->table())) { diff --git a/database/migrations/2024_05_21_112438_rename_actions_table_to_operations.php b/database/migrations/2024_05_21_112438_rename_actions_table_to_operations.php new file mode 100644 index 00000000..0a18d9db --- /dev/null +++ b/database/migrations/2024_05_21_112438_rename_actions_table_to_operations.php @@ -0,0 +1,44 @@ +doesntSame('actions', $this->table())) { + $this->validateTable($this->table()); + + Schema::rename('actions', $this->table()); + } + } + + public function down(): void + { + if (Schema::hasTable($this->table()) && $this->doesntSame('actions', $this->table())) { + $this->validateTable('actions'); + + Schema::rename($this->table(), 'actions'); + } + } + + protected function validateTable(string $name): void + { + if (Schema::hasTable($name)) { + throw new RuntimeException(sprintf('A table named [%s] already exists. Change the table name settings in the [%s] configuration file.', $name, 'config/deploy-operations.php')); + } + } + + protected function doesntSame(string $first, string $second): bool + { + return $first !== $second; + } + + protected function table(): string + { + return app(Config::class)->table(); + } +}; diff --git a/database/migrations/2024_05_21_114318_rename_column_in_operations_table.php b/database/migrations/2024_05_21_114318_rename_column_in_operations_table.php new file mode 100644 index 00000000..823a0b20 --- /dev/null +++ b/database/migrations/2024_05_21_114318_rename_column_in_operations_table.php @@ -0,0 +1,32 @@ +rename('action', 'operation'); + } + + public function down(): void + { + $this->rename('operation', 'action'); + } + + protected function rename(string $from, string $to): void + { + if (Schema::hasColumn($this->table(), $from)) { + Schema::table($this->table(), fn (Blueprint $table) => $table->renameColumn($from, $to)); + } + } + + protected function table(): string + { + return app(Config::class)->table(); + } +}; diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index c8a4b82d..7daafb79 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -40,14 +40,14 @@ function resolveNumeric(value) { return isNaN(num) ? value : num } -const hostname = 'actions.dragon-code.pro' +const hostname = 'deploy-operations.dragon-code.pro' export default defineUserConfig({ bundler: viteBundler(), lang: 'en-US', - title: 'Dragon Code: Actions', - description: 'Performing actions with saving the list of called files', + title: 'Dragon Code: Deploy Operations for Laravel', + description: 'Performing deploy operations with saving the list of called files', head: [ ['link', {rel: 'icon', href: `https://${hostname}/images/logo.svg`}], @@ -60,9 +60,9 @@ export default defineUserConfig({ logo: `https://${hostname}/images/logo.svg`, - repo: 'https://github.com/TheDragonCode/laravel-actions', + repo: 'https://github.com/TheDragonCode/laravel-deploy-operations', repoLabel: 'GitHub', - docsRepo: 'https://github.com/TheDragonCode/laravel-actions', + docsRepo: 'https://github.com/TheDragonCode/laravel-deploy-operations', docsBranch: 'main', docsDir: 'docs', @@ -71,11 +71,12 @@ export default defineUserConfig({ navbar: [ { - text: '5.x', + text: '6.x', children: [ - {text: '5.x', link: '/getting-started/installation/index.md'}, - {text: '4.x', link: 'https://github.com/TheDragonCode/laravel-actions/blob/4.x/docs/index.md'}, - {text: '3.x', link: 'https://github.com/TheDragonCode/laravel-actions/blob/3.x/docs/index.md'}, + {text: '6.x', link: '/getting-started/installation/index.md'}, + {text: '5.x', link: 'https://github.com/TheDragonCode/laravel-deploy-operations/blob/5.x/docs/index.md'}, + {text: '4.x', link: 'https://github.com/TheDragonCode/laravel-deploy-operations/blob/4.x/docs/index.md'}, + {text: '3.x', link: 'https://github.com/TheDragonCode/laravel-deploy-operations/blob/3.x/docs/index.md'}, ] } ], diff --git a/docs/getting-started/installation/index.md b/docs/getting-started/installation/index.md index fa089caa..bf33f8a3 100644 --- a/docs/getting-started/installation/index.md +++ b/docs/getting-started/installation/index.md @@ -1,9 +1,9 @@ # Installation -To get the latest version of `Deploy Actions for Laravel`, simply require the project using [Composer](https://getcomposer.org): +To get the latest version of `Deploy Operations for Laravel`, require the project using [Composer](https://getcomposer.org): ```bash -composer require dragon-code/laravel-actions +composer require dragon-code/laravel-deploy-operations ``` Or manually update `require` block of `composer.json` and run `composer update` console command. @@ -11,7 +11,7 @@ Or manually update `require` block of `composer.json` and run `composer update` ```json { "require": { - "dragon-code/laravel-actions": "^5.0" + "dragon-code/laravel-deploy-operations": "^6.0" } } ``` @@ -19,5 +19,5 @@ Or manually update `require` block of `composer.json` and run `composer update` If necessary, you can publish the configuration file by calling the console command: ```bash -php artisan vendor:publish --provider="DragonCode\LaravelActions\ServiceProvider" +php artisan vendor:publish --provider="DragonCode\LaravelDeployOperations\ServiceProvider" ``` diff --git a/docs/helpers/artisan.md b/docs/helpers/artisan.md index ba4458fe..344807fc 100644 --- a/docs/helpers/artisan.md +++ b/docs/helpers/artisan.md @@ -1,11 +1,12 @@ # Artisan Command -Quite often, when working with actions, it becomes necessary to run one or another console command, and each time you have to write the following code: +Quite often, when working with operations, it becomes necessary to run one or another console command, +and each time you have to write the following code: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class () extends Action +return new class extends Operation { public function __invoke(): void { diff --git a/docs/helpers/events.md b/docs/helpers/events.md index fa3cc576..7486fa27 100644 --- a/docs/helpers/events.md +++ b/docs/helpers/events.md @@ -1,36 +1,38 @@ # Events -You can also handle events when executing actions: +You can also handle events when executing operations: -``` -DragonCode\LaravelActions\Events\ActionStarted -DragonCode\LaravelActions\Events\ActionEnded -DragonCode\LaravelActions\Events\ActionFailed -DragonCode\LaravelActions\Events\NoPendingActions +```php +DragonCode\LaravelDeployOperations\Events\DeployOperationStarted::class +DragonCode\LaravelDeployOperations\Events\DeployOperationEnded::class +DragonCode\LaravelDeployOperations\Events\DeployOperationFailed::class +DragonCode\LaravelDeployOperations\Events\NoPendingDeployOperations::class ``` -If there are no action files to execute, the `NoPendingActions` event will be sent. +If there are no operation files to execute, the `NoPendingDeployOperations` event will be sent. -In other cases, the `ActionStarted` event will be sent before processing starts, and the `ActionEnded` event will be sent after processing. +In other cases, the `DeployOperationStarted` event will be sent before processing starts, +and the `DeployOperationEnded` event will be sent after processing. For example: ```php namespace App\Providers; -use App\Listeners\SomeActionsListener; -use DragonCode\LaravelActions\Events\ActionEnded; -use DragonCode\LaravelActions\Events\ActionStarted; -use DragonCode\LaravelActions\Events\NoPendingActions; +use App\Listeners\SomeOperationsListener; +use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded; +use DragonCode\LaravelDeployOperations\Events\DeployOperationFailed; +use DragonCode\LaravelDeployOperations\Events\DeployOperationStarted; +use DragonCode\LaravelDeployOperations\Events\NoPendingDeployOperations; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider { protected $listen = [ - ActionStarted::class => [SomeActionsListener::class], - ActionEnded::class => [SomeActionsListener::class], - ActionFailed::class => [SomeActionsListener::class], - NoPendingActions::class => [SomeActionsListener::class], + DeployOperationStarted::class => [SomeOperationsListener::class], + DeployOperationEnded::class => [SomeOperationsListener::class], + DeployOperationFailed::class => [SomeOperationsListener::class], + NoPendingDeployOperations::class => [SomeOperationsListener::class], ]; } ``` @@ -38,9 +40,9 @@ class EventServiceProvider extends ServiceProvider ```php namespace App\Listeners; -use DragonCode\LaravelActions\Events\BaseEvent; +use DragonCode\LaravelDeployOperations\Events\BaseEvent; -class SomeActionsListener +class SomeOperationsListener { public function handle(BaseEvent $event): void { diff --git a/docs/helpers/execution-status.md b/docs/helpers/execution-status.md index ab71ab6d..a8d0bcfe 100644 --- a/docs/helpers/execution-status.md +++ b/docs/helpers/execution-status.md @@ -5,10 +5,10 @@ You can also override the `success` and `failed` methods, which are called on su ## If Success ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; use Illuminate\Support\Facade\Log; -return new class () extends Action +return new class extends Operation { public function up(): void { @@ -32,18 +32,18 @@ return new class () extends Action }; ``` -Call the `php artisan actions` command. +Call the `php artisan operations` command. The log file will contain two `success` entries. ## If Failed ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; use Exeption; use Illuminate\Support\Facade\Log; -return new class extends Action +return new class extends Operation { public function up(): void { @@ -67,6 +67,6 @@ return new class extends Action }; ``` -Call the `php artisan actions` command. +Call the `php artisan operations` command. The log file will contain two `failed` entries. diff --git a/docs/how-to-use/creating.md b/docs/how-to-use/creating.md index b628afee..dc3e5114 100644 --- a/docs/how-to-use/creating.md +++ b/docs/how-to-use/creating.md @@ -1,14 +1,14 @@ -# Creating Actions +# Creating Operations -To create an action use the `make:action` artisan command: +To create an operation use the `make:operation` artisan command: ```bash -php artisan make:action some_name +php artisan make:operation some_name ``` -The new action's file will be placed in your `actions` directory in the base path of your app. +The new operation's file will be placed in your `operations` directory in the base path of your app. -Each action file name contains a timestamp, which allows Laravel to determine the order of the actions. +Each operation file name contains a timestamp, which allows Laravel to determine the order of the operations. ## Automatically Generate A File Name @@ -18,7 +18,7 @@ If you do not specify the "name" attribute, then the file name will be generated > git branch name ?: 'auto' ```bash -php artisan make:action +php artisan make:operation ### When the git repository is found (`base_path('.git')` directory is exists) and HEAD branch name is 'qwerty' # 2022_10_11_225116_qwerty.php @@ -33,45 +33,45 @@ php artisan make:action ## Nested Files -You can use nested paths to create actions: +You can use nested paths to create operations: ```bash -php artisan make:action Foo/Bar/QweRty -php artisan make:action Foo/Bar/QweRty.php +php artisan make:operation Foo/Bar/QweRty +php artisan make:operation Foo/Bar/QweRty.php -php artisan make:action Foo\Bar\QweRty -php artisan make:action Foo\Bar\QweRty.php +php artisan make:operation Foo\Bar\QweRty +php artisan make:operation Foo\Bar\QweRty.php -php artisan make:action foo\bar\QweRty -php artisan make:action foo\bar\QweRty.php +php artisan make:operation foo\bar\QweRty +php artisan make:operation foo\bar\QweRty.php ``` -All of these commands will create a file called `actions/foo/bar/Y_m_d_His_qwe_rty.php`. +All of these commands will create a file called `operations/foo/bar/Y_m_d_His_qwe_rty.php`. For example: ```bash -php artisan make:action foo\bar\QweRty -# actions/foo/bar/2022_10_11_225734_qwe_rty.php +php artisan make:operation foo\bar\QweRty +# operations/foo/bar/2022_10_11_225734_qwe_rty.php -php artisan make:action foo\bar\QweRty.php -# actions/foo/bar/2022_10_11_225734_qwe_rty.php +php artisan make:operation foo\bar\QweRty.php +# operations/foo/bar/2022_10_11_225734_qwe_rty.php -php artisan make:action foo/bar/QweRty -# actions/foo/bar/2022_10_11_225734_qwe_rty.php +php artisan make:operation foo/bar/QweRty +# operations/foo/bar/2022_10_11_225734_qwe_rty.php -php artisan make:action foo/bar/QweRty.php -# actions/foo/bar/2022_10_11_225734_qwe_rty.php +php artisan make:operation foo/bar/QweRty.php +# operations/foo/bar/2022_10_11_225734_qwe_rty.php ``` ## Invokable Method -By default, the new action class will contain the `__invoke` method, but you can easily replace it with public `up` name. +By default, the new operation class will contain the `__invoke` method, but you can easily replace it with public `up` name. ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class () extends Action +return new class extends Operation { public function __invoke(): void { @@ -81,19 +81,19 @@ return new class () extends Action ``` > Note that the `__invoke` method has been added as a single call. -> This means that when the action is running, it will be called, but not when it is rolled back. +> This means that when the operation is running, it will be called, but not when it is rolled back. > > You should also pay attention to the fact that if there is an `__invoke` method in the class, the `down` method will not be called. ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class () extends Action +return new class extends Operation { - public function __invoke(): void {} // called when `php artisan actions` running + public function __invoke(): void {} // called when `php artisan operations` running public function down(): void {} // doesn't call when `php artisan migrate:rollback` running - // and any other commands to revert the action. + // and any other commands to revert the operation. }; ``` @@ -102,10 +102,10 @@ return new class () extends Action You can also use the dependency injection with `__invoke`, `up` and `down` methods: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; use Tests\Concerns\Some; -return new class () extends Action +return new class extends Operation { public function __invoke(Some $some): void { @@ -115,10 +115,10 @@ return new class () extends Action ``` ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; use Tests\Concerns\Some; -return new class () extends Action +return new class extends Operation { public function up(Some $some): void { diff --git a/docs/how-to-use/customize-stub.md b/docs/how-to-use/customize-stub.md index 83fd6c18..9bc391ad 100644 --- a/docs/how-to-use/customize-stub.md +++ b/docs/how-to-use/customize-stub.md @@ -1,9 +1,9 @@ # Customize Stub -In order to use your action template, you first need to publish it using the console command: +In order to use your operation template, you first need to publish it using the console command: ``` -php artisan actions:stub +php artisan operations:stub ``` -As a result, the file `stubs/action.stub` will be created in the root of the project, which you can change for yourself. +As a result, the file `stubs/deploy-operation.stub` will be created in the root of the project, which you can change for yourself. diff --git a/docs/how-to-use/rollback.md b/docs/how-to-use/rollback.md index a8343017..d936f4fc 100644 --- a/docs/how-to-use/rollback.md +++ b/docs/how-to-use/rollback.md @@ -1,44 +1,44 @@ -# Rolling Back Actions +# Rolling Back Operations -To roll back the latest action operation, you may use the `rollback` command. This command rolls back the last "batch" of actions, which may include multiple action files: +To roll back the latest operation, you may use the `rollback` command. This command rolls back the last "batch" of operations, which may include multiple operation files: ``` -php artisan actions:rollback +php artisan operations:rollback ``` -You may roll back a limited number of actions by providing the `step` option to the rollback command. For example, the following command will roll back the last five actions: +You may roll back a limited number of operations by providing the `step` option to the rollback command. For example, the following command will roll back the last five operations: ``` -php artisan actions:rollback --step=5 +php artisan operations:rollback --step=5 ``` -The `actions:reset` command will roll back all of your application's actions: +The `operations:reset` command will roll back all of your application's operations: ``` -php artisan actions:reset +php artisan operations:reset ``` For example: ```bash -php artisan actions:rollback -# action batch +php artisan operations:rollback +# operation batch # 2022_10_12_021837_some 1 # 2022_10_12_021838_some 2 # 2022_10_12_021839_some 2 # 2022_10_12_021840_some 3 // will be canceled # 2022_10_12_021841_some 3 // will be canceled -php artisan actions:rollback --step=1 -# action batch +php artisan operations:rollback --step=1 +# operation batch # 2022_10_12_021837_some 1 # 2022_10_12_021838_some 2 # 2022_10_12_021839_some 2 # 2022_10_12_021840_some 3 // will be canceled # 2022_10_12_021841_some 3 // will be canceled -php artisan actions:rollback --step=2 -# action batch +php artisan operations:rollback --step=2 +# operation batch # 2022_10_12_021837_some 1 # 2022_10_12_021838_some 2 // will be canceled # 2022_10_12_021839_some 2 // will be canceled @@ -46,26 +46,26 @@ php artisan actions:rollback --step=2 # 2022_10_12_021841_some 3 // will be canceled ``` -## Roll Back & Action Using A Single Command +## Roll Back & Operation Using A Single Command -The `actions:refresh` command will roll back all of your actions and then execute the `actions` command. This command effectively re-creates your entire +The `operations:refresh` command will roll back all of your operations and then execute the `operations` command. This command effectively re-creates your entire database: ``` -php artisan actions:refresh +php artisan operations:refresh ``` -You may roll back & re-run a limited number of actions by providing the `step` option to the `refresh` command. For example, the following command will roll back & -re-run the last five actions: +You may roll back & re-run a limited number of operations by providing the `step` option to the `refresh` command. For example, the following command will roll back & +re-run the last five operations: ``` -php artisan actions:refresh --step=5 +php artisan operations:refresh --step=5 ``` -## Drop All Actions & Rerun Actions +## Drop All & Rerun Operations -The `actions:fresh` command will drop all actions records from the actions table and then execute the actions command: +The `operations:fresh` command will drop all operation records from the operation table and then execute the operations command: ``` -php artisan actions:fresh +php artisan operations:fresh ``` diff --git a/docs/how-to-use/running.md b/docs/how-to-use/running.md index 73d9120f..6ec76513 100644 --- a/docs/how-to-use/running.md +++ b/docs/how-to-use/running.md @@ -1,12 +1,12 @@ -# Running Actions +# Running Operations -To run all of your outstanding actions, execute the `actions` artisan command: +To run all of your outstanding operations, execute the `operations` artisan command: ```bash -php artisan actions +php artisan operations ``` -Action call order is checked by filename without path: +Operation call order is checked by filename without path: ```bash 2022_10_14_000001_test1 # 1 @@ -22,36 +22,36 @@ bar/2022_10_14_000003_test3 # 3 2022_10_14_000004_test4 # 4 ``` -## Isolating Action Execution +## Isolating Operations Execution -If you are deploying your application across multiple servers and running actions as part of your deployment process, you likely do not want two servers attempting to run -the database at the same time. To avoid this, you may use the `isolated` option when invoking the `actions` command. +If you are deploying your application across multiple servers and running operations as part of your deployment process, you likely do not want two servers attempting to run +the database at the same time. To avoid this, you may use the `isolated` option when invoking the `operations` command. -When the `isolated` option is provided, Laravel will acquire an atomic lock using your application's cache driver before attempting to run your actions. All other attempts to -run the `actions` command while that lock is held will not execute; however, the command will still exit with a successful exit status code: +When the `isolated` option is provided, Laravel will acquire an atomic lock using your application's cache driver before attempting to run your operations. All other attempts to +run the `operations` command while that lock is held will not execute; however, the command will still exit with a successful exit status code: ```bash -php artisan actions --isolated +php artisan operations --isolated ``` ## Split Launch Option -Sometimes it becomes necessary to launch actions separately, for example, to notify about the successful deployment of a project. +Sometimes it becomes necessary to launch operations separately, for example, to notify about the successful deployment of a project. -There is a `before` option for this when calling actions: +There is a `before` option for this when calling operations: ```bash -php artisan actions --before +php artisan operations --before ``` -When calling the `actions` command with the `before` parameter, the script will execute only those actions within which the value of the `before` parameter is `true`. +When calling the `operations` command with the `before` parameter, the script will execute only those operations within which the value of the `before` parameter is `true`. -For backwards compatibility, the `before` parameter is set to `true` by default, but actions will only be executed if the option is explicitly passed. +For backwards compatibility, the `before` parameter is set to `true` by default, but operations will only be executed if the option is explicitly passed. ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected bool $before = false; @@ -62,7 +62,7 @@ return new class extends Action }; ``` -For example, you need to call actions when deploying an application. Some actions should be run after the actions are deployed, and others after the application is fully +For example, you need to call operations when deploying an application. Some operations should be run after the operations are deployed, and others after the application is fully launched. To run, you need to pass the `before` parameter. For example, when using [`deployer`](https://github.com/deployphp/deployer) it would look like this: @@ -71,43 +71,43 @@ To run, you need to pass the `before` parameter. For example, when using [`deplo task('deploy', [ // ... 'artisan:migrate', - 'artisan:actions --before', // here + 'artisan:operation --before', // here 'deploy:publish', 'php-fpm:reload', 'artisan:queue:restart', - 'artisan:actions', // here + 'artisan:operations', // here ]); ``` -Thus, when `actions` is called, all actions whose `before` parameter is `true` will be executed, and after that, the remaining tasks will be executed. +Thus, when `operations` is called, all operations whose `before` parameter is `true` will be executed, and after that, the remaining tasks will be executed. > Note: -> If you call the `actions` command without the `before` parameter, +> If you call the `operations` command without the `before` parameter, > then all tasks will be executed regardless of the value of the `$before` -> attribute inside the action class. +> attribute inside the operation class. -## Forcing Actions To Run In Production +## Forcing Operations To Run In Production > Some commands cannot be executed in production without confirmation. -> These include all commands except `actions:status` and `actions`. +> These include all commands except `operations:status` and `operations`. -Some action operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database, +Some operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database, you will be prompted for confirmation before the commands are executed. To force the commands to run without a prompt, use the `--force` flag: ```bash -php artisan actions:install --force +php artisan operations:install --force ``` ## Execution Every Time In some cases, you need to call the code every time you deploy the application. For example, to call reindexing. -To do this, override the `$once` variable in the action file: +To do this, override the `$once` variable in the operation file: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected bool $once = false; @@ -118,24 +118,24 @@ return new class extends Action }; ``` -If the value is `$once = false`, the `up` method will be called every time the `actions` command called. +If the value is `$once = false`, the `up` method will be called every time the `operations` command called. -In this case, information about it will not be written to the `actions` table and, therefore, the `down` method will not be called when the rollback command is called. +In this case, information about it will not be written to the `operations` table and, therefore, the `down` method will not be called when the rollback command is called. > Note > -> When using the `before` parameter to run command, it is recommended to override the value of the `$before` attribute to `false`, otherwise this action will be executed twice. +> When using the `before` parameter to run command, it is recommended to override the value of the `$before` attribute to `false`, otherwise this operation will be executed twice. ## Execution In A Specific Environment -In some cases, it becomes necessary to execute an action in a specific environment. For example `production`. +In some cases, it becomes necessary to execute an operation in a specific environment. For example `production`. For this you can use the `$environment` parameter: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected string|array|null $environment = 'production'; @@ -149,9 +149,9 @@ return new class extends Action You can also specify multiple environment names: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected string|array|null $environment = ['testing', 'staging']; @@ -162,18 +162,18 @@ return new class extends Action }; ``` -By default, the action will run in all environments. The same will happen if you specify `null` or `[]` as the value. +By default, the operation will run in all environments. The same will happen if you specify `null` or `[]` as the value. ## Execution Excluding Certain Environments -In some cases, it becomes necessary to execute an action excluding certain environments. For example `production`. +In some cases, it becomes necessary to execute an operation excluding certain environments. For example `production`. For this you can use the `$except_environment` parameter: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected string|array|null $exceptEnvironment = 'production'; @@ -187,9 +187,9 @@ return new class extends Action You can also specify multiple environment names: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected string|array|null $exceptEnvironment = ['testing', 'staging']; @@ -200,20 +200,20 @@ return new class extends Action }; ``` -By default, no actions will be excluded. The same happens if you specify `null` or `[]` value. +By default, no operations will be excluded. The same happens if you specify `null` or `[]` value. ## Database Transactions -In some cases, it becomes necessary to undo previously performed actions in the database. For example, when code execution throws an error. To do this, the code must be wrapped in +In some cases, it becomes necessary to undo previously performed operations in the database. For example, when code execution throws an error. To do this, the code must be wrapped in a transaction. By setting the `$transactions = true` parameter, you will ensure that your code is wrapped in a transaction without having to manually call the `DB::transaction()` method. This -will reduce the time it takes to create the action. +will reduce the time it takes to create the operation. ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected bool $transactions = true; @@ -228,14 +228,14 @@ return new class extends Action ## Asynchronous Call -In some cases, it becomes necessary to execute actions in an asynchronous manner without delaying the deployment process. +In some cases, it becomes necessary to execute operations in an asynchronous manner without delaying the deployment process. -To do this, you need to override the `$async` property in the action class: +To do this, you need to override the `$async` property in the operation class: ```php -use DragonCode\LaravelActions\Action; +use DragonCode\LaravelDeployOperations\Operation; -return new class extends Action +return new class extends Operation { protected bool $async = true; @@ -246,9 +246,9 @@ return new class extends Action }; ``` -In this case, the action file that defines this parameter will run asynchronously using the `DragonCode\LaravelActions\Jobs\ActionJob` class. +In this case, the operation file that defines this parameter will run asynchronously using the `DragonCode\LaravelDeployOperations\Jobs\OperationJob` class. -The name of the connection and queue can be changed through the [settings](https://github.com/TheDragonCode/laravel-actions/tree/main/config). +The name of the connection and queue can be changed through the [settings](https://github.com/TheDragonCode/laravel-deploy-operations/tree/main/config). ::: Info We remind you that in this case the [queuing system](https://laravel.com/docs/queues) must work in your application. diff --git a/docs/how-to-use/status.md b/docs/how-to-use/status.md index 56400b4a..19e19080 100644 --- a/docs/how-to-use/status.md +++ b/docs/how-to-use/status.md @@ -1,7 +1,8 @@ -# Actions Status +# Operations Status -The `actions:status` command displays the execution status of actions. In it you can see which actions were executed and which were not: +The `operations:status` command displays the execution status of operations. +In it you can see which operations were executed and which were not: ``` -php artisan actions:status +php artisan operations:status ``` diff --git a/docs/index.md b/docs/index.md index cfa6bfb7..b6e1d741 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ -# Deploy Actions for Laravel +# Deploy Operations for Laravel -![the dragon code actions](https://preview.dragon-code.pro/the-dragon-code/deploy-actions.svg?brand=laravel&mode=dark) +![the dragon code operations](https://preview.dragon-code.pro/the-dragon-code/deploy-operations.svg?brand=laravel&mode=dark) [![Stable Version][badge_stable]][link_packagist] [![Unstable Version][badge_unstable]][link_packagist] @@ -8,13 +8,16 @@ [![Github Workflow Status][badge_build]][link_build] [![License][badge_license]][link_license] -> Actions are like version control for your actions process, allowing your team to modify and share the application's actionable schema. If you have ever had to tell a teammate -> to manually perform any action on a production server, you've come across an issue that actions solves. +> Operations are like version control for your operations process, +> allowing your team to modify and share the application's operationable schema. +> If you have ever had to tell a teammate to manually perform any operation on a production server, +> you've come across an issue that operation solves. ## Table of contents * Prologue * [Upgrade Guide](prologue/upgrade-guide/index.md) + * [To 6.x from 5.x](prologue/upgrade-guide/6.x.md) * [To 5.x from 4.x](prologue/upgrade-guide/5.x.md) * [To 4.x from 3.x](prologue/upgrade-guide/4.x.md) * [To 3.x from 2.x](prologue/upgrade-guide/3.x.md) @@ -22,7 +25,7 @@ * [Installation](getting-started/installation/index.md) * How to use * [Creating](how-to-use/creating.md) - * [Running Actions](how-to-use/running.md) + * [Running Operations](how-to-use/running.md) * [Rolling Back](how-to-use/rollback.md) * [Status](how-to-use/status.md) * Helpers @@ -35,18 +38,18 @@ This package is licensed under the [MIT License](prologue/license.md). -[badge_build]: https://img.shields.io/github/actions/workflow/status/TheDragonCode/laravel-actions/phpunit.yml?style=flat-square +[badge_build]: https://img.shields.io/github/actions/workflow/status/TheDragonCode/laravel-deploy-operations/phpunit.yml?style=flat-square -[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/laravel-actions.svg?style=flat-square +[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/laravel-deploy-operations.svg?style=flat-square -[badge_license]: https://img.shields.io/packagist/l/dragon-code/laravel-actions.svg?style=flat-square +[badge_license]: https://img.shields.io/packagist/l/dragon-code/laravel-deploy-operations.svg?style=flat-square -[badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/laravel-actions?label=stable&style=flat-square +[badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/laravel-deploy-operations?label=stable&style=flat-square [badge_unstable]: https://img.shields.io/badge/unstable-dev--main-orange?style=flat-square -[link_build]: https://github.com/TheDragonCode/laravel-actions/actions +[link_build]: https://github.com/TheDragonCode/laravel-deploy-operations/actions [link_license]: prologue/license.md -[link_packagist]: https://packagist.org/packages/dragon-code/laravel-actions +[link_packagist]: https://packagist.org/packages/dragon-code/laravel-deploy-operations diff --git a/docs/prologue/upgrade-guide/3.x.md b/docs/prologue/upgrade-guide/3.x.md index 94885cce..64bf0c76 100644 --- a/docs/prologue/upgrade-guide/3.x.md +++ b/docs/prologue/upgrade-guide/3.x.md @@ -82,7 +82,7 @@ class Some extends Actionable {} // after use DragonCode\LaravelActions\Action; -return new class () extends Action {}; +return new class extends Action {}; ``` ## Invokable Method diff --git a/docs/prologue/upgrade-guide/4.x.md b/docs/prologue/upgrade-guide/4.x.md index 96cd7b7f..760d09cd 100644 --- a/docs/prologue/upgrade-guide/4.x.md +++ b/docs/prologue/upgrade-guide/4.x.md @@ -1,6 +1,6 @@ # Upgrading To 4.x from 3.x -### High Impact Changes +### High-Impact Changes - [Rename package name](#rename-package-name) - [Changing the names of console commands](#changing-the-names-of-console-commands) @@ -18,7 +18,7 @@ > Note > If you used inheritance of actions from other actions, then you will need to process these files manually. -For your convenience, we have created an upgrade console command: +For your convenience, we have created an `upgrade` console command: ```bash composer remove dragon-code/laravel-migration-actions diff --git a/docs/prologue/upgrade-guide/6.x.md b/docs/prologue/upgrade-guide/6.x.md new file mode 100644 index 00000000..4830b708 --- /dev/null +++ b/docs/prologue/upgrade-guide/6.x.md @@ -0,0 +1,146 @@ +# Upgrading To 6.x from 5.x + +## High-Impact Changes + +- [Updating Dependencies](#updating-dependencies) +- [Changed the namespace](#changed-the-namespace) +- [Changed the name of the main class](#changed-the-name-of-the-main-class) +- [Changed names of console commands](#changed-names-of-console-commands) +- [Changed event names](#changed-event-names) +- [Configuration file name changed](#configuration-file-name-changed) + +## Minor-Impact Changes + +- [Changed file location](#changed-file-location) + +## Low-Impact Changes + +- [Stub name changed](#stub-name-changed) + +## The easiest way to upgrade + +> Note +> If you used inheritance of actions from other actions, then you will need to process these files manually. + +For your convenience, we have created an `upgrade` console command: + +```bash +composer remove dragon-code/laravel-actions +composer require dragon-code/laravel-deploy-operations:^6.0 + +php artisan operations:upgrade +php artisan migrate +``` + +It will do the following: + +- Changing the old namespace of “actions” to a new one +- Moves files to a new location +- Updates the configuration file +- Rename the stub file (if published) + +Please note that the script allows you to automate most of the actions, but may not complete them completely. +Therefore, you will need to manually check the result of the upgrade by checking this guide. + +## Updating Dependencies + +You should change the package name in the `composer.json` file from `dragon-code/laravel-actions` +to `dragon-code/laravel-deploy-operations`, and also change its version to `^6.0`: + +```json lines +{ + "require": { + // ... + "dragon-code/laravel-deploy-operations": "^6.0" + } +} +``` + +Then you need to update the dependencies: + +```bash +composer update +``` + +## Changed the namespace + +The namespace has been changed from `DragonCode\LaravelActions` to `DragonCode\LaravelDeployOperations`. + +You need to replace it in all actions of your application, as well as when using [events](../../helpers/events.md). + +## Changed the name of the main class + +You should replace `DragonCode\LaravelActions\Action` namespace with `DragonCode\LaravelDeployOperations\Operation`. + +## Changed names of console commands + +| New Name | Old Name | +|-----------------------|--------------------| +| `make:operation` | `make:action` | +| `operations` | `actions` | +| `operations:fresh` | `actions:fresh` | +| `operations:install` | `actions:install` | +| `operations:refresh` | `actions:refresh` | +| `operations:reset` | `actions:reset` | +| `operations:rollback` | `actions:rollback` | +| `operations:status` | `actions:status` | +| `operations:stub` | `actions:stub` | +| `operations:upgrade` | `actions:upgrade` | + +## Changed event names + +| New Name | Old Name | +|-----------------------------|--------------------| +| `DeployOperationStarted` | `ActionStarted` | +| `DeployOperationEnded` | `ActionEnded` | +| `DeployOperationFailed` | `ActionFailed` | +| `NoPendingDeployOperations` | `NoPendingActions` | + +Don't forget to also change the namespace from `DragonCode\LaravelActions\Events` +to `DragonCode\LaravelDeployOperations\Events`. + +## Configuration file name changed + +We recommend that you delete the old configuration file `config/actions.php` and publish a new one. +This way you will see the changes made to it. + +```bash +php artisan vendor:publish --provider="DragonCode\LaravelDeployOperations\ServiceProvider" +``` + +## Changed names of constants + +If you use package constant references, you must also rename them. + +The old name was in `UPPER_CASE`, the new one was in `PascalCase`. + +For example: + +```php +// Old +class Names +{ + public const ACTIONS = 'actions'; + public const FRESH = 'actions:fresh'; + // ... +} +``` + +```php +// New +class Names +{ + public const Operations = 'operations'; + public const Fresh = 'operations:fresh'; + // ... +} +``` + +## Changed file location + +File storage directory changed to `operations` from `actions`. + +## Stub name changed + +If you published a stub file, then you also need to rename it from `stubs/action.stub` to `stubs/deploy-operation.stub` +and make changes to its structure. diff --git a/docs/prologue/upgrade-guide/index.md b/docs/prologue/upgrade-guide/index.md index b9826d62..024262d9 100644 --- a/docs/prologue/upgrade-guide/index.md +++ b/docs/prologue/upgrade-guide/index.md @@ -1,5 +1,6 @@ # Upgrade Guide +* [Upgrading To 6.x from 5.x](6.x.md) * [Upgrading To 5.x from 4.x](5.x.md) * [Upgrading To 4.x from 3.x](4.x.md) * [Upgrading To 3.x from 2.x](3.x.md) diff --git a/ide.json b/ide.json index 0aaf6f24..208e39a1 100644 --- a/ide.json +++ b/ide.json @@ -2,17 +2,17 @@ "$schema": "https://laravel-ide.com/schema/laravel-ide-v2.json", "codeGenerations": [ { - "id": "dragon-code.create-action", - "name": "Create Action", - "inputFilter": "actions", + "id": "dragon-code.create-deploy-operation", + "name": "Create Deploy Operation", + "inputFilter": "deploy-operations", "files": [ { - "directory": "/actions", + "directory": "/operations", "name": "${CURRENT_TIME|format:yyyy_MM_dd_HHmmss}_${INPUT_CLASS|className|snakeCase}.php", "template": { "type": "stub", - "path": "/stubs/action.stub", - "fallbackPath": "resources/stubs/action.stub" + "path": "/stubs/deploy-operation.stub", + "fallbackPath": "resources/stubs/deploy-operation.stub" } } ] diff --git a/resources/stubs/action.stub b/resources/stubs/action.stub deleted file mode 100644 index 303c3a5b..00000000 --- a/resources/stubs/action.stub +++ /dev/null @@ -1,17 +0,0 @@ -hasIsolateOption() ? (int) $this->option(Options::ISOLATED) : false; + return $this->hasIsolateOption() ? (int) $this->option(Options::Isolated) : false; } protected function hasIsolateOption(): bool { - return $this->hasOption(Options::ISOLATED) && $this->option(Options::ISOLATED); + return $this->hasOption(Options::Isolated) && $this->option(Options::Isolated); } } diff --git a/src/Concerns/Optionable.php b/src/Concerns/Optionable.php index dbfb7427..bd283308 100644 --- a/src/Concerns/Optionable.php +++ b/src/Concerns/Optionable.php @@ -2,25 +2,25 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Concerns; +namespace DragonCode\LaravelDeployOperations\Concerns; -use DragonCode\LaravelActions\Constants\Options; +use DragonCode\LaravelDeployOperations\Constants\Options; use DragonCode\Support\Facades\Helpers\Arr; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use function in_array; -/** @mixin \DragonCode\LaravelActions\Console\Command */ +/** @mixin \DragonCode\LaravelDeployOperations\Console\Command */ trait Optionable { protected array $arguments = []; protected array $options = [ - Options::CONNECTION, - Options::FORCE, - Options::MUTE, - Options::ISOLATED, + Options::Connection, + Options::Force, + Options::Mute, + Options::Isolated, ]; protected function configure(): void @@ -45,22 +45,69 @@ protected function getArguments(): array protected function availableOptions(): array { return [ - [Options::BEFORE, null, InputOption::VALUE_NONE, 'Run actions marked as before'], - [Options::CONNECTION, null, InputOption::VALUE_OPTIONAL, 'The database connection to use'], - [Options::FORCE, null, InputOption::VALUE_NONE, 'Force the operation to run when in production'], - [Options::PATH, null, InputOption::VALUE_OPTIONAL, 'The path to the actions files to be executed'], - [Options::REALPATH, null, InputOption::VALUE_NONE, 'Indicate any provided action file paths are pre-resolved absolute path'], - [Options::STEP, null, InputOption::VALUE_OPTIONAL, 'Force the actions to be run so they can be rolled back individually'], - [Options::MUTE, null, InputOption::VALUE_NONE, 'Turns off the output of informational messages'], - [Options::ISOLATED, null, InputOption::VALUE_OPTIONAL, 'Do not run the actions command if another instance of the actions command is already running', false], - [Options::SYNC, null, InputOption::VALUE_OPTIONAL, 'Makes all actions run synchronously', false], + [ + Options::Before, + null, + InputOption::VALUE_NONE, + 'Run operations marked as before', + ], + [ + Options::Connection, + null, + InputOption::VALUE_OPTIONAL, + 'The database connection to use', + ], + [ + Options::Force, + null, + InputOption::VALUE_NONE, + 'Force the operation to run when in production', + ], + [ + Options::Path, + null, + InputOption::VALUE_OPTIONAL, + 'The path to the operations files to be executed', + ], + [ + Options::Realpath, + null, + InputOption::VALUE_NONE, + 'Indicate any provided operation file paths are pre-resolved absolute path', + ], + [ + Options::Step, + null, + InputOption::VALUE_OPTIONAL, + 'Force the operations to be run so they can be rolled back individually', + ], + [ + Options::Mute, + null, + InputOption::VALUE_NONE, + 'Turns off the output of informational messages', + ], + [ + Options::Isolated, + null, + InputOption::VALUE_OPTIONAL, + 'Do not run the operations command if another instance of the operations command is already running', + false, + ], + [ + Options::Sync, + null, + InputOption::VALUE_OPTIONAL, + 'Makes all operations run synchronously', + false, + ], ]; } protected function availableArguments(): array { return [ - [Options::NAME, InputArgument::OPTIONAL, 'The name of the action'], + [Options::Name, InputArgument::OPTIONAL, 'The name of the operation'], ]; } } diff --git a/src/Console/Actions.php b/src/Console/Actions.php deleted file mode 100644 index 373a8502..00000000 --- a/src/Console/Actions.php +++ /dev/null @@ -1,29 +0,0 @@ -config->get('actions.connection'); + return $this->config->get('deploy-operations.connection'); } public function table(): string { - return $this->config->get('actions.table'); + return $this->config->get('deploy-operations.table'); } public function exclude(): array { - return Arr::of((array) $this->config->get('actions.exclude')) + return Arr::of((array) $this->config->get('deploy-operations.exclude')) ->map(fn (string $path) => str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path)) ->filter() ->toArray(); @@ -53,6 +53,6 @@ public function gitPath(): string protected function directory(): string { - return $this->config->get('actions.path', base_path('actions')); + return $this->config->get('deploy-operations.path', base_path('operations')); } } diff --git a/src/Helpers/Git.php b/src/Helpers/Git.php index 7780ebac..df042b1e 100644 --- a/src/Helpers/Git.php +++ b/src/Helpers/Git.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Helpers; +namespace DragonCode\LaravelDeployOperations\Helpers; use DragonCode\Support\Facades\Filesystem\Directory; diff --git a/src/Helpers/Sorter.php b/src/Helpers/Sorter.php index 80fb4415..1a755a25 100644 --- a/src/Helpers/Sorter.php +++ b/src/Helpers/Sorter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Helpers; +namespace DragonCode\LaravelDeployOperations\Helpers; use Closure; use DragonCode\Support\Facades\Filesystem\Path; @@ -22,9 +22,9 @@ public function byKeys(array $items): array return Arr::ksort($items, $this->callback()); } - public function byRan(array $actions, array $completed): array + public function byRan(array $values, array $completed): array { - foreach ($actions as $value) { + foreach ($values as $value) { if (! in_array($value, $completed, true)) { $completed[] = $value; } diff --git a/src/Jobs/ActionJob.php b/src/Jobs/OperationJob.php similarity index 63% rename from src/Jobs/ActionJob.php rename to src/Jobs/OperationJob.php index 5c7f7cc4..425b937c 100644 --- a/src/Jobs/ActionJob.php +++ b/src/Jobs/OperationJob.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Jobs; +namespace DragonCode\LaravelDeployOperations\Jobs; -use DragonCode\LaravelActions\Constants\Names; -use DragonCode\LaravelActions\Constants\Options; +use DragonCode\LaravelDeployOperations\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Options; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,7 +16,7 @@ use function config; -class ActionJob implements ShouldBeUnique, ShouldQueue +class OperationJob implements ShouldBeUnique, ShouldQueue { use Dispatchable; use InteractsWithQueue; @@ -32,9 +32,9 @@ public function __construct( public function handle(): void { - Artisan::call(Names::ACTIONS, [ - '--' . Options::PATH => $this->filename, - '--' . Options::SYNC => true, + Artisan::call(Names::Operations, [ + '--' . Options::Path => $this->filename, + '--' . Options::Sync => true, ]); } @@ -45,11 +45,11 @@ public function uniqueId(): string protected function setQueueConnection(): void { - $this->onConnection(config('actions.queue.connection')); + $this->onConnection(config('deploy-operations.queue.connection')); } protected function setQueueName(): void { - $this->onQueue(config('actions.queue.name')); + $this->onQueue(config('deploy-operations.queue.name')); } } diff --git a/src/Notifications/Beautiful.php b/src/Notifications/Beautiful.php deleted file mode 100644 index 74fa9faf..00000000 --- a/src/Notifications/Beautiful.php +++ /dev/null @@ -1,57 +0,0 @@ -canSpeak()) { - $this->components()->line($style, $string, $this->verbosity); - } - } - - public function info(string $string): void - { - if ($this->canSpeak()) { - $this->components()->info($string, $this->verbosity); - } - } - - public function warning(string $string): void - { - if ($this->canSpeak()) { - $this->components()->warn($string, $this->verbosity); - } - } - - public function task(string $description, Closure $task): void - { - if ($this->canSpeak()) { - $this->components()->task($description, $task); - - return; - } - - $task(); - } - - public function twoColumn(string $first, string $second): void - { - if ($this->canSpeak()) { - $this->components()->twoColumnDetail($first, $second, $this->verbosity); - } - } - - protected function components(): Factory - { - return $this->components ??= new Factory($this->output); - } -} diff --git a/src/Notifications/Notification.php b/src/Notifications/Notification.php index ee181712..91469f76 100644 --- a/src/Notifications/Notification.php +++ b/src/Notifications/Notification.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Notifications; +namespace DragonCode\LaravelDeployOperations\Notifications; use Closure; -use DragonCode\LaravelActions\Contracts\Notification as NotificationContract; use Illuminate\Console\OutputStyle; +use Illuminate\Console\View\Components\Factory; use Symfony\Component\Console\Output\OutputInterface; -abstract class Notification implements NotificationContract +class Notification { protected ?OutputStyle $output = null; @@ -17,17 +17,53 @@ abstract class Notification implements NotificationContract protected int $verbosity = OutputInterface::VERBOSITY_NORMAL; - abstract public function line(string $string, ?string $style = null): void; + protected ?Factory $components = null; - abstract public function info(string $string): void; + public function line(string $string, ?string $style = null): void + { + if ($this->canSpeak()) { + $this->components()->line($style, $string, $this->verbosity); + } + } + + public function info(string $string): void + { + if ($this->canSpeak()) { + $this->components()->info($string, $this->verbosity); + } + } + + public function warning(string $string): void + { + if ($this->canSpeak()) { + $this->components()->warn($string, $this->verbosity); + } + } - abstract public function warning(string $string): void; + public function task(string $description, Closure $task): void + { + if ($this->canSpeak()) { + $this->components()->task($description, $task); + + return; + } + + $task(); + } - abstract public function task(string $description, Closure $task): void; + public function twoColumn(string $first, string $second): void + { + if ($this->canSpeak()) { + $this->components()->twoColumnDetail($first, $second, $this->verbosity); + } + } - abstract public function twoColumn(string $first, string $second): void; + protected function components(): Factory + { + return $this->components ??= new Factory($this->output); + } - public function setOutput(OutputStyle $output, bool $silent = false): NotificationContract + public function setOutput(OutputStyle $output, bool $silent = false): Notification { $this->output = $output; $this->silent = $silent; diff --git a/src/Action.php b/src/Operation.php similarity index 73% rename from src/Action.php rename to src/Operation.php index 37423fe7..c127703a 100644 --- a/src/Action.php +++ b/src/Operation.php @@ -1,20 +1,20 @@ drop(); - $this->actions(); + $this->operations(); } protected function drop(): void { if ($this->repository->repositoryExists()) { - $this->notification->task('Dropping all actions', fn () => $this->repository->deleteRepository()); + $this->notification->task('Dropping all operations', fn () => $this->repository->deleteRepository()); } } - protected function actions(): void + protected function operations(): void { - $this->runCommand(Names::ACTIONS, [ - '--' . Options::CONNECTION => $this->options->connection, - '--' . Options::PATH => $this->options->path, - '--' . Options::REALPATH => true, + $this->runCommand(Names::Operations, [ + '--' . Options::Connection => $this->options->connection, + '--' . Options::Path => $this->options->path, + '--' . Options::Realpath => true, ]); } } diff --git a/src/Processors/Install.php b/src/Processors/Install.php index f951b54f..5767a07f 100644 --- a/src/Processors/Install.php +++ b/src/Processors/Install.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; use DragonCode\Support\Facades\Filesystem\Directory; use DragonCode\Support\Facades\Filesystem\Path; @@ -13,12 +13,12 @@ class Install extends Processor public function handle(): void { if ($this->exists()) { - $this->notification->info('Actions repository already exists'); + $this->notification->info('Operations repository already exists'); return; } - $this->notification->task('Installing the action repository', function () { + $this->notification->task('Installing the operation repository', function () { $this->create(); $this->ensureDirectory(); }); diff --git a/src/Processors/Make.php b/src/Processors/Make.php index 4008b214..9d2f31a7 100644 --- a/src/Processors/Make.php +++ b/src/Processors/Make.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; use DragonCode\Support\Facades\Filesystem\File; use DragonCode\Support\Facades\Filesystem\Path; @@ -16,11 +16,11 @@ class Make extends Processor { protected string $fallback = 'auto'; - protected string $defaultStub = __DIR__ . '/../../resources/stubs/action.stub'; + protected string $defaultStub = __DIR__ . '/../../resources/stubs/deploy-operation.stub'; public function handle(): void { - $this->notification->task('Creating an action', fn () => $this->run()); + $this->notification->task('Creating an operation', fn () => $this->run()); } protected function run(): void @@ -68,7 +68,7 @@ protected function getTime(): string protected function stubPath(): string { - if ($path = realpath(base_path('stubs/action.stub'))) { + if ($path = realpath(base_path('stubs/deploy-operation.stub'))) { return $path; } diff --git a/src/Processors/Actions.php b/src/Processors/Operations.php similarity index 52% rename from src/Processors/Actions.php rename to src/Processors/Operations.php index 50042a71..7128612a 100644 --- a/src/Processors/Actions.php +++ b/src/Processors/Operations.php @@ -2,57 +2,57 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; - -use DragonCode\LaravelActions\Constants\Names; -use DragonCode\LaravelActions\Constants\Options; -use DragonCode\LaravelActions\Events\ActionEnded; -use DragonCode\LaravelActions\Events\ActionFailed; -use DragonCode\LaravelActions\Events\ActionStarted; -use DragonCode\LaravelActions\Events\NoPendingActions; +namespace DragonCode\LaravelDeployOperations\Processors; + +use DragonCode\LaravelDeployOperations\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Options; +use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded; +use DragonCode\LaravelDeployOperations\Events\DeployOperationFailed; +use DragonCode\LaravelDeployOperations\Events\DeployOperationStarted; +use DragonCode\LaravelDeployOperations\Events\NoPendingDeployOperations; use DragonCode\Support\Facades\Helpers\Str; use Throwable; -class Actions extends Processor +class Operations extends Processor { public function handle(): void { $this->showCaption(); $this->ensureRepository(); - $this->runActions($this->getCompleted()); + $this->runOperations($this->getCompleted()); } protected function showCaption(): void { - $this->notification->info('Running actions'); + $this->notification->info('Running operations'); } protected function ensureRepository(): void { - $this->runCommand(Names::INSTALL, [ - '--' . Options::CONNECTION => $this->options->connection, - '--' . Options::FORCE => true, - '--' . Options::MUTE => true, + $this->runCommand(Names::Install, [ + '--' . Options::Connection => $this->options->connection, + '--' . Options::Force => true, + '--' . Options::Mute => true, ]); } - protected function runActions(array $completed): void + protected function runOperations(array $completed): void { try { if ($files = $this->getNewFiles($completed)) { - $this->fireEvent(ActionStarted::class, 'up'); + $this->fireEvent(DeployOperationStarted::class, 'up'); $this->runEach($files, $this->getBatch()); - $this->fireEvent(ActionEnded::class, 'up'); + $this->fireEvent(DeployOperationEnded::class, 'up'); return; } - $this->fireEvent(NoPendingActions::class, 'up'); + $this->fireEvent(NoPendingDeployOperations::class, 'up'); } catch (Throwable $e) { - $this->fireEvent(ActionFailed::class, 'up'); + $this->fireEvent(DeployOperationFailed::class, 'up'); throw $e; } @@ -80,7 +80,7 @@ protected function getNewFiles(array $completed): array protected function getCompleted(): array { - return $this->repository->getCompleted()->pluck('action')->toArray(); + return $this->repository->getCompleted()->pluck('operation')->all(); } protected function getBatch(): int diff --git a/src/Processors/Processor.php b/src/Processors/Processor.php index 8bf86962..dbcc1a3e 100644 --- a/src/Processors/Processor.php +++ b/src/Processors/Processor.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; use Closure; -use DragonCode\LaravelActions\Concerns\Artisan; -use DragonCode\LaravelActions\Contracts\Notification; -use DragonCode\LaravelActions\Helpers\Config; -use DragonCode\LaravelActions\Helpers\Git; -use DragonCode\LaravelActions\Helpers\Sorter; -use DragonCode\LaravelActions\Repositories\ActionRepository; -use DragonCode\LaravelActions\Services\Migrator; -use DragonCode\LaravelActions\Values\Options; +use DragonCode\LaravelDeployOperations\Concerns\Artisan; +use DragonCode\LaravelDeployOperations\Helpers\Config; +use DragonCode\LaravelDeployOperations\Helpers\Git; +use DragonCode\LaravelDeployOperations\Helpers\Sorter; +use DragonCode\LaravelDeployOperations\Notifications\Notification; +use DragonCode\LaravelDeployOperations\Repositories\OperationsRepository; +use DragonCode\LaravelDeployOperations\Services\Migrator; +use DragonCode\LaravelDeployOperations\Values\Options; use DragonCode\Support\Facades\Helpers\Arr; use DragonCode\Support\Facades\Helpers\Str; use DragonCode\Support\Filesystem\File; @@ -33,7 +33,7 @@ public function __construct( protected InputInterface $input, protected OutputStyle $output, protected Config $config, - protected ActionRepository $repository, + protected OperationsRepository $repository, protected Git $git, protected File $file, protected Migrator $migrator, @@ -52,7 +52,10 @@ protected function getFiles(string $path, ?Closure $filter = null): array $files = $this->isFile($file) ? [$file] : $this->file->names($path, $filter, true); - $files = Arr::filter($files, fn (string $path) => Str::endsWith($path, '.php') && ! Str::contains($path, $this->config->exclude())); + $files = Arr::filter( + $files, + fn (string $path) => Str::endsWith($path, '.php') && ! Str::contains($path, $this->config->exclude()) + ); return Arr::of($this->sorter->byValues($files)) ->map(fn (string $value) => Str::before($value, '.php')) @@ -67,7 +70,7 @@ protected function runCommand(string $command, array $options = []): void protected function tableNotFound(): bool { if (! $this->repository->repositoryExists()) { - $this->notification->warning('Actions table not found'); + $this->notification->warning('Deploy operations table not found'); return true; } diff --git a/src/Processors/Refresh.php b/src/Processors/Refresh.php index 742a3048..a14773b4 100644 --- a/src/Processors/Refresh.php +++ b/src/Processors/Refresh.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; -use DragonCode\LaravelActions\Constants\Names; -use DragonCode\LaravelActions\Constants\Options; +use DragonCode\LaravelDeployOperations\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Options; class Refresh extends Processor { @@ -15,25 +15,25 @@ public function handle(): void $path = $this->options->path; $this->runReset($connection, $path); - $this->runActions($connection, $path); + $this->runOperations($connection, $path); } protected function runReset(?string $connection, ?string $path, bool $realPath = true): void { - $this->runCommand(Names::RESET, [ - '--' . Options::CONNECTION => $connection, - '--' . Options::PATH => $path, - '--' . Options::REALPATH => $realPath, - '--' . Options::FORCE => true, + $this->runCommand(Names::Reset, [ + '--' . Options::Connection => $connection, + '--' . Options::Path => $path, + '--' . Options::Realpath => $realPath, + '--' . Options::Force => true, ]); } - protected function runActions(?string $connection, ?string $path, bool $realPath = true): void + protected function runOperations(?string $connection, ?string $path, bool $realPath = true): void { - $this->runCommand(Names::ACTIONS, [ - '--' . Options::CONNECTION => $connection, - '--' . Options::PATH => $path, - '--' . Options::REALPATH => $realPath, + $this->runCommand(Names::Operations, [ + '--' . Options::Connection => $connection, + '--' . Options::Path => $path, + '--' . Options::Realpath => $realPath, ]); } } diff --git a/src/Processors/Reset.php b/src/Processors/Reset.php index 19f3e20c..53c51df9 100644 --- a/src/Processors/Reset.php +++ b/src/Processors/Reset.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; -use DragonCode\LaravelActions\Constants\Names; -use DragonCode\LaravelActions\Constants\Options; +use DragonCode\LaravelDeployOperations\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Options; class Reset extends Processor { @@ -20,12 +20,12 @@ public function handle(): void protected function rollback(?string $connection, ?string $path, int $step): void { - $this->runCommand(Names::ROLLBACK, [ - '--' . Options::CONNECTION => $connection, - '--' . Options::PATH => $path, - '--' . Options::REALPATH => true, - '--' . Options::STEP => $step, - '--' . Options::FORCE => true, + $this->runCommand(Names::Rollback, [ + '--' . Options::Connection => $connection, + '--' . Options::Path => $path, + '--' . Options::Realpath => true, + '--' . Options::Step => $step, + '--' . Options::Force => true, ]); } diff --git a/src/Processors/Rollback.php b/src/Processors/Rollback.php index ff45af97..fea8ed24 100644 --- a/src/Processors/Rollback.php +++ b/src/Processors/Rollback.php @@ -2,58 +2,58 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; -use DragonCode\LaravelActions\Events\ActionEnded; -use DragonCode\LaravelActions\Events\ActionStarted; -use DragonCode\LaravelActions\Events\NoPendingActions; +use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded; +use DragonCode\LaravelDeployOperations\Events\DeployOperationStarted; +use DragonCode\LaravelDeployOperations\Events\NoPendingDeployOperations; class Rollback extends Processor { public function handle(): void { if ($this->tableNotFound() || $this->nothingToRollback()) { - $this->fireEvent(NoPendingActions::class, 'down'); + $this->fireEvent(NoPendingDeployOperations::class, 'down'); return; } - if ($actions = $this->getActions($this->options->step)) { - $this->fireEvent(ActionStarted::class, 'down'); + if ($items = $this->getOperations($this->options->step)) { + $this->fireEvent(DeployOperationStarted::class, 'down'); $this->showCaption(); - $this->run($actions); + $this->run($items); - $this->fireEvent(ActionEnded::class, 'down'); + $this->fireEvent(DeployOperationEnded::class, 'down'); return; } - $this->fireEvent(NoPendingActions::class, 'down'); + $this->fireEvent(NoPendingDeployOperations::class, 'down'); } protected function showCaption(): void { - $this->notification->info('Rollback Actions'); + $this->notification->info('Rollback Operations'); } - protected function run(array $actions): void + protected function run(array $rows): void { - foreach ($actions as $row) { - $this->rollbackAction($row->action); + foreach ($rows as $row) { + $this->rollback($row->operation); } } - protected function getActions(?int $step): array + protected function getOperations(?int $step): array { return (int) $step > 0 ? $this->repository->getByStep($step) : $this->repository->getLast(); } - protected function rollbackAction(string $action): void + protected function rollback(string $item): void { - $this->migrator->runDown($action, $this->options); + $this->migrator->runDown($item, $this->options); } protected function nothingToRollback(): bool diff --git a/src/Processors/Status.php b/src/Processors/Status.php index 1922bdb9..7277cefb 100644 --- a/src/Processors/Status.php +++ b/src/Processors/Status.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; use DragonCode\Support\Facades\Helpers\Arr; @@ -10,7 +10,7 @@ class Status extends Processor { - protected string $columnName = 'Action name'; + protected string $columnName = 'Operation name'; protected string $columnStatus = 'Batch / Status'; @@ -27,7 +27,7 @@ public function handle(): void [$files, $completed] = $this->getData(); if ($this->isEmpty($files, $completed)) { - $this->notification->info('No actions found'); + $this->notification->info('No operations found'); return; } @@ -47,18 +47,18 @@ protected function showHeaders(): void $this->notification->twoColumn($this->columnName, $this->columnStatus); } - protected function showStatus(array $actions, array $completed): void + protected function showStatus(array $items, array $completed): void { - foreach ($this->merge($actions, array_keys($completed)) as $action) { - $status = $this->getStatusFor($completed, $action); + foreach ($this->merge($items, array_keys($completed)) as $item) { + $status = $this->getStatusFor($completed, $item); - $this->notification->twoColumn($action, $status); + $this->notification->twoColumn($item, $status); } } - protected function merge(array $actions, array $completed): array + protected function merge(array $items, array $completed): array { - return $this->sorter->byRan($actions, $completed); + return $this->sorter->byRan($items, $completed); } protected function getData(): array @@ -69,9 +69,9 @@ protected function getData(): array return [$files, $completed]; } - protected function getStatusFor(array $completed, string $action): string + protected function getStatusFor(array $completed, string $item): string { - if ($batch = Arr::get($completed, $action)) { + if ($batch = Arr::get($completed, $item)) { return sprintf('[%s] %s', $batch, $this->statusRan); } @@ -81,12 +81,12 @@ protected function getStatusFor(array $completed, string $action): string protected function getCompleted(): array { return $this->repository->getCompleted() - ->pluck('batch', 'action') - ->toArray(); + ->pluck('batch', 'operation') + ->all(); } - protected function isEmpty(array $actions, array $completed): bool + protected function isEmpty(array $items, array $completed): bool { - return empty($actions) && empty($completed); + return empty($items) && empty($completed); } } diff --git a/src/Processors/StubPublish.php b/src/Processors/StubPublish.php index 3eacfec0..71fe85dc 100644 --- a/src/Processors/StubPublish.php +++ b/src/Processors/StubPublish.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; use DragonCode\Support\Facades\Filesystem\File; @@ -10,7 +10,7 @@ class StubPublish extends Processor { - protected string $stub = __DIR__ . '/../../resources/stubs/action.stub'; + protected string $stub = __DIR__ . '/../../resources/stubs/deploy-operation.stub'; public function handle(): void { @@ -36,6 +36,6 @@ protected function doesntExist(): bool protected function path(): string { - return base_path('stubs/action.stub'); + return base_path('stubs/deploy-operation.stub'); } } diff --git a/src/Processors/Upgrade.php b/src/Processors/Upgrade.php index ebbc8880..ba454f52 100644 --- a/src/Processors/Upgrade.php +++ b/src/Processors/Upgrade.php @@ -2,12 +2,182 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Processors; +namespace DragonCode\LaravelDeployOperations\Processors; + +use DragonCode\LaravelDeployOperations\ServiceProvider; +use DragonCode\Support\Facades\Filesystem\Directory; +use DragonCode\Support\Facades\Filesystem\File; +use DragonCode\Support\Facades\Helpers\Str; +use Stringable; class Upgrade extends Processor { public function handle(): void { - $this->notification->warning('When upgrading to 5 from version 4, the project files do not change.'); + if ($this->alreadyUpgraded()) { + $this->notification->info('Operations upgrade already done'); + + return; + } + + $this->run(); + } + + protected function run(): void + { + $this->moveFiles(); + $this->moveConfig(); + $this->moveStub(); + $this->callMigration(); + $this->clean(); + } + + protected function moveFiles(): void + { + foreach ($this->getOldFiles() as $filename) { + $this->notification->task($filename, fn () => $this->move( + $this->oldPath($filename . '.php'), + $this->newPath($filename . '.php') + )); + } + } + + protected function move(string $from, string $to): void + { + $content = $this->open($from); + + $content = $this->replaceNamespace($content); + $content = $this->replaceClassName($content); + $content = $this->replaceDeclareStrictType($content); + $content = $this->replaceWithInvoke($content); + + $this->store($to, $content); + } + + protected function clean(): void + { + $this->notification->task( + 'Delete old directory', + fn () => Directory::ensureDelete($this->oldPath()) + ); + } + + protected function open(string $filename): string + { + return file_get_contents($filename); + } + + protected function store(string $filename, string $content): void + { + File::store($filename, $content); + } + + protected function replaceNamespace(string $content): string + { + return Str::of($content)->replace( + ['DragonCode\\LaravelActions\\Action', 'Action'], + ['DragonCode\\LaravelDeployOperations\\Operation', 'Operation'], + )->toString(); + } + + protected function replaceClassName(string $content): string + { + return Str::of($content) + ->pregReplace( + '/((?:return\s+new\s+class\s*\(?\s*\)?|final\s+class|class)\s*.+extends\s+Action)/', + 'return new class extends Operation' + ) + ->trim() + ->trim(';') + ->append(';') + ->append(PHP_EOL) + ->toString(); + } + + protected function replaceDeclareStrictType(string $content): string + { + return Str::of($content) + ->replace('(declare\s*\(\s*strict_types\s*=\s*[1|0]\);)', '') + ->replace("toString(); + } + + protected function replaceWithInvoke(string $content): string + { + return Str::of($content) + ->when(! Str::matchContains($content, '/public\s+function\s+down/'), function (Stringable $string) { + return $string->pregReplace('/(public\s+function\s+up)/', 'public function __invoke'); + })->toString(); + } + + protected function moveConfig(): void + { + $this->notification->task('Moving config file', function () { + $this->runCommand('vendor:publish', [ + '--provider' => ServiceProvider::class, + '--force' => true, + ]); + + $path = config_path('deploy-operations.php'); + + $table = config('actions.table', 'operations'); + + $content = Str::replace(file_get_contents($path), "'table' => 'operations'", "'table' => '$table'"); + + file_put_contents($path, $content); + + File::ensureDelete(config_path('actions.php')); + }); + } + + protected function moveStub(): void + { + if (! File::exists(base_path('stubs/action.stub'))) { + $this->notification->info('Stub file doesn\'t exist.'); + + return; + } + + $this->notification->task('Moving stub file', fn () => $this->move( + base_path('stubs/action.stub'), + base_path('stubs/deploy-operation.stub'), + )); + } + + protected function callMigration(): void + { + $this->notification->task('Call migrations', function () { + $this->runCommand('migrate', [ + '--path' => __DIR__ . '/../../database/migrations/2024_05_21_112438_rename_actions_table_to_operations.php', + '--realpath' => true, + '--force' => true, + ]); + + $this->runCommand('migrate', [ + '--path' => __DIR__ . '/../../database/migrations/2024_05_21_114318_rename_column_in_operations_table', + '--realpath' => true, + '--force' => true, + ]); + }); + } + + protected function getOldFiles(): array + { + return $this->getFiles($this->oldPath()); + } + + protected function oldPath(?string $filename = null): string + { + return base_path('actions/' . $filename); + } + + protected function newPath(?string $filename = null): string + { + return $this->options->path . '/' . $filename; + } + + protected function alreadyUpgraded(): bool + { + return Directory::exists($this->newPath()); } } diff --git a/src/Repositories/ActionRepository.php b/src/Repositories/OperationsRepository.php similarity index 78% rename from src/Repositories/ActionRepository.php rename to src/Repositories/OperationsRepository.php index 3480e5e0..f9a4fb8e 100644 --- a/src/Repositories/ActionRepository.php +++ b/src/Repositories/OperationsRepository.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Repositories; +namespace DragonCode\LaravelDeployOperations\Repositories; -use DragonCode\LaravelActions\Constants\Order; -use DragonCode\LaravelActions\Helpers\Config; +use DragonCode\LaravelDeployOperations\Constants\Order; +use DragonCode\LaravelDeployOperations\Helpers\Config; use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionResolverInterface as Resolver; use Illuminate\Database\Query\Builder as Query; @@ -15,7 +15,7 @@ use function compact; -class ActionRepository +class OperationsRepository { protected ?string $connection = null; @@ -24,13 +24,6 @@ public function __construct( protected Config $config ) {} - public function setConnection(?string $connection): self - { - $this->connection = $connection; - - return $this; - } - public function getCompleted(): Collection { return $this->sortedTable()->get(); @@ -38,7 +31,7 @@ public function getCompleted(): Collection public function getByStep(int $steps): array { - return $this->sortedTable(Order::DESC) + return $this->sortedTable(Order::Desc) ->whereIn('batch', $this->getBatchNumbers($steps)) ->get() ->all(); @@ -46,7 +39,7 @@ public function getByStep(int $steps): array public function getLast(): array { - return $this->sortedTable(Order::DESC) + return $this->sortedTable(Order::Desc) ->where('batch', $this->getLastBatchNumber()) ->get() ->all(); @@ -62,14 +55,14 @@ public function getLastBatchNumber(): int return (int) $this->table()->max('batch'); } - public function log(string $action, int $batch): void + public function log(string $operation, int $batch): void { - $this->table()->insert(compact('action', 'batch')); + $this->table()->insert(compact('operation', 'batch')); } - public function delete(string $action): void + public function delete(string $operation): void { - $this->table()->where(compact('action'))->delete(); + $this->table()->where(compact('operation'))->delete(); } public function createRepository(): void @@ -77,7 +70,7 @@ public function createRepository(): void $this->schema()->create($this->config->table(), function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('action'); + $table->string('operation'); $table->unsignedInteger('batch'); }); @@ -98,14 +91,14 @@ public function deleteRepository(): void */ protected function getBatchNumbers(int $steps): array { - return $this->sortedTable(Order::DESC) + return $this->sortedTable(Order::Desc) ->pluck('batch') ->unique() ->take($steps) ->all(); } - protected function sortedTable(string $order = Order::ASC): Query + protected function sortedTable(string $order = Order::Asc): Query { return $this->table() ->orderBy('batch', $order) @@ -128,4 +121,11 @@ protected function getConnection(): ConnectionInterface $this->connection ?: $this->config->connection() ); } + + public function setConnection(?string $connection): self + { + $this->connection = $connection; + + return $this; + } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index e9f4bc36..efed0ffb 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -2,11 +2,9 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions; +namespace DragonCode\LaravelDeployOperations; -use DragonCode\LaravelActions\Concerns\About; -use DragonCode\LaravelActions\Contracts\Notification; -use DragonCode\LaravelActions\Notifications\Beautiful; +use DragonCode\LaravelDeployOperations\Concerns\About; use Illuminate\Support\ServiceProvider as BaseServiceProvider; class ServiceProvider extends BaseServiceProvider @@ -21,7 +19,6 @@ public function boot(): void $this->registerAbout(); $this->registerCommands(); $this->registerMigrations(); - $this->registerNotifications(); } } @@ -33,7 +30,7 @@ public function register(): void protected function registerCommands(): void { $this->commands([ - Console\Actions::class, + Console\Operations::class, Console\Fresh::class, Console\Install::class, Console\Make::class, @@ -51,20 +48,15 @@ protected function registerMigrations(): void $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); } - protected function registerNotifications(): void - { - $this->app->bind(Notification::class, Beautiful::class); - } - protected function publishConfig(): void { $this->publishes([ - __DIR__ . '/../config/actions.php' => $this->app->configPath('actions.php'), + __DIR__ . '/../config/deploy-operations.php' => $this->app->configPath('deploy-operations.php'), ], 'config'); } protected function registerConfig(): void { - $this->mergeConfigFrom(__DIR__ . '/../config/actions.php', 'actions'); + $this->mergeConfigFrom(__DIR__ . '/../config/deploy-operations.php', 'deploy-operations'); } } diff --git a/src/Services/Migrator.php b/src/Services/Migrator.php index d37ee927..0eb31c69 100644 --- a/src/Services/Migrator.php +++ b/src/Services/Migrator.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Services; - -use DragonCode\LaravelActions\Action; -use DragonCode\LaravelActions\Contracts\Notification; -use DragonCode\LaravelActions\Helpers\Config; -use DragonCode\LaravelActions\Jobs\ActionJob; -use DragonCode\LaravelActions\Repositories\ActionRepository; -use DragonCode\LaravelActions\Values\Options; +namespace DragonCode\LaravelDeployOperations\Services; + +use DragonCode\LaravelDeployOperations\Helpers\Config; +use DragonCode\LaravelDeployOperations\Jobs\OperationJob; +use DragonCode\LaravelDeployOperations\Notifications\Notification; +use DragonCode\LaravelDeployOperations\Operation; +use DragonCode\LaravelDeployOperations\Repositories\OperationsRepository; +use DragonCode\LaravelDeployOperations\Values\Options; use DragonCode\Support\Exceptions\FileNotFoundException; use DragonCode\Support\Facades\Helpers\Str; use DragonCode\Support\Filesystem\File; @@ -27,7 +27,7 @@ class Migrator public function __construct( protected File $file, protected Notification $notification, - protected ActionRepository $repository, + protected OperationsRepository $repository, protected Config $config, protected Container $container ) {} @@ -48,28 +48,28 @@ public function setOutput(OutputStyle $output): self public function runUp(string $filename, int $batch, Options $options): void { - $path = $this->resolvePath($filename, $options->path); - $action = $this->resolveAction($path); - $name = $this->resolveActionName($path); + $path = $this->resolvePath($filename, $options->path); + $operation = $this->resolveOperation($path); + $name = $this->resolveOperationName($path); - if (! $this->allowAction($action, $options)) { + if (! $this->allowOperation($operation, $options)) { $this->notification->twoColumn($name, 'SKIPPED'); return; } - if ($this->hasAsync($action, $options)) { - ActionJob::dispatch($name); + if ($this->hasAsync($operation, $options)) { + OperationJob::dispatch($name); return; } - $this->notification->task($name, function () use ($action, $name, $batch) { - $this->hasAction($action, '__invoke') - ? $this->runAction($action, '__invoke') - : $this->runAction($action, 'up'); + $this->notification->task($name, function () use ($operation, $name, $batch) { + $this->hasOperation($operation, '__invoke') + ? $this->runOperation($operation, '__invoke') + : $this->runOperation($operation, 'up'); - if ($this->allowLogging($action)) { + if ($this->allowLogging($operation)) { $this->log($name, $batch); } }); @@ -77,45 +77,50 @@ public function runUp(string $filename, int $batch, Options $options): void public function runDown(string $filename, Options $options): void { - $path = $this->resolvePath($filename, $options->path); - $action = $this->resolveAction($path); - $name = $this->resolveActionName($path); + $path = $this->resolvePath($filename, $options->path); + $operation = $this->resolveOperation($path); + $name = $this->resolveOperationName($path); - $this->notification->task($name, function () use ($action, $name) { - $this->runAction($action, 'down'); + $this->notification->task($name, function () use ($operation, $name) { + $this->runOperation($operation, 'down'); $this->deleteLog($name); }); } - protected function runAction(Action $action, string $method): void + protected function runOperation(Operation $operation, string $method): void { - if ($this->hasAction($action, $method)) { + if ($this->hasOperation($operation, $method)) { try { - $this->runMethod($action, $method, $action->enabledTransactions(), $action->transactionAttempts()); - - $action->success(); + $this->runMethod( + $operation, + $method, + $operation->enabledTransactions(), + $operation->transactionAttempts() + ); + + $operation->success(); } catch (Throwable $e) { - $action->failed(); + $operation->failed(); throw $e; } } } - protected function hasAction(Action $action, string $method): bool + protected function hasOperation(Operation $operation, string $method): bool { - return method_exists($action, $method); + return method_exists($operation, $method); } - protected function hasAsync(Action $action, Options $options): bool + protected function hasAsync(Operation $operation, Options $options): bool { - return ! $options->sync && $action->isAsync(); + return ! $options->sync && $operation->isAsync(); } - protected function runMethod(Action $action, string $method, bool $transactions, int $attempts): void + protected function runMethod(Operation $operation, string $method, bool $transactions, int $attempts): void { - $callback = fn () => $this->container->call([$action, $method]); + $callback = fn () => $this->container->call([$operation, $method]); $transactions ? DB::transaction($callback, $attempts) : $callback(); } @@ -130,22 +135,22 @@ protected function deleteLog(string $name): void $this->repository->delete($name); } - protected function allowAction(Action $action, Options $options): bool + protected function allowOperation(Operation $operation, Options $options): bool { - if (! $this->allowEnvironment($action)) { + if (! $this->allowEnvironment($operation)) { return false; } - return ! $this->disallowBefore($action, $options); + return ! $this->disallowBefore($operation, $options); } - protected function allowEnvironment(Action $action): bool + protected function allowEnvironment(Operation $operation): bool { $env = $this->config->environment(); - return $action->allow() - && $this->onEnvironment($env, $action->onEnvironment()) - && $this->exceptEnvironment($env, $action->exceptEnvironment()); + return $operation->allow() + && $this->onEnvironment($env, $operation->onEnvironment()) + && $this->exceptEnvironment($env, $operation->exceptEnvironment()); } protected function onEnvironment(?string $env, array $on): bool @@ -158,14 +163,14 @@ protected function exceptEnvironment(?string $env, array $except): bool return empty($except) || ! in_array($env, $except); } - protected function disallowBefore(Action $action, Options $options): bool + protected function disallowBefore(Operation $operation, Options $options): bool { - return $options->before && ! $action->hasBefore(); + return $options->before && ! $operation->hasBefore(); } - protected function allowLogging(Action $action): bool + protected function allowLogging(Operation $operation): bool { - return $action->isOnce(); + return $operation->isOnce(); } protected function resolvePath(string $filename, string $path): string @@ -179,7 +184,7 @@ protected function resolvePath(string $filename, string $path): string return Str::finish($path . DIRECTORY_SEPARATOR . $filename, '.php'); } - protected function resolveAction(string $path): Action + protected function resolveOperation(string $path): Operation { if ($this->file->exists($path)) { return require $path; @@ -188,7 +193,7 @@ protected function resolveAction(string $path): Action throw new FileNotFoundException($path); } - protected function resolveActionName(string $path): string + protected function resolveOperationName(string $path): string { return Str::of(realpath($path)) ->after(realpath($this->config->path()) . DIRECTORY_SEPARATOR) diff --git a/src/Services/Mutex.php b/src/Services/Mutex.php index 15ba0e16..5ad42c4e 100644 --- a/src/Services/Mutex.php +++ b/src/Services/Mutex.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Services; +namespace DragonCode\LaravelDeployOperations\Services; use Carbon\CarbonInterval; -use DragonCode\LaravelActions\Console\Command; +use DragonCode\LaravelDeployOperations\Console\Command; use Illuminate\Contracts\Cache\Factory as Cache; use Illuminate\Contracts\Cache\Repository; @@ -41,6 +41,6 @@ protected function ttl(): CarbonInterval protected function name(Command $command): string { - return 'framework' . DIRECTORY_SEPARATOR . 'action-' . $command->getName(); + return 'framework' . DIRECTORY_SEPARATOR . 'deploy-operation-' . $command->getName(); } } diff --git a/src/Values/Options.php b/src/Values/Options.php index 3d8a88b9..77d76f6b 100644 --- a/src/Values/Options.php +++ b/src/Values/Options.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace DragonCode\LaravelActions\Values; +namespace DragonCode\LaravelDeployOperations\Values; -use DragonCode\LaravelActions\Helpers\Config; +use DragonCode\LaravelDeployOperations\Helpers\Config; use DragonCode\SimpleDataTransferObject\DataTransferObject; use DragonCode\Support\Facades\Helpers\Boolean; use DragonCode\Support\Facades\Helpers\Str; diff --git a/tests/Commands/ActionsTest.php b/tests/Commands/ActionsTest.php deleted file mode 100644 index 56012ef2..00000000 --- a/tests/Commands/ActionsTest.php +++ /dev/null @@ -1,747 +0,0 @@ -assertDatabaseDoesntTable($this->table); - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseHasTable($this->table); - $this->assertDatabaseCount($this->table, 0); - - $this->artisan(Names::MAKE, ['name' => 'TestMigration'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'test_migration'); - } - - public function testSameName() - { - $this->assertDatabaseDoesntTable($this->table); - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseHasTable($this->table); - $this->assertDatabaseCount($this->table, 0); - - $this->artisan(Names::MAKE, ['name' => 'TestMigration'])->assertExitCode(0); - - sleep(2); - - $this->artisan(Names::MAKE, ['name' => 'TestMigration'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($this->table, 2); - $this->assertDatabaseActionHas($this->table, 'test_migration'); - } - - public function testOnce() - { - $this->copyFiles(); - - $table = 'every_time'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 3); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 4); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, $table); - } - - public function testSuccessTransaction() - { - $this->copySuccessTransaction(); - - $table = 'transactions'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 3); - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, $table); - } - - public function testFailedTransaction() - { - $this->copyFailedTransaction(); - - $table = 'transactions'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - - try { - $this->artisan(Names::ACTIONS)->assertExitCode(0); - } - catch (Exception $e) { - $this->assertSame(Exception::class, get_class($e)); - $this->assertSame('Random message', $e->getMessage()); - } - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - } - - public function testSingleEnvironment() - { - $this->copyFiles(); - - $table = 'environment'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_testing'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 5); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionHas($this->table, 'run_on_testing'); - $this->assertDatabaseActionHas($this->table, 'run_except_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_testing'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 5); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionHas($this->table, 'run_on_testing'); - $this->assertDatabaseActionHas($this->table, 'run_except_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_testing'); - } - - public function testManyEnvironments() - { - $this->copyFiles(); - - $table = 'environment'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_many_environments'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_many_environments'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 5); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionHas($this->table, 'run_on_testing'); - $this->assertDatabaseActionHas($this->table, 'run_on_many_environments'); - $this->assertDatabaseActionHas($this->table, 'run_except_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_many_environments'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 5); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionHas($this->table, 'run_on_testing'); - $this->assertDatabaseActionHas($this->table, 'run_on_many_environments'); - $this->assertDatabaseActionHas($this->table, 'run_except_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_except_many_environments'); - } - - public function testAllow() - { - $this->copyFiles(); - - $table = 'environment'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_allow'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_disallow'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 5); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_allow'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_disallow'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 5); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_allow'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_disallow'); - } - - public function testUpSuccess() - { - $this->copyFiles(); - - $table = 'success'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_success'); - } - - public function testUpSuccessOnFailed() - { - $this->copyFiles(); - - $table = 'success'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed'); - - try { - $this->copySuccessFailureMethod(); - - $this->artisan(Names::ACTIONS)->assertExitCode(0); - } - catch (Throwable $e) { - $this->assertInstanceOf(Exception::class, $e); - - $this->assertSame('Custom exception', $e->getMessage()); - - $this->assertTrue(Str::contains($e->getFile(), 'run_success_on_failed')); - } - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed'); - } - - public function testUpFailed() - { - $this->copyFiles(); - - $table = 'failed'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_failed'); - } - - public function testUpFailedOnException() - { - $this->copyFiles(); - - $table = 'failed'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure'); - - try { - $this->copyFailedMethod(); - - $this->artisan(Names::ACTIONS)->assertExitCode(0); - } - catch (Throwable $e) { - $this->assertInstanceOf(Exception::class, $e); - - $this->assertSame('Custom exception', $e->getMessage()); - - $this->assertTrue(Str::contains($e->getFile(), 'run_failed_failure')); - } - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure'); - } - - public function testPathAsFileWithExtension() - { - $this->copyFiles(); - - $table = 'test'; - - $path = 'sub_path/2021_12_15_205804_baz.php'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'baz'); - $this->artisan(Names::ACTIONS, ['--path' => $path])->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'baz'); - - $this->assertSame('sub_path/2021_12_15_205804_baz', $this->table()->first()->action); - } - - public function testPathAsFileWithoutExtension() - { - $this->copyFiles(); - - $table = 'test'; - - $path = 'sub_path/2021_12_15_205804_baz'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'baz'); - $this->artisan(Names::ACTIONS, ['--path' => $path])->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'baz'); - - $this->assertSame($path, $this->table()->first()->action); - } - - public function testPathAsDirectory() - { - $this->copyFiles(); - - $table = 'test'; - - $path = 'sub_path'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'baz'); - $this->artisan(Names::ACTIONS, ['--path' => $path])->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 2); - $this->assertDatabaseActionHas($this->table, 'baz'); - - $this->assertSame('sub_path/2021_12_15_205804_baz', $this->table()->first()->action); - } - - public function testActionNotFound() - { - $this->assertDatabaseDoesntTable($this->table); - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseHasTable($this->table); - - $this->artisan(Names::STATUS)->assertExitCode(0); - } - - public function testDisabledBefore() - { - $this->copyFiles(); - - $table = 'before'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionHas($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionHas($this->table, 'test_before_disabled'); - } - - public function testEnabledBefore() - { - $this->copyFiles(); - - $table = 'before'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - } - - public function testMixedBefore() - { - $this->copyFiles(); - - $table = 'before'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionHas($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionHas($this->table, 'test_before_disabled'); - } - - public function testDI(): void - { - $this->copyDI(); - - $table = 'test'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'invoke'); - $this->assertDatabaseActionDoesntLike($this->table, 'invoke_down'); - $this->assertDatabaseActionDoesntLike($this->table, 'up_down'); - $this->assertDatabaseActionDoesntLike($table, 'up_down', column: 'value'); - $this->assertDatabaseActionDoesntLike($table, 'invoke_down', column: 'value'); - $this->assertDatabaseActionDoesntLike($table, 'invoke', column: 'value'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 3); - $this->assertDatabaseCount($this->table, 3); - $this->assertDatabaseActionHas($this->table, 'invoke'); - $this->assertDatabaseActionHas($this->table, 'invoke_down'); - $this->assertDatabaseActionHas($this->table, 'up_down'); - $this->assertDatabaseActionHas($table, 'up_down', column: 'value'); - $this->assertDatabaseActionHas($table, 'invoke_down', column: 'value'); - $this->assertDatabaseActionHas($table, 'invoke', column: 'value'); - } - - public function testSorting(): void - { - $files = []; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $files[] = date('Y_m_d_His_') . 'test1'; - $this->artisan(Names::MAKE, ['name' => 'test1'])->assertExitCode(0); - sleep(2); - $files[] = 'foo/' . date('Y_m_d_His_') . 'test2'; - $this->artisan(Names::MAKE, ['name' => 'foo/test2'])->assertExitCode(0); - sleep(2); - $files[] = 'bar/' . date('Y_m_d_His_') . 'test3'; - $this->artisan(Names::MAKE, ['name' => 'bar/test3'])->assertExitCode(0); - sleep(2); - $files[] = 'foo/' . date('Y_m_d_His_') . 'test4'; - $this->artisan(Names::MAKE, ['name' => 'foo/test4'])->assertExitCode(0); - sleep(2); - $files[] = 'bar/' . date('Y_m_d_His_') . 'test5'; - $this->artisan(Names::MAKE, ['name' => 'bar/test5'])->assertExitCode(0); - sleep(2); - $files[] = date('Y_m_d_His_') . 'test6'; - $this->artisan(Names::MAKE, ['name' => 'test6'])->assertExitCode(0); - - $this->artisan(Names::ACTIONS)->assertExitCode(0); - $this->assertDatabaseCount($this->table, 6); - - $records = DB::table($this->table)->orderBy('id')->pluck('action')->toArray(); - - $this->assertSame($files, $records); - } - - public function testDirectoryExclusion() - { - $this->copyFiles(); - - $this->app['config']->set('actions.exclude', 'sub_path'); - - $table = 'every_time'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 10); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 10); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 3); - $this->assertDatabaseCount($this->table, 10); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 4); - $this->assertDatabaseCount($this->table, 10); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); - } - - public function testFileExclusion() - { - $this->copyFiles(); - - $this->app['config']->set('actions.exclude', 'sub_path/2021_12_15_205804_baz'); - - $table = 'every_time'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionHas($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 2); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionHas($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 3); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionHas($this->table, 'sub_path/2022_10_27_230732_foo'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 4); - $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->assertDatabaseActionDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); - $this->assertDatabaseActionHas($this->table, 'sub_path/2022_10_27_230732_foo'); - } - - public function testEmptyDirectory() - { - $this->copyEmptyDirectory(); - - $table = 'every_time'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, $table); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table, 0); - $this->assertDatabaseCount($this->table, 0); - } - - public function testAsync() - { - $this->copyAsync(); - - $table1 = 'test'; - $table2 = 'every_time'; - - $queue = config('actions.queue.name'); - - Queue::fake(); - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - Queue::assertNothingPushed(); - - $this->assertDatabaseCount($table1, 0); - $this->assertDatabaseCount($table2, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'foo_bar'); - $this->assertDatabaseActionDoesntLike($this->table, 'every_time'); - - $this->artisan(Names::ACTIONS)->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseActionDoesntLike($this->table, 'foo_bar'); - $this->assertDatabaseActionDoesntLike($this->table, 'every_time'); - - Queue::assertPushed(ActionJob::class, 2); - - Queue::assertPushedOn($queue, ActionJob::class, fn (ActionJob $job) => Str::contains($job->filename, [ - 'foo_bar', - 'every_time', - ])); - } - - public function testSync() - { - $this->copyAsync(); - - $table1 = 'test'; - $table2 = 'every_time'; - - $this->artisan(Names::INSTALL)->assertExitCode(0); - - $this->assertDatabaseCount($table1, 0); - $this->assertDatabaseCount($table2, 0); - $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'foo_bar'); - $this->assertDatabaseActionDoesntLike($this->table, 'every_time'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table1, 1); - $this->assertDatabaseCount($table2, 1); - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'foo_bar'); - $this->assertDatabaseActionDoesntLike($this->table, 'every_time'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table1, 1); - $this->assertDatabaseCount($table2, 2); - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'foo_bar'); - $this->assertDatabaseActionDoesntLike($this->table, 'every_time'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); - - $this->assertDatabaseCount($table1, 1); - $this->assertDatabaseCount($table2, 3); - $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'foo_bar'); - $this->assertDatabaseActionDoesntLike($this->table, 'every_time'); - } -} diff --git a/tests/Commands/EventsTest.php b/tests/Commands/EventsTest.php index 5c9e19b0..0e650272 100644 --- a/tests/Commands/EventsTest.php +++ b/tests/Commands/EventsTest.php @@ -4,10 +4,10 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; -use DragonCode\LaravelActions\Events\ActionEnded; -use DragonCode\LaravelActions\Events\ActionFailed; -use DragonCode\LaravelActions\Events\ActionStarted; +use DragonCode\LaravelDeployOperations\Constants\Names; +use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded; +use DragonCode\LaravelDeployOperations\Events\DeployOperationFailed; +use DragonCode\LaravelDeployOperations\Events\DeployOperationStarted; use Exception; use Illuminate\Support\Facades\Event; use Tests\TestCase; @@ -21,12 +21,12 @@ public function testSuccess() Event::fake(); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); - Event::assertDispatchedTimes(ActionStarted::class, 1); - Event::assertDispatchedTimes(ActionEnded::class, 1); + Event::assertDispatchedTimes(DeployOperationStarted::class, 1); + Event::assertDispatchedTimes(DeployOperationEnded::class, 1); - Event::assertNotDispatched(ActionFailed::class); + Event::assertNotDispatched(DeployOperationFailed::class); } public function testFailed() @@ -39,13 +39,13 @@ public function testFailed() Event::fake(); try { - $this->artisan(Names::ACTIONS)->run(); + $this->artisan(Names::Operations)->run(); } catch (Throwable $e) { - Event::assertDispatchedTimes(ActionStarted::class, 1); - Event::assertDispatchedTimes(ActionFailed::class, 1); + Event::assertDispatchedTimes(DeployOperationStarted::class, 1); + Event::assertDispatchedTimes(DeployOperationFailed::class, 1); - Event::assertNotDispatched(ActionEnded::class); + Event::assertNotDispatched(DeployOperationEnded::class); throw $e; } diff --git a/tests/Commands/FreshTest.php b/tests/Commands/FreshTest.php index 6105f399..5afa0c81 100644 --- a/tests/Commands/FreshTest.php +++ b/tests/Commands/FreshTest.php @@ -4,7 +4,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use Tests\TestCase; class FreshTest extends TestCase @@ -13,21 +13,21 @@ public function testFreshCommand(): void { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->artisan(Names::MAKE, ['name' => 'Fresh'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'Fresh'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 1); - $this->artisan(Names::FRESH)->assertExitCode(0); + $this->artisan(Names::Fresh)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'fresh'); + $this->assertDatabaseOperationHas($this->table, 'fresh'); } } diff --git a/tests/Commands/InstallTest.php b/tests/Commands/InstallTest.php index 7f9c66a5..f66efc79 100644 --- a/tests/Commands/InstallTest.php +++ b/tests/Commands/InstallTest.php @@ -2,8 +2,8 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; -use DragonCode\LaravelActions\Constants\Options; +use DragonCode\LaravelDeployOperations\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Options; use Tests\TestCase; class InstallTest extends TestCase @@ -12,7 +12,7 @@ public function testCreate(): void { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); } @@ -21,8 +21,8 @@ public function testAlreadyCreated(): void { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); } @@ -31,7 +31,7 @@ public function testMutedCreate(): void { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL, ['--' . Options::MUTE => true])->assertExitCode(0); + $this->artisan(Names::Install, ['--' . Options::Mute => true])->assertExitCode(0); $this->assertDatabaseHasTable($this->table); } @@ -40,8 +40,8 @@ public function testMutedAlreadyCreated(): void { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL, ['--' . Options::MUTE => true])->assertExitCode(0); - $this->artisan(Names::INSTALL, ['--' . Options::MUTE => true])->assertExitCode(0); + $this->artisan(Names::Install, ['--' . Options::Mute => true])->assertExitCode(0); + $this->artisan(Names::Install, ['--' . Options::Mute => true])->assertExitCode(0); $this->assertDatabaseHasTable($this->table); } diff --git a/tests/Commands/MakeTest.php b/tests/Commands/MakeTest.php index 03b1ab4c..1139b295 100644 --- a/tests/Commands/MakeTest.php +++ b/tests/Commands/MakeTest.php @@ -2,7 +2,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use DragonCode\Support\Facades\Filesystem\File; use Tests\TestCase; @@ -12,11 +12,11 @@ public function testMakingFiles() { $name = 'MakeExample'; - $path = $this->getActionsPath() . '/' . date('Y_m_d_His') . '_make_example.php'; + $path = $this->getOperationsPath() . '/' . date('Y_m_d_His') . '_make_example.php'; $this->assertFileDoesNotExist($path); - $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); + $this->artisan(Names::Make, compact('name'))->assertExitCode(0); $this->assertFileExists($path); @@ -28,11 +28,11 @@ public function testMakingFiles() public function testAutoName() { - $path = $this->getActionsPath() . '/' . date('Y_m_d_His') . '_auto.php'; + $path = $this->getOperationsPath() . '/' . date('Y_m_d_His') . '_auto.php'; $this->assertFileDoesNotExist($path); - $this->artisan(Names::MAKE)->assertExitCode(0); + $this->artisan(Names::Make)->assertExitCode(0); $this->assertFileExists($path); } @@ -41,11 +41,11 @@ public function testNestedRightSlashWithoutExtension() { $name = 'Foo/bar/QweRty'; - $path = $this->getActionsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; + $path = $this->getOperationsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; $this->assertFileDoesNotExist($path); - $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); + $this->artisan(Names::Make, compact('name'))->assertExitCode(0); $this->assertFileExists($path); @@ -59,11 +59,11 @@ public function testNestedRightSlashWithExtension() { $name = 'Foo/bar/QweRty.php'; - $path = $this->getActionsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; + $path = $this->getOperationsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; $this->assertFileDoesNotExist($path); - $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); + $this->artisan(Names::Make, compact('name'))->assertExitCode(0); $this->assertFileExists($path); @@ -77,11 +77,11 @@ public function testNestedLeftSlashWithoutExtension() { $name = 'Foo\\bar\\QweRty'; - $path = $this->getActionsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; + $path = $this->getOperationsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; $this->assertFileDoesNotExist($path); - $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); + $this->artisan(Names::Make, compact('name'))->assertExitCode(0); $this->assertFileExists($path); @@ -95,11 +95,11 @@ public function testNestedLeftSlashWithExtension() { $name = 'Foo\\bar\\QweRty.php'; - $path = $this->getActionsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; + $path = $this->getOperationsPath() . '/foo/bar/' . date('Y_m_d_His') . '_qwe_rty.php'; $this->assertFileDoesNotExist($path); - $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); + $this->artisan(Names::Make, compact('name'))->assertExitCode(0); $this->assertFileExists($path); @@ -113,29 +113,27 @@ public function testFromCustomizedStub() { $name = 'MakeExample'; - $stubPath = base_path('stubs/action.stub'); + $stubPath = base_path('stubs/deploy-operation.stub'); - $actionPath = $this->getActionsPath() . '/' . date('Y_m_d_His') . '_make_example.php'; + $operationPath = $this->getOperationsPath() . '/' . date('Y_m_d_His') . '_make_example.php'; $this->assertFileDoesNotExist($stubPath); File::copy(__DIR__ . '/../fixtures/app/stubs/customized.stub', $stubPath); $this->assertFileExists($stubPath); - $this->assertFileDoesNotExist($actionPath); + $this->assertFileDoesNotExist($operationPath); - $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); + $this->artisan(Names::Make, compact('name'))->assertExitCode(0); - $this->assertFileExists($actionPath); + $this->assertFileExists($operationPath); - $content = file_get_contents($actionPath); + $content = file_get_contents($operationPath); $this->assertStringContainsString('Foo\\Bar\\Some', $content); $this->assertStringContainsString('extends Some', $content); - $this->assertStringNotContainsString('DragonCode\\LaravelActions\\Action', $content); - $this->assertStringNotContainsString('extends Action', $content); - $this->assertStringNotContainsString('Run the actions.', $content); - $this->assertStringNotContainsString('@return void', $content); + $this->assertStringNotContainsString('DragonCode\\LaravelDeployOperations\\Operation', $content); + $this->assertStringNotContainsString('extends Operation', $content); } } diff --git a/tests/Commands/MutexTest.php b/tests/Commands/MutexTest.php index 30223383..eeffce67 100644 --- a/tests/Commands/MutexTest.php +++ b/tests/Commands/MutexTest.php @@ -4,9 +4,9 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Console\Command; -use DragonCode\LaravelActions\Constants\Options; -use DragonCode\LaravelActions\Services\Mutex; +use DragonCode\LaravelDeployOperations\Console\Command; +use DragonCode\LaravelDeployOperations\Constants\Options; +use DragonCode\LaravelDeployOperations\Services\Mutex; use Illuminate\Container\Container; use Mockery as m; use Symfony\Component\Console\Input\ArrayInput; @@ -93,7 +93,7 @@ public function testCanRunCommandAgainNonAutomated() protected function runCommand($withIsolated = true) { - $input = new ArrayInput(['--' . Options::ISOLATED => $withIsolated]); + $input = new ArrayInput(['--' . Options::Isolated => $withIsolated]); $output = new NullOutput(); $this->command->run($input, $output); diff --git a/tests/Commands/OperationsTest.php b/tests/Commands/OperationsTest.php new file mode 100644 index 00000000..a2623fb1 --- /dev/null +++ b/tests/Commands/OperationsTest.php @@ -0,0 +1,747 @@ +assertDatabaseDoesntTable($this->table); + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseHasTable($this->table); + $this->assertDatabaseCount($this->table, 0); + + $this->artisan(Names::Make, ['name' => 'TestMigration'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, 'test_migration'); + } + + public function testSameName() + { + $this->assertDatabaseDoesntTable($this->table); + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseHasTable($this->table); + $this->assertDatabaseCount($this->table, 0); + + $this->artisan(Names::Make, ['name' => 'TestMigration'])->assertExitCode(0); + + sleep(2); + + $this->artisan(Names::Make, ['name' => 'TestMigration'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($this->table, 2); + $this->assertDatabaseOperationHas($this->table, 'test_migration'); + } + + public function testOnce() + { + $this->copyFiles(); + + $table = 'every_time'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 3); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 4); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + } + + public function testSuccessTransaction() + { + $this->copySuccessTransaction(); + + $table = 'transactions'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 3); + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, $table); + } + + public function testFailedTransaction() + { + $this->copyFailedTransaction(); + + $table = 'transactions'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + + try { + $this->artisan(Names::Operations)->assertExitCode(0); + } + catch (Exception $e) { + $this->assertSame(Exception::class, get_class($e)); + $this->assertSame('Random message', $e->getMessage()); + } + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + } + + public function testSingleEnvironment() + { + $this->copyFiles(); + + $table = 'environment'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_testing'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 5); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationHas($this->table, 'run_on_testing'); + $this->assertDatabaseOperationHas($this->table, 'run_except_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_testing'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 5); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationHas($this->table, 'run_on_testing'); + $this->assertDatabaseOperationHas($this->table, 'run_except_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_testing'); + } + + public function testManyEnvironments() + { + $this->copyFiles(); + + $table = 'environment'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_many_environments'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_many_environments'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 5); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationHas($this->table, 'run_on_testing'); + $this->assertDatabaseOperationHas($this->table, 'run_on_many_environments'); + $this->assertDatabaseOperationHas($this->table, 'run_except_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_many_environments'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 5); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationHas($this->table, 'run_on_testing'); + $this->assertDatabaseOperationHas($this->table, 'run_on_many_environments'); + $this->assertDatabaseOperationHas($this->table, 'run_except_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_except_many_environments'); + } + + public function testAllow() + { + $this->copyFiles(); + + $table = 'environment'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_allow'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_disallow'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 5); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_allow'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_disallow'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 5); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_allow'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_disallow'); + } + + public function testUpSuccess() + { + $this->copyFiles(); + + $table = 'success'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_success'); + } + + public function testUpSuccessOnFailed() + { + $this->copyFiles(); + + $table = 'success'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success_on_failed'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success_on_failed'); + + try { + $this->copySuccessFailureMethod(); + + $this->artisan(Names::Operations)->assertExitCode(0); + } + catch (Throwable $e) { + $this->assertInstanceOf(Exception::class, $e); + + $this->assertSame('Custom exception', $e->getMessage()); + + $this->assertTrue(Str::contains($e->getFile(), 'run_success_on_failed')); + } + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success_on_failed'); + } + + public function testUpFailed() + { + $this->copyFiles(); + + $table = 'failed'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'run_failed'); + } + + public function testUpFailedOnException() + { + $this->copyFiles(); + + $table = 'failed'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed_failure'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed_failure'); + + try { + $this->copyFailedMethod(); + + $this->artisan(Names::Operations)->assertExitCode(0); + } + catch (Throwable $e) { + $this->assertInstanceOf(Exception::class, $e); + + $this->assertSame('Custom exception', $e->getMessage()); + + $this->assertTrue(Str::contains($e->getFile(), 'run_failed_failure')); + } + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed_failure'); + } + + public function testPathAsFileWithExtension() + { + $this->copyFiles(); + + $table = 'test'; + + $path = 'sub_path/2021_12_15_205804_baz.php'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'baz'); + $this->artisan(Names::Operations, ['--path' => $path])->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, 'baz'); + + $this->assertSame('sub_path/2021_12_15_205804_baz', $this->table()->first()->operation); + } + + public function testPathAsFileWithoutExtension() + { + $this->copyFiles(); + + $table = 'test'; + + $path = 'sub_path/2021_12_15_205804_baz'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'baz'); + $this->artisan(Names::Operations, ['--path' => $path])->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, 'baz'); + + $this->assertSame($path, $this->table()->first()->operation); + } + + public function testPathAsDirectory() + { + $this->copyFiles(); + + $table = 'test'; + + $path = 'sub_path'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'baz'); + $this->artisan(Names::Operations, ['--path' => $path])->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 2); + $this->assertDatabaseOperationHas($this->table, 'baz'); + + $this->assertSame('sub_path/2021_12_15_205804_baz', $this->table()->first()->operation); + } + + public function testOperationsNotFound() + { + $this->assertDatabaseDoesntTable($this->table); + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseHasTable($this->table); + + $this->artisan(Names::Status)->assertExitCode(0); + } + + public function testDisabledBefore() + { + $this->copyFiles(); + + $table = 'before'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationHas($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationHas($this->table, 'test_before_disabled'); + } + + public function testEnabledBefore() + { + $this->copyFiles(); + + $table = 'before'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations, ['--before' => true])->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations, ['--before' => true])->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + } + + public function testMixedBefore() + { + $this->copyFiles(); + + $table = 'before'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations, ['--before' => true])->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations, ['--before' => true])->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationHas($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 12); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationHas($this->table, 'test_before_disabled'); + } + + public function testDI(): void + { + $this->copyDI(); + + $table = 'test'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'invoke'); + $this->assertDatabaseOperationDoesntLike($this->table, 'invoke_down'); + $this->assertDatabaseOperationDoesntLike($this->table, 'up_down'); + $this->assertDatabaseOperationDoesntLike($table, 'up_down', column: 'value'); + $this->assertDatabaseOperationDoesntLike($table, 'invoke_down', column: 'value'); + $this->assertDatabaseOperationDoesntLike($table, 'invoke', column: 'value'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 3); + $this->assertDatabaseCount($this->table, 3); + $this->assertDatabaseOperationHas($this->table, 'invoke'); + $this->assertDatabaseOperationHas($this->table, 'invoke_down'); + $this->assertDatabaseOperationHas($this->table, 'up_down'); + $this->assertDatabaseOperationHas($table, 'up_down', column: 'value'); + $this->assertDatabaseOperationHas($table, 'invoke_down', column: 'value'); + $this->assertDatabaseOperationHas($table, 'invoke', column: 'value'); + } + + public function testSorting(): void + { + $files = []; + + $this->artisan(Names::Install)->assertExitCode(0); + + $files[] = date('Y_m_d_His_') . 'test1'; + $this->artisan(Names::Make, ['name' => 'test1'])->assertExitCode(0); + sleep(2); + $files[] = 'foo/' . date('Y_m_d_His_') . 'test2'; + $this->artisan(Names::Make, ['name' => 'foo/test2'])->assertExitCode(0); + sleep(2); + $files[] = 'bar/' . date('Y_m_d_His_') . 'test3'; + $this->artisan(Names::Make, ['name' => 'bar/test3'])->assertExitCode(0); + sleep(2); + $files[] = 'foo/' . date('Y_m_d_His_') . 'test4'; + $this->artisan(Names::Make, ['name' => 'foo/test4'])->assertExitCode(0); + sleep(2); + $files[] = 'bar/' . date('Y_m_d_His_') . 'test5'; + $this->artisan(Names::Make, ['name' => 'bar/test5'])->assertExitCode(0); + sleep(2); + $files[] = date('Y_m_d_His_') . 'test6'; + $this->artisan(Names::Make, ['name' => 'test6'])->assertExitCode(0); + + $this->artisan(Names::Operations)->assertExitCode(0); + $this->assertDatabaseCount($this->table, 6); + + $records = DB::table($this->table)->orderBy('id')->pluck('operation')->all(); + + $this->assertSame($files, $records); + } + + public function testDirectoryExclusion() + { + $this->copyFiles(); + + $this->app['config']->set('deploy-operations.exclude', 'sub_path'); + + $table = 'every_time'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 10); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 10); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 3); + $this->assertDatabaseCount($this->table, 10); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 4); + $this->assertDatabaseCount($this->table, 10); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); + } + + public function testFileExclusion() + { + $this->copyFiles(); + + $this->app['config']->set('deploy-operations.exclude', 'sub_path/2021_12_15_205804_baz'); + + $table = 'every_time'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 1); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationHas($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 2); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationHas($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 3); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationHas($this->table, 'sub_path/2022_10_27_230732_foo'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 4); + $this->assertDatabaseCount($this->table, 11); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->assertDatabaseOperationDoesntLike($this->table, 'sub_path/2021_12_15_205804_baz'); + $this->assertDatabaseOperationHas($this->table, 'sub_path/2022_10_27_230732_foo'); + } + + public function testEmptyDirectory() + { + $this->copyEmptyDirectory(); + + $table = 'every_time'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, $table); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table, 0); + $this->assertDatabaseCount($this->table, 0); + } + + public function testAsync() + { + $this->copyAsync(); + + $table1 = 'test'; + $table2 = 'every_time'; + + $queue = config('deploy-operations.queue.name'); + + Queue::fake(); + + $this->artisan(Names::Install)->assertExitCode(0); + + Queue::assertNothingPushed(); + + $this->assertDatabaseCount($table1, 0); + $this->assertDatabaseCount($table2, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'foo_bar'); + $this->assertDatabaseOperationDoesntLike($this->table, 'every_time'); + + $this->artisan(Names::Operations)->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseOperationDoesntLike($this->table, 'foo_bar'); + $this->assertDatabaseOperationDoesntLike($this->table, 'every_time'); + + Queue::assertPushed(OperationJob::class, 2); + + Queue::assertPushedOn($queue, OperationJob::class, fn (OperationJob $job) => Str::contains($job->filename, [ + 'foo_bar', + 'every_time', + ])); + } + + public function testSync() + { + $this->copyAsync(); + + $table1 = 'test'; + $table2 = 'every_time'; + + $this->artisan(Names::Install)->assertExitCode(0); + + $this->assertDatabaseCount($table1, 0); + $this->assertDatabaseCount($table2, 0); + $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseOperationDoesntLike($this->table, 'foo_bar'); + $this->assertDatabaseOperationDoesntLike($this->table, 'every_time'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table1, 1); + $this->assertDatabaseCount($table2, 1); + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, 'foo_bar'); + $this->assertDatabaseOperationDoesntLike($this->table, 'every_time'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table1, 1); + $this->assertDatabaseCount($table2, 2); + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, 'foo_bar'); + $this->assertDatabaseOperationDoesntLike($this->table, 'every_time'); + $this->artisan(Names::Operations)->assertExitCode(0); + + $this->assertDatabaseCount($table1, 1); + $this->assertDatabaseCount($table2, 3); + $this->assertDatabaseCount($this->table, 1); + $this->assertDatabaseOperationHas($this->table, 'foo_bar'); + $this->assertDatabaseOperationDoesntLike($this->table, 'every_time'); + } +} diff --git a/tests/Commands/RefreshTest.php b/tests/Commands/RefreshTest.php index 94642de1..a8409a5c 100644 --- a/tests/Commands/RefreshTest.php +++ b/tests/Commands/RefreshTest.php @@ -2,7 +2,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use Tests\TestCase; class RefreshTest extends TestCase @@ -11,21 +11,21 @@ public function testRefreshCommand() { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->artisan(Names::MAKE, ['name' => 'Refresh'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'Refresh'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 1); - $this->artisan(Names::REFRESH)->assertExitCode(0); + $this->artisan(Names::Refresh)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'refresh'); + $this->assertDatabaseOperationHas($this->table, 'refresh'); } } diff --git a/tests/Commands/ResetTest.php b/tests/Commands/ResetTest.php index 8457448d..d841bc99 100644 --- a/tests/Commands/ResetTest.php +++ b/tests/Commands/ResetTest.php @@ -2,7 +2,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use Tests\TestCase; class ResetTest extends TestCase @@ -11,22 +11,22 @@ public function testResetCommand() { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->artisan(Names::MAKE, ['name' => 'Reset'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'Reset'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 1); - $this->assertDatabaseActionHas($this->table, 'reset'); + $this->assertDatabaseOperationHas($this->table, 'reset'); - $this->artisan(Names::RESET)->assertExitCode(0); + $this->artisan(Names::Reset)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'reset'); + $this->assertDatabaseOperationDoesntLike($this->table, 'reset'); } } diff --git a/tests/Commands/RollbackTest.php b/tests/Commands/RollbackTest.php index a4c02e84..13f92d3e 100644 --- a/tests/Commands/RollbackTest.php +++ b/tests/Commands/RollbackTest.php @@ -2,7 +2,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use Exception; use Illuminate\Support\Str; use Tests\TestCase; @@ -14,42 +14,42 @@ public function testRollbackCommand() { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->artisan(Names::MAKE, ['name' => 'RollbackOne'])->assertExitCode(0); - $this->artisan(Names::MAKE, ['name' => 'RollbackTwo'])->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'RollbackOne'])->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'RollbackTwo'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 2); - $this->assertDatabaseActionHas($this->table, 'rollback_one'); - $this->assertDatabaseActionHas($this->table, 'rollback_two'); - $this->assertDatabaseActionDoesntLike($this->table, 'rollback_tree'); + $this->assertDatabaseOperationHas($this->table, 'rollback_one'); + $this->assertDatabaseOperationHas($this->table, 'rollback_two'); + $this->assertDatabaseOperationDoesntLike($this->table, 'rollback_tree'); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 2); - $this->artisan(Names::MAKE, ['name' => 'RollbackTree'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'RollbackTree'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 3); - $this->assertDatabaseActionHas($this->table, 'rollback_one'); - $this->assertDatabaseActionHas($this->table, 'rollback_two'); - $this->assertDatabaseActionHas($this->table, 'rollback_tree'); + $this->assertDatabaseOperationHas($this->table, 'rollback_one'); + $this->assertDatabaseOperationHas($this->table, 'rollback_two'); + $this->assertDatabaseOperationHas($this->table, 'rollback_tree'); } public function testEnvironment() @@ -58,31 +58,31 @@ public function testEnvironment() $table = 'environment'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_many_environments'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_many_environments'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 5); $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionHas($this->table, 'run_on_testing'); - $this->assertDatabaseActionHas($this->table, 'run_on_many_environments'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationHas($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationHas($this->table, 'run_on_testing'); + $this->assertDatabaseOperationHas($this->table, 'run_on_many_environments'); + $this->artisan(Names::Operations)->assertExitCode(0); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseCount($table, 10); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_all'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_production'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_testing'); - $this->assertDatabaseActionDoesntLike($this->table, 'run_on_many_environments'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_all'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_production'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_testing'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_on_many_environments'); } public function testDownSuccess() @@ -91,21 +91,21 @@ public function testDownSuccess() $table = 'success'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 2); $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_success'); + $this->assertDatabaseOperationHas($this->table, 'run_success'); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseCount($table, 4); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success'); } public function testDownSuccessOnFailed() @@ -114,27 +114,27 @@ public function testDownSuccessOnFailed() $table = 'success'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success_on_failed'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 2); $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_success_on_failed'); try { $this->copySuccessFailureMethod(); - $this->table()->insert(['action' => '2021_12_23_165048_run_success_on_failed', 'batch' => 999]); + $this->table()->insert(['operation' => '2021_12_23_165048_run_success_on_failed', 'batch' => 999]); $this->assertDatabaseCount($table, 2); $this->assertDatabaseCount($this->table, 13); - $this->assertDatabaseActionHas($this->table, 'run_success_on_failed'); + $this->assertDatabaseOperationHas($this->table, 'run_success_on_failed'); - $this->artisan(Names::ROLLBACK)->assertExitCode(1); + $this->artisan(Names::Rollback)->assertExitCode(1); } catch (Throwable $e) { $this->assertInstanceOf(Exception::class, $e); @@ -146,7 +146,7 @@ public function testDownSuccessOnFailed() $this->assertDatabaseCount($table, 2); $this->assertDatabaseCount($this->table, 13); - $this->assertDatabaseActionHas($this->table, 'run_success_on_failed'); + $this->assertDatabaseOperationHas($this->table, 'run_success_on_failed'); } public function testDownFailed() @@ -155,21 +155,21 @@ public function testDownFailed() $table = 'failed'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'run_failed'); + $this->assertDatabaseOperationHas($this->table, 'run_failed'); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed'); } public function testUpFailedOnException() @@ -178,23 +178,23 @@ public function testUpFailedOnException() $table = 'failed'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed_failure'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure'); + $this->assertDatabaseOperationDoesntLike($this->table, 'run_failed_failure'); try { $this->copyFailedMethod(); - $this->table()->insert(['action' => '2021_12_23_184029_run_failed_failure', 'batch' => 999]); + $this->table()->insert(['operation' => '2021_12_23_184029_run_failed_failure', 'batch' => 999]); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); } catch (Throwable $e) { $this->assertInstanceOf(Exception::class, $e); @@ -206,7 +206,7 @@ public function testUpFailedOnException() $this->assertDatabaseCount($table, 1); $this->assertDatabaseCount($this->table, 13); - $this->assertDatabaseActionHas($this->table, 'run_failed_failure'); + $this->assertDatabaseOperationHas($this->table, 'run_failed_failure'); } public function testDisabledBefore() @@ -215,26 +215,26 @@ public function testDisabledBefore() $table = 'before'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 2); $this->assertDatabaseCount($this->table, 12); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionHas($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationHas($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations)->assertExitCode(0); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseCount($table, 4); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); } public function testEnabledBefore() @@ -243,26 +243,26 @@ public function testEnabledBefore() $table = 'before'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations, ['--before' => true])->assertExitCode(0); $this->assertDatabaseCount($table, 1); $this->assertDatabaseCount($this->table, 11); - $this->assertDatabaseActionHas($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); - $this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0); + $this->assertDatabaseOperationHas($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); + $this->artisan(Names::Operations, ['--before' => true])->assertExitCode(0); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseCount($table, 2); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled'); - $this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_enabled'); + $this->assertDatabaseOperationDoesntLike($this->table, 'test_before_disabled'); } public function testDI(): void @@ -271,36 +271,36 @@ public function testDI(): void $table = 'test'; - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseCount($table, 0); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'invoke'); - $this->assertDatabaseActionDoesntLike($this->table, 'invoke_down'); - $this->assertDatabaseActionDoesntLike($this->table, 'up_down'); - $this->assertDatabaseActionDoesntLike($table, 'up_down', column: 'value'); - $this->assertDatabaseActionDoesntLike($table, 'invoke_down', column: 'value'); - $this->assertDatabaseActionDoesntLike($table, 'invoke', column: 'value'); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->assertDatabaseOperationDoesntLike($this->table, 'invoke'); + $this->assertDatabaseOperationDoesntLike($this->table, 'invoke_down'); + $this->assertDatabaseOperationDoesntLike($this->table, 'up_down'); + $this->assertDatabaseOperationDoesntLike($table, 'up_down', column: 'value'); + $this->assertDatabaseOperationDoesntLike($table, 'invoke_down', column: 'value'); + $this->assertDatabaseOperationDoesntLike($table, 'invoke', column: 'value'); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($table, 3); $this->assertDatabaseCount($this->table, 3); - $this->assertDatabaseActionHas($this->table, 'invoke'); - $this->assertDatabaseActionHas($this->table, 'invoke_down'); - $this->assertDatabaseActionHas($this->table, 'up_down'); - $this->assertDatabaseActionHas($table, 'up_down', column: 'value'); - $this->assertDatabaseActionHas($table, 'invoke_down', column: 'value'); - $this->assertDatabaseActionHas($table, 'invoke', column: 'value'); + $this->assertDatabaseOperationHas($this->table, 'invoke'); + $this->assertDatabaseOperationHas($this->table, 'invoke_down'); + $this->assertDatabaseOperationHas($this->table, 'up_down'); + $this->assertDatabaseOperationHas($table, 'up_down', column: 'value'); + $this->assertDatabaseOperationHas($table, 'invoke_down', column: 'value'); + $this->assertDatabaseOperationHas($table, 'invoke', column: 'value'); - $this->artisan(Names::ROLLBACK)->assertExitCode(0); + $this->artisan(Names::Rollback)->assertExitCode(0); $this->assertDatabaseCount($table, 1); $this->assertDatabaseCount($this->table, 0); - $this->assertDatabaseActionDoesntLike($this->table, 'invoke'); - $this->assertDatabaseActionDoesntLike($this->table, 'invoke_down'); - $this->assertDatabaseActionDoesntLike($this->table, 'up_down'); - $this->assertDatabaseActionDoesntLike($table, 'up_down', column: 'value'); - $this->assertDatabaseActionDoesntLike($table, 'invoke_down', column: 'value'); - $this->assertDatabaseActionHas($table, 'invoke', column: 'value'); + $this->assertDatabaseOperationDoesntLike($this->table, 'invoke'); + $this->assertDatabaseOperationDoesntLike($this->table, 'invoke_down'); + $this->assertDatabaseOperationDoesntLike($this->table, 'up_down'); + $this->assertDatabaseOperationDoesntLike($table, 'up_down', column: 'value'); + $this->assertDatabaseOperationDoesntLike($table, 'invoke_down', column: 'value'); + $this->assertDatabaseOperationHas($table, 'invoke', column: 'value'); } } diff --git a/tests/Commands/StatusTest.php b/tests/Commands/StatusTest.php index 3c7e7ed5..c85a0aa9 100644 --- a/tests/Commands/StatusTest.php +++ b/tests/Commands/StatusTest.php @@ -2,7 +2,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use Tests\TestCase; class StatusTest extends TestCase @@ -11,7 +11,7 @@ public function testNotFound(): void { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::STATUS)->assertExitCode(0); + $this->artisan(Names::Status)->assertExitCode(0); $this->assertDatabaseDoesntTable($this->table); } @@ -20,20 +20,20 @@ public function testStatusCommand() { $this->assertDatabaseDoesntTable($this->table); - $this->artisan(Names::INSTALL)->assertExitCode(0); + $this->artisan(Names::Install)->assertExitCode(0); $this->assertDatabaseHasTable($this->table); $this->assertDatabaseCount($this->table, 0); - $this->artisan(Names::STATUS)->expectsTable([], [])->assertExitCode(0); + $this->artisan(Names::Status)->expectsTable([], [])->assertExitCode(0); - $this->artisan(Names::MAKE, ['name' => 'Status'])->assertExitCode(0); - $this->artisan(Names::ACTIONS)->assertExitCode(0); + $this->artisan(Names::Make, ['name' => 'Status'])->assertExitCode(0); + $this->artisan(Names::Operations)->assertExitCode(0); $this->assertDatabaseCount($this->table, 1); - $this->artisan(Names::STATUS)->assertExitCode(0); + $this->artisan(Names::Status)->assertExitCode(0); - $this->assertDatabaseActionHas($this->table, 'status'); + $this->assertDatabaseOperationHas($this->table, 'status'); } } diff --git a/tests/Commands/StubPublishTest.php b/tests/Commands/StubPublishTest.php index 329622c7..aa800815 100644 --- a/tests/Commands/StubPublishTest.php +++ b/tests/Commands/StubPublishTest.php @@ -4,7 +4,7 @@ namespace Tests\Commands; -use DragonCode\LaravelActions\Constants\Names; +use DragonCode\LaravelDeployOperations\Constants\Names; use DragonCode\Support\Facades\Filesystem\File; use Tests\TestCase; @@ -14,7 +14,7 @@ public function testFirst(): void { $this->assertFileDoesNotExist($this->path()); - $this->artisan(Names::STUB_PUBLISH)->assertExitCode(0); + $this->artisan(Names::StubPublish)->assertExitCode(0); $this->assertFileExists($this->path()); } @@ -31,22 +31,18 @@ public function testSkip(): void $this->assertStringContainsString('Foo\\Bar\\Some', $content); $this->assertStringContainsString('extends Some', $content); - $this->assertStringNotContainsString('DragonCode\\LaravelActions\\Action', $content); - $this->assertStringNotContainsString('extends Action', $content); - $this->assertStringNotContainsString('Run the actions.', $content); - $this->assertStringNotContainsString('@return void', $content); + $this->assertStringNotContainsString('DragonCode\\LaravelDeployOperations\\Operation', $content); + $this->assertStringNotContainsString('extends Operation', $content); - $this->artisan(Names::STUB_PUBLISH)->assertExitCode(0); + $this->artisan(Names::StubPublish)->assertExitCode(0); $content = file_get_contents($this->path()); $this->assertStringContainsString('Foo\\Bar\\Some', $content); $this->assertStringContainsString('extends Some', $content); - $this->assertStringNotContainsString('DragonCode\\LaravelActions\\Action', $content); - $this->assertStringNotContainsString('extends Action', $content); - $this->assertStringNotContainsString('Run the actions.', $content); - $this->assertStringNotContainsString('@return void', $content); + $this->assertStringNotContainsString('DragonCode\\LaravelDeployOperations\\Operation', $content); + $this->assertStringNotContainsString('extends Operation', $content); } public function testForce(): void @@ -61,12 +57,10 @@ public function testForce(): void $this->assertStringContainsString('Foo\\Bar\\Some', $content); $this->assertStringContainsString('extends Some', $content); - $this->assertStringNotContainsString('DragonCode\\LaravelActions\\Action', $content); - $this->assertStringNotContainsString('extends Action', $content); - $this->assertStringNotContainsString('Run the actions.', $content); - $this->assertStringNotContainsString('@return void', $content); + $this->assertStringNotContainsString('DragonCode\\LaravelDeployOperations\\Operation', $content); + $this->assertStringNotContainsString('extends Operation', $content); - $this->artisan(Names::STUB_PUBLISH, [ + $this->artisan(Names::StubPublish, [ '--force' => true, ])->assertExitCode(0); @@ -75,14 +69,12 @@ public function testForce(): void $this->assertStringNotContainsString('Foo\\Bar\\Some', $content); $this->assertStringNotContainsString('extends Some', $content); - $this->assertStringContainsString('DragonCode\\LaravelActions\\Action', $content); - $this->assertStringContainsString('extends Action', $content); - $this->assertStringContainsString('Run the actions.', $content); - $this->assertStringContainsString('@return void', $content); + $this->assertStringContainsString('DragonCode\\LaravelDeployOperations\\Operation', $content); + $this->assertStringContainsString('extends Operation', $content); } protected function path(): string { - return base_path('stubs/action.stub'); + return base_path('stubs/deploy-operation.stub'); } } diff --git a/tests/Concerns/AssertDatabase.php b/tests/Concerns/AssertDatabase.php index e83b7e32..f513254f 100644 --- a/tests/Concerns/AssertDatabase.php +++ b/tests/Concerns/AssertDatabase.php @@ -22,7 +22,7 @@ protected function assertDatabaseDoesntTable(string $table): void ); } - protected function assertDatabaseActionHas(string $table, $value, $connection = null, string $column = 'action'): void + protected function assertDatabaseOperationHas(string $table, $value, $connection = null, string $column = 'operation'): void { $this->assertDatabaseHasLike($table, $column, $value, $connection); } @@ -37,7 +37,7 @@ protected function assertDatabaseHasLike(string $table, string $column, $value, $this->assertTrue($exists); } - protected function assertDatabaseActionDoesntLike(string $table, $value, $connection = null, string $column = 'action'): void + protected function assertDatabaseOperationDoesntLike(string $table, $value, $connection = null, string $column = 'operation'): void { $this->assertDatabaseDoesntLike($table, $column, $value, $connection); } diff --git a/tests/Concerns/Database.php b/tests/Concerns/Database.php index 0900083f..911455ec 100644 --- a/tests/Concerns/Database.php +++ b/tests/Concerns/Database.php @@ -6,7 +6,7 @@ trait Database { protected string $database = 'testing'; - protected string $table = 'foo_actions'; + protected string $table = 'foo_operations'; protected function setDatabase($app): void { @@ -18,8 +18,8 @@ protected function setDatabase($app): void 'prefix' => '', ]); - $app['config']->set('actions.connection', $this->database); - $app['config']->set('actions.table', $this->table); + $app['config']->set('deploy-operations.connection', $this->database); + $app['config']->set('deploy-operations.table', $this->table); } protected function freshDatabase(): void diff --git a/tests/Concerns/Files.php b/tests/Concerns/Files.php index 5688a513..f988267d 100644 --- a/tests/Concerns/Files.php +++ b/tests/Concerns/Files.php @@ -19,7 +19,7 @@ protected function freshFiles(): void protected function copyFiles(): void { File::copyDirectory( - __DIR__ . '/../fixtures/app/actions', + __DIR__ . '/../fixtures/app/operations', $this->targetDirectory() ); } @@ -51,7 +51,7 @@ protected function copyDI(): void protected function copySuccessFailureMethod(): void { File::copy( - __DIR__ . '/../fixtures/app/actions_failed/2021_12_23_165048_run_success_on_failed.php', + __DIR__ . '/../fixtures/app/operations_failed/2021_12_23_165048_run_success_on_failed.php', $this->targetDirectory('2021_12_23_165048_run_success_on_failed.php') ); } @@ -59,7 +59,7 @@ protected function copySuccessFailureMethod(): void protected function copyFailedMethod(): void { File::copy( - __DIR__ . '/../fixtures/app/actions_failed/2021_12_23_184029_run_failed_failure.php', + __DIR__ . '/../fixtures/app/operations_failed/2021_12_23_184029_run_failed_failure.php', $this->targetDirectory('2021_12_23_184029_run_failed_failure.php') ); } @@ -82,7 +82,7 @@ protected function copyFailedTransaction(): void protected function targetDirectory(?string $path = null): string { - $dir = $this->getActionsPath(); + $dir = $this->getOperationsPath(); File::ensureDirectoryExists($dir); @@ -94,8 +94,8 @@ protected function stubsDirectory(): string return base_path('stubs'); } - protected function getActionsPath(): string + protected function getOperationsPath(): string { - return $this->app['config']->get('actions.path'); + return $this->app['config']->get('deploy-operations.path'); } } diff --git a/tests/Helpers/GitTest.php b/tests/Helpers/GitTest.php index fbf15003..82f1cb06 100644 --- a/tests/Helpers/GitTest.php +++ b/tests/Helpers/GitTest.php @@ -4,7 +4,7 @@ namespace Tests\Helpers; -use DragonCode\LaravelActions\Helpers\Git; +use DragonCode\LaravelDeployOperations\Helpers\Git; use Tests\TestCase; class GitTest extends TestCase diff --git a/tests/Helpers/SorterTest.php b/tests/Helpers/SorterTest.php index e76cd1ee..58442e6b 100644 --- a/tests/Helpers/SorterTest.php +++ b/tests/Helpers/SorterTest.php @@ -4,7 +4,7 @@ namespace Tests\Helpers; -use DragonCode\LaravelActions\Helpers\Sorter; +use DragonCode\LaravelDeployOperations\Helpers\Sorter; use Tests\TestCase; class SorterTest extends TestCase @@ -57,7 +57,7 @@ public function testByKeys(): void public function testByRan(): void { - $actions = [ + $items = [ '2022_10_13_013321_test1', 'foo/2022_10_13_013322_test2', 'bar/2022_10_13_013323_test3', @@ -81,7 +81,7 @@ public function testByRan(): void '2022_10_13_013326_test6', ]; - $this->assertSame($expected, $this->sorter()->byRan($actions, $completed)); + $this->assertSame($expected, $this->sorter()->byRan($items, $completed)); } protected function sorter(): Sorter diff --git a/tests/TestCase.php b/tests/TestCase.php index 3c6ac6ff..dbb817dc 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,8 +2,8 @@ namespace Tests; -use DragonCode\LaravelActions\Repositories\ActionRepository; -use DragonCode\LaravelActions\ServiceProvider; +use DragonCode\LaravelDeployOperations\Repositories\OperationsRepository; +use DragonCode\LaravelDeployOperations\ServiceProvider; use Illuminate\Container\Container; use Illuminate\Database\Query\Builder; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -45,8 +45,8 @@ protected function table(): Builder return DB::table($this->table); } - protected function repository(): ActionRepository + protected function repository(): OperationsRepository { - return Container::getInstance()->make(ActionRepository::class); + return Container::getInstance()->make(OperationsRepository::class); } } diff --git a/tests/fixtures/app/async/2021_04_06_212742_every_time.php b/tests/fixtures/app/async/2021_04_06_212742_every_time.php index a63e9ffc..0bfec69f 100644 --- a/tests/fixtures/app/async/2021_04_06_212742_every_time.php +++ b/tests/fixtures/app/async/2021_04_06_212742_every_time.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/di/2022_10_11_234251_invoke_down.php b/tests/fixtures/app/di/2022_10_11_234251_invoke_down.php index cf377cf4..5e9251d0 100644 --- a/tests/fixtures/app/di/2022_10_11_234251_invoke_down.php +++ b/tests/fixtures/app/di/2022_10_11_234251_invoke_down.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/di/2022_10_11_234312_up_down.php b/tests/fixtures/app/di/2022_10_11_234312_up_down.php index e6cf02b0..5323c91a 100644 --- a/tests/fixtures/app/di/2022_10_11_234312_up_down.php +++ b/tests/fixtures/app/di/2022_10_11_234312_up_down.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/2020_12_07_153105_foo_bar.php b/tests/fixtures/app/operations/2020_12_07_153105_foo_bar.php similarity index 82% rename from tests/fixtures/app/actions/2020_12_07_153105_foo_bar.php rename to tests/fixtures/app/operations/2020_12_07_153105_foo_bar.php index 937b25ad..7eb70acc 100644 --- a/tests/fixtures/app/actions/2020_12_07_153105_foo_bar.php +++ b/tests/fixtures/app/operations/2020_12_07_153105_foo_bar.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/2021_01_02_020947_every_time.php b/tests/fixtures/app/operations/2021_01_02_020947_every_time.php similarity index 80% rename from tests/fixtures/app/actions/2021_01_02_020947_every_time.php rename to tests/fixtures/app/operations/2021_01_02_020947_every_time.php index ddb17983..15406867 100644 --- a/tests/fixtures/app/actions/2021_01_02_020947_every_time.php +++ b/tests/fixtures/app/operations/2021_01_02_020947_every_time.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/2021_05_24_120003_run_on_many_environments.php b/tests/fixtures/app/operations/2021_05_24_120003_run_on_many_environments.php similarity index 85% rename from tests/fixtures/app/actions/2021_05_24_120003_run_on_many_environments.php rename to tests/fixtures/app/operations/2021_05_24_120003_run_on_many_environments.php index 08db8003..d2105703 100644 --- a/tests/fixtures/app/actions/2021_05_24_120003_run_on_many_environments.php +++ b/tests/fixtures/app/operations/2021_05_24_120003_run_on_many_environments.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/2021_10_26_143304_run_disallow.php b/tests/fixtures/app/operations/2021_10_26_143304_run_disallow.php similarity index 85% rename from tests/fixtures/app/actions/2021_10_26_143304_run_disallow.php rename to tests/fixtures/app/operations/2021_10_26_143304_run_disallow.php index 1016842c..2d8d1805 100644 --- a/tests/fixtures/app/actions/2021_10_26_143304_run_disallow.php +++ b/tests/fixtures/app/operations/2021_10_26_143304_run_disallow.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/2021_12_23_165047_run_success.php b/tests/fixtures/app/operations/2021_12_23_165047_run_success.php similarity index 87% rename from tests/fixtures/app/actions/2021_12_23_165047_run_success.php rename to tests/fixtures/app/operations/2021_12_23_165047_run_success.php index 43be107a..56fea18a 100644 --- a/tests/fixtures/app/actions/2021_12_23_165047_run_success.php +++ b/tests/fixtures/app/operations/2021_12_23_165047_run_success.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/2021_12_23_184029_run_failed.php b/tests/fixtures/app/operations/2021_12_23_184029_run_failed.php similarity index 82% rename from tests/fixtures/app/actions/2021_12_23_184029_run_failed.php rename to tests/fixtures/app/operations/2021_12_23_184029_run_failed.php index 74898453..b39b7b33 100644 --- a/tests/fixtures/app/actions/2021_12_23_184029_run_failed.php +++ b/tests/fixtures/app/operations/2021_12_23_184029_run_failed.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions/sub_path/2022_10_27_230732_foo.php b/tests/fixtures/app/operations/sub_path/2022_10_27_230732_foo.php similarity index 82% rename from tests/fixtures/app/actions/sub_path/2022_10_27_230732_foo.php rename to tests/fixtures/app/operations/sub_path/2022_10_27_230732_foo.php index 937b25ad..7eb70acc 100644 --- a/tests/fixtures/app/actions/sub_path/2022_10_27_230732_foo.php +++ b/tests/fixtures/app/operations/sub_path/2022_10_27_230732_foo.php @@ -1,11 +1,11 @@ table()->insert([ diff --git a/tests/fixtures/app/actions_failed/2021_12_23_165048_run_success_on_failed.php b/tests/fixtures/app/operations_failed/2021_12_23_165048_run_success_on_failed.php similarity index 85% rename from tests/fixtures/app/actions_failed/2021_12_23_165048_run_success_on_failed.php rename to tests/fixtures/app/operations_failed/2021_12_23_165048_run_success_on_failed.php index 15bc98e1..e2447cfa 100644 --- a/tests/fixtures/app/actions_failed/2021_12_23_165048_run_success_on_failed.php +++ b/tests/fixtures/app/operations_failed/2021_12_23_165048_run_success_on_failed.php @@ -1,11 +1,11 @@