inferay 0.1.14 → 0.1.16
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 +1 -1
- package/src/cli.js +13 -10
- package/src/releases.js +1 -25
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { install } from "./install.js";
|
|
2
3
|
import { launchApp } from "./launch.js";
|
|
3
4
|
import { doctor } from "./doctor.js";
|
|
4
5
|
import { getChannel, setChannel } from "./config.js";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const { version: VERSION } = require("../package.json");
|
|
9
|
+
const KNOWN_COMMANDS = new Set([
|
|
10
|
+
"help",
|
|
11
|
+
"install",
|
|
12
|
+
"launch",
|
|
13
|
+
"doctor",
|
|
14
|
+
"update",
|
|
15
|
+
"channel",
|
|
16
|
+
"version",
|
|
17
|
+
]);
|
|
7
18
|
|
|
8
19
|
function printHelp() {
|
|
9
20
|
console.log(`inferay ${VERSION}
|
|
@@ -110,13 +121,5 @@ export async function main(argv) {
|
|
|
110
121
|
}
|
|
111
122
|
|
|
112
123
|
function isKnownCommand(command) {
|
|
113
|
-
return
|
|
114
|
-
"help",
|
|
115
|
-
"install",
|
|
116
|
-
"launch",
|
|
117
|
-
"doctor",
|
|
118
|
-
"update",
|
|
119
|
-
"channel",
|
|
120
|
-
"version",
|
|
121
|
-
]).has(command);
|
|
124
|
+
return KNOWN_COMMANDS.has(command);
|
|
122
125
|
}
|
package/src/releases.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { createWriteStream } from "node:fs";
|
|
3
|
-
import { mkdir
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
4
3
|
import { join } from "node:path";
|
|
5
4
|
import { pipeline } from "node:stream/promises";
|
|
6
5
|
import { tmpdir } from "node:os";
|
|
@@ -50,11 +49,6 @@ export function findAsset(release, platform) {
|
|
|
50
49
|
return preferred.map((matcher) => assets.find(matcher)).find(Boolean);
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
function findChecksumAsset(release) {
|
|
54
|
-
const assets = Array.isArray(release.assets) ? release.assets : [];
|
|
55
|
-
return assets.find((asset) => /checksums?\.txt$/i.test(asset.name || ""));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
52
|
export async function downloadAsset(asset) {
|
|
59
53
|
if (!asset?.browser_download_url) {
|
|
60
54
|
throw new Error("release asset is missing a download URL");
|
|
@@ -71,21 +65,3 @@ export async function downloadAsset(asset) {
|
|
|
71
65
|
await pipeline(response.body, createWriteStream(destination));
|
|
72
66
|
return destination;
|
|
73
67
|
}
|
|
74
|
-
|
|
75
|
-
async function sha256(filePath) {
|
|
76
|
-
const hash = createHash("sha256");
|
|
77
|
-
const file = await readFile(filePath);
|
|
78
|
-
hash.update(file);
|
|
79
|
-
return hash.digest("hex");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function verifyChecksum(filePath, expected) {
|
|
83
|
-
if (!expected) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
const actual = await sha256(filePath);
|
|
87
|
-
if (actual !== expected) {
|
|
88
|
-
throw new Error(`checksum mismatch for ${filePath}`);
|
|
89
|
-
}
|
|
90
|
-
return actual;
|
|
91
|
-
}
|