Add missing references

This commit is contained in:
2026-01-06 09:05:09 +01:00
parent 9eb102a96f
commit 3c8d85ebc2
4 changed files with 11 additions and 14 deletions

View File

@@ -2,6 +2,7 @@ package dev.kruhlmann.imgfloat.service;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileNotFoundException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -22,7 +23,7 @@ public class VersionService {
private final String clientVersion;
private final String releaseVersion;
public VersionService() {
public VersionService() throws IOException {
this.serverVersion = resolveServerVersion();
this.clientVersion = resolveClientVersion();
this.releaseVersion = normalizeReleaseVersion(this.clientVersion);
@@ -61,14 +62,6 @@ public class VersionService {
return "unknown";
}
private String resolveClientVersion() {
try {
return getPackageJsonVersion();
} catch (IOException e) {
throw new IllegalStateException("Client manifest is missing", e);
}
}
private String normalizeReleaseVersion(String baseVersion) throws IllegalStateException {
String normalized = baseVersion.trim();
normalized = normalized.replaceFirst("(?i)^v", "");
@@ -154,10 +147,10 @@ public class VersionService {
return null;
}
private String getPackageJsonVersion() throws IOException {
private String resolveClientVersion() throws IOException {
Path packageJsonPath = Paths.get("package.json");
if (!Files.exists(packageJsonPath) || !Files.isRegularFile(packageJsonPath)) {
return null;
throw new FileNotFoundException("package.json not found at " + packageJsonPath.toAbsolutePath());
}
String packageJson = Files.readString(packageJsonPath, StandardCharsets.UTF_8);
@@ -169,6 +162,6 @@ public class VersionService {
}
}
return null;
throw new IllegalStateException("Version not found or invalid in package.json");
}
}