mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-15 21:05:35 +08:00
- Add --installed option to check-update command to compare against on-disk version (tool packages) - Support use_installed parameter in ArtifactDownloader::checkUpdate/checkUpdates - Add -y shorthand for --auto-fix in doctor command - Hook InteractiveTerm::init() in ConsoleApplication::doRun() to properly inject Symfony input/output
122 lines
4.0 KiB
PHP
122 lines
4.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace StaticPHP;
|
|
|
|
use StaticPHP\Command\BuildLibsCommand;
|
|
use StaticPHP\Command\BuildTargetCommand;
|
|
use StaticPHP\Command\CheckUpdateCommand;
|
|
use StaticPHP\Command\CraftCommand;
|
|
use StaticPHP\Command\Dev\DumpCapabilitiesCommand;
|
|
use StaticPHP\Command\Dev\DumpStagesCommand;
|
|
use StaticPHP\Command\Dev\EnvCommand;
|
|
use StaticPHP\Command\Dev\GenDepsDataCommand;
|
|
use StaticPHP\Command\Dev\GenExtDocsCommand;
|
|
use StaticPHP\Command\Dev\GenExtTestMatrixCommand;
|
|
use StaticPHP\Command\Dev\IsInstalledCommand;
|
|
use StaticPHP\Command\Dev\LintConfigCommand;
|
|
use StaticPHP\Command\Dev\PackageInfoCommand;
|
|
use StaticPHP\Command\Dev\PackLibCommand;
|
|
use StaticPHP\Command\Dev\ShellCommand;
|
|
use StaticPHP\Command\Dev\TestBotCommand;
|
|
use StaticPHP\Command\DoctorCommand;
|
|
use StaticPHP\Command\DownloadCommand;
|
|
use StaticPHP\Command\DumpExtensionsCommand;
|
|
use StaticPHP\Command\DumpLicenseCommand;
|
|
use StaticPHP\Command\ExtractCommand;
|
|
use StaticPHP\Command\InstallPackageCommand;
|
|
use StaticPHP\Command\MicroCombineCommand;
|
|
use StaticPHP\Command\ResetCommand;
|
|
use StaticPHP\Command\SPCConfigCommand;
|
|
use StaticPHP\Package\TargetPackage;
|
|
use StaticPHP\Registry\PackageLoader;
|
|
use StaticPHP\Registry\Registry;
|
|
use StaticPHP\Util\InteractiveTerm;
|
|
use Symfony\Component\Console\Application;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
class ConsoleApplication extends Application
|
|
{
|
|
public const string VERSION = '3.0.0-alpha1';
|
|
|
|
private static array $additional_commands = [];
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct('StaticPHP', self::VERSION);
|
|
|
|
require_once ROOT_DIR . '/src/bootstrap.php';
|
|
|
|
// resolve registry
|
|
Registry::resolve();
|
|
|
|
/**
|
|
* @var string $name
|
|
* @var TargetPackage $package
|
|
*/
|
|
foreach (PackageLoader::getPackages(['target', 'virtual-target']) as $name => $package) {
|
|
// only add target that contains artifact.source
|
|
if ($package->hasStage('build')) {
|
|
logger()->debug("Registering build target command for package: {$name}");
|
|
$this->addCommand(new BuildTargetCommand($name));
|
|
}
|
|
}
|
|
|
|
// add core commands
|
|
$this->addCommands([
|
|
new DownloadCommand(),
|
|
new DoctorCommand(),
|
|
new InstallPackageCommand(),
|
|
new BuildLibsCommand(),
|
|
new ExtractCommand(),
|
|
new SPCConfigCommand(),
|
|
new DumpLicenseCommand(),
|
|
new DumpExtensionsCommand(),
|
|
new ResetCommand(),
|
|
new CheckUpdateCommand(),
|
|
new MicroCombineCommand(),
|
|
new CraftCommand(),
|
|
|
|
// dev commands
|
|
new ShellCommand(),
|
|
new IsInstalledCommand(),
|
|
new EnvCommand(),
|
|
new LintConfigCommand(),
|
|
new PackLibCommand(),
|
|
new DumpStagesCommand(),
|
|
new DumpCapabilitiesCommand(),
|
|
new PackageInfoCommand(),
|
|
new GenExtDocsCommand(),
|
|
new GenDepsDataCommand(),
|
|
new GenExtTestMatrixCommand(),
|
|
new TestBotCommand(),
|
|
]);
|
|
|
|
// add additional commands from registries
|
|
if (!empty(self::$additional_commands)) {
|
|
$this->addCommands(self::$additional_commands);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
public static function _addAdditionalCommands(array $additional_commands): void
|
|
{
|
|
self::$additional_commands = array_merge(self::$additional_commands, $additional_commands);
|
|
}
|
|
|
|
/**
|
|
* Hook Symfony's doRun() to inject the real input/output into InteractiveTerm before
|
|
* any command executes. From this point forward, InteractiveTerm uses the configured
|
|
* Console (respecting --no-ansi, --verbose, etc.) instead of the lazy STDERR fallback.
|
|
*/
|
|
public function doRun(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
InteractiveTerm::init($input, $output);
|
|
return parent::doRun($input, $output);
|
|
}
|
|
}
|