@nwutils/getter 0.1.6 → 0.2.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/package.json +11 -4
- package/src/main.js +21 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwutils/getter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Get NW.js and related binaries for Linux, MacOS and Windows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -37,15 +37,22 @@
|
|
|
37
37
|
"url": "git+https://github.com/nwutils/getter.git"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
+
"lint": "eslint .",
|
|
40
41
|
"test": "node --test --experimental-test-coverage --test-coverage-exclude=\"tests/**/*\" \"tests/specs/*.test.js\""
|
|
41
42
|
},
|
|
42
43
|
"volta": {
|
|
43
|
-
"node": "
|
|
44
|
-
"npm": "11.
|
|
44
|
+
"node": "25.1.0",
|
|
45
|
+
"npm": "11.7.0"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"semver": "^7.7.3",
|
|
48
|
-
"tar": "^7.5.
|
|
49
|
+
"tar": "^7.5.3",
|
|
49
50
|
"yauzl-promise": "^4.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@eslint/js": "^9.39.2",
|
|
54
|
+
"eslint": "^9.39.2",
|
|
55
|
+
"eslint-plugin-jsdoc": "^62.1.0",
|
|
56
|
+
"globals": "^17.0.0"
|
|
50
57
|
}
|
|
51
58
|
}
|
package/src/main.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
4
3
|
import url from "node:url";
|
|
5
4
|
|
|
6
5
|
import semver from "semver";
|
|
@@ -17,9 +16,9 @@ import verify from "./verify.js";
|
|
|
17
16
|
* @property {string | "latest" | "stable" | "lts"} version Runtime version
|
|
18
17
|
* @property {"normal" | "sdk"} flavor Build flavor
|
|
19
18
|
* @property {"linux" | "osx" | "win"} platform Target platform
|
|
20
|
-
* @property {"ia32" | "x64" | "arm64"} arch Target
|
|
21
|
-
* @property {"https://dl.nwjs.io"} downloadUrl Download server
|
|
22
|
-
* @property {"https://nwjs.io/versions.json"} manifestUrl Manifest
|
|
19
|
+
* @property {"ia32" | "x64" | "arm64"} arch Target architecture
|
|
20
|
+
* @property {"https://dl.nwjs.io"} downloadUrl Download server, accepts http and https
|
|
21
|
+
* @property {"https://nwjs.io/versions.json"} manifestUrl Manifest URI, accepts file, http and https
|
|
23
22
|
* @property {string} cacheDir Cache directory
|
|
24
23
|
* @property {boolean} cache If false, remove cache and redownload.
|
|
25
24
|
* @property {boolean} ffmpeg If true, ffmpeg is not downloaded.
|
|
@@ -42,10 +41,18 @@ async function get(options) {
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
const manifestFilePath = path.resolve(options.cacheDir, "manifest.json");
|
|
45
|
-
|
|
44
|
+
if (options.manifestUrl.startsWith('file://')) {
|
|
45
|
+
const filePath = url.fileURLToPath(options.manifestUrl);
|
|
46
|
+
fs.writeFileSync(manifestFilePath, fs.readFileSync(filePath, 'utf-8'));
|
|
47
|
+
} else {
|
|
48
|
+
await request(options.manifestUrl, manifestFilePath);
|
|
49
|
+
}
|
|
46
50
|
const manifestData = JSON.parse(await fs.promises.readFile(manifestFilePath, "utf-8"));
|
|
47
51
|
|
|
48
|
-
if (options.version === "latest"
|
|
52
|
+
if (options.version === "latest"
|
|
53
|
+
|| options.version === "stable"
|
|
54
|
+
|| options.version === "lts"
|
|
55
|
+
) {
|
|
49
56
|
options.version = manifestData[options.version].slice(1);
|
|
50
57
|
} else if (semver.valid(semver.coerce(options.version))) {
|
|
51
58
|
options.version = semver.coerce(options.version).version;
|
|
@@ -73,6 +80,14 @@ async function get(options) {
|
|
|
73
80
|
throw new Error('Expected "options.manifestUrl" to be a string. Received: ' + options.manifestUrl);
|
|
74
81
|
}
|
|
75
82
|
|
|
83
|
+
if (typeof options.manifestUrl == "string"
|
|
84
|
+
&& options.manifestUrl.startsWith('file://') === false
|
|
85
|
+
&& options.manifestUrl.startsWith('http://') === false
|
|
86
|
+
&& options.manifestUrl.startsWith('https://') === false
|
|
87
|
+
) {
|
|
88
|
+
throw new Error('Expected "options.manifestUrl" to be a string starting with "file://", "http://", or "https://". Received: ' + options.manifestUrl);
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
if (typeof options.cacheDir !== "string") {
|
|
77
92
|
throw new Error('Expected "options.cacheDir" to be a string. Received: ' + options.cacheDir);
|
|
78
93
|
}
|