Skip to content

Commit e08d314

Browse files
committed
[FIX] Deleting install files in finalisation install.
1 parent 1a89936 commit e08d314

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

bin/evo

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ final class EvoBootstrapper
292292
$composerHome = rtrim($home, "/\\") . DIRECTORY_SEPARATOR . '.composer';
293293
}
294294

295+
// Ensure Composer sees these even if we fall back to shell execution.
296+
@putenv('HOME=' . $home);
297+
@putenv('COMPOSER_HOME=' . $composerHome);
298+
if (!is_dir($composerHome)) {
299+
@mkdir($composerHome, 0755, true);
300+
}
301+
295302
$this->out('Updating PHP installer package via Composer...');
296303
$code = $this->runProcess(
297304
[
@@ -448,7 +455,7 @@ final class EvoBootstrapper
448455
2 => STDERR,
449456
];
450457

451-
$mergedEnv = array_merge($_ENV, $env);
458+
$mergedEnv = array_merge($this->readCurrentEnvironment(), $env);
452459
$proc = @proc_open($cmd, $descriptors, $pipes, $cwd ?: null, $mergedEnv);
453460
if (is_resource($proc)) {
454461
$code = proc_close($proc);
@@ -475,6 +482,39 @@ final class EvoBootstrapper
475482
return (int)$exitCode;
476483
}
477484

485+
/**
486+
* @return array<string, string>
487+
*/
488+
private function readCurrentEnvironment(): array
489+
{
490+
$env = [];
491+
492+
foreach ($_ENV as $k => $v) {
493+
if (is_string($k) && is_string($v)) {
494+
$env[$k] = $v;
495+
}
496+
}
497+
foreach ($_SERVER as $k => $v) {
498+
if (is_string($k) && is_string($v)) {
499+
$env[$k] = $v;
500+
}
501+
}
502+
503+
// Provide a sane PATH if the environment is mostly empty.
504+
if (!isset($env['PATH']) || trim($env['PATH']) === '') {
505+
$path = getenv('PATH');
506+
if (is_string($path) && trim($path) !== '') {
507+
$env['PATH'] = $path;
508+
} else {
509+
$env['PATH'] = PHP_OS_FAMILY === 'Windows'
510+
? 'C:\\Windows\\System32'
511+
: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin';
512+
}
513+
}
514+
515+
return $env;
516+
}
517+
478518
private function isFunctionDisabled(string $name): bool
479519
{
480520
$disabled = (string)ini_get('disable_functions');

src/Commands/InstallCommand.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,13 +2930,34 @@ protected function finalizeInstallation(string $name, array $options): void
29302930
$this->tui->addLog('Removed install directory.', 'info');
29312931
}
29322932

2933+
// Remove localization tooling dir (not needed in production)
2934+
$txDir = $projectPath . '/.tx';
2935+
if (is_dir($txDir)) {
2936+
$this->removeDirectory($txDir);
2937+
$this->tui->addLog('Removed .tx directory.', 'info');
2938+
}
2939+
29332940
// Remove composer.json from root (not the one in core/)
29342941
$rootComposerJson = $projectPath . '/composer.json';
29352942
if (file_exists($rootComposerJson) && !is_dir($rootComposerJson)) {
29362943
@unlink($rootComposerJson);
29372944
$this->tui->addLog('Removed root composer.json.', 'info');
29382945
}
29392946

2947+
// Remove repository-only files from project root
2948+
foreach ([
2949+
'.gitattributes',
2950+
'LICENSE',
2951+
'ng.inx',
2952+
'README.md',
2953+
] as $file) {
2954+
$path = $projectPath . '/' . $file;
2955+
if (file_exists($path) && !is_dir($path)) {
2956+
@unlink($path);
2957+
$this->tui->addLog("Removed {$file}.", 'info');
2958+
}
2959+
}
2960+
29402961
// Remove config.php.example
29412962
$configExample = $projectPath . '/config.php.example';
29422963
if (file_exists($configExample)) {

0 commit comments

Comments
 (0)