nw-builder 4.20.0 → 4.22.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
@@ -195,7 +195,7 @@ const packagePath = await nwbuild({
195
195
  });
196
196
  ```
197
197
 
198
- `format` selects the packager to run and defaults to `"AppImage"` on Linux. Only `"AppImage"` is implemented today - `deb`, `rpm`, `msix`, `nsis` and `dmg` are reserved for later.
198
+ `format` selects the packager to run. It defaults to `"AppImage"` on Linux and `"nsis"` on Windows. Only `"AppImage"` and `"nsis"` are implemented today - `deb`, `rpm`, `msix` and `dmg` are reserved for later.
199
199
 
200
200
  ```javascript
201
201
  const appImagePath = await nwbuild({
@@ -204,33 +204,129 @@ const appImagePath = await nwbuild({
204
204
  });
205
205
  ```
206
206
 
207
+ #### Signing
208
+
209
+ Set `sign` to embed a GPG signature in the AppImage. It needs `gpg` on the host
210
+ with the secret key imported. `signKey` picks the key, defaulting to `gpg`'s
211
+ default secret key. A passphrase protected key reads its passphrase from the
212
+ `APPIMAGETOOL_SIGN_PASSPHRASE` environment variable.
213
+
214
+ ```javascript
215
+ await nwbuild({
216
+ mode: "package",
217
+ sign: true,
218
+ signKey: "ABCDEF1234567890",
219
+ });
220
+ ```
221
+
222
+ #### Self updating
223
+
224
+ Set `publish` to where releases are uploaded to make the AppImage self updatable
225
+ with [`@nwutils/updater`](https://www.npmjs.com/package/@nwutils/updater). An
226
+ `app-update.yml` pointing at `publish` is embedded in the AppImage, and a
227
+ `latest-linux.yml` update info file holding the app's `package.json` `version`
228
+ is written next to it. Upload both to every release.
229
+
230
+ Set `updateInformation: true` to also support zsync based updaters such as
231
+ AppImageUpdate - this needs `zsyncmake` on the host, and the `.zsync` file
232
+ written next to the AppImage must be uploaded too.
233
+
234
+ ```json
235
+ {
236
+ "name": "demo",
237
+ "version": "1.2.0",
238
+ "nwbuild": {
239
+ "mode": "package",
240
+ "platform": "linux",
241
+ "app": { "name": "Demo" },
242
+ "publish": { "provider": "github", "owner": "nwutils", "repo": "demo" },
243
+ "updateInformation": true
244
+ }
245
+ }
246
+ ```
247
+
248
+ With the CLI, pass `--publish.provider=github --publish.owner=nwutils
249
+ --publish.repo=demo`. See the
250
+ [`@nwutils/packager` docs](https://www.npmjs.com/package/@nwutils/packager) for
251
+ the `generic` provider and more details.
252
+
253
+ #### Windows installer (NSIS)
254
+
255
+ With `platform: "win"`, package mode builds an NSIS installer,
256
+ `<app.name>-<arch>-Setup.exe`, next to `outDir`. It installs for the current
257
+ user without asking for administrator rights, adds an uninstaller to Windows'
258
+ installed apps list, and replaces the previous version on upgrade. It needs the
259
+ NSIS compiler, `makensis`, on the host: `apt install nsis` on Linux,
260
+ `brew install makensis` on MacOS or `choco install nsis` on Windows. Wine isn't
261
+ needed, so the installer can be built on any platform.
262
+
263
+ The installer takes its details from the Windows `app` options:
264
+
265
+ - Version: `app.productVersion`, falling back to `app.version`. Both default to the `package.json` `version`, and packaging stops before building if there is none.
266
+ - Publisher: `app.company`.
267
+ - Copyright: `app.legalCopyright`.
268
+ - Icon: `app.icon`, if it's a `.ico` file. Otherwise the installer uses NSIS' default icon and a warning is logged.
269
+
270
+ Options with no `app` equivalent go in `nsis`:
271
+
272
+ | Name | Type | Default | Description |
273
+ | ----------------- | --------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
274
+ | appId | `string` | Value of `app.name` | Name of the registry key the installation is recorded under. Keep it the same across releases, so upgrades replace the old version. |
275
+ | license | `string` | | Path to a `.txt` or `.rtf` license file the user has to accept. |
276
+ | desktopShortcut | `boolean` | `true` | If true, create a desktop shortcut. |
277
+ | startMenuShortcut | `boolean` | `true` | If true, create a Start Menu shortcut. |
278
+ | makensisPath | `string` | `"makensis"` | Path to the NSIS compiler. |
279
+
280
+ ```javascript
281
+ const installerPath = await nwbuild({
282
+ mode: "package",
283
+ platform: "win",
284
+ app: {
285
+ name: "Demo",
286
+ icon: "./icon.ico",
287
+ company: "ACME",
288
+ },
289
+ nsis: {
290
+ appId: "com.example.demo",
291
+ license: "./LICENSE.txt",
292
+ },
293
+ });
294
+ ```
295
+
296
+ With the CLI, pass `--nsis.appId=com.example.demo --nsis.desktopShortcut=false`.
297
+
207
298
  ## API Reference
208
299
 
209
300
  Options
210
301
 
211
- | Name | Type | Default | Description |
212
- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
213
- | mode | `"get" \| "run" \| "build" \| "package"` | `"build"` | Choose between get, run, build or package mode |
214
- | version | `string \| "latest" \| "stable"` | `"latest"` | Runtime version |
215
- | flavor | `"normal" \| "sdk"` | `"normal"` | Runtime flavor |
216
- | platform | `"linux" \| "osx" \| "win"` | | Host platform |
217
- | arch | `"ia32" \| "x64" \| "arm64"` | | Host architecture |
218
- | downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server. Supports file systems too (for example `file:///home/localghost/nwjs_mirror`) |
219
- | manifestUrl | `"https://nwjs.io/versions.json" \| "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"` | `"https://nwjs.io/versions.json"` | Versions manifest URI, gotten via https or local file |
220
- | cacheDir | `string` | `"./cache"` | Directory to cache NW binaries |
221
- | cache | `boolean` | `true` | If true the existing cache is used. Otherwise it removes and redownloads it. |
222
- | ffmpeg | `boolean` | `false` | If true the chromium ffmpeg is replaced by community version with proprietary codecs. |
223
- | logLevel | `"error" \| "warn" \| "info" \| "debug"` | `"info"` | Specify level of logging. |
224
- | shaSum | `boolean` | `true` | Flag to enable/disable shasum checks. |
225
- | srcDir | `string` | `"./"` | File paths to application code |
226
- | argv | `string[]` | `[]` | Command line arguments to pass to NW executable in run mode. You can also define these in `chromium-args` in NW.js manifest. |
227
- | glob | `boolean` | `true` | If true file globbing is enabled when parsing `srcDir`. |
228
- | outDir | `string` | `"./out"` | Directory to store build artifacts |
229
- | managedManifest | `boolean \| string \| object` | `false` | Managed manifest |
230
- | nodeAddon | `boolean` | `false` | Rebuild Node native addons |
231
- | zip | `boolean \| "zip" \| "tar" \| "tgz"` | `false` | If true, "zip", "tar" or "tgz" the `outDir` directory is compressed. |
232
- | format | `"AppImage" \| "deb" \| "rpm" \| "msix" \| "nsis" \| "dmg"` | `"AppImage"` on Linux | Packaged output format, used in package mode. Only `"AppImage"` is implemented today. |
233
- | app | `LinuxRc \| WinRc \| OsxRc` | Additional options for each platform. (See below.) |
302
+ | Name | Type | Default | Description |
303
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
304
+ | mode | `"get" \| "run" \| "build" \| "package"` | `"build"` | Choose between get, run, build or package mode |
305
+ | version | `string \| "latest" \| "stable"` | `"latest"` | Runtime version |
306
+ | flavor | `"normal" \| "sdk"` | `"normal"` | Runtime flavor |
307
+ | platform | `"linux" \| "osx" \| "win"` | | Host platform |
308
+ | arch | `"ia32" \| "x64" \| "arm64"` | | Host architecture |
309
+ | downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server. Supports file systems too (for example `file:///home/localghost/nwjs_mirror`) |
310
+ | manifestUrl | `"https://nwjs.io/versions.json" \| "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"` | `"https://nwjs.io/versions.json"` | Versions manifest URI, gotten via https or local file |
311
+ | cacheDir | `string` | `"./cache"` | Directory to cache NW binaries |
312
+ | cache | `boolean` | `true` | If true the existing cache is used. Otherwise it removes and redownloads it. |
313
+ | ffmpeg | `boolean` | `false` | If true the chromium ffmpeg is replaced by community version with proprietary codecs. |
314
+ | logLevel | `"error" \| "warn" \| "info" \| "debug"` | `"info"` | Specify level of logging. |
315
+ | shaSum | `boolean` | `true` | Flag to enable/disable shasum checks. |
316
+ | srcDir | `string` | `"./"` | File paths to application code |
317
+ | argv | `string[]` | `[]` | Command line arguments to pass to NW executable in run mode. You can also define these in `chromium-args` in NW.js manifest. |
318
+ | glob | `boolean` | `true` | If true file globbing is enabled when parsing `srcDir`. |
319
+ | outDir | `string` | `"./out"` | Directory to store build artifacts |
320
+ | managedManifest | `boolean \| string \| object` | `false` | Managed manifest |
321
+ | nodeAddon | `boolean` | `false` | Rebuild Node native addons |
322
+ | zip | `boolean \| "zip" \| "tar" \| "tgz"` | `false` | If true, "zip", "tar" or "tgz" the `outDir` directory is compressed. |
323
+ | 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
+ | sign | `boolean` | `false` | If true, embed a GPG signature in the AppImage. Used in package mode. |
325
+ | 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. |
327
+ | updateInformation | `boolean \| string` | | AppImage zsync update information. `true` derives it from `publish`. Used in package mode. |
328
+ | nsis | `object` | | NSIS installer options, used in package mode. See [Windows installer (NSIS)](#windows-installer-nsis). |
329
+ | app | `LinuxRc \| WinRc \| OsxRc` | Additional options for each platform. (See below.) |
234
330
 
235
331
  ### `app` configuration object
236
332
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "4.20.0",
3
+ "version": "4.22.0",
4
4
  "description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -54,16 +54,24 @@
54
54
  "demo:exe:win": "../../tests/fixtures/nw-builder/out/win/Demo.exe",
55
55
  "demo:cli": "nwbuild --mode=build --flavor=sdk --glob=false --cacheDir=./node_modules/nw --logLevel=debug --managedManifest=../../tests/fixtures/nw-builder/app/package.json --outDir=../../tests/fixtures/nw-builder/out/linux --app.name=Demo --app.icon=../../tests/fixtures/nw-builder/app/icon.png ../../tests/fixtures/nw-builder/app"
56
56
  },
57
- "devDependencies": {
58
- "base-volta-off-of-nwjs": "^1.0.5",
59
- "nw": "^0.115.0"
60
- },
61
57
  "dependencies": {
62
- "@nwutils/builder": "^0.1.0",
63
- "@nwutils/getter": "^0.2.5",
64
- "@nwutils/packager": "^0.3.0",
65
- "@nwutils/runner": "^0.2.3",
58
+ "@nwutils/builder": "^0.1.3",
59
+ "@nwutils/getter": "^0.3.1",
60
+ "@nwutils/packager": "^0.6.0",
61
+ "@nwutils/runner": "^0.2.7",
66
62
  "commander": "^15.0.0",
67
63
  "glob": "^13.0.6"
64
+ },
65
+ "devEngines": {
66
+ "runtime": {
67
+ "name": "node",
68
+ "version": "26.7.0",
69
+ "onFail": "warn"
70
+ },
71
+ "packageManager": {
72
+ "name": "npm",
73
+ "version": "12.0.2",
74
+ "onFail": "warn"
75
+ }
68
76
  }
69
77
  }
package/src/cli.js CHANGED
@@ -48,18 +48,36 @@ program
48
48
  .option("--managedManifest <string>", "Managed manifest mode", false)
49
49
  .option("--nodeAddon <boolean>", "Download NW.js Node headers", false)
50
50
  .option("--format <string>", "Packaged output format, used in package mode")
51
+ .option(
52
+ "--sign <boolean>",
53
+ "Sign the AppImage with GPG, used in package mode",
54
+ )
55
+ .option(
56
+ "--signKey <string>",
57
+ "GPG key to sign the AppImage with, used in package mode",
58
+ )
59
+ .option(
60
+ "--updateInformation <string>",
61
+ "AppImage zsync update information, or true to derive it from --publish.*",
62
+ )
51
63
  .allowUnknownOption(true)
52
64
  .allowExcessArguments(true);
53
65
 
54
- // Handle unknown --app.* arguments
66
+ // Handle unknown --app.*, --publish.* and --nsis.* arguments
55
67
  const unknownArgs = program.parse(process.argv).args;
56
68
  /** @type {Record<string, string>} */
57
69
  const appConfig = {};
70
+ /** @type {Record<string, string>} */
71
+ const publishConfig = {};
72
+ /** @type {Record<string, string>} */
73
+ const nsisConfig = {};
74
+ /** @type {Record<string, Record<string, string>>} */
75
+ const configs = { app: appConfig, publish: publishConfig, nsis: nsisConfig };
58
76
  for (const arg of unknownArgs) {
59
- const match = arg.match(/^--app\.([^.=]+)=(.*)$/);
77
+ const match = arg.match(/^--(app|publish|nsis)\.([^.=]+)=(.*)$/);
60
78
  if (match) {
61
- const [, key, value] = match;
62
- appConfig[key] = value;
79
+ const [, group, key, value] = match;
80
+ configs[group][key] = value;
63
81
  }
64
82
  }
65
83
 
@@ -67,7 +85,14 @@ for (const arg of unknownArgs) {
67
85
  const opts = {
68
86
  ...program.opts(),
69
87
  app: appConfig,
70
- srcDir: program.args.find((arg) => !arg.startsWith("--app")),
88
+ publish: Object.keys(publishConfig).length > 0 ? publishConfig : undefined,
89
+ nsis: Object.keys(nsisConfig).length > 0 ? nsisConfig : undefined,
90
+ srcDir: program.args.find(
91
+ (arg) =>
92
+ !arg.startsWith("--app") &&
93
+ !arg.startsWith("--publish") &&
94
+ !arg.startsWith("--nsis"),
95
+ ),
71
96
  cli: true,
72
97
  };
73
98
 
package/src/index.d.ts CHANGED
@@ -42,8 +42,24 @@ export interface Options<P extends SupportedPlatform = SupportedPlatform> {
42
42
  logLevel?: "error" | "warn" | "info" | "debug";
43
43
  /** Managed manifest */
44
44
  managedManifest?: boolean | string | object;
45
- /** Packaged output format, used in package mode. Defaults to `"AppImage"` on Linux. Only `"AppImage"` is implemented today - the others are reserved. */
45
+ /** 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. */
46
46
  format?: "AppImage" | "deb" | "rpm" | "msix" | "nsis" | "dmg";
47
+ /** NSIS installer options, used in package mode. The installer's version, publisher, copyright and `.ico` icon come from `app`. */
48
+ nsis?: NsisOptions;
49
+ }
50
+
51
+ /** NSIS installer options that have no equivalent in `app` */
52
+ export interface NsisOptions {
53
+ /** 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. */
54
+ appId?: string;
55
+ /** Path to a `.txt` or `.rtf` license file the user has to accept. */
56
+ license?: string;
57
+ /** If true, create a desktop shortcut. Defaults to true. */
58
+ desktopShortcut?: boolean;
59
+ /** If true, create a Start Menu shortcut. Defaults to true. */
60
+ startMenuShortcut?: boolean;
61
+ /** Path to the NSIS compiler. Defaults to `makensis` on the `PATH`. */
62
+ makensisPath?: string;
47
63
  }
48
64
 
49
65
  /** Platform-specific application options */
package/src/index.js CHANGED
@@ -33,7 +33,12 @@ import util from "./util.js";
33
33
  * @property {boolean} [nativeAddon = false] Get Node native addons
34
34
  * @property {boolean} [cli=false] If true the CLI is used to parse options. This option is used internally.
35
35
  * @property {string[]} [argv = []] CLI arguments passed to the NW.js process in run mode
36
- * @property {"AppImage" | "deb" | "rpm" | "msix" | "nsis" | "dmg"} [format] Packaged output format, used in package mode. Defaults to `"AppImage"` on Linux. Only `"AppImage"` is implemented today - the others are reserved.
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
+ * @property {boolean} [sign=false] If true, embed a GPG signature in the AppImage, used in package mode.
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`.
40
+ * @property {boolean | string} [updateInformation] AppImage zsync update information, used in package mode. `true` derives it from `publish`.
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`.
37
42
  */
38
43
 
39
44
  /**
@@ -200,15 +205,39 @@ async function nwbuild(options) {
200
205
  resolved.logLevel,
201
206
  `Packaging NW.js application as ${resolved.format}...`,
202
207
  );
203
- const packagePath = await pkg({
204
- format: resolved.format,
205
- appDir: resolved.outDir,
206
- appName: resolved.app.name,
207
- icon: resolved.app.icon,
208
- arch: resolved.arch,
209
- cacheDir: resolved.cacheDir,
210
- cache: resolved.cache,
211
- });
208
+ let packagePath;
209
+ if (resolved.format === "nsis") {
210
+ const nsisOptions = util.nsisOptions(resolved);
211
+ if (resolved.app.icon && nsisOptions.icon === undefined) {
212
+ util.log(
213
+ "warn",
214
+ resolved.logLevel,
215
+ `The installer uses NSIS' default icon, since options.app.icon isn't a .ico file: ${resolved.app.icon}`,
216
+ );
217
+ }
218
+ packagePath = await pkg({
219
+ format: resolved.format,
220
+ appDir: resolved.outDir,
221
+ appName: resolved.app.name,
222
+ arch: resolved.arch,
223
+ ...nsisOptions,
224
+ });
225
+ } else {
226
+ packagePath = await pkg({
227
+ format: resolved.format,
228
+ appDir: resolved.outDir,
229
+ appName: resolved.app.name,
230
+ icon: resolved.app.icon,
231
+ arch: resolved.arch,
232
+ cacheDir: resolved.cacheDir,
233
+ cache: resolved.cache,
234
+ sign: resolved.sign,
235
+ signKey: resolved.signKey,
236
+ version: manifest.json?.version,
237
+ publish: resolved.publish,
238
+ updateInformation: resolved.updateInformation,
239
+ });
240
+ }
212
241
  util.log(
213
242
  "info",
214
243
  resolved.logLevel,
package/src/util.js CHANGED
@@ -109,6 +109,11 @@ import * as GlobModule from "glob";
109
109
  * @property {boolean | string} [shaSum] If true, shasum is enabled
110
110
  * @property {boolean | string} [nativeAddon] Get Node native addons
111
111
  * @property {"AppImage" | "deb" | "rpm" | "msix" | "nsis" | "dmg"} [format] Packaged output format, used in package mode
112
+ * @property {boolean | string} [sign] If true, sign the AppImage, used in package mode
113
+ * @property {string} [signKey] GPG key to sign the AppImage with, used in package mode
114
+ * @property {import("@nwutils/packager").PublishOptions} [publish] Where releases are published, used in package mode
115
+ * @property {boolean | string} [updateInformation] AppImage zsync update information, used in package mode
116
+ * @property {NsisOptions} [nsis] NSIS installer options, used in package mode
112
117
  * @property {string[]} [argv] CLI arguments passed to the NW.js process in run mode
113
118
  * @property {boolean | string} [glob] If true file globbing is enabled when parsing srcDir
114
119
  * @property {string | string[]} [srcDir] File paths to application code
@@ -119,6 +124,54 @@ import * as GlobModule from "glob";
119
124
  * @property {boolean} [cli] If true the CLI is used to parse options
120
125
  */
121
126
 
127
+ /**
128
+ * NSIS installer options that have no equivalent in `options.app`. Values
129
+ * may arrive as strings from the CLI - `parse()` normalizes the booleans.
130
+ * @typedef {object} NsisOptions
131
+ * @property {string} [appId] Name of the registry key the installation is recorded under. Defaults to `app.name`. Keep it the same across releases.
132
+ * @property {string} [license] Path to a `.txt` or `.rtf` license file the user has to accept.
133
+ * @property {boolean | string} [desktopShortcut] If true, create a desktop shortcut. Defaults to true.
134
+ * @property {boolean | string} [startMenuShortcut] If true, create a Start Menu shortcut. Defaults to true.
135
+ * @property {string} [makensisPath] Path to the NSIS compiler. Defaults to `makensis` on the `PATH`.
136
+ */
137
+
138
+ /**
139
+ * Map resolved options to the options `@nwutils/packager`'s `nsis()` takes,
140
+ * besides `appDir`, `appName` and `arch`. Installer metadata comes from the
141
+ * Windows `options.app` values `@nwutils/builder` also writes into the
142
+ * executable, so both agree.
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()`.
145
+ */
146
+ function nsisOptions(options) {
147
+ const app = options.app ?? {};
148
+ const nsis = options.nsis ?? {};
149
+
150
+ const version = app.productVersion ?? app.version;
151
+ if (typeof version !== "string" || version === "") {
152
+ throw new Error(
153
+ 'options.format "nsis" needs the application\'s version. Set "version" in package.json, or options.app.productVersion.',
154
+ );
155
+ }
156
+
157
+ return {
158
+ version,
159
+ /* The installer icon has to be a `.ico` file, but `app.icon` is often the window's `.png` icon. */
160
+ icon:
161
+ typeof app.icon === "string" &&
162
+ path.extname(app.icon).toLowerCase() === ".ico"
163
+ ? app.icon
164
+ : undefined,
165
+ publisher: app.company === "" ? undefined : app.company,
166
+ copyright: app.legalCopyright,
167
+ appId: nsis.appId,
168
+ license: nsis.license,
169
+ desktopShortcut: /** @type {boolean} */ (nsis.desktopShortcut ?? true),
170
+ startMenuShortcut: /** @type {boolean} */ (nsis.startMenuShortcut ?? true),
171
+ makensisPath: nsis.makensisPath,
172
+ };
173
+ }
174
+
122
175
  /**
123
176
  * Get manifest (array of NW release metadata) from URL.
124
177
  * @param {string} manifestUrl Versions manifest URI, https or file path
@@ -351,7 +404,23 @@ export const parse = async (options, pkg) => {
351
404
 
352
405
  if (options.mode === "package") {
353
406
  options.format =
354
- options.format ?? (options.platform === "linux" ? "AppImage" : undefined);
407
+ options.format ??
408
+ (options.platform === "linux"
409
+ ? "AppImage"
410
+ : options.platform === "win"
411
+ ? "nsis"
412
+ : undefined);
413
+ options.sign = str2Bool(options.sign ?? false);
414
+ options.updateInformation = str2Bool(options.updateInformation);
415
+ if (options.format === "nsis") {
416
+ options.nsis = options.nsis ?? {};
417
+ options.nsis.desktopShortcut = str2Bool(
418
+ options.nsis.desktopShortcut ?? true,
419
+ );
420
+ options.nsis.startMenuShortcut = str2Bool(
421
+ options.nsis.startMenuShortcut ?? true,
422
+ );
423
+ }
355
424
  }
356
425
 
357
426
  options.argv = options.argv ?? [];
@@ -632,6 +701,40 @@ export const validate = async (options, releaseInfo) => {
632
701
  `options.format "AppImage" requires options.platform to be "linux". Got ${JSON.stringify(options.platform)}.`,
633
702
  );
634
703
  }
704
+ if (options.format === "nsis") {
705
+ if (options.platform !== "win") {
706
+ throw new Error(
707
+ `options.format "nsis" requires options.platform to be "win". Got ${JSON.stringify(options.platform)}.`,
708
+ );
709
+ }
710
+ const nsis = options.nsis ?? {};
711
+ for (const key of /** @type {const} */ ([
712
+ "appId",
713
+ "license",
714
+ "makensisPath",
715
+ ])) {
716
+ if (
717
+ nsis[key] !== undefined &&
718
+ (typeof nsis[key] !== "string" || nsis[key] === "")
719
+ ) {
720
+ throw new Error(
721
+ `Expected options.nsis.${key} to be a non-empty string. Got ${JSON.stringify(nsis[key])}`,
722
+ );
723
+ }
724
+ }
725
+ for (const key of /** @type {const} */ ([
726
+ "desktopShortcut",
727
+ "startMenuShortcut",
728
+ ])) {
729
+ if (nsis[key] !== undefined && typeof nsis[key] !== "boolean") {
730
+ throw new Error(
731
+ `Expected options.nsis.${key} to be a boolean. Got ${JSON.stringify(nsis[key])}`,
732
+ );
733
+ }
734
+ }
735
+ /* Throws now, before building, if the installer would have no version. */
736
+ nsisOptions(options);
737
+ }
635
738
  }
636
739
 
637
740
  /* By the time validate() runs, parse() has already defaulted options.app to {}. */
@@ -1090,4 +1193,5 @@ export default {
1090
1193
  parse,
1091
1194
  validate,
1092
1195
  log,
1196
+ nsisOptions,
1093
1197
  };