Skip to content
Snippets Groups Projects
Commit 8667ca8e authored by Pierre Dureau's avatar Pierre Dureau
Browse files

Issue #3467398 by pdureau: Migration command: don't break if missing composer.json

parent 53471f68
No related branches found
No related tags found
1 merge request!181Issue #3467398 by pdureau: Migration command: don't break if missing composer.json
Pipeline #250525 passed
......@@ -21,6 +21,13 @@ class ComponentWriter {
mkdir($path, 0775, TRUE);
}
$filename = $component_id . '.component.yml';
// Let's comply with https://prettier.io/
// - indentation: 2 spaces
// However, still not 100% compliant:
// - strings: Symfony does simple quotes, Prettier does double quotes
// - empty objects: Symfony does "{ }", Prettier does "{}"
// - arrays of objects: Symfony adds a line break after dash, Prettier
// doesn't.
$yaml = Yaml::dump($definition, 10, 2);
file_put_contents($path . $filename, $yaml);
}
......
......@@ -109,6 +109,10 @@ final class UiPatternsLegacyCommands extends DrushCommands {
*/
protected function changeInfoFile(string $extension, string $extension_path): void {
$info_path = $extension_path . "/" . $extension . ".info.yml";
// Just a safeguard because a info file is always expected.
if (!file_exists($info_path)) {
return;
}
$content = file_get_contents($info_path) ?: "";
$content = preg_replace('/ui_patterns_settings.*/', 'ui_patterns:ui_patterns_legacy', $content);
file_put_contents($info_path, $content);
......@@ -119,6 +123,11 @@ final class UiPatternsLegacyCommands extends DrushCommands {
*/
protected function changeComposerFile(string $extension_path): void {
$composer_path = $extension_path . "/composer.json";
// Some themes or modules don't have a composer file. It is generated by
// the Drupal pipeline if missing.
if (!file_exists($composer_path)) {
return;
}
$content = file_get_contents($composer_path) ?: "";
$data = json_decode($content, TRUE);
unset($data["require"]["drupal/ui_patterns_settings"]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment