Files
RuoYi-Vue3-FastAPI/ruoyi-fastapi-backend/cli/groups/plugin/commands/discovery.py
T
insistence 2a055ba648 feat: 新增插件系统 (#112)
* feat: 初始化插件系统

* refactor: 收口插件系统运行时重构

* perf: 优化插件系统类型提示

* fix&perf: 修复和优化插件系统

* fix: 修复gitignore规则误忽略插件文件的问题

* fix: 修复运行时插件根路径算错的问题

* fix: 加强插件发现和路由注册的防护措施

* revert: 回滚定时任务白名单

* fix: 移除未使用的应用路由注册探测

* revert: 恢复部分代码

* perf: 优化插件系统

* docs: 新增插件开发文档

* perf: 优化插件管理模块

* perf: 提升插件系统核心能力

* refactor: 重构生命周期 step runner

* fix: 修复lint错误

* test: 清理测试用例

* test: 调整测试目录名称

* fix: 修复前后端目录硬编码的问题

* fix: 修复插件系统安全性缺口

* refactor: 重新设计插件生命周期 Migration 事务与回滚

* perf: 优化插件系统边界问题

* refactor: 重构当前插件系统的依赖体系设计

* perf: 优化代码

* perf: 优化代码

* fix: 修复代码合并问题

* fix: 修复bug

* perf: 优化代码

* perf&fix: 优化代码和修复bug

* docs: 优化文档格式

* feat: 适配Vue2版本

* docs: 更新README文档

* fix: 修复ruff lint错误

* chore: 更新后端依赖文件
2026-07-28 20:35:18 +08:00

115 lines
3.6 KiB
Python

from collections.abc import Callable
from typing import Annotated, Any
import typer
from cli.context import EnvOption, OutputOption
def register_discovery_commands(app: typer.Typer, get_controller: Callable[[], Any]) -> None:
"""
注册插件发现与诊断命令。
:param app: Typer 命令组
:param get_controller: 插件命令控制器工厂
:return: None
"""
@app.command('list', help='查看本地插件列表')
def list_command(
env: EnvOption = 'dev',
output: OutputOption = 'text',
) -> None:
"""
查看本地插件列表。
:param env: 当前命令运行环境
:param output: 输出格式
:return: None
"""
get_controller().list_plugins(env, output)
@app.command('info', help='查看插件详情')
def info_command(
plugin_id: Annotated[str, typer.Argument(help='插件ID')],
env: EnvOption = 'dev',
output: OutputOption = 'text',
) -> None:
"""
查看插件详情。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:return: None
"""
get_controller().plugin_info(plugin_id, env, output)
@app.command('check', help='检查插件依赖状态')
def check_command(
plugin_id: Annotated[str | None, typer.Argument(help='插件ID,不传则检查全部插件')] = None,
env: EnvOption = 'dev',
output: OutputOption = 'text',
) -> None:
"""
检查插件依赖状态。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:return: None
"""
get_controller().check_plugin(plugin_id, env, output)
@app.command('health', help='执行插件健康检查')
def health_command(
plugin_id: Annotated[str, typer.Argument(help='插件ID')],
env: EnvOption = 'dev',
output: OutputOption = 'text',
) -> None:
"""
执行插件健康检查。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:return: None
"""
get_controller().health_plugin(plugin_id, env, output)
@app.command('diagnose', help='生成插件诊断包')
def diagnose_command(
plugin_id: Annotated[str, typer.Argument(help='插件ID')],
env: EnvOption = 'dev',
output: OutputOption = 'text',
output_file: Annotated[str, typer.Option('--output-file', help='诊断包 JSON 导出文件路径')] = '',
) -> None:
"""
生成插件诊断包。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:param output_file: 诊断包 JSON 导出文件路径
:return: None
"""
get_controller().diagnose_plugin(plugin_id, env, output, output_file=output_file)
@app.command('docs', help='生成插件 Markdown 文档片段')
def docs_command(
plugin_id: Annotated[str, typer.Argument(help='插件ID')],
env: EnvOption = 'dev',
output: OutputOption = 'text',
output_file: Annotated[str, typer.Option('--output-file', help='Markdown 文档导出文件路径')] = '',
) -> None:
"""
生成插件 Markdown 文档片段。
:param plugin_id: 插件ID
:param env: 当前命令运行环境
:param output: 输出格式
:param output_file: Markdown 文档导出文件路径
:return: None
"""
get_controller().generate_plugin_docs(plugin_id, env, output, output_file=output_file)