add doctor command

This commit is contained in:
crazywhalecc
2023-04-22 21:23:12 +08:00
parent 4c0d35c723
commit 528ad1199a
11 changed files with 334 additions and 27 deletions

View File

@@ -2,16 +2,14 @@
declare(strict_types=1);
// 工作目录
use ZM\Logger\ConsoleLogger;
define('WORKING_DIR', getcwd());
const ROOT_DIR = __DIR__ . '/../..';
// 程序启动时间
// CLI start time
define('START_TIME', microtime(true));
// 规定目录
define('BUILD_ROOT_PATH', is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot'));
define('SOURCE_PATH', is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source'));
define('DOWNLOAD_PATH', is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads'));
@@ -24,29 +22,35 @@ define('SEPARATED_PATH', [
BUILD_ROOT_PATH,
]);
// 危险的命令额外用 notice 级别提醒
// dangerous command
const DANGER_CMD = [
'rm',
'rmdir',
];
// 替换方案
// file replace strategy
const REPLACE_FILE_STR = 1;
const REPLACE_FILE_PREG = 2;
const REPLACE_FILE_USER = 3;
// 编译输出类型
// build sapi type
const BUILD_MICRO_NONE = 0;
const BUILD_MICRO_ONLY = 1;
const BUILD_MICRO_BOTH = 2;
// 编译状态
// library build status
const BUILD_STATUS_OK = 0;
const BUILD_STATUS_ALREADY = 1;
const BUILD_STATUS_FAILED = 2;
// 编译类型
// build target type
const BUILD_TYPE_CLI = 1;
const BUILD_TYPE_MICRO = 2;
const BUILD_TYPE_FPM = 3;
// doctor error fix policy
const FIX_POLICY_DIE = 1; // die directly
const FIX_POLICY_PROMPT = 2; // if it can be fixed, ask fix or not
const FIX_POLICY_AUTOFIX = 3; // if it can be fixed, just fix automatically
ConsoleLogger::$date_format = 'H:i:s';

View File

@@ -105,7 +105,7 @@ function f_mkdir(string $directory, int $permissions = 0777, bool $recursive = f
return mkdir($directory, $permissions, $recursive);
}
function shell(): UnixShell
function shell(?bool $debug = null): UnixShell
{
return new UnixShell();
return new UnixShell($debug);
}