Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 80fb268

Browse files
committed
Write a Composer warning message when upgrading from < 5.0.0
1 parent 12e7115 commit 80fb268

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

composer/src/Plugin.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,35 @@ public function addVagrantfile(Event $event) {
5757

5858
if (file_exists($source)) {
5959
if (!file_exists($target) || md5_file($source) != md5_file($target)) {
60+
$isLegacy = $this->isLegacyVagrantfile($target);
61+
6062
copy($source, $target);
63+
64+
$extra = $this->composer->getPackage()->getExtra();
65+
if ($isLegacy && !isset($extra['drupalvm']['config_dir'])) {
66+
$this->io->writeError(
67+
'<warning>'
68+
. 'Drupal VM has been updated and consequently written over your Vagrantfile which from now on will be managed by Drupal VM. '
69+
. 'Due to this change, you are required to set the `config_dir` location in your composer.json file:'
70+
. "\n"
71+
. "\n $ composer config extra.drupalvm.config_dir <sub-directory>"
72+
. "\n"
73+
. '</warning>'
74+
);
75+
}
6176
}
6277
}
6378
}
6479

80+
/**
81+
* Return if the parent project is using the < 5.0.0 delegating Vagrantfile.
82+
*
83+
* @return bool
84+
*/
85+
private function isLegacyVagrantfile($vagrantfile) {
86+
if (!file_exists($vagrantfile)) {
87+
return false;
88+
}
89+
return strpos(file_get_contents($vagrantfile), '# Load the real Vagrantfile') !== false;
90+
}
6591
}

0 commit comments

Comments
 (0)