63 lines
3.2 KiB
Markdown
63 lines
3.2 KiB
Markdown
# 插件发布(桌面版)
|
||
|
||
> 2026-12-01 重写:网页版已停用,Cloudflare Pages / Functions / `PLUGINS` KV 通道一起下线,
|
||
> `scripts/plugins-publish.sh`、`scripts/plugins-publish.mjs` 已删除。桌面版插件只走**插件市场**。
|
||
|
||
## 两条链路
|
||
|
||
| 链路 | 说明 | 产物 |
|
||
|---|---|---|
|
||
| 内置插件 | 随安装包发布,启动即加载 | 桌面仓 `plugins/`(`plugin-<id>.<sha12>.js` + `index.json` 带 SRI `integrity`) |
|
||
| 市场插件 | 用户按需安装 | `market/plugins/<id>-<ver>.zip` + `market/index.json`,托管在 `market.maqiart.eu.org` |
|
||
|
||
纯函数(`integrityOf` / `storedNameOf` / `buildIndex` / `mergeIndexes`)在 `scripts/plugin-integrity.mjs`,
|
||
由同步脚本与测试共用;加载与注册仍由 `src/plugin-host.js` + `src/runtime-plugin-loader.js` 负责。
|
||
|
||
## 发布步骤
|
||
|
||
```bash
|
||
# 1) 插件源仓:改版本(package.json 与 src/index.js 里 register 的 version 必须同时改)→ 校验 → 提交
|
||
cd ~/open/github/iwb-plugins-desktop
|
||
npm run build -- <需构建的插件> # 手写单文件跳过
|
||
npm run validate # 必须 15/15
|
||
|
||
# 2) 桌面仓:同步内置产物 + 生成市场
|
||
cd ~/open/github/image-workbench-desktop
|
||
node scripts/sync-plugins-from-repo.js
|
||
node scripts/gen-market.js
|
||
node scripts/gen-market-page.js
|
||
node scripts/gen-site.js # 复制成 site/plugins-index.json 并刷新首页/插件页版本号
|
||
npm run check:plugins # 13 个插件一致性门禁(发布脚本也会自动跑)
|
||
|
||
# 3) 上传 NAS(文件是只读位,覆盖前先 rm)
|
||
scp market/index.json market/index.html [email protected]:/vol8/web/iwb-market/
|
||
scp market/plugins/<id>-<ver>.zip [email protected]:/vol8/web/iwb-market/plugins/
|
||
scp site/index.html site/plugins-index.json [email protected]:/vol8/web/iwb-download/
|
||
scp site/plugins/index.html [email protected]:/vol8/web/iwb-download/plugins/
|
||
ssh [email protected] "chmod -R a+rX /vol8/web/iwb-market /vol8/web/iwb-download"
|
||
```
|
||
|
||
## 必须回读核验
|
||
|
||
不能只看命令退出码,下载站与市场都要回读:
|
||
|
||
```bash
|
||
curl -s "https://market.maqiart.eu.org/index.json?t=$(date +%s)" | head -c 200
|
||
curl -s "https://download.maqiart.eu.org/plugins-index.json?t=$(date +%s)" | head -c 200
|
||
```
|
||
|
||
- 市场索引条数正确(当前 13 个),改动插件版本已更新
|
||
- 每个新 zip 的 `bundleSha256` 与线上下载字节一致
|
||
- 解包 `main.js` 确认 manifest 的 `version` 真的变了(2026-12-01 就踩过:清单升版、产物没升版)
|
||
|
||
## 客户端安装时的校验
|
||
|
||
`src/runtime-plugin-market.js` 对市场条目做:zip 整体 `bundleSha256` → 逐文件 sha256(`files[]`)→ 路径白名单 → 体积/数量上限;
|
||
内置清单的 `integrity` 交给浏览器 SRI 强制校验,缺失即拒载(开发者模式的 `plugins/local/` 例外)。
|
||
|
||
## 版本号一致性(历史事故)
|
||
|
||
- `package.json` 与 `src/index.js` 里 register 的 `version` 是两处,只改一处会让客户端自报旧版本
|
||
- 需构建的插件(image-annotate / image-vectorize)**先确认 `<id>/plugin/` 源码不落后于已提交产物**再 build,
|
||
否则重建会回退手工补的补丁(2026-12-01 实测会丢 `getNodeImage(id,{max:4096/2048})`)
|