nw-builder 4.21.4 → 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 +74 -3
- package/package.json +5 -5
- package/src/cli.js +19 -5
- package/src/index.d.ts +36 -1
- package/src/index.js +36 -16
- package/src/util.js +114 -1
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
|
|
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({
|
|
@@ -250,6 +250,76 @@ With the CLI, pass `--publish.provider=github --publish.owner=nwutils
|
|
|
250
250
|
[`@nwutils/packager` docs](https://www.npmjs.com/package/@nwutils/packager) for
|
|
251
251
|
the `generic` provider and more details.
|
|
252
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
|
+
|
|
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
|
+
|
|
253
323
|
## API Reference
|
|
254
324
|
|
|
255
325
|
Options
|
|
@@ -275,11 +345,12 @@ Options
|
|
|
275
345
|
| managedManifest | `boolean \| string \| object` | `false` | Managed manifest |
|
|
276
346
|
| nodeAddon | `boolean` | `false` | Rebuild Node native addons |
|
|
277
347
|
| zip | `boolean \| "zip" \| "tar" \| "tgz"` | `false` | If true, "zip", "tar" or "tgz" the `outDir` directory is compressed. |
|
|
278
|
-
| format | `"AppImage" \| "deb" \| "rpm" \| "msix" \| "nsis" \| "dmg"` | `"AppImage"` on Linux
|
|
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. |
|
|
279
349
|
| sign | `boolean` | `false` | If true, embed a GPG signature in the AppImage. Used in package mode. |
|
|
280
350
|
| signKey | `string` | | ID of the GPG key to sign with. Requires `sign`. Used in package mode. |
|
|
281
|
-
| publish | `{provider: "github", owner, repo} \| {provider: "generic", url}` | | Where releases are published. Makes the AppImage self updatable with `@nwutils/updater`.
|
|
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. |
|
|
282
352
|
| updateInformation | `boolean \| string` | | AppImage zsync update information. `true` derives it from `publish`. Used in package mode. |
|
|
353
|
+
| nsis | `object` | | NSIS installer options, used in package mode. See [Windows installer (NSIS)](#windows-installer-nsis). |
|
|
283
354
|
| app | `LinuxRc \| WinRc \| OsxRc` | Additional options for each platform. (See below.) |
|
|
284
355
|
|
|
285
356
|
### `app` configuration object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.
|
|
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",
|
|
@@ -55,10 +55,10 @@
|
|
|
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
57
|
"dependencies": {
|
|
58
|
-
"@nwutils/builder": "^0.1.
|
|
59
|
-
"@nwutils/getter": "^0.
|
|
60
|
-
"@nwutils/packager": "^0.
|
|
61
|
-
"@nwutils/runner": "^0.2.
|
|
58
|
+
"@nwutils/builder": "^0.1.3",
|
|
59
|
+
"@nwutils/getter": "^0.3.1",
|
|
60
|
+
"@nwutils/packager": "^0.7.0",
|
|
61
|
+
"@nwutils/runner": "^0.2.7",
|
|
62
62
|
"commander": "^15.0.0",
|
|
63
63
|
"glob": "^13.0.6"
|
|
64
64
|
},
|
package/src/cli.js
CHANGED
|
@@ -63,17 +63,21 @@ program
|
|
|
63
63
|
.allowUnknownOption(true)
|
|
64
64
|
.allowExcessArguments(true);
|
|
65
65
|
|
|
66
|
-
// Handle unknown --app.* and --
|
|
66
|
+
// Handle unknown --app.*, --publish.* and --nsis.* arguments
|
|
67
67
|
const unknownArgs = program.parse(process.argv).args;
|
|
68
68
|
/** @type {Record<string, string>} */
|
|
69
69
|
const appConfig = {};
|
|
70
70
|
/** @type {Record<string, string>} */
|
|
71
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 };
|
|
72
76
|
for (const arg of unknownArgs) {
|
|
73
|
-
const match = arg.match(/^--(app|publish)\.([^.=]+)=(.*)$/);
|
|
77
|
+
const match = arg.match(/^--(app|publish|nsis)\.([^.=]+)=(.*)$/);
|
|
74
78
|
if (match) {
|
|
75
79
|
const [, group, key, value] = match;
|
|
76
|
-
|
|
80
|
+
configs[group][key] = value;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
|
|
@@ -81,9 +85,19 @@ for (const arg of unknownArgs) {
|
|
|
81
85
|
const opts = {
|
|
82
86
|
...program.opts(),
|
|
83
87
|
app: appConfig,
|
|
84
|
-
publish
|
|
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,
|
|
95
|
+
nsis: Object.keys(nsisConfig).length > 0 ? nsisConfig : undefined,
|
|
85
96
|
srcDir: program.args.find(
|
|
86
|
-
(arg) =>
|
|
97
|
+
(arg) =>
|
|
98
|
+
!arg.startsWith("--app") &&
|
|
99
|
+
!arg.startsWith("--publish") &&
|
|
100
|
+
!arg.startsWith("--nsis"),
|
|
87
101
|
),
|
|
88
102
|
cli: true,
|
|
89
103
|
};
|
package/src/index.d.ts
CHANGED
|
@@ -42,8 +42,43 @@ 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"`
|
|
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
|
+
/** Where releases are published, used in package mode. Makes the AppImage or NSIS installation self updatable with `@nwutils/updater`. */
|
|
50
|
+
publish?: PublishOptions;
|
|
51
|
+
}
|
|
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
|
+
|
|
70
|
+
/** NSIS installer options that have no equivalent in `app` */
|
|
71
|
+
export interface NsisOptions {
|
|
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. */
|
|
73
|
+
appId?: string;
|
|
74
|
+
/** Path to a `.txt` or `.rtf` license file the user has to accept. */
|
|
75
|
+
license?: string;
|
|
76
|
+
/** If true, create a desktop shortcut. Defaults to true. */
|
|
77
|
+
desktopShortcut?: boolean;
|
|
78
|
+
/** If true, create a Start Menu shortcut. Defaults to true. */
|
|
79
|
+
startMenuShortcut?: boolean;
|
|
80
|
+
/** Path to the NSIS compiler. Defaults to `makensis` on the `PATH`. */
|
|
81
|
+
makensisPath?: string;
|
|
47
82
|
}
|
|
48
83
|
|
|
49
84
|
/** Platform-specific application options */
|
package/src/index.js
CHANGED
|
@@ -33,11 +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"`
|
|
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
|
+
* @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`.
|
|
41
42
|
*/
|
|
42
43
|
|
|
43
44
|
/**
|
|
@@ -204,20 +205,39 @@ async function nwbuild(options) {
|
|
|
204
205
|
resolved.logLevel,
|
|
205
206
|
`Packaging NW.js application as ${resolved.format}...`,
|
|
206
207
|
);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
+
}
|
|
221
241
|
util.log(
|
|
222
242
|
"info",
|
|
223
243
|
resolved.logLevel,
|
package/src/util.js
CHANGED
|
@@ -113,6 +113,7 @@ import * as GlobModule from "glob";
|
|
|
113
113
|
* @property {string} [signKey] GPG key to sign the AppImage with, used in package mode
|
|
114
114
|
* @property {import("@nwutils/packager").PublishOptions} [publish] Where releases are published, used in package mode
|
|
115
115
|
* @property {boolean | string} [updateInformation] AppImage zsync update information, used in package mode
|
|
116
|
+
* @property {NsisOptions} [nsis] NSIS installer options, used in package mode
|
|
116
117
|
* @property {string[]} [argv] CLI arguments passed to the NW.js process in run mode
|
|
117
118
|
* @property {boolean | string} [glob] If true file globbing is enabled when parsing srcDir
|
|
118
119
|
* @property {string | string[]} [srcDir] File paths to application code
|
|
@@ -123,6 +124,55 @@ import * as GlobModule from "glob";
|
|
|
123
124
|
* @property {boolean} [cli] If true the CLI is used to parse options
|
|
124
125
|
*/
|
|
125
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, publish: import("@nwutils/packager").PublishOptions | 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
|
+
publish: options.publish,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
126
176
|
/**
|
|
127
177
|
* Get manifest (array of NW release metadata) from URL.
|
|
128
178
|
* @param {string} manifestUrl Versions manifest URI, https or file path
|
|
@@ -355,9 +405,23 @@ export const parse = async (options, pkg) => {
|
|
|
355
405
|
|
|
356
406
|
if (options.mode === "package") {
|
|
357
407
|
options.format =
|
|
358
|
-
options.format ??
|
|
408
|
+
options.format ??
|
|
409
|
+
(options.platform === "linux"
|
|
410
|
+
? "AppImage"
|
|
411
|
+
: options.platform === "win"
|
|
412
|
+
? "nsis"
|
|
413
|
+
: undefined);
|
|
359
414
|
options.sign = str2Bool(options.sign ?? false);
|
|
360
415
|
options.updateInformation = str2Bool(options.updateInformation);
|
|
416
|
+
if (options.format === "nsis") {
|
|
417
|
+
options.nsis = options.nsis ?? {};
|
|
418
|
+
options.nsis.desktopShortcut = str2Bool(
|
|
419
|
+
options.nsis.desktopShortcut ?? true,
|
|
420
|
+
);
|
|
421
|
+
options.nsis.startMenuShortcut = str2Bool(
|
|
422
|
+
options.nsis.startMenuShortcut ?? true,
|
|
423
|
+
);
|
|
424
|
+
}
|
|
361
425
|
}
|
|
362
426
|
|
|
363
427
|
options.argv = options.argv ?? [];
|
|
@@ -638,6 +702,54 @@ export const validate = async (options, releaseInfo) => {
|
|
|
638
702
|
`options.format "AppImage" requires options.platform to be "linux". Got ${JSON.stringify(options.platform)}.`,
|
|
639
703
|
);
|
|
640
704
|
}
|
|
705
|
+
if (options.format === "nsis") {
|
|
706
|
+
if (options.platform !== "win") {
|
|
707
|
+
throw new Error(
|
|
708
|
+
`options.format "nsis" requires options.platform to be "win". Got ${JSON.stringify(options.platform)}.`,
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
const nsis = options.nsis ?? {};
|
|
712
|
+
for (const key of /** @type {const} */ ([
|
|
713
|
+
"appId",
|
|
714
|
+
"license",
|
|
715
|
+
"makensisPath",
|
|
716
|
+
])) {
|
|
717
|
+
if (
|
|
718
|
+
nsis[key] !== undefined &&
|
|
719
|
+
(typeof nsis[key] !== "string" || nsis[key] === "")
|
|
720
|
+
) {
|
|
721
|
+
throw new Error(
|
|
722
|
+
`Expected options.nsis.${key} to be a non-empty string. Got ${JSON.stringify(nsis[key])}`,
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
for (const key of /** @type {const} */ ([
|
|
727
|
+
"desktopShortcut",
|
|
728
|
+
"startMenuShortcut",
|
|
729
|
+
])) {
|
|
730
|
+
if (nsis[key] !== undefined && typeof nsis[key] !== "boolean") {
|
|
731
|
+
throw new Error(
|
|
732
|
+
`Expected options.nsis.${key} to be a boolean. Got ${JSON.stringify(nsis[key])}`,
|
|
733
|
+
);
|
|
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
|
+
}
|
|
750
|
+
/* Throws now, before building, if the installer would have no version. */
|
|
751
|
+
nsisOptions(options);
|
|
752
|
+
}
|
|
641
753
|
}
|
|
642
754
|
|
|
643
755
|
/* By the time validate() runs, parse() has already defaulted options.app to {}. */
|
|
@@ -1096,4 +1208,5 @@ export default {
|
|
|
1096
1208
|
parse,
|
|
1097
1209
|
validate,
|
|
1098
1210
|
log,
|
|
1211
|
+
nsisOptions,
|
|
1099
1212
|
};
|