From a6f5952dee6be8698a3e58aae4ba975949d802d3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 9 Jul 2021 12:59:07 +0800 Subject: [PATCH] update to 2.5.1 (build 416) --- docs/component/module/module-pack.md | 64 ++++++++++++++++--- docs/update/v2.md | 4 +- .../Generate/SystemdGenerateCommand.php | 2 +- src/ZM/Command/Module/ModuleListCommand.php | 7 +- src/ZM/Command/Module/ModulePackCommand.php | 7 +- src/ZM/Command/Module/ModuleUnpackCommand.php | 7 +- src/ZM/ConsoleApplication.php | 4 +- 7 files changed, 73 insertions(+), 22 deletions(-) diff --git a/docs/component/module/module-pack.md b/docs/component/module/module-pack.md index cdccefc2..d3fecade 100644 --- a/docs/component/module/module-pack.md +++ b/docs/component/module/module-pack.md @@ -100,14 +100,62 @@ src/ } ``` +#### - global-config-override +- 类型:string | false。 +- 含义:解包时是否需要手动编辑全局配置(`global.php`)。 -| 字段名 | 类型 | 含义 | -| ---------------------- | ---------------------------------- | ---------------------------------------- | -| description | string | 模块的描述 | -| version | string | 模块的版本(建议使用 x.y.z 三段式) | -| depends | array of string(例如`{"a":"b"}`) | 模块依赖关系声明 | -| light-cache-store | string[] | 打包模块时要储存的持久化 LightCache 键名 | -| global-config-override | string \| false | 是否需要手动编辑全局配置(`global.php`) | -| | | | +这里如果写 string 类型的,那么就是相当于在解包时会提示此处的内容,内容推荐填写要求解包模块用户需要编辑的项目,比如 「请将 static_file_server 的 status 改为 true,以便使用静态文本功能」。 +如果是 false,那么和不指定此参数效果是一样的,无需用户修改 global.php。 + +??? note "点我查看编写实例:" + ```json + { + "name": "foo", + "description": "这个是一个示例模块打包教程", + "global-config-override": "请将 static_file_server 的 status 改为 true" + } + ``` + +#### - allow-hotload + +- 类型:bool。 +- 含义:是否允许用户无需解压直接加载模块包文件(phar)。 + +当此项为 true 时,可以将模块包直接放入 `zm_data/modules` 文件夹下,然后将 `global.php` 中的 `module_loader` 项中的 `enable_hotload` 改为 true,启动框架即可加载。 + +??? note "点我查看编写实例:" + ```json + { + "name": "foo", + "description": "这个是一个示例模块打包教程", + "allow-hotload": true + } + ``` + +!!! warning "注意" + 如果使用允许热加载,那么模块包中的配置最好不要有 `global-config-override` 和 `light-cache-store`,以此来达到最正确的效果,一般热加载更适合 Library(库)类型的模块。 + +#### - zm-data-store + +- 类型:array of string(例如 `["foo","bar"]`)。 +- 含义:打包时要添加到模块包内的 `zm_data` 目录下的子目录或文件。 + +其中项目必须是相对路径,不能是绝对路径,且必须是在配置项 `zm_data` 指定的目录(默认会在框架项目的根目录下的 `zm_data/` 目录。 + +我们假设要打包一个 `{zm_data 目录}/config/` 目录及其目录下的文件,和一个 `main.png` 文件,下方是实例。 + +??? note "点我查看编写实例:" + ```json + { + "name": "foo", + "description": "这个是一个示例模块打包教程", + "zm-data-store": [ + "config/", + "main.png" + ] + } + ``` + +在打包时框架会自动添加这些文件到 phar 插件包内,到解包时,会自动将这些文件释放到对应框架的 `zm_data` 目录下。 \ No newline at end of file diff --git a/docs/update/v2.md b/docs/update/v2.md index 8b082528..141e539e 100644 --- a/docs/update/v2.md +++ b/docs/update/v2.md @@ -1,8 +1,8 @@ # 更新日志(v2 版本) -## v2.5.0(未发布,测试中) +## v2.5.0(build 415) -> 更新时间:未知 +> 更新时间:2021.7.9 以下是版本**新增内容**: diff --git a/src/ZM/Command/Generate/SystemdGenerateCommand.php b/src/ZM/Command/Generate/SystemdGenerateCommand.php index e750afb7..93f0d0b9 100644 --- a/src/ZM/Command/Generate/SystemdGenerateCommand.php +++ b/src/ZM/Command/Generate/SystemdGenerateCommand.php @@ -17,10 +17,10 @@ class SystemdGenerateCommand extends Command protected function configure() { $this->setDescription("生成框架的 systemd 配置文件"); - ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config'); } protected function execute(InputInterface $input, OutputInterface $output): int { + ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config'); $path = $this->generate(); $output->writeln("成功生成 systemd 文件,位置:" . $path . ""); $output->writeln("有关如何使用 systemd 配置文件,请访问 `https://github.com/zhamao-robot/zhamao-framework/issues/36`"); diff --git a/src/ZM/Command/Module/ModuleListCommand.php b/src/ZM/Command/Module/ModuleListCommand.php index 18d7f490..a4430a09 100644 --- a/src/ZM/Command/Module/ModuleListCommand.php +++ b/src/ZM/Command/Module/ModuleListCommand.php @@ -20,6 +20,10 @@ class ModuleListCommand extends Command protected function configure() { $this->setDescription("Build an \".phar\" file | 将项目构建一个phar包"); $this->setHelp("此功能将会把炸毛框架的模块打包为\".phar\",供发布和执行。"); + // ... + } + + protected function execute(InputInterface $input, OutputInterface $output): int { ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config'); ZMConfig::setEnv($args["env"] ?? ""); if (ZMConfig::get("global") === false) { @@ -38,10 +42,7 @@ class ModuleListCommand extends Command $timezone = ZMConfig::get("global", "timezone") ?? "Asia/Shanghai"; date_default_timezone_set($timezone); - // ... - } - protected function execute(InputInterface $input, OutputInterface $output): int { $list = ModuleManager::getConfiguredModules(); foreach ($list as $v) { diff --git a/src/ZM/Command/Module/ModulePackCommand.php b/src/ZM/Command/Module/ModulePackCommand.php index 806371b5..fc422249 100644 --- a/src/ZM/Command/Module/ModulePackCommand.php +++ b/src/ZM/Command/Module/ModulePackCommand.php @@ -24,6 +24,10 @@ class ModulePackCommand extends Command $this->setDescription("Build an \".phar\" file | 将项目构建一个phar包"); $this->setHelp("此功能将会把炸毛框架的模块打包为\".phar\",供发布和执行。"); $this->addOption("target", "D", InputOption::VALUE_REQUIRED, "Output Directory | 指定输出目录"); + // ... + } + + protected function execute(InputInterface $input, OutputInterface $output): int { ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config'); ZMConfig::setEnv($args["env"] ?? ""); if (ZMConfig::get("global") === false) { @@ -42,10 +46,7 @@ class ModulePackCommand extends Command $timezone = ZMConfig::get("global", "timezone") ?? "Asia/Shanghai"; date_default_timezone_set($timezone); - // ... - } - protected function execute(InputInterface $input, OutputInterface $output): int { $list = ModuleManager::getConfiguredModules(); if (!isset($list[$input->getArgument("module-name")])) { $output->writeln("不存在模块 ".$input->getArgument("module-name")." !"); diff --git a/src/ZM/Command/Module/ModuleUnpackCommand.php b/src/ZM/Command/Module/ModuleUnpackCommand.php index 5e4c70a8..60db7482 100644 --- a/src/ZM/Command/Module/ModuleUnpackCommand.php +++ b/src/ZM/Command/Module/ModuleUnpackCommand.php @@ -28,6 +28,10 @@ class ModuleUnpackCommand extends Command ]); $this->setDescription("Unpack a phar module into src directory"); $this->setHelp("此功能将phar格式的模块包解包到src目录下。"); + // ... + } + + protected function execute(InputInterface $input, OutputInterface $output): int { ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config'); ZMConfig::setEnv($args["env"] ?? ""); if (ZMConfig::get("global") === false) { @@ -46,10 +50,7 @@ class ModuleUnpackCommand extends Command $timezone = ZMConfig::get("global", "timezone") ?? "Asia/Shanghai"; date_default_timezone_set($timezone); - // ... - } - protected function execute(InputInterface $input, OutputInterface $output): int { $list = ModuleManager::getPackedModules(); if (!isset($list[$input->getArgument("module-name")])) { $output->writeln("不存在打包的模块 ".$input->getArgument("module-name")." !"); diff --git a/src/ZM/ConsoleApplication.php b/src/ZM/ConsoleApplication.php index c872ca92..46ddca68 100644 --- a/src/ZM/ConsoleApplication.php +++ b/src/ZM/ConsoleApplication.php @@ -28,8 +28,8 @@ class ConsoleApplication extends Application { private static $obj = null; - const VERSION_ID = 415; - const VERSION = "2.5.0"; + const VERSION_ID = 416; + const VERSION = "2.5.1"; /** * @throws InitException