
Security News
Ruby's Bundler 4.0.18 Extends Cooldown to bundle lock and bundle cache
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.
@unihubjs/plugin-cli
Advanced tools
UniHub 官方插件开发 CLI 工具,快速创建、构建和打包 UniHub 插件。
# 全局安装
npm install -g @unihubjs/plugin-cli
# 或使用 npx(无需安装)
npx @unihubjs/plugin-cli create my-plugin
# 交互式创建
unihub-plugin create
# 或使用简写
uhp create
# 指定插件名称
uhp create my-awesome-plugin
# 指定模板
uhp create my-plugin --template vue
支持的模板:
simple - 纯 HTML/CSS/JS,最简单vue - Vue 3 + TypeScript,推荐react - React 18 + TypeScriptcd my-plugin
npm install
npm run dev
# 或使用 CLI
uhp dev
npm run build
# 或使用 CLI
uhp build
npm run package
# 或使用 CLI
uhp package
生成的 plugin.zip 可以直接拖拽到 UniHub 安装。
创建新插件项目
uhp create [name] [options]
选项:
-t, --template <type> 模板类型 (simple|vue|react)
-d, --dir <directory> 目标目录
启动开发服务器
uhp dev [options]
选项:
-p, --port <port> 端口号 (默认: 5173)
构建插件
uhp build [options]
选项:
-w, --watch 监听文件变化
打包插件为 .zip 文件
uhp package [options]
选项:
-o, --output <path> 输出路径 (默认: plugin.zip)
验证插件配置
uhp validate
检查:
my-plugin/
├── package.json # 插件配置
├── dist/ # 构建输出
│ └── index.html # 入口文件
├── src/ # 源代码
│ ├── main.ts
│ ├── App.vue
│ └── style.css
├── scripts/
│ └── package.js # 打包脚本
└── README.md
{
"name": "my-plugin",
"version": "1.0.0",
"description": "我的插件",
"author": "Your Name",
"unihub": {
"id": "com.yourname.myplugin",
"name": "我的插件",
"icon": "🚀",
"category": "tool",
"entry": "dist/index.html",
"permissions": ["clipboard"]
}
}
| 字段 | 说明 | 示例 |
|---|---|---|
id | 插件唯一标识(反向域名格式) | "com.yourname.myplugin" |
name | 插件显示名称 | "我的插件" |
icon | 图标(Emoji、URL 或相对路径) | "🚀" |
category | 分类 | "tool" |
entry | 入口文件路径 | "dist/index.html" |
| 字段 | 说明 | 示例 |
|---|---|---|
permissions | 权限列表 | ["clipboard", "fs"] |
keywords | 搜索关键词 | ["tool", "utility"] |
tool - 工具formatter - 格式化encoder - 编码/解码productivity - 效率developer - 开发者工具entertainment - 娱乐custom - 自定义clipboard - 剪贴板读写fs - 文件系统访问http - HTTP 请求spawn - 后端进程db - 数据库存储notification - 系统通知system - 系统信息插件可以通过 window.unihub 访问系统功能:
// 剪贴板
await window.unihub.clipboard.writeText('text')
const text = await window.unihub.clipboard.readText()
// 文件系统(需要 fs 权限)
const content = await window.unihub.fs.readFile(path)
await window.unihub.fs.writeFile(path, content)
// HTTP 请求(需要 http 权限)
const data = await window.unihub.http.get(url)
await window.unihub.http.post(url, data)
// 数据库(需要 db 权限)
const value = await window.unihub.db.get(key)
await window.unihub.db.set(key, value)
// 通知(需要 notification 权限)
await window.unihub.notification.show(title, body)
declare global {
interface Window {
unihub?: {
clipboard?: {
writeText: (text: string) => Promise<void>
readText: () => Promise<string>
}
// 其他 API...
}
}
}
使用 uhp dev 启动开发服务器,支持热重载。
在 UniHub 中打开开发者工具(F12)查看控制台输出。
plugin.zip 上传到 GitHub Release 或 CDNmarketplace/plugins.json用户可以直接拖拽 plugin.zip 到 UniHub 的插件管理页面安装。
查看 UniHub 项目中的示例插件:
examples/simple-html-plugin - 纯 HTML 实现examples/modern-vue-plugin - Vue 3 实现examples/h5-formatter-plugin - 格式化工具MIT
FAQs
UniHub 官方插件开发 CLI 工具
We found that @unihubjs/plugin-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.