forked from louislam/uptime-kuma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script for downloading the dist files from github
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ dist-ssr | |
|
||
/private | ||
/out | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
console.log("Downloading dist"); | ||
const https = require("https"); | ||
const tar = require("tar"); | ||
|
||
const packageJSON = require("../package.json"); | ||
const fs = require("fs"); | ||
const version = packageJSON.version; | ||
|
||
const filename = "dist.tar.gz"; | ||
|
||
const url = `https://github.com/louislam/uptime-kuma/releases/download/${version}/${filename}`; | ||
download(url); | ||
|
||
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")) { | ||
fs.rmdirSync("./dist-backup", { | ||
recursive: true | ||
}); | ||
} | ||
|
||
fs.renameSync("./dist", "./dist-backup"); | ||
} | ||
|
||
const tarStream = tar.x({ | ||
cwd: "./", | ||
}); | ||
|
||
tarStream.on("close", () => { | ||
fs.rmdirSync("./dist-backup", { | ||
recursive: true | ||
}); | ||
console.log("Done"); | ||
}); | ||
|
||
tarStream.on("error", () => { | ||
if (fs.existsSync("./dist-backup")) { | ||
fs.renameSync("./dist-backup", "./dist"); | ||
} | ||
console.log("Done"); | ||
}); | ||
|
||
response.pipe(tarStream); | ||
} else if (response.statusCode === 302) { | ||
download(response.headers.location); | ||
} else { | ||
console.log("dist not found"); | ||
} | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters