mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
trust filesystem, not downloads
This commit is contained in:
@@ -44,6 +44,9 @@ class CraftCommand extends BaseCommand
|
||||
// apply env
|
||||
array_walk($craft['extra-env'], fn ($v, $k) => f_putenv("{$k}={$v}"));
|
||||
|
||||
// stash craft for doctor checks that depend on what's being built (e.g. frankenphp → go-xcaddy)
|
||||
ApplicationContext::set('craft', $craft);
|
||||
|
||||
// run doctor
|
||||
if ($craft['craft-options']['doctor']) {
|
||||
$doctor = new Doctor($this->output, FIX_POLICY_AUTOFIX);
|
||||
|
||||
43
src/StaticPHP/Doctor/Item/GoXcaddyCheck.php
Normal file
43
src/StaticPHP/Doctor/Item/GoXcaddyCheck.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace StaticPHP\Doctor\Item;
|
||||
|
||||
use StaticPHP\Attribute\Doctor\CheckItem;
|
||||
use StaticPHP\Attribute\Doctor\FixItem;
|
||||
use StaticPHP\Attribute\Doctor\OptionalCheck;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Doctor\CheckResult;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
|
||||
#[OptionalCheck([self::class, 'optionalCheck'])]
|
||||
class GoXcaddyCheck
|
||||
{
|
||||
public static function optionalCheck(): bool
|
||||
{
|
||||
if (!ApplicationContext::has('craft')) {
|
||||
return false;
|
||||
}
|
||||
$craft = ApplicationContext::get('craft');
|
||||
return in_array('frankenphp', $craft['sapi'] ?? [], true);
|
||||
}
|
||||
|
||||
#[CheckItem('if go-xcaddy is installed', level: 800)]
|
||||
public function check(): CheckResult
|
||||
{
|
||||
if (!new PackageInstaller()->addInstallPackage('go-xcaddy')->isPackageInstalled('go-xcaddy')) {
|
||||
return CheckResult::fail('go-xcaddy is not installed', 'install-go-xcaddy');
|
||||
}
|
||||
return CheckResult::ok(PKG_ROOT_PATH . '/go-xcaddy/bin/xcaddy');
|
||||
}
|
||||
|
||||
#[FixItem('install-go-xcaddy')]
|
||||
public function installGoXcaddy(): bool
|
||||
{
|
||||
$installer = new PackageInstaller(interactive: false);
|
||||
$installer->addInstallPackage('go-xcaddy');
|
||||
$installer->run(true);
|
||||
return $installer->isPackageInstalled('go-xcaddy');
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class ZigCheck
|
||||
public function checkZig(): CheckResult
|
||||
{
|
||||
if (new PackageInstaller()->addInstallPackage('zig')->isPackageInstalled('zig')) {
|
||||
return CheckResult::ok();
|
||||
return CheckResult::ok(PKG_ROOT_PATH . '/zig/zig');
|
||||
}
|
||||
return CheckResult::fail('zig is not installed', 'install-zig');
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ class PackageInstaller
|
||||
if ($this->isBuildPackage($package)) {
|
||||
return $package->isInstalled();
|
||||
}
|
||||
if ($package->getArtifact() !== null && $package->getArtifact()->shouldUseBinary()) {
|
||||
if ($package->getArtifact() !== null && $package->getArtifact()->hasPlatformBinary()) {
|
||||
$artifact = $package->getArtifact();
|
||||
return $artifact->isBinaryExtracted();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user