Files
ConvertX/src/helpers/printVersions.ts
T

216 lines
5.0 KiB
TypeScript
Raw Normal View History

import { exec } from "node:child_process";
import { readFile } from "node:fs";
import { version } from "../../package.json";
2025-02-18 20:05:46 +01:00
console.log(`ConvertX v${version}`);
if (process.env.NODE_ENV === "production") {
readFile("/etc/os-release", "utf8", (error, stdout) => {
if (error) {
console.error("Not running on docker, this is not supported.");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
console.log(stdout.split('PRETTY_NAME="')[1]?.split('"')[0]);
}
});
exec("pandoc -v", (error, stdout) => {
if (error) {
console.error("Pandoc is not installed.");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`pandoc v${stdout.match(/pandoc ([\d.]+)/)?.[1] || "unknown"}`);
}
});
exec("ffmpeg -version", (error, stdout) => {
if (error) {
console.error("FFmpeg is not installed.");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`FFmpeg v${stdout.match(/version ([\w+.-]+)/)?.[1] || "unknown"}`);
}
});
exec("vips -v", (error, stdout) => {
if (error) {
console.error("Vips is not installed.");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`Vips v${stdout.match(/vips-([\d.]+)/)?.[1] || "unknown"}`);
}
});
2025-05-23 21:18:47 +02:00
exec("magick --version", (error, stdout) => {
if (error) {
console.error("ImageMagick is not installed.");
2026-08-19 21:45:07 +02:00
return;
2025-05-23 21:18:47 +02:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`ImageMagick v${stdout.match(/ImageMagick ([\d.-]+)/)?.[1] || "unknown"}`);
2025-05-23 21:18:47 +02:00
}
});
exec("gm version", (error, stdout) => {
if (error) {
console.error("GraphicsMagick is not installed.");
2026-08-19 21:45:07 +02:00
return;
}
2024-11-16 11:34:47 +01:00
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`GraphicsMagick v${stdout.match(/GraphicsMagick ([\d.]+)/)?.[1] || "unknown"}`);
2024-11-16 11:34:47 +01:00
}
});
exec("inkscape --version", (error, stdout) => {
if (error) {
console.error("Inkscape is not installed.");
2026-08-19 21:45:07 +02:00
return;
2024-11-16 11:34:47 +01:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`Inkscape v${stdout.match(/Inkscape ([\d.]+)/)?.[1] || "unknown"}`);
}
});
exec("djxl --version", (error, stdout) => {
if (error) {
console.error("libjxl-tools is not installed.");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`djxl v${stdout.match(/(?:v)?([\d.]+)/)?.[1] || "unknown"}`);
}
});
2026-08-19 21:45:07 +02:00
exec("dasel version", (error, stdout) => {
2025-09-09 00:18:26 +01:00
if (error) {
console.error("dasel is not installed.");
2026-08-19 21:45:07 +02:00
return;
2025-09-09 00:18:26 +01:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
const ver = stdout.replace("dasel", "").trim().split(/\s+/)[0] || "unknown";
console.log(`dasel ${ver}`);
2025-09-09 00:18:26 +01:00
}
});
exec("xelatex -version", (error, stdout) => {
if (error) {
console.error("Tex Live with XeTeX is not installed.");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`XeTeX v${stdout.match(/XeTeX ([\d.-]+)/)?.[1] || "unknown"}`);
}
});
2024-08-23 19:14:06 +02:00
exec("resvg -V", (error, stdout) => {
if (error) {
console.error("resvg is not installed");
2026-08-19 21:45:07 +02:00
return;
2024-08-23 19:14:06 +02:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`resvg v${(stdout.split("\n")[0] ?? "").trim().replace(/^v/, "")}`);
2024-08-23 19:14:06 +02:00
}
});
exec("assimp version", (error, stdout) => {
if (error) {
console.error("assimp is not installed");
2026-08-19 21:45:07 +02:00
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
const match = stdout.match(/Version ([\d.]+)/i);
console.log(`assimp v${match?.[1] || "unknown"}`);
}
});
2024-12-07 02:38:30 +01:00
exec("ebook-convert --version", (error, stdout) => {
if (error) {
console.error("ebook-convert (calibre) is not installed");
2026-08-19 21:45:07 +02:00
return;
2024-12-07 02:38:30 +01:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`ebook-convert v${stdout.match(/calibre ([\d.]+)/)?.[1] || "unknown"}`);
2024-12-07 02:38:30 +01:00
}
});
2025-02-18 20:05:46 +01:00
exec("heif-info -v", (error, stdout) => {
if (error) {
console.error("libheif is not installed");
2026-08-19 21:45:07 +02:00
return;
2025-02-18 20:05:46 +01:00
}
if (stdout) {
console.log(`libheif v${stdout.split("\n")[0]}`);
}
});
2025-05-05 21:03:53 -05:00
exec("potrace -v", (error, stdout) => {
if (error) {
console.error("potrace is not installed");
2026-08-19 21:45:07 +02:00
return;
2025-05-05 21:03:53 -05:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
const ver = stdout.match(/potrace ([\d.]+)/)?.[1]?.replace(/\.$/, "") || "unknown";
console.log(`potrace v${ver}`);
2025-05-05 21:03:53 -05:00
}
});
2025-06-26 04:01:47 +02:00
exec("soffice --version", (error, stdout) => {
if (error) {
console.error("libreoffice is not installed");
2026-08-19 21:45:07 +02:00
return;
2025-06-26 04:01:47 +02:00
}
if (stdout) {
2026-10-06 17:45:45 +02:00
console.log(`LibreOffice v${stdout.match(/LibreOffice ([\d.]+)/)?.[1] || "unknown"}`);
2025-06-26 04:01:47 +02:00
}
});
2026-08-19 21:45:07 +02:00
// msgconvert has no version flag, so read the version of the perl module providing it
exec(
"perl -MEmail::Outlook::Message -e 'print $Email::Outlook::Message::VERSION'",
(error, stdout) => {
if (error) {
console.error("msgconvert (libemail-outlook-message-perl) is not installed");
return;
}
2026-08-19 21:45:07 +02:00
if (stdout) {
console.log(`msgconvert v${stdout.split("\n")[0]}`);
}
},
);
exec("markitdown -v", (error, stdout) => {
if (error) {
console.error("markitdown is not installed");
return;
}
if (stdout) {
2026-10-06 17:45:45 +02:00
const ver = stdout.match(/([\d.]+)/)?.[1] || "unknown";
console.log(`markitdown v${ver}`);
}
});
console.log(`Bun v${Bun.version}`);
}