This repository was archived by the owner on Feb 13, 2023. It is now read-only.
File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,36 @@ public function addVagrantfile(Event $event) {
57
57
58
58
if (file_exists ($ source )) {
59
59
if (!file_exists ($ target ) || md5_file ($ source ) != md5_file ($ target )) {
60
+ $ isLegacy = $ this ->isLegacy ();
61
+
60
62
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 consquently written over your Vagrantfile which from now on will be managed by Drupal VM. '
69
+ . 'Due to this change, you are now required to set your `config_dir` location in your composer.json file. Below follows the necessary change: '
70
+ . '</warning> '
71
+ );
72
+ $ this ->io ->writeError ('' );
73
+ $ this ->io ->writeError (json_encode (['extra ' => ['drupalvm ' => ['config_dir ' => '<sub-directory> ' ]]], JSON_PRETTY_PRINT ));
74
+ }
61
75
}
62
76
}
63
77
}
64
78
79
+ /**
80
+ * Return if the parent project is using the < 5.0.0 delegating Vagrantfile.
81
+ *
82
+ * @return bool
83
+ */
84
+ private function isLegacy () {
85
+ $ baseDir = dirname (Factory::getComposerFile ());
86
+ $ vagrantfile = $ baseDir . '/Vagrantfile ' ;
87
+ if (!file_exists ($ vagrantfile )) {
88
+ return false ;
89
+ }
90
+ return strpos (file_get_contents ($ vagrantfile ), '# Load the real Vagrantfile ' ) !== FALSE ;
91
+ }
65
92
}
You can’t perform that action at this time.
0 commit comments