From 1eeac3ae973b62599bee0c37691810a2046227c2 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:08:02 +0200 Subject: [PATCH] fix: replace templates in Metadata class with placeholder data --- src/me/topchetoeu/jscript/Main.java | 20 +++++++++---------- src/me/topchetoeu/jscript/Metadata.java | 19 +++++++++++++++--- .../jscript/engine/debug/DebugServer.java | 8 ++++---- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/me/topchetoeu/jscript/Main.java b/src/me/topchetoeu/jscript/Main.java index 91baec7..abe8ba8 100644 --- a/src/me/topchetoeu/jscript/Main.java +++ b/src/me/topchetoeu/jscript/Main.java @@ -142,20 +142,18 @@ public class Main { Values.printError(e, "(while initializing TS)"); } } - private static void initReader() { + + public static void main(String args[]) { + System.out.println(String.format("Running %s v%s by %s", Metadata.name(), Metadata.version(), Metadata.author())); + + Main.args = args; var reader = new Thread(Main::reader); + + initEnv(); + initEngine(); + reader.setDaemon(true); reader.setName("STD Reader"); reader.start(); } - - public static void main(String args[]) { - System.out.println(String.format("Running %s v%s by %s", Metadata.NAME, Metadata.VERSION, Metadata.AUTHOR)); - - Main.args = args; - - initEnv(); - initEngine(); - initReader(); - } } diff --git a/src/me/topchetoeu/jscript/Metadata.java b/src/me/topchetoeu/jscript/Metadata.java index 5a0bf0b..05eefaf 100644 --- a/src/me/topchetoeu/jscript/Metadata.java +++ b/src/me/topchetoeu/jscript/Metadata.java @@ -1,7 +1,20 @@ package me.topchetoeu.jscript; public class Metadata { - public static final String VERSION = "${VERSION}"; - public static final String AUTHOR = "${AUTHOR}"; - public static final String NAME = "${NAME}"; + private static final String VERSION = "${VERSION}"; + private static final String AUTHOR = "${AUTHOR}"; + private static final String NAME = "${NAME}"; + + public static String version() { + if (VERSION.equals("$" + "{VERSION}")) return "1337-devel"; + else return VERSION; + } + public static String author() { + if (AUTHOR.equals("$" + "{AUTHOR}")) return "anonymous"; + else return AUTHOR; + } + public static String name() { + if (NAME.equals("$" + "{NAME}")) return "some-product"; + else return NAME; + } } diff --git a/src/me/topchetoeu/jscript/engine/debug/DebugServer.java b/src/me/topchetoeu/jscript/engine/debug/DebugServer.java index 5d7248a..3154ab6 100644 --- a/src/me/topchetoeu/jscript/engine/debug/DebugServer.java +++ b/src/me/topchetoeu/jscript/engine/debug/DebugServer.java @@ -19,7 +19,7 @@ import me.topchetoeu.jscript.json.JSONList; import me.topchetoeu.jscript.json.JSONMap; public class DebugServer { - public static String browserDisplayName = Metadata.NAME + "/" + Metadata.VERSION; + public static String browserDisplayName = Metadata.name() + "/" + Metadata.version(); public final HashMap targets = new HashMap<>(); @@ -236,9 +236,9 @@ public class DebugServer { this.protocol = getClass().getClassLoader().getResourceAsStream("assets/protocol.json").readAllBytes(); var index = new String(getClass().getClassLoader().getResourceAsStream("assets/index.html").readAllBytes()); this.index = index - .replace("${NAME}", Metadata.NAME) - .replace("${VERSION}", Metadata.VERSION) - .replace("${AUTHOR}", Metadata.AUTHOR) + .replace("${NAME}", Metadata.name()) + .replace("${VERSION}", Metadata.version()) + .replace("${AUTHOR}", Metadata.author()) .getBytes(); } catch (IOException e) { throw new UncheckedIOException(e); }