first commit.

This commit is contained in:
kj
2026-10-05 15:08:39 -03:00
commit b7799f9fff
93 changed files with 8966 additions and 0 deletions
@@ -0,0 +1,47 @@
<?php
namespace Toolbox;
/**
* Ejecuta los comandos `post-install` de un paquete, mostrándolos y pidiendo
* confirmación salvo en modo `--yes`.
*/
final class PostInstall
{
/**
* @param list<string> $commands
* @param callable(string):int|null $runner
* @return list<string> comandos ejecutados
*/
public static function run(
array $commands,
Console $console,
bool $assumeYes = false,
?callable $runner = null
): array {
$executed = [];
foreach ($commands as $command) {
$console->out(' post-install: ' . $command);
if (!$console->confirm(' ¿Ejecutar?', $assumeYes)) {
$console->warn('post-install omitido: ' . $command);
continue;
}
if ($runner !== null) {
$runner($command);
} else {
passthru($command, $code);
if (($code ?? 0) !== 0) {
throw new ToolboxException("post-install falló: {$command}");
}
}
$executed[] = $command;
}
return $executed;
}
}