扩展工具链维护
本页适用于维护 picloom、picloom-tooling、picloom-extensions 的核心开发者。开发独立插件或主题请直接参阅插件快速开始与主题快速开始。
包结构与职责
公共 SDK、校验规则与构建脚手架集中维护在 picloom-tooling 仓库(Bun 1.4.5+):
| 目录 | npm 包 | 职责 |
|---|---|---|
package-rules | @picloom/package-rules | 插件与主题共用的包身份/版本、资源路径、多语言文案、配置 Schema 与单次校验规则 |
plugin-sdk | @picloom/plugin-sdk | 插件声明(definePlugin)、运行契约、PluginError、文件/HTTP/扫描辅助与单测工具 |
theme-sdk | @picloom/theme-sdk | 主题声明(defineTheme)、纯浏览器运行契约、剪贴板/字节辅助与 Vue 组合式封装 |
tools/plugin-tools | @picloom/plugin-tools | 插件清单提取、离线结构检查与 ZIP 打包 CLI |
tools/theme-tools | @picloom/theme-tools | 主题本地模拟预览、离线校验、Vite 构建与 ZIP 打包 CLI |
tools/create-plugin | @picloom/create-plugin | bun create @picloom/plugin 脚手架与 template/ 源码模板 |
tools/create-theme | @picloom/create-theme | bun create @picloom/theme 脚手架与 template/ 源码模板 |
@picloom/theme-sdk 为纯浏览器契约,不引入插件 SDK 或服务端运行时。tools/create-theme/template/ 在构建时通过 prepare.ts 生成附带仓库根 LICENSE 的 dist/template/;调整主题模板时直接修改 template/,不手工编辑 dist/template/。
本地打包与跨仓同步
在 picloom-tooling 执行构建、类型检查与测试,并将 7 个包同步到相邻消费仓库(或生成的独立插件/主题目录):
cd ../picloom-tooling
bun install --frozen-lockfile
bun run build && bun run typecheck && bun test ./tests
bun run dev:sync -- ../picloom ../picloom-extensionsdev:sync 会先执行构建,将 7 个包打成带内容哈希的 .tgz 写入目标仓库 .local-packages/,改写目标仓库及其 workspace 的 package.json 并在目标仓库自动执行 bun install。
联调结束或提交代码前,切回已发布的 npm 版本并刷新目标仓库锁文件:
bun run dev:registry -- ../picloom ../picloom-extensions
cd ../picloom && bun install
cd ../picloom-extensions && bun installdev:registry 仅将 package.json 恢复为精确版本号,不会自动运行安装;必须在目标仓库执行 bun install 刷新 bun.lock(主仓 tests/ci-release.test.ts 会拦截残留的 .local-packages 引用)。
独立项目与仓库示例验证
在 picloom 主仓运行端到端工具链验证(默认读取相邻 ../picloom-tooling,可通过 PICLOOM_TOOLING_DIR 指定路径):
bun run test:plugin-tooling # 需下载网络;纯 Bun PATH 环境验证脚手架、类型、打包与隔离宿主安装/上传/处理
bun run test:theme-tooling # 需下载网络与 Playwright Chromium;验证脚手架、本地预览、构建与宿主安装主仓 examples/ 下的 5 个插件示例(path、storage、processor、access、post-save)由 examples/build.ts 调用 @picloom/plugin-tools 输出到 outputs/examples/*.zip,修改示例或 SDK 协议后执行:
bun run build:examples && bun test tests/examples.test.tsnpm 发布顺序
发布前可在各包目录执行 bun pm pack --dry-run 核对文件清单,按依赖层级依次发布:
- 发布
@picloom/package-rules。 - 更新依赖版本并构建测试后,发布
@picloom/plugin-sdk、@picloom/theme-sdk、@picloom/plugin-tools、@picloom/theme-tools。 - 同步
tools/create-plugin/template/package.json与tools/create-theme/template/package.json中固定的依赖版本号(修改模板时同步核对模板README.md),执行bun run build刷新create-theme/dist/template/,再发布@picloom/create-plugin与@picloom/create-theme。 - 执行
bun run dev:registry -- ../picloom ../picloom-extensions,在picloom与picloom-extensions运行bun install更新干净的bun.lock,并在空目录实测bun create。