Skip to content

Commit 82026b6

Browse files
committed
synchronize cli and main
1 parent 47e4a85 commit 82026b6

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

main/bootloader/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ module.exports = {
55
foolHeroku: require("./foolHeroku"),
66
preload: require("./preload"),
77
update: require("./update"),
8+
updateCli: require("./updateCli"),
89
};

main/bootloader/updateCli.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const {execShellCommand} = require("../utils/COMMON");
2+
const axios = require("axios");
3+
4+
module.exports = {
5+
des: "Kiem tra va cap nhat kb2abot-cli",
6+
fn: async () => {
7+
const {data} = await axios.get("https://raw.githubusercontent.com/kb2abot/kb2abot-cli/main/package.json");
8+
const {version} = data;
9+
let currentVersion;
10+
try {
11+
currentVersion = await execShellCommand("kb2abot-cli -v");
12+
}
13+
catch (e) {
14+
currentVersion = e.message;
15+
}
16+
if (currentVersion != version) {
17+
await execShellCommand("npm i kb2abot-cli@latest -g");
18+
}
19+
}
20+
};

main/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ globalThis.kb2abot = Object.assign(k2babotGlobalModel, {
2727
/////////////////////////////////////////////////////
2828

2929

30-
const {cli, checkInternet, checkNode, foolHeroku, preload, update} = require("./bootloader");
30+
const {
31+
cli,
32+
checkInternet,
33+
checkNode,
34+
foolHeroku,
35+
preload,
36+
update,
37+
updateCli
38+
} = require("./bootloader");
3139
const botsDir = path.join(__dirname, "../bots");
3240
const deployPath = path.join(__dirname, "./deploy/index.js");
3341

3442
const tasks = [];
3543
const isDev = process.argv.slice(2)[0] == "dev";
3644
tasks.push(checkInternet);
3745
!isDev && tasks.push(update);
46+
tasks.push(updateCli);
3847
tasks.push(foolHeroku);
3948
tasks.push(checkNode);
4049
tasks.push(preload);

0 commit comments

Comments
 (0)