1 Star 0 Fork 473

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
upgrade.js 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
einsqing 提交于 2020-04-02 10:25 . jsdelivr
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(
"https://cdn.jsdelivr.net/gh/doodooke/node@master/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(
`https://cdn.jsdelivr.net/gh/doodooke/node@master/${nodeLatestVersion}/${os}.zip`,
"./bin",
"Node"
);
process.exit();
}
process.emit("startServer");
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/fhb1020/doodoo.git
git@gitee.com:fhb1020/doodoo.git
fhb1020
doodoo
多多客(doodooke)微信小程序SaaS平台
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385