Skip to content

Commit d55c1a3

Browse files
feat: add glob flag (#829)
1 parent d6a3c27 commit d55c1a3

File tree

24 files changed

+251
-203
lines changed

24 files changed

+251
-203
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
- run: npm run fmt
3333
- run: npm run lnt
3434
- run: npm link
35-
- run: npm run test:jest
35+
# - run: npm run test:jest
3636
- run: npm run test:unit
3737
# - run: npm run test:e2e

docs/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [4.2.0] - 2023-03-27
11+
12+
## Added
13+
14+
- Glob flag defaulting to trye. Currently file globbing is broken and it is recommended to set `glob` to false.
15+
1016
## Changed
1117

1218
- Fixed `get` mode
19+
- Fixed `run` mode
20+
- Fixed `build` mode
21+
- Updated `get` mode docs
1322

1423
## [4.1.1-beta.2] - 2023-03-15
1524

docs/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Installation Guide
22

3-
Every NW.js release includes a modified Node.js at a specific version. Native Node modules are not compatible with the NW.js ABI. To prevent this scenario, `nw-builder` requires the host Node version to be identical to NW.js's Node version. It is recommended to use a [Node Version Manager](https://nodejs.org/en/download/package-manager) to manage multiple Node installations. Consult the [manifest](https://nwjs.io/versions) for what Node version to install.
3+
Every NW.js release includes a modified Node.js at a specific version. By installing a version greater/equal to NW.js's Node version, you get to use the latest features. In that case tt is recommended to use a [Node Version Manager](https://nodejs.org/en/download/package-manager) to manage multiple Node installations. Consult the [manifest](https://nwjs.io/versions) for what Node version to install.
44

55
With the environment setup, install `nw-builder` using npm:
66

docs/mode-get.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Get NW.js binaries
22

3-
There are multiple ways to get NW.js binaries.
4-
53
Module usage:
64

75
```javascript
@@ -10,15 +8,38 @@ nwbuild({
108
});
119
```
1210

11+
This is equivalent to:
12+
13+
```javascript
14+
nwbuild({
15+
mode: "get",
16+
version: "latest",
17+
flavor: "normal",
18+
platform: "linux",
19+
arch: "x64",
20+
downloadUrl: "https://dl.nwjs.io",
21+
manifestUrl: "https://nwjs.io/versions",
22+
cacheDir: "./cache",
23+
cache: true,
24+
ffmpeg: false,
25+
});
26+
```
27+
1328
CLI usage:
1429

1530
```shell
1631
nwbuild --mode=get
1732
```
1833

19-
This downloads the latest version of the normal build flavor for the host platform and architecture. This might be useful as a `postInstall` step in your `package.json` or when running `Chromedriver` tests you don't want to run or build your app.
34+
This is equivalent to:
35+
36+
```shell
37+
nwbuild --mode=get --version=latest --flavor=normal --platform=linux --arch=x64 --downloadUrl=https://dl.nwjs.io --manifestUrl=https://nwjs.io/versions --cacheDir=./cache --cache=true --ffmpeg=false
38+
```
2039

21-
There are some more options/flags which allow you to customise this behaviour. Let's look at what these options allow us to do:
40+
> When the `platform` and `arch` are not specified, they default to the host platform and arch. For this guide, we are assumed to be using Linux x64.
41+
42+
This might be useful as a `postInstall` step in your `package.json` or when running `Chromedriver` tests you don't want to run or build your app. Here are some other use cases:
2243

2344
## Download unofficial MacOS ARM builds:
2445

@@ -56,6 +77,8 @@ nwbuild({
5677
});
5778
```
5879

80+
CLI usage:
81+
5982
```shell
6083
nwbuild --mode=get --downloadUrl=https://npm.taobao.org/mirrors/nwjs/
6184
```

e2e/demo.cjs

Lines changed: 0 additions & 23 deletions
This file was deleted.

e2e/demo.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nw-builder",
3-
"version": "4.1.1-beta.3",
3+
"version": "4.2.0",
44
"description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
55
"keywords": [
66
"NW.js",
@@ -48,10 +48,9 @@
4848
"test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
4949
"test:unit": "node --test-reporter=spec --test test/unit/index.js",
5050
"test:e2e": "node --test-reporter=spec --test e2e/index.js",
51-
"test:manual:get": "nwbuild --mode=get",
52-
"demo:esm": "cd e2e && node demo.js",
53-
"demo:cjs": "cd e2e && node demo.cjs",
54-
"demo:cli": "cd e2e && nwbuild ./app/* --mode=build --version=0.74.0 --flavor=normal --platform=win --arch=x64 --outDir=./out --cacheDir=./tmp"
51+
"test:manual:get": "cd test/fixture && nwbuild --mode=get",
52+
"test:manual:dev": "cd test/fixture && nwbuild --mode=run ./app --no-glob",
53+
"test:manual:bld": "cd test/fixture && nwbuild --mode=build ./app --no-glob"
5554
},
5655
"devDependencies": {
5756
"eslint": "^8.36.0",

src/bld/build.js

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { setWinConfig } from "./winCfg.js";
1111
/**
1212
* Generate NW build artifacts
1313
*
14-
* @param {string[]} files Array of NW app files
14+
* @param {string | string[]} files Array of NW app files
1515
* @param {string} nwDir Directory to hold NW binaries
1616
* @param {string} outDir Directory to store build artifacts
1717
* @param {"linux" | "osx" | "win"} platform Platform is the operating system type
@@ -37,33 +37,50 @@ export const build = async (
3737
await cp(nwDir, outDir, { recursive: true });
3838

3939
log.debug(`Copy files in srcDir to ${outDir} directory`);
40-
for (let file of files) {
41-
log.debug(`Copy ${file} file to ${outDir} directory`);
40+
41+
if (typeof files === "string") {
4242
await cp(
43-
file,
43+
files,
4444
resolve(
4545
outDir,
4646
platform !== "osx"
4747
? "package.nw"
4848
: "nwjs.app/Contents/Resources/app.nw",
49+
),
50+
{ recursive: true },
51+
);
52+
} else {
53+
for (let file of files) {
54+
log.debug(`Copy ${file} file to ${outDir} directory`);
55+
await cp(
4956
file,
57+
resolve(
58+
outDir,
59+
platform !== "osx"
60+
? "package.nw"
61+
: "nwjs.app/Contents/Resources/app.nw",
62+
file,
63+
),
64+
{ recursive: true },
65+
);
66+
}
67+
68+
// Write NW.js manifest file to outDir
69+
// TODO: Allow user to specify manifest file config options
70+
log.debug(`Write NW.js manifest file to ${outDir} directory`);
71+
await writeFile(
72+
resolve(
73+
outDir,
74+
platform !== "osx"
75+
? "package.nw"
76+
: "nwjs.app/Contents/Resources/app.nw",
77+
"package.json",
5078
),
79+
JSON.stringify(nwPkg, null, 2),
80+
"utf8",
5181
);
5282
}
5383

54-
// Write NW.js manifest file to outDir
55-
// TODO: Allow user to specify manifest file config options
56-
log.debug(`Write NW.js manifest file to ${outDir} directory`);
57-
await writeFile(
58-
resolve(
59-
outDir,
60-
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw",
61-
"package.json",
62-
),
63-
JSON.stringify(nwPkg, null, 2),
64-
"utf8",
65-
);
66-
6784
log.debug(`Starting platform specific config steps for ${platform}`);
6885
switch (platform) {
6986
case "linux":

src/log.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export const log = createLogger({
1515
],
1616
});
1717

18-
if (process.env.NODE_ENV !== "production") {
19-
log.add(
20-
new transports.Console({
21-
level: "debug",
22-
}),
23-
);
24-
}
18+
// if (process.env.NODE_ENV !== "production") {
19+
// log.add(
20+
// new transports.Console({
21+
// level: "debug",
22+
// }),
23+
// );
24+
// }

0 commit comments

Comments
 (0)