nw-builder 4.7.5 → 4.7.7

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/README.md CHANGED
@@ -371,6 +371,7 @@ nwbuild({
371
371
 
372
372
  ### Chores
373
373
 
374
+ - chore(docs): don't store JSDoc definitions in `typedef`s - get's hard to understand during development.
374
375
  - chore(get): verify sha checksum for downloads
375
376
  - chore: annotate file paths as `fs.PathLike` instead of `string`.
376
377
  - chore(bld): factor out core build step
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "4.7.5",
3
+ "version": "4.7.7",
4
4
  "description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -9,7 +9,7 @@
9
9
  "Application"
10
10
  ],
11
11
  "author": {
12
- "name": "Steffen Müller",
12
+ "name": "Steffen Müller",
13
13
  "url": "https://www.mllrsohn.com/"
14
14
  },
15
15
  "maintainers": [
@@ -41,38 +41,42 @@
41
41
  "url": "https://github.com/nwutils/nw-builder.git"
42
42
  },
43
43
  "scripts": {
44
+ "postinstall": "node ./src/postinstall.js",
44
45
  "lint": "eslint ./src/**/*.js ./test/**/*.js",
45
46
  "lint:fix": "eslint --fix ./src/**/*.js ./test/**/*.js",
46
47
  "markdown:fix": "markdownlint --fix ./README.md",
47
48
  "docs": "jsdoc -d docs ./README.md ./src/index.js ./src/get.js ./src/run.js ./src/bld.js",
48
- "test": "vitest run",
49
+ "test": "vitest run --coverage",
49
50
  "demo": "cd test/fixture && node demo.js"
50
51
  },
51
52
  "devDependencies": {
52
- "@stylistic/eslint-plugin-js": "^2.1.0",
53
+ "@stylistic/eslint-plugin-js": "^2.2.2",
54
+ "@vitest/coverage-v8": "^1.6.0",
55
+ "base-volta-off-of-nwjs": "^1.0.5",
53
56
  "eslint": "^9.4.0",
54
57
  "eslint-config-tjw-jsdoc": "^1.0.5",
55
- "eslint-plugin-jsdoc": "^48.2.9",
58
+ "eslint-plugin-jsdoc": "^48.2.13",
56
59
  "eslint-plugin-markdown": "^5.0.0",
57
60
  "jsdoc": "^4.0.3",
58
- "selenium-webdriver": "^4.21.0",
61
+ "nw": "^0.88.0-5",
62
+ "selenium-webdriver": "^4.22.0",
59
63
  "vitest": "^1.6.0"
60
64
  },
61
65
  "dependencies": {
62
66
  "axios": "^1.7.2",
63
67
  "cli-progress": "^3.12.0",
64
68
  "compressing": "^1.10.1",
65
- "glob": "^10.4.1",
69
+ "glob": "^10.4.2",
66
70
  "node-gyp": "^10.1.0",
67
71
  "plist": "^3.1.0",
68
72
  "resedit": "^2.0.2",
69
73
  "semver": "^7.6.2",
70
- "tar": "^7.2.0",
74
+ "tar": "^7.4.0",
71
75
  "yargs": "^17.7.2",
72
76
  "yauzl-promise": "^4.0.0"
73
77
  },
74
- "packageManager": "npm@10.7.0",
75
- "engines": {
76
- "node": ">=14"
78
+ "packageManager": "npm@10.8.1",
79
+ "volta": {
80
+ "node": "22.0.0"
77
81
  }
78
82
  }
package/src/bld.js CHANGED
@@ -317,11 +317,11 @@ const setWinConfig = async ({ app, outDir }) => {
317
317
  await fsm.rename(path.resolve(outDir, "nw.exe"), outDirAppExe);
318
318
  const exe = peLibrary.NtExecutable.from(await fsm.readFile(outDirAppExe));
319
319
  const res = peLibrary.NtExecutableResource.from(exe);
320
+ // English (United States)
321
+ const EN_US = 1033;
320
322
  if (app.icon) {
321
323
  const iconBuffer = await fsm.readFile(path.resolve(app.icon));
322
324
  const iconFile = resedit.Data.IconFile.from(iconBuffer);
323
- // English (United States)
324
- const EN_US = 1033;
325
325
  resedit.Resource.IconGroupEntry.replaceIconsForResource(
326
326
  res.entries,
327
327
  // This is the name of the icon group nw.js uses that gets shown in file exlorers
@@ -1,31 +1,56 @@
1
1
  import fs from "node:fs";
2
+ import path from "node:path";
3
+ import process from "node:process";
2
4
 
3
- import { beforeAll, describe, it } from "vitest";
5
+ import * as nw from "nw";
6
+ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
4
7
 
5
8
  import decompress from "./decompress.js";
6
- import request from "./request.js";
7
- import util from "../util.js";
8
9
 
9
- describe("get/decompress", function () {
10
+ import util from '../util.js';
10
11
 
11
- let tarUrl = "https://dl.nwjs.io/v0.83.0/nwjs-sdk-v0.83.0-linux-x64.tar.gz";
12
- let zipUrl = "https://dl.nwjs.io/v0.83.0/nwjs-sdk-v0.83.0-osx-x64.zip";
12
+ describe("get/decompress", async function () {
13
+
14
+ let nwFilePath = '';
15
+ let nwDirPath = '';
16
+ let nwOutPath = "./test/fixture/cache";
17
+
18
+ afterAll(async function () {
19
+ await fs.promises.rm(nwOutPath, { recursive: true, force: true });
20
+ });
13
21
 
14
22
  beforeAll(async function () {
15
- const cacheExists = await util.fileExists("./test/fixture/cache")
23
+ nwDirPath = await nw.findpath('all', { flavor: 'sdk' });
24
+
25
+ const cacheExists = await util.fileExists(nwOutPath)
16
26
  if (!cacheExists) {
17
- await fs.promises.mkdir("./test/fixture/cache");
27
+ await fs.promises.mkdir(nwOutPath);
18
28
  }
19
29
 
20
- await request(tarUrl, "./test/fixture/cache/nw.tar.gz");
21
- await request(zipUrl, "./test/fixture/cache/nw.zip");
22
- }, Infinity);
30
+ if (process.platform === 'linux') {
31
+ nwFilePath = nwDirPath + '.tar.gz';
32
+ } else {
33
+ nwFilePath = nwDirPath + '.zip';
34
+ }
35
+ });
23
36
 
24
- it("decompresses a Linux tarball", async function () {
25
- await decompress("./test/fixture/cache/nw.tar.gz", "./test/fixture/cache");
37
+ it("decompresses a NW.js binary", async function () {
38
+ await decompress(nwFilePath, nwOutPath);
26
39
  }, Infinity);
27
40
 
28
- it("decompresses a MacOS zip", async function () {
29
- await decompress("./test/fixture/cache/nw.zip", "./test/fixture/cache");
30
- }, Infinity);
41
+ it.runIf(process.platform === 'darwin')("preserves symlinks on macos", async function () {
42
+ const frameworksPath = path.resolve(process.cwd(), nwOutPath, nwDirPath, "nwjs.app", "Contents", "Frameworks", "nwjs Framework.framework");
43
+ const symlinks = [
44
+ path.join(frameworksPath, "Helpers"),
45
+ path.join(frameworksPath, "Libraries"),
46
+ path.join(frameworksPath, "nwjs Framework"),
47
+ path.join(frameworksPath, "Resources"),
48
+ path.join(frameworksPath, "Versions", "Current"),
49
+ ];
50
+
51
+ for (const symlink of symlinks) {
52
+ const stats = await fs.promises.lstat(symlink);
53
+ expect(stats.isSymbolicLink()).toEqual(true);
54
+ }
55
+ });
31
56
  });
@@ -8,7 +8,7 @@ import axios from "axios";
8
8
  *
9
9
  * @async
10
10
  * @function
11
- *
11
+ *
12
12
  * @param {string} url - Download server
13
13
  * @param {string} filePath - file path of downloaded content
14
14
  * @return {Promise<void>}
@@ -23,5 +23,7 @@ export default async function request(url, filePath) {
23
23
  responseType: "stream"
24
24
  });
25
25
 
26
- await stream.promises.pipeline(response.data, writeStream);
26
+ response.data.pipe(writeStream);
27
+
28
+ // await stream.promises.pipeline(response.data, writeStream);
27
29
  }
@@ -1,22 +1,16 @@
1
- import fs from "node:fs";
2
-
3
- import { afterEach, describe, expect, it } from "vitest";
1
+ import { describe, expect, it } from "vitest";
4
2
 
5
3
  import util from "../util.js";
6
4
 
7
5
  import request from "./request.js";
8
6
 
9
- describe("get/request", function () {
7
+ describe.skip("get/request", function () {
10
8
 
11
9
  let url = "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"
12
10
  const filePath = "./test/fixture/cache/request.test.json";
13
11
 
14
- afterEach(async function () {
15
- await fs.promises.rm(filePath, { force: true });
16
- });
17
-
18
12
  it("downloads from specific url", async function () {
19
13
  await request(url, filePath);
20
14
  expect(util.fileExists(filePath)).resolves.toBe(true);
21
- }, Infinity);
15
+ });
22
16
  });
@@ -0,0 +1,13 @@
1
+ import child_process from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import url from 'node:url';
5
+
6
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
7
+
8
+ const baseVoltaPath = path.resolve(path.join(__dirname, '..', 'node_modules', 'base-volta-off-of-nwjs', 'index.js'));
9
+
10
+ /* Execute the script in development mode only since it is used during testing */
11
+ if (fs.existsSync(baseVoltaPath)) {
12
+ child_process.execSync('node ' + baseVoltaPath);
13
+ }
package/src/util.js CHANGED
@@ -426,7 +426,7 @@ async function fileExists(filePath) {
426
426
  let exists = true;
427
427
  try {
428
428
  await fs.promises.stat(filePath);
429
- } catch {
429
+ } catch (_) {
430
430
  exists = false;
431
431
  }
432
432
  return exists;