nw-builder 4.11.4 → 4.11.5
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 +6 -6
- package/package.json +3 -3
- package/src/cli.js +18 -17
- package/src/util.js +24 -6
package/README.md
CHANGED
|
@@ -5,15 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and Linux.
|
|
7
7
|
|
|
8
|
-
For version 3, please go to the [corresponding branch](https://github.com/nwutils/nw-builder/tree/v3).
|
|
9
|
-
|
|
10
8
|
## Major Features
|
|
11
9
|
|
|
12
10
|
- Get, run or build applications.
|
|
13
11
|
- Integrate [FFmpeg community builds](https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt)
|
|
14
12
|
- Configure executable fields and icons
|
|
15
13
|
- Downloading from mirrors
|
|
16
|
-
- Node Native Addon support
|
|
14
|
+
- Node Native Addon support (partial)
|
|
17
15
|
|
|
18
16
|
## Table of Contents
|
|
19
17
|
|
|
@@ -30,19 +28,19 @@ For version 3, please go to the [corresponding branch](https://github.com/nwutil
|
|
|
30
28
|
## Install
|
|
31
29
|
|
|
32
30
|
```shell
|
|
33
|
-
npm i -D nw
|
|
31
|
+
npm i -D nw-builder
|
|
34
32
|
```
|
|
35
33
|
|
|
36
34
|
Every NW.js release includes a modified Node.js binary at a specific version. It is recommended to [install](https://nodejs.org/en/download/package-manager) exactly that version on the host system. Not doing so may download ABI incompatible Node modules. Consult the NW.js [versions manifest](https://nwjs.io/versions) for what Node.js version to install. It is recommended to use a Node version manager (such as [volta](https://volta.sh), n, nvm, or nvm-windows) to be able to easily install and switch between Node versions.
|
|
37
35
|
|
|
38
36
|
## Usage
|
|
39
37
|
|
|
40
|
-
This package can be used via a command line interface, be imported as a JavaScript module, or configured via the Node manifest as a JSON object.
|
|
38
|
+
This package can be used via a command line interface, be imported as a JavaScript module, or configured via the Node manifest as a JSON object. If options are defined in Node manifest, then they will be used over options defined in CLI or JavaScript API.
|
|
41
39
|
|
|
42
40
|
CLI interface:
|
|
43
41
|
|
|
44
42
|
```shell
|
|
45
|
-
nwbuild --mode=build --glob=false --flavor=sdk --cacheDir=./node_modules/nw
|
|
43
|
+
nwbuild --mode=build --glob=false --flavor=sdk --cacheDir=./node_modules/nw /path/to/project
|
|
46
44
|
```
|
|
47
45
|
|
|
48
46
|
ESM import:
|
|
@@ -68,6 +66,7 @@ nwbuild({
|
|
|
68
66
|
glob: false,
|
|
69
67
|
flavor: "sdk",
|
|
70
68
|
cacheDir: "./node_modules/nw",
|
|
69
|
+
srcDir: "/path/to/project",
|
|
71
70
|
});
|
|
72
71
|
```
|
|
73
72
|
|
|
@@ -80,6 +79,7 @@ Node manifest usage:
|
|
|
80
79
|
"glob": false,
|
|
81
80
|
"flavor": "sdk",
|
|
82
81
|
"cacheDir": "./node_modules/nw",
|
|
82
|
+
"srcDir": "/path/to/project"
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.5",
|
|
4
4
|
"description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"test:cov": "vitest --coverage.enabled true",
|
|
49
49
|
"demo:bld": "node ./tests/fixtures/demo.js",
|
|
50
50
|
"demo:exe": "./tests/fixtures/out/nwapp.app/Contents/MacOS/nwapp",
|
|
51
|
-
"demo:cli": "nwbuild --mode
|
|
51
|
+
"demo:cli": "nwbuild --mode=run --version=0.92.0 --flavor=sdk --glob=false --cacheDir=./node_modules/nw ./tests/fixtures/app"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@eslint/js": "^9.12.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"eslint": "^9.12.0",
|
|
58
58
|
"eslint-plugin-jsdoc": "^50.3.2",
|
|
59
59
|
"globals": "^15.11.0",
|
|
60
|
-
"nw": "^0.
|
|
60
|
+
"nw": "^0.93.0",
|
|
61
61
|
"selenium-webdriver": "^4.25.0",
|
|
62
62
|
"vitest": "^2.0.4"
|
|
63
63
|
},
|
package/src/cli.js
CHANGED
|
@@ -5,23 +5,24 @@ import { program } from 'commander';
|
|
|
5
5
|
import nwbuild from './index.js';
|
|
6
6
|
|
|
7
7
|
program
|
|
8
|
-
.
|
|
9
|
-
.option('--
|
|
10
|
-
.option('--
|
|
11
|
-
.option('--
|
|
12
|
-
.option('--
|
|
13
|
-
.option('--
|
|
14
|
-
.option('--
|
|
15
|
-
.option('--
|
|
16
|
-
.option('--
|
|
17
|
-
.option('--
|
|
18
|
-
.option('--
|
|
19
|
-
.option('--
|
|
20
|
-
.option('--
|
|
21
|
-
.option('--
|
|
22
|
-
.option('--
|
|
23
|
-
.option('--
|
|
24
|
-
.option('--
|
|
8
|
+
.argument('<string>', 'File path(s) to project')
|
|
9
|
+
.option('--mode <string>', 'get, run or build mode', 'build')
|
|
10
|
+
.option('--version <string>', 'NW.js version', 'latest')
|
|
11
|
+
.option('--flavor <string>', 'NW.js build flavor', 'normal')
|
|
12
|
+
.option('--platform <string>', 'NW.js supported platform')
|
|
13
|
+
.option('--arch <string>', 'NW.js supported architecture')
|
|
14
|
+
.option('--downloadUrl <string>', 'NW.js download server')
|
|
15
|
+
.option('--manifestUrl <string>', 'NW.js version info')
|
|
16
|
+
.option('--cacheDir <string>', 'Cache NW.js binaries')
|
|
17
|
+
.option('--outDir <string>', 'NW.js build artifacts')
|
|
18
|
+
.option('--app <object>', 'Platform specific app metadata. Refer to docs for more info')
|
|
19
|
+
.option('--cache <boolean>', 'Flag to enable/disable caching', true)
|
|
20
|
+
.option('--ffmpeg <boolean>', 'Flag to enable/disable downloading community ffmpeg', false)
|
|
21
|
+
.option('--glob <boolean>', 'Flag to enable/disable globbing', true)
|
|
22
|
+
.option('--logLevel <string>', 'Specify log level')
|
|
23
|
+
.option('--zip <string>', 'Flag to enable/disable compression', false)
|
|
24
|
+
.option('--managedManifest <string>', 'Managed manifest mode', false)
|
|
25
|
+
.option('--nodeAddon <boolean>', 'Download NW.js Node headers', false);
|
|
25
26
|
|
|
26
27
|
program.parse();
|
|
27
28
|
|
package/src/util.js
CHANGED
|
@@ -161,6 +161,24 @@ async function getNodeManifest({
|
|
|
161
161
|
return manifest;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Function to convert `'true'` and `'false'` into `true` and `false`.
|
|
166
|
+
* `commander` does not do the conversion automatically.
|
|
167
|
+
* @param {any} option - a boolean type option
|
|
168
|
+
* @returns {any} Usually `undefined`, `true` or `false`. if not then it is validated later on.
|
|
169
|
+
*/
|
|
170
|
+
function str2Bool (option) {
|
|
171
|
+
if (typeof option === 'string') {
|
|
172
|
+
if (option === 'true') {
|
|
173
|
+
return true;
|
|
174
|
+
} else if (option === 'false') {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
return option;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
164
182
|
/**
|
|
165
183
|
* Parse options.
|
|
166
184
|
* @param {import("../../index.js").Options} options Options
|
|
@@ -178,8 +196,8 @@ export const parse = async (options, pkg) => {
|
|
|
178
196
|
options.downloadUrl = options.downloadUrl ?? 'https://dl.nwjs.io';
|
|
179
197
|
options.manifestUrl = options.manifestUrl ?? 'https://nwjs.io/versions';
|
|
180
198
|
options.cacheDir = options.cacheDir ?? './cache';
|
|
181
|
-
options.cache = options.cache ?? true;
|
|
182
|
-
options.ffmpeg = options.ffmpeg ?? false;
|
|
199
|
+
options.cache = str2Bool(options.cache ?? true);
|
|
200
|
+
options.ffmpeg = str2Bool(options.ffmpeg ?? false);
|
|
183
201
|
options.logLevel = options.logLevel ?? 'info';
|
|
184
202
|
|
|
185
203
|
if (options.mode === 'get') {
|
|
@@ -187,7 +205,7 @@ export const parse = async (options, pkg) => {
|
|
|
187
205
|
}
|
|
188
206
|
|
|
189
207
|
options.argv = options.argv ?? [];
|
|
190
|
-
options.glob = options.glob ?? true;
|
|
208
|
+
options.glob = str2Bool(options.glob) ?? true;
|
|
191
209
|
options.srcDir = options.srcDir ?? (options.glob ? './*' : '.');
|
|
192
210
|
|
|
193
211
|
if (options.mode === 'run') {
|
|
@@ -195,10 +213,10 @@ export const parse = async (options, pkg) => {
|
|
|
195
213
|
}
|
|
196
214
|
|
|
197
215
|
options.outDir = path.resolve(options.outDir ?? './out');
|
|
198
|
-
options.zip = options.zip ?? false;
|
|
216
|
+
options.zip = str2Bool(options.zip) ?? false;
|
|
199
217
|
|
|
200
|
-
options.managedManifest = options.managedManifest ?? false;
|
|
201
|
-
options.nativeAddon = options.nativeAddon ?? false;
|
|
218
|
+
options.managedManifest = str2Bool(options.managedManifest) ?? false;
|
|
219
|
+
options.nativeAddon = str2Bool(options.nativeAddon) ?? false;
|
|
202
220
|
|
|
203
221
|
options.app = options.app ?? {};
|
|
204
222
|
options.app.name = options.app.name ?? pkg.name;
|