nw-builder 3.8.4 → 3.8.6

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.
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.8.6] - 2022-09-22
11
+
12
+ - Fix mac and windows build
13
+
14
+ ## [3.8.5] - 2022-09-20
15
+
16
+ ### Added
17
+
18
+ - `nwbuild` function which accidently got removed.
19
+
20
+ ### Changed
21
+
22
+ - Update usage docs for `nwbuild`
23
+
10
24
  ## [3.8.4] - 2022-09-20
11
25
 
12
26
  ### Changed
package/bin/nwbuild.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const yargs = require("yargs/yargs");
4
4
  const { hideBin } = require("yargs/helpers");
5
5
 
6
- const NwBuilder = require("../lib/index.cjs");
6
+ const { nwbuild } = require("../lib/index.cjs");
7
7
  const { Options, detectCurrentPlatform } = require("../dist/index.cjs");
8
8
 
9
9
  const cli = yargs(hideBin(process.argv))
@@ -139,14 +139,8 @@ const cli = yargs(hideBin(process.argv))
139
139
  })
140
140
  .parse();
141
141
 
142
- const nw = new NwBuilder({
142
+ nwbuild({
143
143
  ...cli,
144
144
  currentPlatform: detectCurrentPlatform(process),
145
145
  files: cli._,
146
146
  });
147
-
148
- if (cli.mode === "build") {
149
- nw.build();
150
- } else {
151
- nw.run();
152
- }
@@ -34,9 +34,29 @@ This should give an error:
34
34
  [ ERROR ] package.json not found
35
35
  ```
36
36
 
37
- ## Write your first application:
37
+ ## Write your first NW.js application
38
38
 
39
- To learn how to write your NW.js application, follow the steps given [here](https://ayushmxn.github.io/nw-repro/getting-started#write-your-first-nwjs-application).
39
+ Create a folder such as `nw` with a `package.json` explicitly for your NW app. This keeps your Node application config and NW application config seperate. The manifest should at the least have a `name` and `main` property. `main` points to the entry point of your NW.js application. This can be an HTML or JavaScript file.
40
+
41
+ ```json
42
+ "name":"nw-demo"
43
+ "version":"0.1.0"
44
+ "main":"./index.html"
45
+ ```
46
+
47
+ Here's an example on how to use a JavaScript file as the entry point:
48
+
49
+ ```json
50
+ "name":"nw-demo"
51
+ "version":"0.1.0"
52
+ "main":"./main.js"
53
+ ```
54
+
55
+ ```javascript
56
+ nw.Window.open("./index.html", {}, () => {});
57
+ ```
58
+
59
+ More information can be found in the [API reference](http://docs.nwjs.io/en/latest/References/App/)
40
60
 
41
61
  ## Run your first application
42
62
 
@@ -52,11 +72,9 @@ Module usage:
52
72
  const { nwbuild } = require("nw-builder");
53
73
 
54
74
  nwbuild({
55
- files: "./path/to/nw/app"
56
- })
57
- .then(() => { ... })
58
- .catch(() => { ... })
59
- .finally(() => { ... })
75
+ files: "./path/to/nw/app",
76
+ mode: "run",
77
+ });
60
78
  ```
61
79
 
62
80
  This is the minimum arguments required to run a NW.js application. It detects your current platform, downloads the required NW binary and runs it.
@@ -75,17 +93,16 @@ Module usage:
75
93
  const { nwbuild } = require("nw-builder");
76
94
 
77
95
  nwbuild({
78
- files: "./path/to/nw/app/dir/**/*.*"
79
- mode: "build"
80
- })
81
- .then(() => { ... })
82
- .catch(() => { ... })
83
- .finally(() => { ... })
96
+ files: "./path/to/nw/app/dir/**/*.*",
97
+ flavor: "normal",
98
+ platforms: ["win32", "linux64"],
99
+ mode: "build",
100
+ });
84
101
  ```
85
102
 
86
103
  This is the minimum arguments required to build a NW.js application. It detects your current platform, downloads the required NW binary and builds for the current platform.
87
104
 
88
- You can learn more about the configuration options in the [API reference](./api).
105
+ You can learn more about the configuration options in the [API reference](http://docs.nwjs.io/en/latest/References/App/).
89
106
 
90
107
  ## Tips
91
108
 
@@ -111,7 +128,7 @@ However this may not make sense if you have multiple scripts with multiple optio
111
128
  }
112
129
  ```
113
130
 
114
- You can even define your options in your project's `package.json` under the `nwbuild` property. This is ideal if you only have one NW.js run or build process. Note that the `package.json` options override the CLI and module.
131
+ You can even define your options in your project's `package.json` under the `nwbuild` property. This is ideal if you only have one NW.js run or build process. Note that the `package.json` options override the CLI and module options.
115
132
 
116
133
  `run.js`
117
134
 
package/lib/index.cjs CHANGED
@@ -1035,4 +1035,21 @@ NwBuilder.prototype.preparePlatformFiles = function (
1035
1035
  return true;
1036
1036
  };
1037
1037
 
1038
+ const nwbuild = (options) => {
1039
+ let nw = new NwBuilder(options);
1040
+
1041
+ if (options.mode === "build") {
1042
+ nw.build();
1043
+ return 0;
1044
+ } if (options.mode === "run") {
1045
+ nw.run();
1046
+ return 0;
1047
+ } else {
1048
+ console.error("[ WARN ] Invalid mode option.");
1049
+ return 1;
1050
+ }
1051
+ };
1052
+
1038
1053
  module.exports = NwBuilder;
1054
+ exports = module.exports;
1055
+ exports.nwbuild = nwbuild;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "3.8.4",
3
+ "version": "3.8.6",
4
4
  "description": "Build NW.js desktop applications for Mac, Windows and Linux.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -22,7 +22,7 @@
22
22
  "test": "npm run test:unit && tape './test/*.cjs'",
23
23
  "test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
24
24
  "demo": "cd ./test/demo && npm run start",
25
- "demo:cli": "nwbuild ./** --mode=build --platforms=linux32, linux64 --version=0.67.1",
25
+ "demo:cli": "nwbuild ./** --mode=build --platforms=linux32,linux64 --version=0.67.1",
26
26
  "build": "esbuild src/index.js --bundle --minify --platform=node --outfile=./dist/index.cjs"
27
27
  },
28
28
  "devDependencies": {
@@ -45,7 +45,7 @@
45
45
  "graceful-fs-extra": "^2.0.0",
46
46
  "inherits": "^2.0.4",
47
47
  "lodash": "^4.17.21",
48
- "nw-install": "^0.3.3",
48
+ "nw-install": "^0.3.4",
49
49
  "plist": "^3.0.5",
50
50
  "progress": "^2.0.3",
51
51
  "rcedit": "^3.0.1",
@@ -1,16 +1,8 @@
1
- const NwBuilder = require("../../lib/index.cjs");
1
+ const { nwbuild } = require("../../lib/index.cjs");
2
2
 
3
- const nw = new NwBuilder({
3
+ nwbuild({
4
4
  files: "./**",
5
5
  version: "0.67.1",
6
6
  platforms: ["linux64"],
7
+ mode: "build",
7
8
  });
8
-
9
- // Replace `build` with `run` to run the application instead
10
- nw.build()
11
- .then((msg) => {
12
- console.log(msg);
13
- })
14
- .catch((error) => {
15
- console.log(error);
16
- });