From dbac6114e3208c4eca6b868671728e73c031367b Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Mon, 31 Oct 2022 18:27:38 +0100 Subject: [PATCH 1/9] Magento: create variable for bin/magento so it can be overridden to a custom location --- recipe/magento2.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 440f0a273..159a283a8 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -75,16 +75,18 @@ 'var/view_preprocessed/*' ]); +set('bin/magento', '{{release_or_current_path}}/bin/magento'); + set('magento_version', function () { // detect version - $versionOutput = run('{{bin/php}} {{release_or_current_path}}/bin/magento --version'); + $versionOutput = run('{{bin/php}} {{bin/magento}} --version'); preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); return $matches[0] ?? '2.0'; }); set('maintenance_mode_status_active', function () { // detect maintenance mode active - $maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/bin/magento maintenance:status"); + $maintenanceModeStatusOutput = run("{{bin/php}} {{bin/magento}} maintenance:status"); return strpos($maintenanceModeStatusOutput, MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG) !== false; }); @@ -94,8 +96,7 @@ // Tasks desc('Compiles magento di'); task('magento:compile', function () { - run('cd {{release_or_current_path}} && {{bin/composer}} dump-autoload -o'); - run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:di:compile"); + run("{{bin/php}} {{bin/magento}} setup:di:compile"); run('cd {{release_or_current_path}} && {{bin/composer}} dump-autoload -o'); }); @@ -109,7 +110,7 @@ } } - run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_content_locales}} $themesToCompile -j {{static_content_jobs}}"); + run("{{bin/php}} {{bin/magento}} setup:static-content:deploy --content-version={{content_version}} {{static_content_locales}} $themesToCompile -j {{static_content_jobs}}"); }); desc('Syncs content version'); @@ -144,7 +145,7 @@ $configImportNeeded = true; } else { try { - run('{{bin/php}} {{release_or_current_path}}/bin/magento app:config:status'); + run('{{bin/php}} {{bin/magento}} app:config:status'); } catch (RunException $e) { if ($e->getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { $configImportNeeded = true; @@ -159,7 +160,7 @@ invoke('magento:maintenance:enable'); } - run('{{bin/php}} {{release_or_current_path}}/bin/magento app:config:import --no-interaction'); + run('{{bin/php}} {{bin/magento}} app:config:import --no-interaction'); if (get('enable_zerodowntime') && !get('maintenance_mode_status_active')) { invoke('magento:maintenance:disable'); @@ -172,7 +173,7 @@ $databaseUpgradeNeeded = false; try { - run('{{bin/php}} {{release_or_current_path}}/bin/magento setup:db:status'); + run('{{bin/php}} {{bin/magento}} setup:db:status'); } catch (RunException $e) { if ($e->getExitCode() == DB_UPDATE_NEEDED_EXIT_CODE) { $databaseUpgradeNeeded = true; @@ -186,7 +187,7 @@ invoke('magento:maintenance:enable'); } - run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:upgrade --keep-generated --no-interaction"); + run("{{bin/php}} {{bin/magento}} setup:upgrade --keep-generated --no-interaction"); if (get('enable_zerodowntime') && !get('maintenance_mode_status_active')) { invoke('magento:maintenance:disable'); @@ -196,7 +197,7 @@ desc('Flushes Magento Cache'); task('magento:cache:flush', function () { - run("{{bin/php}} {{release_or_current_path}}/bin/magento cache:flush"); + run("{{bin/php}} {{bin/magento}} cache:flush"); }); desc('Magento2 deployment operations'); From a7298a8b3307ca6ba1e4c391183beeb178b50c17 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 25 Jan 2023 16:41:32 +0100 Subject: [PATCH 2/9] Update docs --- docs/recipe/magento2.md | 68 +++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index b3b901090..79ed36934 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -179,33 +179,43 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ``` -### magento_version +### bin/magento [Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78) +```php title="Default value" +'{{release_or_current_path}}/bin/magento' +``` + + +### magento_version +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L80) + + + ```php title="Default value" // detect version -$versionOutput = run('{{bin/php}} {{release_or_current_path}}/bin/magento --version'); +$versionOutput = run('{{bin/php}} {{bin/magento}} --version'); preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); return $matches[0] ?? '2.0'; ``` ### maintenance_mode_status_active -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L85) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L87) ```php title="Default value" // detect maintenance mode active -$maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/bin/magento maintenance:status"); +$maintenanceModeStatusOutput = run("{{bin/php}} {{bin/magento}} maintenance:status"); return strpos($maintenanceModeStatusOutput, MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG) !== false; ``` ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L94) Deploy without setting maintenance mode if possible @@ -215,7 +225,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L229) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L230) artifact deployment section settings section @@ -226,7 +236,7 @@ settings section ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L230) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L231) @@ -236,7 +246,7 @@ settings section ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L231) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L232) @@ -246,7 +256,7 @@ settings section ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) @@ -259,7 +269,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L240) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L241) :::info Autogenerated @@ -270,14 +280,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L302) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L303) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L304) Array of shared directories that will be added to the default shared_dirs without overriding @@ -287,7 +297,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L96) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L98) Compiles magento di. @@ -295,7 +305,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L103) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L104) Deploys assets. @@ -303,7 +313,7 @@ Deploys assets. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L116) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L117) Syncs content version. @@ -311,7 +321,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L126) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L127) Enables maintenance mode. @@ -319,7 +329,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L132) Disables maintenance mode. @@ -327,7 +337,7 @@ Disables maintenance mode. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L136) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L137) Config Import. @@ -335,7 +345,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L171) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L172) Upgrades magento database. @@ -343,7 +353,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L198) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) Flushes Magento Cache. @@ -351,7 +361,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L203) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L204) Magento2 deployment operations. @@ -366,7 +376,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L211) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L212) Magento2 build operations. @@ -379,7 +389,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L217) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L218) Deploys your project. @@ -395,7 +405,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L250) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L251) Packages all relevant files in an artifact. @@ -403,7 +413,7 @@ tasks section ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L260) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L261) Uploads artifact in release folder for extraction. @@ -411,7 +421,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L265) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L266) Extracts artifact in release path. @@ -419,7 +429,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L271) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L272) Clears generated files prior to building. @@ -427,7 +437,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L276) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L277) Prepare local artifact build. @@ -435,7 +445,7 @@ Prepare local artifact build. ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L307) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L308) Adds additional files and dirs to the list of shared files and dirs. From 86f18bebaea872775dcc49b15f4de0eca441f1ec Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 2 Nov 2022 14:08:11 +0100 Subject: [PATCH 3/9] Allow Magento to be installed in a subdirectory --- recipe/magento2.php | 62 ++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 440f0a273..329d62208 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -40,39 +40,43 @@ return time(); }); +// Magento directory relative to repository root. Use "." (default) if it is not located in a subdirectory +set('magento_dir', '.'); + + set('shared_files', [ - 'app/etc/env.php', - 'var/.maintenance.ip', + '{{magento_dir}}/app/etc/env.php', + '{{magento_dir}}/var/.maintenance.ip', ]); set('shared_dirs', [ - 'var/composer_home', - 'var/log', - 'var/export', - 'var/report', - 'var/import', - 'var/import_history', - 'var/session', - 'var/importexport', - 'var/backups', - 'var/tmp', - 'pub/sitemap', - 'pub/media', - 'pub/static/_cache' + '{{magento_dir}}/var/composer_home', + '{{magento_dir}}/var/log', + '{{magento_dir}}/var/export', + '{{magento_dir}}/var/report', + '{{magento_dir}}/var/import', + '{{magento_dir}}/var/import_history', + '{{magento_dir}}/var/session', + '{{magento_dir}}/var/importexport', + '{{magento_dir}}/var/backups', + '{{magento_dir}}/var/tmp', + '{{magento_dir}}/pub/sitemap', + '{{magento_dir}}/pub/media', + '{{magento_dir}}/pub/static/_cache' ]); set('writable_dirs', [ - 'var', - 'pub/static', - 'pub/media', - 'generated', - 'var/page_cache' + '{{magento_dir}}/var', + '{{magento_dir}}/pub/static', + '{{magento_dir}}/pub/media', + '{{magento_dir}}/generated', + '{{magento_dir}}/var/page_cache' ]); set('clear_paths', [ - 'generated/*', - 'pub/static/_cache/*', - 'var/generation/*', - 'var/cache/*', - 'var/page_cache/*', - 'var/view_preprocessed/*' + '{{magento_dir}}/generated/*', + '{{magento_dir}}/pub/static/_cache/*', + '{{magento_dir}}/var/generation/*', + '{{magento_dir}}/var/cache/*', + '{{magento_dir}}/var/page_cache/*', + '{{magento_dir}}/var/view_preprocessed/*' ]); set('magento_version', function () { @@ -84,7 +88,7 @@ set('maintenance_mode_status_active', function () { // detect maintenance mode active - $maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/bin/magento maintenance:status"); + $maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/{{bin/magento}} maintenance:status"); return strpos($maintenanceModeStatusOutput, MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG) !== false; }); @@ -124,12 +128,12 @@ desc('Enables maintenance mode'); task('magento:maintenance:enable', function () { - run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/bin/magento maintenance:enable; fi"); + run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{bin/magento}} maintenance:enable; fi"); }); desc('Disables maintenance mode'); task('magento:maintenance:disable', function () { - run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/bin/magento maintenance:disable; fi"); + run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{bin/magento}} maintenance:disable; fi"); }); desc('Config Import'); From c59bc675381b657c24cd897d37192797487c0166 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 2 Nov 2022 14:08:48 +0100 Subject: [PATCH 4/9] Update docs --- docs/recipe/magento2.md | 126 ++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index b3b901090..3d1d1c94f 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -101,8 +101,18 @@ return time(); ``` +### magento_dir +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L44) + +Magento directory relative to repository root. Use "." (default) if it is not located in a subdirectory + +```php title="Default value" +'.' +``` + + ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L43) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L47) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -110,14 +120,14 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ```php title="Default value" [ - 'app/etc/env.php', - 'var/.maintenance.ip', + '{{magento_dir}}/app/etc/env.php', + '{{magento_dir}}/var/.maintenance.ip', ] ``` ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L47) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -125,25 +135,25 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ```php title="Default value" [ - 'var/composer_home', - 'var/log', - 'var/export', - 'var/report', - 'var/import', - 'var/import_history', - 'var/session', - 'var/importexport', - 'var/backups', - 'var/tmp', - 'pub/sitemap', - 'pub/media', - 'pub/static/_cache' + '{{magento_dir}}/var/composer_home', + '{{magento_dir}}/var/log', + '{{magento_dir}}/var/export', + '{{magento_dir}}/var/report', + '{{magento_dir}}/var/import', + '{{magento_dir}}/var/import_history', + '{{magento_dir}}/var/session', + '{{magento_dir}}/var/importexport', + '{{magento_dir}}/var/backups', + '{{magento_dir}}/var/tmp', + '{{magento_dir}}/pub/sitemap', + '{{magento_dir}}/pub/media', + '{{magento_dir}}/pub/static/_cache' ] ``` ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L62) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L66) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -151,17 +161,17 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ```php title="Default value" [ - 'var', - 'pub/static', - 'pub/media', - 'generated', - 'var/page_cache' + '{{magento_dir}}/var', + '{{magento_dir}}/pub/static', + '{{magento_dir}}/pub/media', + '{{magento_dir}}/generated', + '{{magento_dir}}/var/page_cache' ] ``` ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L69) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L73) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -169,18 +179,18 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ```php title="Default value" [ - 'generated/*', - 'pub/static/_cache/*', - 'var/generation/*', - 'var/cache/*', - 'var/page_cache/*', - 'var/view_preprocessed/*' + '{{magento_dir}}/generated/*', + '{{magento_dir}}/pub/static/_cache/*', + '{{magento_dir}}/var/generation/*', + '{{magento_dir}}/var/cache/*', + '{{magento_dir}}/var/page_cache/*', + '{{magento_dir}}/var/view_preprocessed/*' ] ``` ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L82) @@ -193,19 +203,19 @@ return $matches[0] ?? '2.0'; ### maintenance_mode_status_active -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L85) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L89) ```php title="Default value" // detect maintenance mode active -$maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/bin/magento maintenance:status"); +$maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/{{bin/magento}} maintenance:status"); return strpos($maintenanceModeStatusOutput, MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG) !== false; ``` ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L96) Deploy without setting maintenance mode if possible @@ -215,7 +225,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L229) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233) artifact deployment section settings section @@ -226,7 +236,7 @@ settings section ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L230) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) @@ -236,7 +246,7 @@ settings section ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L231) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L235) @@ -246,7 +256,7 @@ settings section ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L237) @@ -259,7 +269,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L240) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L244) :::info Autogenerated @@ -270,14 +280,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L305) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L303) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L307) Array of shared directories that will be added to the default shared_dirs without overriding @@ -287,7 +297,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L96) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L100) Compiles magento di. @@ -295,7 +305,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L103) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L107) Deploys assets. @@ -303,7 +313,7 @@ Deploys assets. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L116) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L120) Syncs content version. @@ -311,7 +321,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L126) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L130) Enables maintenance mode. @@ -319,7 +329,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L135) Disables maintenance mode. @@ -327,7 +337,7 @@ Disables maintenance mode. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L136) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L140) Config Import. @@ -335,7 +345,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L171) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L175) Upgrades magento database. @@ -343,7 +353,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L198) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L202) Flushes Magento Cache. @@ -351,7 +361,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L203) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L207) Magento2 deployment operations. @@ -366,7 +376,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L211) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L215) Magento2 build operations. @@ -379,7 +389,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L217) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L221) Deploys your project. @@ -395,7 +405,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L250) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L254) Packages all relevant files in an artifact. @@ -403,7 +413,7 @@ tasks section ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L260) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L264) Uploads artifact in release folder for extraction. @@ -411,7 +421,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L265) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L269) Extracts artifact in release path. @@ -419,7 +429,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L271) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L275) Clears generated files prior to building. @@ -427,7 +437,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L276) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L280) Prepare local artifact build. @@ -435,7 +445,7 @@ Prepare local artifact build. ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L307) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L311) Adds additional files and dirs to the list of shared files and dirs. From 24e942abc25489fea10184886ecb5899bf08464d Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 2 Nov 2022 14:23:22 +0100 Subject: [PATCH 5/9] Use Magento subdirectory for composer command --- recipe/magento2.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 329d62208..db3d0855e 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -98,9 +98,8 @@ // Tasks desc('Compiles magento di'); task('magento:compile', function () { - run('cd {{release_or_current_path}} && {{bin/composer}} dump-autoload -o'); run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:di:compile"); - run('cd {{release_or_current_path}} && {{bin/composer}} dump-autoload -o'); + run('cd {{release_or_current_path}}/{{magento_dir}} && {{bin/composer}} dump-autoload -o'); }); desc('Deploys assets'); From 63d87ed0ef8c9f925297f8f94d58942a1bab0966 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 2 Nov 2022 14:52:58 +0100 Subject: [PATCH 6/9] Fix bin/magento call in magento_version function --- recipe/magento2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 159a283a8..f12077ede 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -79,7 +79,7 @@ set('magento_version', function () { // detect version - $versionOutput = run('{{bin/php}} {{bin/magento}} --version'); + $versionOutput = run('{{bin/php}} {{release_or_current_path}}/{{bin/magento}} --version'); preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); return $matches[0] ?? '2.0'; }); From f751831e2c48b5a8e4e83aa1ba62a0a31fcd8497 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 25 Jan 2023 16:51:33 +0100 Subject: [PATCH 7/9] Update docs --- docs/recipe/magento2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 79ed36934..d7f787467 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -196,7 +196,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ```php title="Default value" // detect version -$versionOutput = run('{{bin/php}} {{bin/magento}} --version'); +$versionOutput = run('{{bin/php}} {{release_or_current_path}}/{{bin/magento}} --version'); preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); return $matches[0] ?? '2.0'; ``` From c7f963f76834a48b1dae654f2004e3a8b9693225 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 25 Jan 2023 16:51:53 +0100 Subject: [PATCH 8/9] Update docs --- docs/recipe/magento2.md | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 3d1d1c94f..ba786c06f 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -225,7 +225,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L232) artifact deployment section settings section @@ -236,7 +236,7 @@ settings section ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233) @@ -246,7 +246,7 @@ settings section ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L235) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) @@ -256,7 +256,7 @@ settings section ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L237) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L236) @@ -269,7 +269,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L244) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L243) :::info Autogenerated @@ -280,14 +280,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L305) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L304) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L307) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) Array of shared directories that will be added to the default shared_dirs without overriding @@ -305,7 +305,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L107) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L106) Deploys assets. @@ -313,7 +313,7 @@ Deploys assets. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L120) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L119) Syncs content version. @@ -321,7 +321,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L130) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L129) Enables maintenance mode. @@ -329,7 +329,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L135) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L134) Disables maintenance mode. @@ -337,7 +337,7 @@ Disables maintenance mode. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L140) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L139) Config Import. @@ -345,7 +345,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L175) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L174) Upgrades magento database. @@ -353,7 +353,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L202) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L201) Flushes Magento Cache. @@ -361,7 +361,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L207) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L206) Magento2 deployment operations. @@ -376,7 +376,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L215) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L214) Magento2 build operations. @@ -389,7 +389,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L221) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L220) Deploys your project. @@ -405,7 +405,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L254) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L253) Packages all relevant files in an artifact. @@ -413,7 +413,7 @@ tasks section ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L264) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L263) Uploads artifact in release folder for extraction. @@ -421,7 +421,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L269) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L268) Extracts artifact in release path. @@ -429,7 +429,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L275) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L274) Clears generated files prior to building. @@ -437,7 +437,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L280) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L279) Prepare local artifact build. @@ -445,7 +445,7 @@ Prepare local artifact build. ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L311) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310) Adds additional files and dirs to the list of shared files and dirs. From e849530803a82d4533bf7c29ffefb03b819a7549 Mon Sep 17 00:00:00 2001 From: Fabian Schmengler Date: Wed, 8 Feb 2023 16:18:29 +0100 Subject: [PATCH 9/9] Combine magento_dir and bin/magento configurations correctly --- docs/recipe/magento2.md | 44 ++++++++++++++++++++--------------------- recipe/magento2.php | 10 ++++++---- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index b58b494ea..28343d283 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -195,7 +195,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ```php title="Default value" -'{{release_or_current_path}}/bin/magento' +'{{release_or_current_path}}/{{magento_dir}}/bin/magento' ``` @@ -206,7 +206,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ```php title="Default value" // detect version -$versionOutput = run('{{bin/php}} {{release_or_current_path}}/{{bin/magento}} --version'); +$versionOutput = run('{{bin/php}} {{bin/magento}} --version'); preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); return $matches[0] ?? '2.0'; ``` @@ -235,7 +235,7 @@ true ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L234) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L236) artifact deployment section settings section @@ -246,7 +246,7 @@ settings section ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L235) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L237) @@ -256,7 +256,7 @@ settings section ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L236) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L238) @@ -266,7 +266,7 @@ settings section ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L238) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L240) @@ -279,7 +279,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L245) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L247) :::info Autogenerated @@ -290,14 +290,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L308) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L308) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310) Array of shared directories that will be added to the default shared_dirs without overriding @@ -339,7 +339,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L136) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L137) Disables maintenance mode. @@ -347,7 +347,7 @@ Disables maintenance mode. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L141) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L143) Config Import. @@ -355,7 +355,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L176) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L178) Upgrades magento database. @@ -363,7 +363,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L203) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L205) Flushes Magento Cache. @@ -371,7 +371,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L208) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L210) Magento2 deployment operations. @@ -386,7 +386,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L216) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L218) Magento2 build operations. @@ -399,7 +399,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L222) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L224) Deploys your project. @@ -415,7 +415,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L255) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L257) Packages all relevant files in an artifact. @@ -423,7 +423,7 @@ tasks section ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L265) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L267) Uploads artifact in release folder for extraction. @@ -431,7 +431,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L270) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L272) Extracts artifact in release path. @@ -439,7 +439,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L276) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L278) Clears generated files prior to building. @@ -447,7 +447,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L281) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L283) Prepare local artifact build. @@ -455,7 +455,7 @@ Prepare local artifact build. ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L312) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L314) Adds additional files and dirs to the list of shared files and dirs. diff --git a/recipe/magento2.php b/recipe/magento2.php index 9324a9751..b71b8fab2 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -79,11 +79,11 @@ '{{magento_dir}}/var/view_preprocessed/*' ]); -set('bin/magento', '{{release_or_current_path}}/bin/magento'); +set('bin/magento', '{{release_or_current_path}}/{{magento_dir}}/bin/magento'); set('magento_version', function () { // detect version - $versionOutput = run('{{bin/php}} {{release_or_current_path}}/{{bin/magento}} --version'); + $versionOutput = run('{{bin/php}} {{bin/magento}} --version'); preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); return $matches[0] ?? '2.0'; }); @@ -129,12 +129,14 @@ desc('Enables maintenance mode'); task('magento:maintenance:enable', function () { - run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{bin/magento}} maintenance:enable; fi"); + // do not use {{bin/magento}} because it would be in "release" but the maintenance mode must be set in "current" + run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento maintenance:enable; fi"); }); desc('Disables maintenance mode'); task('magento:maintenance:disable', function () { - run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{bin/magento}} maintenance:disable; fi"); + // do not use {{bin/magento}} because it would be in "release" but the maintenance mode must be set in "current" + run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento maintenance:disable; fi"); }); desc('Config Import');