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

qnb-updater

v1.0.0

Published

qnb updater

Downloads

1

Readme

graceful-updater

NPM version CI node version npm download

Software updates solution for Electron applications, It is convenient to complete full software update and dynamic update.

English | 简体中文

Installment

$ npm i graceful-updater --save

Sample

please visit: https://github.com/electron-modules/electron-modules-sample

// 1. options
const options = {
  url: getFeedUrl(),
  logger: console, // logger
  productName: 'demo',
  updateInfoFormatter: (res) => {
    return res;
  },
  ifNeedUpdate: (res) => {
    console.log('local version', currentVersion);
    console.log('local project version', currentBuildNumber);
    console.log('remote version', res.version);
    console.log('remote project version', res.project_version);
    return semver.gt(res.version, currentVersion) ||
      res.project_version > currentBuildNumber;
  },
};
// 2. initialization
const electronUpdator = new MacUpdator(options);

// 3. Bind events
electronUpdator.on(EventType.UPDATE_DOWNLOADED, (...args) => {
  console.log('updator >> %s, args: %j', EventType.UPDATE_DOWNLOADED, args);
});
electronUpdator.on(EventType.CHECKING_FOR_UPDATE, (...args) => {
  console.log('updator >> %s, args: %j', EventType.CHECKING_FOR_UPDATE, args);
});
electronUpdator.on(EventType.UPDATE_AVAILABLE, (data) => {
  const { version, project_version } = data?.updateInfo || {};
  const message = [
    'available',
    `local version: ${currentVersion}`,
    `local project version: ${currentBuildNumber}`,
    `remote version: ${version}`,
    `remote project version: ${project_version}`,
  ].join('\n');
  dialog.showMessageBoxSync({
    message,
  });
});
electronUpdator.on(EventType.UPDATE_NOT_AVAILABLE, (data) => {
  const { version, project_version } = data?.updateInfo || {};
  const message = [
    'not available',
    `local version: ${currentVersion}`,
    `local project version: ${currentBuildNumber}`,
    `remote version: ${version}`,
    `remote project version: ${project_version}`,
  ].join('\n');
  dialog.showMessageBoxSync({
    message,
  });
});
electronUpdator.on(EventType.ERROR, (...args) => {
  console.log('updator >> %s, args: %j', EventType.ERROR, args);
});
electronUpdator.on(EventType.UPDATE_DOWNLOAD_PROGRESS, (data) => {
  const { status, progress } = data;
  console.log('updator >> %s, status: %s, progress: %d', EventType.UPDATE_DOWNLOAD_PROGRESS, status, progress);
  app.windowManager.get('updator').webContents.send('updator:updateDownloadProgress', { status, progress });
});

Documents

Options

| Param | Type | Required | Description | Default value | | --- | --- | --- | --- | --- | | url | String | Yes | Check for update remote address, and the returned data follows the UpdateInfo object | | | ifNeedUpdate | Function | Yes | Check if update is required | | | updateInfoFormatter | Function | No | The server returns data format adaptation. If the returned format cannot match the UpdateInfo, this method can be used to format | | logger | Object | No | Log method | console | | productName | String | Yes | Application Name | | | autoDownload | String | No | Whether to download automatically | false | | getWindowsHelperExeDir | Function | No | Windows helper directory | false |

UpdateInfo

| Param | Type | Required | Description | Default value | | --- | --- | --- | --- | --- | | version | String | Yes | version | | | projectVersion | Number | No | project version | | | files | Array<Object> | Yes | The list of files to be downloaded. The returned data follows the File object | | | updateType | Enum<String> | Yes | Update type, full update or dynamic update.Package is full update,Asar is dynamic update | | | releaseNotes | Array<String> | Yes | The release notes. | |

File

| Param | Type | Required | Description | Default value | | --- | --- | --- | --- | --- | | url | String | No | download address | | | signature | String | No | download address signature | | | updateType | Enum<String> | Yes | Update type, full update or dynamic update.Package is full update,Asar is dynamic update | |

Methods

  1. checkForUpdates(ExecuteType)
  • ExecuteType ExecuteType(User or Auto)

Check whether there is content to be updated. If the ExecuteType is User, the update-available event will be triggered directly after the update is detected. Otherwise, the update-available event will be triggered after the package is automatically downloaded

  1. setFeedUrl(url)
  • url: New update URL According to the needs of different scenarios, dynamically set the URL for checking updates
  1. downloadUpdate(ExecuteType)
  • ExecuteType ExecuteType(User or Auto)

Start downloading the installation package. If the ExecuteType is User, no pre-check will be performed. After the download is completed, the update-downloaded event will be triggered directly. Otherwise, the update-downloaded event will be triggered after the internal pre-check is completed

  1. quitAndInstall() Exit the app and start the installation. If the installation package has been downloaded, the application will be restarted directly and the new version will be installed. Otherwise, enter the download process

Events

  1. checking-for-update

Triggered when checking for updates

  1. update-available
  • params: update info
  • params.updateInfo: UpdateInfo

Triggered when an available update is checked

  1. update-not-available
  • params: update info
  • params.updateInfo: UpdateInfo

Triggered when no updates are checked

  1. update-download-progress
  • params: status and file info the download process.
  • params.status: download status begin, downloading, end
  • params.progress: Current download progress percentage. 0 ~ 100
  • params.data: The file stream of downloaded content can be used for signature verification

Triggering during download

  1. update-downloaded

Triggered when the download is complete

  1. error
  • params: Error

Triggered when an error occurs inside the updater

Contributors

|zlyi|xudafeng|snapre| | :---: | :---: | :---: |

This project follows the git-contributor spec, auto updated at Sun Jun 04 2023 13:22:25 GMT+0800.

License

The MIT License (MIT)