/electronup:electronup-auto-updatefrom electronup
Integrates electron-updater auto-update into electronup projects. Covers initAutoUpdater, checkForUpdates, builderConfig.publish, platform-specific artifacts, and troubleshooting update failures.
Ships in electronup. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
electronup 导出三个基于 electron-updater 的辅助 API:
| 导出 | 说明 |
|---|---|
initAutoUpdater(options?) | 配置 updater,默认启动后检查;返回真实实例 |
checkForUpdates() | 手动检查;未打包(app.isPackaged === false)时返回 null |
autoUpdater | 真实实例的惰性代理,用来订阅事件 |
把 electron-updater 装进应用的 dependencies(不是 devDependencies):
pnpm add electron-updater
辅助代码在运行时才 require('electron-updater'),打包工具跟踪不到,加 noExternal 也没用,必须作为生产依赖随应用分发。
electronup.config.ts 把 electronup 打进主进程产物,并配置更新源:
import { defineConfig } from 'electronup'
export default defineConfig({
packConfig: {
noExternal: ['electronup'],
},
builderConfig: {
publish: [
{ provider: 'github', owner: 'your-org', repo: 'your-app' },
// 或 { provider: 'generic', url: 'https://updates.example.com/' }
],
linux: { target: ['AppImage'] },
},
})
主进程在 app.whenReady() 之后初始化,先订阅事件再初始化:
import { app } from 'electron'
import { autoUpdater, initAutoUpdater } from 'electronup'
void app.whenReady().then(() => {
autoUpdater.on('error', error => console.error('更新失败:', error))
autoUpdater.on('update-available', info => console.log('发现新版本', info.version))
autoUpdater.on('update-downloaded', () => {
// 提示用户重启;electronup 不提供内置 UI
})
initAutoUpdater({
checkOnStart: true, // 默认 true,仅打包后才真正请求
autoDownload: true, // 默认 true
autoInstallOnAppQuit: true, // 默认 true
// logger: 兼容 electron-updater 的 logger,可选
})
})
手动检查时 Promise 会正常 reject,需要自己 try/catch:
import { checkForUpdates } from 'electronup'
try { await checkForUpdates() }
catch (error) { console.error(error) }
electronup.config.ts、渲染进程或 preload 中调用(配置文件里只 import 不调用是安全的)。channel、allowPrerelease),通过 autoUpdater 代理读写即可。| 平台 | 构建 | 更新元数据 | 要求 |
|---|---|---|---|
| Windows | electronup build --win x64(NSIS,默认) | latest.yml | portable 不支持自动更新;正式发布建议签名(verifyUpdateCodeSignature 默认开启) |
| macOS | electronup build --mac(dmg + zip,默认) | latest-mac.yml | 必须保留 zip;应用需签名并公证,否则更新被系统拒绝 |
| Linux | electronup build --linux x64 | latest-linux.yml | 用 AppImage / deb / rpm;snap 不支持 |
把安装包、.blockmap 与 latest*.yml 一起上传到 publish 指向的位置。Windows / macOS 的 --dir 构建不生成 app-update.yml,目录包通过不能证明自动更新可用。
electronup build --dir 后检查未打包目录:resources/app(.asar) 中能找到 node_modules/electron-updater,且 electron.cjs 里已内联更新辅助代码(不是 require("electronup"))。resources/app-update.yml 中 provider 与地址正确,latest*.yml 的版本号、文件大小、sha512 与产物一致。python -m http.server 配合 generic provider)→ 启动旧版确认检测、下载、退出后安装、重启后版本变化。构建成功不等于升级可用,没做这一步要明确告诉用户。| 现象 | 原因 |
|---|---|
Cannot find module 'electron-updater' | 没装进 dependencies |
Cannot find module 'electronup' | 没加 packConfig.noExternal: ['electronup'] |
| 开发时不检查更新 | 预期行为:未打包时不发请求 |
客户端报找不到 latest.yml / 404 | 元数据没上传,或 publish 地址与上传位置不一致 |
| macOS 更新失败 | 缺 zip、未签名或未公证 |
| 构建配置阶段报 electron 相关错误 | 在配置文件或模块顶层调用了 updater API |
详细文档:https://quiteerjs.github.io/electronup/introduce/auto-update。
What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/electronup-build运行 electronup dev / electronup build,为 Windows、macOS、Linux 打包指定架构的安装包,只构建渲染进程(--web)或只出目录(--dir),并排查构建/打包失败。用户要启动 Electron 开发环境、打包、出安装包、在 CI 构建或遇到 electronup 构建报错时使用。/electronup-config编写或修改 electronup.config.ts(defineConfig、目录、viteConfig、packConfig、preload、builderConfig、签名、.env 环境变量)。用户要改 electronup 配置、加 Vite 插件、配置 preload、调整 electron-builder 选项、排查“配置不生效”时使用。/electronup-create用 create-electronup 新建 electronup + Electron 项目,或把 electronup 接入已有项目。用户提到创建/初始化 Electron 项目、create-electronup、electronup 模板(vanilla/vue/react/react-swc/solid)或“给现有项目加 electronup”时使用。/electronup-modules在 Electron 主进程里接入 @quiteer/electron-* 运行时模块包(窗口 browser、IPC 契约 ipc、预加载 preload、应用生命周期 app、菜单 menu、托盘 tray、全局快捷键 shortcut)。用户要管理窗口、写类型安全的 IPC、配 preload 通道白名单、做单实例 / deep link / 退出清理、加菜单托盘快捷键,或排查这些包的报错时使用。npx claudepluginhub quiteerjs/electronup --plugin electronupOther plugins' skills for the same job