nw-builder 4.0.2 → 4.0.3

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.
@@ -0,0 +1,30 @@
1
+ import { readdir } from "node:fs/promises";
2
+
3
+ /**
4
+ * Validate options
5
+ *
6
+ * @param {object} options Options
7
+ * @param {object} releaseInfo Version specific NW release info
8
+ * @return {undefined} True if options are valid. False otherwise
9
+ */
10
+ export const validate = async (options, releaseInfo) => {
11
+ if (options.srcDir === "") {
12
+ throw new Error("srcDir is empty");
13
+ }
14
+ if (options.mode !== "run" && options.mode !== "build") {
15
+ throw new Error("Invalid mode value. Expected run or build.");
16
+ }
17
+ if (
18
+ options.platform &&
19
+ options.arch &&
20
+ !releaseInfo.files.includes(`${options.platform}-${options.arch}`)
21
+ ) {
22
+ throw new Error(
23
+ `Platform ${options.platform} and architecture ${options.arch} is not supported. Sorry!`,
24
+ );
25
+ }
26
+ if (options.outDir) {
27
+ await readdir(options.outDir);
28
+ }
29
+ return undefined;
30
+ };
@@ -1,30 +1,38 @@
1
- const { nwbuild } = require("nw-builder");
1
+ import { platform } from "node:process";
2
+ import nwbuild from "nw-builder";
2
3
 
3
- const bld = async () => {
4
+ if (platform === "linux") {
4
5
  await nwbuild({
5
6
  srcDir: "./nwapp",
7
+ mode: "build",
6
8
  version: "0.70.1",
7
9
  flavour: "normal",
8
10
  platform: "linux",
9
11
  arch: "x64",
10
12
  outDir: "./build/nix",
11
13
  });
14
+ }
15
+
16
+ if (platform === "darwin") {
12
17
  await nwbuild({
13
18
  srcDir: "./nwapp",
19
+ mode: "build",
14
20
  version: "0.70.1",
15
21
  flavour: "normal",
16
22
  platform: "osx",
17
23
  arch: "x64",
18
24
  outDir: "./build/osx",
19
25
  });
26
+ }
27
+
28
+ if (platform === "win32") {
20
29
  await nwbuild({
21
30
  srcDir: "./nwapp",
31
+ mode: "build",
22
32
  version: "0.70.1",
23
33
  flavour: "normal",
24
34
  platform: "win",
25
35
  arch: "x64",
26
36
  outDir: "./build/win",
27
37
  });
28
- };
29
-
30
- bld();
38
+ }
@@ -0,0 +1,11 @@
1
+ import nwbuild from "nw-builder";
2
+
3
+ await nwbuild({
4
+ srcDir: "./nwapp/**/*",
5
+ mode: "build",
6
+ version: "0.70.1",
7
+ flavour: "normal",
8
+ platform: "linux",
9
+ arch: "x64",
10
+ outDir: "./build/nix",
11
+ });
File without changes
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "nwdemo",
3
+ "version": "0.0.1",
4
+ "main": "index.html",
5
+ "author": "ABC Corp"
6
+ }
@@ -0,0 +1,11 @@
1
+ import nwbuild from "nw-builder";
2
+
3
+ await nwbuild({
4
+ srcDir: "./nwapp/**/*",
5
+ mode: "build",
6
+ version: "0.70.1",
7
+ flavour: "normal",
8
+ platform: "osx",
9
+ arch: "x64",
10
+ outDir: "./build/osx",
11
+ });
@@ -0,0 +1,11 @@
1
+ import nwbuild from "nw-builder";
2
+
3
+ await nwbuild({
4
+ srcDir: "./nwapp/**/*",
5
+ mode: "build",
6
+ version: "0.70.1",
7
+ flavour: "normal",
8
+ platform: "win",
9
+ arch: "x64",
10
+ outDir: "./build/win",
11
+ });
File without changes
package/docs/index.md DELETED
@@ -1,112 +0,0 @@
1
- # Documentation
2
-
3
- > This assumes you know how to [write an NW.js application](https://nwjs.readthedocs.io/en/latest/For%20Users/Getting%20Started/).
4
-
5
- ## Install
6
-
7
- Install `nw-builder` via `npm` or your preferred Node package manager of choice.
8
-
9
- ```shell
10
- npm i -D nw-builder
11
- ```
12
-
13
- ## Usage
14
-
15
- ### Run your first application
16
-
17
- Module usage
18
-
19
- ```javascript
20
- import { nwbuild } from "nw-builder";
21
-
22
- nwbuild({
23
- srcDir: "./nwapp",
24
- mode: "run",
25
- version: "0.70.1",
26
- flavour: "sdk",
27
- });
28
- ```
29
-
30
- CLI usage
31
-
32
- ```shell
33
- nwbuild ./nwapp --mode=run --version=0.70.1 --flavour=sdk
34
- ```
35
-
36
- package.json usage
37
-
38
- `./nwapp/package.json`
39
-
40
- ```json
41
- {
42
- "name": "nwdemo",
43
- "main": "./index.html",
44
- "nwbuild": {
45
- "srcDir": "./nwapp",
46
- "mode": "run",
47
- "version": "0.70.1",
48
- "flavour": "sdk"
49
- }
50
- }
51
- ```
52
-
53
- ### Build your first application
54
-
55
- Module usage
56
-
57
- ```javascript
58
- import { nwbuild } from "nw-builder";
59
-
60
- nwbuild({
61
- srcDir: "./nwapp",
62
- mode: "run",
63
- version: "0.70.1",
64
- flavour: "normal",
65
- platform: "linux",
66
- arch: "x64",
67
- outDir: "./out",
68
- });
69
- ```
70
-
71
- CLI usage
72
-
73
- ```shell
74
- nwbuild ./nwapp --mode=build --version=0.70.1 --flavour=normal --platform=linux --arch=x64 --outDir=./out
75
- ```
76
-
77
- package.json usage
78
-
79
- `./nwapp/package.json`
80
-
81
- ```json
82
- {
83
- "name": "nwdemo",
84
- "main": "./index.html",
85
- "nwbuild": {
86
- "srcDir": "./nwapp",
87
- "mode": "build",
88
- "version": "0.70.1",
89
- "flavour": "normal",
90
- "platform": "linux",
91
- "arch": "x64",
92
- "outDir": "./out"
93
- }
94
- }
95
- ```
96
-
97
- ## API Reference
98
-
99
- | Name | Type | Default | Description |
100
- | ----------- | --------- | -------------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------- | ---------------------- |
101
- | srcDir | `string | string[]` | | Directory to hold NW app files unless or array of file glob patterns |
102
- | mode | `run | build` | | Run or build application |
103
- | version | `latest | stable | string` | | NW runtime version |
104
- | flavour | `sdk | normal` | | NW runtime build flavour. |
105
- | platform | `linux | osx | win` | | NW supported platforms |
106
- | arch | `ia32 | x64` | | NW supported architectures |
107
- | outDir | `string` | | Directory to store build artifacts |
108
- | cacheDir | `string` | `./cacheDir` | Directory to store NW binaries |
109
- | downloadUrl | `string` | `https://dl.nwjs.io` | URI to download NW binaries from |
110
- | manifestUrl | `string` | `https://nwjs.io/versions` | URI to download manifest from |
111
- | cache | `boolean` | `true` | If `true` the existing cache is used. Otherwise it removes and redownloads it. |
112
- | zip | `boolean` | `false` | If `true` the `outDir` directory is zipped |