isDot() || $file->isLink() || str_starts_with($file->getFilename(), '.')) { continue; } $target = $to.'/'.$file->getFilename(); if ($file->isDir()) { $copy($file->getPathname(), $target, $links); } elseif (! $links || ! link($file->getPathname(), $target)) { copy($file->getPathname(), $target); } } }; if ($native) { foreach (['app', 'config', 'routes', 'packages', 'resources', 'public'] as $directory) { $copy($original.'/'.$directory, $root.'/'.$directory); } $old = json_decode(file_get_contents(dirname(__DIR__, 2).'/docs/proofs/sgf-composition-delivery.json'), true, 32, JSON_THROW_ON_ERROR)['clone']; $old = realpath($old) ?: ''; $temp = str_replace('\\', '/', realpath(sys_get_temp_dir())); $normal = str_replace('\\', '/', $old); $private = str_starts_with(strtolower($normal), strtolower($temp).'/sgf-composition-') && preg_match('/^sgf-composition-[a-f0-9]{12}$/D', basename($old)); // Hardlinks only to an earlier disposable dependency copy, never to the actual destination. $copy(($private && is_dir($old.'/vendor')) ? $old.'/vendor' : $original.'/vendor', $root.'/vendor', $private); mkdir($root.'/bootstrap/cache', 0700, true); foreach (['app.php', 'providers.php'] as $file) { copy($original.'/bootstrap/'.$file, $root.'/bootstrap/'.$file); } copy($original.'/composer.json', $root.'/composer.json'); copy($original.'/artisan', $root.'/artisan'); if (!is_dir($root.'/public')) mkdir($root.'/public', 0700, true); copy($original.'/public/index.php', $root.'/public/index.php'); } else { foreach ($manifest['host_overlays'] as $file => $values) { if (! is_dir(dirname($root.'/'.$file))) { mkdir(dirname($root.'/'.$file), 0700, true); }copy($original.'/'.$file, $root.'/'.$file); } } // Frontend overlays are existing host files too; preserve their exact baseline // in native copies without sharing mutable assets with the real destination. foreach ($manifest['host_overlays'] as $file => $values) { if (!is_file($root.'/'.$file)) { if (!is_dir(dirname($root.'/'.$file))) mkdir(dirname($root.'/'.$file),0700,true); copy($original.'/'.$file,$root.'/'.$file); } } foreach (['bootstrap/cache', 'packages/purchasing', 'storage/framework/views', 'storage/framework/cache', 'storage/framework/sessions', 'storage/logs'] as $directory) { if (! is_dir($root.'/'.$directory)) { mkdir($root.'/'.$directory, 0700, true); } } copy($original.'/packages/purchasing/current.json',$root.'/packages/purchasing/current.json'); file_put_contents($root.'/storage/framework/down','{"status":503}'); return $root; }