From 3afc80c22054facd8405bd28f3f53c5a8639ff1d Mon Sep 17 00:00:00 2001 From: Daniel Love Date: Tue, 15 Mar 2022 13:35:11 -0600 Subject: [PATCH] Adding `pub/static` to Magento 2 shared directories list & simplifying the list. Removing all `writable_dirs` directives in Magento 2 recipe. Removing `deploy:unlock` from `magento:init` task. Updating `fill` function to support `int` & `boolean` defined values. Updating change log. --- CHANGELOG.md | 19 ++++++++++++++++++- cms/magento/magento2.php | 28 +++++++--------------------- cms/wp/README.md | 8 ++++---- src/functions.php | 14 +++++++++----- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c84249a..f6bda71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,24 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi ## [Unreleased][unreleased] +## [0.3.21] - 2022-03-15 + +### Fixed + +- Adding `pub/static` to Magento 2 shared directories list & simplifying the list. +- Removing all `writable_dirs` directives in Magento 2 recipe. +- Removing `deploy:unlock` from `magento:init` task. +- Updating `fill` function to support `int` & `boolean` defined values. + ## [0.3.20] - 2022-03-10 +### Changed + +- Updated Drupal recipes to better support multi-site DB pull operations. +- Added `dev:sites` task which outputs the list of defined sites. +- Defined a pair of local hosts. +- Updating `cms:drupal:db:backup:create` to use project name in backup. + ### Fixed - Fixing cms:drupal:db:backup:create to handle grep count error status code. @@ -295,7 +311,8 @@ config vars to be overridden. **Initial release!** -[unreleased]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.20...main +[unreleased]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.21...main +[0.3.21]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.20...0.3.21 [0.3.20]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.19...0.3.20 [0.3.19]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.18...0.3.19 [0.3.18]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.17...0.3.18 diff --git a/cms/magento/magento2.php b/cms/magento/magento2.php index 39159bf..f09edf7 100644 --- a/cms/magento/magento2.php +++ b/cms/magento/magento2.php @@ -18,30 +18,18 @@ set('app_type', 'magento'); set('mage', 'bin/magento'); fill('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', + 'var', 'pub/media', + 'pub/page-cache', + 'pub/sitemap', + 'pub/static', + 'generated', ]); fill('shared_files', [ 'app/etc/env.php', 'var/.maintenance.ip', ]); -fill('writable_dirs', [ - 'var', - 'pub/static', - 'pub/media', - 'generated', - 'pub/page-cache', -]); +fill('writable_dirs', []); fill('clear_paths', [ 'generated/*', 'pub/static/_cache/*', @@ -77,8 +65,6 @@ set($var, $newVars); } - - invoke('deploy:unlock'); }); desc('Enables maintenance mode'); @@ -262,7 +248,7 @@ static function (): void { run('{{mage}} config:set system/backup/functionality_enabled 1'); } ); - } catch (RunException) { + } catch (RunException $e) { return; } diff --git a/cms/wp/README.md b/cms/wp/README.md index eff4301..fdc7d4e 100644 --- a/cms/wp/README.md +++ b/cms/wp/README.md @@ -15,10 +15,10 @@ to `foo.dev1.example`, `foo.staging1.example` & `production1.example`. You will config: namespace: foo repository_user: bar - repository_domain: 'repository1.example` - dev_domain: 'dev1.example` - staging_domain: 'staging1.example` - production_domain: 'production1.example` + repository_domain: 'repository1.example' + dev_domain: 'dev1.example' + staging_domain: 'staging1.example' + production_domain: 'production1.example' upload_dir: 'docroot/app/uploads' import: diff --git a/src/functions.php b/src/functions.php index 311bd4d..23a8343 100644 --- a/src/functions.php +++ b/src/functions.php @@ -19,27 +19,31 @@ function fill(string $var, $defaultValue): void if (! has($var)) { set($var, $defaultValue); } else { - $value = get($var); - switch (\gettype($value)) { + $definedValue = get($var); + switch (\gettype($definedValue)) { case 'array': - if (! \count($value)) { + // Allow override of the defined array if empty. + if (! \count($definedValue)) { set($var, $defaultValue); } break; case 'string': - if (\trim($value) === '') { + // Allow override of the defined string if empty. + if (\trim($definedValue) === '') { set($var, $defaultValue); } break; case 'boolean': + case 'int': + // Var already defined. Do nothing. break; default: - throw new \DomainException('Unsupported type: ' . \gettype($value)); + throw new \DomainException('Unsupported type: ' . \gettype($definedValue)); } } }