Giter Club home page Giter Club logo

electron-asar-hot-fix's Introduction

electron-asar-hot-fix

中文文档 | English

What it is

A NodeJs module for electron, used to support app.asar update, revised in electron-asar-hot-updater (thanks to yansenlei),electron-asar-hot-updater Based on electron-asar-updater refactoring.

electron-asar-hot-fix: https://github.com/iceliebodich/electron-asar-hot-fix electron-asar-hot-updater: https://github.com/yansenlei/electron-asar-hot-updater

How it works (Read this first)

  • EAU (Electron Asar Updater) was built upon Electron Application Updater to handle the process of updating the app.asar file inside an Electron app ; it simply replaces the app.asar file (at /resources/) with the new one called "update.asar"!
  • The check for "updates" must by triggered by the application. EAU doesn't make any kind of periodic checks on its own.
  • EAU talks to an API (let's call it so) to tell it if there is a new update.
    • EAU takes three parameters:
      • The first parameter is a object, it has the download url url, the file's sha1 value sha1, methodrequest method(post or get),and a custom parameter.
      • The second parameter is a successful callback.
      • The third parameter is a failed callback, it will tell us where we fail to update.
    • If there's an update available the API should respond with the source for this update update.asar file.
    • EAU then downloads the .asar file, deletes the old app.asar and renames the update.asar to app.asar.

But why ? (use cases)


Installation

$ npm install --save electron-asar-hot-fix

Now, inside the main.js file, call it like this:

const { app } = require("electron");
const EAU = require("electron-asar-hot-fix");

// Version checking needs to be implemented manually,sha1 is not necessary
app.on("ready", function () {
  const params = {
    url: "",
    sha1: "",
    method: "get", // or post
    args: {},
  };
  EAU.download(
    params,
    (success) => {},
    (error) => {}
  );
});

if you use vue-cli-plugin-electron-builder plugin

You may need to configure in vue.config.js:

module.exports = {
  pluginOptions: {
    electronBuilder: {
      builderOptions: {
        asar: true,
        extraResources: [
          {
            from: "node_modules/electron-asar-hot-fix/updater.exe",
            to: "../updater.exe",
          },
        ],
      },
    },
  },
};

let file smaller

When you use compressed files, the comparison of the sha1 value is the comparison of the incoming sha1 and the downloaded zip archive. If you use a zip file, the plug-in will unzip the file after downloading it, which will make your update file smaller, but you must make sure that update.asar is at the root of the zip package: At present, the name of this asar file can only be update, and it is not considered to support customization for the time being.

If you use compressed files, you need configure the Content-Disposition in the Response Headers, and it has the zip key words.

── update.zip
   └── update.asar

Windows update

This is to get around the fact that the prompt text from the timeout command was always being shown, even when redirecting to NUL

The updater.exe is a really simple C# console app, compiled with Mono. Source code. from electron-asar-updater pull #2. If the user system version is win7, you may need to manually install .Net framework first.

License

😃 if you have any comments or wish to contribute to this project, you are welcome to submit Issues or PR.

MIT - iceliebodich

electron-asar-hot-fix's People

Stargazers

Queal avatar

Watchers

James Cloos avatar  avatar

Forkers

queal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.