nw 0.88.0 → 0.89.0-sdk
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 +2 -2
- package/package.json +7 -5
- package/src/decompress.test.js +45 -17
- package/src/parse.js +3 -20
- package/src/postinstall.js +1 -1
- package/src/request.js +1 -1
- package/src/request.test.js +5 -15
- package/src/run.js +1 -1
- package/src/util.js +13 -4
package/README.md
CHANGED
|
@@ -90,14 +90,14 @@ Executing `npm start` runs the NW.js app. Omitting the file path makes NW.js che
|
|
|
90
90
|
|
|
91
91
|
``` js
|
|
92
92
|
import { findpath } from 'nw';
|
|
93
|
-
|
|
93
|
+
let path = await findpath();
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
## Find the path to the chromedriver binary
|
|
97
97
|
|
|
98
98
|
``` js
|
|
99
99
|
import { findpath } from 'nw';
|
|
100
|
-
|
|
100
|
+
let path = await findpath('chromedriver', { flavor: 'sdk' });
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
## Download specific versions independant of installer version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0-sdk",
|
|
4
4
|
"description": "An installer for nw.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"postinstall": "node src/postinstall.js",
|
|
16
16
|
"test": "vitest run",
|
|
17
|
+
"test:cov": "vitest --coverage.enabled true",
|
|
17
18
|
"demo": "nw ./test/app --log-level=verbose"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
@@ -33,10 +34,10 @@
|
|
|
33
34
|
],
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"axios": "^1.7.
|
|
37
|
+
"axios": "^1.7.2",
|
|
37
38
|
"commander": "^12.1.0",
|
|
38
39
|
"semver": "^7.6.2",
|
|
39
|
-
"tar": "^7.
|
|
40
|
+
"tar": "^7.4.0",
|
|
40
41
|
"yauzl-promise": "^4.0.0"
|
|
41
42
|
},
|
|
42
43
|
"keywords": [
|
|
@@ -52,7 +53,8 @@
|
|
|
52
53
|
"application"
|
|
53
54
|
],
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"
|
|
56
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
57
|
+
"selenium-webdriver": "^4.22.0",
|
|
56
58
|
"vitest": "^1.6.0"
|
|
57
59
|
}
|
|
58
|
-
}
|
|
60
|
+
}
|
package/src/decompress.test.js
CHANGED
|
@@ -1,27 +1,55 @@
|
|
|
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 { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
4
6
|
|
|
7
|
+
import * as nw from "../src/index.js";
|
|
5
8
|
import decompress from "./decompress.js";
|
|
6
|
-
import
|
|
9
|
+
import util from './util.js';
|
|
7
10
|
|
|
8
|
-
describe("get/decompress", function () {
|
|
11
|
+
describe("get/decompress", async function () {
|
|
9
12
|
|
|
10
|
-
let
|
|
11
|
-
let
|
|
13
|
+
let nwFilePath = '';
|
|
14
|
+
let nwDirPath = '';
|
|
15
|
+
let nwOutPath = "./test/fixture/cache";
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
await fs.promises.
|
|
15
|
-
|
|
16
|
-
await request(tarUrl, "./test/fixture/cache/nw.tar.gz");
|
|
17
|
-
await request(zipUrl, "./test/fixture/cache/nw.zip");
|
|
18
|
-
}, Infinity);
|
|
17
|
+
afterAll(async function () {
|
|
18
|
+
await fs.promises.rm(nwOutPath, { recursive: true, force: true });
|
|
19
|
+
});
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
await
|
|
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);
|
|
22
38
|
}, Infinity);
|
|
23
39
|
|
|
24
|
-
it("
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
});
|
package/src/parse.js
CHANGED
|
@@ -24,8 +24,8 @@ import util from '../src/util.js';
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Parse options.
|
|
27
|
-
*
|
|
28
|
-
* @param {ParseOptions} options
|
|
27
|
+
*
|
|
28
|
+
* @param {ParseOptions} options
|
|
29
29
|
* @return {Promise<ParseOptions>}
|
|
30
30
|
*/
|
|
31
31
|
export default async function parse(options) {
|
|
@@ -45,27 +45,10 @@ export default async function parse(options) {
|
|
|
45
45
|
parsedVersion.minor,
|
|
46
46
|
parsedVersion.patch
|
|
47
47
|
].join('.');
|
|
48
|
-
|
|
49
48
|
options.flavor = options.flavor || process.env.npm_config_nwjs_build_type || process.env.NWJS_BUILD_TYPE || 'normal';
|
|
50
|
-
|
|
51
|
-
/* Check if version is a prelease. */
|
|
52
|
-
if (typeof parsedVersion?.prerelease?.[0] === 'string') {
|
|
53
|
-
let prerelease = parsedVersion.prerelease[0].split('-');
|
|
54
|
-
if (prerelease.length > 1) {
|
|
55
|
-
prerelease = prerelease.slice(0, -1);
|
|
56
|
-
}
|
|
57
|
-
options.version = [options.version, ...prerelease].join('-');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* Check build flavor and slice that off the `version`. */
|
|
61
|
-
if (options.version.endsWith('-sdk')) {
|
|
62
|
-
options.version = options.version.slice(0, -4);
|
|
63
|
-
options.flavor = 'sdk';
|
|
64
|
-
} else if (options.version.endsWith('sdk')) {
|
|
65
|
-
options.version = version.slice(0, -3);
|
|
49
|
+
if (String(parsedVersion?.prerelease[0]).endsWith('sdk')) {
|
|
66
50
|
options.flavor = 'sdk';
|
|
67
51
|
}
|
|
68
|
-
|
|
69
52
|
options.platform = options.platform || util.PLATFORM_KV[process.env.npm_config_nwjs_platform || process.env.NWJS_PLATFORM || process.platform];
|
|
70
53
|
options.arch = options.arch || util.ARCH_KV[process.env.npm_config_nwjs_process_arch || process.env.NWJS_ARCH || process.arch];
|
|
71
54
|
options.downloadUrl = options.downloadUrl || process.env.npm_config_nwjs_urlbase || process.env.NWJS_URLBASE || 'https://dl.nwjs.io';
|
package/src/postinstall.js
CHANGED
|
@@ -45,7 +45,7 @@ async function postinstall() {
|
|
|
45
45
|
*/
|
|
46
46
|
const prerelease = String(parsedVersion?.prerelease[0]);
|
|
47
47
|
/* Check build flavor and slice that off the `version`. */
|
|
48
|
-
if (prerelease.endsWith('
|
|
48
|
+
if (prerelease.endsWith('sdk')) {
|
|
49
49
|
flavor = 'sdk';
|
|
50
50
|
}
|
|
51
51
|
|
package/src/request.js
CHANGED
package/src/request.test.js
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
4
2
|
|
|
5
3
|
import request from "./request.js";
|
|
6
4
|
import util from "./util.js";
|
|
7
5
|
|
|
8
|
-
describe("get/request", function () {
|
|
6
|
+
describe.skip("get/request", function () {
|
|
9
7
|
|
|
10
8
|
let url = "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"
|
|
11
|
-
const filePath = "./test/fixture/request.test.json";
|
|
12
|
-
|
|
13
|
-
afterEach(async function () {
|
|
14
|
-
await fs.promises.rm(filePath, { force: true });
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
beforeAll(async function () {
|
|
18
|
-
await fs.promises.mkdir('./test/fixture', { recursive: true });
|
|
19
|
-
});
|
|
9
|
+
const filePath = "./test/fixture/cache/request.test.json";
|
|
20
10
|
|
|
21
11
|
it("downloads from specific url", async function () {
|
|
22
12
|
await request(url, filePath);
|
|
23
13
|
expect(util.fileExists(filePath)).resolves.toBe(true);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
14
|
+
});
|
|
15
|
+
}, Infinity);
|
package/src/run.js
CHANGED
package/src/util.js
CHANGED
|
@@ -43,21 +43,28 @@ const EXE_NAME = {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Get the platform dependant path of the NW.js or ChromeDriver binary.
|
|
46
|
-
*
|
|
47
|
-
* @param {'nwjs' | 'chromedriver'}
|
|
46
|
+
*
|
|
47
|
+
* @param {'nwjs' | 'chromedriver' | 'all'} Path to NW.js or Chromedriver executable.
|
|
48
48
|
* @return {Promise<string>}
|
|
49
49
|
*/
|
|
50
50
|
async function findpath(executable = 'nwjs', options = {}) {
|
|
51
51
|
options = await parse(options);
|
|
52
52
|
const nwDir = path.resolve(__dirname, '..', `nwjs${options.flavor === "sdk" ? "-sdk" : ""}-v${options.version}-${options.platform}-${options.arch}`);
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
/**
|
|
55
55
|
* File path to executable.
|
|
56
|
-
*
|
|
56
|
+
*
|
|
57
57
|
* @type {string}
|
|
58
58
|
*/
|
|
59
59
|
let binPath = '';
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Get the platform dependant path of the NW.js directory containing everything.
|
|
63
|
+
*/
|
|
64
|
+
function findDir() {
|
|
65
|
+
binPath = nwDir;
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
/**
|
|
62
69
|
* Get the platform dependant path of the NW.js binary.
|
|
63
70
|
*/
|
|
@@ -76,6 +83,8 @@ async function findpath(executable = 'nwjs', options = {}) {
|
|
|
76
83
|
findNwjs();
|
|
77
84
|
} else if (executable === 'chromedriver') {
|
|
78
85
|
findChromeDriver();
|
|
86
|
+
} else if (executable === 'all') {
|
|
87
|
+
findDir();
|
|
79
88
|
} else {
|
|
80
89
|
console.error(`[ ERROR ] Expected nwjs or chromedriver, got ${executable}.`);
|
|
81
90
|
}
|