mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Fail fast and include pakcage.json
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -128,6 +128,17 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>${project.basedir}</directory>
|
||||||
|
<includes>
|
||||||
|
<include>package.json</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -62,12 +62,11 @@ public class VersionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String resolveClientVersion() {
|
private String resolveClientVersion() {
|
||||||
String packageJsonVersion = getPackageJsonVersion();
|
try {
|
||||||
if (packageJsonVersion != null && !packageJsonVersion.isBlank()) {
|
return getPackageJsonVersion();
|
||||||
return packageJsonVersion;
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException("Client manifest is missing", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String normalizeReleaseVersion(String baseVersion) {
|
private String normalizeReleaseVersion(String baseVersion) {
|
||||||
@@ -159,23 +158,19 @@ public class VersionService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPackageJsonVersion() {
|
private String getPackageJsonVersion() throws IOException {
|
||||||
Path packageJsonPath = Paths.get("package.json");
|
Path packageJsonPath = Paths.get("package.json");
|
||||||
if (!Files.exists(packageJsonPath) || !Files.isRegularFile(packageJsonPath)) {
|
if (!Files.exists(packageJsonPath) || !Files.isRegularFile(packageJsonPath)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
String packageJson = Files.readString(packageJsonPath, StandardCharsets.UTF_8);
|
||||||
String packageJson = Files.readString(packageJsonPath, StandardCharsets.UTF_8);
|
Matcher matcher = PACKAGE_VERSION_PATTERN.matcher(packageJson);
|
||||||
Matcher matcher = PACKAGE_VERSION_PATTERN.matcher(packageJson);
|
if (matcher.find()) {
|
||||||
if (matcher.find()) {
|
String version = matcher.group(1);
|
||||||
String version = matcher.group(1);
|
if (version != null && !version.isBlank()) {
|
||||||
if (version != null && !version.isBlank()) {
|
return version.trim();
|
||||||
return version.trim();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.warn("Unable to read version from package.json", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user