<?php /* (c) Jacob Moen <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once __DIR__ . '/common.php'; task('local-config', function () { if (askConfirmation("Local configuration.\n\nThis will overwrite any existing file without further warning!\n\nAre you sure you want to continue?")) { /** * Paser value for template compiler * * @param array $matches * @return string */ $paser = function ($matches) { if (isset($matches[1])) { if ($matches[1] === 'release_path') { $matches[1] = 'deploy_path'; } $value = env()->get($matches[1]); if (is_null($value) || is_bool($value) || is_array($value)) { $value = var_export($value, true); } } else { $value = $matches[0]; } return $value; }; /**
if (askConfirmation('Are you sure to generate and upload settings.php file?')) { $basepath = dirname(__FILE__) . '/drupal7'; //Import secrets $secrets = env('settings'); //Prepare replacement variables $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($secrets)); $replacements = []; foreach ($iterator as $key => $value) { $keys = []; for ($i = $iterator->getDepth(); $i > 0; $i--) { $keys[] = $iterator->getSubIterator($i - 1)->key(); } $keys[] = $key; $replacements['{{' . implode('.', $keys) . '}}'] = $value; } //Create settings from template $settings = file_get_contents($basepath . '/settings.php'); $settings = strtr($settings, $replacements); writeln('settings.php created succesfuly'); $tmpFilename = tempnam($basepath, 'tmp_settings_'); file_put_contents($tmpFilename, $settings); upload($tmpFilename, '{{deploy_path}}/shared/sites/{{drupal_site}}/settings.php'); unlink($tmpFilename); } }); //Upload Drupal 7 files folder task('drupal:upload_files', function () { if (askConfirmation('Are you sure?')) { upload('sites/{{drupal_site}}/files', '{{deploy_path}}/shared/sites/{{drupal_site}}/files'); } });