nw 0.90.0 → 0.91.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011-2019 NW.js Authors
2
+ Copyright (c) 2011-2019 The Chromium Authors
3
+ Copyright (c) 2011-2018 Intel Corp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
+ Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
17
+ A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
20
+ THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw",
3
- "version": "0.90.0",
3
+ "version": "0.91.0",
4
4
  "description": "An installer for NW.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,7 @@
14
14
  "scripts": {
15
15
  "postinstall": "node src/postinstall.js",
16
16
  "test": "vitest run",
17
- "test:coverage": "vitest --coverage.enabled true",
18
- "license-check": "jsgl -l ."
17
+ "test:coverage": "vitest --coverage.enabled true"
19
18
  },
20
19
  "files": [
21
20
  "src"
@@ -32,7 +31,7 @@
32
31
  ],
33
32
  "license": "MIT",
34
33
  "dependencies": {
35
- "axios": "^1.7.2",
34
+ "axios": "^1.7.4",
36
35
  "commander": "^12.1.0",
37
36
  "semver": "^7.6.3",
38
37
  "tar": "^7.4.3",
@@ -51,9 +50,7 @@
51
50
  "application"
52
51
  ],
53
52
  "devDependencies": {
54
- "@vitest/coverage-v8": "^2.0.4",
55
- "js-green-licenses": "^4.0.0",
56
- "patch-package": "^8.0.0",
53
+ "@vitest/coverage-v8": "^2.0.5",
57
54
  "selenium-webdriver": "^4.23.0",
58
55
  "vitest": "^2.0.2"
59
56
  }
package/src/get.js CHANGED
@@ -96,6 +96,12 @@ async function get(options) {
96
96
 
97
97
  await decompress(nwFilePath, options.cacheDir);
98
98
 
99
+ await verify(
100
+ `${options.downloadUrl}/v${options.version}/SHASUMS256.txt`,
101
+ `${options.cacheDir}/shasum/${options.version}.txt`,
102
+ options.cacheDir,
103
+ );
104
+
99
105
  await fs.promises.symlink(nwDirPath, './nwjs', );
100
106
 
101
107
  if (options.ffmpeg === true) {
package/src/verify.js ADDED
@@ -0,0 +1,47 @@
1
+ import crypto from 'node:crypto';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ import request from './request.js';
6
+ import util from './util.js';
7
+
8
+ /**
9
+ * Verify the SHA256 checksum of downloaded artifacts.
10
+ *
11
+ * @param {string} shaUrl - URL to get the shasum text file from.
12
+ * @param {string} shaOut - File path to shasum text file.
13
+ * @param {string} cacheDir - File path to cache directory.
14
+ * @throws {Error}
15
+ * @returns {Promise<boolean>}
16
+ */
17
+ export default async function verify(shaUrl, shaOut, cacheDir) {
18
+ const shaOutExists = await util.fileExists(shaOut);
19
+
20
+ if (shaOutExists === false) {
21
+ /* Create directory if does not exist. */
22
+ await fs.promises.mkdir(path.dirname(shaOut), { recursive: true });
23
+
24
+ /* Download SHASUM text file. */
25
+ await request(shaUrl, shaOut);
26
+ }
27
+
28
+ /* Read SHASUM text file */
29
+ const shasum = await fs.promises.readFile(shaOut, { encoding: 'utf-8' });
30
+ const shasums = shasum.trim().split('\n');
31
+ for await (const line of shasums) {
32
+ const [storedSha, filePath] = line.split(' ');
33
+ const relativeFilePath = path.resolve(cacheDir, filePath);
34
+ const relativefilePathExists = await util.fileExists(relativeFilePath);
35
+ if (relativefilePathExists) {
36
+ const fileBuffer = await fs.promises.readFile(relativeFilePath);
37
+ const hash = crypto.createHash('sha256');
38
+ hash.update(fileBuffer);
39
+ const generatedSha = hash.digest('hex');
40
+ if (storedSha !== generatedSha) {
41
+ throw new Error('SHA256 checksums do not match.');
42
+ }
43
+ }
44
+ }
45
+
46
+ return true;
47
+ }
@@ -1,55 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import process from "node:process";
4
-
5
- import { afterAll, beforeAll, describe, expect, it } from "vitest";
6
-
7
- import * as nw from "../src/index.js";
8
- import decompress from "./decompress.js";
9
- import util from './util.js';
10
-
11
- describe("get/decompress", async function () {
12
-
13
- let nwFilePath = '';
14
- let nwDirPath = '';
15
- let nwOutPath = "./test/fixture/cache";
16
-
17
- afterAll(async function () {
18
- await fs.promises.rm(nwOutPath, { recursive: true, force: true });
19
- });
20
-
21
- beforeAll(async function () {
22
- nwDirPath = await nw.findpath('all', { flavor: 'sdk' });
23
-
24
- const cacheExists = await util.fileExists(nwOutPath)
25
- if (!cacheExists) {
26
- await fs.promises.mkdir(nwOutPath);
27
- }
28
-
29
- if (process.platform === 'linux') {
30
- nwFilePath = nwDirPath + '.tar.gz';
31
- } else {
32
- nwFilePath = nwDirPath + '.zip';
33
- }
34
- });
35
-
36
- it("decompresses a NW.js binary", async function () {
37
- await decompress(nwFilePath, nwOutPath);
38
- }, Infinity);
39
-
40
- it.runIf(process.platform === 'darwin')("preserves symlinks on macos", async function () {
41
- const frameworksPath = path.resolve(process.cwd(), nwOutPath, nwDirPath, "nwjs.app", "Contents", "Frameworks", "nwjs Framework.framework");
42
- const symlinks = [
43
- path.join(frameworksPath, "Helpers"),
44
- path.join(frameworksPath, "Libraries"),
45
- path.join(frameworksPath, "nwjs Framework"),
46
- path.join(frameworksPath, "Resources"),
47
- path.join(frameworksPath, "Versions", "Current"),
48
- ];
49
-
50
- for (const symlink of symlinks) {
51
- const stats = await fs.promises.lstat(symlink);
52
- expect(stats.isSymbolicLink()).toEqual(true);
53
- }
54
- });
55
- });
@@ -1,31 +0,0 @@
1
- import fs from "node:fs";
2
- import process from "node:process";
3
-
4
- import { afterEach, beforeAll, describe, expect, it } from "vitest";
5
-
6
- import ffmpeg from "./ffmpeg.js";
7
- import util from "./util.js";
8
-
9
- describe("get/ffmpeg", function () {
10
-
11
- let ffmpegFile = '';
12
-
13
- afterEach(function () {
14
- fs.promises.rm(ffmpegFile, { recursive: true, force: true });
15
- });
16
-
17
- beforeAll(async function () {
18
- await fs.promises.mkdir("./test/fixture", { recursive: true });
19
- });
20
-
21
- it("downloades community prebuild FFmpeg for specifc platform", async function () {
22
- ffmpegFile = await ffmpeg(
23
- "https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases/download",
24
- "0.83.0",
25
- util.PLATFORM_KV[process.platform],
26
- util.ARCH_KV[process.arch],
27
- "./test/fixture"
28
- );
29
- expect(util.fileExists(ffmpegFile)).resolves.toBe(true);
30
- }, Infinity);
31
- });
package/src/node.test.js DELETED
@@ -1,24 +0,0 @@
1
- import fs from "node:fs";
2
-
3
- import { afterEach, describe, expect, it } from "vitest";
4
-
5
- import node from "./node.js";
6
- import util from "./util.js";
7
-
8
- describe("get/node", function () {
9
-
10
- let nodeFile = '';
11
-
12
- afterEach(function () {
13
- fs.promises.rm(nodeFile, { recursive: true, force: true });
14
- });
15
-
16
- it("downloades Node headers", async function () {
17
- nodeFile = await node(
18
- "https://dl.nwjs.io",
19
- "0.83.0",
20
- "./test/fixture"
21
- );
22
- expect(util.fileExists(nodeFile)).resolves.toBe(true);
23
- }, Infinity);
24
- });
package/src/nw.test.js DELETED
@@ -1,28 +0,0 @@
1
- import fs from "node:fs";
2
- import process from "node:process";
3
-
4
- import { afterEach, describe, expect, it } from "vitest";
5
-
6
- import nw from "./nw.js";
7
- import util from "./util.js";
8
-
9
- describe("get/nw", function () {
10
-
11
- let nwFile = '';
12
-
13
- afterEach(function () {
14
- fs.promises.rm(nwFile, { recursive: true, force: true });
15
- });
16
-
17
- it("downloades a NW.js Linux tarball or Windows/MacOS zip", async function () {
18
- nwFile = await nw(
19
- "https://dl.nwjs.io",
20
- "0.83.0",
21
- "sdk",
22
- util.PLATFORM_KV[process.platform],
23
- util.ARCH_KV[process.arch],
24
- "./test/fixture"
25
- );
26
- expect(util.fileExists(nwFile)).resolves.toBe(true);
27
- }, Infinity);
28
- });
@@ -1,15 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- import request from "./request.js";
4
- import util from "./util.js";
5
-
6
- describe.skip("get/request", function () {
7
-
8
- let url = "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"
9
- const filePath = "./test/fixture/cache/request.test.json";
10
-
11
- it("downloads from specific url", async function () {
12
- await request(url, filePath);
13
- expect(util.fileExists(filePath)).resolves.toBe(true);
14
- });
15
- }, Infinity);