From 702cfff1d9245dd506b54681e9f00d1d8b0bb084 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Fri, 27 Oct 2017 11:49:54 +0200 Subject: [PATCH] Adjust drush and alias settings for Drush 9 beta8 --- src/Handler.php | 18 ++++++++++-------- templates/aliases.yml.twig | 10 ---------- templates/drush.yml.twig | 4 ++++ templates/{{ projectname }}.alias.yml.twig | 8 ++++++++ 4 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 templates/aliases.yml.twig create mode 100644 templates/{{ projectname }}.alias.yml.twig diff --git a/src/Handler.php b/src/Handler.php index 91e5224..2b17ff9 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -120,13 +120,15 @@ class Handler { $options['webRoot'] = $webRoot . '/'; $orig_ignored = FALSE; foreach ($this->getFiles($projectRoot, $webRoot, $settingsPath) as $template => $def) { - $file = $def['dest'] . '/' . $template; + $twig_loader->setTemplate($template, $template); + $filename = $twig->render($template, $options); + $file = $def['dest'] . '/' . $filename; if ($overwrite || !$fs->exists($file)) { - $twig_loader->setTemplate($template, file_get_contents($pluginRoot . '/templates/' . $template . '.twig')); - $rendered = $twig->render($template, $options); - if (!empty($def['add2yaml']) && isset($options[$template])) { + $twig_loader->setTemplate($filename, file_get_contents($pluginRoot . '/templates/' . $template . '.twig')); + $rendered = $twig->render($filename, $options); + if (!empty($def['add2yaml']) && isset($options[$filename])) { $yaml = Yaml::parse($rendered); - $yaml = array_merge_recursive($yaml, $options[$template]); + $yaml = array_merge_recursive($yaml, $options[$filename]); $rendered = Yaml::dump($yaml, 9, 2); } if ($fs->exists($file)) { @@ -144,12 +146,12 @@ class Handler { } } else { - $this->git('ignore ' . $template); + $this->git('ignore ' . $filename); } file_put_contents($file, $rendered); } if (isset($def['link']) && ($def['link'] != $settingsPath)) { - $link = $def['link'] . '/' . $template; + $link = $def['link'] . '/' . $filename; if (!$fs->exists($link)) { $rel = substr($fs->makePathRelative($file, $projectRoot . '/' . $link), 3, -1); $fs->symlink($rel, $link); @@ -188,7 +190,7 @@ class Handler { 'drushrc.php' => [ 'dest' => $projectRoot . '/drush', ], - 'aliases.yml' => [ + '{{ projectname }}.alias.yml' => [ 'dest' => $projectRoot . '/drush', 'add2yaml' => TRUE, ], diff --git a/templates/aliases.yml.twig b/templates/aliases.yml.twig deleted file mode 100644 index e637107..0000000 --- a/templates/aliases.yml.twig +++ /dev/null @@ -1,10 +0,0 @@ -sites: - {{ projectname }}: - dev: - root: '/var/www/html/{{ webRoot }}' - uri: '{{ projectname }}.docker.localhost:8000' - live: - root: '{{ live.root }}' - uri: '{{ live.uri }}' - remote-host: '{{ live.host }}' - remote-user: '{{ live.user }}' diff --git a/templates/drush.yml.twig b/templates/drush.yml.twig index 4d920a8..19436a9 100644 --- a/templates/drush.yml.twig +++ b/templates/drush.yml.twig @@ -1,3 +1,7 @@ +drush: + paths: + include: + - './drush/contrib' options: uri: 'http://{{ projectname }}.docker.localhost:8000' command: diff --git a/templates/{{ projectname }}.alias.yml.twig b/templates/{{ projectname }}.alias.yml.twig new file mode 100644 index 0000000..5fdf3ce --- /dev/null +++ b/templates/{{ projectname }}.alias.yml.twig @@ -0,0 +1,8 @@ +dev: + root: '/var/www/html/{{ webRoot }}' + uri: '{{ projectname }}.docker.localhost:8000' +live: + root: '{{ live.root }}' + uri: '{{ live.uri }}' + host: '{{ live.host }}' + user: '{{ live.user }}' -- GitLab