infynon 0.2.2 → 0.2.5
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 +3 -2
- package/postinstall.js +27 -0
- package/run-pkg.js +5 -0
- package/run.js +12 -4
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infynon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Thin npm installer for the proprietary INFYNON CLI binary releases.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"infynon": "run.js",
|
|
7
|
-
"infynon-pkg": "run.js"
|
|
7
|
+
"infynon-pkg": "run-pkg.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postinstall": "node postinstall.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"LICENSE",
|
|
15
15
|
"run.js",
|
|
16
|
+
"run-pkg.js",
|
|
16
17
|
"postinstall.js",
|
|
17
18
|
"preuninstall.js"
|
|
18
19
|
],
|
package/postinstall.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const https = require("https");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
|
+
const { spawnSync } = require("child_process");
|
|
7
8
|
|
|
8
9
|
const REPO = "d4rkNinja/infynon-cli";
|
|
9
10
|
const VERSION = require("./package.json").version;
|
|
@@ -56,6 +57,23 @@ function downloadFile(url, dest, redirects) {
|
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
function verifyBinary() {
|
|
61
|
+
const result = spawnSync(BIN_PATH, ["--version"], {
|
|
62
|
+
encoding: "utf8",
|
|
63
|
+
windowsHide: true,
|
|
64
|
+
});
|
|
65
|
+
if (result.error) {
|
|
66
|
+
throw new Error("Downloaded binary is not executable: " + result.error.message);
|
|
67
|
+
}
|
|
68
|
+
if (result.status !== 0) {
|
|
69
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
70
|
+
throw new Error(
|
|
71
|
+
"Downloaded binary failed verification" +
|
|
72
|
+
(detail ? ": " + detail : " with exit code " + result.status)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
async function main() {
|
|
60
78
|
const info = getTarget();
|
|
61
79
|
|
|
@@ -89,6 +107,15 @@ async function main() {
|
|
|
89
107
|
fs.chmodSync(BIN_PATH, 0o755);
|
|
90
108
|
}
|
|
91
109
|
|
|
110
|
+
try {
|
|
111
|
+
verifyBinary();
|
|
112
|
+
} catch (err) {
|
|
113
|
+
fs.unlink(BIN_PATH, function () {});
|
|
114
|
+
console.error("[infynon] Binary verification failed: " + err.message);
|
|
115
|
+
console.error("[infynon] Reinstall after the release asset is corrected: npm install -g infynon");
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
|
|
92
119
|
console.log("[infynon] Installed successfully. Run: infynon --help");
|
|
93
120
|
}
|
|
94
121
|
|
package/run-pkg.js
ADDED
package/run.js
CHANGED
|
@@ -20,13 +20,21 @@ if (!fs.existsSync(BIN_PATH)) {
|
|
|
20
20
|
process.exit(1);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
function runBinary(args) {
|
|
24
|
+
return spawnSync(BIN_PATH, args, {
|
|
25
|
+
stdio: "inherit",
|
|
26
|
+
windowsHide: false,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const result = runBinary(process.argv.slice(2));
|
|
27
31
|
|
|
28
32
|
if (result.error) {
|
|
29
33
|
console.error("[infynon] Failed to run binary:", result.error.message);
|
|
34
|
+
if (process.platform === "win32" && result.error.code === "UNKNOWN") {
|
|
35
|
+
console.error("[infynon] The installed Windows binary could not be executed.");
|
|
36
|
+
console.error("[infynon] Reinstall to download and verify a fresh release asset: npm install -g infynon");
|
|
37
|
+
}
|
|
30
38
|
process.exit(1);
|
|
31
39
|
}
|
|
32
40
|
|