update to v2.4.0 (build 400)

add systemd:generate command
add check:config command
init command add `--force|-F` option
add MessageUtil function `addShortCommand()`
clear debug message
This commit is contained in:
jerry
2021-03-25 16:18:09 +08:00
parent 6155236d3c
commit 93a68a5582
12 changed files with 89 additions and 57 deletions

View File

@@ -9,7 +9,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class CheckConfigCommand extends Command
{
protected static $defaultName = 'check-config';
protected static $defaultName = 'check:config';
private $need_update = false;
@@ -17,14 +17,13 @@ class CheckConfigCommand extends Command
$this->setDescription("检查配置文件是否和框架当前版本有更新");
}
/** @noinspection PhpIncludeInspection */
protected function execute(InputInterface $input, OutputInterface $output): int {
if (LOAD_MODE !== 1) {
$output->writeln("<error>仅限在Composer依赖模式中使用此命令");
return Command::FAILURE;
}
$current_cfg = WORKING_DIR . "/config/";
$remote_cfg = include_once $current_cfg . "/vendor/zhamao/framework/config/global.php";
$current_cfg = getcwd() . "/config/";
$remote_cfg = include_once WORKING_DIR . "/config/global.php";
if (file_exists($current_cfg . "global.php")) {
$this->check($remote_cfg, "global.php", $output);
}
@@ -39,17 +38,23 @@ class CheckConfigCommand extends Command
}
if ($this->need_update === true) {
$output->writeln("<comment>有配置文件需要更新,详情见文档 https://framework.zhamao.xin/update/config.md</comment>");
} else {
$output->writeln("<info>配置文件暂无更新!</info>");
}
return Command::SUCCESS;
}
/**
* @noinspection PhpIncludeInspection
*/
private function check($remote, $local, OutputInterface $out) {
$local_file = include_once WORKING_DIR . "/config/".$local;
$local_file = include_once getcwd() . "/config/".$local;
foreach($remote as $k => $v) {
$out->writeln("<comment>正在检查".$k."</comment>");
if (!isset($local_file[$k])) {
$out->writeln("<info>配置文件 ".$local . " 需要更新!</info>");
$out->writeln("<error>配置文件 ".$local . " 需要更新!(缺少 `$k` 字段配置)</error>");
$this->need_update = true;
return;
}
}
}