From ec67336e114dc9820945903abdd021b01eb41427 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Sat, 8 Jun 2024 04:20:18 +0700 Subject: [PATCH 1/3] Use new Drupal Finder API. (#673) --- composer.json | 2 +- scripts/composer/ScriptHandler.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 208a89ab3..15b7c363f 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "drush/drush": "^13@beta", "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", - "webflo/drupal-finder": "^1.2" + "webflo/drupal-finder": "^1.3" }, "require-dev": { "drupal/core-dev": "^11@alpha", diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 088c2b608..837f0c740 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -12,15 +12,14 @@ use Drupal\Core\Site\Settings; use Drupal\Core\Site\SettingsEditor; use DrupalFinder\DrupalFinder; +use DrupalFinder\DrupalFinderComposerRuntime; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Filesystem\Path; class ScriptHandler { public static function createRequiredFiles(Event $event) { $fs = new Filesystem(); - $drupalFinder = new DrupalFinder(); - $drupalFinder->locateRoot(getcwd()); + $drupalFinder = new DrupalFinderComposerRuntime(); $drupalRoot = $drupalFinder->getDrupalRoot(); $dirs = [ @@ -44,7 +43,7 @@ public static function createRequiredFiles(Event $event) { require_once $drupalRoot . '/core/includes/install.inc'; new Settings([]); $settings['settings']['config_sync_directory'] = (object) [ - 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), + 'value' => '../config/sync', 'required' => TRUE, ]; SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings); From 5332c5202a1df8a64d975b83a757321e0606e07c Mon Sep 17 00:00:00 2001 From: Jesper Noordsij <45041769+jnoordsij@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:57:47 +0200 Subject: [PATCH 2/3] Changes to usage of DrupalFinderComposerRuntime API in ScriptHandler (#677) Co-authored-by: Alex Skrypnyk --- scripts/composer/ScriptHandler.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 837f0c740..9abe6d70b 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -11,9 +11,9 @@ use Composer\Semver\Comparator; use Drupal\Core\Site\Settings; use Drupal\Core\Site\SettingsEditor; -use DrupalFinder\DrupalFinder; use DrupalFinder\DrupalFinderComposerRuntime; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Path; class ScriptHandler { @@ -22,6 +22,11 @@ public static function createRequiredFiles(Event $event) { $drupalFinder = new DrupalFinderComposerRuntime(); $drupalRoot = $drupalFinder->getDrupalRoot(); + if (is_null($drupalRoot)) { + $event->getIO()->writeError('Drupal root could not be detected.'); + exit(1); + } + $dirs = [ 'modules', 'profiles', @@ -43,7 +48,7 @@ public static function createRequiredFiles(Event $event) { require_once $drupalRoot . '/core/includes/install.inc'; new Settings([]); $settings['settings']['config_sync_directory'] = (object) [ - 'value' => '../config/sync', + 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), 'required' => TRUE, ]; SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings); From 51a8982bf251c0d6c33821f0b55b97e3819bfd9e Mon Sep 17 00:00:00 2001 From: Jesper Noordsij <45041769+jnoordsij@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:04:03 +0200 Subject: [PATCH 3/3] Fix misplaced full stop in ScriptHandler --- scripts/composer/ScriptHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 9abe6d70b..0ccdb8564 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -97,7 +97,7 @@ public static function checkComposerVersion(Event $event) { $io->writeError('You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.'); } elseif (Comparator::lessThan($version, '2.3.6')) { - $io->writeError('Drupal-project requires Composer version 2.3.6 or higher. Please update your Composer before continuing.'); + $io->writeError('Drupal-project requires Composer version 2.3.6 or higher. Please update your Composer before continuing.'); exit(1); } }