1 Star 0 Fork 473

WeBest/多多客(doodooke)微信小程序SaaS平台

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
upgrade.js 2.23 KB
一键复制 编辑 原始数据 按行查看 历史
einsqing 提交于 2020-03-11 16:21 . 修复win兼容性
const axios = require("axios");
const download = require("download");
const ProgressBar = require("progress");
const glob = require("glob");
const semver = require("semver");
async function downloadZip(url, dest, tag) {
const response = await axios({
method: "get",
url: url,
responseType: "stream"
});
const bar = new ProgressBar(
`[doodoo-upgrade] Updating ${tag} [:bar] :rate/bps :percent :etas`,
{
complete: "=",
incomplete: " ",
width: 40,
total: parseInt(response.data.headers["content-length"], 10)
}
);
await download(url, dest, {
extract: true,
filter: file => {
if (/__MACOSX/.test(file.path)) {
return false;
}
return true;
}
}).on("response", res => {
bar.total = res.headers["content-length"];
res.on("data", data => bar.tick(data.length));
});
}
module.exports = async () => {
// 检测升级系统
// TODO
// 检测商业版
const js7Files = glob.sync("**/*.js7", { ignore: ["**/node_modules/**"] });
if (!js7Files.length) {
process.emit("startServer");
return;
}
// 检测升级node
const requestNodeInfo = await axios.get(
"http://upgrade.doodooke.com/node/node.json"
);
const nodeInfo = requestNodeInfo.data;
const nodeLatestVersion = nodeInfo.latest;
if (
!process.env.DOODOO_CORE_VERSION ||
semver.gt(nodeLatestVersion, process.env.DOODOO_CORE_VERSION)
) {
let os;
if (process.platform === "darwin") {
os = "mac";
}
if (process.platform === "linux") {
os = "linux";
}
if (process.platform === "win32") {
os = "win";
}
if (!os) {
throw new Error("如需支持其他操作系统,请联系客服。");
}
console.log("[doodoo-upgrade] 温馨提示:开始升级node,升级完成请重启");
await downloadZip(
`http://upgrade.doodooke.com/node/${nodeLatestVersion}/${os}.zip`,
"./bin",
"Node"
);
process.exit();
}
process.emit("startServer");
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/WeBest/doodoo.git
git@gitee.com:WeBest/doodoo.git
WeBest
doodoo
多多客(doodooke)微信小程序SaaS平台
master

搜索帮助