diff --git a/docs/recipe/typo3.md b/docs/recipe/typo3.md index d1dc48278..b96683cbc 100644 --- a/docs/recipe/typo3.md +++ b/docs/recipe/typo3.md @@ -28,38 +28,71 @@ Additionally, Deployer has a lot of other features, like: You can read more about Deployer in [Getting Started](/docs/getting-started.md). The [deploy](#deploy) task of **TYPO3** consists of: -* [deploy:prepare](/docs/recipe/common.md#deploy-prepare) – Prepares a new release - * [deploy:info](/docs/recipe/deploy/info.md#deploy-info) – Displays info about deployment - * [deploy:setup](/docs/recipe/deploy/setup.md#deploy-setup) – Prepares host for deploy - * [deploy:lock](/docs/recipe/deploy/lock.md#deploy-lock) – Locks deploy - * [deploy:release](/docs/recipe/deploy/release.md#deploy-release) – Prepares release - * [deploy:update_code](/docs/recipe/deploy/update_code.md#deploy-update_code) – Updates code - * [deploy:env](/docs/recipe/deploy/env.md#deploy-env) – Configure .env file - * [deploy:shared](/docs/recipe/deploy/shared.md#deploy-shared) – Creates symlinks for shared files and dirs - * [deploy:writable](/docs/recipe/deploy/writable.md#deploy-writable) – Makes writable dirs +* [deploy:info](/docs/recipe/deploy/info.md#deploy-info) – Displays info about deployment +* [deploy:setup](/docs/recipe/deploy/setup.md#deploy-setup) – Prepares host for deploy +* [deploy:lock](/docs/recipe/deploy/lock.md#deploy-lock) – Locks deploy +* [deploy:release](/docs/recipe/deploy/release.md#deploy-release) – Prepares release +* [typo3:update_code](/docs/recipe/typo3.md#typo3-update_code) – +* [deploy:shared](/docs/recipe/deploy/shared.md#deploy-shared) – Creates symlinks for shared files and dirs +* [deploy:writable](/docs/recipe/deploy/writable.md#deploy-writable) – Makes writable dirs * [deploy:vendors](/docs/recipe/deploy/vendors.md#deploy-vendors) – Installs vendors -* [deploy:publish](/docs/recipe/common.md#deploy-publish) – Publishes the release - * [deploy:symlink](/docs/recipe/deploy/symlink.md#deploy-symlink) – Creates symlink to release - * [deploy:unlock](/docs/recipe/deploy/lock.md#deploy-unlock) – Unlocks deploy - * [deploy:cleanup](/docs/recipe/deploy/cleanup.md#deploy-cleanup) – Cleanup old releases - * [deploy:success](/docs/recipe/common.md#deploy-success) – Deploys your project +* [typo3:cache:warmup](/docs/recipe/typo3.md#typo3-cache-warmup) – TYPO3 - Cache warmup for system caches +* [typo3:extension:setup](/docs/recipe/typo3.md#typo3-extension-setup) – TYPO3 - Set up all extensions +* [typo3:language:update](/docs/recipe/typo3.md#typo3-language-update) – TYPO3 - Update the language files of all activated extensions +* [typo3:cache:flush](/docs/recipe/typo3.md#typo3-cache-flush) – TYPO3 - Cache clearing for frontend caches +* [typo3:cache:pages:warmup](/docs/recipe/typo3.md#typo3-cache-pages-warmup) – TYPO3 - Cache warmup for frontend caches +* [deploy:unlock](/docs/recipe/deploy/lock.md#deploy-unlock) – Unlocks deploy +* [deploy:cleanup](/docs/recipe/deploy/cleanup.md#deploy-cleanup) – Cleanup old releases +* [deploy:success](/docs/recipe/common.md#deploy-success) – Deploys your project The typo3 recipe is based on the [common](/docs/recipe/common.md) recipe. ## Configuration +### composer_config +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L10) + + + +```php title="Default value" +return json_decode(file_get_contents('./composer.json'), true, 512, JSON_THROW_ON_ERROR); +``` + + ### typo3_webroot -[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L12) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L17) DocumentRoot / WebRoot for the TYPO3 installation +:::info Autogenerated +The value of this configuration is autogenerated on access. +::: + + + + +### bin/typo3 +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L30) + +Path to TYPO3 cli +:::info Autogenerated +The value of this configuration is autogenerated on access. +::: + + + + +### log_files +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L43) + +Log files to display when running `./vendor/bin/dep logs:app` ```php title="Default value" -'Web' +'var/log/typo3_*.log' ``` ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L27) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L48) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -69,13 +102,16 @@ Shared directories [ '{{typo3_webroot}}/fileadmin', '{{typo3_webroot}}/typo3temp', - '{{typo3_webroot}}/uploads', + 'var/session', + 'var/log', + 'var/lock', + 'var/charset', ] ``` ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L36) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L60) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -83,13 +119,14 @@ Shared files ```php title="Default value" [ - '{{typo3_webroot}}/.htaccess', + 'config/system/settings.php', + '.env', ] ``` ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L43) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L68) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -99,8 +136,60 @@ Writeable directories [ '{{typo3_webroot}}/fileadmin', '{{typo3_webroot}}/typo3temp', - '{{typo3_webroot}}/typo3conf', - '{{typo3_webroot}}/uploads', + 'var', +] +``` + + +### composer_options +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L77) + +Overrides [composer_options](/docs/recipe/deploy/vendors.md#composer_options) from `recipe/deploy/vendors.php`. + +Composer options + +```php title="Default value" +' --no-dev --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader' +``` + + +### use_rsync +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L83) + +If set in the config this recipe uses rsync. Default: false (use the Git repository) + +```php title="Default value" +false +``` + + +### update_code_task +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L85) + + + +```php title="Default value" +return get('use_rsync') ? 'rsync' : 'deploy:update_code'; +``` + + +### rsync +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L112) + + + +```php title="Default value" +[ + 'exclude' => array_merge(get('shared_dirs'), get('shared_files'), $exclude), + 'exclude-file' => false, + 'include' => ['vendor'], + 'include-file' => false, + 'filter' => ['dir-merge,-n /.gitignore'], + 'filter-file' => false, + 'filter-perdir' => false, + 'flags' => 'avz', + 'options' => ['delete', 'keep-dirlinks', 'links'], + 'timeout' => 600, ] ``` @@ -108,17 +197,78 @@ Writeable directories ## Tasks +### typo3\:update_code {#typo3-update_code} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L89) + + + + + + +### typo3\:cache\:warmup {#typo3-cache-warmup} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L126) + +TYPO3 - Cache warmup for system caches. + + + + +### typo3\:cache\:flush {#typo3-cache-flush} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L132) + +TYPO3 - Cache clearing for frontend caches. + + + + +### typo3\:cache\:pages\:warmup {#typo3-cache-pages-warmup} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L138) + +TYPO3 - Cache warmup for frontend caches. + + + + +### typo3\:language\:update {#typo3-language-update} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L144) + +TYPO3 - Update the language files of all activated extensions. + + + + +### typo3\:extension\:setup {#typo3-extension-setup} +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L150) + +TYPO3 - Set up all extensions. + + + + ### deploy {#deploy} -[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L18) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/typo3.php#L159) -Deploys your project. +Deploys a TYPO3 project. -Main TYPO3 task +Configure "deploy" task group. This task is group task which contains next tasks: -* [deploy:prepare](/docs/recipe/common.md#deploy-prepare) +* [deploy:info](/docs/recipe/deploy/info.md#deploy-info) +* [deploy:setup](/docs/recipe/deploy/setup.md#deploy-setup) +* [deploy:lock](/docs/recipe/deploy/lock.md#deploy-lock) +* [deploy:release](/docs/recipe/deploy/release.md#deploy-release) +* [typo3:update_code](/docs/recipe/typo3.md#typo3-update_code) +* [deploy:shared](/docs/recipe/deploy/shared.md#deploy-shared) +* [deploy:writable](/docs/recipe/deploy/writable.md#deploy-writable) * [deploy:vendors](/docs/recipe/deploy/vendors.md#deploy-vendors) -* [deploy:publish](/docs/recipe/common.md#deploy-publish) +* [typo3:cache:warmup](/docs/recipe/typo3.md#typo3-cache-warmup) +* [typo3:extension:setup](/docs/recipe/typo3.md#typo3-extension-setup) +* [typo3:language:update](/docs/recipe/typo3.md#typo3-language-update) +* [typo3:cache:flush](/docs/recipe/typo3.md#typo3-cache-flush) +* [typo3:cache:pages:warmup](/docs/recipe/typo3.md#typo3-cache-pages-warmup) +* [deploy:unlock](/docs/recipe/deploy/lock.md#deploy-unlock) +* [deploy:cleanup](/docs/recipe/deploy/cleanup.md#deploy-cleanup) +* [deploy:success](/docs/recipe/common.md#deploy-success) diff --git a/recipe/typo3.php b/recipe/typo3.php index ae01a00cf..5da2c3cda 100644 --- a/recipe/typo3.php +++ b/recipe/typo3.php @@ -3,46 +3,172 @@ namespace Deployer; require_once __DIR__ . '/common.php'; +require_once 'contrib/rsync.php'; add('recipes', ['typo3']); +set('composer_config', function () { + return json_decode(file_get_contents('./composer.json'), true, 512, JSON_THROW_ON_ERROR); +}); + /** * DocumentRoot / WebRoot for the TYPO3 installation */ -set('typo3_webroot', 'Web'); +set('typo3/public_dir', function () { + $composerConfig = get('composer_config'); + + if ($composerConfig['extra']['typo3/cms']['web-dir'] ?? false) { + return $composerConfig['extra']['typo3/cms']['web-dir']; + } + + return 'public'; +}); /** - * Main TYPO3 task + * Path to TYPO3 cli */ -desc('Deploys your project'); -task('deploy', [ - 'deploy:prepare', - 'deploy:vendors', - 'deploy:publish', -]); +set('bin/typo3', function () { + $composerConfig = get('composer_config'); + + if ($composerConfig['config']['bin-dir'] ?? false) { + return $composerConfig['config']['bin-dir'] . '/typo3'; + } + + return 'vendor/bin/typo3'; +}); + +/** + * Log files to display when running `./vendor/bin/dep logs:app` + */ +set('log_files', 'var/log/typo3_*.log'); /** * Shared directories */ set('shared_dirs', [ - '{{typo3_webroot}}/fileadmin', - '{{typo3_webroot}}/typo3temp', - '{{typo3_webroot}}/uploads', + '{{typo3/public_dir}}/fileadmin', + '{{typo3/public_dir}}/assets', + '{{typo3/public_dir}}/typo3temp/assets', + 'var/lock', + 'var/log', + 'var/session', + 'var/spool', ]); /** * Shared files */ -set('shared_files', [ - '{{typo3_webroot}}/.htaccess', -]); +if (!has('shared_files') || empty(get('shared_files'))) { + set('shared_files', [ + 'config/system/settings.php', + ]); +} /** * Writeable directories */ set('writable_dirs', [ - '{{typo3_webroot}}/fileadmin', - '{{typo3_webroot}}/typo3temp', - '{{typo3_webroot}}/typo3conf', - '{{typo3_webroot}}/uploads', + '{{typo3/public_dir}}/fileadmin', + '{{typo3/public_dir}}/assets', + '{{typo3/public_dir}}/typo3temp/assets', + 'var/cache', + 'var/lock', + 'var/log', +]); + +/** + * Composer options + */ +set('composer_options', ' --no-dev --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader'); + + +/** + * If set in the config this recipe uses rsync. Default: false (use the Git repository) + */ +set('use_rsync', false); + +set('update_code_task', function () { + return get('use_rsync') ? 'rsync' : 'deploy:update_code'; +}); + +task('typo3:update_code', function () { + invoke(get('update_code_task')); +}); + +$exclude = [ + '.Build', + '.git', + '.gitlab', + '.ddev', + '.deployer', + '.idea', + '.DS_Store', + '.gitlab-ci.yml', + '.npm', + 'deploy.yaml', + 'package.json', + 'package-lock.json', + 'node_modules/', + 'var/', + '/{{typo3/public_dir}}/assets', + '/{{typo3/public_dir}}/fileadmin', + '/{{typo3/public_dir}}/typo3temp', +]; + +set('rsync', [ + 'exclude' => array_merge(get('shared_dirs'), get('shared_files'), $exclude), + 'exclude-file' => false, + 'include' => ['vendor'], + 'include-file' => false, + 'filter' => ['dir-merge,-n /.gitignore'], + 'filter-file' => false, + 'filter-perdir' => false, + 'flags' => 'avz', + 'options' => ['delete', 'keep-dirlinks', 'links'], + 'timeout' => 600, +]); + + +desc('TYPO3 - Clear all caches'); +task('typo3:cache:flush', function () { + run('{{bin/php}} {{release_path}}/public/typo3 cache:flush '); +}); + +desc('TYPO3 - Cache warmup for system caches'); +task('typo3:cache:warmup', function () { + run('{{bin/php}} {{release_path}}/public/typo3 cache:warmup --group system'); +}); + +desc('TYPO3 - Update the language files of all activated extensions'); +task('typo3:language:update', function () { + run('{{bin/php}} {{release_path}}/public/typo3 language:update'); +}); + +desc('TYPO3 - Set up all extensions'); +task('typo3:extension:setup', function () { + run('{{bin/php}} {{release_path}}/public/typo3 extension:setup'); +}); + +/** + * Configure "deploy" task group. + */ +desc('Deploys a TYPO3 project'); +task('deploy', [ + 'deploy:info', + 'deploy:setup', + 'deploy:lock', + 'deploy:release', + 'typo3:update_code', + 'deploy:shared', + 'deploy:writable', + 'deploy:vendors', + 'typo3:cache:warmup', + 'typo3:extension:setup', + 'typo3:language:update', + 'typo3:cache:flush', + 'deploy:unlock', + 'deploy:cleanup', + 'deploy:success', ]); + +after('deploy:failed', 'deploy:unlock');