@elevo-ai/plugin-serve
v0.2.6
Published
Elevo Plugin Serve
Readme
@elevo/plugin-serve
Elevo Plugin Development Server - 用于本地插件开发的代理服务器。
功能特性
- 🔄 反向代理到主应用服务器
- 📦 本地插件 bundle 托管
- 🎯 可配置端口和代理服务器
- 📊 分级日志系统
安装
npm install -g @elevo/plugin-serve或在项目中使用:
npm install --save-dev @elevo/plugin-serve使用方法
基本用法
plugin-serve使用默认配置:
- Port:
3000 - Proxy Server:
https://172.30.0.188.nip.io - Log Level:
info
命令行参数
plugin-serve [options]选项
| 选项 | 简写 | 说明 | 默认值 |
|------|------|------|--------|
| --port <port> | -p | 服务器监听端口 | 3000 |
| --server <url> | -s | 代理服务器 URL | https://172.30.0.188.nip.io |
| --log-level <level> | -l | 日志级别 | info |
| --version | | 显示版本号 | |
| --help | | 显示帮助信息 | |
示例
自定义端口
plugin-serve --port 8080
# 或
plugin-serve -p 8080自定义代理服务器
plugin-serve --server https://my-server.example.com
# 或
plugin-serve -s https://my-server.example.com设置日志级别
# 仅显示错误
plugin-serve --log-level error
# 显示调试信息
plugin-serve --log-level debug
# 完全静默
plugin-serve --log-level silent组合使用
plugin-serve -p 8080 -s https://my-server.com -l debug日志级别
| 级别 | 说明 | 包含内容 |
|------|------|----------|
| debug | 调试模式 | 所有日志(debug, info, warn, error) |
| info | 信息模式(默认) | 一般信息、警告和错误 |
| warn | 警告模式 | 警告和错误 |
| error | 错误模式 | 仅错误信息 |
| silent | 静默模式 | 不输出任何日志 |
日志示例
info 级别(默认)
[2026-01-30T12:00:00.000Z] [INFO ] Plugin serve configuration:
[2026-01-30T12:00:00.001Z] [INFO ] Port: 3000
[2026-01-30T12:00:00.002Z] [INFO ] Proxy Server: https://172.30.0.188.nip.io
[2026-01-30T12:00:00.003Z] [INFO ] Log Level: info
[2026-01-30T12:00:00.100Z] [INFO ] Serving local plugin "my-plugin" from local bundle
[2026-01-30T12:00:00.200Z] [INFO ] Plugin server listening on http://localhost:3000debug 级别
[2026-01-30T12:00:00.000Z] [INFO ] Plugin serve configuration:
[2026-01-30T12:00:00.001Z] [INFO ] Port: 3000
[2026-01-30T12:00:00.002Z] [INFO ] Proxy Server: https://172.30.0.188.nip.io
[2026-01-30T12:00:00.003Z] [INFO ] Log Level: debug
[2026-01-30T12:00:00.010Z] [DEBUG] Plugin name: my-plugin
[2026-01-30T12:00:00.011Z] [DEBUG] Local bundle path: /path/to/dist/app.umd.js
[2026-01-30T12:00:00.100Z] [DEBUG] Proxying request: GET /api/v1/workspaces/123/plugins
[2026-01-30T12:00:00.150Z] [INFO ] Serving local plugin "my-plugin" from local bundle
[2026-01-30T12:00:00.200Z] [DEBUG] Proxying request to host app: GET /api/v1/other-endpoint
[2026-01-30T12:00:00.300Z] [INFO ] Plugin server listening on http://localhost:3000环境变量
也可以通过环境变量配置(优先级低于命令行参数):
export PLUGIN_SERVE_PORT=8080
export PLUGIN_SERVE_SERVER=https://my-server.com
export PLUGIN_SERVE_LOG_LEVEL=debug
plugin-serve兼容旧版环境变量:
PORT- 等同于PLUGIN_SERVE_PORTSERVER- 等同于PLUGIN_SERVE_SERVER
工作原理
- 本地 bundle 托管:拦截
/api/v1/local-plugins/definitions/:id/bundle请求,返回本地构建的dist/app.umd.js - 插件列表修改:拦截
/api/v1/workspaces/:workspaceId/plugins请求,将匹配的插件的bundle_url替换为本地 bundle 路径 - 反向代理:所有其他请求转发到配置的代理服务器
开发
# 安装依赖
npm install
# 本地测试
node bin/plugin-serve.js --help许可证
MIT
