nw-builder 4.0.8 → 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 CHANGED
@@ -32,7 +32,6 @@ Module usage
32
32
  import nwbuild from "nw-builder";
33
33
 
34
34
  nwbuild({
35
- // Globing does not matter since a process is spawned against the nwapp directory
36
35
  srcDir: "./nwapp/**/*",
37
36
  mode: "run",
38
37
  version: "latest",
@@ -43,7 +42,7 @@ nwbuild({
43
42
  CLI usage
44
43
 
45
44
  ```shell
46
- nwbuild ./nwapp --mode=run --version=latest --flavor=sdk
45
+ nwbuild ./nwapp/**/* --mode=run --version=latest --flavor=sdk
47
46
  ```
48
47
 
49
48
  package.json usage
@@ -84,7 +83,7 @@ nwbuild({
84
83
  CLI usage
85
84
 
86
85
  ```shell
87
- 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
88
87
  ```
89
88
 
90
89
  package.json usage
@@ -302,7 +301,7 @@ The final code should look like this.
302
301
  const { nwbuild } = require("nw-builder");
303
302
 
304
303
  await nwbuild({
305
- srcDir: "./nwapp",
304
+ srcDir: "./nwapp/**/*",
306
305
  mode: "build",
307
306
  version: "latest",
308
307
  flavor: "normal",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "4.0.8",
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": {
@@ -29,13 +28,13 @@
29
28
  "url": "https://github.com/nwutils/nw-builder.git"
30
29
  },
31
30
  "scripts": {
32
- "format": "prettier --write \"./**/*.{js,cjs,md}\"",
31
+ "format": "prettier --write \"./**/*.{css,html,js,json,md}\"",
33
32
  "lint": "eslint ./src",
34
33
  "docs": "jsdoc ./src/nwbuild.js -d docs",
35
34
  "test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
36
- "test:e2e": "cd ./test/e2e && node bld.js",
37
- "demo:cli": "cd ./test/e2e && node cli.js",
38
- "demo:nix": "cd ./test/e2e && node nix.js",
35
+ "test:e2e": "cd ./test/e2e && node bld.js && node run.js",
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
  },
@@ -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 (const file of files) {
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
- }/${basename(file)}`,
43
+ }/${file.split(sep).splice(2).join(sep)}`,
44
44
  {
45
45
  recursive: true,
46
46
  },
package/src/cli.js CHANGED
@@ -37,4 +37,5 @@ const cli = yargs(hideBin(process.argv))
37
37
  nwbuild({
38
38
  ...cli,
39
39
  srcDir: cli._.join(" "),
40
+ cli: true,
40
41
  });
@@ -12,20 +12,20 @@ const decompress = (platform, outDir) => {
12
12
  C: `${outDir}`,
13
13
  })
14
14
  .then(() => {
15
- resolve(0);
15
+ resolve();
16
16
  })
17
- .catch(() => {
18
- reject(1);
17
+ .catch((error) => {
18
+ reject(error);
19
19
  });
20
20
  } else {
21
21
  extract(path.resolve(`${outDir}/nw.zip`), {
22
22
  dir: path.resolve(`${outDir}`),
23
23
  })
24
24
  .then(() => {
25
- resolve(0);
25
+ resolve();
26
26
  })
27
- .catch(() => {
28
- reject(1);
27
+ .catch((error) => {
28
+ reject(error);
29
29
  });
30
30
  }
31
31
  });
package/src/get/remove.js CHANGED
@@ -6,7 +6,7 @@ const remove = (platform, outDir) => {
6
6
  `${outDir}/nw.${platform === "linux" ? "tar.gz" : "zip"}`,
7
7
  (error) => {
8
8
  if (error) {
9
- reject(1);
9
+ reject(error);
10
10
  }
11
11
  },
12
12
  );
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
  /**
@@ -158,7 +159,7 @@ const nwbuild = async (options) => {
158
159
  }
159
160
  } catch (error) {
160
161
  log.error(error);
161
- return error;
162
+ throw error;
162
163
  }
163
164
  };
164
165
 
@@ -20,6 +20,15 @@ const execute = (srcDir, nwPath, argv) => {
20
20
  windowsHide: true,
21
21
  });
22
22
 
23
+ nwProcess.on("nw_app_running", () => {
24
+ log.debug("Kill NW process after confirming that it runs in CI.");
25
+ nwProcess.kill("SIGKILL");
26
+ });
27
+
28
+ if (process.env.NODE_ENV !== "production") {
29
+ nwProcess.emit("nw_app_running");
30
+ }
31
+
23
32
  nwProcess.on("close", () => {
24
33
  resolve();
25
34
  });
@@ -16,21 +16,27 @@ export const getOptions = async (opts) => {
16
16
  let nwPkg;
17
17
  const patterns = opts.srcDir.split(" ");
18
18
 
19
- for (const pattern of patterns) {
20
- let contents = await glob(pattern);
21
- files.push(...contents);
22
- // Try to find the first instance of the package.json
23
- for (const content of contents) {
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
- if (nwPkg === undefined) {
30
- throw new Error("package.json not found in srcDir file glob patterns.");
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
  }