mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
8a92054c2b
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
console.log("Downloading dist");
|
|
const https = require("https");
|
|
const tar = require("tar");
|
|
|
|
const packageJSON = require("../package.json");
|
|
const fs = require("fs");
|
|
const rmSync = require("./fs-rmSync.js");
|
|
const version = packageJSON.version;
|
|
|
|
const filename = "dist.tar.gz";
|
|
|
|
const url = `https://github.com/louislam/uptime-kuma/releases/download/${version}/${filename}`;
|
|
download(url);
|
|
|
|
/**
|
|
* Downloads the latest version of the dist from a GitHub release.
|
|
* @param {string} url The URL to download from.
|
|
* @returns {void}
|
|
*
|
|
* Generated by Trelent
|
|
*/
|
|
function download(url) {
|
|
console.log(url);
|
|
|
|
https.get(url, (response) => {
|
|
if (response.statusCode === 200) {
|
|
console.log("Extracting dist...");
|
|
|
|
if (fs.existsSync("./dist")) {
|
|
|
|
if (fs.existsSync("./dist-backup")) {
|
|
rmSync("./dist-backup", {
|
|
recursive: true
|
|
});
|
|
}
|
|
|
|
fs.renameSync("./dist", "./dist-backup");
|
|
}
|
|
|
|
const tarStream = tar.x({
|
|
cwd: "./",
|
|
});
|
|
|
|
tarStream.on("close", () => {
|
|
if (fs.existsSync("./dist-backup")) {
|
|
rmSync("./dist-backup", {
|
|
recursive: true
|
|
});
|
|
}
|
|
console.log("Done");
|
|
process.exit(0);
|
|
});
|
|
|
|
tarStream.on("error", () => {
|
|
if (fs.existsSync("./dist-backup")) {
|
|
fs.renameSync("./dist-backup", "./dist");
|
|
}
|
|
console.error("Error from tarStream");
|
|
});
|
|
|
|
response.pipe(tarStream);
|
|
} else if (response.statusCode === 302) {
|
|
download(response.headers.location);
|
|
} else {
|
|
console.log("dist not found");
|
|
}
|
|
});
|
|
}
|