static-php-cli/src/SPC/doctor/item/WindowsToolCheckList.php
Jerry Ma 539aaefd72
Add initial windows runtime setup (#292)
* add initial windows runtime setup

* add cool console output

* doctor support windows base

* add `add-path` and `remove-path` for bin/setup-runtime

* fix composer.ps1 path

* add windows system util

* add windows cmd and doctor base check

* add windows fallback for laravel/prompts

* cd fix [skip ci]

* dir separator and typo fix [skip ci]
2023-12-24 20:17:06 +08:00

45 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace SPC\doctor\item;
use SPC\builder\windows\SystemUtil;
use SPC\doctor\AsCheckItem;
use SPC\doctor\AsFixItem;
use SPC\doctor\CheckResult;
use SPC\exception\RuntimeException;
class WindowsToolCheckList
{
#[AsCheckItem('if git are installed', limit_os: 'Windows', level: 999)]
public function checkGit(): ?CheckResult
{
if (SystemUtil::findCommand('git.exe') === null) {
return CheckResult::fail('Git not installed, please install git for windows manually, see: https://git-scm.com/download/win');
// return CheckResult::fail('Git not installed, see https://static-php.dev/en/guide/windows-setup.html');
}
return CheckResult::ok();
}
#[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 998)]
public function checkSDK(): ?CheckResult
{
if (!file_exists(PHP_SDK_PATH . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) {
return CheckResult::fail('php-sdk-binary-tools not downloaded', 'install-php-sdk');
}
return CheckResult::ok(PHP_SDK_PATH);
}
#[AsFixItem('install-php-sdk')]
public function installPhpSdk(): bool
{
try {
cmd(true)->exec('git clone https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH);
} catch (RuntimeException) {
return false;
}
return true;
}
}