From 8aebfd82d8d1f573eb8b49e3e24245ec5e32a96f Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 26 Oct 2024 16:25:05 +0800 Subject: [PATCH] wip --- docker/debian-base.dockerfile | 2 +- extra/download-apprise.mjs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 extra/download-apprise.mjs diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile index 80550412..cf232425 100644 --- a/docker/debian-base.dockerfile +++ b/docker/debian-base.dockerfile @@ -1,5 +1,5 @@ # If the image changed, the second stage image should be changed too -FROM node:20-bookworm-slim AS base2-slim +FROM node:22-bookworm-slim AS base2-slim ARG TARGETPLATFORM # Specify --no-install-recommends to skip unused dependencies, make the base much smaller! diff --git a/extra/download-apprise.mjs b/extra/download-apprise.mjs new file mode 100644 index 00000000..a8e1695e --- /dev/null +++ b/extra/download-apprise.mjs @@ -0,0 +1,32 @@ +// Go to http://ftp.debian.org/debian/pool/main/a/apprise/ using fetch api, where it is a apache directory listing page +// Use cheerio to parse the html and get the latest version of Apprise +// call curl to download the latest version of Apprise +// Target file: the latest version of Apprise, which the format is apprise_{VERSION}_all.deb + +import * as cheerio from "cheerio"; + +const response = await fetch("http://ftp.debian.org/debian/pool/main/a/apprise/"); + +if (!response.ok) { + throw new Error("Failed to fetch page of Apprise Debian repository."); +} + +const html = await response.text(); + +const $ = cheerio.load(html); + +// Get all the links in the page +const linkElements = $("a"); + +// Filter the links which match apprise_{VERSION}_all.deb +const links = []; + +for (let i = 0; i < linkElements.length; i++) { + const link = linkElements[i]; + if (link.attribs.href.match(/apprise_(.*?)_all.deb/) && !link.attribs.href.includes("~")) { + links.push(link.attribs.href); + } +} + +console.log(links); +// TODO: semver compare and download?