npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sellerartifact/electron-app-updater

v0.0.7

Published

用于 Electron 主进程的轻量更新工具。它从版本接口获取最新版本信息;检测到版本变化时,下载新的构建脚本、记录版本号,并重启应用。

Readme

electron-app-updater

用于 Electron 主进程的轻量更新工具。它从版本接口获取最新版本信息;检测到版本变化时,下载新的构建脚本、记录版本号,并重启应用。

安装

pnpm add @sellerartifact/electron-app-updater

使用

在 Electron 的主进程中创建更新器,并在合适的时机调用 checkVersion()。传入的 app 与 dialog 通常来自 electron 包。

import { app, dialog } from 'electron';
import { ElectronAppUpdater } from '@sellerartifact/electron-app-updater';

const updater = new ElectronAppUpdater({
  checkVersionUrl: 'https://example.com/api/app-version',
  app,
  dialog,
});

app.whenReady().then(async () => {
  const isLatest = await updater.checkVersion();

  if (isLatest) {
    console.log('当前已是最新版本');
  }
});

checkVersion() 在远端版本与本地版本一致时返回 true。检测到新版本时,它会执行更新和重启流程,并返回 false。

版本接口

checkVersionUrl 指向的接口需要返回以下结构,其中 url 是可直接下载的 JavaScript 文件地址:

{
  "result": {
    "version": 2,
    "url": "https://example.com/releases/build.js"
  }
}

版本号使用严格不等比较,因此接口应始终返回稳定、可比较的版本值,例如递增数字。

配置

| 参数 | 必填 | 默认值 | 说明 | | -------------------- | ---- | ------------- | --------------------------------------------------- | | checkVersionUrl | 是 | - | 版本接口地址。 | | app | 是 | - | Electron 的 app 实例,用于重启和退出应用。 | | dialog | 是 | - | Electron 的 dialog 实例,用于显示发现更新的提示。 | | configJSONFileName | 否 | config.json | 本地版本记录文件名。 | | buildJSFileName | 否 | build.js | 下载后写入的构建脚本文件名。 |

当前版本信息和构建脚本固定存放在 ./resources/app/src/main:

resources/app/src/main/
	config.json
	build.js

更新时会先将远端版本写入 config.json,再用下载内容覆盖 build.js,约 1.2 秒后调用 app.relaunch() 和 app.exit(0)。请确保该目录存在且应用对其有写入权限。

开发

pnpm install
pnpm build

监听构建:

pnpm dev