nw-builder 3.7.4 → 3.8.2
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/CHANGELOG.md +18 -0
- package/.github/dependabot.yml +17 -0
- package/.github/workflows/cd.yml +2 -7
- package/.github/workflows/ci.yml +8 -13
- package/README.md +34 -59
- package/bin/nwbuild.cjs +140 -96
- package/dist/index.cjs +6 -1
- package/lib/index.cjs +81 -48
- package/lib/utils.cjs +1 -1
- package/package.json +42 -39
- package/src/constants/Options.js +33 -0
- package/src/index.js +17 -2
- package/src/utilities/checkPkgOptions.js +32 -0
- package/src/utilities/detectCurrentPlatform.js +1 -1
- package/src/utilities/parseOptions.js +10 -0
- package/test/demo/index.cjs +2 -11
- package/test/nwBuilder.cjs +64 -64
- package/test/unit/checkCache.test.js +1 -2
- package/test/unit/detectCurrentPlatform.test.js +2 -2
- package/test/utils.cjs +10 -8
- package/test/versions.cjs +9 -3
- package/src/constants/index.js +0 -7
- package/src/utilities/index.js +0 -4
package/.github/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.8.1] - 2022-07-18
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Fix regex to match `package.json` _files_ only
|
|
15
|
+
|
|
16
|
+
## [3.8.0] - 2022-07-11
|
|
17
|
+
|
|
18
|
+
## Added
|
|
19
|
+
|
|
20
|
+
- `mode` option which defaults to run
|
|
21
|
+
- `nwbuild` function
|
|
22
|
+
- `quiet` option to documentation
|
|
23
|
+
|
|
24
|
+
## Changed
|
|
25
|
+
|
|
26
|
+
- CLI options by matching them to the API
|
|
27
|
+
|
|
10
28
|
## [3.7.4] - 2022-06-06
|
|
11
29
|
|
|
12
30
|
## Removed
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
day: "friday"
|
|
13
|
+
- package-ecosystem: "github-actions" # See documentation for possible values
|
|
14
|
+
directory: ".github/" # Location of package manifests
|
|
15
|
+
schedule:
|
|
16
|
+
interval: "weekly"
|
|
17
|
+
day: "friday"
|
package/.github/workflows/cd.yml
CHANGED
|
@@ -9,16 +9,11 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
steps:
|
|
11
11
|
- uses: actions/checkout@v3
|
|
12
|
-
- uses:
|
|
13
|
-
with:
|
|
14
|
-
version: 7.1.0
|
|
15
|
-
run_install: true
|
|
16
|
-
|
|
17
|
-
- uses: actions/setup-node@v2
|
|
12
|
+
- uses: actions/setup-node@v3
|
|
18
13
|
with:
|
|
19
14
|
node-version: "16"
|
|
20
15
|
|
|
21
|
-
- run:
|
|
16
|
+
- run: npm ci
|
|
22
17
|
- uses: JS-DevTools/npm-publish@v1
|
|
23
18
|
with:
|
|
24
19
|
token: ${{ secrets.NPM_TOKEN }}
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -12,20 +12,15 @@ jobs:
|
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
14
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
15
|
-
node: [14, 16, 18]
|
|
15
|
+
node-version: [14, 16, 18]
|
|
16
16
|
runs-on: ${{ matrix.os }}
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v3
|
|
19
|
-
- uses:
|
|
19
|
+
- uses: volta-cli/action@v1
|
|
20
20
|
with:
|
|
21
|
-
version:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- run: pnpm install
|
|
29
|
-
- run: pnpm format
|
|
30
|
-
- run: pnpm lint
|
|
31
|
-
- run: pnpm test
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
npm-version: '8.5.0'
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm run format
|
|
25
|
+
- run: npm run lint
|
|
26
|
+
- run: npm run test
|
package/README.md
CHANGED
|
@@ -42,68 +42,48 @@ pnpm add nw-builder
|
|
|
42
42
|
### CLI
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
|
-
|
|
46
|
-
nwbuild [options] [path] [-- <args>]
|
|
47
|
-
|
|
48
|
-
Options:
|
|
49
|
-
-p, --platforms Platforms to build, comma-sperated, can be:
|
|
50
|
-
win32, win64, osx32, osx64, linux32, linux64 or
|
|
51
|
-
win, osx, linux [default: <Current OS>]
|
|
52
|
-
-v, --version The nw version, eg. 0.64.1 [default: "latest"]
|
|
53
|
-
-r, --run Runs NW.js for the current platform [default: false]
|
|
54
|
-
-o, --buildDir The build folder [default: "./build"]
|
|
55
|
-
-f, --forceDownload Force download of NW.js [default: false]
|
|
56
|
-
--cacheDir The cache folder
|
|
57
|
-
--quiet Disables logging [default: false]
|
|
58
|
-
-- <args> Pass custom arguments to the NW.js instance
|
|
59
|
-
(-r, --run mode only)
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
To run NW.js in dev mode:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
nwbuild -r path/to/app -- <args>
|
|
45
|
+
nwbuild ./path/to/app
|
|
66
46
|
```
|
|
67
47
|
|
|
68
48
|
### Module
|
|
69
49
|
|
|
70
50
|
```js
|
|
71
|
-
|
|
72
|
-
var nw = new NwBuilder({
|
|
73
|
-
files: './path/to/nwfiles/**/**', // use the glob format
|
|
74
|
-
platforms: ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
|
|
75
|
-
version: 'latest',
|
|
76
|
-
argv: ['<nwjs_arg>', ... ] // see nwjs docs for possible <nwjs_arg> values
|
|
77
|
-
});
|
|
51
|
+
const { nwbuild } = require("nw-builder");
|
|
78
52
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
nw.build().then(function () {
|
|
83
|
-
console.log('all done!');
|
|
84
|
-
}).catch(function (error) {
|
|
85
|
-
console.error(error);
|
|
53
|
+
nwbuild({
|
|
54
|
+
files: "./path/to/app",
|
|
55
|
+
platforms: ["linux64", "win32"],
|
|
86
56
|
});
|
|
87
57
|
```
|
|
88
58
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```js
|
|
92
|
-
nw.run()
|
|
93
|
-
.then(function () {
|
|
94
|
-
console.log("all done!");
|
|
95
|
-
})
|
|
96
|
-
.catch(function (error) {
|
|
97
|
-
console.error(error);
|
|
98
|
-
});
|
|
99
|
-
```
|
|
59
|
+
> If no `mode` option is defined, it defaults to `run`. If no `platforms` option is defined, it defaults to the current platform.
|
|
100
60
|
|
|
101
61
|
## API Reference
|
|
102
62
|
|
|
103
63
|
> Stay up to date via the [Changelog](https://github.com/nwjs-community/nw-builder/blob/master/.github/CHANGELOG.md).
|
|
104
64
|
|
|
65
|
+
### Methods
|
|
66
|
+
|
|
67
|
+
#### nwbuild(options, callbacks)
|
|
68
|
+
|
|
69
|
+
The function that setups up, runs and builds your NW.js applications. The `callbacks` are for the `run` and `build` function that run inside the `nwbuild` function. The callbacks `callback[0]`, `callback[1]`, `callback[2]` correspond to the `.then`, `.catch` and `.finally` functions of the `run` or `build` promise.
|
|
70
|
+
|
|
105
71
|
### Options
|
|
106
72
|
|
|
73
|
+
#### options.mode
|
|
74
|
+
|
|
75
|
+
Type: `run` | `build`
|
|
76
|
+
Default value: `run`
|
|
77
|
+
|
|
78
|
+
Specify if you want to run or build your app.
|
|
79
|
+
|
|
80
|
+
#### options.quiet
|
|
81
|
+
|
|
82
|
+
Type: `String`
|
|
83
|
+
Default value: `info`
|
|
84
|
+
|
|
85
|
+
Choose your level of logging between error, warn, info, debug and off.
|
|
86
|
+
|
|
107
87
|
#### options.files _Required_
|
|
108
88
|
|
|
109
89
|
Type: `String`
|
|
@@ -144,7 +124,7 @@ Be aware that the osx32 version can only be built with legacy version of nwjs. S
|
|
|
144
124
|
Type: `String`
|
|
145
125
|
Default value: `false`
|
|
146
126
|
|
|
147
|
-
The Name of your NW.js app. If this value is set to null, it will autodetect the `name` from your
|
|
127
|
+
The Name of your NW.js app. If this value is set to null, it will autodetect the `name` from your project's package.json. This will be used to generate a plist file for mac.
|
|
148
128
|
|
|
149
129
|
#### options.appVersion
|
|
150
130
|
|
|
@@ -361,18 +341,13 @@ This project was created by [Steffen Müller](https://github.com/steffenmllr) an
|
|
|
361
341
|
### Getting Started
|
|
362
342
|
|
|
363
343
|
1. Pick and install a Node version manager
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
1.
|
|
369
|
-
1.
|
|
370
|
-
1. `
|
|
371
|
-
1. `pnpm install`
|
|
372
|
-
* If you haven't used `pnpm` before, [here is a cheatsheet](https://dev.to/equiman/npm-vs-yarn-vs-pnpm-commands-cheatsheet-3el8)
|
|
373
|
-
1. `pnpm demo` to test your changes at first glance
|
|
374
|
-
1. `pnpm test` to run unit tests
|
|
375
|
-
1. Don't forget to run `pnpm format && pnpm lint` before commiting your changes
|
|
344
|
+
- Linux/OSX - [nvm](https://github.com/nvm-sh/nvm)
|
|
345
|
+
- Win 7+/Linux/OSX - [volta](https://volta.sh)
|
|
346
|
+
1. Use your version manager to install Node 14.19 or above
|
|
347
|
+
1. Run `npm install`
|
|
348
|
+
1. `npm run demo` to test your changes at first glance
|
|
349
|
+
1. `npm t` to run unit tests
|
|
350
|
+
1. Don't forget to run `npm run format && npm run lint` before commiting your changes
|
|
376
351
|
|
|
377
352
|
### General Guidelines
|
|
378
353
|
|
package/bin/nwbuild.cjs
CHANGED
|
@@ -1,102 +1,146 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const NwBuilder = require("../lib/index.cjs");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const { detectCurrentPlatform } = require("../dist/index.cjs");
|
|
5
2
|
|
|
6
|
-
const
|
|
3
|
+
const yargs = require("yargs/yargs");
|
|
4
|
+
const { hideBin } = require("yargs/helpers");
|
|
7
5
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
.usage("Usage:\n $0 [options] [path] [-- <args>]")
|
|
11
|
-
|
|
12
|
-
.alias("p", "platforms")
|
|
13
|
-
.default("p", currentPlatform)
|
|
14
|
-
.describe(
|
|
15
|
-
"p",
|
|
16
|
-
"Platforms to build, comma-sperated, can be: \n win32, win64, osx32, osx64, linux32, linux64 or \nwin, osx, linux",
|
|
17
|
-
)
|
|
6
|
+
const { nwbuild } = require("../lib/index.cjs");
|
|
7
|
+
const { Options, detectCurrentPlatform } = require("../dist/index.cjs");
|
|
18
8
|
|
|
9
|
+
const cli = yargs(hideBin(process.argv))
|
|
19
10
|
.version(false)
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
11
|
+
.command("[file(glob)] [options]")
|
|
12
|
+
.option("mode", {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "Choose between run and build mode",
|
|
15
|
+
default: Options["mode"],
|
|
16
|
+
})
|
|
17
|
+
.option("quiet", {
|
|
18
|
+
type: "string",
|
|
19
|
+
description:
|
|
20
|
+
"Choose your level of logging between error, warn, info, debug and off",
|
|
21
|
+
default: Options["quiet"],
|
|
22
|
+
})
|
|
23
|
+
.option("version", {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Version of NW.js you want to use.",
|
|
26
|
+
group: "Run API",
|
|
27
|
+
default: Options["version"],
|
|
28
|
+
})
|
|
29
|
+
.option("flavor", {
|
|
30
|
+
type: "string",
|
|
31
|
+
description:
|
|
32
|
+
"sdk is recommended for development and normal is recommended for production.",
|
|
33
|
+
group: "Run API",
|
|
34
|
+
default: Options["flavor"],
|
|
35
|
+
})
|
|
36
|
+
.option("cacheDir", {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Path to NW.js cache",
|
|
39
|
+
group: "Run API",
|
|
40
|
+
default: Options["cacheDir"],
|
|
41
|
+
})
|
|
42
|
+
.option("platforms", {
|
|
43
|
+
type: "array",
|
|
44
|
+
description:
|
|
45
|
+
"Supported platforms are linux32, linux64, osx32, osx64, win32, win64",
|
|
46
|
+
group: "Run API",
|
|
47
|
+
default: detectCurrentPlatform(process),
|
|
48
|
+
})
|
|
49
|
+
.option("appName", {
|
|
50
|
+
type: "string",
|
|
51
|
+
description: "Name of your application",
|
|
52
|
+
group: "Build API",
|
|
53
|
+
default: Options["appName"],
|
|
54
|
+
})
|
|
55
|
+
.option("appVersion", {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Version of your application",
|
|
58
|
+
group: "Build API",
|
|
59
|
+
default: Options["appVersion"],
|
|
60
|
+
})
|
|
61
|
+
.option("buildDir", {
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "Path to NW.js build",
|
|
64
|
+
group: "Build API",
|
|
65
|
+
default: Options["buildDir"],
|
|
66
|
+
})
|
|
67
|
+
.option("buildType", {
|
|
68
|
+
type: "string",
|
|
69
|
+
description:
|
|
70
|
+
"default is appName, \nversioned is [appName] -v[appVersion], \ntimestamped is [appName] - [timestamp]",
|
|
71
|
+
group: "Build API",
|
|
72
|
+
default: Options["buildType"],
|
|
73
|
+
})
|
|
74
|
+
.option("forceDownload", {
|
|
75
|
+
type: "boolean",
|
|
76
|
+
description: "Delete all cache and builds and redownload them",
|
|
77
|
+
group: "Build API",
|
|
78
|
+
default: Options["forceDownload"],
|
|
79
|
+
})
|
|
80
|
+
.option("macCredits", {
|
|
81
|
+
type: "string",
|
|
82
|
+
description:
|
|
83
|
+
"The path to your credits.html file. By default it uses the one provided by NW.js",
|
|
84
|
+
group: "Build API",
|
|
85
|
+
default: Options["macCredits"],
|
|
86
|
+
})
|
|
87
|
+
.option("macIcns", {
|
|
88
|
+
type: "string",
|
|
89
|
+
description:
|
|
90
|
+
"The path to your ICNS file. By default it uses the one provided by NW.js",
|
|
91
|
+
group: "Build API",
|
|
92
|
+
default: Options["macIcns"],
|
|
93
|
+
})
|
|
94
|
+
.option("macPlist", {
|
|
95
|
+
type: "string",
|
|
96
|
+
description:
|
|
97
|
+
"The path to your Plist file. By default a Plist file is generated from the package.json",
|
|
98
|
+
group: "Build API",
|
|
99
|
+
default: Options["macPlist"],
|
|
100
|
+
})
|
|
101
|
+
.option("winVersionString", {
|
|
102
|
+
type: "object",
|
|
103
|
+
description: "Descriptors for Windows executable",
|
|
104
|
+
group: "Build API",
|
|
105
|
+
default: Options["winVersionString"],
|
|
106
|
+
})
|
|
107
|
+
.option("winIco", {
|
|
108
|
+
type: "string",
|
|
109
|
+
description:
|
|
110
|
+
"Path to your ICO file. By default it uses the one provided by NW.js",
|
|
111
|
+
group: "Build API",
|
|
112
|
+
default: Options["winIco"],
|
|
113
|
+
})
|
|
114
|
+
.option("useRcedit", {
|
|
115
|
+
type: "string",
|
|
116
|
+
description:
|
|
117
|
+
"If set to true, it allows you to set the Windows icon using rcedit instead of winresourcer",
|
|
118
|
+
group: "Build API",
|
|
119
|
+
default: Options["useRcedit"],
|
|
120
|
+
})
|
|
121
|
+
.option("zip", {
|
|
122
|
+
type: "boolean",
|
|
123
|
+
description: "Zip your NW.js application",
|
|
124
|
+
group: "Package API",
|
|
125
|
+
default: Options["zip"],
|
|
126
|
+
})
|
|
127
|
+
.option("zipOptions", {
|
|
128
|
+
type: "boolean",
|
|
129
|
+
description:
|
|
130
|
+
"Configure the underling zip library parameters, like store or compression ratio",
|
|
131
|
+
group: "Package API",
|
|
132
|
+
default: Options["zipOptions"],
|
|
133
|
+
})
|
|
134
|
+
.option("mergeZip", {
|
|
135
|
+
type: "boolean",
|
|
136
|
+
description: "Merge the source file package with the NW.js executable",
|
|
137
|
+
group: "Package API",
|
|
138
|
+
default: Options["mergeZip"],
|
|
139
|
+
})
|
|
140
|
+
.parse();
|
|
141
|
+
|
|
142
|
+
nwbuild({
|
|
143
|
+
...cli,
|
|
144
|
+
currentPlatform: detectCurrentPlatform(process),
|
|
145
|
+
files: cli._,
|
|
102
146
|
});
|