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 🙏

© 2024 – Pkg Stats / Ryan Hefner

luck-electron-auto-updater

v1.0.0

Published

`luck-electron-auto-updater` is an enhancement of the native `autoUpdater`. While the native `autoUpdater` only supports the Squirrel program on Mac and Windows, this module additionally introduces support for Linux (Ubuntu). It's essential to note that t

Downloads

5

Readme

luck-electron-auto-updater

luck-electron-auto-updater is an enhancement of the native autoUpdater. While the native autoUpdater only supports the Squirrel program on Mac and Windows, this module additionally introduces support for Linux (Ubuntu). It's essential to note that the behavior on Linux differs: it merely notifies users of an update and, after downloading, guides them to open the file, requiring manual installation.

Updater Image

Note: On Linux systems, given that users must install manually, it's permissible not to sign the installation package.

简体中文 | English

API

The interfaces and events of this module remain consistent with the native autoUpdater.

Events

  • error
  • checking-for-update
  • update-available
  • update-not-available
  • update-downloaded
  • before-quit-for-update

Methods

  • setFeedURL
  • getFeedURL
  • checkForUpdates
  • quitAndInstall

For more details, refer to the autoUpdater Official Documentation.

Lifecycle

The lifecycle and event-triggering sequence of this module are the same as the native component. The only difference is that on Mac and Windows systems, the quitAndInstall method will update and exit. In contrast, on Linux, it only opens the location of the downloaded file.

Usage Example

const { app, dialog } = require('electron')
const log = require("electron-log");
const { CustomAutoUpdater } = require('luck-electron-auto-updater');

app.autoUpdater = autoUpdater = new CustomAutoUpdater();
const { domain, freq, appName, channel } = app.appConfig.autoUpdate;

log.info('auto update', domain, freq, appName, channel);

if (!domain) return;

const suffix = ['darwin', 'linux'].includes(process.platform) ? `/RELEASES.json?method=JSON&version=${app.getVersion()}` : '';
const checkUpdateUrl = `${domain}/${appName}/${channel}/${process.platform}/${process.arch}${suffix}`;

log.info('auto update checkUpdateUrl', checkUpdateUrl);

function showUpdateDialog() {
    const dialogOpts = {
        type: 'info',
        buttons: [['darwin', 'win32'].includes(process.platform) ? app.i18n.__('restart') : app.i18n.__('open'), app.i18n.__('later')],
        title: app.i18n.__('app_update_tip'),
        message: app.newRelease,
        detail: app.i18n.__('app_update_tip_detail')
    }

    dialog.showMessageBox(dialogOpts).then((returnValue) => {
        if (returnValue.response === 0) autoUpdater.quitAndInstall()
    })
}

autoUpdater.on('update-available', () => {
    log.log('update-available');
    if (app.newRelease)
        showUpdateDialog();
});

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
    log.log('update-downloaded');
    app.newRelease = process.platform === 'win32' ? releaseNotes : releaseName;
    showUpdateDialog();
})

autoUpdater.on('error', (message) => {
    log.error('There was a problem updating the application')
    log.error(message)
});

autoUpdater.setFeedURL({
    url: checkUpdateUrl,
    serverType: 'json',
});

app.whenReady().then(() => {

    // 默认在启用启动时检查一次更新
    setTimeout(() => {
        log.log('auto-update checkForUpdates');
        autoUpdater.checkForUpdates();
    }, 10000);

    // 定时检查更新
    setInterval(() => {
        log.log('auto-update interval checkForUpdates');
        autoUpdater.checkForUpdates()
    }, freq);
});
 autoUpdate: {
        // 是否启用自动更新
        enable: true,
        // 更新服务地址
        domain: "http://162.1.1.69:9999",
        // 更新服务中的应用名称
        appName: "pcclient",
        //publish server
        updateServer:'http://162.1.1.69:8888',
        // 更新频道id
        channel: "e1ad93770345249aeb962d450314e9ef",
        // app id
        appId: 1,
        // app token
        token: '960221a59f2788404ab848db4519592b',
        // 应用更新检测频率,默认每天提醒一次
        freq: 86400000
    },

Server Response Format

The format of the version list returned by the update server is as follows. Linux and Mac systems share a format, while Windows has its unique format.

{
  "releases": [
    {
      "version": "1.1.3",
      "updateTo": {
        "version": "1.1.3",
        "pub_date": "Tue Aug 15 2023 13:45:08 GMT+0800 (CST)",
        "notes": "",
        "name": "1.1.3",
        "url": "http://162.1.1.69:9999/pcclient/e1ad93770345249aeb962d450314e9ef/linux/arm64/luck-pc-client_1.1.3_arm64.deb"
      }
    },
    {
      "version": "1.1.4",
      "updateTo": {
        "version": "1.1.4",
        "pub_date": "Tue Aug 15 2023 13:45:08 GMT+0800 (CST)",
        "notes": "",
        "name": "1.1.4",
        "url": "http://162.1.1.69:9999/pcclient/e1ad93770345249aeb962d450314e9ef/linux/arm64/luck-pc-client_1.1.4_arm64.deb"
      }
    }
  ],
  "currentRelease": "1.1.4"
}

Win format:

B54F68436459E0DDF06CDDEB96DEDADED6082066 http://162.1.1.69:9999/pcclient/e1ad93770345249aeb962d450314e9ef/win32/arm64/luck-pc-client-arm64-1.1.3-full.nupkg 147072854

Testing

npm run test