From 5ef8cec447a8d5d61c818f4ab34b59f914c1e327 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sat, 26 Sep 2020 23:51:00 +0800 Subject: [PATCH 1/3] Fix Terminal version rendering. --- backend/mirai-console/build.gradle.kts | 4 ++-- .../mirai/console/internal/MiraiConsoleBuildConstants.kt | 5 +++-- .../console/terminal/MiraiConsoleImplementationTerminal.kt | 4 +++- .../mirai/console/terminal/MiraiConsoleTerminalLoader.kt | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/mirai-console/build.gradle.kts b/backend/mirai-console/build.gradle.kts index 3bb13026b..4795a996c 100644 --- a/backend/mirai-console/build.gradle.kts +++ b/backend/mirai-console/build.gradle.kts @@ -100,8 +100,8 @@ tasks { })""" } .replace( - Regex("""val version: SemVersion = SemVersion.parse\(".*"\)""") - ) { """val version: SemVersion = SemVersion.parse("${project.version}")""" } + Regex("""const val versionConst:\s+String\s+=\s+".*"""") + ) { """const val versionConst: String = "${project.version}"""" } ) } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt index 95306d28e..b3abe5cbd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleBuildConstants.kt @@ -14,8 +14,9 @@ import java.time.Instant internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants) @JvmStatic - val buildDate: Instant = Instant.ofEpochSecond(1600663022) + val buildDate: Instant = Instant.ofEpochSecond(1601134282) + const val versionConst: String = "1.0-RC-dev-29" @JvmStatic - val version: SemVersion = SemVersion("1.0-RC-dev-28") + val version: SemVersion = SemVersion(versionConst) } diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt index c6d790a76..1cd89f853 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt @@ -151,7 +151,9 @@ val terminal: Terminal = run { private object ConsoleFrontEndDescImpl : MiraiConsoleFrontEndDescription { override val name: String get() = "Terminal" override val vendor: String get() = "Mamoe Technologies" - override val version: SemVersion = net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.version + // net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.version + // is console's version not frontend's version + override val version: SemVersion = SemVersion(net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.versionConst) } private val ANSI_RESET = Ansi().reset().toString() diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt index 2aa23e0b6..06bdaf650 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt @@ -59,7 +59,8 @@ object MiraiConsoleTerminalLoader { @ConsoleTerminalExperimentalApi fun printHelpMessage() { val help = listOf( - "" to "Mirai-Console[Terminal FrontEnd] v" + kotlin.runCatching { + "" to "Mirai-Console[Terminal FrontEnd] v" + net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.versionConst, + "" to " [ BackEnd] v" + kotlin.runCatching { net.mamoe.mirai.console.internal.MiraiConsoleBuildConstants.version }.getOrElse { "" }, "" to "", From 0d21ee4c1b7d1df1001f44cff13bc7b801e8ba43 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 27 Sep 2020 13:01:16 +0800 Subject: [PATCH 2/3] Fix stdout encoding --- .../mirai/console/terminal/MiraiConsoleTerminalLoader.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt index 06bdaf650..8436da087 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt @@ -172,14 +172,18 @@ internal fun overrideSTD() { PrintStream( BufferedOutputStream( logger = DefaultLogger("stdout").run { ({ line: String? -> info(line) }) } - ) + ), + false, + Charsets.UTF_8 ) ) System.setErr( PrintStream( BufferedOutputStream( logger = DefaultLogger("stderr").run { ({ line: String? -> warning(line) }) } - ) + ), + false, + Charsets.UTF_8 ) ) } From 7a2b6e721cb0a93d96565ef645a3e65c9dde9ae2 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 27 Sep 2020 13:16:45 +0800 Subject: [PATCH 3/3] Fix build --- .../mirai/console/terminal/MiraiConsoleTerminalLoader.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt index 8436da087..930e72b48 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleTerminalLoader.kt @@ -174,7 +174,7 @@ internal fun overrideSTD() { logger = DefaultLogger("stdout").run { ({ line: String? -> info(line) }) } ), false, - Charsets.UTF_8 + "UTF-8" ) ) System.setErr( @@ -183,7 +183,7 @@ internal fun overrideSTD() { logger = DefaultLogger("stderr").run { ({ line: String? -> warning(line) }) } ), false, - Charsets.UTF_8 + "UTF-8" ) ) }