mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Remove package.json references and client version
This commit is contained in:
@@ -10,7 +10,6 @@ RUN mvn -B package -DskipTests
|
||||
FROM eclipse-temurin:17-jre
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/target/imgfloat-*.jar app.jar
|
||||
COPY package.json ./
|
||||
EXPOSE 8080 8443
|
||||
ENV JAVA_OPTS=""
|
||||
ENTRYPOINT ["sh", "-c", "exec java ${JAVA_OPTS} -jar app.jar"]
|
||||
|
||||
3
Makefile
3
Makefile
@@ -19,9 +19,6 @@ RUNTIME_ENV = IMGFLOAT_ASSETS_PATH=$(IMGFLOAT_ASSETS_PATH) \
|
||||
SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE=$(SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE) \
|
||||
SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE=$(SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE)
|
||||
|
||||
node_modules: package-lock.json
|
||||
npm install
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
mvn compile
|
||||
|
||||
11
pom.xml
11
pom.xml
@@ -128,17 +128,6 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>package.json</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
|
||||
@@ -20,13 +20,11 @@ public class VersionService {
|
||||
private static final Pattern PACKAGE_VERSION_PATTERN = Pattern.compile("\"version\"\\s*:\\s*\"([^\"]+)\"");
|
||||
|
||||
private final String serverVersion;
|
||||
private final String clientVersion;
|
||||
private final String releaseVersion;
|
||||
|
||||
public VersionService() throws IOException {
|
||||
this.serverVersion = resolveServerVersion();
|
||||
this.clientVersion = resolveClientVersion();
|
||||
this.releaseVersion = normalizeReleaseVersion(this.clientVersion);
|
||||
this.releaseVersion = normalizeReleaseVersion(serverVersion);
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
@@ -143,22 +141,4 @@ public class VersionService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String resolveClientVersion() throws IOException {
|
||||
Path packageJsonPath = Paths.get("package.json");
|
||||
if (!Files.exists(packageJsonPath) || !Files.isRegularFile(packageJsonPath)) {
|
||||
throw new FileNotFoundException("package.json not found at " + packageJsonPath.toAbsolutePath());
|
||||
}
|
||||
|
||||
String packageJson = Files.readString(packageJsonPath, StandardCharsets.UTF_8);
|
||||
Matcher matcher = PACKAGE_VERSION_PATTERN.matcher(packageJson);
|
||||
if (matcher.find()) {
|
||||
String version = matcher.group(1);
|
||||
if (version != null && !version.isBlank()) {
|
||||
return version.trim();
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Version not found or invalid in package.json");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user