diff --git a/.gitattributes b/.gitattributes index 2c7b640d..69458d0c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,5 +11,4 @@ tests/ export-ignore .gitattributes export-ignore .gitignore export-ignore -package.json export-ignore phpunit.xml export-ignore diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3fc0a56c..04daf8be 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,53 +1,124 @@ -name: docs +name: Documentation on: push: branches: - main - workflow_run: - workflows: - - changelog - types: - - completed workflow_dispatch: -permissions: write-all +permissions: + id-token: write + pages: write + +env: + COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }} + ARTIFACT_DOCS: webHelpDO2-all.zip + INSTANCE: docs/do + DOMAIN_NAME: deploy-operations.dragon-code.pro + BUILDER_VERSION: 2025.03.8312 jobs: - generate: + build: + name: Build application runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Build documentation + uses: JetBrains/writerside-github-action@v4 with: - node-version: '22' + instance: ${{ env.INSTANCE }} + artifact: ${{ env.ARTIFACT_DOCS }} + docker-version: ${{ env.BUILDER_VERSION }} - - name: Cache dependencies - uses: actions/cache@v4 - id: npm-cache + - name: Upload artifacts + uses: actions/upload-artifact@v4 with: + name: docs path: | - **/node_modules - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + artifacts/${{ env.ARTIFACT_DOCS }} + artifacts/report.json + retention-days: 7 - - name: Install dependencies - run: npm i + test: + needs: build + name: Testing + runs-on: ubuntu-latest - - name: Build VuePress site - run: npm run build + steps: + - name: Download docs artifact + uses: actions/download-artifact@v4 + with: + name: docs + path: artifacts - - name: Deploy to GitHub Pages - uses: crazy-max/ghaction-github-pages@v4.2.0 + - name: Test documentation + uses: JetBrains/writerside-checker-action@v1 + with: + instance: ${{ env.INSTANCE }} + + robots: + needs: build + name: Generate robots.txt + runs-on: ubuntu-latest + + steps: + - name: Create robots.txt + run: | + touch robots.txt + echo "User-Agent: *" >> robots.txt + echo "Disallow: " >> robots.txt + echo "Host: https://${{ env.DOMAIN_NAME }}" >> robots.txt + echo "Sitemap: https://${{ env.DOMAIN_NAME }}/sitemap.xml" >> robots.txt + + - name: Upload artifacts + uses: actions/upload-artifact@v4 with: - target_branch: gh-pages - build_dir: docs/.vuepress/dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: robots + path: robots.txt + retention-days: 7 + + deploy-pages: + environment: + name: deploy + url: ${{ steps.deployment.outputs.page_url }} + + needs: + - test + - robots + + name: Deploy to pages + runs-on: ubuntu-latest + + steps: + - name: Download docs artifact + uses: actions/download-artifact@v4 + with: + name: docs + + - name: Download robots artifact + uses: actions/download-artifact@v4 + with: + name: robots + + - name: Unzip artifact + run: unzip -O UTF-8 -qq '${{ env.ARTIFACT_DOCS }}' -d dir + + - name: Move robots + run: | + sudo mv robots.txt dir/robots.txt + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: dir + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/docs/.vuepress/.gitignore b/docs/.vuepress/.gitignore deleted file mode 100644 index 1d57eb52..00000000 --- a/docs/.vuepress/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.cache/ -.temp/ - -dist/ diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js deleted file mode 100644 index dc72e049..00000000 --- a/docs/.vuepress/config.js +++ /dev/null @@ -1,119 +0,0 @@ -import fs from 'fs' -import path from 'path' -import dotenv from 'dotenv' - -import {viteBundler} from '@vuepress/bundler-vite' -import {defaultTheme} from '@vuepress/theme-default' -import {defineUserConfig} from 'vuepress' - -dotenv.config() - -function getChildren(folder, sort = 'asc') { - const extension = ['.md'] - const names = ['index.md', 'readme.md'] - - const dir = `${__dirname}/../${folder}` - - return fs - .readdirSync(path.join(dir)) - .filter(item => fs.statSync(path.join(dir, item)).isFile() && !names.includes(item.toLowerCase()) && extension.includes(path.extname(item))) - .sort((a, b) => { - a = resolveNumeric(a) - b = resolveNumeric(b) - - if (a < b) return sort === 'asc' ? -1 : 1 - if (a > b) return sort === 'asc' ? 1 : -1 - - return 0 - }).map(item => `/${folder}/${item}`) -} - -function resolveNumeric(value) { - const sub = value.substring(0, value.indexOf('.')) - - const num = Number(sub) - - return isNaN(num) ? value : num -} - -const hostname = 'deploy-operations.dragon-code.pro' - -export default defineUserConfig({ - bundler: viteBundler(), - - lang: 'en-US', - title: 'Laravel Deploy Operations', - description: 'Performing any actions during the deployment process', - - head: [['link', {rel: 'icon', href: `https://${hostname}/images/logo.svg`}]], - - theme: defaultTheme({ - hostname, - base: '/', - - logo: `https://${hostname}/images/logo.svg`, - - repo: 'https://github.com/TheDragonCode/laravel-deploy-operations', - repoLabel: 'GitHub', - docsRepo: 'https://github.com/TheDragonCode/laravel-deploy-operations', - docsBranch: 'main', - docsDir: 'docs', - - contributors: false, - editLink: true, - - navbar: [ - { - text: '6.x', - children: [ - { - text: '6.x', - link: '/getting-started/installation.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' - }, - ] - }], - - sidebarDepth: 1, - - sidebar: [ - { - text: 'Getting Started', children: [ - '/index.md', - '/getting-started/installation.md', - '/guide/basic.md', - '/upgrade-guide/index.md' - ] - }, - { - text: 'Guide', - children: [ - '/guide/running.md', - '/guide/creating.md', - '/guide/status.md', - '/guide/rollback.md', - '/guide/customize-stub.md', - ] - }, - { - text: 'Helpers', - children: getChildren('helpers') - }, - { - text: 'Extras', - children: [ - '/extras/database-data-dumper.md' - ] - } - ] - }) -}) diff --git a/docs/.vuepress/public/CNAME b/docs/.vuepress/public/CNAME deleted file mode 100644 index fc3c950d..00000000 --- a/docs/.vuepress/public/CNAME +++ /dev/null @@ -1 +0,0 @@ -deploy-operations.dragon-code.pro diff --git a/docs/.vuepress/public/fonts/Nunito-SemiBold.woff2 b/docs/.vuepress/public/fonts/Nunito-SemiBold.woff2 deleted file mode 100644 index 0f41dd93..00000000 Binary files a/docs/.vuepress/public/fonts/Nunito-SemiBold.woff2 and /dev/null differ diff --git a/docs/.vuepress/styles/_fonts.scss b/docs/.vuepress/styles/_fonts.scss deleted file mode 100644 index 8299f17b..00000000 --- a/docs/.vuepress/styles/_fonts.scss +++ /dev/null @@ -1,9 +0,0 @@ -@charset "UTF-8"; - -@font-face { - font-family: 'Nunito'; - src: local('Nunito'), url(/fonts/Nunito-SemiBold.woff2) format('woff2'); - font-weight: 600; - font-style: normal; - font-display: swap; -} diff --git a/docs/.vuepress/styles/index.scss b/docs/.vuepress/styles/index.scss deleted file mode 100644 index d3b35c71..00000000 --- a/docs/.vuepress/styles/index.scss +++ /dev/null @@ -1,17 +0,0 @@ -@charset "UTF-8"; - -@import "fonts"; - -:root { - --content-width: 800px; -} - -.code-group { - &__nav-tab { - font-family: Nunito, system-ui, sans-serif; - } -} - -.line { - color: rgb(235 235 245 / 86%); -} diff --git a/docs/cfg/buildprofiles.xml b/docs/cfg/buildprofiles.xml new file mode 100644 index 00000000..ed702774 --- /dev/null +++ b/docs/cfg/buildprofiles.xml @@ -0,0 +1,49 @@ + + + + + + true + en_US + logo.svg + + + + https://deploy-operations.dragon-code.pro + true + + https://github.com/TheDragonCode/laravel-deploy-operations/edit/main/docs/ + + + logo.svg,logo.svg,logo.svg,logo.svg + + + + + + https://raw.githubusercontent.com/TheDragonCode/laravel-deploy-operations/refs/heads/main/docs/versions.json + + + + + https://deploy-operations.dragon-code.pro/ + false + + + + + + + + diff --git a/docs/do.tree b/docs/do.tree new file mode 100644 index 00000000..62155acc --- /dev/null +++ b/docs/do.tree @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/docs_libraries.tree b/docs/docs_libraries.tree new file mode 100644 index 00000000..74737f26 --- /dev/null +++ b/docs/docs_libraries.tree @@ -0,0 +1,9 @@ + + + + + + + diff --git a/docs/extras/database-data-dumper.md b/docs/extras/database-data-dumper.md deleted file mode 100644 index c78f0e5f..00000000 --- a/docs/extras/database-data-dumper.md +++ /dev/null @@ -1,31 +0,0 @@ -# Database Dumper - -As you build your application, you may accumulate more and more migrations over time. -This can lead to your `database/migrations` directory becoming bloated with potentially hundreds of migrations. -If you would like, you may "squash" your migrations into a single SQL file. -To get started, execute the `schema:dump` command: - -```bash -php artisan schema:dump -``` - -You can read more about the operation of this console command in -the [official documentation](https://laravel.com/docs/11.x/migrations#squashing-migrations). - -Here we mention this console command because operations tend to save the execution state in order to prevent re-runs -where this is not explicitly allowed. -But if you run sequentially the console commands `php artisan schema:dump` and `php artisan migrate:fresh`, you will see -that all actions will be called again. - -This is due to the fact that the dump mechanism saves the contents of just one table - `migrations`. - -To solve this problem, there is a [Database Data Dumper](https://github.com/TheDragonCode/laravel-data-dumper) -project that allows you to specify a list of tables required for export to a dump. - -In addition to those that you can easily specify in its configuration file, we recommend that you also specify -the `operations` table from this project in order to save the state of the operations when performing a clean deployment -of the database from a dump. - -```bash -composer require dragon-code/laravel-data-dumper --dev -``` diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md deleted file mode 100644 index 4ec4730e..00000000 --- a/docs/getting-started/installation.md +++ /dev/null @@ -1,27 +0,0 @@ -# Installation - -## Install the package - -All you need to do to get started is add `Deploy Operations` to your [composer](https://getcomposer.org) dependencies: - -```bash -composer require dragon-code/laravel-deploy-operations -``` - -If necessary, you can publish the configuration file by calling the console command: - -```bash -php artisan vendor:publish --tag=config --provider="DragonCode\LaravelDeployOperations\ServiceProvider" -``` - -## Publish the operation stub (optional) - -You may publish the stub used by the `make:operation` command and/or [Laravel Idea](https://laravel-idea.com) -plugin for [JetBrains PhpStorm](https://www.jetbrains.com/phpstorm/) if you want to modify it. - -```bash -php artisan vendor:publish --tag=stubs --provider="DragonCode\LaravelDeployOperations\ServiceProvider" -``` - -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/guide/basic.md b/docs/guide/basic.md deleted file mode 100644 index ce17d58e..00000000 --- a/docs/guide/basic.md +++ /dev/null @@ -1,66 +0,0 @@ -# Basic Usage - -Create your first operation using `make:operation` command and define the actions it should perform. - -```bash -php artisan make:operation -``` - -This action will create a new file in the `/operations` folder of your application. - -If you are using the `git` version control system, the name of the currently active branch will be used -as the file name suffix, otherwise the word `auto` will be used. - -You can also specify a name for the file yourself by specifying it with the first argument. -For example, `php artisan make:operation qwerty`. - -```php -use App\Models\Article; -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation { - public function __invoke(): void - { - Article::query() - ->lazyById(chunkSize: 100, column: 'id') - ->each->update(['is_active' => true]); - - // and/or any actions... - } -}; -``` - -Next, To run operations, execute the `operations` artisan command: - -```bash -php artisan operations -``` - -The order in which operations are called is checked by file name in alphabetical order, -without taking into account directory names: - -```bash -# actual file names -2022_10_14_000001_test1 # 1 -2022_10_14_000004_test4 # 4 -bar/2022_10_14_000003_test3 # 3 -foo/2022_10_14_000002_test2 # 2 -``` - -```bash -# order of running operations at startup -2022_10_14_000001_test1 # 1 -foo/2022_10_14_000002_test2 # 2 -bar/2022_10_14_000003_test3 # 3 -2022_10_14_000004_test4 # 4 -``` - -In addition to other options described in the "Guide" section, you can divide the execution of operations into -"before" and "after" certain actions. -For example, before and after restarting the queues: - -```bash -php artisan operations --before -php artisan queue:restart -php artisan operations -``` diff --git a/docs/guide/creating.md b/docs/guide/creating.md deleted file mode 100644 index 2e2db63b..00000000 --- a/docs/guide/creating.md +++ /dev/null @@ -1,154 +0,0 @@ -# Creating Operations - -To create an operation use the `make:operation` artisan command: - -```bash -php artisan make:operation some_name -``` - -The new operation's file will be placed in your `operations` directory in the base path of your app. - -Each operation file name contains a timestamp, which allows Laravel to determine the order of the operations. - -## Asks For File Name - -> The question will not be asked when calling a console command passing the `--quiet` parameter. - -When calling the `operations` console command without passing a name in the `name` parameter, -you will be asked for a name for the file. - -```bash -$ php artisan make:operation - Creating an operation - - ┌ What should the operation be named? ─────────────────────────┐ - │ E.g. activate articles │ - └──────────────────────────────────────────────────────────────┘ - Press Enter to autodetect -``` - -You can enter your own or simply press `Enter` to continue. -In this case, automatic file name generation will be applied. - -## Automatically Generate A File Name - -If you do not specify the "name" attribute, then the file name will be generated automatically according to the rule: - -> git branch name ?: 'auto' - -```bash -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 -# 2022_10_11_225118_qwerty.php -# 2022_10_11_225227_qwerty.php - -### When the git repository is not found (`base_path('.git')` directory doesn't exists). -# 2022_10_11_225116_auto.php -# 2022_10_11_225118_auto.php -# 2022_10_11_225227_auto.php -``` - -## Nested Files - -You can use nested paths to create operations: - -```bash -php artisan make:operation Foo/Bar/QweRty -php artisan make:operation Foo/Bar/QweRty.php - -php artisan make:operation Foo\Bar\QweRty -php artisan make:operation 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 `operations/foo/bar/Y_m_d_His_qwe_rty.php`. - -For example: - -```bash -php artisan make:operation foo\bar\QweRty -# operations/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:operation foo/bar/QweRty -# operations/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 operation class will contain the `__invoke` method, but you can easily replace it with public `up` -name. - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - public function __invoke(): void - { - // some code - } -}; -``` - -> Note that the `__invoke` method has been added as a single call. -> 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\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - 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 operation. -}; -``` - -## Dependency Injection - -You can also use the dependency injection with `__invoke`, `up` and `down` methods: - -```php -use DragonCode\LaravelDeployOperations\Operation; -use Tests\Concerns\Some; - -return new class extends Operation -{ - public function __invoke(Some $some): void - { - $value = $some->get('qwerty'); - } -}; -``` - -```php -use DragonCode\LaravelDeployOperations\Operation; -use Tests\Concerns\Some; - -return new class extends Operation -{ - public function up(Some $some): void - { - $value = $some->get('qwerty'); - } - - public function down(Some $some): void - { - $value = $some->get('qwerty'); - } -}; -``` diff --git a/docs/guide/customize-stub.md b/docs/guide/customize-stub.md deleted file mode 100644 index 3f6a984c..00000000 --- a/docs/guide/customize-stub.md +++ /dev/null @@ -1,11 +0,0 @@ -# Customize Stub - -You may publish the stub used by the `make:operation` command and/or [Laravel Idea](https://laravel-idea.com) -plugin for [JetBrains PhpStorm](https://www.jetbrains.com/phpstorm/) if you want to modify it. - -```bash -php artisan vendor:publish --tag=stubs --provider="DragonCode\LaravelDeployOperations\ServiceProvider" -``` - -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/guide/rollback.md b/docs/guide/rollback.md deleted file mode 100644 index d936f4fc..00000000 --- a/docs/guide/rollback.md +++ /dev/null @@ -1,71 +0,0 @@ -# Rolling Back Operations - -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 operations:rollback -``` - -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 operations:rollback --step=5 -``` - -The `operations:reset` command will roll back all of your application's operations: - -``` -php artisan operations:reset -``` - -For example: - -```bash -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 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 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 -# 2022_10_12_021840_some 3 // will be canceled -# 2022_10_12_021841_some 3 // will be canceled -``` - -## Roll Back & Operation Using A Single Command - -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 operations:refresh -``` - -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 operations:refresh --step=5 -``` - -## Drop All & Rerun Operations - -The `operations:fresh` command will drop all operation records from the operation table and then execute the operations command: - -``` -php artisan operations:fresh -``` diff --git a/docs/guide/running.md b/docs/guide/running.md deleted file mode 100644 index 3e17beeb..00000000 --- a/docs/guide/running.md +++ /dev/null @@ -1,288 +0,0 @@ -# Running Operations - -To run all of your outstanding operations, execute the `operations` artisan command: - -```bash -php artisan operations -``` - -The order in which operations are called is checked by file name in alphabetical order, -without taking into account directory names: - -```bash -# actual file names -2022_10_14_000001_test1 # 1 -2022_10_14_000004_test4 # 4 -bar/2022_10_14_000003_test3 # 3 -foo/2022_10_14_000002_test2 # 2 -``` - -```bash -# order of running operations at startup -2022_10_14_000001_test1 # 1 -foo/2022_10_14_000002_test2 # 2 -bar/2022_10_14_000003_test3 # 3 -2022_10_14_000004_test4 # 4 -``` - -## Isolating Operations Execution - -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 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 operations --isolated -``` - -## Split Launch Option - -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 operations: - -```bash -php artisan operations --before -``` - -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 operations will only be executed if -the option is explicitly passed. - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - protected bool $before = false; - - public function __invoke(): void - { - // some code - } -}; -``` - -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: - -```php -task('deploy', [ - // ... - 'artisan:migrate', - 'artisan:operation --before', // here - 'deploy:publish', - 'php-fpm:reload', - 'artisan:queue:restart', - 'artisan:operations', // here -]); -``` - -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 `operations` command without the `before` parameter, -> then all tasks will be executed regardless of the value of the `$before` -> attribute inside the operation class. - -## Forcing Operations To Run In Production - -> Some commands cannot be executed in production without confirmation. -> These include all commands except `operations:status` and `operations`. - -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 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 operation file: - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - protected bool $once = false; - - public function __invoke(): void - { - // some code - } -}; -``` - -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 `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 operation will be executed twice. - -## Execution In A Specific Environment - -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\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - protected string|array|null $environment = 'production'; - - public function __invoke(): void - { - // some code - } -}; -``` - -You can also specify multiple environment names: - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - protected string|array|null $environment = ['testing', 'staging']; - - public function __invoke(): void - { - // some code - } -}; -``` - -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 operation excluding certain environments. For example `production`. - -For this you can use the `$except_environment` parameter: - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - protected string|array|null $exceptEnvironment = 'production'; - - public function __invoke(): void - { - // some code - } -}; -``` - -You can also specify multiple environment names: - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - protected string|array|null $exceptEnvironment = ['testing', 'staging']; - - public function __invoke(): void - { - // some code - } -}; -``` - -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 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 operation. - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - public function __invoke(): void - { - // some code - } - - public function hasTransactions(): bool - { - return true; - } - - public function transactionAttempts(): int - { - return 4; - } -}; -``` - -## Asynchronous Call - -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` method in the operation class: - -```php -use DragonCode\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - public function __invoke(): void - { - // some code - } - - public function isAsync(): bool - { - return true; - } -}; -``` - -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-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. - -Using Laravel version 8.37 and above, checking for the [uniqueness](https://laravel.com/docs/10.x/queues#unique-jobs) of -the execution is supported. -::: diff --git a/docs/guide/status.md b/docs/guide/status.md deleted file mode 100644 index 19e19080..00000000 --- a/docs/guide/status.md +++ /dev/null @@ -1,8 +0,0 @@ -# Operations Status - -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 operations:status -``` diff --git a/docs/helpers/artisan.md b/docs/helpers/artisan.md deleted file mode 100644 index 344807fc..00000000 --- a/docs/helpers/artisan.md +++ /dev/null @@ -1,18 +0,0 @@ -# Artisan Command - -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\LaravelDeployOperations\Operation; - -return new class extends Operation -{ - public function __invoke(): void - { - $this->artisan('some_command', [ - // parameters - ]); - } -}; -``` diff --git a/docs/helpers/events.md b/docs/helpers/events.md deleted file mode 100644 index f4d84fce..00000000 --- a/docs/helpers/events.md +++ /dev/null @@ -1,54 +0,0 @@ -# Events - -You can also handle events when executing operations: - -```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 operation files to execute, the `NoPendingDeployOperations` event will be sent. - -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\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 = [ - DeployOperationStarted::class => [SomeOperationsListener::class], - DeployOperationEnded::class => [SomeOperationsListener::class], - DeployOperationFailed::class => [SomeOperationsListener::class], - NoPendingDeployOperations::class => [SomeOperationsListener::class], - ]; -} -``` - -```php -namespace App\Listeners; - -use DragonCode\LaravelDeployOperations\Enums\MethodEnum; -use DragonCode\LaravelDeployOperations\Events\BaseEvent; - -class SomeOperationsListener -{ - public function handle(BaseEvent $event): void - { - $method = $event->method; // MethodEnum object value - $isBefore = $event->before; // boolean - } -} -``` diff --git a/docs/helpers/execution-status.md b/docs/helpers/execution-status.md deleted file mode 100644 index 40c19320..00000000 --- a/docs/helpers/execution-status.md +++ /dev/null @@ -1,100 +0,0 @@ -# Execution Status - -You can also override the `success` and `failed` methods, which are called on success or failure processing. - -## If Success - -```php -use DragonCode\LaravelDeployOperations\Operation; -use Illuminate\Support\Facade\Log; - -return new class extends Operation -{ - public function up(): void - { - // - } - - public function down(): void - { - // - } - - public function success(): void - { - Log::info('success'); - } - - public function failed(): void - { - Log::info('failed'); - } -}; -``` - -Call the `php artisan operations` command. - -The log file will contain two `success` entries. - -## If Failed - -```php -use DragonCode\LaravelDeployOperations\Operation; -use Exeption; -use Illuminate\Support\Facade\Log; - -return new class extends Operation -{ - public function up(): void - { - throw new Exeption(); - } - - public function down(): void - { - throw new Exeption(); - } - - public function success(): void - { - Log::info('success'); - } - - public function failed(): void - { - Log::info('failed'); - } -}; -``` - -Call the `php artisan operations` command. - -The log file will contain two `failed` entries. - -## Invokable - -The methods will work in the same way in conjunction with the `__invoke` magic method. -The only difference is that in this case the `down` method will not be executed. - -```php -use DragonCode\LaravelDeployOperations\Operation; -use Illuminate\Support\Facade\Log; - -return new class extends Operation -{ - public function __invoke(): void - { - // - } - - public function success(): void - { - Log::info('success'); - } - - public function failed(): void - { - Log::info('failed'); - } -}; -``` diff --git a/docs/images/badge-not-supported.svg b/docs/images/badge-not-supported.svg new file mode 100644 index 00000000..cdd08a78 --- /dev/null +++ b/docs/images/badge-not-supported.svg @@ -0,0 +1 @@ +not supportednot supported \ No newline at end of file diff --git a/docs/images/badge-not-supported_dark.svg b/docs/images/badge-not-supported_dark.svg new file mode 100644 index 00000000..cdd08a78 --- /dev/null +++ b/docs/images/badge-not-supported_dark.svg @@ -0,0 +1 @@ +not supportednot supported \ No newline at end of file diff --git a/docs/images/badge-supported.svg b/docs/images/badge-supported.svg new file mode 100644 index 00000000..ba3771bb --- /dev/null +++ b/docs/images/badge-supported.svg @@ -0,0 +1 @@ +supportedsupported \ No newline at end of file diff --git a/docs/images/badge-supported_dark.svg b/docs/images/badge-supported_dark.svg new file mode 100644 index 00000000..ba3771bb --- /dev/null +++ b/docs/images/badge-supported_dark.svg @@ -0,0 +1 @@ +supportedsupported \ No newline at end of file diff --git a/docs/.vuepress/public/images/logo.svg b/docs/images/logo.svg similarity index 100% rename from docs/.vuepress/public/images/logo.svg rename to docs/images/logo.svg diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 5f73a510..00000000 --- a/docs/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: 'Introduction' ---- -# 🚀 Laravel Deploy Operations - -![the dragon code laravel deploy operations](https://preview.dragon-code.pro/the-dragon-code/deploy-operations.svg?brand=laravel&mode=dark) - -[![Stable Version][badge_stable]][link_packagist] -[![Total Downloads][badge_downloads]][link_packagist] -[![Github Workflow Status][badge_build]][link_build] -[![License][badge_license]][link_license] - -⚡ **Performing any actions during the deployment process** - -Create specific classes for a one-time or more-time usage, that can be executed automatically after each deployment. -Perfect for seeding or updating some data instantly after some database changes, feature updates, or perform any -actions. - -This package is for you if... - -- you regularly need to update specific data after you deploy new code -- you often perform jobs after deployment -- you sometimes forget to execute that one specific job and stuff gets crazy -- your code gets cluttered with jobs that are not being used anymore -- your co-workers always need to be reminded to execute that one job after some database changes -- you often seed or process data in a migration file (which is a big no-no!) - -[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_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=packagist&style=flat-square - -[link_build]: https://github.com/TheDragonCode/laravel-actions/actions - -[link_license]: license.md - -[link_packagist]: https://packagist.org/packages/dragon-code/laravel-deploy-operations - -[link_website]: https://deploy-operations.dragon-code.pro diff --git a/docs/redirection-rules.xml b/docs/redirection-rules.xml new file mode 100644 index 00000000..cc900128 --- /dev/null +++ b/docs/redirection-rules.xml @@ -0,0 +1,49 @@ + + + + + + Created after removal of "About Deploy Operations" from Deploy Operations + starter-topic.html + + + Created after removal of "Running Operations" from Deploy Operations + guide-running-operations.html + + + Created after removal of "Running operations" from Deploy Operations + running-operations.html + + + Created after removal of "Creation Operations" from Deploy Operations + creation-operations.html + + + Created after removal of "Operations Status" from Deploy Operations + operations-status.html + + + Created after removal of "Helpers" from Deploy Operations + Helpers.html + + + Created after removal of "Rolling Back Operations" from Deploy Operations + Rolling-Back-Operations.html + + + Created after removal of "Artisan Command" from Deploy Operations + artisan-command.html + + + Created after removal of "Events" from Deploy Operations + events.html + + + Created after removal of "Execution Status" from Deploy Operations + execution-status.html + + diff --git a/docs/snippets/actual_file_names.sh b/docs/snippets/actual_file_names.sh new file mode 100644 index 00000000..8b7bd726 --- /dev/null +++ b/docs/snippets/actual_file_names.sh @@ -0,0 +1,5 @@ +# actual file names +2022_10_14_000001_test1 # 1 +2022_10_14_000004_test4 # 4 +bar/2022_10_14_000003_test3 # 3 +foo/2022_10_14_000002_test2 # 2 diff --git a/docs/snippets/ask.sh b/docs/snippets/ask.sh new file mode 100644 index 00000000..93b4d7d5 --- /dev/null +++ b/docs/snippets/ask.sh @@ -0,0 +1,7 @@ +php artisan make:operation + Creating an operation + + ┌ What should the operation be named? ─────────────────────────┐ + │ E.g. activate articles │ + └──────────────────────────────────────────────────────────────┘ + Press Enter to autodetect diff --git a/docs/snippets/async.php b/docs/snippets/async.php new file mode 100644 index 00000000..d88deb62 --- /dev/null +++ b/docs/snippets/async.php @@ -0,0 +1,17 @@ +get('qwerty'); + } +}; diff --git a/docs/snippets/di_up_down.php b/docs/snippets/di_up_down.php new file mode 100644 index 00000000..5d3a6fdf --- /dev/null +++ b/docs/snippets/di_up_down.php @@ -0,0 +1,18 @@ +get('qwerty'); + } + + public function down(Some $some): void + { + $value = $some->get('qwerty'); + } +}; diff --git a/docs/snippets/empty.php b/docs/snippets/empty.php new file mode 100644 index 00000000..e43e0bc3 --- /dev/null +++ b/docs/snippets/empty.php @@ -0,0 +1,12 @@ + [SomeOperationsListener::class], + DeployOperationEnded::class => [SomeOperationsListener::class], + DeployOperationFailed::class => [SomeOperationsListener::class], + NoPendingDeployOperations::class => [SomeOperationsListener::class], + ]; +} diff --git a/docs/snippets/events_list.php b/docs/snippets/events_list.php new file mode 100644 index 00000000..64380926 --- /dev/null +++ b/docs/snippets/events_list.php @@ -0,0 +1,8 @@ +lazyById(chunkSize: 100, column: 'id') + ->each->update(['is_active' => true]); + // and/or any actions... + } +}; diff --git a/docs/snippets/example_artisan.php b/docs/snippets/example_artisan.php new file mode 100644 index 00000000..42dce587 --- /dev/null +++ b/docs/snippets/example_artisan.php @@ -0,0 +1,14 @@ +artisan('some_command', [ + // parameters + ]); + } +}; diff --git a/docs/snippets/except_environment.php b/docs/snippets/except_environment.php new file mode 100644 index 00000000..1a2adbb9 --- /dev/null +++ b/docs/snippets/except_environment.php @@ -0,0 +1,17 @@ +environment(), ['testing', 'staging'], true); + } +}; diff --git a/docs/snippets/failed_status.php b/docs/snippets/failed_status.php new file mode 100644 index 00000000..97e15152 --- /dev/null +++ b/docs/snippets/failed_status.php @@ -0,0 +1,28 @@ +isProduction(); + } +}; diff --git a/docs/snippets/on_environments.php b/docs/snippets/on_environments.php new file mode 100644 index 00000000..e9bb593d --- /dev/null +++ b/docs/snippets/on_environments.php @@ -0,0 +1,17 @@ +environment(), ['testing', 'staging'], true); + } +}; diff --git a/docs/snippets/once_method.php b/docs/snippets/once_method.php new file mode 100644 index 00000000..0d8ece1c --- /dev/null +++ b/docs/snippets/once_method.php @@ -0,0 +1,17 @@ +method; // MethodEnum object value + $isBefore = $event->before; // boolean + } +} diff --git a/docs/snippets/success_status.php b/docs/snippets/success_status.php new file mode 100644 index 00000000..7bd0618b --- /dev/null +++ b/docs/snippets/success_status.php @@ -0,0 +1,28 @@ + + + + + Information on how to call Artisan commands from operations + Information on how to call Artisan commands from operations + Information on how to call Artisan commands from operations + + + +

+ 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: +

+ + +
diff --git a/docs/topics/creating-operations.topic b/docs/topics/creating-operations.topic new file mode 100644 index 00000000..f1e563f4 --- /dev/null +++ b/docs/topics/creating-operations.topic @@ -0,0 +1,125 @@ + + + + + Information on how to create operations + Information on how to create operations + Information on how to create operations + + + + +

+ To create an operation use the %command_make% artisan command: +

+ + + %artisan% %command_make% some_name + + +

+ The new operation's file will be placed in your + %directory% directory in the base path of your app. +

+ +

+ Each operation file name contains a timestamp, which allows Laravel to determine the order of the operations. + For example, +

+ + + 2025_04_02_121627_some_name.php + +
+ + + + The question will not be asked when calling a console command passing the --quiet parameter. + + +

+ When calling the %command_run% console command without passing a name in the name parameter, + you will be asked for a name for the file. +

+ + + +

+ You can enter your own or simply press Enter to continue. + In this case, automatic file name generation will be applied +

+
+ + +

+ If you do not specify the name attribute, + then the file name will be generated automatically according to the rule: +

+ + + + +

+ The name for the file will be automatically obtained from the currently active git repository branch at the root of the project. +

+

+ If the branch name cannot be determined, the word “auto” will be used. +

+
+
+ + +

+ You can use nested paths to create operations: +

+ + + +

+ All of these commands will create a file called %directory%/foo/bar/Y_m_d_His_qwe_rty.php. +

+ +

+ For example: +

+ + +
+ + +

+ By default, the new operation class will contain the __invoke method, + but you can easily replace it with public up name. +

+ + + + +

+ Note that the __invoke method has been added as a single call. + 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. +

+
+ + +
+ + +

+ You can also use the dependency injection with __invoke, up and + down methods: +

+ + + +
+
diff --git a/docs/topics/customize-stub.topic b/docs/topics/customize-stub.topic new file mode 100644 index 00000000..6e41e198 --- /dev/null +++ b/docs/topics/customize-stub.topic @@ -0,0 +1,34 @@ + + + + + Information on how to publish a template file for changes + Information on how to publish a template file for changes + Information on how to publish a template file for changes + + + +

+ You may publish the stub used by the make:operation command and/or + Laravel Idea plugin for + JetBrains PhpStorm if you want to modify it. +

+ + + %vendor_publish% + + +

+ This will create the file stubs/deploy-operation.stub, which you can modify to suit you. + +

+ + +
diff --git a/docs/topics/database-data-dumper.topic b/docs/topics/database-data-dumper.topic new file mode 100644 index 00000000..536be7c2 --- /dev/null +++ b/docs/topics/database-data-dumper.topic @@ -0,0 +1,57 @@ + + + + + Adding data from certain tables when executing the `php artisan schema:dump` console command + Adding data from certain tables when executing the `php artisan schema:dump` console command + Adding data from certain tables when executing the `php artisan schema:dump` console command + + + +

+ As you build your application, you may accumulate more and more migrations over time. + This can lead to your + database/migrations directory becoming bloated with potentially hundreds of migrations. + If you would like, you may "squash" your migrations into a single SQL file. + To get started, execute the schema:dump command: +

+ + + %artisan% schema:dump + + +

+ You can read more about the operation of this console command in the + Laravel documentation. +

+ +

+ Here we mention this console command because operations tend to save the execution state in order to prevent re-runs where this is not explicitly allowed. + But if you run sequentially the console commands %artisan% schema:dump and + %artisan% migrate:fresh, you will see that all actions will be called again. +

+ +

+ This is due to the fact that the dump mechanism saves the contents of just one table - migrations. +

+ +

+ To solve this problem, there is a + Database Data Dumper + project that allows you to specify a list of tables required for export to a dump. +

+ +

+ In addition to those that you can easily specify in its configuration file, + we recommend that you also specify the + operations database table from this project in order to save the state of the operations when performing a clean deployment of the database from a dump. +

+ + + composer require dragon-code/laravel-data-dumper --dev + +
diff --git a/docs/topics/events.topic b/docs/topics/events.topic new file mode 100644 index 00000000..d810b47d --- /dev/null +++ b/docs/topics/events.topic @@ -0,0 +1,43 @@ + + + + + Information about events sent when operations are running + Information about events sent when operations are running + Information about events sent when operations are running + + + +

+ You can also handle events when executing operations: +

+ + + +

+ If there are no operation files to execute, the NoPendingDeployOperations event will be sent. +

+ +

+ In other cases, the DeployOperationStarted event will be sent before processing starts, + and the DeployOperationEnded event will be sent after processing. +

+ +

+ For example: +

+ + + + + +

+ It is also possible to subscribe to events manually: +

+ + +
diff --git a/docs/topics/execution-status.topic b/docs/topics/execution-status.topic new file mode 100644 index 00000000..c7ef5f41 --- /dev/null +++ b/docs/topics/execution-status.topic @@ -0,0 +1,52 @@ + + + + + Information about the execution of actions during successful and unsuccessful operation launches + Information about the execution of actions during successful and unsuccessful operation launches + Information about the execution of actions during successful and unsuccessful operation launches + + + +

+ You can also override the success and failed methods, + which are called on success or failure processing. +

+ + + + +

+ Call the %artisan% %command_run% command. +

+ +

+ The log file will contain one success record. +

+
+ + + + +

+ Call the %artisan% %command_run% command. +

+ +

+ The log file will contain one failed record. +

+
+ + +

+ The methods will work in the same way in conjunction with the __invoke magic method. + The only difference is that in this case the down method will not be executed. +

+ + +
+
diff --git a/docs/topics/installation.topic b/docs/topics/installation.topic new file mode 100644 index 00000000..99f355f2 --- /dev/null +++ b/docs/topics/installation.topic @@ -0,0 +1,106 @@ + + + + + Installation and configuration + Installation and configuration + Installation and configuration + + + +

+ To get the latest version of + %product_short% + , simply require the project using + Composer: +

+ + + composer require %package_name% + + +

+ If necessary, you can publish the configuration file by calling the console command: +

+ + + %vendor_publish% + + +

+ Now you can + + create + + new operations. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PHPLaravelPackageDocumentationStatus
^8.211, 12^7.0supported
^8.210, 11, 12^6.0Documentation + not supported
^8.210, 11^5.0Documentation + not supported
^8.07, 8, 9, 10, 11^4.0Documentation + not supported
^8.07, 8, 9^3.0Documentation + not supported
^7.3, ^8.06, 7, 8, 9^2.0---not supported
^7.3, ^8.06, 7, 8^1.0---not supported
+
+
diff --git a/docs/topics/introduction.topic b/docs/topics/introduction.topic new file mode 100644 index 00000000..66c3da1f --- /dev/null +++ b/docs/topics/introduction.topic @@ -0,0 +1,46 @@ + + + + + + %product% + + + ⚡ Performing any actions during the deployment process + + + + + + + + + Guide + + + + + + + + + Helpers + + + + + + + + + Extras + + + + + + diff --git a/docs/topics/operation-helper.topic b/docs/topics/operation-helper.topic new file mode 100644 index 00000000..0cf69888 --- /dev/null +++ b/docs/topics/operation-helper.topic @@ -0,0 +1,61 @@ + + + + + Information about launching operations with the help of the helper + Information about launching operations with the help of the helper + Information about launching operations with the help of the helper + + + +

+ To quickly call operations from other code, you can use the OperationHelper helper function. +

+ + +

+ This will execute any operations not performed earlier: +

+ + + +

+ For example, +

+ + +
+ + +

+ This will execute all previously unexecuted operations in the specified folder: +

+ + + +

+ For example, +

+ + +
+ + + + This will execute the defined operation file even if it was previously called. + Be careful about calling it again. + + + + +

+ For example, +

+ + +
+
diff --git a/docs/topics/operations-status.topic b/docs/topics/operations-status.topic new file mode 100644 index 00000000..937ede4a --- /dev/null +++ b/docs/topics/operations-status.topic @@ -0,0 +1,29 @@ + + + + + Information on how to view the status of performed operations + Information on how to view the status of performed operations + Information on how to view the status of performed operations + + + +

+ The %command_status% command displays the execution status of operations. + In it you can see which operations were executed and which were not: +

+ + + %artisan% %command_status% + + +

+ For example, +

+ + +
diff --git a/docs/topics/rolling-back-operations.topic b/docs/topics/rolling-back-operations.topic new file mode 100644 index 00000000..11660384 --- /dev/null +++ b/docs/topics/rolling-back-operations.topic @@ -0,0 +1,83 @@ + + + + + Information on how to roll back operations + Information on how to roll back operations + Information on how to roll back operations + + + +

+ To roll back the latest operation, you may use the %command_rollback% command. + This command rolls back the last "batch" of operations, which may include multiple operation files: +

+ + + %artisan% %command_rollback% + + +

+ 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: +

+ + + %artisan% %command_rollback% --step=5 + + +

+ The %command_reset% command will roll back all of your application's operations: +

+ + + %artisan% %command_reset% + + +

+ For example: +

+ + + + +

+ The + %command_refresh% command will roll back all of your operations and then execute the operations command. + This command effectively re-creates your entire database: +

+ + + %artisan% %command_refresh% + + +

+ You may roll back and re-run a limited number of operations by providing the step option to the + %command_refresh% command. + For example, the following command will roll back and re-run the last five operations: +

+ + + %artisan% %command_refresh% --step=5 + +
+ + +

+ The + %command_fresh% command will drop all operation records from the operation table and then execute the operations command: +

+ + + %artisan% %command_fresh% + +
+
diff --git a/docs/topics/running-operations.topic b/docs/topics/running-operations.topic new file mode 100644 index 00000000..d3904972 --- /dev/null +++ b/docs/topics/running-operations.topic @@ -0,0 +1,266 @@ + + + + + Information on how to invoke operations during a deployment + Information on how to invoke operations during a deployment + Information on how to invoke operations during a deployment + + + + + +

+ To run all of your outstanding operations, execute the %command_run% artisan command: +

+ + + %artisan% %command_run% + + +

+ The order in which operations are called is checked by file name in alphabetical order, without taking into account directory names: +

+ + + +
+ + +

+ 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 + %command_run% command. +

+ + + %artisan% %command_run% --isolated + +
+ + +

+ 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 operations: +

+ + + %artisan% %command_run% --before + + +

+ When you call the %command_run% command with the before parameter, + the script will only perform operations for which the needBefore method is true. +

+ +

+ For backwards compatibility, the needBefore method returns true by default, + but operations will only be executed if the option is explicitly passed. +

+ + + +

+ 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 it would look like this: +

+ + + +

+ Thus, when %command_run% is called, all operations whose + before parameter is true will be executed, + and after that, the remaining tasks will be executed. +

+ + + If you call the %command_run% command without the before parameter, + then all tasks will be executed regardless of the value of the + needBefore method inside the operation class. + + + + + + Some commands cannot be executed in production without confirmation. + These include all commands except %command_status% and %command_run%. + + +

+ 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: +

+ + + %artisan% %command_install% --force + +
+ + +

+ 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 shouldOnce method in the operation file: +

+ + + +

+ If the value is shouldOnce is false, + the up method will be called every time the %command_run% command called. +

+ +

+ In this case, information about it will not be written to the + %table% table and, therefore, the + down method will not be called when the rollback command is called. +

+ + + When using the before parameter to run command, + it is recommended to override the value of the needBefore method to false, + otherwise this operation will be executed twice. + +
+ + + + By default, the operation will run in all environments. + + +

+ In some cases, it becomes necessary to execute an operation in a specific environment. + For example production. +

+ +

+ For this you can override the shouldRun method: +

+ + + +

+ You can also specify multiple environment names: +

+ + + +

+ You can work with exceptions in the same way: +

+ + +
+ + +

+ 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 withinTransactions to 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 operation. +

+ + + + +

+ The number of code execution attempts in case of transaction errors is set in the + settings file. +

+

+ By default, the number of attempts is %transactions_attempts%. +

+
+
+ + +

+ 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 shouldBeAsync method in the operation class: +

+ + + +

+ In this case, the operation file that defines this parameter will run asynchronously using the + DragonCode\LaravelDeployOperations\Jobs\OperationJob job. +

+ +

+ The name of the connection and queue can be changed through the settings. +

+ + + We remind you that in this case the + queuing system must work in your application. + +
+ + +

+ Operations can also be invoked when Laravel migrations are completed (php artisan migrate). + The Laravel event system is used for this purpose. +

+ +

+ To do this, add a withOperation public method to your migration file that + will return the name of the file or folder to call. + For example: +

+ + + +

+ Now, once the migration is done, Laravel will send a MigrationEnded event, catching which the + %artisan% %command_run% console command will be called passing this parameter. +

+ +

+ The same thing will happen if you invoke the following console command: +

+ + + %artisan% %command_run% --path="foo/2022_10_14_000002_test2" + + +

+ This method works with all three migration methods: up, down and + __invoke. +

+ +

+ When the %artisan% migrate console command is called, + the operation will call the up or __invoke method. +

+ +

+ When the %artisan% migrate:rollback console command is called, + the operation will call the down method if it exists in the operation file. +

+
+ diff --git a/docs/topics/snippets_composer.topic b/docs/topics/snippets_composer.topic new file mode 100644 index 00000000..809718b8 --- /dev/null +++ b/docs/topics/snippets_composer.topic @@ -0,0 +1,19 @@ + + + + + +

+ Then you need to update the dependencies: +

+ + + composer update + +
+
diff --git a/docs/topics/upgrade-3.topic b/docs/topics/upgrade-3.topic new file mode 100644 index 00000000..fd1ccff7 --- /dev/null +++ b/docs/topics/upgrade-3.topic @@ -0,0 +1,195 @@ + + + + + Guide for upgrading to version 3.x from 2.x + Guide for upgrading to version 3.x from 2.x + Guide for upgrading to version 3.x from 2.x + + + + + + + + + + + + Laravel 6.0 support was ended + Dragon Code: Contracts (dragon-code/contracts) support was ended + + + + + + + + + + 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: +

+ + + composer require dragon-code/laravel-migration-actions:^3.0 + %artisan% migrate:actions:upgrade + %artisan% migrate + + +

+ It will do the following: +

+ + +
  • Change the namespace of the abstract class
  • +
  • Add a strict type declaration
  • +
  • Replace the up method with __invoke if the class does not have a + down method +
  • +
  • Replace named classes with anonymous ones
  • +
  • Create a configuration file according to the data saved in your project
  • +
  • Changes properties from snake_case to camelCase
  • +
    +
    + + + +

    + Deploy Actions for Laravel now requires PHP 8.0.2 or greater. +

    +
    + + +

    + You should update the following dependency in your application's composer.json file: +

    + + + { + "require": { + "dragon-code/laravel-migration-actions": "^3.0" + } + } + +
    +
    + + +

    + Publish the config file and migrate the settings from the config/database.php file to + config/actions.php. +

    + + + %artisan% vendor:publish --provider="DragonCode\LaravelActions\ServiceProvider" + +
    + + + Move the action files to the actions folder in the project root, + or update the actions.path option in the configuration file. + + + + Replace DragonCode\LaravelActions\Support\Actionable with + DragonCode\LaravelActions\Action. + + + +

    + Replace named calls to your application's classes with anonymous ones. +

    + +

    + For example: +

    + + + // before + use DragonCode\LaravelActions\Support\Actionable; + + class Some extends Actionable { } + + // after + use DragonCode\LaravelActions\Action; + + return new class extends Action { }; + +
    + + + If your class does not contain a down method, then you can replace the up method with + __invoke. + + + + Just call the %artisan% migrate command to make changes to the action repository table. + + + +

    + Make sure all overridden properties are typed: +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New NameOld Name
    protected bool $onceprotected $once
    protected bool $transactionsprotected $transactions
    protected int $transactionAttemptsprotected $transaction_attempts
    protected string\|array\|null $environmentprotected $environment
    protected string\|array\|null $exceptEnvironmentprotected $except_environment
    protected bool $beforeprotected $before
    +
    + + +

    + Before: +

    + + + 2022_10_13_013321_test1 + 2022_10_13_013326_test2 + bar/2022_10_13_013323_test3 # will not be called + + +

    + After: +

    + + + 2022_10_13_013321_test1 + 2022_10_13_013326_test2 + bar/2022_10_13_013323_test3 # will be called + +
    +
    diff --git a/docs/topics/upgrade-4.topic b/docs/topics/upgrade-4.topic new file mode 100644 index 00000000..3031fc85 --- /dev/null +++ b/docs/topics/upgrade-4.topic @@ -0,0 +1,151 @@ + + + + + Guide for upgrading to version 4.x from 3.x + Guide for upgrading to version 4.x from 3.x + Guide for upgrading to version 4.x from 3.x + + + + + + + + + + + + + + + + + + + + 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: +

    + + + composer remove dragon-code/laravel-migration-actions + composer require dragon-code/laravel-actions:^4.0 + + %artisan% actions:upgrade + %artisan% migrate + + +

    + It will do the following: +

    + + +
  • Renaming manually invoked commands in a project to a new name
  • +
    +
    + + + +

    + You should update the following dependency in your application's composer.json file: +

    + +

    + Replace: +

    + + + { + "require": { + "dragon-code/laravel-migration-actions": "^3.0" + } + } + + +

    + with: +

    + + + { + "require": { + "dragon-code/laravel-actions": "^4.0" + } + } + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New NameOld Name
    %artisan% make:action%artisan% make:migration:action
    %artisan% actions%artisan% migrate:actions
    %artisan% actions:install%artisan% migrate:actions:install
    %artisan% actions:fresh%artisan% migrate:actions:fresh
    %artisan% actions:refresh%artisan% migrate:actions:refresh
    %artisan% actions:reset%artisan% migrate:actions:reset
    %artisan% actions:rollback%artisan% migrate:actions:rollback
    %artisan% actions:status%artisan% migrate:actions:status
    %artisan% actions:upgrade%artisan% migrate:actions:upgrade
    +
    + + + Replace DragonCode\LaravelActions\Constants\Names::MIGRATE + with DragonCode\LaravelActions\Constants\Names::ACTIONS + + + +

    + The new table name is `actions`. +

    + +

    + You can also specify any name in the application + settings file. +

    + + diff --git a/docs/topics/upgrade-5.topic b/docs/topics/upgrade-5.topic new file mode 100644 index 00000000..8bce803b --- /dev/null +++ b/docs/topics/upgrade-5.topic @@ -0,0 +1,58 @@ + + + + + Guide for upgrading to version 5.x from 4.x + Guide for upgrading to version 5.x from 4.x + Guide for upgrading to version 5.x from 4.x + + + + + + + + + + Deploy Actions + now requires PHP 8.2.0 or greater. + + + +

    + Deploy Actions + now requires Laravel 10.0 or greater. +

    + + +

    + If you are using Laravel 10, then you need to install the dependency: +

    + + + composer require doctrine/dbal + +
    +
    + + +

    + You should update the following dependencies in your application's composer.json file: +

    + + + { + "require": { + "dragon-code/laravel-actions": "^5.0" + } + } + + + +
    +
    +
    diff --git a/docs/topics/upgrade-6.topic b/docs/topics/upgrade-6.topic new file mode 100644 index 00000000..91e22f47 --- /dev/null +++ b/docs/topics/upgrade-6.topic @@ -0,0 +1,296 @@ + + + + + Guide for upgrading to version 6.x from 5.x + Guide for upgrading to version 6.x from 5.x + Guide for upgrading to version 6.x from 5.x + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 operations:upgrade console command: +

    + + + composer remove dragon-code/laravel-actions + composer require dragon-code/laravel-deploy-operations:^6.0 + + %artisan% operations:upgrade + %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. +

    +
    + + +

    + 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: +

    + + + { + "require": { + "dragon-code/laravel-deploy-operations": "^6.0" + } + } + + + +
    + + +

    + 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 +
    . + + + + You should replace DragonCode\LaravelActions\Action namespace with + DragonCode\LaravelDeployOperations\Operation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New NameOld Name
    make:operationmake:action
    operationsactions
    operations:freshactions:fresh
    operations:installactions:install
    operations:refreshactions:refresh
    operations:resetactions:reset
    operations:rollbackactions:rollback
    operations:statusactions:status
    operations:stubactions:stub
    operations:upgradeactions:upgrade
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    New NameOld Name
    DeployOperationStartedActionStarted
    DeployOperationEndedActionEnded
    DeployOperationFailedActionFailed
    NoPendingDeployOperationsNoPendingActions
    + +

    + Don't forget to also change the namespace from DragonCode\LaravelActions\Events to + DragonCode\LaravelDeployOperations\Events. +

    +
    + + +

    + The type of the method property for events has been changed. +

    + + + + use DragonCode\LaravelActions\Events\ActionEnded; + use DragonCode\LaravelDeployOperations\Enums\MethodEnum; + + /** @var ActionEnded */ + $event->method; // is string + + + + + + use DragonCode\LaravelDeployOperations\Enums\MethodEnum; + use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded; + + /** @var DeployOperationEnded */ + $event->method; // is MethodEnum + + +
    + + +

    + 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. +

    + + + %artisan% vendor:publish --provider="DragonCode\LaravelDeployOperations\ServiceProvider" + +
    + + +

    + 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: +

    + + + // Old + class Names + { + public const ACTIONS = 'actions'; + public const FRESH = 'actions:fresh'; + // ... + } + + + // New + class Names + { + public const Fresh = 'operations:fresh'; + public const Operations = 'operations'; + // ... + } + +
    + + + File storage directory changed to /operations from /actions. + + + +

    + The following properties have been removed: +

    + + +
  • $transactions
  • +
  • $transactionAttempts
  • +
    + +

    + Instead, you can use the hasTransactions and transactionAttempts methods. +

    + +

    + The enabledTransactions method has been renamed to hasTransactions. +

    +
    + + + The $async property has been removed from the base class. + You can use the previously available isAsync method instead. + + + + 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. + + + +

    + The %artisan% operations:stub console command has been removed. Use another command instead: +

    + + + %artisan% vendor:publish --tag=stubs --provider="DragonCode\LaravelDeployOperations\ServiceProvider" + +
    + diff --git a/docs/topics/upgrade-7.topic b/docs/topics/upgrade-7.topic new file mode 100644 index 00000000..471f37e9 --- /dev/null +++ b/docs/topics/upgrade-7.topic @@ -0,0 +1,287 @@ + + + + + Guide for upgrading to version 7.x from 6.x + Guide for upgrading to version 7.x from 6.x + Guide for upgrading to version 7.x from 6.x + + + + +
    + + + + + + + + + + + + + + + + + +

    + You should update the following dependencies in your application's composer.json file: +

    + + + { + "require": { + "dragon-code/laravel-deploy-operations": "^7.0" + } + } + + + +
    + + + Laravel 10 version is no longer supported due to the lack of event classes required for + %product_short% + . + + + + We decided to drop support for the php artisan operations:upgrade console command. + It does not exist now. + + + +

    + A strict typification has been added to all the project files. +

    + + + declare(strict_types=1); + +
    + + +

    + The DragonCode\LaravelDeployOperations\Helpers\ConfigHelper class has been removed and + DragonCode\LaravelDeployOperations\Data\Config\ConfigData, which is a Data object, is now used instead. +

    + +

    + For example, +

    + + + - $this->config->path('some'); // /operations/some + - config('deploy-operations.transactions.enabled'); // false + - config('deploy-operations.async'); // false + + + $this->config->path . 'some'; // /operations/some + + $this->config->transactions->enabled; // false + + $this->config->async; // false + +
    + + +

    + This tidied up the handling of settings and options. +

    +

    + If you used a direct reference to the Helpers/Config and + Values/Options classes, update your code. +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New NameOld Name
    Commands\InstallCommandCommands\Install
    Commands\MakeCommandCommands\Make
    Commands\OperationsCommandCommands\Operations
    Commands\FreshCommandCommands\Fresh
    Commands\RefreshCommandCommands\Refresh
    Commands\ResetCommandCommands\Reset
    Commands\RollbackCommandCommands\Rollback
    Commands\StatusCommandCommands\Status
    Processors\FreshProcessorProcessors\Fresh
    Processors\InstallProcessorProcessors\Install
    Processors\MakeProcessorProcessors\Make
    Processors\OperationsProcessorProcessors\Operations
    Processors\RefreshProcessorProcessors\Refresh
    Processors\ResetProcessorProcessors\Reset
    Processors\RollbackProcessorProcessors\Rollback
    Processors\StatusProcessorProcessors\Status
    Helpers\GitHelperHelpers\Git
    Helpers\SorterHelperHelpers\Sorter
    Services\MigratorServiceServices\Migrator
    Services\MutexServiceServices\Mutex
    Values\OptionsDataValues\Options
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    New NameOld Name
    Concerns\HasAboutConcerns\About
    Concerns\HasArtisanConcerns\Artisan
    Concerns\HasIsolatableConcerns\Isolatable
    Concerns\HasOptionableConcerns\Optionable
    +
    + + +

    + The following properties and methods have been removed from the + DragonCode\LaravelDeployOperations\Operation + class: +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    RemovedUse Instead
    protected bool $onceprotected bool shouldOnce(): bool
    protected array|string|null $environmentprotected bool shouldRun(): bool
    protected array|string|null $exceptEnvironmentprotected bool shouldRun(): bool
    protected bool $beforeprotected bool needBefore(): bool
    public function getConnection(): ?stringNot used
    public function isOnce(): boolprotected bool shouldOnce(): bool
    public function enabledTransactions(): boolpublic function withinTransactions(): bool
    public function transactionAttempts(): intIt is indicated in the settings
    public function onEnvironment(): arrayprotected bool shouldRun(): bool
    public function exceptEnvironment(): arrayprotected bool shouldRun(): bool
    public function allow(): boolprotected bool shouldRun(): bool
    public function hasBefore(): boolprotected bool needBefore(): bool
    public function isAsync(): boolprotected bool needAsync(): bool
    +
    + diff --git a/docs/topics/usage.topic b/docs/topics/usage.topic new file mode 100644 index 00000000..e9b40ba8 --- /dev/null +++ b/docs/topics/usage.topic @@ -0,0 +1,22 @@ + + + + + Information on how to use %product_short% + Information on how to use %product_short% + Information on how to use %product_short% + + + + + + + + + + + diff --git a/docs/upgrade-guide/3.x.md b/docs/upgrade-guide/3.x.md deleted file mode 100644 index 64bf0c76..00000000 --- a/docs/upgrade-guide/3.x.md +++ /dev/null @@ -1,125 +0,0 @@ -# Upgrading To 3.x from 2.x - -### High Impact Changes - -- [Change the location of the configuration file](#configuration) -- [Replacing named classes with anonymous ones](#anonymous-classes) -- [Changing the namespace of the parent class](#parent-namespace) -- [Changing variable names from `snake_case` to `camelCase` and added typing](#changed-properties) -- [Added recursive search for actions in a folder](#added-recursive-search-for-actions-in-a-folder) -- [PHP 7.3 and 7.4 was dropped](#php-802-required) -- Laravel 6.0 was dropped -- Dragon Code: Contracts (`dragon-code/contracts`) was dropped - -### Medium Impact Changes - -- [Changing the name of an action column in the database](#changed-action-repository) -- [Action storage directory changed](#actions-location) - -## 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 require dragon-code/laravel-migration-actions:^3.0 -php artisan migrate:actions:upgrade -php artisan migrate -``` - -It will do the following: - -- Change the namespace of the abstract class -- Add a strict type declaration -- Replace the `up` method with `__invoke` if the class does not have a `down` method -- Replace named classes with anonymous ones -- Create a configuration file according to the data saved in your project -- Changes properties from `snake_case` to `camelCase` - -## Updating Dependencies - -### PHP 8.0.2 Required - -Deploy Actions for Laravel now requires PHP 8.0.2 or greater. - -### Composer Dependencies - -You should update the following dependency in your application's `composer.json` file: - -- `dragon-code/laravel-migration-actions` to `^3.0` - -## Configuration - -Publish the config file and migrate the settings from the `config/database.php` file to `config/actions.php`. - -```bash -php artisan vendor:publish --provider="DragonCode\LaravelActions\ServiceProvider" -``` - -## Actions Location - -Move the action files to the `actions` folder in the project root, or update the `actions.path` option in the -configuration file. - -## Parent Namespace - -Replace `DragonCode\LaravelActions\Support\Actionable` with `DragonCode\LaravelActions\Action`. - -## Anonymous Classes - -Replace named calls to your application's classes with anonymous ones. - -For example: - -```php -// before -use DragonCode\LaravelActions\Support\Actionable; - -class Some extends Actionable {} - -// after -use DragonCode\LaravelActions\Action; - -return new class extends Action {}; -``` - -## Invokable Method - -If your class does not contain a `down` method, then you can replace the `up` method with `__invoke`. - -## Changed Action Repository - -Just call the `php artisan migrate` command to make changes to the action repository table. - -## Changed Properties - -Make sure all overridden properties are typed: - -| Old Name | New Name | -|---------------------------------|--------------------------------------------------| -| protected $once | protected bool $once | -| protected $transactions | protected bool $transactions | -| protected $transaction_attempts | protected int $transactionAttempts | -| protected $environment | protected string\|array\|null $environment | -| protected $except_environment | protected string\|array\|null $exceptEnvironment | -| protected $before | protected bool $before | - -## Added recursive search for actions in a folder - -### Before: - -```bash -2022_10_13_013321_test1 -2022_10_13_013326_test2 -bar/2022_10_13_013323_test3 # will not be called -``` - -### After: - -```bash -2022_10_13_013321_test1 -2022_10_13_013326_test2 -bar/2022_10_13_013323_test3 # will be called -``` diff --git a/docs/upgrade-guide/4.x.md b/docs/upgrade-guide/4.x.md deleted file mode 100644 index 760d09cd..00000000 --- a/docs/upgrade-guide/4.x.md +++ /dev/null @@ -1,99 +0,0 @@ -# Upgrading To 4.x from 3.x - -### High-Impact Changes - -- [Rename package name](#rename-package-name) -- [Changing the names of console commands](#changing-the-names-of-console-commands) - -### Medium Impact Changes - -- [`Names::MIGRATE` constant name changed](#names-migrate-constant-name-changed) - -### Low Impact Changes - -- [Changed the default name of the table for storing actions](#changed-the-default-name-of-the-table-for-storing-actions) - -## 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-migration-actions -composer require dragon-code/laravel-actions:^4.0 -php artisan actions:upgrade -php artisan migrate -``` - -It will do the following: - -- Renaming manually invoked commands in a project to a new name - -## Updating Dependencies - -### Rename package name - -You should update the following dependency in your application's `composer.json` file: - -Replace: - -```json -{ - "require": { - "dragon-code/laravel-migration-actions": "^3.0" - } -} -``` - -with - -```json -{ - "require": { - "dragon-code/laravel-actions": "^4.0" - } -} -``` - -Then you need to update the dependencies: - -```bash -composer update -``` - -## Changing the names of console commands - -| Old Name | New Name | -|----------------------------------------|--------------------------------| -| `php artisan make:migration:action` | `php artisan make:action` | -| `php artisan migrate:actions` | `php artisan actions` | -| `php artisan migrate:actions:install` | `php artisan actions:install` | -| `php artisan migrate:actions:fresh` | `php artisan actions:fresh` | -| `php artisan migrate:actions:refresh` | `php artisan actions:refresh` | -| `php artisan migrate:actions:reset` | `php artisan actions:reset` | -| `php artisan migrate:actions:rollback` | `php artisan actions:rollback` | -| `php artisan migrate:actions:status` | `php artisan actions:status` | -| `php artisan migrate:actions:upgrade` | `php artisan actions:upgrade` | - -## `Names::MIGRATE` constant name changed - -Replace - -```php -DragonCode\LaravelActions\Constants\Names::MIGRATE -``` - -with - -```php -DragonCode\LaravelActions\Constants\Names::ACTIONS -``` - -## Changed the default name of the table for storing actions - -The new table name is `actions`. - -You can also specify any name in the -application [settings](https://github.com/TheDragonCode/laravel-actions/blob/main/config/actions.php). diff --git a/docs/upgrade-guide/5.x.md b/docs/upgrade-guide/5.x.md deleted file mode 100644 index 620878fe..00000000 --- a/docs/upgrade-guide/5.x.md +++ /dev/null @@ -1,35 +0,0 @@ -# Upgrading To 5.x from 4.x - -## High Impact Changes - -- [Updating Dependencies](#updating-dependencies) - -## Updating Dependencies - -### PHP 8.2.0 Required - -`Deploy Actions for Laravel` now requires PHP 8.2.0 or greater. - -### Laravel 10.0 Required - -`Deploy Actions` now requires Laravel 10.0 or greater. - -### Composer Dependencies - -You should update the following dependencies in your application's `composer.json` file: - -- `dragon-code/laravel-actions` to `^5.0` - -Then you need to update the dependencies: - -```bash -composer update -``` - -### Laravel 10 - -If you are using Laravel 10, then you need to install the dependency: - -```bash -composer require doctrine/dbal -``` diff --git a/docs/upgrade-guide/6.x.md b/docs/upgrade-guide/6.x.md deleted file mode 100644 index b75dd6e3..00000000 --- a/docs/upgrade-guide/6.x.md +++ /dev/null @@ -1,198 +0,0 @@ -# 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 directory location](#changed-directory-location) -- [Database transactions](#database-transactions) -- [Removed `$async` property](#removed-async-property) -- [Removed `operations:stub` command](#removed-operationsstub-command) -- [Changed property typing for events](#changed-property-typing-for-events) - -## 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`. - -## Changed property typing for events - -The type of the `method` property for events has been changed. - -Before: - -```php -use DragonCode\LaravelActions\Events\ActionEnded; -use DragonCode\LaravelDeployOperations\Enums\MethodEnum; - -/** @var ActionEnded */ -$event->method; // is string -``` - -After: - -```php -use DragonCode\LaravelDeployOperations\Enums\MethodEnum; -use DragonCode\LaravelDeployOperations\Events\DeployOperationEnded; - -/** @var DeployOperationEnded */ -$event->method; // is MethodEnum -``` - -## 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 directory location - -File storage directory changed to `operations` from `actions`. - -## Database transactions - -The following properties have been removed: - -- `$transactions` -- `$transactionAttempts` - -Instead, you can use the `hasTransactions` and `transactionAttempts` methods. - -The `enabledTransactions` method has been renamed to `hasTransactions`. - -## Removed `$async` property - -The `$async` property has been removed from the base class. -You can use the previously available `isAsync` method instead. - -## 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. - -## Removed `operations:stub` command - -The `php artisan operations:stub` console command has been removed. Use another command instead: - -```bash -php artisan vendor:publish --tag=stubs --provider="DragonCode\LaravelDeployOperations\ServiceProvider" -``` diff --git a/docs/upgrade-guide/index.md b/docs/upgrade-guide/index.md deleted file mode 100644 index 024262d9..00000000 --- a/docs/upgrade-guide/index.md +++ /dev/null @@ -1,6 +0,0 @@ -# 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/docs/v.list b/docs/v.list new file mode 100644 index 00000000..7d50fb15 --- /dev/null +++ b/docs/v.list @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/versions.json b/docs/versions.json new file mode 100644 index 00000000..a17d18f7 --- /dev/null +++ b/docs/versions.json @@ -0,0 +1,27 @@ +[ + { + "version": "7.x", + "url": "https://deploy-operations.dragon-code.pro", + "isCurrent": true + }, + { + "version": "6.x", + "url": "https://github.com/TheDragonCode/laravel-deploy-operations/tree/6.x/docs", + "isCurrent": false + }, + { + "version": "5.x", + "url": "https://github.com/TheDragonCode/laravel-deploy-operations/tree/5.x/docs", + "isCurrent": false + }, + { + "version": "4.x", + "url": "https://github.com/TheDragonCode/laravel-deploy-operations/tree/4.x/docs", + "isCurrent": false + }, + { + "version": "3.x", + "url": "https://github.com/TheDragonCode/laravel-deploy-operations/tree/3.x/docs", + "isCurrent": false + } +] diff --git a/docs/writerside.cfg b/docs/writerside.cfg new file mode 100644 index 00000000..a24db4b0 --- /dev/null +++ b/docs/writerside.cfg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/package.json b/package.json deleted file mode 100644 index f0f5bb19..00000000 --- a/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "docs", - "version": "1.0.0", - "description": "Performing actions with saving the list of called files", - "author": "Andrey Helldar ", - "license": "MIT", - "homepage": "https://github.com/TheDragonCode/laravel-actions", - "bugs": { - "url": "https://github.com/TheDragonCode/laravel-actions/issues" - }, - "scripts": { - "dev": "vuepress dev docs --debug", - "build": "vuepress build docs" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/TheDragonCode/laravel-actions.git" - }, - "devDependencies": { - "@vuepress/bundler-vite": "^2.0.0-rc.15", - "@vuepress/plugin-prismjs": "^2.0.0-rc.43", - "@vuepress/plugin-shiki": "^2.0.0-rc.0", - "@vuepress/theme-default": "^2.0.0-rc.43", - "@vueuse/core": "^7.7.1", - "dotenv": "^16.4.5", - "sass-embedded": "^1.78.0", - "vuepress": "^2.0.0-rc.15" - }, - "engines": { - "node": ">=22.8" - } -} diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index f63c5839..d90c4447 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -65,7 +65,7 @@ protected function publishConfig(): void { $this->publishes([ __DIR__ . '/../config/deploy-operations.php' => $this->app->configPath('deploy-operations.php'), - ], 'config'); + ], ['config', 'deploy-operations']); } protected function publishStub(): void @@ -74,7 +74,7 @@ protected function publishStub(): void __DIR__ . '/../resources/stubs/deploy-operation.stub' => $this->app->basePath( 'stubs/deploy-operation.stub' ), - ], 'stubs'); + ], ['stubs', 'deploy-operations']); } protected function registerConfig(): void