nw-builder 4.0.2 → 4.0.4
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/.github/dependabot.yml +2 -4
- package/.github/workflows/cd.yml +1 -0
- package/.github/workflows/ci.yml +3 -4
- package/README.md +324 -0
- package/package.json +16 -9
- package/src/bld/linuxCfg.js +34 -16
- package/src/bld/osxCfg.js +40 -44
- package/src/bld/package.js +29 -25
- package/src/bld/winCfg.js +42 -14
- package/src/cli.js +9 -6
- package/src/get/download.js +5 -7
- package/src/get/getReleaseInfo.js +4 -0
- package/src/nwbuild.js +172 -71
- package/src/run/develop.js +23 -7
- package/src/run/execute.js +22 -6
- package/src/util/arch.js +9 -0
- package/src/util/arch.test.js +9 -0
- package/src/util/cache.js +17 -0
- package/src/util/cache.test.js +9 -0
- package/src/util/parse.js +70 -0
- package/src/util/parse.test.js +5 -0
- package/src/util/platform.js +18 -0
- package/src/util/platform.test.js +13 -0
- package/src/util/validate.js +30 -0
- package/test/{demo/bld.cjs → e2e/bld.js} +13 -5
- package/test/e2e/nix.js +11 -0
- package/test/{demo → e2e}/nwapp/index.html +0 -0
- package/test/e2e/nwapp/package.json +6 -0
- package/test/e2e/osx.js +11 -0
- package/test/e2e/win.js +11 -0
- package/test/fixture/cacheDir/nw +0 -0
- package/docs/index.md +0 -112
- package/nwbuild.cjs +0 -113
- package/test/demo/nwapp/package.json +0 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getPlatform } from "./platform.js";
|
|
2
|
+
|
|
3
|
+
test("linux platform support", () => {
|
|
4
|
+
expect(getPlatform("linux")).toBe("linux");
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test("macos platform support", () => {
|
|
8
|
+
expect(getPlatform("darwin")).toBe("osx");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("windows platform support", () => {
|
|
12
|
+
expect(getPlatform("win32")).toBe("win");
|
|
13
|
+
});
|
|
@@ -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
|
-
|
|
1
|
+
import { platform } from "node:process";
|
|
2
|
+
import nwbuild from "nw-builder";
|
|
2
3
|
|
|
3
|
-
|
|
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
|
+
}
|
package/test/e2e/nix.js
ADDED
|
File without changes
|
package/test/e2e/osx.js
ADDED
package/test/e2e/win.js
ADDED
|
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 |
|