nw-builder 4.22.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -295,6 +295,31 @@ const installerPath = await nwbuild({
295
295
 
296
296
  With the CLI, pass `--nsis.appId=com.example.demo --nsis.desktopShortcut=false`.
297
297
 
298
+ Set `publish` to make the installation self updatable with
299
+ [`@nwutils/updater`](https://www.npmjs.com/package/@nwutils/updater)'s
300
+ `NsisUpdater`, the same way as [for AppImages](#self-updating). The installer
301
+ puts an `app-update.yml` pointing at `publish` next to the app's executable,
302
+ and a `latest.yml` update info file (`latest-<arch>.yml` for architectures
303
+ other than `x64`) is written next to the installer. Upload both the installer
304
+ and `latest.yml` to every release. `NsisUpdater` downloads the new installer and
305
+ runs it silently: it waits for the app to exit, updates it, and starts the new
306
+ version, without asking for administrator rights. `sign` and
307
+ `updateInformation` are AppImage only.
308
+
309
+ ```json
310
+ {
311
+ "name": "demo",
312
+ "version": "1.2.0",
313
+ "nwbuild": {
314
+ "mode": "package",
315
+ "platform": "win",
316
+ "app": { "name": "Demo", "icon": "./icon.ico" },
317
+ "nsis": { "appId": "com.example.demo" },
318
+ "publish": { "provider": "github", "owner": "nwutils", "repo": "demo" }
319
+ }
320
+ }
321
+ ```
322
+
298
323
  ## API Reference
299
324
 
300
325
  Options
@@ -323,7 +348,7 @@ Options
323
348
  | format | `"AppImage" \| "deb" \| "rpm" \| "msix" \| "nsis" \| "dmg"` | `"AppImage"` on Linux, `"nsis"` on Windows | Packaged output format, used in package mode. Only `"AppImage"` and `"nsis"` are implemented today. |
324
349
  | sign | `boolean` | `false` | If true, embed a GPG signature in the AppImage. Used in package mode. |
325
350
  | signKey | `string` | | ID of the GPG key to sign with. Requires `sign`. Used in package mode. |
326
- | publish | `{provider: "github", owner, repo} \| {provider: "generic", url}` | | Where releases are published. Makes the AppImage self updatable with `@nwutils/updater`. Used in package mode. |
351
+ | publish | `{provider: "github", owner, repo} \| {provider: "generic", url}` | | Where releases are published. Makes the AppImage or NSIS installation self updatable with `@nwutils/updater`. Package mode. |
327
352
  | updateInformation | `boolean \| string` | | AppImage zsync update information. `true` derives it from `publish`. Used in package mode. |
328
353
  | nsis | `object` | | NSIS installer options, used in package mode. See [Windows installer (NSIS)](#windows-installer-nsis). |
329
354
  | app | `LinuxRc \| WinRc \| OsxRc` | Additional options for each platform. (See below.) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "4.22.0",
3
+ "version": "4.23.0",
4
4
  "description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@nwutils/builder": "^0.1.3",
59
59
  "@nwutils/getter": "^0.3.1",
60
- "@nwutils/packager": "^0.6.0",
60
+ "@nwutils/packager": "^0.7.0",
61
61
  "@nwutils/runner": "^0.2.7",
62
62
  "commander": "^15.0.0",
63
63
  "glob": "^13.0.6"
package/src/cli.js CHANGED
@@ -85,7 +85,13 @@ for (const arg of unknownArgs) {
85
85
  const opts = {
86
86
  ...program.opts(),
87
87
  app: appConfig,
88
- publish: Object.keys(publishConfig).length > 0 ? publishConfig : undefined,
88
+ /* The packager validates `publish`, so the raw --publish.* strings are passed as-is. */
89
+ publish:
90
+ Object.keys(publishConfig).length > 0
91
+ ? /** @type {import("./index.d.ts").PublishOptions} */ (
92
+ /** @type {unknown} */ (publishConfig)
93
+ )
94
+ : undefined,
89
95
  nsis: Object.keys(nsisConfig).length > 0 ? nsisConfig : undefined,
90
96
  srcDir: program.args.find(
91
97
  (arg) =>
package/src/index.d.ts CHANGED
@@ -46,8 +46,27 @@ export interface Options<P extends SupportedPlatform = SupportedPlatform> {
46
46
  format?: "AppImage" | "deb" | "rpm" | "msix" | "nsis" | "dmg";
47
47
  /** NSIS installer options, used in package mode. The installer's version, publisher, copyright and `.ico` icon come from `app`. */
48
48
  nsis?: NsisOptions;
49
+ /** Where releases are published, used in package mode. Makes the AppImage or NSIS installation self updatable with `@nwutils/updater`. */
50
+ publish?: PublishOptions;
49
51
  }
50
52
 
53
+ /** Where releases are published */
54
+ export type PublishOptions =
55
+ | {
56
+ /** The latest (non draft, non prerelease) release of a GitHub repository */
57
+ provider: "github";
58
+ /** Owner of the GitHub repository */
59
+ owner: string;
60
+ /** Name of the GitHub repository */
61
+ repo: string;
62
+ }
63
+ | {
64
+ /** Any static file server */
65
+ provider: "generic";
66
+ /** Base URL the latest release's files are served from */
67
+ url: string;
68
+ };
69
+
51
70
  /** NSIS installer options that have no equivalent in `app` */
52
71
  export interface NsisOptions {
53
72
  /** Name of the registry key the installation is recorded under. Defaults to `app.name`. Keep it the same across releases, so installing a new version replaces the previous one. */
package/src/index.js CHANGED
@@ -36,7 +36,7 @@ import util from "./util.js";
36
36
  * @property {"AppImage" | "deb" | "rpm" | "msix" | "nsis" | "dmg"} [format] Packaged output format, used in package mode. Defaults to `"AppImage"` on Linux and `"nsis"` on Windows. Only `"AppImage"` and `"nsis"` are implemented today - the others are reserved.
37
37
  * @property {boolean} [sign=false] If true, embed a GPG signature in the AppImage, used in package mode.
38
38
  * @property {string} [signKey] ID of the GPG key to sign the AppImage with, used in package mode. Requires `sign`.
39
- * @property {import("@nwutils/packager").PublishOptions} [publish] Where releases are published, used in package mode. Makes the AppImage self updatable with `@nwutils/updater`.
39
+ * @property {import("@nwutils/packager").PublishOptions} [publish] Where releases are published, used in package mode. Makes the AppImage or NSIS installation self updatable with `@nwutils/updater`.
40
40
  * @property {boolean | string} [updateInformation] AppImage zsync update information, used in package mode. `true` derives it from `publish`.
41
41
  * @property {import("./util.js").NsisOptions} [nsis] NSIS installer options, used in package mode. The installer's version, publisher, copyright and `.ico` icon come from `app`.
42
42
  */
package/src/util.js CHANGED
@@ -141,7 +141,7 @@ import * as GlobModule from "glob";
141
141
  * Windows `options.app` values `@nwutils/builder` also writes into the
142
142
  * executable, so both agree.
143
143
  * @param {Options} options Options after `parse()`.
144
- * @returns {{version: string, icon: string | undefined, publisher: string | undefined, copyright: string | undefined, appId: string | undefined, license: string | undefined, desktopShortcut: boolean, startMenuShortcut: boolean, makensisPath: string | undefined}} Options for `nsis()`.
144
+ * @returns {{version: string, icon: string | undefined, publisher: string | undefined, copyright: string | undefined, appId: string | undefined, license: string | undefined, desktopShortcut: boolean, startMenuShortcut: boolean, makensisPath: string | undefined, publish: import("@nwutils/packager").PublishOptions | undefined}} Options for `nsis()`.
145
145
  */
146
146
  function nsisOptions(options) {
147
147
  const app = options.app ?? {};
@@ -169,6 +169,7 @@ function nsisOptions(options) {
169
169
  desktopShortcut: /** @type {boolean} */ (nsis.desktopShortcut ?? true),
170
170
  startMenuShortcut: /** @type {boolean} */ (nsis.startMenuShortcut ?? true),
171
171
  makensisPath: nsis.makensisPath,
172
+ publish: options.publish,
172
173
  };
173
174
  }
174
175
 
@@ -732,6 +733,20 @@ export const validate = async (options, releaseInfo) => {
732
733
  );
733
734
  }
734
735
  }
736
+ /* GPG signatures and zsync update information only exist for AppImages. */
737
+ if (options.sign === true) {
738
+ throw new Error(
739
+ 'options.sign is only supported with options.format "AppImage".',
740
+ );
741
+ }
742
+ if (
743
+ options.updateInformation !== undefined &&
744
+ options.updateInformation !== false
745
+ ) {
746
+ throw new Error(
747
+ 'options.updateInformation is only supported with options.format "AppImage". NSIS installs self update with options.publish alone.',
748
+ );
749
+ }
735
750
  /* Throws now, before building, if the installer would have no version. */
736
751
  nsisOptions(options);
737
752
  }