nw-builder 3.8.6-beta.0 → 3.8.6-beta.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/.eslintignore +6 -0
- package/.github/dependabot.yml +8 -13
- package/.github/workflows/cd.yml +18 -9
- package/.github/workflows/ci.yml +24 -15
- package/.prettierignore +6 -0
- package/{.github/CHANGELOG.md → CHANGELOG.md} +16 -2
- package/README.md +33 -0
- package/bin/nwbuild.cjs +1 -21
- package/cfg/eslint.config.cjs +17 -0
- package/demo.cjs +29 -0
- package/docs/getting-started.md +6 -6
- package/e2e/test.js +47 -0
- package/lib/index.cjs +774 -870
- package/lib/utils.cjs +4 -3
- package/package.json +30 -64
- package/src/constants/Options.js +1 -1
- package/src/get.js +206 -0
- package/src/index.js +13 -4
- package/src/log.js +32 -0
- package/src/run.js +78 -0
- package/src/util.js +275 -0
- package/src/utilities/checkCache.js +3 -3
- package/src/utilities/detectCurrentPlatform.js +3 -3
- package/test/demo/index.html +4 -3
- package/test/demo/package.json +3 -23
- package/test/fixtures/nwapp/index.html +4 -3
- package/test/fixtures/testVersions.html +54 -66
- package/dist/index.cjs +0 -6
- package/src/utilities/checkPkgOptions.js +0 -28
- package/src/utilities/parseOptions.js +0 -10
- package/test/demo/icon.icns +0 -0
- package/test/demo/icon.ico +0 -0
- package/test/demo/index.cjs +0 -8
package/.eslintignore
ADDED
package/.github/dependabot.yml
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
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
1
|
version: 2
|
|
7
2
|
updates:
|
|
8
|
-
- package-ecosystem: "npm"
|
|
9
|
-
directory: "
|
|
3
|
+
- package-ecosystem: "npm"
|
|
4
|
+
directory: "."
|
|
10
5
|
schedule:
|
|
11
|
-
interval: "
|
|
12
|
-
|
|
13
|
-
- package-ecosystem: "github-actions"
|
|
14
|
-
directory: ".github/"
|
|
6
|
+
interval: "daily"
|
|
7
|
+
target-branch: "v3"
|
|
8
|
+
- package-ecosystem: "github-actions"
|
|
9
|
+
directory: ".github/"
|
|
15
10
|
schedule:
|
|
16
|
-
interval: "
|
|
17
|
-
|
|
11
|
+
interval: "daily"
|
|
12
|
+
target-branch: "v3"
|
package/.github/workflows/cd.yml
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
name: cd
|
|
1
|
+
name: v3-cd
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
4
|
branches:
|
|
5
5
|
- v3
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
|
-
|
|
9
|
-
runs-on: ubuntu-
|
|
8
|
+
npm:
|
|
9
|
+
runs-on: ubuntu-22.04
|
|
10
10
|
steps:
|
|
11
|
-
-
|
|
12
|
-
|
|
11
|
+
- name: Checkout repository
|
|
12
|
+
uses: actions/checkout@v3.3.0
|
|
13
|
+
- name: Get Node version from Node manifest
|
|
14
|
+
run: |
|
|
15
|
+
echo "NODE_VER=$(jq -r '.engines.node' package.json | sed 's/v//' )" >> $GITHUB_ENV
|
|
16
|
+
- name: Setup Node
|
|
17
|
+
uses: actions/setup-node@v3.6.0
|
|
13
18
|
with:
|
|
14
|
-
node-version:
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
19
|
+
node-version: ${{ env.NODE_VER }}
|
|
20
|
+
cache: "npm"
|
|
21
|
+
- name: Enable corepack
|
|
22
|
+
run: corepack enable
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
- name: Publish to npm
|
|
26
|
+
uses: JS-DevTools/npm-publish@v2.2.1
|
|
18
27
|
with:
|
|
19
28
|
token: ${{ secrets.NPM_TOKEN }}
|
|
20
29
|
tag: stable
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: ci
|
|
1
|
+
name: v3-ci
|
|
2
2
|
on:
|
|
3
3
|
pull_request:
|
|
4
4
|
branches:
|
|
@@ -12,19 +12,28 @@ concurrency:
|
|
|
12
12
|
cancel-in-progress: true
|
|
13
13
|
|
|
14
14
|
jobs:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
matrix:
|
|
18
|
-
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
19
|
-
node-version: [14, 16, 18]
|
|
20
|
-
runs-on: ${{ matrix.os }}
|
|
15
|
+
e2e:
|
|
16
|
+
runs-on: ubuntu-22.04
|
|
21
17
|
steps:
|
|
22
|
-
-
|
|
23
|
-
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v3.3.0
|
|
20
|
+
- name: Get Node version from Node manifest
|
|
21
|
+
run: |
|
|
22
|
+
echo "NODE_VER=$(jq -r '.engines.node' package.json | sed 's/v//' )" >> $GITHUB_ENV
|
|
23
|
+
- name: Setup Node
|
|
24
|
+
uses: actions/setup-node@v3.6.0
|
|
24
25
|
with:
|
|
25
|
-
node-version: ${{
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
26
|
+
node-version: ${{ env.NODE_VER }}
|
|
27
|
+
cache: "npm"
|
|
28
|
+
- name: Enable corepack
|
|
29
|
+
run: corepack enable
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: npm ci
|
|
32
|
+
- name: Prepare test environment
|
|
33
|
+
run: npm run test:prep
|
|
34
|
+
- name: Run Jest tests
|
|
35
|
+
run: npm run test:jest
|
|
36
|
+
- name: Run Tape tests
|
|
37
|
+
run: npm run test:tape
|
|
38
|
+
- name: Run ChromeDriver tests
|
|
39
|
+
run: npm run test:sanity
|
package/.prettierignore
ADDED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
All notable changes to this project will be documented in this file
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.8.6-beta.2] - 2023-08-23
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Migrate from function to class implementation.
|
|
15
|
+
- Refactor options parsing and validation logic.
|
|
16
|
+
|
|
17
|
+
## [3.8.6-beta.1] - 2023-08-19
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Migrate from `nw-install` to `node:https`.
|
|
22
|
+
- Refactor executable renaming logic
|
|
23
|
+
|
|
10
24
|
## [3.8.6] - 2022-09-22
|
|
11
25
|
|
|
12
26
|
- Fix mac and windows build
|
package/README.md
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
# nw-builder
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/nw-builder)
|
|
4
|
+
[](https://gitter.im/nwjs/nw-builder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
5
|
+
|
|
3
6
|
Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and Linux.
|
|
4
7
|
|
|
8
|
+
For version 4, please go to the [corresponding branch](https://github.com/nwutils/nw-builder/tree/main).
|
|
9
|
+
|
|
5
10
|
## Table of Contents
|
|
6
11
|
|
|
7
12
|
- [Installation](https://github.com/nwutils/nw-builder#installation)
|
|
@@ -208,6 +213,34 @@ Default value: `true`
|
|
|
208
213
|
|
|
209
214
|
WINDOWS AND LINUX ONLY: Merge the source file package with the Node Webkit executable.
|
|
210
215
|
|
|
216
|
+
#### options.downloadUrl
|
|
217
|
+
|
|
218
|
+
Type: `string`
|
|
219
|
+
Default value: `https://dl.nwjs.io`
|
|
220
|
+
|
|
221
|
+
Server to download binaries from.
|
|
222
|
+
|
|
223
|
+
#### options.manifestUrl
|
|
224
|
+
|
|
225
|
+
Type: `string`
|
|
226
|
+
Default value: `https://nwjs.io/versions`
|
|
227
|
+
|
|
228
|
+
Server to download binaries from.
|
|
229
|
+
|
|
230
|
+
#### options.quiet
|
|
231
|
+
|
|
232
|
+
Type: `string`
|
|
233
|
+
Default: `"info"`
|
|
234
|
+
|
|
235
|
+
Set the log level. Valid options are `"error"`, `"warn"`, `"info"`, `"debug"` and `"off"`.
|
|
236
|
+
|
|
237
|
+
#### options.useRcedit
|
|
238
|
+
|
|
239
|
+
Type: `Boolean`
|
|
240
|
+
Default: `false`
|
|
241
|
+
|
|
242
|
+
`winresourcer` is used to update Windows executable resources by default. `rcedit` can be used if preferred.
|
|
243
|
+
|
|
211
244
|
### Manifest Options
|
|
212
245
|
|
|
213
246
|
#### platformOverrides
|
package/bin/nwbuild.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const yargs = require("yargs/yargs");
|
|
|
4
4
|
const { hideBin } = require("yargs/helpers");
|
|
5
5
|
|
|
6
6
|
const { nwbuild } = require("../lib/index.cjs");
|
|
7
|
-
const {
|
|
7
|
+
const { detectCurrentPlatform } = require("../dist/index.cjs");
|
|
8
8
|
|
|
9
9
|
const cli = yargs(hideBin(process.argv))
|
|
10
10
|
.version(false)
|
|
@@ -12,130 +12,110 @@ const cli = yargs(hideBin(process.argv))
|
|
|
12
12
|
.option("mode", {
|
|
13
13
|
type: "string",
|
|
14
14
|
description: "Choose between run and build mode",
|
|
15
|
-
default: Options["mode"],
|
|
16
15
|
})
|
|
17
16
|
.option("quiet", {
|
|
18
17
|
type: "string",
|
|
19
18
|
description:
|
|
20
19
|
"Choose your level of logging between error, warn, info, debug and off",
|
|
21
|
-
default: Options["quiet"],
|
|
22
20
|
})
|
|
23
21
|
.option("version", {
|
|
24
22
|
type: "string",
|
|
25
23
|
description: "Version of NW.js you want to use.",
|
|
26
24
|
group: "Run API",
|
|
27
|
-
default: Options["version"],
|
|
28
25
|
})
|
|
29
26
|
.option("flavor", {
|
|
30
27
|
type: "string",
|
|
31
28
|
description:
|
|
32
29
|
"sdk is recommended for development and normal is recommended for production.",
|
|
33
30
|
group: "Run API",
|
|
34
|
-
default: Options["flavor"],
|
|
35
31
|
})
|
|
36
32
|
.option("cacheDir", {
|
|
37
33
|
type: "string",
|
|
38
34
|
description: "Path to NW.js cache",
|
|
39
35
|
group: "Run API",
|
|
40
|
-
default: Options["cacheDir"],
|
|
41
36
|
})
|
|
42
37
|
.option("platforms", {
|
|
43
38
|
type: "array",
|
|
44
39
|
description:
|
|
45
40
|
"Supported platforms are linux32, linux64, osx32, osx64, win32, win64",
|
|
46
41
|
group: "Run API",
|
|
47
|
-
default: detectCurrentPlatform(process),
|
|
48
42
|
})
|
|
49
43
|
.option("appName", {
|
|
50
44
|
type: "string",
|
|
51
45
|
description: "Name of your application",
|
|
52
46
|
group: "Build API",
|
|
53
|
-
default: Options["appName"],
|
|
54
47
|
})
|
|
55
48
|
.option("appVersion", {
|
|
56
49
|
type: "string",
|
|
57
50
|
description: "Version of your application",
|
|
58
51
|
group: "Build API",
|
|
59
|
-
default: Options["appVersion"],
|
|
60
52
|
})
|
|
61
53
|
.option("buildDir", {
|
|
62
54
|
type: "string",
|
|
63
55
|
description: "Path to NW.js build",
|
|
64
56
|
group: "Build API",
|
|
65
|
-
default: Options["buildDir"],
|
|
66
57
|
})
|
|
67
58
|
.option("buildType", {
|
|
68
59
|
type: "string",
|
|
69
60
|
description:
|
|
70
61
|
"default is appName, \nversioned is [appName] -v[appVersion], \ntimestamped is [appName] - [timestamp]",
|
|
71
62
|
group: "Build API",
|
|
72
|
-
default: Options["buildType"],
|
|
73
63
|
})
|
|
74
64
|
.option("forceDownload", {
|
|
75
65
|
type: "boolean",
|
|
76
66
|
description: "Delete all cache and builds and redownload them",
|
|
77
67
|
group: "Build API",
|
|
78
|
-
default: Options["forceDownload"],
|
|
79
68
|
})
|
|
80
69
|
.option("macCredits", {
|
|
81
70
|
type: "string",
|
|
82
71
|
description:
|
|
83
72
|
"The path to your credits.html file. By default it uses the one provided by NW.js",
|
|
84
73
|
group: "Build API",
|
|
85
|
-
default: Options["macCredits"],
|
|
86
74
|
})
|
|
87
75
|
.option("macIcns", {
|
|
88
76
|
type: "string",
|
|
89
77
|
description:
|
|
90
78
|
"The path to your ICNS file. By default it uses the one provided by NW.js",
|
|
91
79
|
group: "Build API",
|
|
92
|
-
default: Options["macIcns"],
|
|
93
80
|
})
|
|
94
81
|
.option("macPlist", {
|
|
95
82
|
type: "string",
|
|
96
83
|
description:
|
|
97
84
|
"The path to your Plist file. By default a Plist file is generated from the package.json",
|
|
98
85
|
group: "Build API",
|
|
99
|
-
default: Options["macPlist"],
|
|
100
86
|
})
|
|
101
87
|
.option("winVersionString", {
|
|
102
88
|
type: "object",
|
|
103
89
|
description: "Descriptors for Windows executable",
|
|
104
90
|
group: "Build API",
|
|
105
|
-
default: Options["winVersionString"],
|
|
106
91
|
})
|
|
107
92
|
.option("winIco", {
|
|
108
93
|
type: "string",
|
|
109
94
|
description:
|
|
110
95
|
"Path to your ICO file. By default it uses the one provided by NW.js",
|
|
111
96
|
group: "Build API",
|
|
112
|
-
default: Options["winIco"],
|
|
113
97
|
})
|
|
114
98
|
.option("useRcedit", {
|
|
115
99
|
type: "string",
|
|
116
100
|
description:
|
|
117
101
|
"If set to true, it allows you to set the Windows icon using rcedit instead of winresourcer",
|
|
118
102
|
group: "Build API",
|
|
119
|
-
default: Options["useRcedit"],
|
|
120
103
|
})
|
|
121
104
|
.option("zip", {
|
|
122
105
|
type: "boolean",
|
|
123
106
|
description: "Zip your NW.js application",
|
|
124
107
|
group: "Package API",
|
|
125
|
-
default: Options["zip"],
|
|
126
108
|
})
|
|
127
109
|
.option("zipOptions", {
|
|
128
110
|
type: "boolean",
|
|
129
111
|
description:
|
|
130
112
|
"Configure the underling zip library parameters, like store or compression ratio",
|
|
131
113
|
group: "Package API",
|
|
132
|
-
default: Options["zipOptions"],
|
|
133
114
|
})
|
|
134
115
|
.option("mergeZip", {
|
|
135
116
|
type: "boolean",
|
|
136
117
|
description: "Merge the source file package with the NW.js executable",
|
|
137
118
|
group: "Package API",
|
|
138
|
-
default: Options["mergeZip"],
|
|
139
119
|
})
|
|
140
120
|
.parse();
|
|
141
121
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parserOptions: {
|
|
3
|
+
ecmaVersion: 2023,
|
|
4
|
+
sourceType: "module",
|
|
5
|
+
},
|
|
6
|
+
env: {
|
|
7
|
+
es6: true,
|
|
8
|
+
node: true,
|
|
9
|
+
},
|
|
10
|
+
extends: ["eslint:recommended", "tjw-jsdoc"],
|
|
11
|
+
rules: {
|
|
12
|
+
"jsdoc/require-file-overview": "off",
|
|
13
|
+
"jsdoc/require-returns-description": "off",
|
|
14
|
+
"jsdoc/match-description": "off",
|
|
15
|
+
"jsdoc/valid-types": "off",
|
|
16
|
+
},
|
|
17
|
+
};
|
package/demo.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const { resolve } = require("node:path");
|
|
3
|
+
|
|
4
|
+
const NwBuilder = require("./lib/index.cjs");
|
|
5
|
+
|
|
6
|
+
const nw = new NwBuilder({
|
|
7
|
+
files: ["package.json", "test/demo/*"],
|
|
8
|
+
platforms: ["linux64", "osx64", "win64"],
|
|
9
|
+
version: "0.67.1",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
nw.build().then(() => {
|
|
13
|
+
let NW_manifest = JSON.parse(
|
|
14
|
+
fs.readFileSync("package.json", { encoding: "utf8" }),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
NW_manifest.main = "test/demo/index.html";
|
|
18
|
+
|
|
19
|
+
const manifestPath = resolve(
|
|
20
|
+
"build",
|
|
21
|
+
"nw-builder",
|
|
22
|
+
"win64",
|
|
23
|
+
"package.nw",
|
|
24
|
+
"package.json",
|
|
25
|
+
);
|
|
26
|
+
const manifestData = JSON.stringify(NW_manifest);
|
|
27
|
+
|
|
28
|
+
fs.writeFileSync(manifestPath, manifestData, { encoding: "utf8" });
|
|
29
|
+
});
|
package/docs/getting-started.md
CHANGED
|
@@ -72,8 +72,8 @@ Module usage:
|
|
|
72
72
|
const { nwbuild } = require("nw-builder");
|
|
73
73
|
|
|
74
74
|
nwbuild({
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
files: "./path/to/nw/app",
|
|
76
|
+
mode: "run",
|
|
77
77
|
});
|
|
78
78
|
```
|
|
79
79
|
|
|
@@ -93,10 +93,10 @@ Module usage:
|
|
|
93
93
|
const { nwbuild } = require("nw-builder");
|
|
94
94
|
|
|
95
95
|
nwbuild({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
files: "./path/to/nw/app/dir/**/*.*",
|
|
97
|
+
flavor: "normal",
|
|
98
|
+
platforms: ["win32", "linux64"],
|
|
99
|
+
mode: "build",
|
|
100
100
|
});
|
|
101
101
|
```
|
|
102
102
|
|
package/e2e/test.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { equal } from "node:assert";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { arch as ARCH, platform as PLATFORM } from "node:process";
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
|
|
6
|
+
import NwBuilder from "nw-builder";
|
|
7
|
+
import { By } from "selenium-webdriver";
|
|
8
|
+
import chrome from "selenium-webdriver/chrome.js";
|
|
9
|
+
|
|
10
|
+
import { ARCH_KV, PLATFORM_KV } from "../src/util.js";
|
|
11
|
+
|
|
12
|
+
const { Driver, ServiceBuilder, Options } = chrome;
|
|
13
|
+
|
|
14
|
+
describe("test modes", async () => {
|
|
15
|
+
let driver = undefined;
|
|
16
|
+
|
|
17
|
+
let nwOptions = {
|
|
18
|
+
files: "test/demo/**",
|
|
19
|
+
version: "0.67.1",
|
|
20
|
+
flavor: "sdk",
|
|
21
|
+
cacheDir: "cache",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
it("should run", async () => {
|
|
25
|
+
const nw = NwBuilder({ ...nwOptions });
|
|
26
|
+
|
|
27
|
+
nw.build();
|
|
28
|
+
|
|
29
|
+
const options = new Options();
|
|
30
|
+
const args = [`--nwapp=${resolve("test", "demo")}`, "--headless=new"];
|
|
31
|
+
options.addArguments(args);
|
|
32
|
+
|
|
33
|
+
const chromedriverPath = resolve(
|
|
34
|
+
nwOptions.cacheDir,
|
|
35
|
+
`nwjs${nwOptions.flavor === "sdk" ? "-sdk" : ""}-v${nwOptions.version}-${
|
|
36
|
+
PLATFORM_KV[PLATFORM]
|
|
37
|
+
}-${ARCH_KV[ARCH]}`,
|
|
38
|
+
`chromedriver${PLATFORM_KV[PLATFORM] === "win" ? ".exe" : ""}`,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const service = new ServiceBuilder(chromedriverPath).build();
|
|
42
|
+
|
|
43
|
+
driver = Driver.createSession(options, service);
|
|
44
|
+
const text = await driver.findElement(By.id("test")).getText();
|
|
45
|
+
equal(text, "Hello, World!");
|
|
46
|
+
});
|
|
47
|
+
});
|