Skip to content

Commit

Permalink
add script for downloading the dist files from github
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Oct 2, 2021
1 parent c93f427 commit 2625cbe
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CNAME
install.sh
SECURITY.md
tsconfig.json

/tmp

### .gitignore content (commented rules are duplicated)

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist-ssr

/private
/out
/tmp
57 changes: 57 additions & 0 deletions extra/download-dist.js
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");
}
});
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"build-docker-nightly-alpine": "docker buildx build -f dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly-alpine --target nightly . --push",
"build-docker-nightly-amd64": "docker buildx build --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
"upload-artifacts": "docker buildx build --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
"setup": "git checkout 1.7.3 && npm install --legacy-peer-deps && node node_modules/esbuild/install.js && npm run build && npm prune",
"setup": "git checkout 1.7.3 && npm ci --production && npm run download-dist",
"download-dist": "node extra/download-dist.js",
"update-version": "node extra/update-version.js",
"mark-as-nightly": "node extra/mark-as-nightly.js",
"reset-password": "node extra/reset-password.js",
Expand Down Expand Up @@ -77,6 +78,7 @@
"redbean-node": "0.1.2",
"socket.io": "~4.2.0",
"socket.io-client": "~4.2.0",
"tar": "^6.1.11",
"tcp-ping": "~0.1.1",
"thirty-two": "~1.0.2",
"timezones-list": "~3.0.1",
Expand Down

0 comments on commit 2625cbe

Please sign in to comment.