254 Star 1.3K Fork 470

doodooke / 多多客(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");
}
NodeJS
1
https://gitee.com/doodooke/doodoo.git
git@gitee.com:doodooke/doodoo.git
doodooke
doodoo
多多客(doodooke)微信小程序SaaS平台
master

搜索帮助