From 1f44437d060d6b9329f09e1691666ef6b79534bf Mon Sep 17 00:00:00 2001 From: Aptivi CEO Date: Sat, 15 Feb 2025 23:16:16 +0300 Subject: [PATCH] add - Added support warning --- We've added a nonintrusive support warning message for release builds of Nitrocid KS when a release series of Nitrocid is nearing end of support. --- Type: add Breaking: False Doc Required: False Backport Required: False Part: 1/1 --- public/Nitrocid/Kernel/KernelEntry.cs | 3 ++ public/Nitrocid/Kernel/KernelReleaseInfo.cs | 31 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/public/Nitrocid/Kernel/KernelEntry.cs b/public/Nitrocid/Kernel/KernelEntry.cs index 6695f8be86..6997efe4b7 100644 --- a/public/Nitrocid/Kernel/KernelEntry.cs +++ b/public/Nitrocid/Kernel/KernelEntry.cs @@ -169,6 +169,9 @@ private static void MainLoop() // Show a tip telling users to see license information TextWriters.Write("* " + Translate.DoTranslation("Run 'license' to see the license information."), KernelColorType.Tip); + // Show another tip for release window + KernelReleaseInfo.NotifyReleaseSupportWindow(); + // Initialize shell DebugWriter.WriteDebug(DebugLevel.I, "Shell is being initialized."); ShellManager.StartShellInternal(ShellType.Shell); diff --git a/public/Nitrocid/Kernel/KernelReleaseInfo.cs b/public/Nitrocid/Kernel/KernelReleaseInfo.cs index bf59d2e64b..134e1a709e 100644 --- a/public/Nitrocid/Kernel/KernelReleaseInfo.cs +++ b/public/Nitrocid/Kernel/KernelReleaseInfo.cs @@ -17,11 +17,17 @@ // along with this program. If not, see . // +using Nitrocid.ConsoleBase.Colors; +using Nitrocid.ConsoleBase.Writers; +using Nitrocid.Kernel.Time; +using Nitrocid.Kernel.Time.Renderers; +using Nitrocid.Languages; +using System; + namespace Nitrocid.Kernel { internal static class KernelReleaseInfo { - // Release specifiers (SPECIFIER: REL, DEV, ALPHA, BETA, or RC | None satisfied: Unsupported Release) internal readonly static string ReleaseSpecifier = "" #if !SPECIFIERREL @@ -46,5 +52,28 @@ internal static class KernelReleaseInfo #endif ; + // Release support window info + internal readonly static DateTime supportWindow = new(2034, 3, 11); + internal readonly static bool supportWindowPrimed = +#if SPECIFIERREL + true; +#else + false; +#endif + + internal static void NotifyReleaseSupportWindow() + { + // Don't do anything if not primed yet + if (!supportWindowPrimed) + return; + + // Check to see if we're close to end of support window + var currentDate = TimeDateTools.KernelDateTime.Date; + var supportWindowWarn = supportWindow.Subtract(new TimeSpan(30, 0, 0, 0)); + if (currentDate >= supportWindowWarn && currentDate < supportWindow) + TextWriters.Write("* " + Translate.DoTranslation("We'll no longer support this version of Nitrocid KS after this date") + $": {TimeDateRenderers.RenderDate(supportWindow)}. " + Translate.DoTranslation("Make sure that you upgrade to the supported version soon if you want to continue receiving support."), KernelColorType.Warning); + else if (currentDate >= supportWindow) + TextWriters.Write("* " + Translate.DoTranslation("This version of Nitrocid KS is no longer supported.") + " " + Translate.DoTranslation("Make sure that you upgrade to the supported version soon if you want to continue receiving support."), KernelColorType.Warning); + } } }