nw-builder 4.8.0 → 4.9.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/README.md +0 -1
- package/package.json +9 -11
- package/src/bld.js +14 -18
- package/src/get/index.js +8 -1
- package/src/get/verify.js +48 -0
- package/src/get/verify.test.js +15 -0
- package/src/postinstall.js +0 -5
package/README.md
CHANGED
|
@@ -386,7 +386,6 @@ nwbuild({
|
|
|
386
386
|
### Chores
|
|
387
387
|
|
|
388
388
|
- chore(docs): don't store JSDoc definitions in `typedef`s - get's hard to understand during development.
|
|
389
|
-
- chore(get): verify sha checksum for downloads
|
|
390
389
|
- chore: annotate file paths as `fs.PathLike` instead of `string`.
|
|
391
390
|
- chore(bld): factor out core build step
|
|
392
391
|
- chore(bld): factor out linux config
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
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
|
|
12
|
+
"name": "Steffen MÃÂÃÂÃÂüller",
|
|
13
13
|
"url": "https://www.mllrsohn.com/"
|
|
14
14
|
},
|
|
15
15
|
"maintainers": [
|
|
@@ -52,26 +52,24 @@
|
|
|
52
52
|
"license-check": "jsgl --local ."
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@stylistic/eslint-plugin-js": "^2.
|
|
56
|
-
"@vitest/coverage-v8": "^2.0.
|
|
55
|
+
"@stylistic/eslint-plugin-js": "^2.6.2",
|
|
56
|
+
"@vitest/coverage-v8": "^2.0.5",
|
|
57
57
|
"base-volta-off-of-nwjs": "^1.0.5",
|
|
58
|
-
"eslint": "^9.
|
|
58
|
+
"eslint": "^9.9.0",
|
|
59
59
|
"eslint-config-tjw-jsdoc": "^1.0.5",
|
|
60
|
-
"eslint-plugin-jsdoc": "^
|
|
60
|
+
"eslint-plugin-jsdoc": "^50.2.2",
|
|
61
61
|
"eslint-plugin-markdown": "^5.0.0",
|
|
62
62
|
"js-green-licenses": "^4.0.0",
|
|
63
63
|
"jsdoc": "^4.0.3",
|
|
64
|
-
"nw": "^0.
|
|
65
|
-
"patch-package": "^8.0.0",
|
|
64
|
+
"nw": "^0.90.0",
|
|
66
65
|
"selenium-webdriver": "^4.23.0",
|
|
67
66
|
"vitest": "^2.0.4"
|
|
68
67
|
},
|
|
69
68
|
"dependencies": {
|
|
70
69
|
"archiver": "^7.0.1",
|
|
71
|
-
"axios": "^1.7.
|
|
72
|
-
"cli-progress": "^3.12.0",
|
|
70
|
+
"axios": "^1.7.4",
|
|
73
71
|
"glob": "^11.0.0",
|
|
74
|
-
"node-gyp": "^10.
|
|
72
|
+
"node-gyp": "^10.2.0",
|
|
75
73
|
"plist": "^3.1.0",
|
|
76
74
|
"resedit": "^2.0.2",
|
|
77
75
|
"semver": "^7.6.3",
|
package/src/bld.js
CHANGED
|
@@ -230,21 +230,19 @@ const manageManifest = async ({ nwPkg, managedManifest, outDir, platform }) => {
|
|
|
230
230
|
"utf8",
|
|
231
231
|
);
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
: "nwjs.app/Contents/Resources/app.nw",
|
|
239
|
-
),
|
|
233
|
+
const cwd = path.resolve(
|
|
234
|
+
outDir,
|
|
235
|
+
platform !== "osx"
|
|
236
|
+
? "package.nw"
|
|
237
|
+
: "nwjs.app/Contents/Resources/app.nw",
|
|
240
238
|
);
|
|
241
239
|
|
|
242
240
|
if (manifest.packageManager.startsWith("npm")) {
|
|
243
|
-
child_process.execSync(`npm install
|
|
241
|
+
child_process.execSync(`npm install`, { cwd });
|
|
244
242
|
} else if (manifest.packageManager.startsWith("yarn")) {
|
|
245
|
-
child_process.execSync(`yarn install
|
|
243
|
+
child_process.execSync(`yarn install`, { cwd });
|
|
246
244
|
} else if (manifest.packageManager.startsWith("pnpm")) {
|
|
247
|
-
child_process.execSync(`pnpm install
|
|
245
|
+
child_process.execSync(`pnpm install`, { cwd });
|
|
248
246
|
}
|
|
249
247
|
};
|
|
250
248
|
|
|
@@ -420,16 +418,14 @@ const setOsxConfig = async ({ outDir, app }) => {
|
|
|
420
418
|
|
|
421
419
|
const buildNativeAddon = ({ cacheDir, version, platform, arch, outDir, nodeVersion }) => {
|
|
422
420
|
let nodePath = path.resolve(cacheDir, `node-v${version}-${platform}-${arch}`);
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
: "nwjs.app/Contents/Resources/app.nw",
|
|
429
|
-
),
|
|
421
|
+
const cwd = path.resolve(
|
|
422
|
+
outDir,
|
|
423
|
+
platform !== "osx"
|
|
424
|
+
? "package.nw"
|
|
425
|
+
: "nwjs.app/Contents/Resources/app.nw",
|
|
430
426
|
);
|
|
431
427
|
|
|
432
|
-
child_process.execSync(`node-gyp rebuild --target=${nodeVersion} --nodedir=${nodePath}
|
|
428
|
+
child_process.execSync(`node-gyp rebuild --target=${nodeVersion} --nodedir=${nodePath}`, { cwd });
|
|
433
429
|
};
|
|
434
430
|
|
|
435
431
|
const compress = async ({
|
package/src/get/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import decompress from "./decompress.js";
|
|
|
6
6
|
import ffmpeg from "./ffmpeg.js";
|
|
7
7
|
import node from "./node.js";
|
|
8
8
|
import nw from "./nw.js";
|
|
9
|
+
import verify from './verify.js';
|
|
9
10
|
|
|
10
11
|
import util from "../util.js";
|
|
11
12
|
|
|
@@ -24,7 +25,7 @@ import util from "../util.js";
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Get binaries.
|
|
27
|
-
*
|
|
28
|
+
*
|
|
28
29
|
* @deprecated since v4.6.4. This logic will be ported over to `nwjs/npm-installer` repo and removed in the next major release (v5.0).
|
|
29
30
|
*
|
|
30
31
|
* @async
|
|
@@ -133,6 +134,12 @@ async function get(options) {
|
|
|
133
134
|
|
|
134
135
|
await decompress(ffmpegFilePath, options.cacheDir);
|
|
135
136
|
|
|
137
|
+
await verify(
|
|
138
|
+
`${options.downloadUrl}/v${options.version}/SHASUMS256.txt`,
|
|
139
|
+
`${options.cacheDir}/shasum/${options.version}.txt`,
|
|
140
|
+
options.cacheDir,
|
|
141
|
+
);
|
|
142
|
+
|
|
136
143
|
/**
|
|
137
144
|
* Platform dependant file name of FFmpeg binary.
|
|
138
145
|
*
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
|
|
7
|
+
import util from '../util.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Verify the SHA256 checksum of downloaded artifacts.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} shaUrl - URL to get the shasum text file from.
|
|
13
|
+
* @param {string} shaOut - File path to shasum text file.
|
|
14
|
+
* @param {string} cacheDir - File path to cache directory.
|
|
15
|
+
* @throws {Error}
|
|
16
|
+
* @returns {Promise<boolean>}
|
|
17
|
+
*/
|
|
18
|
+
export default async function verify(shaUrl, shaOut, cacheDir) {
|
|
19
|
+
const shaOutExists = await util.fileExists(shaOut);
|
|
20
|
+
|
|
21
|
+
if (shaOutExists === false) {
|
|
22
|
+
/* Create directory if does not exist. */
|
|
23
|
+
await fs.promises.mkdir(path.dirname(shaOut), { recursive: true });
|
|
24
|
+
|
|
25
|
+
/* Download SHASUM text file. */
|
|
26
|
+
await request(shaUrl, shaOut);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Read SHASUM text file */
|
|
30
|
+
const shasum = await fs.promises.readFile(shaOut, { encoding: 'utf-8' });
|
|
31
|
+
const shasums = shasum.trim().split('\n');
|
|
32
|
+
for await (const line of shasums) {
|
|
33
|
+
const [storedSha, filePath] = line.split(' ');
|
|
34
|
+
const relativeFilePath = path.resolve(cacheDir, filePath);
|
|
35
|
+
const relativefilePathExists = await util.fileExists(relativeFilePath);
|
|
36
|
+
if (relativefilePathExists) {
|
|
37
|
+
const fileBuffer = await fs.promises.readFile(relativeFilePath);
|
|
38
|
+
const hash = crypto.createHash('sha256');
|
|
39
|
+
hash.update(fileBuffer);
|
|
40
|
+
const generatedSha = hash.digest('hex');
|
|
41
|
+
if (storedSha !== generatedSha) {
|
|
42
|
+
throw new Error('SHA256 checksums do not match.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import verify from "./verify.js";
|
|
4
|
+
|
|
5
|
+
describe("get/verify", function () {
|
|
6
|
+
|
|
7
|
+
it("verify shasums", async function () {
|
|
8
|
+
const status = await verify(
|
|
9
|
+
'https://dl.nwjs.io/v0.90.0/SHASUMS256.txt',
|
|
10
|
+
'./node_modules/nw/shasum/0.90.0.txt',
|
|
11
|
+
'./node_modules/nw'
|
|
12
|
+
);
|
|
13
|
+
expect(status).toBe(true);
|
|
14
|
+
}, Infinity);
|
|
15
|
+
});
|
package/src/postinstall.js
CHANGED
|
@@ -6,13 +6,8 @@ import url from 'node:url';
|
|
|
6
6
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
7
7
|
|
|
8
8
|
const baseVoltaPath = path.resolve(path.join(__dirname, '..', 'node_modules', 'base-volta-off-of-nwjs', 'index.js'));
|
|
9
|
-
const patchPackagePath = path.resolve(path.join(__dirname, '..', 'node_modules', 'patch-package'));
|
|
10
9
|
|
|
11
10
|
/* Execute the script in development mode only since it is used during testing */
|
|
12
11
|
if (fs.existsSync(baseVoltaPath)) {
|
|
13
12
|
child_process.execSync('node ' + baseVoltaPath);
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
if (fs.existsSync(patchPackagePath)) {
|
|
17
|
-
child_process.execSync('node ' + patchPackagePath);
|
|
18
|
-
}
|