# @electron-delta/builder

> True delta updates for electronjs.

Latest version **0.1.17** (published 2022-08-16) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @electron-delta/builder
pnpm add @electron-delta/builder
yarn add @electron-delta/builder
bun add @electron-delta/builder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.17 |
| Published | 2022-08-16 |
| First published | 2022-04-11 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 5.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Sandeep Acharya |
| Maintainers | sandeep1995 |
| Keywords | electron-delta-builder, electron-delta, delta-updates, auto-updater |

## Links

- npm: https://www.npmjs.com/package/@electron-delta/builder
- Repository: https://github.com/electron-delta/electron-delta
- Homepage: https://github.com/electron-delta/electron-delta#readme
- Issues: https://github.com/electron-delta/electron-delta/issues
- npm.io page: https://npm.io/package/@electron-delta/builder

## Dependencies (6)

- [got](https://npm.io/package/got.md) ^11.8.3
- [semver](https://npm.io/package/semver.md) ^7.3.7
- [node-7z](https://npm.io/package/node-7z.md) ^3.0.0
- [7zip-bin](https://npm.io/package/7zip-bin.md) ^5.2.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [env-paths](https://npm.io/package/env-paths.md) ^2.2.1

## Recent versions

- 0.1.17 (latest) — 2022-08-16
- 0.1.14 — 2022-06-07
- 0.1.13 — 2022-05-24
- 0.1.12 — 2022-05-20
- 0.1.11 — 2022-05-20
- 0.1.10 — 2022-04-26
- 0.1.5 — 2022-04-22
- 0.1.4 — 2022-04-11
- 0.1.3 — 2022-04-11

## README

## I'm working on macos delta updates. It's going to come soon. Help required!

# @electron-delta/builder

True delta updates for electronjs apps. It reduces the bandwidth usage by 90%. Users download only the delta. It uses binary diffing (`HDiffPatch` library) to generate the delta.

![Delta updates](https://electrondelta.com/assets/delta-downloading.png)

## Requirements

1. The app must use `electron-builder` to build the app.
2. Currently only `Windows` os is supported. MacOS support is arriving soon.
3. Target must be `nsis` or `nsis-web`

## Installation

#### Step 1:

```sh
npm install @electron-delta/builder -D
```

#### Step 2:

Create a file name called `.electron-delta.js` in the root of the project.

#### Step 3:

In the `electron-builder` config, mention the above file as `afterAllArtifactBuild` hook.

```json
"build": {
    "appId": "com.electron.sample-app",
    "afterAllArtifactBuild": ".electron-delta.js",
    "win": {
      "target": ["nsis"],
      "publish": ["github"]
    },
    "nsis": {
      "oneClick": true,
      "perMachine": false,
    }
}
```

#### Step 4:

Paste the following code in the `.electron-delta.js` file. It will be executed after the app is built.

```js
// .electron-delta.js
const DeltaBuilder = require("@electron-delta/builder");
const path = require("path");

const options = {
  productIconPath: path.join(__dirname, "icon.ico"),
  productName: "electron-sample-app",

  getPreviousReleases: async () => {
    return [
      {
        version: '0.0.12',
        url: 'https://github.com/electron-delta/electron-sample-app/releases/download/v0.0.12/electron-sample-app-0.0.12.exe'
      },
      {
        version: '0.0.11',
        url: 'https://github.com/electron-delta/electron-sample-app/releases/download/v0.0.11/electron-sample-app-0.0.11.exe'
      },
      {
        version: '0.0.9',
        url: 'https://github.com/electron-delta/electron-sample-app/releases/download/v0.0.9/electron-sample-app-0.0.9.exe'
      }
    ];
  },
  sign: async (filePath) => {
    // sign each delta executable
  },
};

exports.default = async function (context) {
  const deltaInstallerFiles = await DeltaBuilder.build({
    context,
    options,
  });
  return deltaInstallerFiles;
};
```

## `options`
  - `productIconPath`: (required) Path to the icon file. The icon file must be a .ico file.
  - `productName`: (required) Name of the product.
  - `getPreviousReleases`: (required) Function to get the previous releases. It must return an array of objects. Each object must have `version` and `url` properties.
  - `sign`: (required) Function to sign the delta executable.
  - `cache`: (optional) Path to the cache directory. If not specified, the default cache directory will be used. The default cache directory is `~/.electron-delta/`.
  - `processName`: (optional) Name of the process. If different from the product name.
  - `latestVersion`: (optional) Latest version of the product. If not specified, the latest version will be fetched `process.env.npm_package_version`.

---
_Source: https://npm.io/package/@electron-delta/builder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
