nw-builder 4.0.9 → 4.0.10
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 +3 -3
- package/package.json +3 -4
- package/src/bld/package.js +3 -3
- package/src/cli.js +1 -0
- package/src/nwbuild.js +1 -0
- package/src/util/options.js +16 -10
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ nwbuild({
|
|
|
42
42
|
CLI usage
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
|
-
nwbuild ./nwapp --mode=run --version=latest --flavor=sdk
|
|
45
|
+
nwbuild ./nwapp/**/* --mode=run --version=latest --flavor=sdk
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
package.json usage
|
|
@@ -83,7 +83,7 @@ nwbuild({
|
|
|
83
83
|
CLI usage
|
|
84
84
|
|
|
85
85
|
```shell
|
|
86
|
-
nwbuild ./nwapp --mode=build --version=latest --flavor=normal --platform=linux --arch=x64 --outDir=./out
|
|
86
|
+
nwbuild ./nwapp/**/* --mode=build --version=latest --flavor=normal --platform=linux --arch=x64 --outDir=./out
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
package.json usage
|
|
@@ -301,7 +301,7 @@ The final code should look like this.
|
|
|
301
301
|
const { nwbuild } = require("nw-builder");
|
|
302
302
|
|
|
303
303
|
await nwbuild({
|
|
304
|
-
srcDir: "./nwapp",
|
|
304
|
+
srcDir: "./nwapp/**/*",
|
|
305
305
|
mode: "build",
|
|
306
306
|
version: "latest",
|
|
307
307
|
flavor: "normal",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
4
4
|
"description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"./src",
|
|
23
23
|
"./LICENSE"
|
|
24
|
-
|
|
25
24
|
],
|
|
26
25
|
"homepage": "https://github.com/nwutils/nw-builder",
|
|
27
26
|
"repository": {
|
|
@@ -34,8 +33,8 @@
|
|
|
34
33
|
"docs": "jsdoc ./src/nwbuild.js -d docs",
|
|
35
34
|
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
36
35
|
"test:e2e": "cd ./test/e2e && node bld.js && node run.js",
|
|
37
|
-
"demo:cli": "cd ./test/e2e &&
|
|
38
|
-
"demo:nix": "cd
|
|
36
|
+
"demo:cli": "cd ./test/e2e && nwbuild ./nwapp/* ./nwapp/**/* --mode=build --version=latest --flavor=normal --platform=linux --arch=x64 --outDir=./build/cli",
|
|
37
|
+
"demo:nix": "cd test/e2e && node nix.js",
|
|
39
38
|
"demo:osx": "cd ./test/e2e && node osx.js",
|
|
40
39
|
"demo:win": "cd ./test/e2e && node win.js"
|
|
41
40
|
},
|
package/src/bld/package.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { sep } from "node:path";
|
|
1
2
|
import { cp, rm } from "node:fs/promises";
|
|
2
|
-
import { basename } from "node:path";
|
|
3
3
|
|
|
4
4
|
import { log } from "../log.js";
|
|
5
5
|
|
|
@@ -34,13 +34,13 @@ const packager = async (
|
|
|
34
34
|
log.debug(`Copy ${nwDir} files to ${outDir} directory`);
|
|
35
35
|
await cp(nwDir, outDir, { recursive: true });
|
|
36
36
|
|
|
37
|
-
for (
|
|
37
|
+
for (let file of files) {
|
|
38
38
|
log.debug(`Copy ${file} file to ${outDir} directory`);
|
|
39
39
|
await cp(
|
|
40
40
|
file,
|
|
41
41
|
`${outDir}/${
|
|
42
42
|
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw"
|
|
43
|
-
}/${
|
|
43
|
+
}/${file.split(sep).splice(2).join(sep)}`,
|
|
44
44
|
{
|
|
45
45
|
recursive: true,
|
|
46
46
|
},
|
package/src/cli.js
CHANGED
package/src/nwbuild.js
CHANGED
|
@@ -69,6 +69,7 @@ import { log } from "./log.js";
|
|
|
69
69
|
* @property {App} app Multi platform configuration options
|
|
70
70
|
* @property {boolean} [cache=true] If true the existing cache is used. Otherwise it removes and redownloads it.
|
|
71
71
|
* @property {boolean} [zip=false] If true the outDir directory is zipped
|
|
72
|
+
* @property {boolean} [cli=false] If true the CLI is used to glob srcDir and parse other options
|
|
72
73
|
*/
|
|
73
74
|
|
|
74
75
|
/**
|
package/src/util/options.js
CHANGED
|
@@ -16,21 +16,27 @@ export const getOptions = async (opts) => {
|
|
|
16
16
|
let nwPkg;
|
|
17
17
|
const patterns = opts.srcDir.split(" ");
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (basename(content) === "package.json" && nwPkg === undefined) {
|
|
25
|
-
nwPkg = JSON.parse(await readFile(content));
|
|
26
|
-
}
|
|
19
|
+
// If the cli option is not true, then the srcDir glob patterns have not been parsed
|
|
20
|
+
if (opts.cli !== true) {
|
|
21
|
+
for (const pattern of patterns) {
|
|
22
|
+
let contents = await glob(pattern);
|
|
23
|
+
files.push(...contents);
|
|
27
24
|
}
|
|
25
|
+
} else {
|
|
26
|
+
files = [...patterns];
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Try to find the first instance of the package.json
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
if (basename(file) === "package.json" && nwPkg === undefined) {
|
|
32
|
+
nwPkg = JSON.parse(await readFile(file));
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
if (nwPkg === undefined) {
|
|
37
|
+
throw new Error("package.json not found in srcDir file glob patterns.");
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
if (files.length === 0) {
|
|
35
41
|
throw new Error(`The globbing pattern ${opts.srcDir} is invalid.`);
|
|
36
42
|
}
|