Skip to content

Commit

Permalink
feat: print version of installed converters to log
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed Jun 27, 2024
1 parent fae2ba9 commit 801cf28
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
75 changes: 75 additions & 0 deletions src/helpers/printVersions.ts
Original file line number Diff line number Diff line change
@@ -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]);
}
});
}
5 changes: 3 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down

0 comments on commit 801cf28

Please sign in to comment.