From 00621b8a2bb2e8a87573ef3af75e1aa30444bdec Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Wed, 16 Mar 2022 16:24:42 +0000 Subject: [PATCH 1/2] DD#0000: feat: Added configurable themes to Magento2 --- docs/recipe/magento2.md | 54 ++++++++++++++++++++++++++--------------- recipe/magento2.php | 16 +++++++++++- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index e355445e0..9be985712 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -11,11 +11,13 @@ ## Configuration ### static_content_locales -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L20) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L22) By default setup:static-content:deploy uses `en_US`. To change that, simply put `set('static_content_locales', 'en_US de_DE');` in you deployer script. +You can also set the themes to run against. By default it'll deploy +all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` ```php title="Default value" 'en_US' @@ -23,14 +25,26 @@ in you deployer script. ### content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L22) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L24) + + + + + +### magento_themes +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L28) + +```php title="Default value" +[ +] +``` ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L26) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L32) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -46,7 +60,7 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L31) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L37) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -71,7 +85,7 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L45) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -88,7 +102,7 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L57) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -107,21 +121,21 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L60) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L66) ### maintenance_mode_status_active -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L67) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L73) ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L74) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L80) Deploy without setting maintenance mode if possible @@ -134,7 +148,7 @@ true ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L84) Compiles magento di. @@ -142,7 +156,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L85) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L91) Deploys assets. @@ -150,7 +164,7 @@ Deploys assets. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L90) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L104) Syncs content version. @@ -158,7 +172,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L100) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L114) Enables maintenance mode. @@ -166,7 +180,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L105) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L119) Disables maintenance mode. @@ -174,7 +188,7 @@ Disables maintenance mode. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L110) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L124) Config Import. @@ -182,7 +196,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L145) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) Upgrades magento database. @@ -190,7 +204,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L172) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L186) Flushes Magento Cache. @@ -198,7 +212,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L177) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L191) Magento2 deployment operations. @@ -213,7 +227,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L185) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) Magento2 build operations. @@ -226,7 +240,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L191) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L205) Deploys your project. diff --git a/recipe/magento2.php b/recipe/magento2.php index 55558489c..31a1f90a2 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -17,12 +17,18 @@ // By default setup:static-content:deploy uses `en_US`. // To change that, simply put `set('static_content_locales', 'en_US de_DE');` // in you deployer script. +// You can also set the themes to run against. By default it'll deploy +// all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` set('static_content_locales', 'en_US'); set('content_version', function () { return time(); }); +set('magento_themes', [ + +]); + set('shared_files', [ 'app/etc/env.php', 'var/.maintenance.ip', @@ -83,7 +89,15 @@ desc('Deploys assets'); task('magento:deploy:assets', function () { - run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_content_locales}}"); + + $themesToCompile = ''; + if (count(get('magento_themes')) > 0) { + foreach (get('magento_themes') as $theme) { + $themesToCompile .= ' -t ' . $theme; + } + } + + run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_content_locales}} $themesToCompile"); }); desc('Syncs content version'); From 6b28be7e451a8cd96c028c701da609e516971582 Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Thu, 17 Mar 2022 10:47:32 +0000 Subject: [PATCH 2/2] DD#0000: feat: Added concurrent jobs to static:content:deploy --- docs/recipe/magento2.md | 68 +++++++++++++++++++++++------------------ recipe/magento2.php | 20 ++++++++---- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 9be985712..583f32943 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -11,40 +11,50 @@ ## Configuration ### static_content_locales -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L22) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L20) By default setup:static-content:deploy uses `en_US`. To change that, simply put `set('static_content_locales', 'en_US de_DE');` in you deployer script. -You can also set the themes to run against. By default it'll deploy -all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` ```php title="Default value" 'en_US' ``` -### content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L24) - +### magento_themes +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L26) +You can also set the themes to run against. By default it'll deploy +all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` +```php title="Default value" +[ +] +``` -### magento_themes -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L28) +### static_content_jobs +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L34) +Also set the number of conccurent jobs to run. The default is 1 +Update using: `set('static_content_jobs', '1');` ```php title="Default value" -[ - -] +'1' ``` +### content_version +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L36) + + + + + ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L32) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L40) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -60,7 +70,7 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L37) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L45) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -85,7 +95,7 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L59) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -102,7 +112,7 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L57) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L65) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -121,21 +131,21 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L66) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L74) ### maintenance_mode_status_active -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L73) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L81) ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L80) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L88) Deploy without setting maintenance mode if possible @@ -148,7 +158,7 @@ true ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L84) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92) Compiles magento di. @@ -156,7 +166,7 @@ Tasks ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L91) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L99) Deploys assets. @@ -164,7 +174,7 @@ Deploys assets. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L104) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L112) Syncs content version. @@ -172,7 +182,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L114) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L122) Enables maintenance mode. @@ -180,7 +190,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L119) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L127) Disables maintenance mode. @@ -188,7 +198,7 @@ Disables maintenance mode. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L124) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L132) Config Import. @@ -196,7 +206,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L167) Upgrades magento database. @@ -204,7 +214,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L186) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L194) Flushes Magento Cache. @@ -212,7 +222,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L191) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) Magento2 deployment operations. @@ -227,7 +237,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L199) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L207) Magento2 build operations. @@ -240,7 +250,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L205) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L213) Deploys your project. diff --git a/recipe/magento2.php b/recipe/magento2.php index 31a1f90a2..556ba0b40 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -17,18 +17,26 @@ // By default setup:static-content:deploy uses `en_US`. // To change that, simply put `set('static_content_locales', 'en_US de_DE');` // in you deployer script. -// You can also set the themes to run against. By default it'll deploy -// all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` set('static_content_locales', 'en_US'); -set('content_version', function () { - return time(); -}); +// Configuration +// You can also set the themes to run against. By default it'll deploy +// all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` set('magento_themes', [ ]); +// Configuration + +// Also set the number of conccurent jobs to run. The default is 1 +// Update using: `set('static_content_jobs', '1');` +set('static_content_jobs', '1'); + +set('content_version', function () { + return time(); +}); + set('shared_files', [ 'app/etc/env.php', 'var/.maintenance.ip', @@ -97,7 +105,7 @@ } } - run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_content_locales}} $themesToCompile"); + 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}}"); }); desc('Syncs content version');