mirror of
https://github.com/gantry/gantry5.git
synced 2026-09-03 20:52:53 -05:00
65 lines
2.4 KiB
PHP
Executable File
65 lines
2.4 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
setlocale(LC_ALL, ['en_GB.utf8', 'en_GB']);
|
|
date_default_timezone_set('America/Denver');
|
|
chdir(__DIR__ . '/..');
|
|
|
|
echo "# Running composer update for build script\n";
|
|
composer_update('bin/builder', false);
|
|
|
|
chdir('platforms');
|
|
|
|
echo "# Running composer update for Grav\n";
|
|
composer_update('grav/gantry5', true);
|
|
composer_update('grav/gantry5/compat', false);
|
|
|
|
echo "# Running composer update for Joomla\n";
|
|
composer_update('joomla/lib_gantry5', true);
|
|
composer_update('joomla/plg_system_gantry5_debugbar', false);
|
|
composer_update('joomla/lib_gantry5/compat', false);
|
|
|
|
echo "# Running composer update for WP\n";
|
|
composer_update('wordpress/gantry5', true);
|
|
composer_update('wordpress/gantry5_debugbar', false);
|
|
composer_update('wordpress/gantry5/compat', false);
|
|
|
|
echo "# Applying compat vendor patches\n";
|
|
require __DIR__ . '/apply-compat-patches';
|
|
|
|
function composer_update($folder, $link)
|
|
{
|
|
chdir($folder);
|
|
if ($link && !file_exists('src')) {
|
|
$projectRoot = realpath(__DIR__ . '/..');
|
|
$source = $projectRoot ? $projectRoot . DIRECTORY_SEPARATOR . 'src' : __DIR__ . '/..' . DIRECTORY_SEPARATOR . 'src';
|
|
// Try symlink first
|
|
try {
|
|
@symlink($source, 'src');
|
|
} catch (\Throwable $e) {
|
|
// ignore
|
|
}
|
|
|
|
// Fallback: copy directory when symlink is not available (Windows)
|
|
if (!file_exists('src') && $source && is_dir($source)) {
|
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
|
@mkdir('src');
|
|
foreach ($iterator as $item) {
|
|
$dest = 'src' . DIRECTORY_SEPARATOR . ltrim(str_replace($source, '', $item->getPathname()), DIRECTORY_SEPARATOR);
|
|
if ($item->isDir()) {
|
|
@mkdir($dest);
|
|
} else {
|
|
copy($item->getPathname(), $dest);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (false === exec('composer update --no-dev --no-progress --ignore-platform-req=ext-dom --ignore-platform-req=ext-xml --ignore-platform-req=ext-simplexml --ignore-platform-req=ext-xmlwriter', $output, $result) || $result) {
|
|
echo implode("\n", $output);
|
|
throw new \RuntimeException('Failed to run composer update in ' . $folder);
|
|
}
|
|
|
|
echo implode("\n", $output) . "\n";
|
|
chdir(preg_replace('|[^/]+|', '..', $folder));
|
|
}
|