Files
RuoYi-Vue3-FastAPI/ruoyi-fastapi-backend/cli/groups/plugin/commands/developer.py
T
insistence 4bd83bc7cd feat: 支持 v2 插件、独立前端和签名制品发布 (#130)
* feat: 支持 v2 插件、原生扩展与签名发布

* fix: 修复测试

* feat: 增强宿主 SDK、运行观测与制品维护能力

* feat: 增强文件传输、配置观测与本地开发能力

* feat: 支持 SSE 实时事件流并完善开发脚手架

* feat: 完善长连接鉴权复核与关闭回收

* feat: 增强生命周期与任务关闭可靠性

* feat: 收紧健康检查契约并补齐前端与真实网络验收

* feat: 增加SDK溯源与离线更新工具并验证跨版本兼容

* feat: 增加持久化业务示例与受控 Python 交付

* feat: 增加统一运行诊断与多worker状态观测

* feat: 增加固定目标发布等待与自动验收

* fix: 修复多环境插件部署前缀与代理配置不一致

* fix: 修复测试
2026-10-09 23:49:45 +08:00

114 lines
4.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from collections.abc import Callable
from typing import Annotated, Any, Literal
import typer
from cli.context import DryRunOption, EnvOption, OutputOption
from ..options import PluginCreateCommandOptions
def register_developer_commands(app: typer.Typer, get_controller: Callable[[], Any]) -> None:
"""
注册插件开发者命令。
:param app: Typer 命令组
:param get_controller: 插件命令控制器工厂
:return: None
"""
@app.command('test', help='执行插件测试')
def test_command(
plugin_id: Annotated[str, typer.Argument(help='插件ID')],
env: EnvOption = 'dev',
output: OutputOption = 'text',
keyword: Annotated[str, typer.Option('--keyword', '-k', help='pytest -k 过滤表达式')] = '',
maxfail: Annotated[int, typer.Option('--maxfail', min=0, help='最大失败数,0 表示不限制')] = 0,
quiet: Annotated[bool, typer.Option('--quiet', '-q', help='启用简洁输出')] = False,
frontend_build: Annotated[bool, typer.Option('--frontend-build', help='追加执行前端构建验收')] = False,
) -> None:
"""
执行插件测试。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:param keyword: pytest 关键字过滤表达式
:param maxfail: 最大失败数
:param quiet: 是否启用简洁输出
:param frontend_build: 是否追加执行前端构建验收
:return: None
"""
get_controller().test_plugin(
plugin_id,
env,
output,
keyword=keyword,
maxfail=maxfail,
quiet=quiet,
frontend_build=frontend_build,
)
@app.command('create', help='创建插件开发模板')
def create_command( # noqa: PLR0913
plugin_id: Annotated[str, typer.Argument(help='插件ID')],
*,
env: EnvOption = 'dev',
output: OutputOption = 'text',
template: Annotated[
str,
typer.Option(
'--template',
help='v1:minimal、backend-only、full-stack、scheduled-job、crud-page;'
'v2:python-asgi、python-bundle、rust-asgi、rust-bundle(生成独立源码工程)',
),
] = 'full-stack',
frontend_version: Annotated[
Literal['auto', 'vue2', 'vue3'],
typer.Option('--frontend-version', help='v1 前端 Vue 版本:auto、vue2、vue3;v2 bundle 不使用宿主 Vue'),
] = 'auto',
backend_only: Annotated[bool, typer.Option('--backend-only', help='只创建后端插件模板')] = False,
frontend_only: Annotated[bool, typer.Option('--frontend-only', help='只创建前端插件模板')] = False,
no_migration: Annotated[bool, typer.Option('--no-migration', help='不创建 migration 示例')] = False,
no_seed: Annotated[bool, typer.Option('--no-seed', help='不创建 seed 示例')] = False,
no_job: Annotated[bool, typer.Option('--no-job', help='不创建定时任务示例')] = False,
no_config: Annotated[bool, typer.Option('--no-config', help='不创建配置项示例')] = False,
no_test: Annotated[bool, typer.Option('--no-test', help='不创建测试样例')] = False,
dry_run: DryRunOption = False,
) -> None:
"""
创建插件开发模板。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:param template: 插件模板名称
:param frontend_version: 前端 Vue 版本
:param backend_only: 是否只创建后端插件模板
:param frontend_only: 是否只创建前端插件模板
:param no_migration: 是否不创建 migration 示例
:param no_seed: 是否不创建 seed 示例
:param no_job: 是否不创建定时任务示例
:param no_config: 是否不创建配置项示例
:param no_test: 是否不创建测试样例
:param dry_run: 是否仅预演
:return: None
"""
get_controller().create_plugin(
plugin_id,
env,
output,
PluginCreateCommandOptions(
backend_only=backend_only,
frontend_only=frontend_only,
template=template,
frontend_version=frontend_version,
no_migration=no_migration,
no_seed=no_seed,
no_job=no_job,
no_config=no_config,
no_test=no_test,
dry_run=dry_run,
),
)