invgate-cli 0.3.0 → 0.3.2
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/{install.js → cli.js} +11 -5
- package/package.json +7 -4
package/{install.js → cli.js}
RENAMED
|
@@ -7,8 +7,10 @@ const https = require("https");
|
|
|
7
7
|
|
|
8
8
|
const BIN = "invgate-cli" + (platform() === "win32" ? ".exe" : "");
|
|
9
9
|
const RELEASES = "https://github.com/wdelcant/invgate-cli/releases";
|
|
10
|
+
const { writeFileSync, readFileSync } = require("fs");
|
|
10
11
|
const DIR = join(homedir(), ".invgate", "bin");
|
|
11
12
|
const BIN_PATH = join(DIR, BIN);
|
|
13
|
+
const VER_PATH = join(DIR, ".version");
|
|
12
14
|
|
|
13
15
|
async function getLatestVersion() {
|
|
14
16
|
return new Promise((resolve, reject) => {
|
|
@@ -48,20 +50,23 @@ async function download(url, dest) {
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
async function main() {
|
|
51
|
-
|
|
53
|
+
const latestVer = await getLatestVersion();
|
|
54
|
+
let currentVer = "";
|
|
55
|
+
try { currentVer = readFileSync(VER_PATH, "utf8").trim(); } catch {}
|
|
56
|
+
|
|
57
|
+
if (existsSync(BIN_PATH) && currentVer === latestVer) {
|
|
52
58
|
try {
|
|
53
59
|
execSync(`"${BIN_PATH}"`, { stdio: "inherit" });
|
|
54
60
|
return;
|
|
55
61
|
} catch {}
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const url = `${RELEASES}/download/v${version}/${asset}`;
|
|
64
|
+
const asset = getAssetName(latestVer);
|
|
65
|
+
const url = `${RELEASES}/download/v${latestVer}/${asset}`;
|
|
61
66
|
const tmp = join(DIR, asset);
|
|
62
67
|
|
|
63
68
|
mkdirSync(DIR, { recursive: true });
|
|
64
|
-
console.error(`Downloading invgate-cli v${
|
|
69
|
+
console.error(`Downloading invgate-cli v${latestVer} for ${platform()}/${process.arch}...`);
|
|
65
70
|
await download(url, tmp);
|
|
66
71
|
|
|
67
72
|
if (asset.endsWith(".zip")) {
|
|
@@ -71,6 +76,7 @@ async function main() {
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
try { require("fs").unlinkSync(tmp); } catch {}
|
|
79
|
+
writeFileSync(VER_PATH, latestVer);
|
|
74
80
|
|
|
75
81
|
execSync(`"${BIN_PATH}"`, { stdio: "inherit" });
|
|
76
82
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "invgate-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Runtime OpenAPI/Swagger CLI for InvGate Asset Management",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/wdelcant/invgate-cli.git"
|
|
9
|
+
},
|
|
7
10
|
"bin": {
|
|
8
|
-
"invgate-cli": "
|
|
11
|
+
"invgate-cli": "cli.js"
|
|
9
12
|
},
|
|
10
13
|
"files": [
|
|
11
|
-
"
|
|
14
|
+
"cli.js"
|
|
12
15
|
],
|
|
13
16
|
"os": ["darwin", "linux", "win32"],
|
|
14
17
|
"cpu": ["x64", "arm64"]
|