mirror of
https://github.com/tale/headplane.git
synced 2026-07-26 07:48:14 +00:00
37 lines
800 B
TypeScript
37 lines
800 B
TypeScript
import type { HostInfo } from "~/types";
|
|
|
|
export function getTSVersion(host: HostInfo) {
|
|
const { IPNVersion } = host;
|
|
if (!IPNVersion) {
|
|
return "Unknown";
|
|
}
|
|
|
|
// IPNVersion is <Semver>-<something>-<something>
|
|
return IPNVersion.split("-")[0];
|
|
}
|
|
|
|
export function getOSInfo(host: HostInfo) {
|
|
const { OS, OSVersion } = host;
|
|
// OS follows runtime.GOOS but uses iOS and macOS instead of darwin
|
|
const formattedOS = formatOS(OS);
|
|
|
|
// Trim in case OSVersion is empty
|
|
return `${formattedOS} ${OSVersion ?? ""}`.trim();
|
|
}
|
|
|
|
function formatOS(os?: string) {
|
|
switch (os) {
|
|
case "macOS":
|
|
case "iOS":
|
|
return os;
|
|
case "windows":
|
|
return "Windows";
|
|
case "linux":
|
|
return "Linux";
|
|
case undefined:
|
|
return "Unknown";
|
|
default:
|
|
return os;
|
|
}
|
|
}
|