From 801cf28d1e5edac9353b0b16be75a4fb48470b8a Mon Sep 17 00:00:00 2001 From: C4illin Date: Fri, 28 Jun 2024 00:05:21 +0200 Subject: [PATCH] feat: print version of installed converters to log --- Dockerfile | 1 + src/helpers/printVersions.ts | 75 ++++++++++++++++++++++++++++++++++++ src/index.tsx | 5 ++- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/helpers/printVersions.ts diff --git a/Dockerfile b/Dockerfile index ea4c124..0bc81a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,4 +51,5 @@ COPY --from=install /temp/prod/node_modules node_modules COPY . . EXPOSE 3000/tcp +ENV NODE_ENV=production ENTRYPOINT [ "bun", "run", "./src/index.tsx" ] \ No newline at end of file diff --git a/src/helpers/printVersions.ts b/src/helpers/printVersions.ts new file mode 100644 index 0000000..ec42f61 --- /dev/null +++ b/src/helpers/printVersions.ts @@ -0,0 +1,75 @@ +import { exec } from "node:child_process"; +import { version } from "../../package.json"; +console.log(`ConvertX v${version}`); + +if (process.env.NODE_ENV === "production") { + exec("cat /etc/os-release", (error, stdout) => { + if (error) { + console.error("Not running on docker, this is not supported."); + } + + if (stdout) { + console.log(stdout.split('PRETTY_NAME="')[1]?.split('"')[0]); + } + }); + + exec("pandoc -v", (error, stdout) => { + if (error) { + console.error("Pandoc is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); + + exec("ffmpeg -version", (error, stdout) => { + if (error) { + console.error("FFmpeg is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); + + exec("vips -v", (error, stdout) => { + if (error) { + console.error("Vips is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); + + exec("gm version", (error, stdout) => { + if (error) { + console.error("GraphicsMagick is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); + + exec("djxl --version", (error, stdout) => { + if (error) { + console.error("libjxl-tools is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); + + exec("xelatex -version", (error, stdout) => { + if (error) { + console.error("Tex Live with XeTeX is not installed."); + } + + if (stdout) { + console.log(stdout.split("\n")[0]); + } + }); +} diff --git a/src/index.tsx b/src/index.tsx index 6a29034..47b82d3 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -19,9 +19,10 @@ import { normalizeFiletype, normalizeOutputFiletype, } from "./helpers/normalizeFiletype"; +import "./helpers/printVersions"; + + -import { version } from "../package.json"; -console.log(`ConvertX v${version}`); const db = new Database("./data/mydb.sqlite", { create: true }); const uploadsDir = "./data/uploads/";